diff --git a/tgstation.dme b/tgstation.dme index a6cfdf18a82..edc62458eea 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6683,6 +6683,7 @@ #include "voidcrew\_DEFINES\bounty_ai.dm" #include "voidcrew\_DEFINES\bounty_board.dm" #include "voidcrew\_DEFINES\bounty_bosses.dm" +#include "voidcrew\_DEFINES\bounty_chrome.dm" #include "voidcrew\_DEFINES\bounty_criminals.dm" #include "voidcrew\_DEFINES\bounty_identity.dm" #include "voidcrew\_DEFINES\bounty_kingpin.dm" @@ -6695,6 +6696,7 @@ #include "voidcrew\_DEFINES\drug_smuggling.dm" #include "voidcrew\_DEFINES\dynamic_events.dm" #include "voidcrew\_DEFINES\flags.dm" +#include "voidcrew\_DEFINES\gorilla_gore.dm" #include "voidcrew\_DEFINES\gun_feel.dm" #include "voidcrew\_DEFINES\hud.dm" #include "voidcrew\_DEFINES\human_npcs.dm" @@ -6703,6 +6705,7 @@ #include "voidcrew\_DEFINES\lich.dm" #include "voidcrew\_DEFINES\lighting.dm" #include "voidcrew\_DEFINES\loot.dm" +#include "voidcrew\_DEFINES\mantis_gore.dm" #include "voidcrew\_DEFINES\maps.dm" #include "voidcrew\_DEFINES\maths.dm" #include "voidcrew\_DEFINES\metrics.dm" @@ -6925,6 +6928,7 @@ #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\carbon\floored_fall.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" @@ -7038,6 +7042,7 @@ #include "voidcrew\mapping\shuttles\syndicate\geneva.dm" #include "voidcrew\mapping\shuttles\syndicate\hyena.dm" #include "voidcrew\mapping\spawners\nanites.dm" +#include "voidcrew\modules\admin\chrome_test_kit.dm" #include "voidcrew\modules\admin\feature_testing.dm" #include "voidcrew\modules\admin\overmap_management.dm" #include "voidcrew\modules\admin\overmap_management_bans.dm" @@ -7110,6 +7115,8 @@ #include "voidcrew\modules\bounties\bounty_board.dm" #include "voidcrew\modules\bounties\bounty_boss.dm" #include "voidcrew\modules\bounties\bounty_boss_kits.dm" +#include "voidcrew\modules\bounties\bounty_chrome.dm" +#include "voidcrew\modules\bounties\bounty_combat_sense.dm" #include "voidcrew\modules\bounties\bounty_companions.dm" #include "voidcrew\modules\bounties\bounty_criminal.dm" #include "voidcrew\modules\bounties\bounty_identity.dm" @@ -7129,6 +7136,13 @@ #include "voidcrew\modules\bounties\bounty_turn_in.dm" #include "voidcrew\modules\bounties\bounty_types.dm" #include "voidcrew\modules\bounties\bounty_weapons.dm" +#include "voidcrew\modules\bounties\chrome\bounty_chrome_cascade.dm" +#include "voidcrew\modules\bounties\chrome\bounty_chrome_deadeye.dm" +#include "voidcrew\modules\bounties\chrome\bounty_chrome_gorilla.dm" +#include "voidcrew\modules\bounties\chrome\bounty_chrome_mantis.dm" +#include "voidcrew\modules\bounties\chrome\bounty_chrome_piledriver.dm" +#include "voidcrew\modules\bounties\chrome\bounty_chrome_redline.dm" +#include "voidcrew\modules\bounties\chrome\bounty_cyberpsycho.dm" #include "voidcrew\modules\captain_management\captain_management.dm" #include "voidcrew\modules\captain_management\command_transfer.dm" #include "voidcrew\modules\captain_management\ship_applications.dm" @@ -7187,24 +7201,44 @@ #include "voidcrew\modules\cryo\despawn.dm" #include "voidcrew\modules\cryo\machine.dm" #include "voidcrew\modules\cyberware\chrome_cradle.dm" +#include "voidcrew\modules\cyberware\chrome_hud.dm" +#include "voidcrew\modules\cyberware\chrome_wheel.dm" +#include "voidcrew\modules\cyberware\chrome_wheel_arms.dm" +#include "voidcrew\modules\cyberware\chrome_wheel_hud.dm" +#include "voidcrew\modules\cyberware\chrome_wheel_keybindings.dm" #include "voidcrew\modules\cyberware\cradle_ui.dm" +#include "voidcrew\modules\cyberware\cyberware_anim.dm" +#include "voidcrew\modules\cyberware\cyberware_anim2.dm" #include "voidcrew\modules\cyberware\cyberware_base.dm" #include "voidcrew\modules\cyberware\cyberware_component.dm" #include "voidcrew\modules\cyberware\cyberware_feedback.dm" #include "voidcrew\modules\cyberware\cyberware_salvage.dm" #include "voidcrew\modules\cyberware\cyberware_scan.dm" +#include "voidcrew\modules\cyberware\cyberware_scan_overlay.dm" #include "voidcrew\modules\cyberware\cyberware_stealth.dm" +#include "voidcrew\modules\cyberware\cyberware_zoom.dm" #include "voidcrew\modules\cyberware\parlor_fixtures.dm" #include "voidcrew\modules\cyberware\ripperdoc_catalog.dm" +#include "voidcrew\modules\cyberware\street_doc_catalog.dm" #include "voidcrew\modules\cyberware\ware_arm_utility.dm" #include "voidcrew\modules\cyberware\ware_legend.dm" +#include "voidcrew\modules\cyberware\ware_line_berserk.dm" +#include "voidcrew\modules\cyberware\ware_line_camo.dm" +#include "voidcrew\modules\cyberware\ware_line_governor.dm" +#include "voidcrew\modules\cyberware\ware_line_mantis.dm" +#include "voidcrew\modules\cyberware\ware_line_models_a.dm" +#include "voidcrew\modules\cyberware\ware_line_sandy.dm" +#include "voidcrew\modules\cyberware\ware_line_widowline.dm" +#include "voidcrew\modules\cyberware\ware_line_zoom.dm" #include "voidcrew\modules\cyberware\ware_military_arms.dm" #include "voidcrew\modules\cyberware\ware_military_body.dm" +#include "voidcrew\modules\cyberware\ware_models_b.dm" #include "voidcrew\modules\cyberware\ware_pro_combat.dm" #include "voidcrew\modules\cyberware\ware_pro_utility.dm" #include "voidcrew\modules\cyberware\ware_registry.dm" #include "voidcrew\modules\cyberware\ware_second_wind.dm" #include "voidcrew\modules\cyberware\ware_street.dm" +#include "voidcrew\modules\cyberware\ware_street_passives.dm" #include "voidcrew\modules\derelict_outposts\derelict_layout.dm" #include "voidcrew\modules\derelict_outposts\derelict_leash.dm" #include "voidcrew\modules\derelict_outposts\derelict_outpost.dm" @@ -7309,6 +7343,26 @@ #include "voidcrew\modules\hyperviolence\visuals\gut_motion.dm" #include "voidcrew\modules\hyperviolence\visuals\hit_reactions.dm" #include "voidcrew\modules\hyperviolence\visuals\npc_motion.dm" +#include "voidcrew\modules\hyperviolence\wire\_wire_defines.dm" +#include "voidcrew\modules\hyperviolence\wire\wire_cut.dm" +#include "voidcrew\modules\hyperviolence\wire\wire_garrote.dm" +#include "voidcrew\modules\hyperviolence\wire\wire_held.dm" +#include "voidcrew\modules\hyperviolence\wire\wire_seams.dm" +#include "voidcrew\modules\hyperviolence\wire\wire_sever_fx.dm" +#include "voidcrew\modules\hyperviolence\wire\wire_users.dm" +#include "voidcrew\modules\hyperviolence_gorilla\chrome_puppet_rig.dm" +#include "voidcrew\modules\hyperviolence_gorilla\chrome_use_release.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_finisher.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_haymaker.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_looks.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_pound.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_pry.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_punch.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_slam.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_swing.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_throw.dm" +#include "voidcrew\modules\hyperviolence_gorilla\gorilla_thrust.dm" +#include "voidcrew\modules\hyperviolence_gorilla\hv_finisher_chrome.dm" #include "voidcrew\modules\intents\_defines.dm" #include "voidcrew\modules\intents\hud_integration.dm" #include "voidcrew\modules\intents\hud_intent.dm" @@ -7359,6 +7413,16 @@ #include "voidcrew\modules\loot\uniques\research.dm" #include "voidcrew\modules\loot\uniques\syndicate.dm" #include "voidcrew\modules\loot\uniques\wardrobe.dm" +#include "voidcrew\modules\mantis_gore\mantis_blade.dm" +#include "voidcrew\modules\mantis_gore\mantis_charge.dm" +#include "voidcrew\modules\mantis_gore\mantis_core.dm" +#include "voidcrew\modules\mantis_gore\mantis_housing.dm" +#include "voidcrew\modules\mantis_gore\mantis_impale.dm" +#include "voidcrew\modules\mantis_gore\mantis_lunge_fx.dm" +#include "voidcrew\modules\mantis_gore\mantis_rig.dm" +#include "voidcrew\modules\mantis_gore\mantis_scissor.dm" +#include "voidcrew\modules\mantis_gore\mantis_swing.dm" +#include "voidcrew\modules\mantis_gore\mantis_wounds.dm" #include "voidcrew\modules\metrics\combat_metrics.dm" #include "voidcrew\modules\metrics\economy_metrics.dm" #include "voidcrew\modules\metrics\metrics_helpers.dm" @@ -7384,6 +7448,8 @@ #include "voidcrew\modules\missions\mission_pad.dm" #include "voidcrew\modules\missions\mission_target.dm" #include "voidcrew\modules\missions\player_bounty.dm" +#include "voidcrew\modules\missions\site_dressing.dm" +#include "voidcrew\modules\missions\spawn_cover.dm" #include "voidcrew\modules\missions\code\controllers\subsystem\missions.dm" #include "voidcrew\modules\missions\missions\big_game_hunt.dm" #include "voidcrew\modules\missions\missions\delivery.dm" @@ -7396,6 +7462,7 @@ #include "voidcrew\modules\missions\missions\recovery.dm" #include "voidcrew\modules\missions\missions\recovery_variants.dm" #include "voidcrew\modules\missions\missions\rescue.dm" +#include "voidcrew\modules\missions\missions\rescue_survivor.dm" #include "voidcrew\modules\missions\missions\research.dm" #include "voidcrew\modules\missions\missions\suppression.dm" #include "voidcrew\modules\missions\missions\survey.dm" @@ -7800,6 +7867,7 @@ #include "voidcrew\modules\throwing\diagnostics.dm" #include "voidcrew\modules\trade\anomaly_charts.dm" #include "voidcrew\modules\trade\bag_rift_protection.dm" +#include "voidcrew\modules\trade\buyback_listed.dm" #include "voidcrew\modules\trade\modsuit_bench.dm" #include "voidcrew\modules\trade\outpost.dm" #include "voidcrew\modules\trade\outpost_amenities.dm" diff --git a/tgui/packages/voidcrew_tgui/interfaces/ChromeCradle.tsx b/tgui/packages/voidcrew_tgui/interfaces/ChromeCradle.tsx index 57008cc670e..cf51c16a304 100644 --- a/tgui/packages/voidcrew_tgui/interfaces/ChromeCradle.tsx +++ b/tgui/packages/voidcrew_tgui/interfaces/ChromeCradle.tsx @@ -370,10 +370,7 @@ const Rack = () => { if (!has_occupant) { return ( -
- The rack is dark. Drag yourself onto the slab to lie back and it wakes - up. -
+
The rack is dark.
); } @@ -477,7 +474,7 @@ const TileCard = (props: { ware: Ware }) => {
- T{ware.tier} {TIER_NAMES[ware.tier] || 'CHROME'} + {TIER_NAMES[ware.tier] || 'CHROME'} load {ware.load} {ware.capacity_bonus > 0 && +{ware.capacity_bonus} cap} @@ -520,10 +517,7 @@ const Detail = () => { if (!ware) { return ( -
- Pick a piece from the rack. Anything you own shows up on the body before - the rig touches you. -
+
Nothing selected.
); } @@ -548,7 +542,7 @@ const Detail = () => {
- TIER {ware.tier} · {TIER_NAMES[ware.tier] || 'CHROME'} + {TIER_NAMES[ware.tier] || 'CHROME'} {ware.state === 'installed' @@ -603,7 +597,7 @@ const Detail = () => { )} {!!overCapacity && (
- No neural headroom. Shed load or find a Governor. + No neural headroom.
)}
@@ -614,7 +608,6 @@ const Detail = () => { act('remove', { ref: ware.ref })} > EXTRACT @@ -623,11 +616,7 @@ const Detail = () => { act('install', { ref: ware.ref })} > INSTALL @@ -776,10 +765,7 @@ const StatusDeck = () => { style={{ width: `${progress * 100}%` }} /> -
- Hold still. Leaving the slab cancels the cycle. Nothing is lost, the - ware goes to the tray. -
+
Hold still.
); } @@ -789,19 +775,13 @@ const StatusDeck = () => { notes.push('Trade embargo. The rig will not work on you.'); } if (!has_occupant) { - notes.push('The slab is empty. Drag yourself onto it to lie back.'); + notes.push('The slab is empty.'); } else if (!occupant_is_user) { - notes.push( - `${occupant_name} is on the slab. The rig takes orders from its occupant only. You can still pop the parts tray.`, - ); + notes.push(`${occupant_name} is on the slab.`); } else if (!can_operate) { - notes.push( - 'The rig refuses: you have to be conscious and unrestrained to consent to chrome work.', - ); + notes.push('The rig needs you awake and free to say yes.'); } else { - notes.push( - 'Rig idle. Highlight a piece in the rack, check it on the body, then commit.', - ); + notes.push('Rig idle.'); } if (tray_count > 0) { notes.push( @@ -841,10 +821,7 @@ const Controls = () => { act('tuneup')} > {`TUNE-UP · ${tuneup_fee} CR`} @@ -852,7 +829,6 @@ const Controls = () => { act('eject_tray')} > {`EJECT TRAY${tray_count > 0 ? ` · ${tray_count}` : ''}`} @@ -860,7 +836,6 @@ const Controls = () => { act('eject_cash')} > EJECT CASH @@ -868,7 +843,6 @@ const Controls = () => { act('get_up')} > {occupant_is_user ? 'GET UP' : 'UNBUCKLE'} diff --git a/tools/gear_catalog/ratings/ammo.json b/tools/gear_catalog/ratings/ammo.json index 4cb6dcb603c..6d7ae0e45a1 100644 --- a/tools/gear_catalog/ratings/ammo.json +++ b/tools/gear_catalog/ratings/ammo.json @@ -342,6 +342,15 @@ "reason": "Built into the peashooter, never on its own. Rated with the gun.", "tier": "green" }, + "/obj/item/ammo_box/magazine/internal/cylinder/rev38/cyberware_holdout": { + "confidence": "high", + "group": "magazines built into a gun", + "hash": "", + "name": "holdout cylinder", + "rank": 8, + "reason": "Built into the Holdout revolver arm, never on its own. Rated with the gun.", + "tier": "yellow" + }, "/obj/item/ammo_box/magazine/internal/cylinder/rev38/housecall": { "confidence": "high", "group": "magazines built into a gun", diff --git a/tools/gear_catalog/ratings/cyberware.json b/tools/gear_catalog/ratings/cyberware.json index f4c5b57f0ea..f6116cd316f 100644 --- a/tools/gear_catalog/ratings/cyberware.json +++ b/tools/gear_catalog/ratings/cyberware.json @@ -19,7 +19,7 @@ "hash": "c229d282cf893570", "name": "Strong-Arm empowered musculature implant", "note": "Humans only. With the implanted arm active, an empty-hand combat-mode left-click on a mob becomes a slam on a 5 s cooldown: the hand's unarmed damage roll plus 5 (plus 20 more against beast, special and mining mobs), doubled and run through melee armor, and the target is thrown 1 tile if the wearer is standing; it is not used while Hulk. One implant in each arm lets the wearer pry closed airlocks open bare-handed (6 s, instant if unpowered, refused if bolted or welded). An EMP puts the arm down for 9 s (4.5 s on a light pulse): slams fail, and half the time the wearer lunges onto the target and falls for 3 s, otherwise is paralyzed for 1 s.", - "rank": 6, + "rank": 14, "reason": "A slam for 20 to 30 damage every 5 s per arm, 60 to 70 against mining mobs and beasts, and a pair pries powered airlocks in 6 s. 1,200 cr for two from cargo. EMP makes the arm a liability for 9 s.", "tier": "yellow" }, @@ -28,7 +28,7 @@ "group": "Work tools", "hash": "5b81131a4a10a42c", "name": "Harpoon Spool", - "rank": 6, + "rank": 9, "reason": "Pulls a loose item or small creature to you from 6 tiles every 8 s, anything bigger drags you a tile. Can grab a dropped gun, little else. Load 2, 2,800 cr.", "tier": "green" }, @@ -37,7 +37,7 @@ "group": "Arm weapons and fists", "hash": "31fd669dadf0cf4c", "name": "Bunker Buster housing", - "rank": 5, + "rank": 10, "reason": "Two 60-damage rockets that floor the target and wreck doors and machines with no blast, about 10 on the gun score plus breaching. Two hands, two shots, then 600 cr at reputation 22 or late research. Loot only.", "tier": "yellow" }, @@ -51,6 +51,15 @@ "reason": "Every timed action takes 25% less time, surgery, welding, cuffing and repairs alike, plus a driver, wrench and cutters in the arm. Worth a slot for medics and engineers. Load 2, 1,800 cr.", "tier": "yellow" }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street": { + "confidence": "medium", + "group": "Work tools", + "hash": "", + "name": "Tinker's fingers", + "rank": 3, + "reason": "A driver, wrench and cutters in the arm, and every timed action 10% faster. The Fixer's Fingers at a tenth of the stack: load 1, 700 cr. Splice takes a pulled set back for 350 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/arm/toolkit/cyberware/graverobber": { "confidence": "medium", "group": "Scouting and sight", @@ -66,7 +75,7 @@ "group": "Hacking and ship control", "hash": "52911504b95eb634", "name": "Icepick Jack", - "rank": 1, + "rank": 4, "reason": "Knocks hostile turrets out for 15 s, turns them for 10 s, and forces bolted or unpowered doors in 6 s. A boarding crew's key to player hulls, though jacking their turrets sets off an alarm. Load 3, 1 voucher.", "tier": "yellow" }, @@ -75,8 +84,8 @@ "group": "Arm weapons and fists", "hash": "b190c2719a5d40f7", "name": "Mantis Blade housing (right)", - "note": "Each housing extends a hardlight blade into the hand (it can't be dropped; retract stows it). An ability, usable from either housing with its blade out, dashes up to 5 tiles to a living target after a 0.3 s wind-up, lands 10 brute (armor applies, wounding) per extended blade on arrival and floors the target for 2 s. The 20 s cooldown is shared by both housings and is spent even if the dash falls short.", - "rank": 2, + "note": "Each housing extends a hardlight blade into the hand (it can't be dropped; retract stows it). An ability, usable from either housing with its blade out, dashes up to 5 tiles to a living target after a 0.3 s wind-up, lands 10 brute (armor applies, wounding) per extended blade on arrival and floors the target for 2 s; held as a rooted, telegraphed crouch (broken by one 10-damage hit or a stun, costing the full cooldown) it leaps up to 7 tiles. The dash never crosses chasms, lava or space. The 20 s cooldown is shared by both housings and is spent even if the dash falls short; a credited kill of a person or anything with 100+ max health drops it to 3 s, at most once per 8 s, once per body per 2 min. Gore (D31): 3 cuts on one limb within 8 s (5 under cover 15-34, never at 35+) tear its artery; with both blades out every 3rd cut adds a 10 brute follow-through and a 1.5 s stagger; a two-blade lunge into someone at 70% health or down holds them 0.8 s (1.5 s against a wall) and rips out for 2x8 brute; a head swing at someone in crit takes the head off after a 1.2 s interruptible wind-up (Atlas: 25 brute instead).", + "rank": 5, "reason": "Half of a pair: 20-force blades that can't be disarmed, plus a 5-tile lunge every 20 s that adds 20 damage and floors the target for 2 s. Load 6 the pair, 4 vouchers at reputation 22, one on the shelf per round.", "tier": "red" }, @@ -85,45 +94,113 @@ "group": "Arm weapons and fists", "hash": "91733b8b4ac9435a", "name": "Mantis Blade housing (left)", - "note": "Each housing extends a hardlight blade into the hand (it can't be dropped; retract stows it). An ability, usable from either housing with its blade out, dashes up to 5 tiles to a living target after a 0.3 s wind-up, lands 10 brute (armor applies, wounding) per extended blade on arrival and floors the target for 2 s. The 20 s cooldown is shared by both housings and is spent even if the dash falls short.", - "rank": 3, + "note": "Each housing extends a hardlight blade into the hand (it can't be dropped; retract stows it). An ability, usable from either housing with its blade out, dashes up to 5 tiles to a living target after a 0.3 s wind-up, lands 10 brute (armor applies, wounding) per extended blade on arrival and floors the target for 2 s; held as a rooted, telegraphed crouch (broken by one 10-damage hit or a stun, costing the full cooldown) it leaps up to 7 tiles. The dash never crosses chasms, lava or space. The 20 s cooldown is shared by both housings and is spent even if the dash falls short; a credited kill of a person or anything with 100+ max health drops it to 3 s, at most once per 8 s, once per body per 2 min. Gore (D31): 3 cuts on one limb within 8 s (5 under cover 15-34, never at 35+) tear its artery; with both blades out every 3rd cut adds a 10 brute follow-through and a 1.5 s stagger; a two-blade lunge into someone at 70% health or down holds them 0.8 s (1.5 s against a wall) and rips out for 2x8 brute; a head swing at someone in crit takes the head off after a 1.2 s interruptible wind-up (Atlas: 25 brute instead).", + "rank": 6, "reason": "Left half of the Mantis pair: 20-force blades that can't be disarmed, plus a 5-tile lunge every 20 s that adds 20 damage and floors the target for 2 s.", "tier": "red" }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Scorch Blade housing (right)", + "note": "Each landed cut adds 2 fire stacks and sets the target alight; the lunge adds 4 once, however many blades arrive. Corpses are left alone and the wearer is never lit. The blade is lit while out. Its torn arteries are seared half shut (2 flow, clotting) instead of the Mantis's 3.5 that never clots; otherwise the Mantis lunge, leap, kill reset, impale, X-slash and scissor.", + "rank": 3, + "reason": "Half of a pair: the Mantis blades and lunge, with every cut and the lunge setting the target alight. Load 8 the pair, 4 vouchers at reputation 22, one on the shelf per round.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Scorch Blade housing (left)", + "note": "Each landed cut adds 2 fire stacks and sets the target alight; the lunge adds 4 once, however many blades arrive. Corpses are left alone and the wearer is never lit. The blade is lit while out. Its torn arteries are seared half shut (2 flow, clotting) instead of the Mantis's 3.5 that never clots; otherwise the Mantis lunge, leap, kill reset, impale, X-slash and scissor.", + "rank": 4, + "reason": "Left half of the Scorch pair: the Mantis blades and lunge, with every cut and the lunge setting the target alight.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Shiv Blade housing (right)", + "note": "No lunge, and none of the Mantis gore moves: its cuts bleed like any knife (no torn arteries, X-slash, impale or scissor).", + "rank": 15, + "reason": "Half of a pair: 14-force blades that can't be disarmed, no lunge. Load 4 the pair, 2,400 cr at yellow reputation. Splice takes a pulled housing back for 600 cr.", + "tier": "yellow" + }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/left": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Shiv Blade housing (left)", + "note": "No lunge, and none of the Mantis gore moves: its cuts bleed like any knife (no torn arteries, X-slash, impale or scissor).", + "rank": 16, + "reason": "Left half of the Shiv pair: 14-force blades that can't be disarmed, no lunge.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire": { "confidence": "high", "group": "Arm weapons and fists", "hash": "174a6ea665db7cac", "name": "Widowline spool housing", - "rank": 1, + "rank": 2, "reason": "20 damage a swing (15 brute, 5 burn) straight through all armor, reach 2, and it cuts neighbours for 75%. The best melee against armored crews, useless on walls and doors. Load 5, 3 vouchers at reputation 22, one on the shelf per round.", "tier": "red" }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Widowline Arc spool housing", + "note": "The Widowline wire with a shock on every landed hit. A living target takes 5 more burn and a 2 s stagger (stacking to 4 s) unless it is shock immune or its suit is insulated; gloves do not matter. Silicons, mechs and robotic mobs take 25 more burn. A hit on a turret, ship laser turret, console or camera knocks it out for 5 s, once per 15 s per wire; outpost property is immune. The cleave does not shock. Its garrote always takes the head off, not only in hard crit; an Atlas frame, a sealed helmet, an armoured collar or plating still stops it. A wire pair counts as Arc if either wire is.", + "rank": 1, + "reason": "The Widowline's 20 a swing through all armor and reach 2, plus 5 burn and a stagger on the target, 25 extra burn on robots and mechs, and a turret or console shorted out for 5 s, and a garrote that always beheads. Load 6, 5 vouchers at reputation 22, one on the shelf per round.", + "tier": "red" + }, "/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw": { "confidence": "high", "group": "Work tools", "hash": "29ec5344a41717f9", "name": "Rockjaw drill fist", "note": "Folds a mining drill out of the forearm. While the drill is out, ore from any rock the wearer cracks (with any tool) is swept 0.2 s later into an internal hopper with no size limit in the code instead of landing on the floor; a second button dumps the hopper at the wearer's feet. Sweeping is off during an EMP reboot, and the hopper's contents drop if the arm ware is destroyed.", - "rank": 5, + "rank": 7, "reason": "A mining drill in the forearm with a bottomless ore hopper. A miner's bag and pick in one arm slot. Load 2, 1,200 cr.", "tier": "green" }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore": { + "confidence": "medium", + "group": "Work tools", + "hash": "", + "name": "Deepcore drill fist", + "rank": 6, + "reason": "The Rockjaw's ore hopper on a faster drill, between the Rockjaw drill and a diamond drill. Load 3, 2,400 cr. Splice takes a pulled one back for 1,200 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin": { "confidence": "medium", "group": "Arm weapons and fists", "hash": "43903115df46709c", "name": "Popup Ronin housing", - "rank": 4, + "rank": 9, "reason": "A one-handed machine pistol in the arm that can't be disarmed: 20 damage, 3.3 shots a second, about a WT-550 on the gun score (47). 20-round magazines are 250 cr at reputation 22 or late research. Loot only.", "tier": "yellow" }, + "/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Holdout housing", + "rank": 11, + "reason": "A .38 revolver in the arm that can't be disarmed: 25 damage, six shots, about 2.5 a second, reloaded by hand a round at a time with ordinary .38. Load 3, 2,400 cr at reputation 4. Splice takes a pulled housing back for 1,200 cr.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/arm/toolkit/cyberware/skyhook": { "confidence": "high", "group": "Mobility and stealth", "hash": "d2c5b721e44bd009", "name": "Skyhook wrist winch", - "rank": 3, + "rank": 4, "reason": "Fires a line at any wall or anchored structure within 7 tiles and hauls you there, every 8 s. Real chase and escape mobility, at the cost of an arm slot. Load 3, loot only.", "tier": "yellow" }, @@ -132,7 +209,7 @@ "group": "Work tools", "hash": "4a6c47ce239cc051", "name": "integrated paperwork implant", - "rank": 7, + "rank": 11, "reason": "A pen, clipboard, lighter and laser pointer in your arm. Harmless.", "tier": "none" }, @@ -141,7 +218,7 @@ "group": "Work tools", "hash": "6e21944c25437900", "name": "surgical toolset implant", - "rank": 3, + "rank": 4, "reason": "A surgical kit in your arm. Saves carrying the tools. Late printing.", "tier": "green" }, @@ -150,7 +227,7 @@ "group": "Work tools", "hash": "2ffcab76bdd48728", "name": "morbid surgical toolset implant", - "rank": 4, + "rank": 5, "reason": "The surgical arm rebuilt for looks and a nasty mood. Same job as the plain one.", "tier": "green" }, @@ -169,7 +246,7 @@ "hash": "095577f719c51add", "name": "anti-drop implant", "note": "A toggle button: switching it on makes whatever is in the wearer's hands at that moment undroppable (stuns and disarms don't release it) until the button is pressed again or the item leaves the hand; items picked up afterwards are not locked. An EMP releases it and flings the held items up to 10 tiles in random directions, and as with every brain implant any EMP also stuns the wearer for 20 s (10 s on a light pulse).", - "rank": 6, + "rank": 8, "reason": "Locks what's in your hands so stuns and disarms can't take it. Same job as Gecko Grip at about 24 cr of material, but any EMP stuns you for 20 s and flings the item.", "tier": "green" }, @@ -179,7 +256,7 @@ "hash": "8ae45008ffefef4e", "name": "CNS rebooter implant", "note": "1 s after the wearer gains a stun, immobilize, paralysis or stamina crit it clears stun, knockdown, immobilize, paralysis and all stamina damage, then grants stun immunity, baton resistance and immunity to damage slowdown for 6 s (stamina is zeroed again at the end). Then locks out for 60 s. An EMP takes it offline for 9 s (4.5 s on a light pulse), and as with every brain implant also stuns the wearer for 20 s (10 s light).", - "rank": 2, + "rank": 3, "reason": "Once a minute a stun is cleared after 1 s, stamina resets, and you get 6 s of stun immunity. Undoes the first stun of a fight for one neural load. Any EMP stuns the wearer for 20 s and takes it offline for 9 s.", "tier": "yellow" }, @@ -189,7 +266,7 @@ "hash": "df0fb0f149203f80", "name": "CNS skillchip connector implant", "note": "Lets the wearer put a skillchip in or take one out without surgery: a 1.5 s action, inserting the chip in the active hand or, with an empty hand, choosing an installed chip from a radial menu. An EMP knocks installed chips onto the floor (one on a light pulse, two on a heavy one), and as with every brain implant stuns the wearer for 20 s (10 s light). With no chip installed the handler indexes the first chip of an empty or null list and its brain-damage branch is called without a brain, so it may error out before the reboot timer starts (unconfirmed).", - "rank": 7, + "rank": 8, "reason": "Swap skillchips without surgery. Skillchips do almost nothing, and any EMP stuns you for 20 s.", "tier": "none" }, @@ -199,7 +276,7 @@ "hash": "5bc666bd0e7ad39e", "name": "nutriment pump implant", "note": "While the wearer's nutrition is at or below 150 (250 for the PLUS version) it adds about 50 nutrition, then waits 5 s before it can do so again, which stops nutrition falling below that line. An EMP pushes bad-food toxin into the blood (5 units on a heavy pulse, 10 on the PLUS version).", - "rank": 5, + "rank": 6, "reason": "Keeps you just above starving. Removes the need for a kitchen for one neural load.", "tier": "green" }, @@ -209,7 +286,7 @@ "hash": "ce113e10a6c8deab", "name": "nutriment pump implant PLUS", "note": "While the wearer's nutrition is at or below 150 (250 for the PLUS version) it adds about 50 nutrition, then waits 5 s before it can do so again, which stops nutrition falling below that line. An EMP pushes bad-food toxin into the blood (5 units on a heavy pulse, 10 on the PLUS version).", - "rank": 4, + "rank": 5, "reason": "Keeps you fed before you get hungry. Removes food from a six-hour round for one neural load.", "tier": "green" }, @@ -229,7 +306,7 @@ "hash": "14f4a2c2517247c0", "name": "Herculean gravitronic spinal implant", "note": "Cuts the wearer's climbing, ladder, gym-machine, table-carry and vent-boulder lifting times to 80%, adds +1 speed and +4 range to everything they throw, adds 4 to tackle strength and lets them break boulders off a discovered ore vent with bare hands. An EMP deals 20 brute (10 light) to the chest. A gravity anomaly core can be slotted in to change it into the Atlas variant.", - "rank": 6, + "rank": 9, "reason": "Faster climbing, throws fly farther and faster, tackles hit harder, and you can break boulders off ore vents by hand. Nothing here wins a fight. About 85 cr of material.", "tier": "green" }, @@ -239,20 +316,40 @@ "hash": "ffff4012788ccee2", "name": "implantable thrusters set", "note": "A toggle that lets the wearer move under their own power in zero gravity, with a movement-speed bonus while floating and no stabilization, so they keep drifting when they stop. It draws on ambient air above 30 kPa for free, otherwise internals gas or the wearer's plasma store, and turns itself off if neither is available.", - "rank": 5, + "rank": 7, "reason": "A jetpack in your chest with no back slot used, and a speed bonus while floating. Free air when there's pressure, otherwise your tank. About 74 cr of material after 200 research points.", "tier": "green" }, + "/obj/item/organ/cyberimp/cyberware/adrenal_pump": { + "confidence": "medium", + "group": "Nerves and stuns", + "hash": "", + "name": "Adrenal pump", + "note": "When a stamina update leaves a conscious wearer at 70 or more stamina loss and the pump is ready, one tick later it takes 40 off, speeds the wearer up (movement -0.4) and tints them red for 3 s, and plays a loud heartbeat. It then waits 4 minutes; the wait is stored as a ready-at time on the organ, so a refit does not reset it. It ignores the stamina dumped by the Cascade and Redline crashes. It takes the spare heart slot, so it evicts the Clotter node, and goes off during an EMP reboot or brownout.", + "rank": 5, + "reason": "Once every 4 minutes a bad run of stamina damage is cut by 40 and the wearer gets 3 s of extra speed, enough to stay out of a stamina crit for one more volley. Load 2, 2,400 cr at reputation 4.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/cyberware/atlas": { "confidence": "medium", "group": "Armor and frame", "hash": "0a8132740babf01b", "name": "Atlas frame", "note": "Bones can't be broken (no dislocations or fractures) and limbs can't be dismembered; slashes, punctures, burns and bleeding still land normally. Items and mobs the wearer throws get +2 tiles of range and +1 speed, and any throw of the wearer by something else travels half as far. All of it drops during an EMP reboot or over-capacity brownout.", - "rank": 3, + "rank": 4, "reason": "No broken bones and no lost limbs, thrown things fly farther and you get thrown half as far. Slashes, burns and bleeding still land. Load 4, 2 vouchers at reputation 22.", "tier": "yellow" }, + "/obj/item/organ/cyberimp/cyberware/atlas/street": { + "confidence": "medium", + "group": "Armor and frame", + "hash": "", + "name": "Strut frame", + "note": "Bone wounds (dislocations, hairline and compound fractures) are refused while the ware is online; nothing else. Limbs can still be dismembered, throws are not boosted and the wearer's own knockback is not reduced. Drops during an EMP reboot or over-capacity brownout.", + "rank": 8, + "reason": "Bones can't break: no dislocations or fractures. Limbs still come off, and slashes, burns and bleeding land as usual. None of the Atlas Frame's throw boost or knockback cut. Load 2, 1,500 cr at reputation 4.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/cyberware/cargo_cavity": { "confidence": "high", "group": "Body upkeep", @@ -265,32 +362,80 @@ "/obj/item/organ/cyberimp/cyberware/cascade": { "confidence": "high", "group": "Operating system", - "hash": "875de17ed8afaa7f", + "hash": "", "name": "Cascade lattice", "rank": 1, - "reason": "Eight seconds a minute at about double speed, melee twice as fast and 40% dodge while moving, then six seconds of crash and 80 stamina. Load 12 of 20, 8 vouchers at reputation 22. An EMP mid-burst ends it.", + "reason": "Eight seconds a minute at about double speed, melee twice as fast, 60% dodge against blows (and shots while moving) and a bigger crit roll on its own hits, then six seconds of crash and 80 stamina. Load 12 of 20, 8 vouchers at reputation 22. An EMP mid-burst ends it.", "tier": "red" }, + "/obj/item/organ/cyberimp/cyberware/cascade/milspec": { + "confidence": "medium", + "group": "Operating system", + "hash": "", + "name": "Service reflex lattice", + "rank": 4, + "reason": "Seven seconds in every 90 at close to the lattice's speed, melee 40% quicker, 45% dodge against blows (and shots while moving) and a bigger crit roll on its own hits, then seven seconds of crash and 90 stamina. Load 9, 4 vouchers at reputation 11. An EMP mid-burst ends it.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/cyberware/cascade/street": { + "confidence": "medium", + "group": "Operating system", + "hash": "", + "name": "Spliced reflex rig", + "rank": 7, + "reason": "Six seconds in every 120 at a clear speed boost, melee a quarter quicker, 30% dodge against blows (and shots while moving) and a small crit roll bonus on its own hits, then eight seconds of crash and 90 stamina. A short window on a long cooldown keeps it below the service lattice. Load 6, 3,600 cr at reputation 4. An EMP mid-burst ends it.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/cyberware/chromatic_dermis": { "confidence": "high", "group": "Body upkeep", "hash": "ec8cfbbd975a51eb", "name": "Chromatic Dermis ink suite", "note": "Cosmetic only: draws a glowing outline of the chosen colour and pattern around the wearer that flares when they take damage, swing, use a chrome ability or when other chrome acts, dims when they are hungry, and goes dark while the ware is down. No mechanical effect.", - "rank": 8, + "rank": 9, "reason": "Glowing tattoos with no other effect. Load 0, 400 cr.", "tier": "none" }, + "/obj/item/organ/cyberimp/cyberware/clotter_node": { + "confidence": "medium", + "group": "Body upkeep", + "hash": "", + "name": "Clotter node", + "note": "While online, multiplies the blood a human wearer loses by 0.5, on life ticks and flat bleeds alike. It stacks multiplicatively with other bleed reducers and goes off during an EMP reboot or over-capacity brownout. It takes the spare heart slot, so it evicts the Adrenal pump.", + "rank": 3, + "reason": "Halves the blood lost to wounds. It buys a bleeding crew member time between medic visits and does nothing against burst damage. Load 1, 900 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/cyberware/coolant": { "confidence": "medium", "group": "Armor and frame", "hash": "4ceed965097294a4", "name": "Coolant Loop lattice", - "note": "While the ware is online the wearer takes no damage from overheating (hot air or body temperature), takes half burn damage (humans only), and loses 1 fire stack per second. It does not stop fire: a burning wearer is still burned at half strength. All three drop during an EMP reboot or over-capacity brownout.", + "note": "While the ware is online the wearer takes no damage from overheating (hot air or body temperature), takes half burn damage (humans only), and loses 1 fire stack per second. Fire on a human only does harm through body heat, which the ware blocks, so a burning wearer loses clothes but takes no burn from the flames; burn dealt outright (lasers) lands at half. All three drop during an EMP reboot or over-capacity brownout.", "rank": 2, "reason": "Halves all burn damage on top of armor, lasers included, plus no heat damage and fire burns off fast. Half of every beam in the game for load 3. Bullets and blades ignore it. 3,600 cr with no reputation.", "tier": "red" }, + "/obj/item/organ/cyberimp/cyberware/coolant/street": { + "confidence": "medium", + "group": "Armor and frame", + "hash": "", + "name": "Heat-sink lining", + "note": "While the ware is online the wearer takes no damage from overheating (hot air or body temperature) and loses 1 fire stack per second. It does not reduce burn damage dealt outright (lasers land at full strength), but fire on a human only does harm through body heat, which the ware blocks, so a burning wearer loses clothes and takes no burn from the flames. Both drop during an EMP reboot or over-capacity brownout.", + "rank": 9, + "reason": "No heat damage from hot air or lava country, and being set alight burns only your clothes, but laser burns land at full strength. The heat half of the Coolant Loops for load 1, 1,500 cr.", + "tier": "green" + }, + "/obj/item/organ/cyberimp/cyberware/cuffer_wrists": { + "confidence": "medium", + "group": "Work tools", + "hash": "", + "name": "Cuffer's wrists", + "note": "While online, handcuffing takes 75% of the usual time, the trait combat and insulated gloves also give. It takes the hands slot, so it evicts the Gecko Grip and the Medic's palms.", + "rank": 10, + "reason": "Cuffs go on in three quarters of the time with no glove needed. A small edge for bounty hunters and boarders. Load 1, 500 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/cyberware/dead_channel": { "confidence": "medium", "group": "Nerves and stuns", @@ -304,11 +449,21 @@ "/obj/item/organ/cyberimp/cyberware/dermal_mesh": { "confidence": "high", "group": "Armor and frame", - "hash": "5b60dbb7a15c8084", + "hash": "", "name": "Dermal Mesh weave", - "note": "While online, adds physiology armor to a human wearer: melee 15, bullet 15, laser 10, wound 5. The armor is removed during an EMP reboot or an over-capacity brownout.", - "rank": 4, - "reason": "15 melee, 15 bullet, 10 laser on the whole body, on top of whatever you wear. A clear step up for load 2 and 2,000 cr. EMP switches it off for 9 s.", + "note": "While online, adds physiology armor to a human wearer: melee 15, bullet 15, laser 10, wound 5. Bullets and buckshot pellets from the front glance off at 15% (each pellet rolls on its own), keep flying at reduced damage and cost the wearer 5 stamina each. Never lasers, energy, melee or shots into the back. Shares the dodge arbiter: dodge plus glance never stop more than 60% of shots. The armor and the glance are off during an EMP reboot or an over-capacity brownout.", + "rank": 5, + "reason": "15 melee, 15 bullet, 10 laser on the whole body, on top of whatever you wear, and one bullet in seven from the front glances off. A clear step up for load 2 and 2,000 cr. EMP switches it off for 9 s.", + "tier": "yellow" + }, + "/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave": { + "confidence": "medium", + "group": "Armor and frame", + "hash": "", + "name": "Hardweave plating", + "note": "While online, adds physiology armor to a human wearer: melee 20, bullet 20, laser 15, energy 10, wound 10. Bullets and buckshot pellets from the front glance off at 30% (each pellet rolls on its own), keep flying at reduced damage and cost the wearer 5 stamina each. Never lasers, energy, melee or shots into the back. Shares the dodge arbiter: dodge plus glance never stop more than 60% of shots. The armor and the glance are off during an EMP reboot or an over-capacity brownout.", + "rank": 3, + "reason": "20 melee, 20 bullet, 15 laser, 10 energy and 10 wound armor on the whole body, on top of whatever you wear, and nearly a third of bullets from the front glance off. A size up from the Mesh and well short of the Slabskin Plate, which adds bomb, fire, acid and a bigger glance. Load 3, 3,000 cr at reputation 4. Strong for yellow against gunfire from the front, still useless against lasers and flanking. EMP switches it off for 9 s.", "tier": "yellow" }, "/obj/item/organ/cyberimp/cyberware/doppler": { @@ -321,13 +476,33 @@ "reason": "Anything alive and moving within 9 tiles shows through walls, without taking your eye slot. Standing still hides you and the ping is audible. Thermals' little brother. Load 2, 1 voucher.", "tier": "yellow" }, + "/obj/item/organ/cyberimp/cyberware/doppler/street": { + "confidence": "medium", + "group": "Scouting and sight", + "hash": "", + "name": "Thumper ear", + "note": "A toggle: while on, living mobs within 5 tiles on the wearer's level that are moving show as blips through walls on the wearer's HUD, each lasting 3 s after its last step so standing still drops off the display; machines never show. It plays a sonar ping at the wearer on every life tick while any mover is tracked, louder than the Heartbeat Doppler's and doubled within 3 tiles, so nearby players can hear it.", + "rank": 3, + "reason": "Anything alive and moving within 5 tiles shows through walls for a moment after each step, without taking your eye slot. Standing still hides you and the ping carries. A shorter, louder Heartbeat Doppler. Load 1, 1,500 cr at reputation 4.", + "tier": "yellow" + }, + "/obj/item/organ/cyberimp/cyberware/frostline": { + "confidence": "medium", + "group": "Armor and frame", + "hash": "", + "name": "Frostline lining", + "note": "While the ware is online the wearer takes no damage from cold air or body temperature. It does nothing for pressure, breathing or burns. The trait drops during an EMP reboot or over-capacity brownout.", + "rank": 10, + "reason": "No cold damage on ice planets and in the cold of space, but low pressure and no air still kill. Shares the seal slot with every air and heat lining, so it never sits beside a bladder. Load 1, 1,500 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/cyberware/gastro": { "confidence": "high", "group": "Body upkeep", "hash": "26dc92f22c6385f6", "name": "Gastro Reactor", "note": "The wearer eats 35% faster, food that is contaminated (for example dropped on the floor) gives no infection or disgust mood, vomiting costs half the nutrition, everything they eat counts as 6 points higher quality (lifting rotten or gross food above the disgust line, though species-toxic food stays toxic) and disgust drains away at 3 per second. Off during an EMP reboot or over-capacity brownout.", - "rank": 6, + "rank": 7, "reason": "Eat anything, eat faster, no food poisoning. No bearing on a fight. Load 1, 400 cr.", "tier": "none" }, @@ -337,7 +512,7 @@ "hash": "e331ce1251c1f939", "name": "Gecko Grip palm pads", "note": "The wearer's hands refuse to drop held items while stunned, paralyzed, unconscious, in crit or stamina-crit (handcuffs still take the hands, and the dead drop them). They can walk over tables and climb obstacles 20% faster, and stepping onto a chasm edge shoves them back to the lip instead of dropping them, resetting after 30 s. An EMP opens the hands and hurls whatever is held up to 5 tiles (3 on a light pulse).", - "rank": 5, + "rank": 7, "reason": "Stuns and crit can't strip what you're holding, you walk over tables and a chasm edge throws you back. Load 1, 900 cr. An EMP flings your gun away.", "tier": "green" }, @@ -346,29 +521,59 @@ "group": "Mobility and stealth", "hash": "d87709dff38cd54e", "name": "Ghostskin weave", - "note": "A button turns on 10 s of optical camo (a faint outline that brightens when they move) with a 30 s cooldown spent on use; pressing it again drops the field early. The field collapses on attacking a living thing, firing a gun, being hit or attacked, hostile bullets, being cuffed, death or an EMP. Basic-mob AI won't target the wearer from more than 2 tiles away while it is up.", + "note": "A button turns on 10 s of optical camo (a faint outline that brightens when they move) with a 30 s cooldown spent on use; pressing it again drops the field early. The field collapses on attacking a living thing, firing a gun, being hit or attacked (an animal's bite, a mech or a xeno included), hostile bullets, a real electric shock, being cuffed, death or an EMP. Basic-mob AI won't target the wearer from more than 2 tiles away while it is up.", "rank": 2, "reason": "Ten seconds of near-invisibility every 30, and mobs farther than 2 tiles lose you. Attacking or being hit ends it. A free escape or free first shot in most fights, and it walks you through ruins. Load 5, 4 vouchers at reputation 22.", "tier": "red" }, + "/obj/item/organ/cyberimp/cyberware/ghostskin/street": { + "confidence": "medium", + "group": "Mobility and stealth", + "hash": "", + "name": "Flickerskin weave", + "note": "A button turns on 7 s of optical camo (a faded outline at about a quarter opacity that brightens when they move) with a 45 s cooldown spent on use; pressing it again drops the field early. The field collapses on attacking a living thing, firing a gun, being hit or attacked (an animal's bite, a mech or a xeno included), hostile bullets, a real electric shock, being cuffed, death or an EMP. It does not grant the mob-hiding camo trait, so NPC AI still targets the wearer at any range and Chrome Read still resolves them.", + "rank": 6, + "reason": "Seven seconds of mostly faded camo every 45: people lose you in a crowd or a dim room, mobs and turrets still see you, and any swing or hit ends it. A cheap way to break line of sight from players. Load 2, 2,400 cr at yellow reputation.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/cyberware/gorilla_arms": { "confidence": "high", "group": "Arm weapons and fists", - "hash": "9c748c5bf556a0e0", + "hash": "", "name": "Gorilla Arms myomer lattice (right)", - "note": "Humans only. Each arm turns an empty-hand combat-mode left-click into a flat 20 brute (armor rolled, +10 wound bonus) with a 1-tile knockback on a mob, 4 s cooldown per arm; a mob held in an aggressive grab is hurled 4 tiles. On a rock wall it drills it, and on a structure or machine with integrity it does 40 brute (1 s cooldown for both). With both arms, closed airlocks can be pried bare-handed (4 s if powered, instant if unpowered, refused if bolted or welded). Not used while Hulk or while the ware is down.", + "note": "Humans only. Each arm turns an empty-hand combat-mode left-click into a 20 brute punch (armor rolled, +15 wound bonus, through the gore layer's aimed crits) with a 1-tile knockback on the safe path, 4 s cooldown per arm; three punches on one limb inside 15 s snap it (compound fracture on an arm or leg, caved ribs on the chest) unless 40+ melee covers it. A mob held in an aggressive grab is hurled 4 tiles, or slammed into the floor (25) or onto a table (30), once per 10 s grab-move cooldown. Each arm has a Haymaker wheel chip: wind up 0.8 to 1.5 s, 20 to 30 brute and a 3 to 4 tile launch (into a wall: +10 and cracked ribs), 20 s shared cooldown. The pair adds Ground pound (stagger and daze everything adjacent bar crew, 45 s) and three finishers on a target in crit or stunned with both hands empty, picked by aim: head bursts the head, an arm tears it off, the chest breaks the back (floored until set); about 2 s of wind-up, interrupted by 10 damage, a step or the victim breaking free; shares the 20 s cooldown. Rock breaks, structures take 40, and the pair pries powered airlocks in 4 s (never trader outpost doors).", "rank": 7, - "reason": "Half of a pair: a flat 20 damage punch every 4 s, 40 to machines and structures every second, breaks rock, and the pair pries powered airlocks in 4 s. A breaching tool more than a weapon. Load 6 the pair.", - "tier": "yellow" + "reason": "Half of a pair. With the haymaker, the grab-slam and three finishers it is a melee kill kit, not only a breaching tool: about Mantis-level against someone it can catch, and it ends downed targets outright. Counters are range, the wind-ups, 40+ melee armour and the Atlas frame. Load 6 the pair, 3 vouchers at advanced reputation.", + "tier": "red" }, "/obj/item/organ/cyberimp/cyberware/gorilla_arms/left": { "confidence": "high", "group": "Arm weapons and fists", - "hash": "25756d0541291f90", + "hash": "", "name": "Gorilla Arms myomer lattice (left)", - "note": "Humans only. Each arm turns an empty-hand combat-mode left-click into a flat 20 brute (armor rolled, +10 wound bonus) with a 1-tile knockback on a mob, 4 s cooldown per arm; a mob held in an aggressive grab is hurled 4 tiles. On a rock wall it drills it, and on a structure or machine with integrity it does 40 brute (1 s cooldown for both). With both arms, closed airlocks can be pried bare-handed (4 s if powered, instant if unpowered, refused if bolted or welded). Not used while Hulk or while the ware is down.", + "note": "Humans only. Each arm turns an empty-hand combat-mode left-click into a 20 brute punch (armor rolled, +15 wound bonus, through the gore layer's aimed crits) with a 1-tile knockback on the safe path, 4 s cooldown per arm; three punches on one limb inside 15 s snap it (compound fracture on an arm or leg, caved ribs on the chest) unless 40+ melee covers it. A mob held in an aggressive grab is hurled 4 tiles, or slammed into the floor (25) or onto a table (30), once per 10 s grab-move cooldown. Each arm has a Haymaker wheel chip: wind up 0.8 to 1.5 s, 20 to 30 brute and a 3 to 4 tile launch (into a wall: +10 and cracked ribs), 20 s shared cooldown. The pair adds Ground pound (stagger and daze everything adjacent bar crew, 45 s) and three finishers on a target in crit or stunned with both hands empty, picked by aim: head bursts the head, an arm tears it off, the chest breaks the back (floored until set); about 2 s of wind-up, interrupted by 10 damage, a step or the victim breaking free; shares the 20 s cooldown. Rock breaks, structures take 40, and the pair pries powered airlocks in 4 s (never trader outpost doors).", "rank": 8, - "reason": "Left half of the Gorilla pair: a flat 20 damage punch every 4 s, 40 to machines and structures every second, breaks rock, and the pair pries powered airlocks in 4 s.", + "reason": "Left half of the Gorilla pair: the punch, snaps, slam and Haymaker; the pair adds Ground pound and the three finishers. With the haymaker, the grab-slam and three finishers it is a melee kill kit, not only a breaching tool: about Mantis-level against someone it can catch, and it ends downed targets outright. Counters are range, the wind-ups, 40+ melee armour and the Atlas frame. Load 6 the pair, 3 vouchers at advanced reputation.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/cyberware/gorilla_arms/street": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Brawler myomers (right)", + "note": "Humans only. Each arm turns an empty-hand combat-mode left-click into a 14 brute punch (armor rolled, +10 wound bonus, through the gore layer's aimed crits) with a 1-tile knockback, 5 s cooldown per arm; four punches on one limb inside 15 s snap it unless 40+ melee covers it. 32 to structures every 1.5 s, which dents plain and reinforced airlocks; breaks rock. A mob held in an aggressive grab is slammed into the floor (18 brute, 20 stamina) or onto a table (22 brute, 30 stamina, 30 to the table) with a 1 s knockdown, once per 15 s grab-move cooldown; it is never hurled. The synced pair forces powered airlocks open in 7 s (instant if unpowered, refused if bolted or welded, and refused at trader outposts, where a pry or punch at a door counts as aggression), adds Ground pound (stagger up to 6 s and 10 stamina on everything adjacent bar crew, no daze, nothing moved, 60 s) and the limb rip finisher on a target in crit or stunned. No haymaker, head clap, backbreaker or flex. A Brawler arm beside a Gorilla arm syncs neither pair.", + "rank": 12, + "reason": "Half of a pair: a 14 damage punch every 5 s that snaps a limb on the fourth hit, a grab slam for 18 to 22 with a 1 s knockdown every 15 s, and 32 to structures, enough to break down an airlock. The pair forces powered airlocks in 7 s, staggers everything adjacent every 60 s and tears an arm off a downed target. Above the Strong-Arm, which slams a little harder but has no finisher or door damage; below Gorilla Arms, which hurl, hit harder, pry faster and have three finishers. Load 4 the pair, 2,000 cr at reputation 4. Either ripperdoc takes a pulled arm back for 500 cr.", + "tier": "yellow" + }, + "/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left": { + "confidence": "medium", + "group": "Arm weapons and fists", + "hash": "", + "name": "Brawler myomers (left)", + "note": "Humans only. Each arm turns an empty-hand combat-mode left-click into a 14 brute punch (armor rolled, +10 wound bonus, through the gore layer's aimed crits) with a 1-tile knockback, 5 s cooldown per arm; four punches on one limb inside 15 s snap it unless 40+ melee covers it. 32 to structures every 1.5 s, which dents plain and reinforced airlocks; breaks rock. A mob held in an aggressive grab is slammed into the floor (18 brute, 20 stamina) or onto a table (22 brute, 30 stamina, 30 to the table) with a 1 s knockdown, once per 15 s grab-move cooldown; it is never hurled. The synced pair forces powered airlocks open in 7 s (instant if unpowered, refused if bolted or welded, and refused at trader outposts, where a pry or punch at a door counts as aggression), adds Ground pound (stagger up to 6 s and 10 stamina on everything adjacent bar crew, no daze, nothing moved, 60 s) and the limb rip finisher on a target in crit or stunned. No haymaker, head clap, backbreaker or flex. A Brawler arm beside a Gorilla arm syncs neither pair.", + "rank": 13, + "reason": "Left half of the Brawler pair: a 14 damage punch every 5 s, an 18 to 22 grab slam every 15 s, 32 to structures. The pair forces airlocks, has a light ground pound and the limb rip.", "tier": "yellow" }, "/obj/item/organ/cyberimp/cyberware/governor_delete": { @@ -380,6 +585,24 @@ "reason": "Adds 15 neural load for 35 in all, giving up the slot Cascade and Redline need. That runs Slabskin, Lazarus, Mantis, Hopper, Dead Channel, Coolant, Deadeye and Atlas at once. 5 vouchers at reputation 22.", "tier": "red" }, + "/obj/item/organ/cyberimp/cyberware/governor_delete/milspec": { + "confidence": "medium", + "group": "Operating system", + "hash": "", + "name": "Governor Bypass", + "rank": 6, + "reason": "Raises the neural load limit from 20 to 30 for no load of its own, in the slot Cascade and Redline need. 3 vouchers at reputation 11.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/cyberware/governor_delete/street": { + "confidence": "medium", + "group": "Operating system", + "hash": "", + "name": "Governor Patch", + "rank": 9, + "reason": "Raises the neural load limit from 20 to 25 for no load of its own, in the slot Cascade and Redline need. 2,500 cr at reputation 4.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/cyberware/hemoglass": { "confidence": "medium", "group": "Body upkeep", @@ -395,10 +618,28 @@ "group": "Mobility and stealth", "hash": "2f8e33baec594340", "name": "Hopper piston calves", - "rank": 4, + "rank": 5, "reason": "Jump 4 tiles over tables, gaps and people every 8 s. Won't cross walls or windows. Strong in any fight. Load 3, 3,600 cr.", "tier": "yellow" }, + "/obj/item/organ/cyberimp/cyberware/hopper/milspec": { + "confidence": "medium", + "group": "Mobility and stealth", + "hash": "", + "name": "Vaulter pistons", + "rank": 3, + "reason": "Jump 5 tiles over tables, gaps and people every 6 s, and walk away from drops and wet floors like the Shock Coils. Won't cross walls or windows. Load 4, 3 vouchers at reputation 11.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/cyberware/hopper/street": { + "confidence": "medium", + "group": "Mobility and stealth", + "hash": "", + "name": "Spring calves", + "rank": 8, + "reason": "Jump 3 tiles over tables, gaps and people every 14 s. Won't cross walls or windows. The cheap rung under the Hopper, with none of the Shock Coils' trims. Load 2, 1,800 cr at reputation 4. Splice takes a pulled pair back for 900 cr.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/cyberware/lazarus": { "confidence": "high", "group": "Revive and last stand", @@ -409,6 +650,26 @@ "reason": "Once every 6 minutes, dropping into crit stands you up at 30% health with stuns cleared after a 1 s seizure. A second life in the same fight. Load 5, 4 vouchers at reputation 22.", "tier": "red" }, + "/obj/item/organ/cyberimp/cyberware/medic_palms": { + "confidence": "medium", + "group": "Work tools", + "hash": "", + "name": "Medic's palms", + "note": "While online, gives the wearer the quicker chemistry trait (syringes, pills, patches and the like take less time) and the quicker fireman carry (3 s instead of 5), the same traits as nitrile gloves, without using the glove slot. It takes the hands slot, so it evicts the Gecko Grip and the Cuffer's wrists.", + "rank": 8, + "reason": "Nitrile-glove speed on chemistry and carrying without the glove slot, so a medic can wear insulated or armored gloves instead. Load 1, 600 cr.", + "tier": "green" + }, + "/obj/item/organ/cyberimp/cyberware/muffler_ear": { + "confidence": "medium", + "group": "Nerves and stuns", + "hash": "", + "name": "Muffler ear", + "note": "While online, takes one point off the intensity of a bang, which is what earmuffs do: a flashbang or similar bang does nothing to the wearer, though the flash still blinds. It goes off during an EMP reboot or brownout. It takes the chrome ears slot, so it evicts the Heartbeat Doppler.", + "rank": 10, + "reason": "A flashbang's bang stops dropping the wearer, like earmuffs you can't take off. The flash still blinds. Load 1, 700 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/cyberware/piledriver": { "confidence": "high", "group": "Mobility and stealth", @@ -427,13 +688,31 @@ "reason": "Twelve seconds in every 90: stun immune, 40% less brute and burn, 8 more on punches, and a roar that staggers everyone within 5 tiles. Then 100 stamina and slow legs. Load 10, 6 vouchers at reputation 22.", "tier": "red" }, + "/obj/item/organ/cyberimp/cyberware/redline/milspec": { + "confidence": "medium", + "group": "Operating system", + "hash": "", + "name": "Vanguard core", + "rank": 5, + "reason": "Ten seconds in every 105: stun immune, 30% less brute and burn, 5 more on punches, and a roar that staggers everyone within 4 tiles. Then 100 stamina and slow legs. Load 8, 4 vouchers at reputation 11.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/cyberware/redline/street": { + "confidence": "medium", + "group": "Operating system", + "hash": "", + "name": "Hothead core", + "rank": 8, + "reason": "Eight seconds in every 90: 20% less brute and burn and 3 more on punches, with no stun immunity and no roar. Then 100 stamina and slow legs. Load 4, 3,000 cr at reputation 4.", + "tier": "yellow" + }, "/obj/item/organ/cyberimp/cyberware/registry_uplink": { "confidence": "low", "group": "Hacking and ship control", "hash": "3ab34be71b4333f9", "name": "Registry uplink", "note": "Gives a button that opens an outpost's management panel from anywhere, with no distance, docking, zone or console-power requirement, for each outpost where the wearer is currently the management user. It needs the wearer conscious and the ware running, and any open panel closes if the ware goes down or is removed.", - "rank": 3, + "rank": 6, "reason": "Opens the management panel of an outpost you run from anywhere. Convenience for outpost owners, no use to anyone else. Load 2, 2,800 cr.", "tier": "green" }, @@ -443,7 +722,7 @@ "hash": "332ab143dabb3d52", "name": "Rigger socket", "note": "Opens a working helm console on the ship the bearer is standing on, from anywhere aboard, subject to the console's normal crew access; broken, unpowered and view-only viewscreen consoles don't count. While the uplink is up the bearer has +1 movement slowdown, and it drops if they leave the hull, go unconscious, close the panel, lose the console, or the socket is EMP'd or browned out. The button has a 5 second cooldown.", - "rank": 2, + "rank": 5, "reason": "Fly your ship from anywhere aboard at a walking pace. Lets a pilot hide from boarders or fix things mid-fight, and it needs a working helm. Load 4, 3 vouchers at reputation 22.", "tier": "yellow" }, @@ -453,7 +732,7 @@ "hash": "e057ede2eff30ba2", "name": "Scrapper's Knuckles", "note": "Replaces the bearer's own punch (combat mode, left click, not a Hulk) with that hand's normal unarmed roll plus 4 flat damage against mobs, and double that total against machines and structures. Humans can still block it and armor still applies; it stops working while the ware is EMP'd or browned out.", - "rank": 9, + "rank": 17, "reason": "Half of a pair: punches do 4 more, double against machines. A cheap brawler's first step. Load 2 the pair, 800 cr.", "tier": "green" }, @@ -463,7 +742,7 @@ "hash": "1262168b74587722", "name": "Scrapper's Knuckles", "note": "Replaces the bearer's own punch (combat mode, left click, not a Hulk) with that hand's normal unarmed roll plus 4 flat damage against mobs, and double that total against machines and structures. Humans can still block it and armor still applies; it stops working while the ware is EMP'd or browned out.", - "rank": 10, + "rank": 18, "reason": "Left half of the Scrapper pair: punches do 4 more, double against machines.", "tier": "green" }, @@ -473,28 +752,38 @@ "hash": "7266f264ffd401f9", "name": "Second Wind bladder", "note": "When the surroundings have under 16 kPa of oxygen and the bearer isn't on tank internals, the bladder supplies the breath itself from a 180 second reserve, spending 8 seconds of reserve per breath and refilling 16 seconds per breath taken in breathable air. It replaces only the breath, and it announces itself with a gasp, a HUD alert and a loud breathing loop; it does nothing for no-breathers or while EMP'd or browned out.", - "rank": 5, + "rank": 7, "reason": "Three minutes of air when you lose your internals, refills as you breathe. A safety net against vacuum. Load 1, 900 cr.", "tier": "green" }, + "/obj/item/organ/cyberimp/cyberware/second_wind/deep": { + "confidence": "medium", + "group": "Armor and frame", + "hash": "", + "name": "Deep-lung bladder", + "note": "Works exactly like the Second Wind bladder: when the surroundings have under 16 kPa of oxygen and the bearer isn't on tank internals, it supplies the breath itself, spending 8 seconds of reserve per breath. The reserve is 360 seconds (180) and refills 24 seconds per breath taken in breathable air (16). It announces itself with a gasp, a HUD alert and a loud breathing loop; it does nothing for no-breathers or while EMP'd or browned out.", + "rank": 6, + "reason": "Six minutes of air when you lose your internals, refilling faster than the Second Wind. A longer safety net against vacuum, not a way to work in it. Load 2, 1,800 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/cyberware/shock_coils": { "confidence": "medium", "group": "Nerves and stuns", "hash": "d453bb62463e3dcb", "name": "Shock Coil calf pistons", "note": "Halves knockdown durations and cuts stun durations by 20%, stops slipping on water-wet floors (water only), and cancels fall damage from dropping down levels with no power cost; falls of 2 or more levels still stagger the bearer for up to 10 seconds. All of it switches off while the ware is EMP'd or browned out.", - "rank": 4, + "rank": 6, "reason": "Knockdowns are half as long, stuns 20% shorter, no slipping on water or fall damage. The best cheap chrome: load 1, 500 cr. Evicted by Hopper.", "tier": "green" }, "/obj/item/organ/cyberimp/cyberware/slabskin": { "confidence": "high", "group": "Armor and frame", - "hash": "7b785a3adf8b7c37", + "hash": "", "name": "Slabskin plate", - "note": "While online it adds built-in armor to the bearer (melee 25, bullet 25, laser 25, energy 20, bomb 25, fire 20, acid 20, wound 15), and any brute or burn hit of 5 or more throws sparks and often a ricochet sound so others can see the plate. The armor switches off while the ware is EMP'd or browned out.", + "note": "While online it adds built-in armor to the bearer (melee 25, bullet 25, laser 25, energy 20, bomb 25, fire 20, acid 20, wound 15), and any brute or burn hit of 5 or more throws sparks and often a ricochet sound so others can see the plate. Bullets and buckshot pellets from the front glance off at 45% (each pellet rolls on its own), keep flying at reduced damage and cost the wearer 5 stamina each. Never lasers, energy, melee or shots into the back. Shares the dodge arbiter: dodge plus glance never stop more than 60% of shots. The armor and the glance switch off while the ware is EMP'd or browned out.", "rank": 1, - "reason": "25 armor against melee, bullets and lasers on the whole body, multiplied on top of whatever you wear, plus bomb, fire, acid and wounds. About a second armor vest that covers your head and limbs. Load 6, 3 vouchers at reputation 22. EMP switches it off for 9 s.", + "reason": "25 armor against melee, bullets and lasers on the whole body, multiplied on top of whatever you wear, plus bomb, fire, acid and wounds, and almost half of bullets from the front glance off. About a second armor vest that covers your head and limbs, and the best answer to a gunline in the game. Load 6, 3 vouchers at reputation 22. EMP switches it off for 9 s.", "tier": "red" }, "/obj/item/organ/cyberimp/cyberware/slipwire": { @@ -503,16 +792,46 @@ "hash": "83d2c1a6b828b267", "name": "Slipwire reflex shunt", "note": "While the bearer has moved within the last second, a hostile projectile has a 15% chance to be dodged with a visible sidestep and the round flies on; shooters 1 tile away always hit, and it doesn't work lying down, buckled or unconscious. Also gives a small speed bonus (-0.1 slowdown); with other dodge sources only the highest chance counts, and everything here is off while the ware is EMP'd or browned out.", - "rank": 3, + "rank": 4, "reason": "15% of bullets miss while you're moving, never from an adjacent shooter, and you run slightly faster. Takes the slot Dead Channel wants. Load 4, 2 vouchers.", "tier": "yellow" }, + "/obj/item/organ/cyberimp/cyberware/slipwire/milspec": { + "confidence": "medium", + "group": "Nerves and stuns", + "hash": "", + "name": "Weaver shunt", + "note": "While the bearer has moved within the last second, a hostile projectile has a 20% chance to be dodged with a visible sidestep and the round flies on; shooters 1 tile away always hit, and it doesn't work lying down, buckled or unconscious. Also gives a speed bonus (-0.15 slowdown). With other dodge sources only the highest chance counts, so a Cascade window's 40% still wins, and everything here is off while the ware is EMP'd or browned out.", + "rank": 2, + "reason": "20% of bullets miss while you're moving, never from an adjacent shooter, and you run a little faster than a Slipwire. Takes the slot Dead Channel wants. Load 5, 3 vouchers at reputation 11.", + "tier": "red" + }, + "/obj/item/organ/cyberimp/cyberware/slipwire/street": { + "confidence": "medium", + "group": "Nerves and stuns", + "hash": "", + "name": "Twitchwire", + "note": "While the bearer has moved within the last second, a hostile projectile has an 8% chance to be dodged with a visible sidestep and the round flies on; shooters 1 tile away always hit, and it doesn't work lying down, buckled or unconscious. No speed bonus. With other dodge sources only the highest chance counts, and it is off while the ware is EMP'd or browned out.", + "rank": 9, + "reason": "8% of bullets miss while you're moving, never from an adjacent shooter, and nothing else. A cheap taste of the Slipwire in the slot Dead Channel wants. Load 2, 1,800 cr at reputation 4.", + "tier": "yellow" + }, + "/obj/item/organ/cyberimp/cyberware/subvocal_mic": { + "confidence": "medium", + "group": "Mobility and stealth", + "hash": "", + "name": "Subvocal mic", + "note": "While online, a radio line the wearer speaks (headset, department or intercom) is spoken at range 0 instead of 1: the wearer and anyone on their tile hear it, a neighbour one tile away gets the usual garbled eavesdrop copy, and nobody further hears it. Ordinary talk is unchanged. It goes off during an EMP reboot or brownout.", + "rank": 10, + "reason": "Radio talk is not overheard by anyone standing close. A small edge for sneaking and boarding. Load 1, 600 cr.", + "tier": "green" + }, "/obj/item/organ/cyberimp/eyes/hud/diagnostic": { "confidence": "high", "group": "Scouting and sight", "hash": "bc1a71fec9d46258", "name": "diagnostic HUD implant", - "rank": 5, + "rank": 6, "reason": "A diagnostic HUD with no glasses. Shows machine and robot health, for engineers.", "tier": "green" }, @@ -521,7 +840,7 @@ "group": "Scouting and sight", "hash": "4beab53dff56918d", "name": "medical HUD implant", - "rank": 3, + "rank": 4, "reason": "A health HUD with no glasses, same job as the green goggles but the eye slot stays free. About 30 cr of material, or found on two hulls.", "tier": "green" }, @@ -530,7 +849,7 @@ "group": "Scouting and sight", "hash": "91681c47158b6422", "name": "security HUD implant", - "rank": 4, + "rank": 5, "reason": "A security HUD with no glasses. Names and wanted status, nothing that wins a fight.", "tier": "green" }, @@ -539,7 +858,7 @@ "group": "Body upkeep", "hash": "81096fd3e55913d0", "name": "breathing tube implant", - "rank": 3, + "rank": 4, "reason": "Use internals with no mask, which frees the mask slot, and you can't be choked. About 2 cr of material after 200 research points.", "tier": "green" } diff --git a/tools/gear_catalog/ratings/explosives.json b/tools/gear_catalog/ratings/explosives.json index 719ee90c508..b0cefb79cfd 100644 --- a/tools/gear_catalog/ratings/explosives.json +++ b/tools/gear_catalog/ratings/explosives.json @@ -462,6 +462,7 @@ "/obj/item/grenade/hypnotic": "no route", "/obj/item/grenade/primer": "no route", "/obj/item/grenade/primer/stingbang": "no route", + "/obj/item/grenade/smokebomb/bounty_boss": "no route", "/obj/item/grenade/spawnergrenade": "no route", "/obj/item/grenade/spawnergrenade/buzzkill": "no route", "/obj/item/grenade/spawnergrenade/cat": "no route", diff --git a/tools/gear_catalog/ratings/guns.json b/tools/gear_catalog/ratings/guns.json index efe8bbffc2b..30e11abdea1 100644 --- a/tools/gear_catalog/ratings/guns.json +++ b/tools/gear_catalog/ratings/guns.json @@ -591,6 +591,15 @@ }, "tier": "yellow" }, + "/obj/item/gun/ballistic/revolver/cyberware_holdout": { + "confidence": "medium", + "group": "sidearms", + "hash": "", + "name": "holdout revolver", + "rank": 14, + "reason": "A .38 revolver folded into the forearm: 25 damage, six shots, about 2.5 a second. Can't be disarmed while deployed, and every reload is a round at a time by hand.", + "tier": "yellow" + }, "/obj/item/gun/ballistic/revolver/golden": { "confidence": "medium", "group": "sidearms", @@ -2136,6 +2145,7 @@ }, "method": "Placed against the pilot's gun ratings with the same score: the formula where a gun has stats, and a judged score where its power is not in the stats. Bands: green under 40, yellow 40 to 109, red 110 and up.", "unrated": { + "/obj/item/flamethrower/full/tank/bounty_boss": "no route", "/obj/item/gun": "abstract", "/obj/item/gun/ballistic": "abstract", "/obj/item/gun/ballistic/automatic": "abstract", diff --git a/tools/gear_catalog/ratings/melee.json b/tools/gear_catalog/ratings/melee.json index a7568c8fc05..ad2dbd69153 100644 --- a/tools/gear_catalog/ratings/melee.json +++ b/tools/gear_catalog/ratings/melee.json @@ -1161,19 +1161,48 @@ "hash": "c34e783490904319", "name": "Widowline monowire", "note": "Each landed hit adds 5 burn damage and cleaves every living mob next to the target that the target can see and that is not on the wielder's crew team, for 75% of the hit's damage in brute and burn. Its armour penetration is the full 100.", - "rank": 1, + "rank": 2, "reason": "Rated with its arm housing: 25 a second through any armor at 2 tiles, and the hit carries into every enemy beside the target. Hidden until used. Needs surgery.", "tier": "red" }, + "/obj/item/melee/cyberware_monowire/live": { + "confidence": "medium", + "group": "arm blades", + "hash": "", + "name": "Widowline Arc monowire", + "note": "Each landed hit also shocks the target for 5 burn and a short stagger (not through shock immunity or insulated suits), adds 25 burn on silicons, mechs and robotic mobs, and shorts a turret, ship laser turret, console or camera for 5 s, once per 15 s. The cleave neighbours take the plain cleave only.", + "rank": 1, + "reason": "Rated with its arm housing: the Widowline wire with a shock, a stagger and a machine-killing short on every landed hit. Needs surgery.", + "tier": "red" + }, "/obj/item/melee/energy/blade/hardlight/cyberware_mantis": { "confidence": "medium", "group": "arm blades", "hash": "e09509a45772dc39", "name": "mantis blade", - "rank": 2, + "rank": 4, "reason": "Rated with its arm housing: 20 force blades that cannot be disarmed, and a 5 tile lunge every 20 s that floors the target for 2 s. Needs surgery.", "tier": "red" }, + "/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch": { + "confidence": "medium", + "group": "arm blades", + "hash": "", + "name": "scorch blade", + "note": "Each landed cut adds 2 fire stacks and sets the target alight. Corpses are left alone and the wielder is never lit.", + "rank": 3, + "reason": "Rated with its arm housing: the Mantis blade and lunge, with every cut and the lunge setting the target alight. Needs surgery.", + "tier": "red" + }, + "/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street": { + "confidence": "medium", + "group": "arm blades", + "hash": "", + "name": "shiv blade", + "rank": 5, + "reason": "Rated with its arm housing: 14 force blades that cannot be disarmed, no lunge. Needs surgery.", + "tier": "yellow" + }, "/obj/item/melee/energy/sword/pirate": { "confidence": "high", "group": "energy blades", @@ -1315,7 +1344,7 @@ "group": "arm blades", "hash": "63a21bf583afc355", "name": "synthetic arm blade", - "rank": 3, + "rank": 6, "reason": "20 force blade grown on a hacked limb grower. Huge, no parry. The route was not fully traced.", "tier": "green" }, diff --git a/tools/gear_catalog/ratings/modsuits.json b/tools/gear_catalog/ratings/modsuits.json index c788db2588f..2a6731b4f8e 100644 --- a/tools/gear_catalog/ratings/modsuits.json +++ b/tools/gear_catalog/ratings/modsuits.json @@ -1428,6 +1428,12 @@ "/obj/item/mod/control/pre_equipped/administrative": "no route", "/obj/item/mod/control/pre_equipped/apocryphal": "no route", "/obj/item/mod/control/pre_equipped/apocryphal/officer": "no route", + "/obj/item/mod/control/pre_equipped/bounty_boss": "no route", + "/obj/item/mod/control/pre_equipped/bounty_boss/atmospheric": "no route", + "/obj/item/mod/control/pre_equipped/bounty_boss/civilian": "no route", + "/obj/item/mod/control/pre_equipped/bounty_boss/engineering": "no route", + "/obj/item/mod/control/pre_equipped/bounty_boss/magnate": "no route", + "/obj/item/mod/control/pre_equipped/bounty_boss/security": "no route", "/obj/item/mod/control/pre_equipped/chrono": "no route", "/obj/item/mod/control/pre_equipped/corporate": "no route", "/obj/item/mod/control/pre_equipped/cosmohonk": "leftover", diff --git a/tools/gear_catalog/ratings/organs.json b/tools/gear_catalog/ratings/organs.json index fba7540a1e9..c3b3e88ea39 100644 --- a/tools/gear_catalog/ratings/organs.json +++ b/tools/gear_catalog/ratings/organs.json @@ -429,7 +429,7 @@ "group": "Eyes", "hash": "970e50f04a7a2db8", "name": "eyes", - "rank": 18, + "rank": 23, "reason": "Plain replacement eyes.", "tier": "none" }, @@ -438,7 +438,7 @@ "group": "Eyes", "hash": "07ec6668fecdcd61", "name": "moth eyes", - "rank": 19, + "rank": 24, "reason": "Plain replacement eyes.", "tier": "none" }, @@ -447,7 +447,7 @@ "group": "Eyes", "hash": "3e1ed2dde4757134", "name": "fung-eye", - "rank": 8, + "rank": 11, "reason": "Night vision you can toggle, with no neural load. Placed in one jungle ruin. Same job as night vision goggles.", "tier": "yellow" }, @@ -456,7 +456,7 @@ "group": "Eyes", "hash": "84a3161d476535dd", "name": "robotic eyes", - "rank": 11, + "rank": 16, "reason": "A working pair of robotic eyes, no better than your own.", "tier": "none" }, @@ -465,7 +465,7 @@ "group": "Eyes", "hash": "7cc5a72a291dbd8a", "name": "basic robotic eyes", - "rank": 13, + "rank": 18, "reason": "Cheap replacement eyes, weak to flashes.", "tier": "none" }, @@ -474,7 +474,7 @@ "group": "Eyes", "hash": "4ba3d5231be60398", "name": "basic robotic moth eyes", - "rank": 14, + "rank": 19, "reason": "Cheap replacement eyes, weak to flashes.", "tier": "none" }, @@ -483,8 +483,35 @@ "group": "Eyes", "hash": "8ea026e0bf1e0602", "name": "Deadeye link", - "rank": 5, - "reason": "Tag a target and your next three shots curve onto it, every 25 s. Bullets stop missing for a burst, but the target gets a warning and walls stop it. Load 3, 2 vouchers with no reputation.", + "rank": 7, + "reason": "Tag a target and your next three shots curve onto it, every 25 s. Bullets stop missing for a burst, but the target gets a warning and walls stop it. Also zooms about 14 tiles out at a slight slowdown, though nobody can shoot while zoomed. Load 3, 2 vouchers at yellow reputation.", + "tier": "yellow" + }, + "/obj/item/organ/eyes/robotic/cyberware/deadeye/milspec": { + "confidence": "medium", + "group": "Eyes", + "hash": "", + "name": "marksman link", + "rank": 3, + "reason": "Tag a target and your next four shots curve onto it, every 18 s, out to 10 tiles. Also zooms the view about 19 tiles out at full speed, though nobody can shoot while zoomed. Load 4, 3 vouchers at advanced reputation.", + "tier": "red" + }, + "/obj/item/organ/eyes/robotic/cyberware/longsight": { + "confidence": "medium", + "group": "Eyes", + "hash": "", + "name": "longsight optics", + "rank": 9, + "reason": "Zooms the view about 19 tiles out at full speed and names implants out to 9 tiles. Scouting only, no help in a fight. Load 2, 2,400 cr at yellow reputation.", + "tier": "yellow" + }, + "/obj/item/organ/eyes/robotic/cyberware/lookout": { + "confidence": "medium", + "group": "Eyes", + "hash": "", + "name": "lookout optics", + "rank": 6, + "reason": "Zooms the view about 24 tiles out at full speed, sees in the dark, and names every implant on a body out to 11 tiles every 8 s. Pure scouting: no shooting while zoomed. Load 3, 3 vouchers at advanced reputation.", "tier": "yellow" }, "/obj/item/organ/eyes/robotic/cyberware/nightshade": { @@ -493,8 +520,8 @@ "hash": "030567541e7e32a4", "name": "Nightshade optics", "note": "Gives night vision with a green tint and puts a glow, visible only to the wearer, on every living body in view even in the dark (corpses glow dimmer). Flash protection stays at the robotic default, and its chrome scan only counts implants without naming them.", - "rank": 6, - "reason": "Night vision with no flash weakness and a glow on every living body in view. Beats night vision goggles for 600 cr and load 1.", + "rank": 8, + "reason": "Night vision with no flash weakness and a glow on every living body in view. Beats night vision goggles for 600 cr and load 1. Also zooms about 9 tiles out at a walk.", "tier": "yellow" }, "/obj/item/organ/eyes/robotic/cyberware/prospector": { @@ -502,16 +529,34 @@ "group": "Eyes", "hash": "5f70c88fa7552793", "name": "Prospector Suite optics", - "rank": 7, - "reason": "A pulse every 10 s shows ore through rock and loot caches within 9 tiles. Great for mining and ruin crews, no help in a fight. Load 2, 2 vouchers.", + "rank": 10, + "reason": "A pulse every 10 s shows ore through rock and loot caches within 9 tiles. Great for mining and ruin crews, no help in a fight. Also zooms about 14 tiles out at a slight slowdown. Load 2, 1 voucher at yellow reputation.", "tier": "yellow" }, + "/obj/item/organ/eyes/robotic/cyberware/prospector/street": { + "confidence": "high", + "group": "Eyes", + "hash": "", + "name": "assay optics", + "rank": 12, + "reason": "A 5-tile ore pulse through rock every 15 s with no cache marks, plus a short zoom that slows you. A cheap start for miners. Load 1, 900 cr.", + "tier": "green" + }, + "/obj/item/organ/eyes/robotic/cyberware/spyglass": { + "confidence": "high", + "group": "Eyes", + "hash": "", + "name": "spyglass optics", + "rank": 13, + "reason": "A short zoom, about 9 tiles, that slows you while you look, and a chrome read that only counts implants. Binoculars reach further but take both hands. Load 1, 400 cr.", + "tier": "green" + }, "/obj/item/organ/eyes/robotic/flashlight": { "confidence": "high", "group": "Eyes", "hash": "31bf05befe1e2bdf", "name": "flashlight eyes", - "rank": 17, + "rank": 22, "reason": "Flashlights strapped into your skull. You can't see through them. A joke.", "tier": "none" }, @@ -520,7 +565,7 @@ "group": "Eyes", "hash": "121bc2c724450f5d", "name": "high luminosity eyes", - "rank": 15, + "rank": 20, "reason": "A coloured torch in your face. Useful in the dark, costs a load.", "tier": "none" }, @@ -529,7 +574,7 @@ "group": "Eyes", "hash": "880f3fcfed561cbf", "name": "high luminosity moth eyes", - "rank": 16, + "rank": 21, "reason": "A coloured torch in your face. Useful in the dark, costs a load.", "tier": "none" }, @@ -538,7 +583,7 @@ "group": "Eyes", "hash": "1719a4848fac0fdb", "name": "robotic moth eyes", - "rank": 12, + "rank": 17, "reason": "A working pair of robotic eyes, no better than your own.", "tier": "none" }, @@ -547,7 +592,7 @@ "group": "Eyes", "hash": "5d54a8f40d09d8b4", "name": "shielded robotic eyes", - "rank": 9, + "rank": 14, "reason": "Flash immunity with no tint, and EMP proof. Better sunglasses that don't take the slot. About 2 cr of material.", "tier": "green" }, @@ -556,7 +601,7 @@ "group": "Eyes", "hash": "617e9ddf30f1f6f4", "name": "shielded robotic moth eyes", - "rank": 10, + "rank": 15, "reason": "Moth looks on shielded eyes. Flash immunity with no tint.", "tier": "green" }, @@ -565,7 +610,7 @@ "group": "Eyes", "hash": "2abaf20763c58a3e", "name": "thermal eyes", - "rank": 3, + "rank": 4, "reason": "Same sight as thermal goggles, every living thing through walls, but sunglasses over them cancel the flash weakness. Better than the goggles, and they print with no reputation. An EMP flashes them.", "tier": "yellow" }, @@ -574,7 +619,7 @@ "group": "Eyes", "hash": "1436defdd6c14505", "name": "thermal moth eyes", - "rank": 4, + "rank": 5, "reason": "Same as thermal eyes with moth looks. Living things through walls, flash weak.", "tier": "yellow" }, @@ -601,7 +646,7 @@ "group": "Eyes", "hash": "927d6a5cf2f19d2f", "name": "snail eyes", - "rank": 20, + "rank": 25, "reason": "Plain replacement eyes.", "tier": "none" }, diff --git a/tools/gear_catalog/ratings/tools.json b/tools/gear_catalog/ratings/tools.json index 80c6cfaaa21..53f65496042 100644 --- a/tools/gear_catalog/ratings/tools.json +++ b/tools/gear_catalog/ratings/tools.json @@ -1446,7 +1446,7 @@ "group": "Mining tools", "hash": "16ae32694e632739", "name": "manual mining scanner", - "rank": 19, + "rank": 20, "reason": "Manual ore scanner. Click for a look at nearby ore. Common on hulls.", "tier": "none" }, @@ -1539,7 +1539,7 @@ "group": "Mining tools", "hash": "c2024f595b1ac958", "name": "ore sensor", - "rank": 20, + "rank": 21, "reason": "Crafted bone ore sensor. Small range and it needs brimdust to make.", "tier": "none" }, @@ -1557,7 +1557,7 @@ "group": "Mining tools", "hash": "971c85bf93572b1b", "name": "pickaxe", - "rank": 14, + "rank": 15, "reason": "Plain pick. Prints at round start and hits for 15, but it's heavy to carry.", "tier": "none" }, @@ -1566,7 +1566,7 @@ "group": "Mining tools", "hash": "b938dac87ca2790e", "name": "diamond-tipped pickaxe", - "rank": 7, + "rank": 8, "reason": "Digs in about a third of the normal time. 1,200 cr at the green waystation, a fair first upgrade.", "tier": "green" }, @@ -1584,7 +1584,7 @@ "group": "Mining tools", "hash": "a8467bba7110047c", "name": "mining drill", - "rank": 10, + "rank": 11, "reason": "Digs at a little over half the normal time. Cheap and printable after 40 research points. The usual first upgrade.", "tier": "green" }, @@ -1593,10 +1593,19 @@ "group": "Mining tools", "hash": "093655e5e5394734", "name": "rockjaw drill", - "rank": 8, + "rank": 9, "reason": "Implant drill. Half-time digging with your hands free. The implant is the real purchase.", "tier": "green" }, + "/obj/item/pickaxe/drill/cyberware/deepcore": { + "confidence": "medium", + "group": "Mining tools", + "hash": "", + "name": "deepcore drill", + "rank": 7, + "reason": "Implant drill. Digs in under a third of the usual time with your hands free, between the rockjaw drill and a diamond drill. The implant is the real purchase.", + "tier": "green" + }, "/obj/item/pickaxe/drill/diamonddrill": { "confidence": "medium", "group": "Mining tools", @@ -1620,7 +1629,7 @@ "group": "Mining tools", "hash": "971c85bf93572b1b", "name": "emergency disembarkation tool", - "rank": 15, + "rank": 16, "reason": "Plain-speed pick from emergency kits. Hits for 15, but it's heavy to carry.", "tier": "none" }, @@ -1629,7 +1638,7 @@ "group": "Mining tools", "hash": "e44656dab7dcaa9d", "name": "improvised pickaxe", - "rank": 17, + "rank": 18, "reason": "Taped-together pick at a third of the normal speed. Better than bare hands.", "tier": "none" }, @@ -1638,7 +1647,7 @@ "group": "Mining tools", "hash": "f0d10d8ea21ed503", "name": "compact pickaxe", - "rank": 14, + "rank": 15, "reason": "Plain-speed pick in a smaller size.", "tier": "none" }, @@ -1647,7 +1656,7 @@ "group": "Mining tools", "hash": "0dc2d79772498eca", "name": "rusty pickaxe", - "rank": 16, + "rank": 17, "reason": "Plain-speed pick from a scrap crate.", "tier": "none" }, @@ -1656,7 +1665,7 @@ "group": "Mining tools", "hash": "d955462ef7f3820e", "name": "silver-plated pickaxe", - "rank": 9, + "rank": 10, "reason": "Half-time digging for 1,000 mining points.", "tier": "green" }, @@ -1674,7 +1683,7 @@ "group": "Mining tools", "hash": "dab2a22ec6f7f472", "name": "material sniffer", - "rank": 22, + "rank": 23, "reason": "Crafted from an analyzer and some cable. Points at loose sheets of iron and glass. Minor.", "tier": "none" }, @@ -1701,7 +1710,7 @@ "group": "Mining tools", "hash": "adad44b7c8924f21", "name": "ventpointer", - "rank": 21, + "rank": 22, "reason": "Points at nearby ore vents. 800 mining points for a shortcut you can walk.", "tier": "none" }, @@ -2195,7 +2204,7 @@ "group": "Mining tools", "hash": "a8c7ee47f9855f4e", "name": "shovel", - "rank": 18, + "rank": 19, "reason": "Plain shovel, 8 force. Prints at round start.", "tier": "none" }, @@ -2215,7 +2224,7 @@ "hash": "39a661a6f4799dbe", "name": "dull bone shovel", "note": "With combat mode on, each hit on an organic mob (and each thrown hit) adds a second hit equal to its own force (10; 8 for the dull version) to the same limb, and does nothing extra to robots or other non-organic mobs. Digs at tool speed 0.3 (0.8 dull).", - "rank": 11, + "rank": 12, "reason": "Dull bone shovel: each hit on an organic lands twice for 16. Slower dig. One ruin.", "tier": "green" }, @@ -2224,7 +2233,7 @@ "group": "Mining tools", "hash": "6d36ec3489795240", "name": "spade", - "rank": 18, + "rank": 19, "reason": "Garden spade.", "tier": "none" }, @@ -2386,7 +2395,7 @@ "group": "Mining tools", "hash": "949739cf35df0bb0", "name": "advanced automatic mining scanner", - "rank": 12, + "rank": 13, "reason": "Shows ore within 7 tiles on its own. 300 cr at the green waystation. Right price, right place.", "tier": "green" }, @@ -2395,7 +2404,7 @@ "group": "Mining tools", "hash": "7c5b6654d9cb653b", "name": "automatic mining scanner", - "rank": 13, + "rank": 14, "reason": "Shows ore within 4 tiles on its own, more slowly. Common on hulls.", "tier": "green" }, diff --git a/voidcrew/_DEFINES/bounties.dm b/voidcrew/_DEFINES/bounties.dm index 7eb625ce9a0..ebb6fc1ec3b 100644 --- a/voidcrew/_DEFINES/bounties.dm +++ b/voidcrew/_DEFINES/bounties.dm @@ -48,6 +48,8 @@ #define BOUNTY_KIT_DEMOLITIONIST "demolitionist" #define BOUNTY_KIT_GHOST "ghost" #define BOUNTY_KIT_HEAVY "heavy" +/// Its kit is its chrome (chrome/bounty_cyberpsycho.dm): the rarest +#define BOUNTY_KIT_CYBERPSYCHO "cyberpsycho" // ===== PLACEMENT KINDS ===== diff --git a/voidcrew/_DEFINES/bounty_ai.dm b/voidcrew/_DEFINES/bounty_ai.dm index ed0c93adcae..258de038b5f 100644 --- a/voidcrew/_DEFINES/bounty_ai.dm +++ b/voidcrew/_DEFINES/bounty_ai.dm @@ -58,6 +58,8 @@ /// 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" +/// world.time the body may take its next step by hand (bounty_ai_step()): its last step, AI walk or by hand, plus its own move delay +#define BB_BOUNTY_NEXT_STEP_AT "bb_bounty_next_step_at" // ===== ACTIVITY STEPS ===== @@ -200,6 +202,16 @@ #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) +/// A companion joining a fight gets up first: no weapon out, no blow or shot, for this long, so their criminal draws first +#define BOUNTY_COMPANION_DRAW_DELAY (1 SECONDS) +/// A companion's gun is backup: pistol strings this long (a criminal's are BOUNTY_PISTOL_STRING_SHOTS)... +#define BOUNTY_COMPANION_PISTOL_STRING 3 +/// ...and SMG bursts this long (a criminal's are BOUNTY_SMG_BURST) +#define BOUNTY_COMPANION_SMG_BURST 2 +/// Company keys (bounty_roll_company()): one companion's fighting style (BOUNTY_STYLE_*)... +#define BOUNTY_COMPANY_STYLE "style" +/// ...and their chrome keys (BOUNTY_CHROME_*), or null for none +#define BOUNTY_COMPANY_CHROME "chrome" // ===== 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 @@ -220,7 +232,9 @@ #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 +/// A gun fires at anyone it can see this far off, while its holder still walks in to its style's own distance (BOUNTY_PISTOL_RANGE). The shotgun's spread and the bottle's throw keep them to their own. +#define BOUNTY_GUN_FIRE_RANGE 7 +/// Walks in to about this far away #define BOUNTY_PISTOL_RANGE 5 #define BOUNTY_PISTOL_MIN_RANGE 3 /// Raising the gun before the first shot of a string diff --git a/voidcrew/_DEFINES/bounty_bosses.dm b/voidcrew/_DEFINES/bounty_bosses.dm index b647004b3fd..8a720d57902 100644 --- a/voidcrew/_DEFINES/bounty_bosses.dm +++ b/voidcrew/_DEFINES/bounty_bosses.dm @@ -13,10 +13,14 @@ /// 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) +/// Its combat stimulant, used through combat sense's rule (human_npc_combat_sense.dm) when it tires in a fight, never while one is still in its blood (C8; it used to inject at the start of a fight, 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) +/// How many of BOUNTY_BOSS_STIMULANT it carries: one for when it first tires, one for a long fight (an ephedrine pen lasts about 100 s). (phase D) #define BOUNTY_BOSS_STIMULANTS 2 +/// Its combat stimpack, one per kit beside BOUNTY_BOSS_STIMULANTS: stimulants and omnizine, used through the same combat sense rule as the others, never while a stimulant is still in its blood +#define BOUNTY_BOSS_COMBAT_STIMULANT /obj/item/reagent_containers/hypospray/medipen/stimpack/traitor +/// The cell in the standard core of a mini-boss's MODsuit (bounty_suits.dm): about 2 hours of a suit running at tg's base drain. The suit doesn't run while its wearer is dormant. +#define BOUNTY_BOSS_MODSUIT_CELL /obj/item/stock_parts/power_store/cell/bluespace /// 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) @@ -60,6 +64,33 @@ /// A spot any player within this many tiles can see is in view. (phase D) #define BOUNTY_BOSS_REINFORCE_SIGHT 13 +// ===== HURT FROM WHERE IT CAN'T REACH (review r1 F4, r2) ===== + +/// Someone who hurt it from where it can't get at them (behind glass, a shut door or a gap, or off its site) is shunned this long: it doesn't go after them, and it keeps out of their sight +#define BOUNTY_BOSS_SHUN_TIME (60 SECONDS) +/// How far it walks for cover, in steps +#define BOUNTY_BOSS_COVER_RANGE 7 +/// How far a shooter is taken to see, for cover, at the least: one farther off sees as far as a clear line from them goes (a scope, or a shot from across the site) +#define BOUNTY_BOSS_COVER_SIGHT 9 +/// How far it works out its walk to someone behind something, in tiles, and how long that walk holds while it stands on the same tile. Someone farther off is in reach if the walk gets it at least half this much closer to them. +#define BOUNTY_BOSS_REACH_RANGE 10 +#define BOUNTY_BOSS_REACH_RETHINK (2 SECONDS) +/// It says a line as it breaks for cover at most this often +#define BOUNTY_BOSS_COVER_BARK_COOLDOWN (30 SECONDS) + +// ===== GORILLA ARMS THROUGH GLASS ===== + +/// The tell before its Gorilla Arms go at a window, grille, table or door: the fist drawn back, the pistons heard, the tile lit. At least 0.8 s (decision 5). +#define BOUNTY_BOSS_SMASH_WINDUP (0.9 SECONDS) +/// What one Gorilla Arms punch does to a structure, used only to count the punches something takes. The punch itself is the implant's (CYBERWARE_GORILLA_STRUCTURE_DAMAGE, which ware_military_arms.dm undefines); a test checks the two agree. +#define BOUNTY_BOSS_SMASH_BLOW 40 +/// It only goes at something it breaks in this many punches; anything tougher, it goes round or takes cover +#define BOUNTY_BOSS_SMASH_MOST_BLOWS 6 +/// The pause after the tell before its next ability may start +#define BOUNTY_BOSS_SMASH_RECOVER (1 SECONDS) +/// The tell's glow and floor mark: the piston punch's orange +#define BOUNTY_BOSS_SMASH_COLOR "#ff8a1f" + // ===== SUMMONED THINGS: CAPS AND LIFETIMES (P4) ===== /// Fire pools (flamer floors and molotovs) burning at once, server-wide @@ -75,6 +106,20 @@ /// 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 +// ===== EACH KIT'S ANSWER TO A DISABLER (C8) ===== +// Real gear a player can own too, worn and locked to the body like the rest of the kit (D3). Measured in +// the port's boss model: a solo hunter with a disabler stamcritted any of them in about two seconds before. + +/// The Juggernaut's tower shield, held from the start and raised as its fight starts: raised, it stops every shot from the half of the map the Juggernaut faces (the Phalanx buckler's own rule, loot/uniques/armory.dm). Flank it. +#define BOUNTY_JUGGERNAUT_SHIELD /obj/item/shield/riot/phalanx_buckler +/// The Heavy's coat: an ablative trenchcoat with its hood up, energy and laser armour 60 on every limb and its head, and half of all beams that hit it reflected (tg's own). Bullets go through it. Bring lethal, or a lot of shots. +#define BOUNTY_HEAVY_COAT /obj/item/clothing/suit/hooded/ablative +/// The Demolitionist's implant: tg's CNS rebooter, one neural load (cyberware_component.dm). Its first stamina crit of a minute lasts a second, then six seconds of stun immunity; cuff it on the second. +#define BOUNTY_DEMOLITIONIST_REBOOTER /obj/item/organ/cyberimp/brain/anti_stun +/// The Ghost's cover from stun fire (combat sense): how many steps it runs for cover, and how many runs it makes in one exchange of fire. Corner it. +#define BOUNTY_GHOST_COVER_STEPS 5 +#define BOUNTY_GHOST_COVER_MOVES 4 + // ===== JUGGERNAUT ===== /// Charge: a roar, a stamp and a cracked-floor line @@ -95,27 +140,37 @@ #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) +/// Slam: both fists up, a red ring. 0.7 -> 0.8 s after review r2, long enough to step out of on sight. +#define BOUNTY_JUGGERNAUT_SLAM_WINDUP (0.8 SECONDS) #define BOUNTY_JUGGERNAUT_SLAM_COOLDOWN (7 SECONDS) #define BOUNTY_JUGGERNAUT_SLAM_DAMAGE 20 #define BOUNTY_JUGGERNAUT_SLAM_KNOCKDOWN (1.5 SECONDS) // ===== PYROMANIAC ===== -/// 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) +/// Its flamethrower: tg's, igniter and full plasma tank fitted, held from the start (it doesn't holster) +#define BOUNTY_PYROMANIAC_FLAMETHROWER /obj/item/flamethrower/full/tank/bounty_boss +/// The bottle in its other hand: tg's molotov, filled with welding fuel +#define BOUNTY_PYROMANIAC_MOLOTOV_BOTTLE /obj/item/reagent_containers/cup/glass/bottle/molotov/bounty_boss +/// Flamer: the pilot light, an orange line on the floor. 0.5 -> 0.8 s after review r2, long enough to step out of on sight. +#define BOUNTY_PYROMANIAC_FLAMER_WINDUP (0.8 SECONDS) #define BOUNTY_PYROMANIAC_FLAMER_COOLDOWN (5 SECONDS) #define BOUNTY_PYROMANIAC_FLAMER_RANGE 3 -/// Full width of the cone, in degrees -#define BOUNTY_PYROMANIAC_FLAMER_ARC 90 +/// Tank pressure (kPa) under which its flamethrower is dry and it won't sweep +#define BOUNTY_PYROMANIAC_FLAMER_EMPTY ONE_ATMOSPHERE +/// The flamethrower stays lit this long after a sweep, then it shuts the valve +#define BOUNTY_PYROMANIAC_FLAMER_SHUTOFF (1 SECONDS) #define BOUNTY_PYROMANIAC_FLAMER_DAMAGE 18 -/// Fire stacks (tg's) the jet puts on anyone in the cone. (phase D, CB-8) +/// Fire stacks (tg's) the jet puts on anyone on its line. (phase D, CB-8) #define BOUNTY_PYROMANIAC_FLAMER_STACKS 4 -/// How long the floor the cone covered keeps burning +/// How long the floor the line covered keeps burning #define BOUNTY_PYROMANIAC_FLAMER_FLOOR (4 SECONDS) +/// Sweeps a plasma tank feeds before the flamethrower runs dry and it changes tanks +#define BOUNTY_PYROMANIAC_FLAMER_SWEEPS 4 +/// Full plasma tanks it carries in its bag for the change +#define BOUNTY_PYROMANIAC_SPARE_TANKS 2 +/// The tank change: it stops to wrench the empty off and fit a full one, at least this long, open the whole time +#define BOUNTY_PYROMANIAC_RELOAD_TIME (3 SECONDS) /// Molotov: a lit rag, the throw, a ring where it lands #define BOUNTY_PYROMANIAC_MOLOTOV_WINDUP (0.7 SECONDS) #define BOUNTY_PYROMANIAC_MOLOTOV_COOLDOWN (7 SECONDS) @@ -124,6 +179,17 @@ /// 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) +/// Smoke (C9): tg's smoke grenade, two in its pockets, on tg's shortest timed fuse (a screwdriver setting a player can pick too) +#define BOUNTY_PYROMANIAC_SMOKE /obj/item/grenade/smokebomb/bounty_boss +#define BOUNTY_PYROMANIAC_SMOKE_FUSE (3 SECONDS) +/// It takes a grenade out and stands this long, then pulls the pin and throws (the Heavy's barrier grenade wind-up) +#define BOUNTY_PYROMANIAC_SMOKE_WINDUP (0.6 SECONDS) +/// Longer than the cloud lasts (tg's 16 s), so it never stacks one on the last +#define BOUNTY_PYROMANIAC_SMOKE_COOLDOWN (20 SECONDS) +/// The furthest shooter it throws at; the nearest is anyone past its flamer's reach +#define BOUNTY_PYROMANIAC_SMOKE_RANGE 7 +/// How long after a hit from someone past its flamer's reach it still answers with smoke (stun fire counts while its combat sense says it is under fire) +#define BOUNTY_PYROMANIAC_SMOKE_HURT_WINDOW (3 SECONDS) // ===== DEMOLITIONIST ===== @@ -158,8 +224,8 @@ /// 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 -/// 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) +/// Dash: a blur line to the target, the Cascade lattice firing as it goes (OC-6 ruling). 0.3 -> 0.6 s after review r2: at 0.3 s only someone already moving could step off the line. +#define BOUNTY_GHOST_DASH_WINDUP (0.6 SECONDS) #define BOUNTY_GHOST_DASH_COOLDOWN (5 SECONDS) #define BOUNTY_GHOST_DASH_RANGE 5 /// Cloak: a shimmer, then a faint distortion. Only how it looks: nothing misses it for it (OC-6 ruling, CB-12) @@ -214,3 +280,7 @@ #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" +/// Where it is walking to, to go through the window, door or wall in its way +#define BB_BOUNTY_BOSS_SPOT "BB_bounty_boss_spot" +/// Where it is walking to, out of the sight of someone it can't get at +#define BB_BOUNTY_BOSS_COVER "BB_bounty_boss_cover" diff --git a/voidcrew/_DEFINES/bounty_chrome.dm b/voidcrew/_DEFINES/bounty_chrome.dm new file mode 100644 index 00000000000..8a9357d9daa --- /dev/null +++ b/voidcrew/_DEFINES/bounty_chrome.dm @@ -0,0 +1,56 @@ +// ===== BOUNTY CHROME (voidcrew/modules/bounties/bounty_chrome.dm) ===== + +/// Percent chance a criminal of each tier carries chrome at all +#define BOUNTY_CHROME_CHANCE_PETTY 10 +#define BOUNTY_CHROME_CHANCE_WANTED 35 +#define BOUNTY_CHROME_CHANCE_MOST_WANTED 60 +/// Percent chance a Wanted or Most Wanted carrier has a second piece, if one fits +#define BOUNTY_CHROME_SECOND_CHANCE 30 +/// A companion's chance is its criminal's tier chance divided by this, and it carries one piece at most +#define BOUNTY_CHROME_COMPANION_DIVISOR 3 +/// The archetype a companion rolls chrome as (the criminal archetypes are BOUNTY_ARCHETYPE_*) +#define BOUNTY_CHROME_COMPANION "companion" + +/// The chrome keys, one per /datum/bounty_chrome_piece subtype +#define BOUNTY_CHROME_CASCADE "cascade" +#define BOUNTY_CHROME_MANTIS "mantis" +#define BOUNTY_CHROME_GORILLA "gorilla" +#define BOUNTY_CHROME_REDLINE "redline" +#define BOUNTY_CHROME_PILEDRIVER "piledriver" +#define BOUNTY_CHROME_LAZARUS "lazarus" +#define BOUNTY_CHROME_DEADEYE "deadeye" + +/// The shortest tell a chrome move may have before it fires the implant (owner decision 5) +#define BOUNTY_CHROME_TELL_MIN (0.8 SECONDS) +/// After a fight starts, how long before the first chrome move may start +#define BOUNTY_CHROME_OPENING (1.5 SECONDS) +/// The shortest gap between two chrome moves of one NPC +#define BOUNTY_CHROME_MOVE_GAP (4 SECONDS) +/// The outline a tell shows, unless the move picks its own colour +#define BOUNTY_CHROME_TELL_COLOR "#ff2079" +/// Trait source for standing still through a tell +#define BOUNTY_CHROME_TRAIT "bounty_chrome" + +/// Why a tell was cut short (/datum/bounty_chrome_move/proc/cancel()) +#define BOUNTY_CHROME_CANCEL_DOWNED "downed" +#define BOUNTY_CHROME_CANCEL_STUNNED "stunned" +#define BOUNTY_CHROME_CANCEL_RESTRAINED "restrained" +#define BOUNTY_CHROME_CANCEL_EMP "emp" +#define BOUNTY_CHROME_CANCEL_DEATH "death" +#define BOUNTY_CHROME_CANCEL_GONE "gone" + +/// Sent on a carbon whose chrome a pair of cyber optics just read, if it felt the read (cyberware_scan.dm): (mob/living/carbon/reader) +#define COMSIG_CARBON_CHROME_READ "carbon_chrome_read" +/// How soon a bounty NPC answers another chrome read after answering one +#define BOUNTY_CHROME_READ_NOTICE_COOLDOWN (20 SECONDS) + +/// A malfunction (bounty_chrome_malfunction_fx()): how often it twitches and spits sparks, its outline's name, and its chrome blue +#define BOUNTY_CHROME_MALFUNCTION_PULSE (0.4 SECONDS) +#define BOUNTY_CHROME_MALFUNCTION_FILTER "bounty_chrome_malfunction" +#define BOUNTY_CHROME_MALFUNCTION_COLOR "#7fd4ff" +/// A colour matrix turning tg's yellow arcs a hot chrome blue, their brightest parts near white +#define BOUNTY_CHROME_MALFUNCTION_MATRIX list(0.25, 0.45, 0.55, 0.25, 0.45, 0.55, 0.25, 0.45, 0.55, 0, 0, 0) + +/// The Bounty Panel's chrome choices (bounty_admin.dm): roll it as usual, or every piece that fits +#define BOUNTY_ADMIN_CHROME_ROLL "roll" +#define BOUNTY_ADMIN_CHROME_ALL "all" diff --git a/voidcrew/_DEFINES/cyberware.dm b/voidcrew/_DEFINES/cyberware.dm index 02a5ffdaa13..cf6eb52c4f0 100644 --- a/voidcrew/_DEFINES/cyberware.dm +++ b/voidcrew/_DEFINES/cyberware.dm @@ -11,12 +11,19 @@ #define CYBERWARE_BIOTECH_CAPACITY 15 #define TRAIT_BIOTECH_NEURAL "biotech_neural" -/// Mob-overlay height worn chrome draws at: between the character-setup -/// underwear/undershirt layer (BODY_LAYER, 32) and the eyes (EYES_LAYER, 31), -/// so a spine rig reads over a bra or undershirt while every EQUIPPED -/// clothing layer (UNIFORM_LAYER 28 and up) still covers it. Fractional on -/// purpose, it must never collide with a real layer index. -#define CYBERWARE_WORN_LAYER 31.5 +/// Mob-overlay height worn chrome draws at: just over the jumpsuit +/// (UNIFORM_LAYER, 28) and under the worn ID (ID_LAYER, 27), so arm plates and +/// a spine rig read over normal clothes while hands (BODYPARTS_HIGH_LAYER 25), +/// gloves, shoes and every suit, vest or armour layer (SUIT_LAYER 19 and up) +/// still cover them. Mob layers count down: a lower number draws on top. +/// Fractional on purpose, it must never collide with a real layer index, nor +/// with a fresh stump (HV_STUMP_FRESH_LAYER, 27.5). +#define CYBERWARE_WORN_LAYER 27.6 +/// Mob layer the lit nodes of a spine rig (Cascade, Redline) shine at: just over +/// whatever is worn on the back (BACK_LAYER 14, and every suit and cloak under +/// it), still under hair (HAIR_LAYER 13) and headgear. Only what glows goes up +/// here; the housing and dark nodes stay at CYBERWARE_WORN_LAYER. +#define CYBERWARE_SPINE_SHINE_LAYER 13.7 // ---- Organ slots ------------------------------------------------------- // Minted here, never in DNA.dm. Slot uniqueness is global per mob, so @@ -150,3 +157,100 @@ /// Minimum environmental O2 partial pressure (kPa) the bladder considers /// breathable, mirroring the lungs' safe_oxygen_min of 16. #define CYBERWARE_BREATHABLE_O2_KPA 16 + +// ---- Optics zoom (cyberware_zoom.dm) ----------------------------------- +// Every set of chrome optics can zoom: tg's scope component pans the camera +// toward the cursor. A zoomed bearer can't fire a gun and their clicks reach +// nothing on the map. + +/// Held by a bearer while their chrome optics are zoomed. Source is the optics. +#define TRAIT_CYBER_ZOOMED "cyber_zoomed" + +// ---- Chrome wheel (chrome_wheel.dm) ------------------------------------ + +/// Name of the "Chrome wheel" keybind; the release poll reads the player's +/// keys for it to catch modifier binds, which never get a keyUp of their own. +#define CHROME_WHEEL_KEYBIND "chrome_wheel" +/// A wheel key let go sooner than this was a tap, and the wheel stays open +/// for a click instead of closing on release. +#define CHROME_WHEEL_HOLD_TIME (0.3 SECONDS) + +/// Wheel states. CLOSED, HELD (open while the key is down) or CLICK (open +/// after a tap, until the next click or press). +#define CHROME_WHEEL_CLOSED 0 +#define CHROME_WHEEL_HELD 1 +#define CHROME_WHEEL_CLICK 2 + +/// Sockets: where a ware's chips sit on the ring. Each owns a run of fixed +/// positions on its region's arc, so one socket's chrome changing never moves +/// another socket's chips. Hand chrome rides its arm's socket. +#define CHROME_WHEEL_SOCKET_EYES "eyes" +#define CHROME_WHEEL_SOCKET_HEAD "head" +#define CHROME_WHEEL_SOCKET_OS "os" +#define CHROME_WHEEL_SOCKET_SKIN "skin" +#define CHROME_WHEEL_SOCKET_LEFT_ARM "l_arm" +#define CHROME_WHEEL_SOCKET_RIGHT_ARM "r_arm" +#define CHROME_WHEEL_SOCKET_LEGS "legs" + +/// Radius in pixels of the ring the chips sit on. +#define CHROME_WHEEL_RADIUS 100 +/// Degrees between neighbouring chips on the ring. +#define CHROME_WHEEL_STEP 14.5 +/// A socket with more chips than its arc holds starts another row this much +/// further out, at the same angles. +#define CHROME_WHEEL_ROW_GAP 26 +/// The ring's centre sits this many pixels above the centre of the view. +#define CHROME_WHEEL_CENTRE_Y 2 +/// Mouse distance from the ring centre inside which nothing is pointed at. +#define CHROME_WHEEL_DEADZONE 34 +/// A chip this close to the mouse is the one under it. +#define CHROME_WHEEL_PICK_RANGE 12 +/// Otherwise the mouse points at the first-row chip whose bearing from the ring +/// centre is nearest its own, if one lies within this many degrees. +#define CHROME_WHEEL_POINT_TOLERANCE 13 + +/// After a pick the wheel stays up this long for the lock and fade. The pick +/// itself lands at once. +#define CHROME_WHEEL_LINGER_TIME (0.2 SECONDS) +/// A wheel opened from the Chrome button fires what a click picks, so a click +/// further than this from the ring's centre picks by bearing no more: out past +/// the second row, a click just shuts the wheel. +#define CHROME_WHEEL_FIRE_REACH (CHROME_WHEEL_RADIUS + CHROME_WHEEL_ROW_GAP + 24) +/// Reserves Arm chrome's place on the wheel (GLOB.chrome_wheel_reserved), as an +/// organ slot reserves its ware's. +#define CHROME_WHEEL_ARMS_KEY "chrome_arms" +/// The region an Arm chrome chip lights: both arms. +#define CHROME_WHEEL_REGION_ARMS "arms" +/// The Chrome button's and Arm chrome's own art. +#define CHROME_HUD_ICON 'voidcrew/modules/cyberware/icons/chrome_hud.dmi' + +#define CHROME_WHEEL_ICON 'voidcrew/modules/cyberware/icons/chrome_wheel.dmi' +/// 240x240 art centred on the ring: body, arcs, leaders, glows, backdrop. +#define CHROME_WHEEL_RING_ICON 'voidcrew/modules/cyberware/icons/chrome_wheel_ring.dmi' +/// Corner brackets borrowed from the chrome read. +#define CHROME_WHEEL_BRACKET_ICON 'voidcrew/modules/cyberware/icons/chrome_read.dmi' + +/// Wheel colours, the chrome read's own. +#define CHROME_WHEEL_HUD_COLOR CYBERWARE_COLOR_TIER_2 +#define CHROME_WHEEL_PANEL_COLOR "#060e12" +#define CHROME_WHEEL_NAME_COLOR "#e6fbff" +#define CHROME_WHEEL_DIM_COLOR "#8fa1a8" +#define CHROME_WHEEL_OFFLINE_COLOR "#ff5a4a" +#define CHROME_WHEEL_OFFLINE_NAME_COLOR "#7d8a90" +/// The pick's brackets (radial.dmi's module_selected cyan). +#define CHROME_WHEEL_PICKED_COLOR "#00ffff" +/// Deployed or armed (radial.dmi's module_active green). +#define CHROME_WHEEL_DEPLOYED_COLOR "#00ff00" + +// ---- Phase 2 models: seal, frame and nervous street models ------------- +// ware_models_b.dm. Hardweave, the Strut frame, the Deep-lung bladder, the +// Heat-sink and Frostline linings, the Twitchwire and Weaver shunts, and the +// Thumper ear. + +/// Held by a bearer whose skeleton simply does not break. Blocks the whole +/// bone wound series, dislocations, hairline fractures, compound fractures, +/// at the wound system's own gate, and nothing else. Every other wound series +/// lands on its bearer exactly as it lands on anyone. Granted by the Atlas +/// frame (ware_military_body.dm) and the Strut frame (ware_models_b.dm); the +/// gate itself is in ware_military_body.dm. +#define TRAIT_CYBERWARE_UNBREAKABLE_BONES "cyberware_unbreakable_bones" diff --git a/voidcrew/_DEFINES/gorilla_gore.dm b/voidcrew/_DEFINES/gorilla_gore.dm new file mode 100644 index 00000000000..31e6ec17bff --- /dev/null +++ b/voidcrew/_DEFINES/gorilla_gore.dm @@ -0,0 +1,361 @@ +// Gorilla Arms x hyperviolence (voidcrew/modules/hyperviolence_gorilla/). Balance notes for +// developers; none of these numbers go in player text. Unit tests can't see these (they compile +// before voidcrew/_DEFINES/), so tests use the literal values with a comment naming the define. + +/// 32x32 pictures: knuckle sparks, piston pumps and heat, scuffs, the pry seam, snapped bones, dents, +/// the finisher masks. +#define GORILLA_GORE_ICON 'voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore.dmi' +/// 64x64 pictures drawn at -16,-16 on the floor tile in front of a wall: the wall impacts. +#define GORILLA_GORE_LARGE_ICON 'voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore_large.dmi' + +/// Layer for sparks and flashes over the whole body. +#define GORILLA_ANIM_TOP_LAYER (-(HIGHEST_LAYER - 0.5)) +/// Layer for the piston pump and heat over the worn arm plates: just above the plates (under suits). +#define GORILLA_ANIM_PLATE_LAYER (-(CYBERWARE_WORN_LAYER - 0.05)) + +// ---- The punch (gorilla_punch.dm) ---- + +/// Wound bonus on a Gorilla piston punch; the Brawler keeps its own. +#define GORILLA_PUNCH_WOUND_BONUS 15 +/// Wound bonus on a Brawler punch. +#define BRAWLER_PUNCH_WOUND_BONUS 10 +/// Brute after armour a punch must deal to strain the limb it hit. +#define GORILLA_STRAIN_MIN_DAMAGE 8 +/// How long a limb holds strain after its last hit. +#define GORILLA_STRAIN_MEMORY (15 SECONDS) +/// Melee cover on a limb (after penetration) that stops a forced snap: #509's aorta scale. +#define GORILLA_SNAP_ARMOUR 40 + +// ---- Shared cooldowns, kept on the bearer (TIMER_COOLDOWN) so both arms share them ---- + +/// The haymaker and every finisher: the pistons are spent. +#define COOLDOWN_GORILLA_PISTONS "gorilla_pistons" +/// The hurl and the slam: one grab move at a time. +#define COOLDOWN_GORILLA_GRAB_MOVE "gorilla_grab_move" +/// The ground pound. +#define COOLDOWN_GORILLA_POUND "gorilla_pound" +/// The deploy flex (cosmetic). +#define COOLDOWN_GORILLA_FLEX "gorilla_flex" + +#define GORILLA_PISTONS_COOLDOWN (20 SECONDS) +/// After a finisher that was called off before the kill. +#define GORILLA_PISTONS_INTERRUPTED (10 SECONDS) +/// After a haymaker held too long and vented. +#define GORILLA_PISTONS_VENTED (5 SECONDS) +#define GORILLA_GRAB_MOVE_COOLDOWN (10 SECONDS) +#define GORILLA_POUND_COOLDOWN (45 SECONDS) +#define GORILLA_FLEX_COOLDOWN (10 SECONDS) +/// A powered airlock forced by the synced Gorilla pair. +#define GORILLA_PRY_TIME (4 SECONDS) + +// ---- The haymaker (gorilla_haymaker.dm) ---- + +#define GORILLA_HAYMAKER_MIN_CHARGE (0.8 SECONDS) +#define GORILLA_HAYMAKER_FULL_CHARGE (1.5 SECONDS) +/// Held this long, the pistons vent and the charge is lost. +#define GORILLA_HAYMAKER_VENT_AFTER (3 SECONDS) +/// A press of Use chrome shorter than this is a tap: the charge waits for a click. +#define GORILLA_HAYMAKER_TAP (0.3 SECONDS) +/// Pixels the bearer leans back at full charge, seen from the side. The lean builds to it over the wind-up. +#define GORILLA_HAYMAKER_LEAN 4 +#define GORILLA_HAYMAKER_MIN_DAMAGE 20 +#define GORILLA_HAYMAKER_MAX_DAMAGE 30 +#define GORILLA_HAYMAKER_MIN_RANGE 3 +#define GORILLA_HAYMAKER_MAX_RANGE 4 +#define GORILLA_HAYMAKER_SPEED 3 +/// The real body stays on show this long as the wind-up's puppets come up (chrome_rig/conceal_after()). +#define GORILLA_HAYMAKER_RIG_HOLD (0.04 SECONDS) +/// The punching arm is half drawn back this far into the wind-up... +#define GORILLA_HAYMAKER_DRAW (0.4 SECONDS) +/// ...and all the way back by this, a throw's length before the earliest blow. +#define GORILLA_HAYMAKER_DRAWN (0.75 SECONDS) +/// The throw: the blow lands this long after the fist is thrown. One server tick. +#define GORILLA_HAYMAKER_THROW (0.05 SECONDS) +/// The thrown fist is on what it hits this soon, a moment before the blow is due... +#define GORILLA_HAYMAKER_OUT (0.03 SECONDS) +/// ...stays there while the blow lands, so the blow's sparks find it there whichever reaches a client first... +#define GORILLA_HAYMAKER_DWELL (0.15 SECONDS) +/// ...carries on past it... +#define GORILLA_HAYMAKER_FOLLOW (0.15 SECONDS) +/// ...and the arms come back to rest. +#define GORILLA_HAYMAKER_RETURN (0.22 SECONDS) +/// A wind-up held too long or called off: the arms come down. +#define GORILLA_HAYMAKER_LOWER (0.25 SECONDS) +/// Pixels the body steps in behind the throw: as few as put the fist on the body. +#define GORILLA_HAYMAKER_STEP_MIN 12 +#define GORILLA_HAYMAKER_STEP_MAX 16 + +// ---- The punching arm (gorilla_swing.dm, gorilla_thrust.dm) ---- + +/// The pace of one beat of a swing: even, fast then settling, or eased in and out. +#define CHROME_SWING_LINEAR 0 +#define CHROME_SWING_EASE_OUT 1 +#define CHROME_SWING_EASE_IN_OUT 2 + +/// A piston punch: the fist draws back... +#define GORILLA_THRUST_BACK (0.04 SECONDS) +/// ...the piston drives it out... +#define GORILLA_THRUST_OUT (0.04 SECONDS) +/// ...and it stays on what it hit while the blow lands, so the sparks find it there whichever reaches a client first. +#define GORILLA_THRUST_DWELL (0.08 SECONDS) +/// The arm comes back to rest. +#define GORILLA_THRUST_REST (0.14 SECONDS) +/// How long after the click a piston punch lands: every punch, with the fist a moment into its stay. +#define GORILLA_THRUST_LANDS (0.1 SECONDS) +/// The first time an arm's picture is shown it may still be on its way to a client: the real arm stays on show this long, in place of the draw-back, and the fist is driven out in what is left before it is due. +#define GORILLA_THRUST_HOLD (0.05 SECONDS) +/// Pixels the body lunges behind a piston punch: tg's lunge at the least, further when the fist would stop short. +#define GORILLA_THRUST_LUNGE_MIN 8 +#define GORILLA_THRUST_LUNGE_MAX 16 +/// Degrees the body tips into a piston punch, as tg's lunge tips it. +#define GORILLA_THRUST_TIP 15 +/// How long a punching arm is drawn, as a share of its own length: the body steps in until the fist lands with the arm no longer than the first, and the arm is never drawn longer than the second (what a fist takes to reach the shin of a body beside its bearer). +#define GORILLA_SWING_EASY_LENGTH 1.9 +#define GORILLA_SWING_MAX_LENGTH 3.3 +/// The most pixels a body steps in behind a fist thrown up or down the screen: further, and it stands on whoever it hits. +#define GORILLA_SWING_STEP_UPRIGHT 12 +/// Pixels from the middle of a stretched fist to its knuckles: it stops this far short of the body it lands on. +#define GORILLA_FIST_KNUCKLES 2.5 + +// ---- Grab and slam ---- + +#define GORILLA_SLAM_FLOOR_DAMAGE 25 +#define GORILLA_SLAM_FLOOR_STAMINA 30 +#define GORILLA_SLAM_TABLE_DAMAGE 30 +#define GORILLA_SLAM_TABLE_STAMINA 40 +#define GORILLA_SLAM_KNOCKDOWN (2 SECONDS) +#define GORILLA_SLAM_TABLE_BREAK 50 +// The slam's beats (gorilla_slam.dm), each a whole number of GORILLA_SLAM_STEPs. From the click: the grip, the hoist, the held +// beat at the top and the drive down, then the impact. Gorilla Arms: 0.44 s to the impact and 0.70 s in all. +#define GORILLA_SLAM_GRIP_TIME (0.08 SECONDS) +#define GORILLA_SLAM_HOIST_TIME (0.2 SECONDS) +#define GORILLA_SLAM_TOP_TIME (0.06 SECONDS) +#define GORILLA_SLAM_DRIVE_TIME (0.1 SECONDS) +/// After the impact: how long the body takes to come to rest, the bearer to stand back up, and the puppets to go. +#define GORILLA_SLAM_REBOUND_TIME (0.12 SECONDS) +#define GORILLA_SLAM_RISE_TIME (0.18 SECONDS) +#define GORILLA_SLAM_SETTLE_TIME (0.26 SECONDS) +/// How long a body takes to come down on its feet when the slam is called off. +#define GORILLA_SLAM_SET_DOWN_TIME (0.15 SECONDS) +/// The length of one straight step of the slam's puppets, and of the swap between the bearer's two rigs when he turns. +#define GORILLA_SLAM_STEP (0.02 SECONDS) +#define GORILLA_SLAM_SWAP (0.01 SECONDS) +/// The most and the least his piston arms are drawn to keep a fist on the body, as shares of their length. +#define GORILLA_SLAM_MAX_REACH 2.2 +#define GORILLA_SLAM_MIN_REACH 0.4 +/// Where the middle of the body is at the top of the lift, in pixels from the bearer: in front of him and up, seen from the +/// side; aside and up, seen from the front or back. Gorilla Arms press it overhead, flat. +#define GORILLA_SLAM_TOP_SIDE_X 4 +#define GORILLA_SLAM_TOP_SIDE_Y 22 +#define GORILLA_SLAM_TOP_FRONT_X 3 +#define GORILLA_SLAM_TOP_FRONT_Y 28 +/// Seen from behind, the floor in front of him is up the screen too, about where a body held overhead is drawn. So he goes +/// up on his toes at the top and holds it this high, and it has somewhere to come down from. +#define GORILLA_SLAM_TOP_BACK_Y 34 +#define GORILLA_SLAM_TOP_BACK_RISE 4 +/// How far up tg draws a body lying on a table. +#define GORILLA_SLAM_TABLE_TOP 12 +/// Pixels a slammed body bounces off what it lands on, and the degrees it tips as it does. +#define GORILLA_SLAM_BOUNCE 4 +#define GORILLA_SLAM_BOUNCE_TIP 6 +/// Drops of blood thrown out round a body the slam cut open: the fewest and the most, and how far from it they land. +#define GORILLA_SLAM_DROPS_MIN 5 +#define GORILLA_SLAM_DROPS_MAX 7 +#define GORILLA_SLAM_DROPS_NEAR 9 +#define GORILLA_SLAM_DROPS_FAR 19 +/// What holds the bearer where he stands for the slam. +#define GORILLA_SLAM_TRAIT "gorilla_slam" + +// ---- Brawler myomers (ware_line_models_a.dm): the street slam, pound, smash and pry ---- + +#define BRAWLER_SLAM_FLOOR_DAMAGE 18 +#define BRAWLER_SLAM_FLOOR_STAMINA 20 +#define BRAWLER_SLAM_TABLE_DAMAGE 22 +#define BRAWLER_SLAM_TABLE_STAMINA 30 +#define BRAWLER_SLAM_KNOCKDOWN (1 SECONDS) +#define BRAWLER_SLAM_TABLE_BREAK 30 +/// The Brawler's shorter haul: 0.40 s to the impact. It brings the body to the shoulder, tipped back and not yet flat. +#define BRAWLER_SLAM_HOIST_TIME (0.16 SECONDS) +#define BRAWLER_SLAM_TOP_SIDE_X 11 +#define BRAWLER_SLAM_TOP_SIDE_Y 13 +#define BRAWLER_SLAM_TOP_FRONT_X 2 +#define BRAWLER_SLAM_TOP_FRONT_Y 18 +#define BRAWLER_SLAM_TOP_TURN 62 +#define BRAWLER_SLAM_BOUNCE 2 +#define BRAWLER_GRAB_MOVE_COOLDOWN (15 SECONDS) +/// Damage per structure smash: over a plain airlock's deflection (21) and a reinforced one's (30). +#define BRAWLER_STRUCTURE_DAMAGE 32 +/// A powered airlock forced by the synced pair. The Gorilla takes GORILLA_PRY_TIME. +#define BRAWLER_PRY_TIME (7 SECONDS) +#define BRAWLER_POUND_COOLDOWN (60 SECONDS) +#define BRAWLER_POUND_STAGGER (6 SECONDS) +#define BRAWLER_POUND_STAMINA 10 +/// What a click while grabbing turned into (gorilla_arms/proc/try_slam()). Not a slam: carry on with the punch. +#define GORILLA_SLAM_NO 0 +/// A slam was done. +#define GORILLA_SLAM_DONE 1 +/// A slam onto a table that can't happen now: leave the click to tg's own table smash. +#define GORILLA_SLAM_PASS 2 + +// ---- Throws (gorilla_throw.dm) ---- + +/// What stopped a planned knockback short of its full reach. +#define GORILLA_THROW_CLEAR 0 +/// A wall: the body hits it. +#define GORILLA_THROW_WALL 1 +/// A mob standing in the way: the body hits it. +#define GORILLA_THROW_MOB 2 +/// Glass, a door, a railing, a hazard or no gravity: the body stops short and hits nothing. +#define GORILLA_THROW_SHORT 3 +/// Most decals a Gorilla throw leaves along its path. +#define GORILLA_TRAIL_MAX 4 +/// Most blood drops and splats one tile of a bleeding body's skid gets. +#define GORILLA_SKID_SPLATS 4 + +// What a wall impact draws, by the injury it caused (owner D38). +/// No skin broken: a dent and chips. +#define GORILLA_SPLAT_DENT 1 +/// Skin broken, moderate: a half-moon on the floor and a thin smear on the wall's edge. +#define GORILLA_SPLAT_EDGE 2 +/// Severe bleeding or a torn artery: a spray up the wall and runs. +#define GORILLA_SPLAT_SPRAY 3 + +// How hard a Gorilla throw meets a wall (owner D48). The crash goes through tg's damage and wound rolls. +/// The one-tile shove off a punch (both lines): a dent, no damage, no knockdown. +#define GORILLA_IMPACT_SHOVE 1 +/// The grab hurl. +#define GORILLA_IMPACT_HURL 2 +/// The haymaker. +#define GORILLA_IMPACT_HAYMAKER 3 +/// A hurl's blunt hit on the part that meets the wall, and its wound bonus. +#define GORILLA_WALL_HURL_BLUNT 6 +#define GORILLA_WALL_HURL_BLUNT_WOUND 15 +/// A hurl's split skin on the wall's edge (a slash roll), and its wound bonus. +#define GORILLA_WALL_HURL_EDGE 6 +#define GORILLA_WALL_HURL_EDGE_WOUND 5 +/// A haymaker's blunt hit and its wound bonus. +#define GORILLA_WALL_HAYMAKER_BLUNT 16 +#define GORILLA_WALL_HAYMAKER_BLUNT_WOUND 25 +/// A haymaker's split skin and its wound bonus. +#define GORILLA_WALL_HAYMAKER_EDGE 8 +#define GORILLA_WALL_HAYMAKER_EDGE_WOUND 15 +/// A part already beaten adds a point of wound bonus per this much brute on it... +#define GORILLA_WALL_HURT_PER_POINT 4 +/// ...up to this many. +#define GORILLA_WALL_HURT_MAX 15 +/// The knockdown of a hard crash, as tg's own wall crash. +#define GORILLA_WALL_KNOCKDOWN (2 SECONDS) + +// ---- Ground pound ---- + +#define GORILLA_POUND_CROUCH (0.45 SECONDS) +/// How long the fists take from overhead to the floor +#define GORILLA_POUND_DRIVE (0.08 SECONDS) +/// How long the bearer takes to stand back up after a ground pound +#define GORILLA_POUND_RISE (0.3 SECONDS) +#define GORILLA_POUND_STAMINA 20 +/// The longest stagger a pound leaves. +#define GORILLA_POUND_STAGGER (10 SECONDS) +#define GORILLA_POUND_DAZE (3 SECONDS) +/// Loose items this far from the pound hop a tile outward. +#define GORILLA_POUND_ITEM_REACH 2 + +// ---- Finishers (gorilla_finisher.dm) ---- + +/// Damage on the bearer that makes them let go. +#define GORILLA_FINISHER_INTERRUPT 10 +/// Melee cover on the head that turns the head clap's burst into a crumpled helmet: #509's skull gate. +#define GORILLA_CLAP_HELMET_ARMOUR 30 +/// Melee cover on an arm that turns the limb rip into a dislocation. +#define GORILLA_RIP_ARMOUR 40 +/// The limb rip's look. Pixels the bearer steps in toward the body, and degrees he leans back from his feet as he +/// hauls (seen from the side). +#define GORILLA_RIP_LEAN 5 +#define GORILLA_RIP_LEAN_BACK 12 +/// How far his piston arms push out to take the wrist, as a share of their length. They hold it there as he hauls. +#define GORILLA_RIP_REACH 1.7 +/// The hauled arm, as a share of its length: the most it stretches to meet his fists, how much further the haul +/// pulls it, and the most it ever stretches. +#define GORILLA_RIP_MAX_STRETCH 1.8 +#define GORILLA_RIP_HAUL 0.35 +#define GORILLA_RIP_MAX_HAUL 2.1 +/// Seen from the side, degrees the arm comes up off the floor into his fists. +#define GORILLA_RIP_TILT 30 +/// The haul's steps, and the pixels the body comes up off the floor with the arm. +#define GORILLA_RIP_HAUL_STEPS 6 +#define GORILLA_RIP_LIFT 3 +/// Melee cover on the chest that turns the broken back into cracked ribs. +#define GORILLA_BACK_ARMOUR 40 +/// How long a broken back's fold stays drawn after the finisher, and how long it then takes to ease out flat. +#define GORILLA_FOLD_TIME (10 SECONDS) +#define GORILLA_FOLD_SETTLE (0.6 SECONDS) +/// The head clap's burst: one short line of blood this many tiles long. +#define GORILLA_CLAP_SPRAY_TILES 2 +/// How far the head clap throws the brain (the eyes, ears and tongue drop on the spot or a tile out). +#define GORILLA_CLAP_BRAIN_MIN 1 +#define GORILLA_CLAP_BRAIN_MAX 2 +/// The head clap's look. How far the held body is brought in toward the bearer (a share of a tile) and how many pixels +/// up it is held until the burst, seen from the side, the front and the back: close enough for his fists to close on its head. +#define GORILLA_CLAP_HOLD_SIDE 0.875 +#define GORILLA_CLAP_HOLD_FRONT 0.7 +#define GORILLA_CLAP_HOLD_BACK 0.85 +#define GORILLA_CLAP_LIFT_SIDE 1 +#define GORILLA_CLAP_LIFT_FRONT 15 +#define GORILLA_CLAP_LIFT_BACK 3 +/// The most his piston arms push out to reach the head, as a share of their length, and the pixels they come off it before the clap. +#define GORILLA_CLAP_MAX_REACH 2.1 +#define GORILLA_CLAP_WIND 3 +/// How long the burst body takes to fall from where it was held. +#define GORILLA_CLAP_DROP_TIME (0.2 SECONDS) +/// The head clap's hold: the fists work the head and the body hangs from it, so it goes wherever they take it. Pixels they shake +/// it side to side and lift it in the squeeze, lift it on for the toss, and drive it back down on the clap. Cut back wherever his +/// arms couldn't stay on the head. +#define GORILLA_CLAP_SHAKE 3 +#define GORILLA_CLAP_HEAVE 2 +#define GORILLA_CLAP_TOSS_LIFT 2 +#define GORILLA_CLAP_SLAM 2 +/// Degrees the hanging body swings behind its head for each pixel the head is shaken aside, and the most it swings. +#define GORILLA_CLAP_SWAY 2.5 +#define GORILLA_CLAP_MAX_SWAY 7 +/// The limb rip's haul: the most degrees the body turns up about its feet toward his fists as the arm is pulled, and how long +/// it takes to fall back flat when the arm gives. +#define GORILLA_RIP_RAISE 22 +#define GORILLA_RIP_FALL_TIME (0.25 SECONDS) +/// How long the let-go body takes to slide back to where tg lays it (tg's own offset slide). +#define GORILLA_RIP_LET_GO (0.2 SECONDS) +/// How long nothing moves at the start of the plant, while the puppets' pictures reach the client. The plant's own +/// 0.3 s still ends inside its stage. +#define GORILLA_RIP_START_HOLD (0.15 SECONDS) +/// Seen from behind, how long the torn arm takes to come down with his fist and hang beside him. +#define GORILLA_RIP_HANG_TIME (0.25 SECONDS) +/// The limb rip's blood: how many drops burst from the socket as the arm comes away, and the furthest (pixels) the pool +/// under the shoulder is laid from the middle of the body's tile. +#define GORILLA_RIP_BURST_DROPS 12 +#define GORILLA_RIP_POOL_REACH 10 +/// The limb rip's blow with the torn arm: up over his head, then down on theirs. The hit lands as it comes down. +#define GORILLA_CLUB_RAISE (0.2 SECONDS) +#define GORILLA_CLUB_STRIKE (0.1 SECONDS) +/// How long before the arm is all the way down the blow lands (recorded 0 to 0.12 s late without it). +#define GORILLA_CLUB_HIT_LEAD (0.05 SECONDS) +/// How far his arms push out on that blow, and the most the torn arm in his fists stretches to reach, as shares of their length. +#define GORILLA_CLUB_REACH 1.6 +#define GORILLA_CLUB_MAX_STRETCH 1.5 +/// Pixels toward the viewer a backbroken body lies on the bearer's tile, so he doesn't hide it, and the offset's source. +#define GORILLA_BACK_IN_FRONT 10 +#define GORILLA_LAID_IN_FRONT_OFFSET "gorilla_laid_in_front" +/// How long a broken back stays folded over the knee before it is rolled off. +#define GORILLA_BACK_FOLD_HOLD (0.3 SECONDS) +/// The shove off the knee onto the tile ahead: how long the body is in the air, and how many pixels it rises on the way. +#define GORILLA_BACK_SHOVE_TIME (0.45 SECONDS) +#define GORILLA_BACK_SHOVE_RISE 6 +/// How long the bearer's arms take to push out after it. +#define GORILLA_BACK_SHOVE_PUSH (0.12 SECONDS) + +// The landed piston punch, the haymaker's hit and the backbreaker's break (gorilla_punch.dm's sound procs). +/// A sound key (/datum/sound_effect/gorilla_piston_punch): one of three punches at random. +#define GORILLA_PUNCH_SOUND "gorilla_piston_punch" +#define GORILLA_HAYMAKER_SOUND 'voidcrew/modules/hyperviolence_gorilla/sound/gorilla_haymaker.ogg' +#define GORILLA_BACKBREAKER_SOUND 'voidcrew/modules/hyperviolence_gorilla/sound/gorilla_backbreaker.ogg' + +/// Filter sources. +#define GORILLA_PUPPET_HIDE "gorilla_puppet_hide" diff --git a/voidcrew/_DEFINES/keybindings.dm b/voidcrew/_DEFINES/keybindings.dm index 921f55734d9..90380ab18c9 100644 --- a/voidcrew/_DEFINES/keybindings.dm +++ b/voidcrew/_DEFINES/keybindings.dm @@ -1,2 +1,8 @@ //Carbon #define COMSIG_KB_CARBON_TAKESHIPPART_DOWN "keybinding_carbon_takeshippart_down" + +//Cyberware (voidcrew/modules/cyberware/chrome_wheel_keybindings.dm) +#define COMSIG_KB_LIVING_CHROME_WHEEL_DOWN "keybinding_living_chrome_wheel_down" +#define COMSIG_KB_LIVING_USE_CHROME_DOWN "keybinding_living_use_chrome_down" +#define COMSIG_KB_LIVING_USE_OS_CHROME_DOWN "keybinding_living_use_os_chrome_down" +#define COMSIG_KB_LIVING_DEPLOY_ARM_CHROME_DOWN "keybinding_living_deploy_arm_chrome_down" diff --git a/voidcrew/_DEFINES/mantis_gore.dm b/voidcrew/_DEFINES/mantis_gore.dm new file mode 100644 index 00000000000..de955bfb4a8 --- /dev/null +++ b/voidcrew/_DEFINES/mantis_gore.dm @@ -0,0 +1,177 @@ +// Mantis Blades x hyperviolence (voidcrew/modules/mantis_gore/). Balance notes for developers; none of +// these numbers go in player text. + +/// 32x32 pictures: glints, the coil glow, trails, the impale tips, the scorch seam. +#define MANTIS_GORE_ICON 'voidcrew/modules/mantis_gore/icons/mantis_gore.dmi' +/// 64x64 pictures: the flick. +#define MANTIS_GORE_LARGE_ICON 'voidcrew/modules/mantis_gore/icons/mantis_gore_large.dmi' +/// 96x96 pictures of the drops a torn artery throws, for each of the eight ways they fly. The wound is in the +/// middle across and MANTIS_ARTERY_WOUND_RISE pixels above the middle: the drops fall further than they rise. +#define MANTIS_ARTERY_ICON 'voidcrew/modules/mantis_gore/icons/mantis_artery.dmi' +#define MANTIS_ARTERY_WOUND_RISE 16 +/// 96x96 pictures centred on the bearer: the arms and blades of each beat of the impale and the scissor, drawn +/// around the victim by the blade rig (mantis_rig.dm). +#define MANTIS_GORE_REACH_ICON 'voidcrew/modules/mantis_gore/icons/mantis_gore_reach.dmi' +/// Layer for blade drawn in front of the victim (and the bearer). +#define MANTIS_OVER_VICTIM_LAYER ABOVE_MOB_LAYER +/// The posed held blades. +#define MANTIS_LEFTHAND_ICON 'voidcrew/modules/mantis_gore/icons/mantis_lefthand.dmi' +#define MANTIS_RIGHTHAND_ICON 'voidcrew/modules/mantis_gore/icons/mantis_righthand.dmi' +/// Layer for pictures on the blades: just over the held blades (cyberware_anim.dm's swing layer). +#define MANTIS_ANIM_BLADE_LAYER (-(HANDS_LAYER - 0.5)) +/// Layer for pictures over the whole body: over everything it wears. +#define MANTIS_ANIM_TOP_LAYER (-(HIGHEST_LAYER - 0.5)) + +// What a blade of the line can do, on /obj/item/melee/energy/blade/hardlight/cyberware_mantis/var/gore_moves. +/// Repeated cuts on one limb tear its artery. +#define MANTIS_MOVE_ARTERY (1<<0) +/// A two-blade lunge skewers someone already hurt. +#define MANTIS_MOVE_IMPALE (1<<1) +/// A head swing at someone dying takes the head off. +#define MANTIS_MOVE_SCISSOR (1<<2) +/// Every third cut with both blades out is a crossed double slash. +#define MANTIS_MOVE_XSLASH (1<<3) +#define MANTIS_MOVES_ALL (MANTIS_MOVE_ARTERY|MANTIS_MOVE_IMPALE|MANTIS_MOVE_SCISSOR|MANTIS_MOVE_XSLASH) + +// Poses of the held blades. Each is an in-hand state "[base_icon_state]_[pose]". +#define MANTIS_POSE_GUARD "guard" +#define MANTIS_POSE_LUNGE "lunge" +#define MANTIS_POSE_RAISE "raise" +#define MANTIS_POSE_COIL "coil" + +// Fields of mantis_rig_beat(). +#define MANTIS_RIG_ORDER 1 +#define MANTIS_RIG_BEARER_W 2 +#define MANTIS_RIG_BEARER_Z 3 +#define MANTIS_RIG_TARGET_W 4 +#define MANTIS_RIG_TARGET_Z 5 +#define MANTIS_RIG_TILT 6 +#define MANTIS_RIG_RAISE 7 + +/// Trait and offset sources. +#define MANTIS_IMPALE_TRAIT "mantis_impale" +#define MANTIS_CHARGE_TRAIT "mantis_charge" + +/// The wound series of a torn limb artery, so it stacks with ordinary cuts on the same limb. +#define WOUND_SERIES_HV_LIMB_ARTERY "wound_series_hv_limb_artery" + +// ---- Arterial gashes ---- +/// Cuts on one limb add up while each lands within this long of the last. +#define MANTIS_CUT_WINDOW (8 SECONDS) +/// A cut must deal this much brute after armour to count. +#define MANTIS_CUT_MIN_DAMAGE 8 +/// Cuts that tear the artery on a limb covered by less than MANTIS_COVER_LIGHT (after armour penetration). +#define MANTIS_TEAR_CUTS_BARE 3 +/// Cuts that tear it under cover from MANTIS_COVER_LIGHT up to MANTIS_COVER_STOP. +#define MANTIS_TEAR_CUTS_COVERED 5 +#define MANTIS_COVER_LIGHT 15 +/// Cover at or above this never tears. +#define MANTIS_COVER_STOP 35 +/// Blood flow at or above which a torn limb artery spurts. +#define MANTIS_ARTERY_OPEN_FLOW 1.5 + +// ---- Kill credit and the lunge reset ---- +/// A death this long after the bearer's last cut counts as their kill. +#define MANTIS_KILL_CREDIT_WINDOW (5 SECONDS) +/// A kill puts the lunge's cooldown down to this, never lower. +#define MANTIS_KILL_RESET_FLOOR (3 SECONDS) +/// At most one reset per bearer in this long. +#define MANTIS_KILL_RESET_COOLDOWN (8 SECONDS) +/// A body that gave a reset gives no other for this long (revive loops). +#define MANTIS_KILL_RESET_VICTIM_LOCKOUT (2 MINUTES) +/// Anything that isn't a person must have at least this much max health to count. +#define MANTIS_KILL_RESET_MIN_HEALTH 100 + +// ---- X-slash ---- +/// Every this many landed cuts on one target is a crossed double slash. +#define MANTIS_XSLASH_EVERY 3 +/// The count holds while each cut lands within this long of the last. +#define MANTIS_XSLASH_WINDOW (4 SECONDS) +#define MANTIS_XSLASH_STAGGER (1.5 SECONDS) + +// ---- Impaling lunge ---- +#define MANTIS_IMPALE_HOLD (0.8 SECONDS) +#define MANTIS_IMPALE_PIN_HOLD (1.5 SECONDS) +/// Brute per blade when they rip free. +#define MANTIS_IMPALE_RIP_DAMAGE 8 +#define MANTIS_IMPALE_RIP_WOUND_BONUS 15 +/// Damage the bearer can take while holding someone up before they lose the grip. +#define MANTIS_IMPALE_BREAK_DAMAGE 15 +/// A target at or under this share of max health is hurt enough to skewer. +#define MANTIS_IMPALE_HEALTH_FRACTION 0.7 +// The beats of the impale (mantis_impale.dm), from the approved storyboard. The bearer's lunge pose shows +// while the lunging body glides in; the blades go in as it lands, and the hold, the pull-back, the rip and +// the drop follow. Where the two bodies sit in each beat is mantis_rig_beat()'s. +/// The victim sliding onto the blades, after the lunging body lands. +#define MANTIS_IMPALE_CONTACT_BEAT (0.05 SECONDS) +/// From the blades going in to the hoist, held up. Short, so the hold fills the 0.8 s. +#define MANTIS_IMPALE_ENTER_BEAT (0.1 SECONDS) +/// Each step of the hoist from the stab up to the hold, and of the pull-back. +#define MANTIS_IMPALE_STEP (0.05 SECONDS) +#define MANTIS_IMPALE_PULL_STEP (0.1 SECONDS) +/// Held up they sag a pixel this long into the hold, for this long, and once more this long after the first. +#define MANTIS_IMPALE_SAG_AFTER (0.15 SECONDS) +#define MANTIS_IMPALE_SAG_FOR (0.1 SECONDS) +/// Facing south, how high (pixels) the victim is drawn up onto the blades before the bearer's body rises with them, +/// a pixel for a pixel, so the bearer's head and shoulders show over the victim's head. +#define MANTIS_IMPALE_SOUTH_RISE_FROM 14 +#define MANTIS_IMPALE_SAG_EVERY (0.2 SECONDS) +/// From the pull-back to the rip-out. +#define MANTIS_IMPALE_RIP_BEAT (0.2 SECONDS) +/// How long the bearer holds the last pose after the blades are out, before they are drawn as usual again, +/// and how long the body takes to fall from the blades to the floor. +#define MANTIS_IMPALE_DROP_BEAT (0.3 SECONDS) +/// From the pull-back to the blades coming out and the body dropping. +#define MANTIS_IMPALE_PULL_BEAT (0.3 SECONDS) + +/// Pixels under a body's middle that it is tipped about: its feet (mantis_tip_matrix()). +#define MANTIS_TIP_FEET (ICON_SIZE_Y / 2 - 4) + +/// How long the lunging body takes to glide in after it has arrived. The hit shows as it lands. +#define MANTIS_LUNGE_GLIDE 1.5 +/// How long the blade rig's pictures take to fade into the real bearer when a move ends (mantis_rig.dm). +#define MANTIS_RIG_HANDBACK (0.15 SECONDS) + +// ---- Charged leap ---- +/// Held shorter than this, it is the ordinary lunge. +#define MANTIS_CHARGE_TAP (0.35 SECONDS) +/// Held this long, it reaches the furthest. +#define MANTIS_CHARGE_FULL (1.2 SECONDS) +/// Pixels the body sinks into the crouch. +#define MANTIS_CHARGE_CROUCH_DROP 5 +/// Held this long, the bearer gives up and straightens. +#define MANTIS_CHARGE_MAX_HOLD (3 SECONDS) +/// After straightening, this long before they can crouch again. +#define MANTIS_CHARGE_REARM (1 SECONDS) +/// One hit this big while crouched breaks it. +#define MANTIS_CHARGE_BREAK_DAMAGE 10 +/// Extra tiles a full charge reaches over the lunge. +#define MANTIS_CHARGE_EXTRA_RANGE 2 + +// ---- Scissor ---- +#define MANTIS_SCISSOR_WINDUP (1.2 SECONDS) +/// Pixels the bearer leans in for the cut, and further when the head lies on the far side of the body. +/// Drawn by the blade rig; this is the bearer's own lean when the rig can't draw them. +#define MANTIS_SCISSOR_LEAN 12 +#define MANTIS_SCISSOR_FAR_LEAN 16 +/// The scissor's swing: the blades come down from the raise, close on the neck, and shut through it this long apart. +#define MANTIS_SCISSOR_SWING_STEP (0.1 SECONDS) +/// The scissor's beats after the cut: the blades shut through the neck, then the bearer straightens over +/// MANTIS_SCISSOR_STRAIGHTEN. +#define MANTIS_SCISSOR_RECOVER_BEAT (0.25 SECONDS) +#define MANTIS_SCISSOR_STRAIGHTEN (0.25 SECONDS) +#define MANTIS_SCISSOR_COOLDOWN (10 SECONDS) +/// Brute to the neck when the head won't come off. +#define MANTIS_SCISSOR_FALLBACK_DAMAGE 25 +/// Where a head cut off by the scissor is drawn on its tile: pixels out from the middle toward the side the +/// head lay, where the neck was, then where it comes to rest, and how far below the middle. +#define MANTIS_HEAD_ROLL_FROM 7 +#define MANTIS_HEAD_ROLL_TO 11 +#define MANTIS_HEAD_ROLL_DROP 5 + +// ---- Blood on the blades ---- +/// How long a drenched blade drips. +#define MANTIS_DRENCH_TIME (60 SECONDS) +#define MANTIS_DRIP_INTERVAL (1.5 SECONDS) +/// Most drops one drench leaves on the floor. +#define MANTIS_DRIP_MAX 20 diff --git a/voidcrew/_maps/map_files/outposts/trader_outpost_outfitter.dmm b/voidcrew/_maps/map_files/outposts/trader_outpost_outfitter.dmm index 2d4848184b2..82854e88a5b 100644 --- a/voidcrew/_maps/map_files/outposts/trader_outpost_outfitter.dmm +++ b/voidcrew/_maps/map_files/outposts/trader_outpost_outfitter.dmm @@ -372,6 +372,10 @@ /obj/effect/landmark/outpost_network_pad_spot, /turf/open/indestructible/dark, /area/voidcrew/trader_outpost/checkpoint) +"bc" = ( +/obj/structure/sink/directional/north, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "bd" = ( /obj/effect/turf_decal/arrows{ dir = 2 @@ -748,6 +752,10 @@ }, /turf/open/indestructible/dark/smooth_large, /area/voidcrew/trader_outpost) +"dg" = ( +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "dD" = ( /obj/effect/turf_decal/stripes, /obj/effect/turf_decal/siding/thinplating_new/dark{ @@ -1043,6 +1051,13 @@ }, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"gS" = ( +/obj/item/trash/can{ + pixel_w = -6; + pixel_z = -4 + }, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "gT" = ( /obj/effect/turf_decal/siding/thinplating_new/dark, /obj/effect/decal/cleanable/dirt, @@ -1171,6 +1186,9 @@ /obj/effect/decal/cleanable/dirt, /turf/open/indestructible/dark/smooth_large, /area/voidcrew/trader_outpost) +"iQ" = ( +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "iR" = ( /obj/effect/turf_decal/siding/thinplating_new/dark{ dir = 8 @@ -1292,6 +1310,12 @@ /obj/effect/decal/cleanable/dirt, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"ku" = ( +/obj/structure/rack, +/obj/structure/sign/poster/contraband/cybersun_six_hundred/directional/north, +/obj/effect/decal/cleanable/dirt, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "kv" = ( /obj/effect/turf_decal/siding/thinplating_new/dark/corner{ dir = 1 @@ -1377,6 +1401,14 @@ }, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"ld" = ( +/obj/structure/table, +/obj/item/cigbutt{ + pixel_w = 5; + pixel_z = 7 + }, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "lw" = ( /obj/structure/rack, /obj/effect/turf_decal/trimline/red/filled/line{ @@ -1402,6 +1434,11 @@ "ly" = ( /turf/open/indestructible/dark, /area/voidcrew/trader_outpost) +"lz" = ( +/mob/living/basic/outpost_trader/ripperdoc/street_doc, +/obj/machinery/light/small/dim/directional/north, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "lE" = ( /obj/structure/window/reinforced/shuttle/indestructible, /turf/open/indestructible/plating, @@ -1533,6 +1570,10 @@ }, /turf/open/indestructible/dark, /area/voidcrew/trader_outpost) +"nV" = ( +/obj/machinery/light/small/directional/west, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "oi" = ( /obj/effect/turf_decal/siding/wideplating_new/dark{ dir = 1 @@ -1631,18 +1672,6 @@ /obj/machinery/newscaster/directional/east, /turf/open/indestructible/dark, /area/voidcrew/trader_outpost) -"pC" = ( -/obj/effect/turf_decal/tile/yellow/anticorner/contrasted{ - dir = 4 - }, -/obj/effect/turf_decal/siding/thinplating_new{ - dir = 5 - }, -/obj/item/kirbyplants/organic/plant22, -/obj/effect/decal/cleanable/cobweb/cobweb2, -/obj/effect/decal/cleanable/dirt, -/turf/open/indestructible, -/area/voidcrew/trader_outpost) "pE" = ( /obj/effect/turf_decal/tile/dark/full, /obj/effect/invisible_wall, @@ -1731,6 +1760,11 @@ /obj/effect/decal/cleanable/dirt/dust, /turf/open/indestructible/dark/textured, /area/voidcrew/trader_outpost) +"qA" = ( +/obj/structure/fluff/shower_drain, +/obj/effect/decal/cleanable/blood/old, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "qN" = ( /obj/structure/closet/crate/secure{ name = "chassis crate"; @@ -1757,6 +1791,12 @@ /obj/effect/decal/cleanable/dirt, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"qZ" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Back Bay" + }, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "rd" = ( /obj/effect/turf_decal/trimline/yellow/filled/line{ dir = 8 @@ -1771,6 +1811,10 @@ /obj/structure/chair/office/light, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"rg" = ( +/obj/structure/closet/crate/bin, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "rj" = ( /obj/structure/table/reinforced/rglass, /obj/structure/desk_bell{ @@ -1813,6 +1857,16 @@ /obj/effect/decal/cleanable/dirt, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"sd" = ( +/obj/machinery/porta_turret/outpost, +/obj/effect/turf_decal/box/red/corners{ + dir = 1 + }, +/obj/effect/turf_decal/box/red/corners{ + dir = 8 + }, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "sf" = ( /obj/structure/closet/secure_closet/outpost_rental, /obj/effect/turf_decal/siding/wideplating_new/dark{ @@ -1828,6 +1882,14 @@ }, /turf/open/indestructible/dark, /area/voidcrew/trader_outpost) +"sh" = ( +/obj/structure/closet/crate{ + anchored = 1; + name = "parts crate" + }, +/obj/effect/decal/cleanable/cobweb, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "si" = ( /obj/effect/turf_decal/siding/wideplating_new/dark{ dir = 4 @@ -1928,6 +1990,14 @@ }, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"tf" = ( +/obj/structure/table, +/obj/structure/fluff/paper/stack{ + pixel_w = -3; + pixel_z = 3 + }, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "tj" = ( /obj/structure/closet/secure_closet/outpost_rental, /obj/effect/turf_decal/siding/wideplating_new/dark{ @@ -1959,6 +2029,11 @@ }, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"tD" = ( +/obj/machinery/chrome_cradle, +/obj/effect/decal/cleanable/blood/old, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "tH" = ( /obj/effect/turf_decal/siding/thinplating_new/corner{ dir = 4 @@ -2075,6 +2150,10 @@ /obj/machinery/light/floor, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"uM" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "vb" = ( /obj/structure/fluff/paper/stack{ dir = 1; @@ -2190,6 +2269,10 @@ }, /turf/open/indestructible/white/smooth_large, /area/voidcrew/trader_outpost) +"wK" = ( +/obj/machinery/light/cold/directional/east, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "wM" = ( /obj/structure/table, /obj/item/storage/medkit/regular, @@ -2375,6 +2458,11 @@ /obj/machinery/light/directional/north, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"zp" = ( +/obj/structure/rack, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "zw" = ( /obj/structure/chair{ dir = 1 @@ -2629,6 +2717,11 @@ }, /turf/open/indestructible/dark, /area/voidcrew/trader_outpost) +"CD" = ( +/obj/structure/chair/stool, +/obj/effect/decal/cleanable/dirt, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "CQ" = ( /obj/effect/turf_decal/tile/yellow/half/contrasted{ dir = 8 @@ -2765,6 +2858,19 @@ }, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"EW" = ( +/obj/effect/turf_decal/tile/yellow/anticorner/contrasted{ + dir = 4 + }, +/obj/effect/turf_decal/siding/thinplating_new{ + dir = 5 + }, +/obj/item/kirbyplants/organic/plant22, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/obj/effect/decal/cleanable/dirt, +/obj/structure/sign/poster/contraband/interdyne_gene_clinics/directional/east, +/turf/open/indestructible, +/area/voidcrew/trader_outpost) "EX" = ( /obj/effect/turf_decal/tile/dark/full, /obj/effect/invisible_wall, @@ -2778,6 +2884,14 @@ /obj/item/radio/intercom/directional/north, /turf/open/indestructible/hoteltile, /area/voidcrew/trader_outpost) +"Ff" = ( +/obj/structure/table, +/obj/structure/desk_bell{ + pixel_w = 0; + pixel_z = 4 + }, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "Fx" = ( /obj/structure/closet/secure_closet/outpost_rental, /obj/effect/turf_decal/siding/wideplating_new/dark{ @@ -2836,6 +2950,10 @@ }, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"Ga" = ( +/obj/machinery/vending/wallmed/directional/east, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "Gd" = ( /obj/effect/turf_decal/siding/wideplating_new/light{ dir = 8 @@ -2854,6 +2972,10 @@ /obj/effect/decal/cleanable/dirt, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"Gk" = ( +/obj/structure/mirror/directional/east, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "Gt" = ( /obj/effect/turf_decal/tile/dark/full, /obj/structure/sign/poster/official/get_your_legs{ @@ -2972,6 +3094,10 @@ }, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"Iu" = ( +/obj/item/cigbutt, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "Iw" = ( /turf/open/indestructible/hoteltile, /area/voidcrew/trader_outpost) @@ -3299,6 +3425,10 @@ /obj/structure/extinguisher_cabinet/directional/west, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"MB" = ( +/obj/effect/decal/cleanable/blood/drip, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "MI" = ( /obj/effect/spawner/random/trash/soap, /obj/machinery/light/small/directional/south, @@ -3314,6 +3444,10 @@ }, /turf/open/indestructible/large, /area/voidcrew/trader_outpost) +"MW" = ( +/obj/effect/decal/cleanable/blood/oil, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "Na" = ( /obj/structure/table, /obj/effect/spawner/random/food_or_drink/donkpockets, @@ -3668,6 +3802,11 @@ }, /turf/open/indestructible/dark, /area/voidcrew/trader_outpost) +"Uc" = ( +/obj/effect/decal/cleanable/blood/gibs/robot_debris/limb, +/obj/item/cigbutt, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "Ud" = ( /obj/effect/turf_decal/bot, /obj/structure/closet/crate, @@ -3924,6 +4063,10 @@ }, /turf/open/indestructible, /area/voidcrew/trader_outpost) +"ZP" = ( +/obj/structure/table, +/turf/open/indestructible/freezer, +/area/voidcrew/trader_outpost) "ZV" = ( /obj/effect/decal/cleanable/dirt/dust, /obj/machinery/light/floor, @@ -5368,7 +5511,7 @@ ai fp vS dU -pC +EW hE gQ Vl @@ -5412,7 +5555,7 @@ CS dU dU dU -dU +qZ dU dU dU @@ -5452,13 +5595,13 @@ lE lE dU dU -aV -aV -aV -aV -aV -aV -aV +sh +ZP +uM +nV +uM +rg +dU dU dU lE @@ -5492,15 +5635,15 @@ ao ao ao ao -ao -aF -aV -aV -aV -aV -aV aV dU +ku +tf +Iu +CD +uM +bc +dU dU FC oU @@ -5534,15 +5677,15 @@ ao ao ao ao -ao -ao -ao -aV -aV -aV -aV aV dU +Uc +ZP +gS +iQ +MW +dg +dU cI cY gg @@ -5576,14 +5719,14 @@ ao ao ao ao -ao -ao -ao -ao -ao -aV -aV aV +dU +lz +Ff +uM +MB +tD +qA lE aE Hd @@ -5618,14 +5761,14 @@ ao ao ao ao -ao -ao -ao -ao -ao -ao -ao -aF +aV +dU +zp +ld +Ga +Gk +wK +sd dU tj AY @@ -5660,14 +5803,14 @@ ao ao ao ao -ao -ao -ao -ao -ao -ao -ao -ao +aV +dU +dU +dU +dU +dU +dU +dU dU dU sf @@ -5702,15 +5845,15 @@ ao ao ao ao -ao -ao -ao -ao -ao -ao -ao -ao -ao +aF +aV +aV +aV +aV +aV +aV +aF +aV dU dU dU diff --git a/voidcrew/edits/modules/mob/living/carbon/floored_fall.dm b/voidcrew/edits/modules/mob/living/carbon/floored_fall.dm new file mode 100644 index 00000000000..3e4796ba2b6 --- /dev/null +++ b/voidcrew/edits/modules/mob/living/carbon/floored_fall.dm @@ -0,0 +1,13 @@ +// tg floors a standing body by laying it down and then picking the side it lies on. For a carbon, lying down +// has already picked a side (lying_angle_on_lying_down()), so the side was picked twice, and half the time the +// second pick was the other one. update_transform() applies a turn straight onto the other side with no tween, +// so half of all knockdowns went flat in a single frame instead of falling. Here the first pick is kept. +// Found on the Mantis lunge's landing (voidcrew/modules/mantis_gore/), true of every knockdown. +/mob/living/carbon/on_floored_start() + on_fall() + if(body_position != STANDING_UP) + return + set_body_position(LYING_DOWN) + // Still upright only if lying down picked nothing: buckled upright, or unable to lie down. + if(!lying_angle) + set_lying_angle(pick(LYING_ANGLE_EAST, LYING_ANGLE_WEST)) diff --git a/voidcrew/modules/admin/chrome_test_kit.dm b/voidcrew/modules/admin/chrome_test_kit.dm new file mode 100644 index 00000000000..8ae937c8ac7 --- /dev/null +++ b/voidcrew/modules/admin/chrome_test_kit.dm @@ -0,0 +1,257 @@ +/** + * # Chrome test kit + * + * One admin verb for trying the cyberware lines without a shopping trip. It drops a Chrome + * Cradle beside the admin with a stack of trade vouchers and a holochip of credits, then offers + * a short list of ready-made builds (see GLOB.chrome_test_loadouts) that either go straight into + * the admin's own body or into a crate at their feet, plus a chromed human to point Chrome Read + * at. The dummy is a human NPC body (voidcrew/modules/human_npcs/) with no + * AI, so it is the same kind of body as the NPCs players meet: its chrome works, and burns out + * to scrap when it dies or a piece leaves it. + * + * Installs here are special inserts, the same door the unit tests use: no cradle sequence, no + * boot splash, no install context. They still obey the body's rules in two ways. A piece whose + * limb is missing is not forced into a body that cannot hold it, and a piece that would push the + * body past its neural capacity goes into the crate instead of browning the whole build out + * (the Cascade and Redline cores share the OS slot with the Governors, so the heavy builds do + * not fit on a stock body). The chat report lists what went where and the final load. + * + * Admin only (R_ADMIN|R_DEBUG), logged like the other feature-testing verbs. The loadouts are + * plain typepath lists so they are easy to retune. + */ + +/** + * The ready-made builds, in install order. Order matters twice: a piece is skipped when the + * body no longer has headroom, so the ones listed first are the ones that stay; and pairs list + * the right arm first, its left twin after. + */ +GLOBAL_LIST_INIT(chrome_test_loadouts, list( + "Blade dancer" = list( + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left, + /obj/item/organ/cyberimp/cyberware/cascade, + /obj/item/organ/cyberimp/cyberware/slipwire, + ), + "Tank" = list( + /obj/item/organ/cyberimp/cyberware/gorilla_arms, + /obj/item/organ/cyberimp/cyberware/gorilla_arms/left, + /obj/item/organ/cyberimp/cyberware/slabskin, + /obj/item/organ/cyberimp/cyberware/atlas, + /obj/item/organ/cyberimp/cyberware/redline, + ), + "Street kid" = list( + /obj/item/organ/cyberimp/cyberware/cascade/street, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/left, + /obj/item/organ/cyberimp/cyberware/ghostskin/street, + /obj/item/organ/cyberimp/cyberware/hopper/street, + /obj/item/organ/eyes/robotic/cyberware/spyglass, + /obj/item/organ/cyberimp/cyberware/clotter_node, + /obj/item/organ/cyberimp/cyberware/medic_palms, + /obj/item/organ/cyberimp/cyberware/subvocal_mic, + /obj/item/organ/cyberimp/cyberware/muffler_ear, + ), +)) + +/// The kit's menu entries that are not loadouts. +#define CHROME_KIT_EVERYTHING "Everything (one of each, in a crate)" +#define CHROME_KIT_DUMMY "Chrome dummy (a chromed human to test on)" +#define CHROME_KIT_BASICS "Cradle, vouchers and credits only" + +/// Vouchers and credits the kit hands out per use. +#define CHROME_KIT_VOUCHERS 30 +#define CHROME_KIT_CREDITS 20000 + +/** + * Every piece of chrome a ripperdoc shelf sells, one of each, as typepaths: the loose organs, + * and the cased pairs as the case (cracking it open spills both halves). Read off the shop's + * own SKU datums so it follows the roster by itself, plus the one piece no shelf sells. + */ +/proc/chrome_kit_everything_types() + var/list/found = list() + for(var/datum/shop_sku/sku_type as anything in subtypesof(/datum/shop_sku/ripperdoc)) + var/item_path = initial(sku_type.item_path) + if(!item_path || found[item_path]) + continue + if(ispath(item_path, /obj/item/organ) || ispath(item_path, /obj/item/cyberware_pair_case) || ispath(item_path, /obj/item/storage/case/cyberware)) + found[item_path] = TRUE + // The Meteor Piledriver is a mission prize, not on any shelf. + found[/obj/item/organ/cyberimp/cyberware/piledriver] = TRUE + return assoc_to_keys(found) + +/// A free turf beside the user for a prop: open floor with nothing solid on it, nearest first. +/proc/chrome_kit_adjacent_turf(atom/user) + var/turf/origin = get_turf(user) + if(!origin) + return null + for(var/direction in GLOB.cardinals) + var/turf/candidate = get_step(origin, direction) + if(!candidate || candidate.density || isspaceturf(candidate)) + continue + var/blocked = FALSE + for(var/atom/movable/occupant as anything in candidate) + if(occupant.density || istype(occupant, /obj/machinery/chrome_cradle)) + blocked = TRUE + break + if(!blocked) + return candidate + return origin + +/** + * Seats a build into a body with special inserts, in order. A piece stays out when the body has + * no limb for it, when it would not fit under the body's neural capacity (the same netted check + * the cradle uses, so a same-slot swap counts) or when the insert is refused. Returns the + * organs left over, ready for a crate; `report` collects a plain line per piece for the chat + * report. + */ +/proc/chrome_kit_install(mob/living/carbon/target, list/ware_types, list/report) + var/list/left_over = list() + var/turf/here = get_turf(target) + for(var/ware_type in ware_types) + var/obj/item/organ/ware = new ware_type(here) + var/reason + if(!target.get_bodypart(deprecise_zone(ware.zone))) + reason = "no limb for it" + else if(!cyberware_insert_check(ware, target, silent = TRUE)) + reason = "no neural headroom" + else if(!ware.Insert(target, special = TRUE)) + reason = "the body refused it" + if(reason) + report += "[ware.name] left out ([reason])" + left_over += ware + return left_over + +/** + * The kit's dummy: a human NPC body with no AI (it never moves, fights or barks), in a grey + * jumpsuit, on no side anyone fights for. Being an NPC body is the point: its chrome burns out at + * death and when a piece leaves it, as on every NPC players meet. + */ +/mob/living/carbon/human/npc/chrome_dummy + ai_controller = null + npc_name = "Chrome dummy" + npc_outfit = /datum/outfit/chrome_dummy + faction = list(FACTION_NEUTRAL) + npc_voice = null + npc_surrender = null + +/datum/outfit/chrome_dummy + name = "Chrome dummy" + uniform = /obj/item/clothing/under/color/grey + +/** + * A chrome dummy at `where` carrying what fits of `ware_types` (chrome_kit_install(); pieces that + * don't fit are deleted, so the dummy keeps only what fits). Returns the dummy. + */ +/proc/chrome_kit_make_dummy(turf/where, list/ware_types, list/report) + var/mob/living/carbon/human/npc/chrome_dummy/dummy = new(where) + var/list/dummy_spare = chrome_kit_install(dummy, ware_types, report) + QDEL_LIST(dummy_spare) + return dummy + +/// A crate of loose chrome at a turf. Items placed straight into the crate, so its slot count +/// never turns the big builds away. +/proc/chrome_kit_crate(turf/where, list/contents_list, crate_name = "chrome crate") + var/obj/structure/closet/crate/crate = new(where) + crate.name = crate_name + for(var/obj/item/spare in contents_list) + spare.forceMove(crate) + return crate + +/// The admin's chrome status line: load against capacity and any piece that is dark. +/proc/chrome_kit_status_line(mob/living/carbon/target) + var/load = get_chrome_load(target) + var/capacity = get_chrome_capacity(target) + var/dark = 0 + for(var/obj/item/organ/ware as anything in get_installed_cyberware(target)) + if(ware.organ_flags & ORGAN_FAILING) + dark++ + return "[length(get_installed_cyberware(target))] pieces, load [load]/[capacity][dark ? ", [dark] dark" : ""]" + +ADMIN_VERB(chrome_test_kit, R_ADMIN|R_DEBUG, "Chrome: Test Kit", "Drop a Chrome Cradle with vouchers and credits beside you, then take a ready-made chrome build (into your body or a crate) or a chromed dummy to test on.", ADMIN_CATEGORY_DEBUG) + var/mob/admin_mob = user.mob + var/turf/origin = get_turf(admin_mob) + if(!origin) + to_chat(user, span_warning("You need a physical location to drop the kit at.")) + return + + var/list/menu = list() + for(var/loadout_name in GLOB.chrome_test_loadouts) + menu += loadout_name + menu += CHROME_KIT_EVERYTHING + menu += CHROME_KIT_DUMMY + menu += CHROME_KIT_BASICS + var/choice = tgui_input_list(user, "Which build?", "Chrome Test Kit", menu) + if(!choice) + return + + // Where it goes, for the two choices that have a body to put it in. + var/into_body = FALSE + if(GLOB.chrome_test_loadouts[choice]) + if(iscarbon(admin_mob)) + var/where = tgui_input_list(user, "Install it where?", "Chrome Test Kit", list("Into my body", "Into a crate at my feet")) + if(!where) + return + into_body = where == "Into my body" + else + to_chat(user, span_notice("You have no body to install into, so the build goes in a crate.")) + + // The dummy takes any one of the builds, or a random one. + var/dummy_build + if(choice == CHROME_KIT_DUMMY) + var/list/builds = list("Random") + for(var/loadout_name in GLOB.chrome_test_loadouts) + builds += loadout_name + dummy_build = tgui_input_list(user, "Which build does the dummy carry?", "Chrome Test Kit", builds) + if(!dummy_build) + return + if(dummy_build == "Random") + dummy_build = pick(GLOB.chrome_test_loadouts) + + // The bench. One cradle per kit spot; asking twice does not stack them. + var/obj/machinery/chrome_cradle/cradle = locate() in view(5, origin) + var/made_cradle = FALSE + if(!cradle) + cradle = new(chrome_kit_adjacent_turf(admin_mob)) + made_cradle = TRUE + new /obj/item/stack/trade_voucher(origin, CHROME_KIT_VOUCHERS) + new /obj/item/holochip(origin, CHROME_KIT_CREDITS) + + var/list/report = list() + var/summary = "[made_cradle ? "a cradle" : "the cradle already here"], [CHROME_KIT_VOUCHERS] vouchers and [CHROME_KIT_CREDITS] cr" + switch(choice) + if(CHROME_KIT_BASICS) + EMPTY_BLOCK_GUARD // the bench, vouchers and credits are the whole kit + if(CHROME_KIT_EVERYTHING) + var/list/everything = list() + for(var/ware_type in chrome_kit_everything_types()) + everything += new ware_type(origin) + chrome_kit_crate(origin, everything, "chrome crate (everything)") + summary += ", a crate with [length(everything)] items" + if(CHROME_KIT_DUMMY) + var/mob/living/carbon/human/npc/chrome_dummy/dummy = chrome_kit_make_dummy(chrome_kit_adjacent_turf(admin_mob), GLOB.chrome_test_loadouts[dummy_build], report) + summary += ", a chrome dummy carrying the [dummy_build] build ([chrome_kit_status_line(dummy)])" + else + var/list/ware_types = GLOB.chrome_test_loadouts[choice] + if(into_body) + var/list/spare = chrome_kit_install(admin_mob, ware_types, report) + summary += ", the [choice] build installed ([chrome_kit_status_line(admin_mob)])" + if(length(spare)) + chrome_kit_crate(origin, spare, "chrome crate ([choice], left over)") + summary += ", [length(spare)] left over in a crate" + else + var/list/boxed = list() + for(var/ware_type in ware_types) + boxed += new ware_type(origin) + chrome_kit_crate(origin, boxed, "chrome crate ([choice])") + summary += ", the [choice] build in a crate" + + to_chat(user, span_notice("Chrome test kit: [summary].")) + for(var/line in report) + to_chat(user, span_notice(" [line].")) + message_admins("[key_name_admin(user)] used the chrome test kit ([choice]) at [ADMIN_VERBOSEJMP(origin)].") + log_admin("[key_name(user)] used the chrome test kit ([choice]): [summary].") + BLACKBOX_LOG_ADMIN_VERB("Chrome Test Kit") + +#undef CHROME_KIT_EVERYTHING +#undef CHROME_KIT_DUMMY +#undef CHROME_KIT_BASICS diff --git a/voidcrew/modules/antag_ruins/ascension_mech.dm b/voidcrew/modules/antag_ruins/ascension_mech.dm index b8fab656eb6..52619b45dba 100644 --- a/voidcrew/modules/antag_ruins/ascension_mech.dm +++ b/voidcrew/modules/antag_ruins/ascension_mech.dm @@ -2037,7 +2037,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) */ /datum/machine_quickhack/safeties name = "Cut the Safeties" - desc = "Strip the target's safety interlocks. Exactly what an emag would do to it, which depends entirely on what it is." + desc = "Strip the target's safety interlocks." radial_icon = 'icons/obj/card.dmi' radial_icon_state = "emag" cooldown = 25 SECONDS @@ -2070,7 +2070,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) /datum/machine_quickhack/bolts name = "Bolts" - desc = "Throw the door's bolts, or pull them if they are already down. Works on the AI wire, so a cut door will not answer." + desc = "Throw the door's bolts, or pull them if they are already down." radial_icon_state = "lockdown" cooldown = 8 SECONDS @@ -2105,8 +2105,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) */ /datum/machine_quickhack/electrify name = "Electrify" - desc = "Run the door's frame live for 30 seconds. It draws on your own current rather than the area's, so a \ - nearly-empty APC still lands the shock. Touching it without insulated gloves is 20 burn and a stun." + desc = "Run the door's frame live for 30 seconds. Touching it without insulated gloves is 20 burn and a stun." radial_icon = 'icons/obj/machines/wallmounts.dmi' radial_icon_state = "apc-spark" cooldown = 20 SECONDS @@ -2171,7 +2170,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) /datum/machine_quickhack/kill_power name = "Kill the Power" - desc = "Flip an APC's breaker. Lights, equipment and air handling across that whole area go dead until it is flipped back." + desc = "Flip an APC's breaker. Lights, equipment and air handling across that whole area go dead." radial_icon = 'icons/obj/machines/wallmounts.dmi' radial_icon_state = "apc0" cooldown = 30 SECONDS @@ -2199,7 +2198,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) */ /datum/machine_quickhack/burst_lights name = "Burst the Lights" - desc = "Push an APC's lighting circuit until every bulb in its area breaks. They stay broken." + desc = "Push an APC's lighting circuit until every bulb in its area breaks." radial_icon_state = "blackout" cooldown = 30 SECONDS @@ -2239,7 +2238,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) */ /datum/machine_quickhack/feedback_surge name = "Feedback Surge" - desc = "Dump everything a person's gear is holding into the person. Empties every power cell they are carrying and shocks them for up to 60 burn, scaled to how much charge there was." + desc = "Empty every power cell a person is carrying through the person, for up to 60 burn." radial_icon = 'icons/obj/weapons/baton.dmi' radial_icon_state = "stunbaton_active" cooldown = 60 SECONDS @@ -2277,7 +2276,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) */ /datum/machine_quickhack/cutout name = "Cutout" - desc = "Quietly empty every power cell a person is carrying and switch their radios off for 45 seconds. No shock and no stun; their gear just stops." + desc = "Quietly empty every power cell a person is carrying and switch their radios off for 45 seconds." radial_icon = 'icons/obj/weapons/baton.dmi' radial_icon_state = "stunbaton_nocell" cooldown = 35 SECONDS @@ -2312,7 +2311,7 @@ GLOBAL_LIST_EMPTY(machine_quickhacks) /datum/machine_quickhack/silence name = "Silence" - desc = "Jam every radio within nine tiles of what you clicked for 45 seconds, and switch the ones already in range off outright for as long." + desc = "Jam every radio within nine tiles of what you clicked for 45 seconds." radial_icon = 'icons/obj/devices/syndie_gadget.dmi' radial_icon_state = "jammer" cooldown = 40 SECONDS @@ -2608,10 +2607,7 @@ GLOBAL_LIST_EMPTY(machine_masshacks) */ /datum/machine_masshack/overload name = "Overload the Room" - desc = "Feed every machine around you power at once, each one at full overload strength. Five seconds of the whole \ - room buzzing, then up to twelve real explosions land a fifth of a second apart. It takes the walls with it and \ - it will breach a hull if one is in the pattern. Lights just burst. Nothing that goes up comes back, and you are \ - standing in the middle of it, leave." + desc = "Overload every machine around you at once. Five seconds of buzzing, then up to twelve explosions. You are standing in the middle of it." radial_icon_state = "overload_machine" cooldown = 3 MINUTES @@ -2652,9 +2648,7 @@ GLOBAL_LIST_EMPTY(machine_masshacks) */ /datum/machine_masshack/arc_flash name = "Arc Flash" - desc = "Every powered machine around you starts earthing itself through whoever is standing nearest to it. Five \ - volleys a second and a half apart, 14 burn each, and it comes out of the wall rather than through their hands, \ - so insulated gloves do nothing. It hits everyone in the room except you, friend or not." + desc = "Every powered machine around you earths itself through whoever is standing nearest. Five volleys, 14 burn each, on everyone but you." radial_icon = 'icons/mob/actions/actions_spells.dmi' radial_icon_state = "lightning" cooldown = 2 MINUTES @@ -2767,9 +2761,7 @@ GLOBAL_LIST_EMPTY(machine_masshacks) */ /datum/machine_masshack/wake name = "Wake the Machines" - desc = "Stand every free-standing machine in the room up to fight for you. Up to eight of them, twice as tough as an \ - animated machine and hitting twice as hard, for two minutes before they fall apart. They know you and nobody \ - else, everyone else in the room is a stranger to them. The machines do not come back." + desc = "Stand up to eight free-standing machines in the room up to fight for you for two minutes." radial_icon_state = "override_machine" cooldown = 3 MINUTES @@ -2797,7 +2789,7 @@ GLOBAL_LIST_EMPTY(machine_masshacks) for(var/mob/living/second as anything in woken) if(first != second) first.befriend(second) - to_chat(user, span_boldnotice("[length(woken)] of them get up. They know your face and each other's, and nobody else's.")) + to_chat(user, span_boldnotice("[length(woken)] of them get up.")) return TRUE /** diff --git a/voidcrew/modules/bounties/bounty_admin.dm b/voidcrew/modules/bounties/bounty_admin.dm index 28b4629f4db..d7285e7c793 100644 --- a/voidcrew/modules/bounties/bounty_admin.dm +++ b/voidcrew/modules/bounties/bounty_admin.dm @@ -57,6 +57,7 @@ // The main menu, in the order it shows #define BOUNTY_ADMIN_MENU_SPAWN "Spawn a criminal at my feet" +#define BOUNTY_ADMIN_MENU_SPAWN_CHROME "Spawn a criminal with chosen chrome" #define BOUNTY_ADMIN_MENU_DECOY "Spawn a decoy next to a criminal" #define BOUNTY_ADMIN_MENU_POST "Post a bounty now" #define BOUNTY_ADMIN_MENU_GIVE "Give a bounty to a player" @@ -132,6 +133,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a /datum/bounty_admin_panel/proc/run_menu(mob/user) var/static/list/menu = list( BOUNTY_ADMIN_MENU_SPAWN, + BOUNTY_ADMIN_MENU_SPAWN_CHROME, BOUNTY_ADMIN_MENU_DECOY, BOUNTY_ADMIN_MENU_POST, BOUNTY_ADMIN_MENU_GIVE, @@ -150,6 +152,8 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a switch(choice) if(BOUNTY_ADMIN_MENU_SPAWN) menu_spawn(user) + if(BOUNTY_ADMIN_MENU_SPAWN_CHROME) + menu_spawn(user, TRUE) if(BOUNTY_ADMIN_MENU_DECOY) menu_decoy(user) if(BOUNTY_ADMIN_MENU_POST) @@ -174,8 +178,12 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a var/about = length(live_criminals()) return "[open] open bount[open == 1 ? "y" : "ies"], [about] criminal\s about, [length(GLOB.bounty_prisoner_pool)] record\s in the prisoner pool." -/datum/bounty_admin_panel/proc/menu_spawn(mob/user) +/// The spawn menu. With `pick_chrome` it also asks which chrome they carry (C0); otherwise it is rolled as usual. +/datum/bounty_admin_panel/proc/menu_spawn(mob/user, pick_chrome = FALSE) var/list/archetypes = archetype_choices() + if(pick_chrome) + // The meek carry no chrome + archetypes -= "Meek" var/archetype_choice = ask_list(user, "Which archetype?", "Spawn a criminal", archetypes) if(!archetype_choice || !authorized(user)) return @@ -196,11 +204,18 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a if(!style_choice || !authorized(user)) return variant = styles[style_choice] + var/chrome = BOUNTY_ADMIN_CHROME_ROLL + if(pick_chrome) + var/list/chromes = chrome_choices() + var/chrome_choice = ask_list(user, "Which chrome?", "Spawn a criminal", chromes) + if(!chrome_choice || !authorized(user)) + return + chrome = chromes[chrome_choice] var/list/activities = list("None" = null) + activity_choices() var/activity_choice = ask_list(user, "Doing what?", "Spawn a criminal", activities) if(!activity_choice || !authorized(user)) return - admin_spawn_criminal(user, tier, archetype, variant, activities[activity_choice], get_turf(user)) + admin_spawn_criminal(user, tier, archetype, variant, activities[activity_choice], get_turf(user), chrome) /datum/bounty_admin_panel/proc/menu_decoy(mob/user) var/datum/weakref/wanted_ref = WEAKREF(pick_criminal(user, "Spawn a decoy next to whom?")) @@ -542,8 +557,47 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a "Demolitionist" = BOUNTY_KIT_DEMOLITIONIST, "Ghost" = BOUNTY_KIT_GHOST, "Heavy" = BOUNTY_KIT_HEAVY, + "Cyberpsycho" = BOUNTY_KIT_CYBERPSYCHO, ) +/** + * The chrome a spawned criminal can be given (C0): rolled as usual for the style or kit picked, none, + * any one piece whatever their style or kit, or every piece that fits in one body. Values are a list of + * BOUNTY_CHROME_* keys, BOUNTY_ADMIN_CHROME_ROLL or BOUNTY_ADMIN_CHROME_ALL. + */ +/datum/bounty_admin_panel/proc/chrome_choices() + var/list/choices = list("Roll as usual" = BOUNTY_ADMIN_CHROME_ROLL, "None" = list()) + for(var/key in GLOB.bounty_chrome_pieces) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + if(piece.weight > 0) + choices[piece.name] = list(key) + choices["All of it"] = BOUNTY_ADMIN_CHROME_ALL + return choices + +/** + * Gives `record` the chrome `chrome` asks for (a chrome_choices() value), for a criminal spawned by an + * admin: rolled as usual for the style or kit it ended up with (never the one P1 rolled first), every + * piece that fits, or exactly the pieces listed. What doesn't fit with its kit's own chrome is left + * off, and a style its chrome can't fight with is changed for one it can. + */ +/datum/bounty_admin_panel/proc/admin_set_chrome(datum/bounty_record/record, chrome) + var/list/kit_organs = record.archetype == BOUNTY_ARCHETYPE_BOSS ? bounty_chrome_kit_organs(record.kit) : list() + if(record.archetype != BOUNTY_ARCHETYPE_NORMAL && record.archetype != BOUNTY_ARCHETYPE_BOSS) + record.chrome = null + return + if(chrome == BOUNTY_ADMIN_CHROME_ALL) + chrome = admin_chrome_all(record, kit_organs) + if(!islist(chrome)) + record.chrome = bounty_chrome_roll(record.tier, record.archetype, record.style, record.kit, kit_organs) + return + var/list/fitted = bounty_chrome_fit_keys(chrome, kit_organs) + record.chrome = length(fitted) ? fitted : null + bounty_chrome_fit_style(record) + +/// "All of it": every piece that fits on top of its kit's chrome. The cyberpsycho kit (C6) takes this choice over. +/datum/bounty_admin_panel/proc/admin_chrome_all(datum/bounty_record/record, list/kit_organs) + return bounty_chrome_all_that_fits(kit_organs) + /// A normal criminal's styles; the meek always carry the holdout, so the menu doesn't offer it /datum/bounty_admin_panel/proc/style_choices() return list( @@ -699,7 +753,8 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a if(!record) return "no record" var/variant = record.kit || record.style - return "[bounty_tier_name(record.tier)] [record.archetype || "criminal"][variant ? " ([variant])" : ""]" + var/chrome = length(record.chrome) ? ", chrome: [jointext(record.chrome, ", ")]" : "" + return "[bounty_tier_name(record.tier)] [record.archetype || "criminal"][variant ? " ([variant])" : ""][chrome]" /datum/bounty_admin_panel/proc/criminal_label(mob/living/carbon/human/npc/bounty_criminal/criminal) var/area/place = get_area(criminal) @@ -801,10 +856,10 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a /** * Spawns a criminal of `tier` and `archetype` at `where`, with no posting: a new record from P1 with - * the kit (a boss) or style (anyone else) set to `variant` when given, then P2's spawn, then P3's - * `activity` when given. Returns the criminal, or null. + * the kit (a boss) or style (anyone else) set to `variant` when given, its chrome as `chrome` asks + * (admin_set_chrome(), C0), then P2's spawn, then P3's `activity` when given. Returns the criminal, or null. */ -/datum/bounty_admin_panel/proc/admin_spawn_criminal(mob/user, tier, archetype, variant, activity, turf/where) +/datum/bounty_admin_panel/proc/admin_spawn_criminal(mob/user, tier, archetype, variant, activity, turf/where, chrome = BOUNTY_ADMIN_CHROME_ROLL) error = null if(!authorized(user)) return null @@ -836,9 +891,17 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a record.kit = null if(variant) record.style = variant + var/list/asked_chrome + if(islist(chrome)) + var/list/chrome_keys = chrome + asked_chrome = chrome_keys.Copy() + admin_set_chrome(record, chrome) 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.") + var/list/left_off = asked_chrome ? asked_chrome - (record.chrome || list()) : null + if(length(left_off)) + tell(user, span_warning("[jointext(left_off, ", ")] didn't fit in them with the rest.")) if(activity) criminal.start_activity(activity, null) log_action(user, "spawn [criminal_name(criminal)], [record_kind(record)][activity ? ", [activity]" : ""], at [AREACOORD(where)]") @@ -1374,6 +1437,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a #undef BOUNTY_ADMIN_TEST_CAPTOR #undef BOUNTY_ADMIN_RELIST_REASON #undef BOUNTY_ADMIN_MENU_SPAWN +#undef BOUNTY_ADMIN_MENU_SPAWN_CHROME #undef BOUNTY_ADMIN_MENU_DECOY #undef BOUNTY_ADMIN_MENU_POST #undef BOUNTY_ADMIN_MENU_GIVE diff --git a/voidcrew/modules/bounties/bounty_ai.dm b/voidcrew/modules/bounties/bounty_ai.dm index 41ee248a3b8..a6f4a76f3b5 100644 --- a/voidcrew/modules/bounties/bounty_ai.dm +++ b/voidcrew/modules/bounties/bounty_ai.dm @@ -189,17 +189,53 @@ * 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. + * + * A `paced` step (a fighter's step aside or back) comes no sooner than a person could take it: the + * body's own move delay after its last step, by hand or on the AI's walk (bounty_ai_step_ready()). Any + * step taken here holds the AI's walk back by that delay too, so the two never add up to a double step. */ -/proc/bounty_ai_step(mob/living/mover, turf/destination) +/proc/bounty_ai_step(mob/living/mover, turf/destination, paced = FALSE) if(QDELETED(mover) || !isturf(mover.loc) || !isturf(destination) || get_dist(mover, destination) != 1) return FALSE + if(paced && !bounty_ai_step_ready(mover)) + 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 + var/direction = get_dir(mover, destination) + mover.Move(destination, direction) + if(mover.loc == was) + return FALSE + var/delay = bounty_ai_note_step(mover, direction) + mover.set_glide_size(DELAY_TO_GLIDE_SIZE(delay)) + // The AI's own walk waits as long before its next step + var/datum/move_loop/walk = GLOB.move_manager.processing_on(mover, SSai_movement) + if(walk && walk.timer < world.time + delay) + walk.pause_for(delay) + return TRUE + +/// Whether `mover` may take a step by hand now: its own move delay has passed since its last step (BB_BOUNTY_NEXT_STEP_AT) +/proc/bounty_ai_step_ready(mob/living/mover) + var/datum/ai_controller/controller = mover?.ai_controller + if(QDELETED(controller)) + return TRUE + return world.time >= controller.blackboard[BB_BOUNTY_NEXT_STEP_AT] + +/** + * `mover` just stepped in `direction`: its next step by hand waits out the body's own move delay + * (cached_multiplicative_slowdown, what a player's step costs them), longer after a diagonal one as a + * player's is. Returns that delay. + */ +/proc/bounty_ai_note_step(mob/living/mover, direction) + var/delay = max(mover.cached_multiplicative_slowdown, world.tick_lag) + if(ISDIAGONALDIR(direction)) + delay *= sqrt(2) + var/datum/ai_controller/controller = mover.ai_controller + if(!QDELETED(controller)) + controller.set_blackboard_key(BB_BOUNTY_NEXT_STEP_AT, world.time + delay) + return delay /// 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) @@ -624,6 +660,13 @@ if(isliving(mover) && !bounty_ai_step_allowed(mover, path[1])) return FALSE +// Each step of the walk counts as the body's last step, so a step by hand (bounty_ai_step()) waits a step's time after it +/datum/ai_movement/jps/bounty/post_move(datum/move_loop/source, succeeded) + . = ..() + var/mob/living/mover = source.moving + if(succeeded == MOVELOOP_SUCCESS && isliving(mover)) + bounty_ai_note_step(mover, mover.last_move) + /// Now and then a step in some direction, while nothing else is planned: never off the leash, never while hiding, cuffed or down /datum/idle_behavior/bounty_wander /// Chance a second of a step diff --git a/voidcrew/modules/bounties/bounty_ai_human.dm b/voidcrew/modules/bounties/bounty_ai_human.dm index ba71cdb90f2..753d930050c 100644 --- a/voidcrew/modules/bounties/bounty_ai_human.dm +++ b/voidcrew/modules/bounties/bounty_ai_human.dm @@ -12,7 +12,7 @@ * 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 + * - Injectors (bounty_ai_use_injector()): a meek criminal's * stimpack as it bolts: a real pen, used on itself. */ diff --git a/voidcrew/modules/bounties/bounty_ai_normal.dm b/voidcrew/modules/bounties/bounty_ai_normal.dm index 6630df3e905..5f8822c3ca5 100644 --- a/voidcrew/modules/bounties/bounty_ai_normal.dm +++ b/voidcrew/modules/bounties/bounty_ai_normal.dm @@ -15,7 +15,8 @@ * - 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. + * and a bruise pack; a stimpack when Wanted, if a pocket is free (a mini-boss carries the combat stimpack); + * - combat sense (bounty_combat_sense.dm): the stimpack when they tire, cover or a charge under stun fire. * * The shared vars are declared in bounty_types.dm and nowhere else; a var only P3 uses has an * `ai_` prefix. @@ -34,6 +35,9 @@ /datum/ai_planning_subtree/bounty_gate, /datum/ai_planning_subtree/bounty_notice, /datum/ai_planning_subtree/bounty_fight_target, + // Its chrome: a tell, then the implant's own action (C0, bounty_chrome.dm) + /datum/ai_planning_subtree/bounty_chrome, + /datum/ai_planning_subtree/npc_combat_sense, /datum/ai_planning_subtree/bounty_arm, /datum/ai_planning_subtree/bounty_ranged, /datum/ai_planning_subtree/bounty_melee, @@ -51,9 +55,18 @@ return key return BOUNTY_STYLE_BRAWLER -/// Plain clothes for their zone, their tier's armour, their style's weapon and spares, and a bruise pack +/** + * Plain clothes for their zone, their tier's armour, their style's weapon and spares, a bruise pack, and + * when Wanted a stimpack for when they tire in a fight (combat sense, bounty_combat_sense.dm). Every Most + * Wanted is a mini-boss, which carries its own pens, combat stimpack included (boss_supplies()). The + * stimpack goes in a pocket, if the style left one free: a pistol's spare magazine or a knife fills the + * second pocket, and a holster or bandolier takes nothing else. + */ /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) + var/datum/outfit/outfit = bounty_fighter_outfit(BOUNTY_ARCHETYPE_NORMAL, zone, record?.tier, ai_wanted_style(), ai_heavy_weapon(), /obj/item/stack/medical/bruise_pack) + if(record?.tier == BOUNTY_TIER_WANTED && outfit && (!outfit.r_pocket || !outfit.l_pocket)) + bounty_outfit_carry(outfit, /obj/item/reagent_containers/hypospray/medipen/stimpack) + return outfit /mob/living/carbon/human/npc/bounty_criminal/normal/ai_notice(mob/living/hunter) var/mob/living/watched = ai_threat() diff --git a/voidcrew/modules/bounties/bounty_boss.dm b/voidcrew/modules/bounties/bounty_boss.dm index 8c4b1680f80..5ada259688a 100644 --- a/voidcrew/modules/bounties/bounty_boss.dm +++ b/voidcrew/modules/bounties/bounty_boss.dm @@ -14,10 +14,11 @@ * 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. + * - Resistance to stuns is its armour, its kit's own answer to a disabler (bounty_boss_kits.dm, C8) and + * the real stimulant pens it carries, used the way combat sense uses them (human_npc_combat_sense.dm): + * when it tires in a fight, never while one is still in its blood (/datum/npc_combat_sense/bounty/boss). * - "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). + * says so, takes a pen if it wants one, and falls back (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). @@ -25,13 +26,24 @@ * 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. 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. + * joins its posse, and so does every crew member of a ship hunting it who is playing and at its site + * (on it, on its dock strip or aboard a ship landed there), seen or not. 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. Never health. * - 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. + * busy or disabled; worn out, it falls back; a target; its combat sense (its stimulant, and the kit's + * reaction to stun fire, if it has one); its kit's gear; an ability, + * never the same one twice in a row; the kit's way of closing in or keeping away; up to and through + * whatever is in its way, if its kit can go through it; its melee; patching itself up with nobody + * about; with nobody in sight, the hunt for the nearest hunter still on its site that it can get at; + * and with nobody it can get at, out of the sight of those shooting at it from where it can't. It + * calms down after BOUNTY_BOSS_CALM_TIME with nobody around. + * - Hurt by someone it can't get at (behind glass it can't break, a shut door, a gap, or off its site), + * it doesn't stand there: it stops going after them for BOUNTY_BOSS_SHUN_TIME and gets out of their + * sight (boss_find_cover()), however far off they are, with a line as it goes. Someone far off with a + * way to them on foot is in reach, and it goes after them. With real Gorilla Arms and an empty hand it + * punches through a window, grille, table or door it can break, after a tell (boss_start_smash()); the + * punches are the implant's own, and it only starts if it can break everything on the way. * - 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, knocked down or dead * in between (tg's states, CB-24), and nothing happens. @@ -45,6 +57,10 @@ /// Trait source for standing still while busy with an ability #define BOUNTY_BOSS_BUSY_TRAIT "bounty_boss_busy" +/// What boss_busy says while its Gorilla Arms go at a window, grille, table or door +#define BOUNTY_BOSS_BUSY_SMASH "smash" +/// The glow on it while they do +#define BOUNTY_BOSS_SMASH_FILTER "bounty_boss_smash" /// Fire pools the bosses have burning (/obj/effect/bounty_boss_fire_pool), for the cap GLOBAL_LIST_EMPTY(bounty_boss_fire_pools) @@ -96,6 +112,8 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) // 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 + // Its stimulant pens, and a kit's answer to stun fire (C8). A kit with its own reaction uses a subtype. + npc_combat_sense = /datum/npc_combat_sense/bounty/boss /// BOUNTY_KIT_*: which kit it is, and the prefix of its dialogue contexts var/boss_kit /// The ability types it is given @@ -135,10 +153,22 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /// 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 + /// Hunters who hurt it from where it couldn't get at them: weakref -> world.time of the last such hit (boss_note_reach()) + var/list/boss_shunned = list() + /// The tiles it can walk to (boss_walkable()): turf -> steps, the tile it stood on then, and when that was worked out + var/list/boss_walk_cache + var/turf/boss_walk_origin + var/boss_walk_at = 0 + /// world.time it may look for new cover + var/boss_cover_rethink_at = 0 + /// world.time it may say a line again as it breaks for cover + var/boss_cover_bark_at = 0 + /// What its Gorilla Arms are going at (boss_start_smash()), the floor mark on it, and the punches thrown so far + var/datum/weakref/boss_smash_target + var/datum/weakref/boss_smash_mark + var/boss_smash_blows = 0 + /// A thrown item of its own, kept out of the world, that its throws are checked with (boss_throw_reaches()) + var/obj/item/bounty_boss_throw_probe/boss_throw_probe /mob/living/carbon/human/npc/bounty_criminal/boss/Initialize(mapload, datum/human_npc_order/order) . = ..() @@ -158,6 +188,10 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) boss_reinforcement_refs = null boss_winding_ref = null boss_last_attacker = null + boss_shunned = null + boss_walk_cache = null + boss_walk_origin = null + QDEL_NULL(boss_throw_probe) return ..() /mob/living/carbon/human/npc/bounty_criminal/boss/death(gibbed) @@ -198,8 +232,11 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss)) /** - * 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. + * Packs what every boss carries into `outfit`, an instance: BOUNTY_BOSS_STIMULANTS stimulant pens and one + * combat stimpack (BOUNTY_BOSS_COMBAT_STIMULANT; its combat sense uses them when it tires, one at a time) + * and a bruise pack, in a bag on its back (one is added if it wears none; in vacuum its MODsuit's storage + * takes them, bounty_suits.dm). They are consumables: used up, never loot (human_npc_gear.dm). Returns + * the outfit. */ /mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_supplies(datum/outfit/outfit) if(!istype(outfit)) @@ -207,6 +244,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) 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[BOUNTY_BOSS_COMBAT_STIMULANT] = (outfit.backpack_contents[BOUNTY_BOSS_COMBAT_STIMULANT] || 0) + 1 outfit.backpack_contents[/obj/item/stack/medical/bruise_pack] = (outfit.backpack_contents[/obj/item/stack/medical/bruise_pack] || 0) + 1 return outfit @@ -256,19 +294,12 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /// 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 ----- /** @@ -310,6 +341,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) var/datum/action/cooldown/mob_cooldown/bounty_boss/winding = boss_winding_ref?.resolve() boss_winding_ref = null winding?.cancel_windup() + boss_end_smash() if(boss_busy) boss_clear_busy() boss_on_interrupted() @@ -369,7 +401,8 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /** * Turns hostile, with `instigator` (who attacked, confronted or was spotted) in its posse if they * 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. + * BOUNTY_BOSS_POSSE_RANGE and can see it joins too, mech pilots included, then the rest of every + * hunting crew at its site (boss_engage_hunting_crews()), and it says its intro line. */ /mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_turn_hostile(mob/living/instigator) if(stat == DEAD) @@ -387,9 +420,43 @@ 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_engage_hunting_crews() boss_bark("intro") return TRUE +/** + * Every crew member of a ship hunting its bounty who is playing (not SSD) and at its site joins its + * posse, seen or not (boss_crew_at_site()), so each owes a companion like anyone in sight: one hunter + * can't wake it alone while the rest of the crew wait on the dock strip or aboard their landed ship + * (review r1). Crew on another site sharing its level, or aboard a ship anywhere else, don't count + * (review r2). + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_engage_hunting_crews() + var/datum/criminal_bounty/posting = posting() + if(!posting || !get_turf(src)) + return + for(var/obj/structure/overmap/ship/ship as anything in posting.hunter_ships()) + for(var/datum/mind/member as anything in ship.ship_team?.members) + var/mob/living/body = member?.current + if(isliving(body) && GET_CLIENT(body) && boss_crew_at_site(body, ship)) + boss_engage(body, announce = FALSE) + +/** + * Whether `body`, of the crew of `ship`, is at its site for its posse: on its level, and on the site + * itself, or anywhere in the site's rectangle, which holds its dock strip and the ships landed on it. + * For a site with no rectangle (a pirate ship), aboard `ship` close alongside it. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_crew_at_site(mob/living/body, obj/structure/overmap/ship/ship) + var/turf/here = get_turf(src) + var/turf/where = get_turf(body) + if(!here || !where || where.z != here.z) + return FALSE + if(body_on_site(where)) + return TRUE + if(site_bounds) + return where.z == site_bounds[5] && where.x >= site_bounds[1] && where.x <= site_bounds[3] && where.y >= site_bounds[2] && where.y <= site_bounds[4] + return ship?.is_aboard(where) && get_dist(here, where) <= BOUNTY_BOSS_HUNT_RANGE + /// 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 @@ -532,12 +599,19 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return who /** - * 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). + * Whether it chooses to go after `target`: one it may go after (boss_can_go_after()), and not one it + * keeps away from (boss_shuns()). */ /mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_valid_target(atom/target) + return boss_can_go_after(target) && !boss_shuns(target) + +/** + * Whether it may 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/carbon/human/npc/bounty_criminal/boss/proc/boss_can_go_after(atom/target) if(QDELETED(target) || target == src) return FALSE if(!boss_reach_ok(get_turf(target))) @@ -623,26 +697,36 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) for(var/mob/living/hunter as anything in hunters) body_add_grudge(hunter) boss_turn_hostile(hunter) + boss_note_reach(hunter) 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/carbon/human/npc/bounty_criminal/boss/proc/boss_nearest_hunter() +/** + * The nearest hunter (or their mech) still on its site within BOUNTY_BOSS_HUNT_RANGE that it can get + * at (boss_can_reach()), for the hunt: it never walks back out to stand in front of someone behind + * glass. Only players with a client count, from SSmobs' list for its level; a test passes its own + * `candidates`. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_nearest_hunter(list/candidates) var/turf/here = get_turf(src) - if(!here || here.z > length(SSmobs.clients_by_zlevel)) + if(!here) return null + if(isnull(candidates)) + if(here.z > length(SSmobs.clients_by_zlevel)) + return null + candidates = SSmobs.clients_by_zlevel[here.z] var/atom/best var/best_distance = BOUNTY_BOSS_HUNT_RANGE + 1 - for(var/mob/living/person as anything in SSmobs.clients_by_zlevel[here.z]) + for(var/mob/living/person in candidates) var/atom/target = boss_target_for(person) - if(!boss_valid_target(target)) - continue var/turf/spot = get_turf(target) - if(!spot || !leash_ok(spot)) + if(!spot || spot.z != here.z) continue var/distance = get_dist(here, spot) - if(distance < best_distance) - best = target - best_distance = distance + // Nearest first: the costly checks only for someone nearer than the best so far + if(distance >= best_distance || !leash_ok(spot) || !boss_valid_target(target) || !boss_can_reach(target)) + continue + best = target + best_distance = distance return best // ----- where it may reach, and what it may break ----- @@ -800,6 +884,538 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) boss_walls_left-- return TRUE +// ===== HURT FROM WHERE IT CAN'T REACH (review r1 F4, r2) ===== + +/** + * Whether it can get at `target` (a person, or a mech) from where it stands: it may go after them + * there, and it is beside them, or nothing on the straight way stops it, or its kit goes through + * everything that does (boss_gets_through()), or it can walk round to them (boss_walks_to()). + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_can_reach(atom/target) + if(!boss_can_go_after(target)) + return FALSE + var/turf/here = get_turf(src) + var/turf/there = get_turf(target) + if(!here || !there || here.z != there.z) + return FALSE + if(Adjacent(target)) + return TRUE + var/list/blockers = boss_line_blockers(here, there) + if(!length(blockers) || boss_gets_through(blockers)) + return TRUE + return boss_walks_to(there) + +/** + * Whether it can walk to `there`, or beside it (someone up on a table or a crate), through nothing it + * can't open (boss_walkable()). Someone beyond BOUNTY_BOSS_REACH_RANGE is past the walk it works out: + * they count as reachable if that walk reaches its edge at least half its range closer to them, so a + * far shooter with open ground between is chased, and one across a gap or behind a wall near it is + * not (review r2). + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_walks_to(turf/there) + var/turf/here = get_turf(src) + if(!here || !there || here.z != there.z) + return FALSE + var/list/steps = boss_walkable() + if(!isnull(steps[there])) + return TRUE + for(var/direction in GLOB.cardinals) + var/turf/beside = get_step(there, direction) + if(beside && !isnull(steps[beside]) && !boss_border_between(beside, there)) + return TRUE + var/distance = get_dist(here, there) + if(distance <= BOUNTY_BOSS_REACH_RANGE) + return FALSE + var/closer_than = distance - BOUNTY_BOSS_REACH_RANGE / 2 + for(var/turf/spot as anything in steps) + if(get_dist(here, spot) >= BOUNTY_BOSS_REACH_RANGE && get_dist(spot, there) <= closer_than) + return TRUE + return FALSE + +/** + * Whether its kit gets through `barrier` (from boss_line_blockers()) to someone behind it: with real + * Gorilla Arms and an empty hand to punch with (boss_gorilla_goes_through()). Each kit adds its own + * (bounty_boss_kits.dm): a charge, a grenade or a molotov thrown over, a breaching charge, rounds that + * chip through. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_goes_through(atom/barrier) + return boss_gorilla_goes_through(barrier) + +/// All or nothing: whether its kit goes through every one of `blockers` (boss_line_blockers()), so it never breaks a grille only to meet glass it can't +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_gets_through(list/blockers) + if(!length(blockers)) + return TRUE + for(var/atom/blocker as anything in blockers) + if(!boss_goes_through(blocker)) + return FALSE + return TRUE + +/** + * Whether what gets it through `barrier` is ready now, so walking up to it is worth more than going + * round: Gorilla Arms that aren't already at something. Each kit adds its own ability that breaks or + * crosses it, off cooldown. With it on cooldown, the boss goes round on foot if it can (the breach + * planner). + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_breaks_through_now(atom/barrier) + return boss_busy != BOUNTY_BOSS_BUSY_SMASH && boss_gorilla_goes_through(barrier) + +/// Its ability of `ability_type`, if it has one off cooldown +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_ability_off_cooldown(ability_type) + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/ability as anything in boss_abilities) + if(!QDELETED(ability) && istype(ability, ability_type)) + return ability.next_use_time <= world.time ? ability : null + return null + +/// What it can open on its own feet, for working out a walk: the access its AI's pathing uses +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_pass_info() + return new /datum/can_pass_info(src, ai_controller ? ai_controller.get_access() : get_access()) + +/** + * The first thing on the straight way from `start` to `finish` that stops it walking: a wall, a gap + * (space, a drop, lava, a chasm), or something solid it can't open or climb (a window, a grille, a + * shut door, a table). Null if the way is clear. People never count. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_barrier_between(turf/start, turf/finish) + var/list/blockers = boss_line_blockers(start, finish, TRUE) + return length(blockers) ? blockers[1] : null + +/** + * Everything on the straight way from `start` to `finish` that stops it walking, in order: walls, + * gaps, and every solid thing it can't open or climb on each step (a grille and the window on the + * same tile are both there). With `first_only`, only the first step that is blocked. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_line_blockers(turf/start, turf/finish, first_only = FALSE) + . = list() + if(!start || !finish || start.z != finish.z) + return + var/datum/can_pass_info/pass_info = boss_pass_info() + var/turf/previous = start + for(var/turf/spot as anything in get_line(start, finish)) + if(spot == start) + continue + if(spot.density) + . += spot + else if(spot != finish && (isspaceturf(spot) || isopenspaceturf(spot) || isgroundlessturf(spot) || islava(spot) || ischasm(spot))) + . += spot + else if(previous.LinkBlockedWithAccess(spot, pass_info)) + var/list/on_step = boss_blockers_on_step(previous, spot, pass_info) + if(length(on_step)) + // A full-tile window blocks the step off its tile as well as the step onto it: once is enough + . |= on_step + else + . += spot + if(first_only && length(.)) + return + previous = spot + +/** + * What stops a step from `origin` onto `destination`: windows or doors on the edge between them, a + * window filling `origin` (tg's pathing counts one as blocking the step off its tile too), and + * everything solid on `destination`. A diagonal step is checked both ways round, giving what stops the + * first way. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_blockers_on_step(turf/origin, turf/destination, datum/can_pass_info/pass_info) + . = list() + var/direction = get_dir(origin, destination) + if(origin.x != destination.x && origin.y != destination.y) + for(var/half in list(direction & (NORTH|SOUTH), direction & (EAST|WEST))) + var/turf/middle = get_step(origin, half) + if(!middle) + continue + if(middle.density) + return list(middle) + var/list/found = boss_blockers_on_step(origin, middle, pass_info) + boss_blockers_on_step(middle, destination, pass_info) + if(length(found)) + return found + return + for(var/obj/border in origin) + if(border.density && ((border.flags_1 & ON_BORDER_1) || istype(border, /obj/structure/window)) && !border.CanAStarPass(direction, pass_info)) + . += border + var/reverse = get_dir(destination, origin) + for(var/obj/thing in destination) + if(thing.density && !thing.CanAStarPass(reverse, pass_info)) + . += thing + +/// Whether a window or door stands on the edge between two tiles side by side +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_border_between(turf/origin, turf/destination) + var/direction = get_dir(origin, destination) + for(var/obj/border in origin) + if(border.density && (border.flags_1 & ON_BORDER_1) && (border.dir & direction)) + return TRUE + var/reverse = get_dir(destination, origin) + for(var/obj/border in destination) + if(border.density && (border.flags_1 & ON_BORDER_1) && (border.dir & reverse)) + return TRUE + return FALSE + +// ----- what a throw gets past ----- + +/** + * Something it throws, never in the world: an item with a throw of its own and the boss as its thrower, + * so tg's own CanPass() rules for a thrown item decide what stops it (windows, windoors, shut doors and + * grilles do; tables, railings and gaps don't). + */ +/obj/item/bounty_boss_throw_probe + name = "thrown thing" + item_flags = ABSTRACT + +/obj/item/bounty_boss_throw_probe/Destroy() + QDEL_NULL(throwing) + return ..() + +/// Its throw probe, made the first time it is needed +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_get_throw_probe() + if(QDELETED(boss_throw_probe)) + boss_throw_probe = new + if(QDELETED(boss_throw_probe.throwing)) + boss_throw_probe.throwing = new /datum/thrownthing(boss_throw_probe, src, SOUTH, world.maxx, 1, src) + return boss_throw_probe + +/** + * Whether something it throws from `start` lands on `finish`: it takes the steps tg's throw takes + * (throw_at() and /datum/thrownthing/tick()), and each one must be a move tg would let a thrown item + * make. People and mechs on the way never count. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_throw_reaches(turf/start, turf/finish) + start = get_turf(start) + finish = get_turf(finish) + if(!start || !finish || start.z != finish.z) + return FALSE + if(start == finish) + return TRUE + var/obj/item/probe = boss_get_throw_probe() + var/dist_x = abs(finish.x - start.x) + var/dist_y = abs(finish.y - start.y) + var/dx = (finish.x > start.x) ? EAST : WEST + var/dy = (finish.y > start.y) ? NORTH : SOUTH + var/pure_diagonal = dist_x == dist_y + if(!pure_diagonal && dist_x <= dist_y) + var/old_dist = dist_x + dist_x = dist_y + dist_y = old_dist + var/old_dir = dx + dx = dy + dy = old_dir + var/longest = max(dist_x, dist_y) + var/diagonal_error = dist_x / 2 - dist_y + var/turf/at = start + for(var/travelled in 0 to longest) + if(at == finish) + return TRUE + var/turf/step = get_step(at, get_dir(at, finish)) + if(!pure_diagonal) + if(diagonal_error >= 0 && longest - travelled != 1) + step = get_step(at, dx) + diagonal_error += (diagonal_error < 0) ? dist_x / 2 : -dist_y + if(!step || !bounty_boss_throw_move(at, step, probe)) + return FALSE + at = step + return at == finish + +/// Whether a thrown thing gets past `barrier` (from boss_line_blockers()), by tg's rules for a thrown item: a gap yes, a wall no +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_throw_passes(atom/barrier) + if(isturf(barrier)) + return !barrier.density + var/border_dir = (barrier.flags_1 & ON_BORDER_1) ? barrier.dir : get_dir(barrier, src) + return barrier.CanPass(boss_get_throw_probe(), border_dir) + +/** + * Whether `probe`, thrown, moves from `origin` onto `destination` beside it. A diagonal goes the way + * tg's Move() takes one, north or south first; whatever stops that half is bumped, and a bump ends a + * throw (/atom/movable/Bump()), so it never gets to try east or west first. + */ +/proc/bounty_boss_throw_move(turf/origin, turf/destination, obj/item/probe) + var/direction = get_dir(origin, destination) + if(!(direction & (direction - 1))) + return bounty_boss_throw_step(origin, destination, probe) + var/turf/first = get_step(origin, direction & (NORTH|SOUTH)) + return first && bounty_boss_throw_step(origin, first, probe) && bounty_boss_throw_step(first, destination, probe) + +/// One straight step of a thrown `probe`: nothing on the edge of `origin` it leaves by, and tg's CanPass() of `destination` and all on it but people and mechs +/proc/bounty_boss_throw_step(turf/origin, turf/destination, obj/item/probe) + var/direction = get_dir(origin, destination) + for(var/atom/movable/border as anything in origin) + if(border != probe && (border.flags_1 & ON_BORDER_1) && border.density && (border.dir & direction) && !border.CanPass(probe, direction)) + return FALSE + var/from_dir = get_dir(destination, origin) + if(!destination.CanPass(probe, from_dir)) + return FALSE + for(var/atom/movable/thing as anything in destination) + if(thing == probe || isliving(thing) || ismecha(thing)) + continue + if(!thing.CanPass(probe, from_dir)) + return FALSE + return TRUE + +/** + * Every tile it could walk to from where it stands, within BOUNTY_BOSS_REACH_RANGE and on its leash, + * through nothing it can't open: turf -> steps, nearest first. Worked out again once it stands on + * another tile, or after BOUNTY_BOSS_REACH_RETHINK on the same one, so the steps and the range are + * always counted from where it is (review r2). + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_walkable() + var/turf/here = get_turf(src) + if(!here) + return list() + if(boss_walk_cache && boss_walk_origin == here && world.time < boss_walk_at + BOUNTY_BOSS_REACH_RETHINK) + return boss_walk_cache + var/datum/can_pass_info/pass_info = boss_pass_info() + var/list/steps = list() + steps[here] = 0 + var/list/queue = list(here) + var/index = 0 + while(index < length(queue)) + index++ + var/turf/spot = queue[index] + var/next_steps = steps[spot] + 1 + for(var/direction in GLOB.cardinals) + var/turf/next = get_step(spot, direction) + if(!next || next.density || !isnull(steps[next]) || get_dist(here, next) > BOUNTY_BOSS_REACH_RANGE) + continue + if(spot.LinkBlockedWithAccess(next, pass_info) || !leash_ok(next)) + continue + steps[next] = next_steps + queue += next + boss_walk_cache = steps + boss_walk_origin = here + boss_walk_at = world.time + return steps + +/// `hunter` just hurt it: if it can't get at them where they are, it keeps away from them for BOUNTY_BOSS_SHUN_TIME +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_note_reach(mob/living/hunter) + if(!boss_can_act() || boss_can_reach(boss_target_for(hunter))) + return FALSE + boss_shunned[WEAKREF(hunter)] = world.time + return TRUE + +/// Whether it keeps away from `target` (a person, or a mech): one of them hurt it lately from where it couldn't get at them, and it still can't +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_shuns(atom/target) + if(!length(boss_shunned)) + return FALSE + for(var/mob/living/person as anything in boss_people_in(target)) + var/last = person.weak_reference ? boss_shunned[person.weak_reference] : null + if(last && world.time < last + BOUNTY_BOSS_SHUN_TIME) + return !boss_can_reach(target) + return FALSE + +/// The hunters it shuns who are still up and still out of its reach (their mechs, for those in one): whose sight it keeps out of. Forgets those it has shunned long enough. +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_watchers() + . = list() + for(var/datum/weakref/ref as anything in boss_shunned.Copy()) + var/mob/living/person = ref.resolve() + if(QDELETED(person) || world.time >= boss_shunned[ref] + BOUNTY_BOSS_SHUN_TIME) + boss_shunned -= ref + continue + if(person.stat != CONSCIOUS) + continue + var/atom/watcher = boss_target_for(person) + if(!boss_can_reach(watcher)) + . |= watcher + +/** + * Whether any of `watchers` can see `spot`: a clear line from them on its level. Within + * BOUNTY_BOSS_COVER_SIGHT, and as far as the line goes past that, so a shooter further off (a scope, + * the dock strip) never leaves it standing in the open thinking it is hidden (review r2). + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_seen_from(turf/spot, list/watchers) + spot = get_turf(spot) + if(!spot) + return FALSE + for(var/atom/watcher as anything in watchers) + var/turf/from = get_turf(watcher) + if(!from || from.z != spot.z) + continue + if(can_see(from, spot, max(BOUNTY_BOSS_COVER_SIGHT, get_dist(from, spot)))) + return TRUE + return FALSE + +/// It breaks for cover from someone it can't get at: a line for it, at most every BOUNTY_BOSS_COVER_BARK_COOLDOWN, so it reads as biding its time, not running +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_cover_bark() + if(world.time < boss_cover_bark_at) + return FALSE + boss_cover_bark_at = world.time + BOUNTY_BOSS_COVER_BARK_COOLDOWN + boss_bark("cover") + return TRUE + +/// How far `spot` is from the nearest of `watchers` +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_distance_from(turf/spot, list/watchers) + . = INFINITY + for(var/atom/watcher as anything in watchers) + . = min(., get_dist(spot, watcher)) + +/** + * Cover from `watchers`: the nearest tile it can walk to within BOUNTY_BOSS_COVER_RANGE steps that + * none of them can see. With nowhere hidden, the one farthest from the nearest of them. Null if + * where it stands is as good as any. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_find_cover(list/watchers) + var/list/steps = boss_walkable() + var/turf/here = get_turf(src) + var/turf/far = here + var/far_distance = boss_distance_from(here, watchers) + // In order of steps, nearest first + for(var/turf/spot as anything in steps) + if(steps[spot] > BOUNTY_BOSS_COVER_RANGE || (spot != here && boss_someone_on(spot))) + continue + if(!boss_seen_from(spot, watchers)) + return spot + var/distance = boss_distance_from(spot, watchers) + if(distance > far_distance) + far = spot + far_distance = distance + return far == here ? null : far + +/// Whether someone else stands on `spot`, so it can't +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_someone_on(turf/spot) + for(var/mob/living/other in spot) + if(other != src && other.density) + return TRUE + return FALSE + +/// The tile it walks to, to go through `barrier` at `target`: the last one before it on the straight way, if it can walk there +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_spot_before(atom/barrier, atom/target) + var/turf/here = get_turf(src) + var/turf/barrier_turf = get_turf(barrier) + if(!here || !barrier_turf) + return null + var/turf/before + for(var/turf/spot as anything in get_line(here, barrier_turf)) + if(spot == barrier_turf) + break + before = spot + if(!before || before == here) + return null + var/list/steps = boss_walkable() + return isnull(steps[before]) ? null : before + +// ===== GORILLA ARMS THROUGH GLASS ===== + +/// Its working Gorilla Arms: the real implant, not EMP'd, browned out or failing +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_gorilla_arms() + . = list() + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in organs) + var/datum/component/cyberware/ware = arm.GetComponent(/datum/component/cyberware) + if(ware?.is_running()) + . += arm + +/// The hand index of `arm`'s own hand, if that hand is empty (the implant only punches with its own fist), else 0 +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_gorilla_hand(obj/item/organ/cyberimp/cyberware/gorilla_arms/arm) + var/obj/item/bodypart/limb = get_bodypart(arm.zone) + if(!limb?.held_index || !isnull(get_item_for_held_index(limb.held_index))) + return 0 + return limb.held_index + +/// Whether it has a working Gorilla Arm with an empty hand to punch with +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_has_gorilla_fist() + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in boss_gorilla_arms()) + if(boss_gorilla_hand(arm)) + return TRUE + return FALSE + +/// Whether its Gorilla Arms get it through `barrier`: one it may smash (boss_can_smash()), with a fist free to do it. Airlocks are left to the arms' own door forcing. +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_gorilla_goes_through(atom/barrier) + return boss_has_gorilla_fist() && boss_can_smash(barrier) + +/** + * Whether its Gorilla Arms may go at `barrier`: a window, a grille, a table or a door that isn't an + * airlock, where it may break things (boss_may_break(): its own site, indoors, never near a ship), and + * one the implant's punches break in at most BOUNTY_BOSS_SMASH_MOST_BLOWS through its armour. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_can_smash(atom/barrier) + if(!isobj(barrier) || istype(barrier, /obj/machinery/door/airlock)) + return FALSE + if(!istype(barrier, /obj/structure/window) && !istype(barrier, /obj/structure/grille) && !istype(barrier, /obj/structure/table) && !istype(barrier, /obj/machinery/door)) + return FALSE + var/obj/thing = barrier + if(!thing.uses_integrity || !boss_may_break(thing)) + return FALSE + var/blow = thing.run_atom_armor(BOUNTY_BOSS_SMASH_BLOW, BRUTE, MELEE, get_dir(thing, src)) + return blow > 0 && thing.get_integrity() <= blow * BOUNTY_BOSS_SMASH_MOST_BLOWS + +/** + * Its Gorilla Arms go at `barrier`, right beside it. The tell first, for BOUNTY_BOSS_SMASH_WINDUP: + * rooted, an orange glow, the barrier's tile lit and the pistons heard. Then real punches with its + * empty Gorilla fists (boss_smash_blow()), each the implant's own, until the barrier is down, the + * punches run out or something stops it. Nobody is hurt by it. Returns TRUE if it started. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_start_smash(atom/barrier) + if(!boss_can_use_ability() || !ai_controller || !Adjacent(barrier) || !boss_has_gorilla_fist() || !boss_can_smash(barrier)) + return FALSE + var/smash_time = BOUNTY_BOSS_SMASH_WINDUP + BOUNTY_BOSS_SMASH_MOST_BLOWS * 1 SECONDS + var/serial = boss_set_busy(BOUNTY_BOSS_BUSY_SMASH, smash_time + 1 SECONDS) + boss_next_ability_at = max(boss_next_ability_at, world.time + BOUNTY_BOSS_SMASH_WINDUP + BOUNTY_BOSS_SMASH_RECOVER) + boss_smash_target = WEAKREF(barrier) + boss_smash_blows = 0 + face_atom(barrier) + visible_message(span_boldwarning("[src] draws back a piston-driven fist at [barrier]!"), blind_message = span_hear("You hear pistons hiss.")) + playsound(src, 'sound/machines/piston/piston_raise.ogg', 60, TRUE) + add_filter(BOUNTY_BOSS_SMASH_FILTER, 2, outline_filter(1, BOUNTY_BOSS_SMASH_COLOR)) + boss_smash_mark = WEAKREF(new /obj/effect/temp_visual/bounty_boss_mark(get_turf(barrier), smash_time, BOUNTY_BOSS_SMASH_COLOR)) + addtimer(CALLBACK(src, PROC_REF(boss_smash_blow), serial), BOUNTY_BOSS_SMASH_WINDUP, TIMER_DELETE_ME) + return TRUE + +/** + * One punch of the smash under `serial` at its barrier: the empty fist of a working Gorilla Arm whose + * own cooldown is over is made the active hand, and the barrier is clicked with it in combat mode, the + * way a player punches (controller.ai_interact()). The implant does the damage. The next punch follows + * when the body and an arm are ready again. Returns TRUE if it threw one. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_smash_blow(serial) + if(!boss_still(BOUNTY_BOSS_BUSY_SMASH, serial)) + return FALSE + var/obj/barrier = boss_smash_target?.resolve() + if(QDELETED(barrier) || !barrier.density || !Adjacent(barrier) || boss_smash_blows >= BOUNTY_BOSS_SMASH_MOST_BLOWS || !boss_may_break(barrier) || !boss_has_gorilla_fist()) + boss_end_smash(serial) + return FALSE + var/threw = FALSE + if(next_move <= world.time) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in boss_gorilla_arms()) + var/hand = boss_gorilla_hand(arm) + if(!hand || !COOLDOWN_FINISHED(arm, slam_cooldown)) + continue + swap_hand(hand, silent = TRUE) + if(get_active_held_item()) + continue + var/is_door = istype(barrier, /obj/machinery/door) + boss_smash_blows++ + ai_controller.ai_interact(target = barrier, combat_mode = TRUE) + threw = TRUE + // A door it punches down spends its wall budget, as one any ability breaks does + if(is_door && (QDELETED(barrier) || barrier.get_integrity() <= 0)) + boss_walls_left-- + break + if(QDELETED(barrier) || !barrier.density || boss_smash_blows >= BOUNTY_BOSS_SMASH_MOST_BLOWS) + boss_end_smash(serial) + return threw + addtimer(CALLBACK(src, PROC_REF(boss_smash_blow), serial), boss_smash_wait(), TIMER_DELETE_ME) + return threw + +/// How long until it can throw its next smash punch: its body's click and the soonest arm's own cooldown, at least a tick +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_smash_wait() + var/soonest = INFINITY + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in boss_gorilla_arms()) + if(boss_gorilla_hand(arm)) + soonest = min(soonest, arm.slam_cooldown) + if(soonest == INFINITY) + soonest = world.time + return max(1, next_move - world.time, soonest - world.time) + +/// The smash is over, or never was: the tell goes, and with `serial` (or none) it is no longer busy with it +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_end_smash(serial) + boss_end_smash_telegraph() + boss_smash_target = null + boss_smash_blows = 0 + if(boss_busy == BOUNTY_BOSS_BUSY_SMASH && (!serial || serial == boss_busy_serial)) + boss_clear_busy(serial) + +/// The smash's glow and floor mark go +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_end_smash_telegraph() + remove_filter(BOUNTY_BOSS_SMASH_FILTER) + var/obj/effect/mark = boss_smash_mark?.resolve() + boss_smash_mark = null + if(!QDELETED(mark)) + qdel(mark) + // ===== SIGNALS ===== /** @@ -967,6 +1583,11 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner return istype(boss) && boss.boss_landing_ok(get_turf(target)) +/// Whether something it throws from where it stands would land where `target` stands, and not stop on glass or a door on the way +/datum/action/cooldown/mob_cooldown/bounty_boss/proc/throw_reaches(atom/target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + return istype(boss) && boss.boss_throw_reaches(get_turf(boss), get_turf(target)) + /datum/action/cooldown/mob_cooldown/bounty_boss/Activate(atom/target) var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss) || QDELETED(target)) @@ -1227,10 +1848,13 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /** * 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. + * it is busy or can't act; worn out, it falls back; its target; its combat sense (a stimulant when it + * tires, and a kit's own reaction to stun fire); its kit's gear; drawing + * its weapon once its fight has started; an ability; the kit's way of closing in or keeping away; up to + * and through whatever is in its way; its melee with what it holds; patching itself up with nobody + * about; with nobody in sight, the hunt for the nearest hunter still on its site that it can get at; + * and with nobody it can get at, out of the sight of those shooting at it from where it can't. Bosses + * never surrender. */ /datum/ai_controller/basic_controller/bounty_boss blackboard = list( @@ -1245,16 +1869,18 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /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/npc_combat_sense, /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/bounty_boss_breach, /datum/ai_planning_subtree/human_npc_melee, /datum/ai_planning_subtree/bounty_treat_self, /datum/ai_planning_subtree/bounty_boss_hunt, + /datum/ai_planning_subtree/bounty_boss_cover, ) /datum/ai_controller/basic_controller/bounty_boss/TryPossessPawn(atom/new_pawn) @@ -1296,9 +1922,10 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /** * 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. + * the hunters (boss_wear_out()). If it wants a stimulant pen now (combat sense's own rule: winded, in a + * fight, none in its blood) it takes it first; then it falls back from whoever it was fighting for + * BOUNTY_BOSS_FALLBACK_TIME and fights on. Back above the line (healed, or its stamina back), it is fresh + * again. */ /datum/ai_planning_subtree/bounty_boss_worn_out @@ -1312,9 +1939,10 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return if(!boss.boss_worn_out) boss.boss_wear_out() + var/datum/component/npc_combat_sense/sense = boss.GetComponent(/datum/component/npc_combat_sense) + if(sense?.rules.can_act(boss, controller) && sense.rules.plan_stim(boss, controller, sense)) + return SUBTREE_RETURN_FINISH_PLANNING 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() @@ -1324,38 +1952,6 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) 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 @@ -1481,6 +2077,129 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) controller.queue_behavior(/datum/ai_behavior/travel_towards/adjacent, BB_BOUNTY_BOSS_PREY) return SUBTREE_RETURN_FINISH_PLANNING +/** + * Its target stands behind things its kit goes through, every one of them (boss_gets_through()): it + * walks up to the first, and with Gorilla Arms right beside it, smashes it. A kit's own ability (a + * charge, a grenade, a breaching charge) has had its turn already. It only does this while what breaks + * through is ready (boss_breaks_through_now()), or when there is no way round on foot; otherwise it + * leaves the walk round to the melee planner rather than wait at the glass (review r2). + */ +/datum/ai_planning_subtree/bounty_boss_breach + +/datum/ai_planning_subtree/bounty_boss_breach/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(!istype(boss) || QDELETED(target) || boss.Adjacent(target)) + return + var/turf/here = get_turf(boss) + var/turf/there = get_turf(target) + var/list/blockers = boss.boss_line_blockers(here, there) + if(!length(blockers) || !boss.boss_gets_through(blockers)) + return + var/atom/barrier = blockers[1] + if(!boss.boss_breaks_through_now(barrier) && boss.boss_walks_to(there)) + return + if(get_dist(here, barrier) <= 1) + if(boss.boss_start_smash(barrier)) + return SUBTREE_RETURN_FINISH_PLANNING + return + var/turf/spot = boss.boss_spot_before(barrier, target) + if(!spot) + return + if(controller.blackboard[BB_BOUNTY_BOSS_SPOT] != spot) + controller.CancelActions() + controller.set_blackboard_key(BB_BOUNTY_BOSS_SPOT, spot) + controller.queue_behavior(/datum/ai_behavior/travel_towards, BB_BOUNTY_BOSS_SPOT) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * Hurt lately by someone it can't get at (boss_shuns()), and nobody it can reach in sight or on the + * hunt: it gets out of their sight (boss_find_cover()) and waits there, rather than stand in the open + * for them, with a line as it goes (boss_cover_bark()). With nowhere hidden in reach it backs off as + * far from them as it can, and keeps going until it gets there. Anyone it can reach brings it out. + */ +/datum/ai_planning_subtree/bounty_boss_cover + +/datum/ai_planning_subtree/bounty_boss_cover/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn + if(!istype(boss) || !length(boss.boss_shunned) || controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/list/watchers = boss.boss_watchers() + if(!length(watchers)) + return + var/turf/here = get_turf(boss) + if(!boss.boss_seen_from(here, watchers)) + controller.clear_blackboard_key(BB_BOUNTY_BOSS_COVER) + return SUBTREE_RETURN_FINISH_PLANNING + var/turf/spot = controller.blackboard[BB_BOUNTY_BOSS_COVER] + // On its way: it keeps walking (every plan, or the walk it queued last time is dropped) until it + // gets there, unless someone took the spot, or it may look again and finds the spot in their sight. + if(spot && spot != here && !boss.boss_someone_on(spot) && (world.time < boss.boss_cover_rethink_at || !boss.boss_seen_from(spot, watchers))) + controller.queue_behavior(/datum/ai_behavior/travel_towards, BB_BOUNTY_BOSS_COVER) + return SUBTREE_RETURN_FINISH_PLANNING + if(world.time < boss.boss_cover_rethink_at) + return SUBTREE_RETURN_FINISH_PLANNING + boss.boss_cover_rethink_at = world.time + BOUNTY_BOSS_REACH_RETHINK + spot = boss.boss_find_cover(watchers) + if(!spot) + controller.clear_blackboard_key(BB_BOUNTY_BOSS_COVER) + return + if(controller.blackboard[BB_BOUNTY_BOSS_COVER] != spot) + controller.CancelActions() + controller.set_blackboard_key(BB_BOUNTY_BOSS_COVER, spot) + boss.boss_cover_bark() + controller.queue_behavior(/datum/ai_behavior/travel_towards, BB_BOUNTY_BOSS_COVER) + return SUBTREE_RETURN_FINISH_PLANNING + +// ===== COMBAT SENSE: ITS STIMULANT, AND A KIT'S ANSWER TO STUN FIRE (C8) ===== + +/** + * A boss's combat sense (voidcrew/modules/human_npcs/human_npc_combat_sense.dm): the bounty family's leash + * and gang rules, and the stimulant pens it carries (boss_supplies()), taken when it tires in a fight and + * never while one is still in its blood. Nothing else injects them: its worn-out fall back asks this for + * the pen too (bounty_boss_worn_out). By default stun fire changes nothing else about how it fights; a + * kit with its own reaction sets it on a subtype (bounty_boss_kits.dm), and a ready ability always goes + * first, its wind-up being the kit's own answer. + */ +/datum/npc_combat_sense/bounty/boss + react_to_stun_fire = FALSE + +/datum/npc_combat_sense/bounty/boss/can_act(mob/living/carbon/human/npc, datum/ai_controller/controller) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = npc + return istype(boss) && boss.boss_hostile && !boss.boss_busy && ..() + +/datum/npc_combat_sense/bounty/boss/in_fight(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = npc + return istype(boss) && boss.boss_hostile && (controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET) || sense.under_fire()) + +/datum/npc_combat_sense/bounty/boss/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) + if(plan_stim(npc, controller, sense)) + return SUBTREE_RETURN_FINISH_PLANNING + if(!under_fire || !react_to_stun_fire || !may_move(npc, controller)) + return + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = npc + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(!QDELETED(target) && boss.boss_choose_ability(target)) + return + if(close_in_reach && reach(npc, controller) <= close_in_reach) + return plan_close_in(npc, controller, sense) + return plan_cover(npc, controller, sense) + +// The second pen of a fight comes with its "recover" line ("Round two."), as its second wind always did. +/datum/npc_combat_sense/bounty/boss/telegraph(mob/living/carbon/human/npc, kind, atom/about, obj/item/used) + . = ..() + if(kind != HUMAN_NPC_BARK_STIMULANT) + return + var/datum/component/npc_combat_sense/sense = npc.GetComponent(/datum/component/npc_combat_sense) + if(sense?.stims_used) + INVOKE_ASYNC(npc, TYPE_PROC_REF(/mob/living, bounty_say), "recover", null, TRUE) + // ===== LOOKS ===== /// A mini-boss's clothes before its kit's: plain dark clothes @@ -1491,3 +2210,5 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) gloves = /obj/item/clothing/gloves/color/black #undef BOUNTY_BOSS_BUSY_TRAIT +#undef BOUNTY_BOSS_BUSY_SMASH +#undef BOUNTY_BOSS_SMASH_FILTER diff --git a/voidcrew/modules/bounties/bounty_boss_kits.dm b/voidcrew/modules/bounties/bounty_boss_kits.dm index 3e6d485036f..19c23093c19 100644 --- a/voidcrew/modules/bounties/bounty_boss_kits.dm +++ b/voidcrew/modules/bounties/bounty_boss_kits.dm @@ -7,29 +7,53 @@ * (/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. + * stimulants and bruise pack are packed by boss_supplies(), and its combat sense (bounty_boss.dm) uses + * the pens when it tires. Nothing it carries is ever loot. * - * - Juggernaut: riot armour and a body grown huge (tg's gigantism gene). Charges in a line, smashing + * - Juggernaut: riot armour, a body grown huge (tg's gigantism gene) and a tower shield it raises as its + * fight starts, stopping every shot from in front of it (C8: flank it). 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). + * when someone is close. Fights with its shield and its free fist. + * - Pyromaniac: a real firefighter suit and helmet (tg's thermal protection, CB-7), a gas mask, a real + * flamethrower with a plasma tank and a molotov in hand, and an ID with its name. Hoses a short line of + * fire with the flamethrower and throws molotovs that leave a burning patch; whoever it catches burns with + * tg's fire stacks (CB-8). Every BOUNTY_PYROMANIAC_FLAMER_SWEEPS sweeps the tank runs dry and it stops to + * change it for one of its spares, open while it does. Its mask keeps its own smoke out of its lungs. Shot with a disabler, it goes for the shooter until its flamer reaches + * them (C8: keep your distance and keep moving). Shot from past its flamer's reach, it pulls the pin + * on one of its two real smoke grenades and throws it halfway to the shooter, then comes through the + * cloud to where the shots came from (C9: back out of the smoke, flank it, or see through it). * - 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). + * someone behind cover. Whoever a blast catches takes tg's light explosion (CB-10). A real CNS + * rebooter in its head gets it up a second after its first stamina crit of a minute (C8: pile on, and + * cuff it on the second). * - 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: 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. + * cuts. Shot with a disabler from beyond its dash, it breaks the line and comes again from cover (C8: + * corner it). + * - Heavy: an ablative trenchcoat with its hood up (C8: energy armour everywhere and half of all beams + * reflected; bring lethal, or a lot of shots) 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. * - * 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. + * Where the air would kill it, each kit seals up in a real MODsuit of its own theme, close to the armour + * of what it wears in good air (bounty_sealed_gear(), bounty_suits.dm): the Juggernaut a security suit, + * the Pyromaniac an atmospherics one, the Demolitionist an engineering one, the Ghost a civilian one and + * the Heavy a magnate one. The suit takes its bag's place on its back, the bag's things in its storage. + * A coat or riot plates don't go over a MODsuit: the Juggernaut keeps its buckler, and the Heavy has the + * magnate suit's energy armour (its coat's) but no reflection out there. + * + * Behind something it can't walk through, a hunter is out of reach unless the kit gets through it + * (boss_goes_through(), bounty_boss.dm): the Juggernaut's charge, the Demolitionist's grenades and + * breaching charge, the Pyromaniac's molotovs, the Heavy's rounds, and real Gorilla Arms (the cyberpsycho's, + * or an admin's pick; no kit rolls them). A grenade or a molotov only goes where a thrown item would + * (boss_throw_passes(), boss_throw_reaches()): over a table, a railing or a gap, never through glass, + * a windoor, a grille or a shut door. + * The Ghost has nothing for it, and takes cover instead. It walks up to the barrier only while that + * ability is off cooldown (boss_breaks_through_now()), or when there is no way round; otherwise it goes + * round on foot. * * 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. @@ -39,7 +63,7 @@ /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut name = "armoured criminal" - desc = "A huge criminal in riot plates, built like a door." + desc = "A huge criminal in riot plates behind a tower shield, built like a door." boss_kit = BOUNTY_KIT_JUGGERNAUT boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/charge, @@ -55,14 +79,64 @@ return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/juggernaut)) /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss_gear_text() - 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." + . = istype(wear_suit, /obj/item/clothing/suit/armor/riot) ? "Riot plates cover [p_them()] from neck to boots." : "[p_They()] [p_are()] built like a door." + if(boss_shield()) + . += " A tower shield covers [p_their()] front." + +/// The tower shield it holds, if it still has one (C8) +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/proc/boss_shield() + for(var/obj/item/shield/riot/phalanx_buckler/shield in held_items) + return shield + return null + +// Its fight on, it raises the shield it holds, the player's way (use in hand), and keeps it up. +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss_gear_plan(datum/ai_controller/controller) + var/obj/item/shield/riot/phalanx_buckler/shield = boss_shield() + if(isnull(shield) || shield.raised || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED) || world.time < controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT]) + return FALSE + controller.queue_behavior(/datum/ai_behavior/bounty_juggernaut_raise_shield) + return TRUE + +/// The Juggernaut raises its shield: the shield in its active hand, then used in hand (tg's Z key) +/datum/ai_behavior/bounty_juggernaut_raise_shield + +/datum/ai_behavior/bounty_juggernaut_raise_shield/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/jugg = controller.pawn + var/obj/item/shield/riot/phalanx_buckler/shield = istype(jugg) ? jugg.boss_shield() : null + if(isnull(shield) || !human_npc_ready_item(jugg, shield)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!shield.raised) + jugg.execute_mode() + if(!shield.raised) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + jugg.visible_message(span_warning("[jugg] sets [jugg.p_their()] shield in front of [jugg.p_them()].")) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED -// Out where the air kills: a black and red space suit, as heavy as its riot plates +// A try that got nowhere: it fights on and tries again in a while, rather than fumble with it every plan +/datum/ai_behavior/bounty_juggernaut_raise_shield/finish_action(datum/ai_controller/controller, succeeded) + . = ..() + if(!succeeded) + controller.set_blackboard_key(BB_HUMAN_NPC_ARMING_RETRY_AT, world.time + 5 SECONDS) + +// Out where the air kills: a security MODsuit, the nearest to 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) + return list(/obj/item/mod/control/pre_equipped/bounty_boss/security) +// Its charge goes straight through a table, a chair, a plain window or a grille +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss_goes_through(atom/barrier) + if(..()) + return TRUE + var/datum/action/cooldown/mob_cooldown/bounty_boss/charge/charge = locate() in boss_abilities + return isobj(barrier) && charge?.smashes(barrier) && boss_may_break(barrier) + +// With its charge ready +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss_breaks_through_now(atom/barrier) + if(..()) + return TRUE + var/datum/action/cooldown/mob_cooldown/bounty_boss/charge/charge = boss_ability_off_cooldown(/datum/action/cooldown/mob_cooldown/bounty_boss/charge) + return isobj(barrier) && charge?.smashes(barrier) && boss_may_break(barrier) + +// The shield has no sling, so it is held from the start, in the off hand; the other fist stays free. /datum/outfit/bounty_boss/juggernaut name = "Bounty mini-boss: Juggernaut" uniform = /obj/item/clothing/under/syndicate/combat @@ -70,6 +144,7 @@ head = /obj/item/clothing/head/helmet/toggleable/riot gloves = /obj/item/clothing/gloves/combat shoes = /obj/item/clothing/shoes/jackboots + l_hand = BOUNTY_JUGGERNAUT_SHIELD /** * Charge: a roar, a stamp and a line on the floor, then a run down that line. The first person in @@ -274,7 +349,7 @@ */ /datum/action/cooldown/mob_cooldown/bounty_boss/slam name = "Ground Slam" - desc = "Bring both fists down on the floor and knock everyone around you off their feet." + desc = "Bring your whole weight down on the floor and knock everyone around you off their feet." cooldown_time = BOUNTY_JUGGERNAUT_SLAM_COOLDOWN windup = BOUNTY_JUGGERNAUT_SLAM_WINDUP @@ -282,7 +357,7 @@ return aimable(target) && get_dist(owner, target) <= 1 /datum/action/cooldown/mob_cooldown/bounty_boss/slam/telegraph(atom/target) - owner.visible_message(span_boldwarning("[owner] raises both fists high over [owner.p_their()] head!")) + owner.visible_message(span_boldwarning("[owner] raises both arms high over [owner.p_their()] head!")) playsound(owner, 'sound/effects/magic/tail_swing.ogg', 60, TRUE) mark_turfs(RANGE_TURFS(1, owner), COLOR_RED) var/matrix/rest = matrix(owner.transform) @@ -293,7 +368,7 @@ /datum/action/cooldown/mob_cooldown/bounty_boss/slam/effect(atom/target) var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner - boss.visible_message(span_danger("[boss] brings both fists down on the floor!")) + boss.visible_message(span_danger("[boss] brings [boss.p_their()] whole weight 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))) boss.boss_hit(victim, BOUNTY_JUGGERNAUT_SLAM_DAMAGE, BRUTE, MELEE, BOUNTY_JUGGERNAUT_SLAM_KNOCKDOWN) @@ -304,75 +379,342 @@ /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac name = "scorched criminal" - desc = "A criminal in a blackened fire suit, with a lit torch in hand." + desc = "A criminal in a blackened fire suit and a gas mask, a flamethrower in one hand and a bottle in the other." boss_kit = BOUNTY_KIT_PYROMANIAC + npc_combat_sense = /datum/npc_combat_sense/bounty/boss/pyromaniac boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/flamer, /datum/action/cooldown/mob_cooldown/bounty_boss/molotov, + /datum/action/cooldown/mob_cooldown/bounty_boss/smoke, ) + /// Sweeps fired off the tank in its flamethrower now + var/boss_flamer_sweeps = 0 + /// world.time its tank change may finish: it takes BOUNTY_PYROMANIAC_RELOAD_TIME + var/boss_reload_ready_at = 0 /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/bounty_build_outfit(zone) - return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/pyromaniac)) + var/datum/outfit/kit = boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/pyromaniac)) + if(istype(kit)) + kit.backpack_contents[/obj/item/tank/internals/plasma/full] = BOUNTY_PYROMANIAC_SPARE_TANKS + return kit + +// The flamethrower's tank runs dry: it changes it for a spare from its bag (bounty_pyro_reload) +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/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/flamethrower/flamer = boss_flamethrower() + if(isnull(flamer) || bounty_pyro_flamer_fuelled(flamer) || isnull(boss_spare_tank())) + return FALSE + controller.queue_behavior(/datum/ai_behavior/bounty_pyro_reload) + return TRUE + +/// A full plasma tank it carries that isn't in its flamethrower, in hand or where it can draw it from +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/proc/boss_spare_tank() + var/obj/item/flamethrower/flamer = boss_flamethrower() + for(var/obj/item/tank/internals/plasma/tank in get_all_contents_type(/obj/item/tank/internals/plasma)) + if(tank == flamer?.ptank || !(is_holding(tank) || human_npc_can_draw(src, tank))) + continue + var/datum/gas_mixture/tank_air = tank.return_air() + if(tank_air?.return_pressure() >= BOUNTY_PYROMANIAC_FLAMER_EMPTY) + return tank + return null + +/** + * One sweep's plasma out of its flamethrower's tank: an even share of what is left, so the tank is dry + * after BOUNTY_PYROMANIAC_FLAMER_SWEEPS sweeps. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/proc/boss_spend_flamer_fuel(obj/item/flamethrower/flamer) + var/datum/gas_mixture/tank_air = flamer?.ptank?.return_air() + if(isnull(tank_air)) + return + boss_flamer_sweeps++ + var/sweeps_left = BOUNTY_PYROMANIAC_FLAMER_SWEEPS - boss_flamer_sweeps + tank_air.remove_ratio(sweeps_left <= 0 ? 1 : 1 / (sweeps_left + 1)) + if(sweeps_left <= 0) + visible_message(span_warning("[src]'s flamethrower coughs and sputters out.")) + +/** + * Changes the plasma tank on its flamethrower the way a player does: a hand freed (the bottle into its + * bag), a full tank out of the bag, and the flamethrower clicked with it, which swaps the tanks and drops + * the empty (tg's flamethrower; the empty is its locked gear, so it is gone once on the floor). It stops + * for it, with a line and the wrench of the fitting, and takes at least BOUNTY_PYROMANIAC_RELOAD_TIME. + * Gives up after a while and fights on. + */ +/datum/ai_behavior/bounty_pyro_reload + action_cooldown = 0.5 SECONDS + +/datum/ai_behavior/bounty_pyro_reload/setup(datum/ai_controller/controller) + . = ..() + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = controller.pawn + var/obj/item/flamethrower/flamer = istype(pyro) ? pyro.boss_flamethrower() : null + if(isnull(flamer)) + return FALSE + controller.set_blackboard_key(BB_BOUNTY_BOSS_RELOAD_UNTIL, world.time + 12 SECONDS) + pyro.boss_reload_ready_at = world.time + BOUNTY_PYROMANIAC_RELOAD_TIME + if(flamer.lit) + flamer.toggle_igniter(pyro) + pyro.visible_message(span_warning("[pyro] stops and wrenches the empty tank off [pyro.p_their()] flamethrower.")) + playsound(pyro, 'sound/items/tools/ratchet_slow.ogg', 60, TRUE) + pyro.boss_bark("reload") + +/datum/ai_behavior/bounty_pyro_reload/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = controller.pawn + var/obj/item/flamethrower/flamer = istype(pyro) ? pyro.boss_flamethrower() : null + if(isnull(flamer) || world.time >= controller.blackboard[BB_BOUNTY_BOSS_RELOAD_UNTIL] || HAS_TRAIT(pyro, TRAIT_HANDS_BLOCKED)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(bounty_pyro_flamer_fuelled(flamer)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(pyro.next_move > world.time) + return AI_BEHAVIOR_DELAY + var/obj/item/tank/internals/plasma/tank = pyro.boss_spare_tank() + if(isnull(tank)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!pyro.is_holding(tank)) + if(!length(pyro.get_empty_held_indexes())) + var/obj/item/bottle = locate(/obj/item/reagent_containers/cup/glass/bottle/molotov) in pyro.held_items + if(isnull(bottle) || !pyro.back?.atom_storage?.attempt_insert(bottle, pyro, messages = FALSE)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_take_in_hand(pyro, tank)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(world.time < pyro.boss_reload_ready_at) + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(pyro, tank)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.ai_interact(target = flamer, combat_mode = FALSE) + if(flamer.ptank == tank) + pyro.boss_flamer_sweeps = 0 + playsound(pyro, 'sound/items/tools/ratchet.ogg', 60, TRUE) + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/bounty_pyro_reload/finish_action(datum/ai_controller/controller, succeeded) + . = ..() + controller.clear_blackboard_key(BB_BOUNTY_BOSS_RELOAD_UNTIL) + if(!succeeded) + // A change that got nowhere: it fights on with what it has for a while + controller.set_blackboard_key(BB_HUMAN_NPC_ARMING_RETRY_AT, world.time + 10 SECONDS) /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss_gear_text() 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. +// Out where the air kills: an atmospherics MODsuit, fireproof like its fire suit, its gas mask on under the helmet. 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) + return list(/obj/item/mod/control/pre_equipped/bounty_boss/atmospheric) + +// A molotov goes over anything a thrown bottle gets past (a table, a railing, a gap), never through glass or a door +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss_goes_through(atom/barrier) + return ..() || boss_throw_passes(barrier) + +// With a molotov ready +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss_breaks_through_now(atom/barrier) + return ..() || (boss_throw_passes(barrier) && !isnull(boss_ability_off_cooldown(/datum/action/cooldown/mob_cooldown/bounty_boss/molotov))) + +// Shot from past its flamer's reach, the smoke goes before anything else (C9) +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss_choose_ability(atom/target) + var/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/ability = boss_ability_off_cooldown(/datum/action/cooldown/mob_cooldown/bounty_boss/smoke) + if(ability && !QDELETED(target) && ability.IsAvailable() && ability.worth_using(target)) + return ability + return ..() + +// Its smoke has its own line +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss_bark(suffix, fallback) + if(suffix == "ability" && istype(boss_winding(), /datum/action/cooldown/mob_cooldown/bounty_boss/smoke)) + return ..("smoke", "ability") + return ..() + +/// The flamethrower it holds, or null +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/proc/boss_flamethrower() + return locate(/obj/item/flamethrower) in held_items + +/// Whether `flamer` has the igniter and the plasma for a sweep +/proc/bounty_pyro_flamer_fuelled(obj/item/flamethrower/flamer) + if(QDELETED(flamer) || !flamer.igniter || !flamer.status || QDELETED(flamer.ptank)) + return FALSE + var/datum/gas_mixture/tank_air = flamer.ptank.return_air() + return tank_air?.return_pressure() >= BOUNTY_PYROMANIAC_FLAMER_EMPTY + +/// The molotov it carries, in hand or in its bag, or null +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/proc/boss_molotov() + for(var/obj/item/reagent_containers/cup/glass/bottle/molotov/bottle in get_all_contents_type(/obj/item/reagent_containers/cup/glass/bottle/molotov)) + if(is_holding(bottle) || human_npc_can_draw(src, bottle)) + return bottle + return null -// 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. +/// Whether it has a hand for a grenade: one free, or its bottle can go back in its bag +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/proc/boss_hand_for_grenade() + if(length(get_empty_held_indexes())) + return TRUE + var/obj/item/bottle = locate(/obj/item/reagent_containers/cup/glass/bottle/molotov) in held_items + return !isnull(bottle) && !!back?.atom_storage?.can_insert(bottle, src, messages = FALSE) + +/// A smoke grenade it carries with the pin still in, in hand or where it can draw it from +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/proc/boss_smoke_grenade() + // One already in hand first (kept from a wind-up it was stunned out of): a pocket one would need a free hand + for(var/obj/item/grenade/smokebomb/grenade in held_items) + if(!grenade.active) + return grenade + for(var/obj/item/grenade/smokebomb/grenade in get_all_contents_type(/obj/item/grenade/smokebomb)) + if(!grenade.active && (is_holding(grenade) || human_npc_can_draw(src, grenade))) + return grenade + return null + +/** + * The Pyromaniac's answer to stun fire (C8): it goes for whoever is shooting it, until its flamer + * reaches them (combat sense's close-in), throwing smoke, a molotov or sweeping the flamer the moment one + * is ready (the boss rules let a ready ability go first). Keep your distance and keep moving. + * + * Out of its sight (in its own smoke, or round a corner) it makes for where the shots last came from, + * not for where the shooter is now (C9): tg's targeting drops whoever it can't see, so this is how it + * comes through the cloud. There it looks again; if they moved, it is the hunt's to find them. + */ +/datum/npc_combat_sense/bounty/boss/pyromaniac + react_to_stun_fire = TRUE + close_in_reach = BOUNTY_PYROMANIAC_FLAMER_RANGE + +// It closes until its flamer reaches, not to arm's length +/datum/npc_combat_sense/bounty/boss/pyromaniac/reach(mob/living/carbon/human/npc, datum/ai_controller/controller) + return BOUNTY_PYROMANIAC_FLAMER_RANGE + +// Whoever is shooting it becomes who it goes for, if it may go after them +/datum/npc_combat_sense/bounty/boss/pyromaniac/plan_close_in(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = npc + var/atom/shooter = sense.threat() + if(istype(boss) && shooter) + var/atom/aim = boss.boss_target_for(shooter) + if(aim != controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] && boss.boss_valid_target(aim)) + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, aim) + if(!can_see(npc, shooter, HUMAN_NPC_SIGHT_RANGE)) + var/turf/spot = sense.threat_turf(npc) + if(isnull(spot) || get_dist(npc, spot) <= 1 || !tile_ok(npc, controller, spot)) + return + sense.charged_at = world.time + sense.decided_at = world.time + controller.set_blackboard_key(BB_HUMAN_NPC_STUN_SHOOTER, spot) + controller.queue_behavior(/datum/ai_behavior/human_npc_close_in, BB_HUMAN_NPC_STUN_SHOOTER, 1) + return SUBTREE_RETURN_FINISH_PLANNING + return ..() + +// The firefighter suit and helmet are what keep its own fire off it (tg's thermal protection, CB-7); the gas +// mask keeps smoke out of its lungs. The flamethrower doesn't holster, so it is in hand from the start, the +// bottle in the other. A smoke grenade in each pocket (C9). /datum/outfit/bounty_boss/pyromaniac name = "Bounty mini-boss: Pyromaniac" uniform = /obj/item/clothing/under/color/black suit = /obj/item/clothing/suit/utility/fire/firefighter head = /obj/item/clothing/head/utility/hardhat/red + mask = /obj/item/clothing/mask/gas gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/workboots - r_hand = BOUNTY_PYROMANIAC_TORCH + r_hand = BOUNTY_PYROMANIAC_FLAMETHROWER + l_hand = BOUNTY_PYROMANIAC_MOLOTOV_BOTTLE + l_pocket = BOUNTY_PYROMANIAC_SMOKE + r_pocket = BOUNTY_PYROMANIAC_SMOKE + id = /obj/item/card/id + +// Its ID carries its name, so with its face behind the mask it still goes by it (tg's own naming). No +// access and no account; a rename (the bounty record's name) follows it onto the card. +/datum/outfit/bounty_boss/pyromaniac/post_equip(mob/living/carbon/human/user, visuals_only = FALSE) + . = ..() + var/obj/item/card/id/card = user.wear_id + if(istype(card)) + card.registered_name = user.real_name + card.update_label() + +/// The Pyromaniac's flamethrower: tg's, built and fuelled. It is a kit item, so lighting it is no news for admins. +/obj/item/flamethrower/full/tank/bounty_boss + warned_admins = TRUE + +/// The Pyromaniac's bottle: tg's molotov, filled with welding fuel +/obj/item/reagent_containers/cup/glass/bottle/molotov/bounty_boss + list_reagents = list(/datum/reagent/fuel = 50) /** - * Flamer: the pilot light hisses and an orange cone shows on the floor, then a jet of fire sweeps - * 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. + * Flamer: it lights its flamethrower and an orange line shows on the floor, then a jet of fire hoses the + * line: BOUNTY_PYROMANIAC_FLAMER_DAMAGE burn and tg's fire stacks on whoever it catches, and the floor + * burns on for BOUNTY_PYROMANIAC_FLAMER_FLOOR (the boss fire, not loose plasma). Each sweep spends a + * share of the tank (boss_spend_flamer_fuel()); with it dry it doesn't sweep until it has changed tanks. + * It shuts the valve after each sweep. */ /datum/action/cooldown/mob_cooldown/bounty_boss/flamer name = "Flamer" - desc = "Sweep a cone of fire in front of you." + desc = "Sweep a line of fire in front of you." cooldown_time = BOUNTY_PYROMANIAC_FLAMER_COOLDOWN windup = BOUNTY_PYROMANIAC_FLAMER_WINDUP - /// The tiles it will cover, from the telegraph - var/list/cone + /// The tiles it will hose, from the telegraph + var/list/fire_line /datum/action/cooldown/mob_cooldown/bounty_boss/flamer/Destroy() - cone = null + fire_line = null return ..() /datum/action/cooldown/mob_cooldown/bounty_boss/flamer/worth_using(atom/target) - return aimable(target) && get_dist(owner, target) <= BOUNTY_PYROMANIAC_FLAMER_RANGE && can_see(owner, target, BOUNTY_PYROMANIAC_FLAMER_RANGE) && landing_ok(target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss = owner + if(!istype(boss) || !aimable(target) || !bounty_pyro_flamer_fuelled(boss.boss_flamethrower())) + return FALSE + return get_dist(owner, target) <= BOUNTY_PYROMANIAC_FLAMER_RANGE && can_see(owner, target, BOUNTY_PYROMANIAC_FLAMER_RANGE) && landing_ok(target) && !human_npc_ally_in_line(boss, target) && length(line_turfs(target)) -/datum/action/cooldown/mob_cooldown/bounty_boss/flamer/telegraph(atom/target) +/** + * The line its fire runs from it to `target`: as far as a flamethrower's flame gets (it stops where air + * can't pass, a wall, a window or a shut door) and as far as its fire may reach: never off its site or + * into a ship (M2) + */ +/datum/action/cooldown/mob_cooldown/bounty_boss/flamer/proc/line_turfs(atom/target) + . = list() 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)) - if(boss.boss_reach_ok(spot)) - cone += spot - owner.visible_message(span_boldwarning("[owner] opens the valve on [owner.p_their()] flamer. The pilot light hisses.")) + var/turf/start = get_turf(owner) + var/turf/aim = get_turf(target) + if(!istype(boss) || !start || !aim) + return + var/turf/previous = start + for(var/turf/spot as anything in get_line(start, aim)) + if(spot == start) + continue + if(!isopenturf(previous) || !(spot in previous.get_atmos_adjacent_turfs(alldir = TRUE)) || !boss.boss_reach_ok(spot)) + break + . += spot + previous = spot + +/datum/action/cooldown/mob_cooldown/bounty_boss/flamer/telegraph(atom/target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss = owner + var/list/line = line_turfs(target) + fire_line = line + var/obj/item/flamethrower/flamer = boss.boss_flamethrower() + if(flamer && human_npc_ready_item(boss, flamer) && !flamer.lit) + flamer.attack_self(boss) + owner.visible_message(span_boldwarning("[owner] opens the valve on [owner.p_their()] flamethrower. The pilot light hisses.")) playsound(owner, 'sound/effects/spray.ogg', 50, TRUE) - mark_turfs(cone, "#ff8a1f") + mark_turfs(line, "#ff8a1f") + +/datum/action/cooldown/mob_cooldown/bounty_boss/flamer/cancel_windup() + fire_line = null + shut_valve() + return ..() /datum/action/cooldown/mob_cooldown/bounty_boss/flamer/effect(atom/target) - var/list/fire_turfs = cone - cone = null - if(!length(fire_turfs)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss = owner + var/list/fire_turfs = fire_line + fire_line = null + var/obj/item/flamethrower/flamer = boss?.boss_flamethrower() + if(!length(fire_turfs) || !flamer?.lit || !bounty_pyro_flamer_fuelled(flamer) || !human_npc_ready_item(boss, flamer)) + shut_valve() return - owner.visible_message(span_danger("[owner] sweeps a jet of fire across the floor!")) + owner.visible_message(span_danger("[owner] hoses 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, BOUNTY_PYROMANIAC_FLAMER_STACKS) + boss.boss_spend_flamer_fuel(flamer) + addtimer(CALLBACK(src, PROC_REF(shut_valve)), BOUNTY_PYROMANIAC_FLAMER_SHUTOFF, TIMER_DELETE_ME) + +/// Puts its flamethrower out, if it is lit and done firing +/datum/action/cooldown/mob_cooldown/bounty_boss/flamer/proc/shut_valve() + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss = owner + if(!istype(boss) || QDELETED(boss)) + return + var/obj/item/flamethrower/flamer = boss.boss_flamethrower() + if(flamer?.lit && !flamer.operating) + flamer.toggle_igniter(boss) /** * Molotov: it lights the rag on a bottle and a ring shows where it will land, then it throws. The @@ -395,10 +737,16 @@ if(!aimable(target)) return FALSE var/distance = get_dist(owner, target) - return distance >= 2 && distance <= BOUNTY_PYROMANIAC_MOLOTOV_RANGE && can_see(owner, target, BOUNTY_PYROMANIAC_MOLOTOV_RANGE) && landing_ok(target) + return distance >= 2 && distance <= BOUNTY_PYROMANIAC_MOLOTOV_RANGE && can_see(owner, target, BOUNTY_PYROMANIAC_MOLOTOV_RANGE) && landing_ok(target) && throw_reaches(target) /datum/action/cooldown/mob_cooldown/bounty_boss/molotov/telegraph(atom/target) landing = get_turf(target) + // Its bottle back in hand, if the smoke put it away + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = owner + if(istype(pyro)) + var/obj/item/bottle = pyro.boss_molotov() + if(bottle) + human_npc_take_in_hand(pyro, bottle) owner.visible_message(span_boldwarning("[owner] lights the rag on a bottle and takes aim!")) playsound(owner, 'sound/items/match_strike.ogg', 60, TRUE) // The ring stays until the bottle lands (L3). @@ -417,7 +765,8 @@ /datum/action/cooldown/mob_cooldown/bounty_boss/molotov/effect(atom/target) var/turf/spot = landing landing = null - if(!spot) + // Glass or a door shut across the way during the wind-up: it holds the bottle. + if(!spot || !throw_reaches(spot)) return owner.visible_message(span_danger("[owner] throws a flaming bottle!")) playsound(owner, 'sound/items/weapons/fwoosh.ogg', 40, TRUE) @@ -431,6 +780,98 @@ 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, BOUNTY_PYROMANIAC_MOLOTOV_STACKS) +/** + * Smoke: it takes out a real smoke grenade it carries, then pulls the pin and throws it halfway to + * whoever shot it from past its flamer's reach (C9). The fuse and the cloud are tg's own: the cloud + * blinds everyone, weakens beams that cross it and makes anyone breathing it without internals cough and + * drop what they hold. Downed during the wind-up, the pin stays in and nothing happens (the grenade is + * kept for later). Two grenades, two clouds: then it has none left. + */ +/datum/action/cooldown/mob_cooldown/bounty_boss/smoke + name = "Smoke Grenade" + desc = "Throw a smoke grenade between you and whoever is shooting at you." + cooldown_time = BOUNTY_PYROMANIAC_SMOKE_COOLDOWN + windup = BOUNTY_PYROMANIAC_SMOKE_WINDUP + /// Where it will land, from the telegraph + var/turf/landing + +/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/Destroy() + landing = null + return ..() + +// Someone it can see past its flamer's reach who has just shot it, with a grenade and a hand for it +/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/worth_using(atom/target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss = owner + if(!aimable(target) || !istype(boss) || !boss.boss_valid_target(target)) + return FALSE + var/obj/item/grenade/smokebomb/grenade = boss.boss_smoke_grenade() + if(isnull(grenade) || (!boss.is_holding(grenade) && !boss.boss_hand_for_grenade())) + return FALSE + var/distance = get_dist(owner, target) + if(distance <= BOUNTY_PYROMANIAC_FLAMER_RANGE || distance > BOUNTY_PYROMANIAC_SMOKE_RANGE || !can_see(owner, target, BOUNTY_PYROMANIAC_SMOKE_RANGE) || !throw_reaches(target)) + return FALSE + var/datum/component/npc_combat_sense/sense = boss.GetComponent(/datum/component/npc_combat_sense) + var/shot = sense?.under_fire() && boss.boss_target_for(sense.threat()) == target + if(!shot && (world.time > boss.boss_last_attacked_at + BOUNTY_PYROMANIAC_SMOKE_HURT_WINDOW || boss.boss_last_attacker?.resolve() != target)) + return FALSE + return !isnull(find_spot(target)) + +/** + * Where it throws: halfway to `target` and at least two tiles out, short of anything in the way, on + * ground it may aim at. That rule keeps ships, hangars and outposts more than the cloud's reach away (M2). + */ +/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/proc/find_spot(atom/target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + var/turf/here = get_turf(owner) + var/turf/there = get_turf(target) + if(!istype(boss) || !here || !there) + return null + var/turf/spot = here + for(var/i in 1 to max(2, floor(get_dist(here, there) / 2))) + var/turf/next = get_step_towards(spot, there) + if(isnull(next) || next == there || next.is_blocked_turf(exclude_mobs = TRUE)) + break + spot = next + if(spot == here || !boss.boss_landing_ok(spot) || !boss.boss_throw_reaches(here, spot)) + return null + return spot + +/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/telegraph(atom/target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss = owner + landing = find_spot(target) + var/obj/item/grenade/smokebomb/grenade = boss.boss_smoke_grenade() + if(isnull(grenade)) + return + // Both hands full: the bottle goes back in its bag for the grenade + if(!boss.is_holding(grenade) && !length(boss.get_empty_held_indexes())) + var/obj/item/bottle = locate(/obj/item/reagent_containers/cup/glass/bottle/molotov) in boss.held_items + if(bottle) + boss.back?.atom_storage?.attempt_insert(bottle, boss, messages = FALSE) + if(!human_npc_take_in_hand(boss, grenade) || !human_npc_ready_item(boss, grenade)) + return + owner.visible_message(span_boldwarning("[owner] pulls out a smoke grenade!")) + if(landing) + mark_turfs(list(landing), "#d8d8d8", "target_circle", /obj/effect/temp_visual/bounty_boss_thrown::duration) + +/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/effect(atom/target) + var/turf/spot = landing || get_turf(target) + landing = null + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + var/obj/item/grenade/smokebomb/grenade = locate() in boss.held_items + // Glass or a door shut across the way during the wind-up: the pin stays in. + if(isnull(grenade) || grenade.active || !spot || !throw_reaches(spot) || !human_npc_ready_item(boss, grenade)) + return + // The player's way: pull the pin in hand, then throw it. From here the fuse is the grenade's own. + 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) + +/// The Pyromaniac's smoke grenades: tg's smoke grenade, its fuse turned down to 3 seconds +/obj/item/grenade/smokebomb/bounty_boss + det_time = BOUNTY_PYROMANIAC_SMOKE_FUSE + /// Something thrown, flying from where it starts to `destination` /obj/effect/temp_visual/bounty_boss_thrown icon = 'icons/obj/weapons/grenade.dmi' @@ -459,15 +900,57 @@ /datum/action/cooldown/mob_cooldown/bounty_boss/breach, ) +/** + * Its rebooter (C8): tg's CNS rebooter, a real implant in its head, one neural load beside any chrome it + * rolled (a Demolitionist rolls at most Cascade and Lazarus, 17 of the body's 20). It is no chrome, so the + * chrome roll doesn't count it and it doesn't burn out when it dies. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/Initialize(mapload, datum/human_npc_order/order) + . = ..() + if(QDELETED(src)) + return + var/obj/item/organ/implant = new BOUNTY_DEMOLITIONIST_REBOOTER() + if(!implant.Insert(src, special = TRUE)) + qdel(implant) + RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_STUNIMMUNE), PROC_REF(boss_rebooted)) + /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/carbon/human/npc/bounty_criminal/boss/demolitionist/boss_gear_text() - return "A bandolier of grenades is slung across [p_their()] chest." + . = "A bandolier of grenades is slung across [p_their()] chest." + if(boss_rebooter()) + . += " A steel port glints at the base of [p_their()] skull." + +/// Its CNS rebooter, if it is still in its head +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/proc/boss_rebooter() + return locate(BOUNTY_DEMOLITIONIST_REBOOTER) in organs + +/// Its rebooter just fired (the implant's own stun immunity went on): everyone sees it get up +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/proc/boss_rebooted(datum/source) + SIGNAL_HANDLER + var/obj/item/organ/implant = boss_rebooter() + if(isnull(implant) || stat == DEAD || !HAS_TRAIT_FROM(src, TRAIT_STUNIMMUNE, REF(implant))) + return + visible_message(span_warning("[src] jerks back to [p_their()] feet, sparks spitting from the back of [p_their()] neck!")) -// Out where the air kills: a plain grey space suit over its work clothes +// Out where the air kills: an engineering MODsuit over its work clothes, as tough as its hard hat /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) + return list(/obj/item/mod/control/pre_equipped/bounty_boss/engineering) +// A grenade goes over anything a thrown grenade gets past (a table, a railing, a gap), and a breaching charge through an interior wall or door +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/boss_goes_through(atom/barrier) + if(..() || boss_throw_passes(barrier)) + return TRUE + return (iswallturf(barrier) || istype(barrier, /obj/machinery/door)) && boss_may_break(barrier) + +// With a grenade ready for anything a thrown grenade gets past, or a breaching charge for an interior wall or door +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/boss_breaks_through_now(atom/barrier) + if(..()) + return TRUE + if(boss_throw_passes(barrier) && boss_ability_off_cooldown(/datum/action/cooldown/mob_cooldown/bounty_boss/grenade)) + return TRUE + return (iswallturf(barrier) || istype(barrier, /obj/machinery/door)) && boss_may_break(barrier) \ + && !isnull(boss_ability_off_cooldown(/datum/action/cooldown/mob_cooldown/bounty_boss/breach)) /** * It keeps BOUNTY_DEMOLITIONIST_KEEP_MIN to _MAX tiles from its target while it has something it @@ -498,9 +981,9 @@ 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 - // A grenade needs the target in sight; its range is checked by the band itself. A breach only when one is possible now. + // A grenade needs the target in sight and a throw that lands on them; its range is checked by the band itself. A breach only when one is possible now. if(istype(ability, /datum/action/cooldown/mob_cooldown/bounty_boss/grenade)) - if(can_see(src, target, get_dist(src, target))) + if(can_see(src, target, get_dist(src, target)) && boss_throw_reaches(get_turf(src), get_turf(target))) return TRUE continue if(ability.worth_using(target)) @@ -542,7 +1025,7 @@ if(!aimable(target)) return FALSE var/distance = get_dist(owner, target) - return distance >= 2 && distance <= BOUNTY_DEMOLITIONIST_GRENADE_RANGE && can_see(owner, target, BOUNTY_DEMOLITIONIST_GRENADE_RANGE) && landing_ok(target) + return distance >= 2 && distance <= BOUNTY_DEMOLITIONIST_GRENADE_RANGE && can_see(owner, target, BOUNTY_DEMOLITIONIST_GRENADE_RANGE) && landing_ok(target) && throw_reaches(target) /datum/action/cooldown/mob_cooldown/bounty_boss/grenade/telegraph(atom/target) landing = get_turf(target) @@ -562,7 +1045,7 @@ 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)) + if(other != spot && !isclosedturf(other) && boss.boss_reach_ok(other) && boss.boss_throw_reaches(get_turf(owner), other)) near += other if(length(near)) addtimer(CALLBACK(src, PROC_REF(throw_grenade), pick(near)), 0.5 SECONDS, TIMER_DELETE_ME) @@ -571,7 +1054,8 @@ /datum/action/cooldown/mob_cooldown/bounty_boss/grenade/proc/throw_grenade(turf/spot) 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) + // Nor with glass or a door shut across the way since it aimed: it holds the grenade. + if(!istype(boss) || !boss.boss_can_act() || !spot || !throw_reaches(spot)) return boss.visible_message(span_danger("[boss] throws a grenade!")) new /obj/effect/temp_visual/bounty_boss_thrown(get_turf(boss), spot) @@ -789,6 +1273,7 @@ name = "hooded criminal" desc = "A lean criminal in a dark hooded cloak, a knife at the ready." boss_kit = BOUNTY_KIT_GHOST + npc_combat_sense = /datum/npc_combat_sense/bounty/boss/ghost // 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( @@ -817,9 +1302,21 @@ /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 +// Out where the air kills: a civilian MODsuit, hardly more armour than its hood and no slower /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) + return list(/obj/item/mod/control/pre_equipped/bounty_boss/civilian) + +/** + * The Ghost's answer to stun fire (C8): from beyond its dash, it breaks the shooter's line, running a few + * steps for cover (combat sense's cover, Slipwire dodging as it goes), and keeps down a moment, longer + * while winded; from cover it comes again with its dash once someone is in reach (the boss rules let a + * ready ability go first). Corner it. + */ +/datum/npc_combat_sense/bounty/boss/ghost + react_to_stun_fire = TRUE + close_in_reach = 0 + cover_steps = BOUNTY_GHOST_COVER_STEPS + cover_moves = BOUNTY_GHOST_COVER_MOVES // 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 @@ -1035,7 +1532,7 @@ /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." + desc = "A big criminal in an ablative coat, carrying a belt-fed gun." boss_kit = BOUNTY_KIT_HEAVY boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/burst, @@ -1046,19 +1543,39 @@ return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/heavy)) /mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss_gear_text() + if(istype(wear_suit, BOUNTY_HEAVY_COAT)) + return "[p_Their()] coat and hood are lined with reflective panels." 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 +// Out where the air kills: a magnate MODsuit (its coat and hood hold no pressure), with the coat's energy armour but no reflection /mob/living/carbon/human/npc/bounty_criminal/boss/heavy/bounty_sealed_gear() - return list(/obj/item/clothing/suit/space/syndicate/black, null) + return list(/obj/item/mod/control/pre_equipped/bounty_boss/magnate) +// Its rounds chip through a window or grille it may break, and fly over a gap +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss_goes_through(atom/barrier) + if(..()) + return TRUE + if(isturf(barrier)) + return !barrier.density + return (istype(barrier, /obj/structure/window) || istype(barrier, /obj/structure/grille)) && boss_may_break(barrier) + +// With its burst ready and a belt in its gun +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss_breaks_through_now(atom/barrier) + if(..()) + return TRUE + var/obj/item/gun/gun = boss_gun() + if(!gun?.can_shoot() || isnull(boss_ability_off_cooldown(/datum/action/cooldown/mob_cooldown/bounty_boss/burst))) + return FALSE + if(isturf(barrier)) + return !barrier.density + return (istype(barrier, /obj/structure/window) || istype(barrier, /obj/structure/grille)) && boss_may_break(barrier) // 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. +// A spare box rides in the bag; a barrier grenade in each pocket. The coat's hood goes up as it is put on +// (tg's hooded suits do that), so its own reflecting hood covers its head (C8). /datum/outfit/bounty_boss/heavy name = "Bounty mini-boss: Heavy" uniform = /obj/item/clothing/under/syndicate/combat - suit = /obj/item/clothing/suit/armor/swat - head = /obj/item/clothing/head/helmet/swat + suit = BOUNTY_HEAVY_COAT gloves = /obj/item/clothing/gloves/combat shoes = /obj/item/clothing/shoes/jackboots r_hand = BOUNTY_HEAVY_GUN diff --git a/voidcrew/modules/bounties/bounty_chrome.dm b/voidcrew/modules/bounties/bounty_chrome.dm new file mode 100644 index 00000000000..faf8dc603f3 --- /dev/null +++ b/voidcrew/modules/bounties/bounty_chrome.dm @@ -0,0 +1,1450 @@ +/** + * # Bounty hunting: chrome + * + * Owner: C0 chrome core. The pieces (C1-C4, voidcrew/modules/bounties/chrome/) and the cyberpsycho (C6) + * build on this file; the seams are listed in the port's SEAMS notes and in the doc comments below. + * + * Some criminals and their companions carry cyberware: the real implants players buy at a ripperdoc + * (voidcrew/modules/cyberware/), installed in their real body through the human NPC base's + * npc_cyberware (owner decision 5). Nothing here stands in for an implant. A Gorilla Arms carrier + * punches with the implant's own empowered punch, a Lazarus node jolts its bearer up by itself, an EMP + * reboots the chrome on its real timer, a brownout browns it out, and it all burns out to scrap when the + * NPC dies (the human NPC base, owner ruling). + * + * What this file adds, all of it AI or looks: + * - Who carries what (/datum/bounty_chrome_piece, GLOB.bounty_chrome_pieces): a roll when the record is + * made, by tier (bounty_chrome_roll()), and a rarer one for companions (bounty_chrome_roll_companion()). + * A roll never puts two implants in one organ slot and never goes over the body's capacity, kit chrome + * included, so nothing browns out. + * - The body (bounty_chrome_prepare(), bounty_chrome_equip()): the record's pieces become npc_cyberware + * before the base installs it, and carriers dress light enough that their worn chrome shows + * (bounty_chrome_expose_outfit()). A pressure suit or modsuit stays shut over it. + * - How the AI uses it (/datum/bounty_chrome_move, /datum/component/bounty_chrome): a tell everyone can + * see and hear, at least BOUNTY_CHROME_TELL_MIN long, then the implant's own action, Trigger()ed the + * way a player's click does. Downed, stunned, cuffed, killed or EMP'd during the tell, nothing fires. + * An area move never starts while someone outside the fight stands where it would land + * (bounty_chrome_area_clear()). Mini-bosses use their moves through their own ability rotation + * (/datum/action/cooldown/mob_cooldown/bounty_boss/chrome). + * - An EMP that knocks chrome out shows it: sparks, arcs and a flicker, as a picture only + * (bounty_chrome_malfunction_fx()). + * - A bounty NPC feels a chrome read and tells the reader off (COMSIG_CARBON_CHROME_READ). + */ + +// ===== THE PIECES ===== + +/// Every piece by key (BOUNTY_CHROME_*): built from the subtypes, so a piece needs no registry edit +GLOBAL_LIST_INIT(bounty_chrome_pieces, init_bounty_chrome_pieces()) + +/proc/init_bounty_chrome_pieces() + var/list/pieces = list() + for(var/datum/bounty_chrome_piece/piece_type as anything in subtypesof(/datum/bounty_chrome_piece)) + if(!initial(piece_type.key)) + continue + var/datum/bounty_chrome_piece/piece = new piece_type + pieces[piece.key] = piece + // The moves each piece drives: every /datum/bounty_chrome_move subtype names its piece by key + for(var/datum/bounty_chrome_move/move_type as anything in subtypesof(/datum/bounty_chrome_move)) + var/datum/bounty_chrome_piece/piece = pieces[initial(move_type.piece_key)] + piece?.move_types += move_type + return pieces + +/** + * The chrome a mini-boss kit (BOUNTY_KIT_*) already carries in its body, as organ typepaths: what a roll + * must fit around. It has to match the kit's own npc_cyberware (bounty_boss_kits.dm); a test spawns + * each kit and checks. + */ +/proc/bounty_chrome_kit_organs(kit) + switch(kit) + if(BOUNTY_KIT_GHOST) + return list(/obj/item/organ/cyberimp/cyberware/slipwire, /obj/item/organ/cyberimp/cyberware/cascade) + if(BOUNTY_KIT_CYBERPSYCHO) + return bounty_psycho_organs() + return list() + +/** + * One piece of chrome a criminal can carry: which real implants it is, and who can roll it. One + * subtype per key, below. The moves that drive it in a fight are /datum/bounty_chrome_move subtypes that + * name it by key (C1-C4), collected into move_types at start. + */ +/datum/bounty_chrome_piece + /// BOUNTY_CHROME_*; the subtype with no key is abstract + var/key + /// What admins see it called + var/name = "chrome" + /// Roll weight among the pieces that suit. 0 never rolls and isn't offered to admins. + var/weight = 10 + /// Lowest tier that rolls it (BOUNTY_TIER_*); a companion is checked against its criminal's tier + var/min_tier = BOUNTY_TIER_PETTY + /// The criminal archetypes that roll it (BOUNTY_ARCHETYPE_*). Never the meek: they run. + var/list/archetypes = list(BOUNTY_ARCHETYPE_NORMAL, BOUNTY_ARCHETYPE_BOSS) + /// Whether a companion can roll it + var/companion = TRUE + /// The fighting styles (BOUNTY_STYLE_*) that roll it, or null for any. Mini-bosses have no style. + var/list/styles + /// Only for styles that shoot (bounty_chrome_style_shoots()) + var/shooter = FALSE + /// The mini-boss kits (BOUNTY_KIT_*) that roll it, or null for any kit + var/list/kits + /// Keys it never rolls alongside (a design choice; organ slots are checked on their own) + var/list/exclusive_with + /// The real implant organs it is, as typepaths + var/list/organs + /// The /datum/bounty_chrome_move types that drive it, filled at start + var/list/move_types = list() + +/// Whether a new `archetype` fighter of `tier`, with `style` or `kit` and the keys `picked` so far, may roll it +/datum/bounty_chrome_piece/proc/can_roll(tier, archetype, style, kit, list/picked) + if(weight <= 0 || !tier || tier < min_tier) + return FALSE + if(archetype == BOUNTY_CHROME_COMPANION) + if(!companion) + return FALSE + else if(!(archetype in archetypes)) + return FALSE + if(archetype == BOUNTY_ARCHETYPE_BOSS) + if(kits && !(kit in kits)) + return FALSE + else + if(styles && !(style in styles)) + return FALSE + if(shooter && !bounty_chrome_style_shoots(style)) + return FALSE + for(var/other in picked) + if(other in exclusive_with) + return FALSE + var/datum/bounty_chrome_piece/other_piece = GLOB.bounty_chrome_pieces[other] + if(key in other_piece?.exclusive_with) + return FALSE + return TRUE + +/// A melee style this piece fights with when it has to change someone's style (an admin's pick), or null if any style will do +/datum/bounty_chrome_piece/proc/fitting_style(style) + if(!styles || (style in styles)) + return null + return styles[1] + +/// Whether fighting style `style` (BOUNTY_STYLE_*) shoots a gun +/proc/bounty_chrome_style_shoots(style) + var/datum/bounty_style/fighting_style = GLOB.bounty_styles[style] + return !!fighting_style?.ranged && ispath(fighting_style.weapon_type, /obj/item/gun) + +/datum/bounty_chrome_piece/cascade + key = BOUNTY_CHROME_CASCADE + name = "Cascade lattice" + // A legend piece: rare, and only on the dangerous + weight = 6 + min_tier = BOUNTY_TIER_WANTED + // The Ghost carries its own; the Heavy's whole fight is being slow and flanked + kits = list(BOUNTY_KIT_JUGGERNAUT, BOUNTY_KIT_PYROMANIAC, BOUNTY_KIT_DEMOLITIONIST) + organs = list(/obj/item/organ/cyberimp/cyberware/cascade) + +/datum/bounty_chrome_piece/redline + key = BOUNTY_CHROME_REDLINE + name = "Redline core" + weight = 6 + min_tier = BOUNTY_TIER_WANTED + // Not on the Juggernaut's riot plates or the Heavy's armour + kits = list(BOUNTY_KIT_PYROMANIAC, BOUNTY_KIT_DEMOLITIONIST, BOUNTY_KIT_GHOST) + organs = list(/obj/item/organ/cyberimp/cyberware/redline) + +/datum/bounty_chrome_piece/piledriver + key = BOUNTY_CHROME_PILEDRIVER + name = "Meteor Piledriver" + // The rarest: Wanted or worse, never a companion + weight = 4 + min_tier = BOUNTY_TIER_WANTED + companion = FALSE + // Of the mini-bosses only the Pyromaniac: the others already charge, dash or fight from range + kits = list(BOUNTY_KIT_PYROMANIAC) + // Two gap-closers that knock people down would be one too many + exclusive_with = list(BOUNTY_CHROME_MANTIS) + organs = list(/obj/item/organ/cyberimp/cyberware/piledriver) + +/datum/bounty_chrome_piece/gorilla + key = BOUNTY_CHROME_GORILLA + name = "Gorilla Arms" + weight = 12 + // The implant powers a bare-handed punch: brawlers only. Never a mini-boss: the Juggernaut's shield fills a hand, so its grab never fires + styles = list(BOUNTY_STYLE_BRAWLER) + archetypes = list(BOUNTY_ARCHETYPE_NORMAL) + organs = list( + /obj/item/organ/cyberimp/cyberware/gorilla_arms, + /obj/item/organ/cyberimp/cyberware/gorilla_arms/left, + ) + +/datum/bounty_chrome_piece/mantis + key = BOUNTY_CHROME_MANTIS + name = "Mantis Blades" + weight = 10 + // Fighters who close in. Never a mini-boss: the Juggernaut's charge and the Ghost's dash already close the gap. + archetypes = list(BOUNTY_ARCHETYPE_NORMAL) + styles = list(BOUNTY_STYLE_BRAWLER, BOUNTY_STYLE_KNIFE, BOUNTY_STYLE_CLUB) + exclusive_with = list(BOUNTY_CHROME_PILEDRIVER) + organs = list( + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left, + ) + +/datum/bounty_chrome_piece/lazarus + key = BOUNTY_CHROME_LAZARUS + name = "Lazarus node" + // A second round in one fight is a lot. Never a companion: putting one down has to stay the answer to every companion. + weight = 8 + min_tier = BOUNTY_TIER_WANTED + companion = FALSE + organs = list(/obj/item/organ/cyberimp/cyberware/lazarus) + +/datum/bounty_chrome_piece/deadeye + key = BOUNTY_CHROME_DEADEYE + name = "Deadeye link" + weight = 12 + // It walks rounds onto a mark: only for those who shoot + archetypes = list(BOUNTY_ARCHETYPE_NORMAL) + shooter = TRUE + organs = list(/obj/item/organ/eyes/robotic/cyberware/deadeye) + +// ===== WHAT AN IMPLANT TAKES ===== + +/// Organ type -> list("slot", "zone", "load", "bonus", "shows"), read off the type once +GLOBAL_LIST_EMPTY(bounty_chrome_organ_facts) + +/** + * What an organ type takes in a body, read off the type (no copy is made, so it works at any time): + * its organ slot and zone, the neural load and capacity bonus it brings (cyberware_component.dm), and + * whether it shows on the body as worn chrome (an aug_overlay). + */ +/proc/bounty_chrome_organ_facts(organ_type) + var/list/facts = GLOB.bounty_chrome_organ_facts[organ_type] + if(facts) + return facts + if(!ispath(organ_type, /obj/item/organ)) + return null + var/obj/item/organ/organ = organ_type + var/load = 0 + var/bonus = 0 + var/shows = FALSE + if(ispath(organ_type, /obj/item/organ/cyberimp/cyberware)) + var/obj/item/organ/cyberimp/cyberware/ware = organ_type + load = initial(ware.chrome_load) + bonus = initial(ware.chrome_capacity_bonus) + else if(ispath(organ_type, /obj/item/organ/cyberimp/arm/toolkit/cyberware)) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = organ_type + load = initial(arm_ware.chrome_load) + bonus = initial(arm_ware.chrome_capacity_bonus) + else if(ispath(organ_type, /obj/item/organ/eyes/robotic/cyberware)) + var/obj/item/organ/eyes/robotic/cyberware/optics = organ_type + load = initial(optics.chrome_load) + bonus = initial(optics.chrome_capacity_bonus) + else if(ispath(organ_type, /obj/item/organ/cyberimp) || (initial(organ.organ_flags) & ORGAN_ROBOTIC)) + // Robotic hardware that isn't chrome costs the body's flat rate (get_installed_capacity_cost()) + load = GLOB.installed_capacity_costs["robotic_organ"] + if(ispath(organ_type, /obj/item/organ/cyberimp)) + var/obj/item/organ/cyberimp/implant = organ_type + shows = !!initial(implant.aug_overlay) + facts = list("slot" = initial(organ.slot), "zone" = initial(organ.zone), "load" = load, "bonus" = bonus, "shows" = shows) + GLOB.bounty_chrome_organ_facts[organ_type] = facts + return facts + +/// Whether the organ types `organ_types` can all be in one body at once: one per organ slot, and no more load than the body's capacity (CYBERWARE_BASE_CAPACITY plus any Governor), so nothing browns out +/proc/bounty_chrome_organs_fit(list/organ_types) + var/list/slots = list() + var/load = 0 + var/capacity = CYBERWARE_BASE_CAPACITY + for(var/organ_type in organ_types) + var/list/facts = bounty_chrome_organ_facts(organ_type) + if(!facts) + return FALSE + var/slot = facts["slot"] + if(slot) + if(slots[slot]) + return FALSE + slots[slot] = TRUE + load += facts["load"] + capacity += facts["bonus"] + return load <= capacity + +/// The organ typepaths of the pieces `keys`, in order +/proc/bounty_chrome_organ_types(list/keys) + . = list() + for(var/key in keys) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + if(piece) + . += piece.organs + +/** + * The keys of `keys` that go in together on top of `existing_organs` (typepaths already bound for the + * body: a kit's own chrome), in order: a piece that would share an organ slot or take the body over its + * capacity is left out, and so is an unknown key or one listed twice. + */ +/proc/bounty_chrome_fit_keys(list/keys, list/existing_organs) + . = list() + var/list/organs = existing_organs ? existing_organs.Copy() : list() + for(var/key in keys) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + if(!piece || (key in .)) + continue + if(!bounty_chrome_organs_fit(organs + piece.organs)) + continue + organs += piece.organs + . += key + +// ===== ROLLING ===== + +/// Percent chance a criminal of `tier` carries chrome +/proc/bounty_chrome_tier_chance(tier) + switch(tier) + if(BOUNTY_TIER_MOST_WANTED) + return BOUNTY_CHROME_CHANCE_MOST_WANTED + if(BOUNTY_TIER_WANTED) + return BOUNTY_CHROME_CHANCE_WANTED + return BOUNTY_CHROME_CHANCE_PETTY + +/** + * The chrome keys a new criminal carries, or null for none: a roll by tier, then one piece (two, now and + * then, from Wanted up), weighted among the pieces that suit its archetype, style and kit and that fit in + * its body on top of `existing_organs` (its kit's own chrome, bounty_chrome_kit_organs()). The meek + * never carry any. Doesn't sleep. + */ +/proc/bounty_chrome_roll(tier, archetype, style, kit, list/existing_organs) + if(archetype != BOUNTY_ARCHETYPE_NORMAL && archetype != BOUNTY_ARCHETYPE_BOSS) + return null + if(!prob(bounty_chrome_tier_chance(tier))) + return null + var/count = (tier >= BOUNTY_TIER_WANTED && prob(BOUNTY_CHROME_SECOND_CHANCE)) ? 2 : 1 + return bounty_chrome_pick(count, tier, archetype, style, kit, existing_organs) + +/** + * The chrome a new companion of a `tier` criminal carries as a list of one key, or null: rarer than its + * criminal's, one piece at most, never Lazarus or the Piledriver. `style` is the companion's own. + * Companions call this as they are dressed (C4); see bounty_chrome_prepare_body(). + */ +/proc/bounty_chrome_roll_companion(tier, style) + if(!prob(bounty_chrome_tier_chance(tier) / BOUNTY_CHROME_COMPANION_DIVISOR)) + return null + return bounty_chrome_pick(1, tier, BOUNTY_CHROME_COMPANION, style, null, null) + +/// Up to `count` different keys, weighted, among the pieces that suit and fit together on top of `existing_organs`. Null if none do. +/proc/bounty_chrome_pick(count, tier, archetype, style, kit, list/existing_organs) + var/list/picked = list() + var/list/organs = existing_organs ? existing_organs.Copy() : list() + for(var/i in 1 to count) + var/list/weights = list() + for(var/key in GLOB.bounty_chrome_pieces) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + if((key in picked) || !piece.can_roll(tier, archetype, style, kit, picked)) + continue + if(!bounty_chrome_organs_fit(organs + piece.organs)) + continue + weights[key] = piece.weight + if(!length(weights)) + break + var/key = pick_weight(weights) + picked += key + var/datum/bounty_chrome_piece/chosen = GLOB.bounty_chrome_pieces[key] + organs += chosen.organs + return length(picked) ? picked : null + +/** + * The most pieces that fit in one body on top of `existing_organs`, whatever they would normally roll + * for, for the Bounty Panel's "All of it": the largest set, then the one with the most chrome in it. The + * cyberpsycho (C6) replaces this choice with its own kit. + */ +/proc/bounty_chrome_all_that_fits(list/existing_organs) + var/list/keys = list() + for(var/key in GLOB.bounty_chrome_pieces) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + if(piece.weight > 0) + keys += key + var/list/best = list() + var/best_load = -1 + var/combinations = 1 << length(keys) + for(var/mask in 1 to combinations - 1) + var/list/chosen = list() + for(var/i in 1 to length(keys)) + if(mask & (1 << (i - 1))) + chosen += keys[i] + if(length(chosen) < length(best)) + continue + var/list/organs = (existing_organs ? existing_organs.Copy() : list()) + bounty_chrome_organ_types(chosen) + if(!bounty_chrome_organs_fit(organs)) + continue + var/load = 0 + for(var/organ_type in bounty_chrome_organ_types(chosen)) + var/list/facts = bounty_chrome_organ_facts(organ_type) + load += facts["load"] + if(length(chosen) > length(best) || load > best_load) + best = chosen + best_load = load + return best + +/** + * Puts a normal criminal's record on a style its chrome fights with, for chrome it was given rather + * than rolled (an admin's pick): Gorilla Arms and Mantis Blades never come with a gun or a bottle. Rolled + * chrome already suits its style. Returns TRUE if the style changed. + */ +/proc/bounty_chrome_fit_style(datum/bounty_record/record) + if(!record || record.archetype != BOUNTY_ARCHETYPE_NORMAL) + return FALSE + for(var/key in record.chrome) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + var/new_style = piece?.fitting_style(record.style) + if(new_style) + record.style = new_style + return TRUE + return FALSE + +// ===== THE BODY ===== + +/// Whether `npc` is a bounty human whose record's chrome goes in its body: a normal criminal or a mini-boss. Never the meek, a decoy (it copies its fugitive's organs, body_match()) or the kingpin. +/proc/bounty_chrome_carrier(mob/living/carbon/human/npc/npc) + return istype(npc, /mob/living/carbon/human/npc/bounty_criminal/normal) || istype(npc, /mob/living/carbon/human/npc/bounty_criminal/boss) + +/** + * Before `npc`'s body is built: the organs of the pieces `keys` that fit on top of what it already + * carries go into its npc_cyberware, which the human NPC base installs once it is dressed (so its outfit + * can be cut to show them, bounty_chrome_expose_outfit()). Returns the keys that went in. + */ +/proc/bounty_chrome_prepare_body(mob/living/carbon/human/npc/npc, list/keys) + if(!ishumannpc(npc) || !length(keys)) + return list() + var/list/existing = npc.npc_cyberware ? npc.npc_cyberware.Copy() : list() + var/list/fitted = bounty_chrome_fit_keys(keys, existing) + if(length(fitted)) + npc.npc_cyberware = existing + bounty_chrome_organ_types(fitted) + return fitted + +/** + * A criminal's Initialize(), before the body is built: its record's chrome becomes npc_cyberware. What + * doesn't fit (an admin's pick that clashes with a kit's chrome) comes off the record, so the record + * stays the truth about the criminal. + */ +/proc/bounty_chrome_prepare(mob/living/carbon/human/npc/bounty_criminal/criminal) + if(!bounty_chrome_carrier(criminal) || !length(criminal.record?.chrome)) + return + var/list/fitted = bounty_chrome_prepare_body(criminal, criminal.record.chrome) + criminal.record.chrome = length(fitted) ? fitted : null + +/// A criminal's Initialize(), once its body is built: its chrome is watched for EMPs, and a carrier gets its moves +/proc/bounty_chrome_ready(mob/living/carbon/human/npc/bounty_criminal/criminal) + // Every criminal, decoys included: a decoy carries its fugitive's chrome and must spark the same way + criminal.AddElement(/datum/element/bounty_chrome_body) + if(bounty_chrome_carrier(criminal) && length(criminal.record?.chrome)) + bounty_chrome_equip(criminal, criminal.record.chrome) + +/** + * Once the chrome `keys` are in `npc`'s body: the AI side of it (the component and the moves of each + * piece), the EMP look, and for a mini-boss one ability in its rotation per move. Adds to chrome it + * has. Returns the component, or null for no keys. + */ +/proc/bounty_chrome_equip(mob/living/carbon/human/npc/npc, list/keys) + if(!ishumannpc(npc) || QDELETED(npc) || !length(keys)) + return null + npc.AddElement(/datum/element/bounty_chrome_body) + return npc.AddComponent(/datum/component/bounty_chrome, keys) + +/** + * Installs the pieces `keys` in `npc`'s live body now, real organs through the base's + * npc_install_cyberware(), as many as fit with what it already has in it, then equips them. For tests and + * admins with a body already built; a spawn goes through bounty_chrome_prepare_body(). Returns the keys + * that went in. + */ +/proc/bounty_chrome_install_now(mob/living/carbon/human/npc/npc, list/keys) + . = list() + if(!ishumannpc(npc) || QDELETED(npc)) + return + var/list/installed = list() + for(var/obj/item/organ/organ in npc.organs) + if(organ.GetComponent(/datum/component/cyberware)) + installed += organ.type + for(var/key in bounty_chrome_fit_keys(keys, installed)) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + for(var/organ_type in piece.organs) + npc.npc_install_cyberware(organ_type) + . += key + if(length(.)) + bounty_chrome_equip(npc, .) + +// A criminal or companion built with chrome that takes the place of an organ it was born with (a Deadeye +// link its eyes): the old organ goes, as tg's own regenerate_organs() does it, instead of the base's Insert() +// dropping it at its feet, a pair of loose eyes on the floor. Decoys copying their fugitive's chrome +// (body_match()) come through here too. +/mob/living/carbon/human/npc/bounty_criminal/npc_install_cyberware(ware_type) + bounty_chrome_clear_natural_slot(src, ware_type) + return ..() + +/mob/living/carbon/human/npc/bounty_companion/npc_install_cyberware(ware_type) + bounty_chrome_clear_natural_slot(src, ware_type) + return ..() + +/// Takes out and deletes the organ (never chrome) in the slot chrome of `ware_type` is about to fill in `npc` +/proc/bounty_chrome_clear_natural_slot(mob/living/carbon/human/npc/npc, ware_type) + var/list/facts = bounty_chrome_organ_facts(ware_type) + var/slot = facts?["slot"] + if(!slot) + return + var/obj/item/organ/born_with = npc.get_organ_slot(slot) + if(!born_with || born_with.GetComponent(/datum/component/cyberware)) + return + born_with.Remove(npc, special = TRUE) + qdel(born_with) + +// ===== DRESSED TO SHOW IT ===== + +/// Where the worn chrome in `organ_types` shows on a body: list("arms", "chest", "legs") of TRUE/FALSE, or null if it shows nowhere +/proc/bounty_chrome_shows(list/organ_types) + var/arms = FALSE + var/chest = FALSE + var/legs = FALSE + for(var/organ_type in organ_types) + var/list/facts = bounty_chrome_organ_facts(organ_type) + if(!facts?["shows"]) + continue + switch(facts["zone"]) + if(BODY_ZONE_R_ARM, BODY_ZONE_L_ARM) + arms = TRUE + if(BODY_ZONE_CHEST) + chest = TRUE + if(BODY_ZONE_R_LEG, BODY_ZONE_L_LEG) + legs = TRUE + if(!arms && !chest && !legs) + return null + return list("arms" = arms, "chest" = chest, "legs" = legs) + +/// Whether its clothes are cut to show the chrome it carries (bounty_chrome_expose_outfit(), from the bounty outfit table): yes, but for a mini-boss, whose kit is its look. The cyberpsycho (C6) may say yes. +/mob/living/carbon/human/npc/proc/bounty_dresses_to_show_chrome() + return !istype(src, /mob/living/carbon/human/npc/bounty_criminal/boss) + +/** + * `outfit` (a typepath or an instance) cut so the worn chrome in `organ_types` shows, as an instance + * (an instance passed in is changed in place). Worn chrome draws over the jumpsuit and under everything + * else (CYBERWARE_WORN_LAYER), so the jumpsuit stays and only what covers it goes: no coat over chest or + * arm chrome, no gloves over arm chrome. Armour stays on: a vest is the tier's toughness. A pressure suit + * or a modsuit stays shut, and so does everything under it. Chrome that doesn't show changes nothing. The + * site's layers (a space suit, cold-weather wear) go on afterwards, over it, as they would on anyone. + */ +/proc/bounty_chrome_expose_outfit(outfit, list/organ_types) + var/list/shows = bounty_chrome_shows(organ_types) + if(!shows) + return outfit + var/datum/outfit/dressed = ispath(outfit, /datum/outfit) ? new outfit() : outfit + if(!istype(dressed)) + return outfit + var/obj/item/clothing/suit = dressed.suit + if((ispath(suit, /obj/item/clothing) && (initial(suit.clothing_flags) & STOPSPRESSUREDAMAGE)) || ispath(dressed.back, /obj/item/mod/control)) + return dressed + var/arms = shows["arms"] + var/chest = shows["chest"] + if((arms || chest) && dressed.suit && !ispath(dressed.suit, /obj/item/clothing/suit/armor)) + // What the coat carried goes in the bag; with no bag the coat stays, it holds their gun + if(dressed.suit_store && dressed.back) + LAZYADDASSOC(dressed.backpack_contents, dressed.suit_store, 1) + dressed.suit_store = null + if(!dressed.suit_store) + dressed.suit = null + if(arms) + dressed.gloves = null + return dressed + +/** + * Bares the worn chrome in `npc`'s live body, as bounty_chrome_expose_outfit() does for an outfit: the + * coat and gloves over it come off. What comes off is deleted (it was locked gear, D3). A pressure suit + * or a modsuit stays shut. For a fugitive whose act drops (bounty_outpost.dm). + * Returns TRUE if anything came off. Doesn't sleep. + */ +/proc/bounty_chrome_bare(mob/living/carbon/human/npc/npc) + if(!ishumannpc(npc) || QDELETED(npc)) + return FALSE + var/list/installed = list() + for(var/obj/item/organ/organ in npc.organs) + if(organ.GetComponent(/datum/component/cyberware)) + installed += organ.type + var/list/shows = bounty_chrome_shows(installed) + if(!shows) + return FALSE + var/obj/item/clothing/suit = npc.wear_suit + if((istype(suit) && (suit.clothing_flags & STOPSPRESSUREDAMAGE)) || istype(npc.back, /obj/item/mod/control)) + return FALSE + var/arms = shows["arms"] + var/chest = shows["chest"] + var/coat_name + . = FALSE + if((arms || chest) && suit && !istype(suit, /obj/item/clothing/suit/armor) && !npc.s_store) + coat_name = "[suit.name]" + npc.temporarilyRemoveItemFromInventory(suit, force = TRUE) + qdel(suit) + . = TRUE + if(arms && npc.gloves) + var/obj/item/hand_wear = npc.gloves + npc.temporarilyRemoveItemFromInventory(hand_wear, force = TRUE) + qdel(hand_wear) + . = TRUE + if(coat_name) + npc.visible_message(span_warning("[npc] shrugs off the [coat_name].")) + +// ===== IN A FIGHT ===== + +/** + * Whether `npc` can use its chrome now: awake, on its feet and on a turf, out of crit, not cuffed, + * stunned or knocked down, not giving up, not hiding or passing as a patron, and not driven by a + * player. All read from tg. + */ +/proc/bounty_chrome_can_act(mob/living/carbon/human/npc/npc) + if(!ishumannpc(npc) || QDELETED(npc) || npc.stat != CONSCIOUS || !isturf(npc.loc) || npc.client) + return FALSE + if(HAS_TRAIT(npc, TRAIT_CRITICAL_CONDITION) || HAS_TRAIT(npc, TRAIT_RESTRAINED) || HAS_TRAIT(npc, TRAIT_INCAPACITATED) || HAS_TRAIT(npc, TRAIT_FLOORED)) + return FALSE + if(npc.npc_surrendering) + return FALSE + var/mob/living/carbon/human/npc/bounty_criminal/criminal = npc + if(istype(criminal) && (criminal.hidden || criminal.blended)) + return FALSE + return TRUE + +/// Whether `npc` is in a fight, by its AI's mode: a criminal fighting, a companion in it, a mini-boss turned hostile. Its state (stuns and the like) is bounty_chrome_can_act()'s. +/proc/bounty_chrome_in_fight(mob/living/carbon/human/npc/npc) + if(QDELETED(npc) || npc.stat == DEAD) + return FALSE + if(istype(npc, /mob/living/carbon/human/npc/bounty_criminal/boss)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = npc + return boss.boss_hostile + if(istype(npc, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = npc + return criminal.ai_mode == BOUNTY_AI_FIGHTING + if(istype(npc, /mob/living/carbon/human/npc/bounty_companion)) + var/mob/living/carbon/human/npc/bounty_companion/companion = npc + return companion.ai_in_fight + return FALSE + +/// Who `npc` is going for now (a person, or a mech), or null +/proc/bounty_chrome_target(mob/living/carbon/human/npc/npc) + var/datum/ai_controller/controller = npc?.ai_controller + if(QDELETED(controller)) + return null + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] || controller.blackboard[BB_BOUNTY_BOSS_PREY] + return QDELETED(target) ? null : target + +/** + * The first action of `action_type` on chrome in `npc` (its implants' own buttons), preferring one + * that can be used now, or null. + */ +/proc/bounty_chrome_action(mob/living/carbon/human/npc/npc, action_type) + if(!ispath(action_type, /datum/action) || QDELETED(npc)) + return null + var/datum/action/found + for(var/obj/item/organ/organ in npc.organs) + if(!organ.GetComponent(/datum/component/cyberware)) + continue + for(var/datum/action/action as anything in organ.actions) + if(!istype(action, action_type) || action.owner != npc) + continue + if(action.IsAvailable()) + return action + found ||= action + return found + +/** + * Fires `npc`'s implant action of `action_type` the way a player's click does: Trigger(), aimed at + * `target` for an action that is clicked onto something. Only an action that can be used now. Returns + * TRUE if it fired. + */ +/proc/bounty_chrome_trigger(mob/living/carbon/human/npc/npc, action_type, atom/target) + var/datum/action/action = bounty_chrome_action(npc, action_type) + if(!action || !action.IsAvailable()) + return FALSE + var/datum/action/cooldown/cooldown_action = action + if(istype(cooldown_action) && cooldown_action.click_to_activate) + if(QDELETED(target)) + return FALSE + return !!action.Trigger(target = target) + return !!action.Trigger() + +// ===== WHO AN AREA MOVE MAY CATCH ===== + +/** + * Whether `person` is in `npc`'s fight, so an area move may catch them: the one it is going for or + * `aimed` at, or a hunter after it. That is someone its side holds a grudge against (they attacked, + * confronted or cuffed it or a companion), in a mini-boss's posse, or crewing a ship hunting its + * bounty. Its own side never is, and nor is anyone else on the site. + */ +/proc/bounty_chrome_in_posse(mob/living/carbon/human/npc/npc, mob/living/person, atom/aimed) + if(QDELETED(npc) || !isliving(person) || person == npc || bounty_ai_same_gang(npc, person)) + return FALSE + for(var/atom/target in list(bounty_chrome_target(npc), aimed)) + if(target == person || (ismecha(target) && person.loc == target)) + return TRUE + var/mob/living/carbon/human/npc/bounty_criminal/side = bounty_ai_side_of(npc) + if(QDELETED(side)) + return FALSE + if(side.body_has_grudge(person)) + return TRUE + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = side + if(istype(boss) && boss.boss_engaged[REF(person)]) + return TRUE + if(!person.mind) + return FALSE + var/datum/criminal_bounty/posting = side.posting() + for(var/obj/structure/overmap/ship/ship as anything in posting?.hunter_ships()) + if(person.mind in ship.ship_team?.members) + return TRUE + // A crewmate of anyone in the fight is in it too: a crew can't keep the area moves off by standing an idle friend beside the shooter + for(var/atom/target in list(bounty_chrome_target(npc), aimed)) + if(bounty_chrome_crewmates(person, target)) + return TRUE + for(var/datum/weakref/enemy_ref as anything in side.grudge) + if(bounty_chrome_crewmates(person, enemy_ref?.resolve())) + return TRUE + return FALSE + +/// Whether `person` and `other` (a person, or a mech with one in it) crew the same ship +/proc/bounty_chrome_crewmates(mob/living/person, atom/other) + var/mob/living/other_person = ismecha(other) ? bounty_ai_pilot_of(other) : other + if(!isliving(other_person) || other_person == person || !LAZYLEN(person?.mind?.ship_teams) || !LAZYLEN(other_person.mind?.ship_teams)) + return FALSE + for(var/datum/team/voidcrew/crew as anything in person.mind.ship_teams) + if(crew in other_person.mind.ship_teams) + return TRUE + return FALSE + +/** + * Whether `npc` may start an area move over `turfs` (owner decision 5): nobody stands there who is + * outside its fight. Its own side and the site's people count as outside it (it doesn't land on its + * friends); the dead and creatures with nobody behind them (site fauna) don't count. The implant itself + * is never changed: once it fires it hits whoever is there, as it would for a player. + */ +/proc/bounty_chrome_area_clear(mob/living/carbon/human/npc/npc, list/turfs, atom/aimed, ignore_faction = FALSE) + if(QDELETED(npc)) + return FALSE + for(var/turf/spot as anything in turfs) + if(!isturf(spot)) + continue + for(var/mob/living/person in spot) + if(person == npc || person.stat == DEAD) + continue + // A move that spares its own side (the Redline roar) doesn't wait on its own companions + if(ignore_faction && bounty_ai_same_gang(npc, person)) + continue + if(!bounty_chrome_in_posse(npc, person, aimed) && bounty_chrome_counts_as_bystander(npc, person)) + return FALSE + for(var/obj/vehicle/sealed/mecha/mech in spot) + for(var/mob/living/pilot in mech.occupants) + if(!bounty_chrome_in_posse(npc, pilot, aimed) && bounty_chrome_counts_as_bystander(npc, pilot)) + return FALSE + return TRUE + +/// Whether `person`, not in `npc`'s fight, keeps an area move from starting: anyone with a player behind them, any person, and anyone on its side. Not a creature with nobody behind it. +/proc/bounty_chrome_counts_as_bystander(mob/living/carbon/human/npc/npc, mob/living/person) + if(person.mind || person.client || ishuman(person)) + return TRUE + return bounty_ai_same_gang(npc, person) || npc.faction_check_atom(person) + +// ===== MOVES ===== + +/** + * # A chrome move + * + * One thing an NPC's AI does with one piece of chrome: a tell, then the implant's own action. C1-C4 + * subtype it, one subtype per move, naming the piece by `piece_key`; nothing else registers it. Each + * NPC carrying the piece gets its own instance (/datum/component/bounty_chrome), so cooldowns are its + * own. + * + * How a normal criminal or a companion uses one (the bounty_chrome planning subtree): while it is in a + * fight and can act, plan() first (a move that queues behaviours of its own, a grab, returns TRUE), then + * a move whose can_start() passes starts: it stands still (tell_holds_still), its AI goes quiet, and + * tell() shows the outline, plays the sound and says the line. After tell_time (never under + * BOUNTY_CHROME_TELL_MIN) fire() runs effect(), which Trigger()s the implant's action. Downed, stunned, + * knocked down, cuffed, EMP'd or killed during the tell: cancel() and nothing fires. A mini-boss runs the + * same tell() and effect() through its ability rotation instead. + * + * The hooks below are called for every move of the NPC, in a fight or not. None may sleep. + */ +/datum/bounty_chrome_move + /// The BOUNTY_CHROME_* key of the piece this move drives; null for an abstract type + var/piece_key + /// What it is called (admins, the mini-boss's ability) + var/name = "chrome" + /// The implant action it fires (a /datum/action subtype on the piece's organs), or null for a move that fires nothing by itself + var/action_type + /// How long its tell lasts. Never under BOUNTY_CHROME_TELL_MIN. + var/tell_time = BOUNTY_CHROME_TELL_MIN + /// It stands still through the tell (TRAIT_IMMOBILIZED, as a mini-boss winding up does) + var/tell_holds_still = TRUE + /// Its AI carries on through the tell (drawing, shooting, moving) instead of going quiet: a tell that is only a look, a gunman's Deadeye lock. Interrupts still cut it short. + var/tell_keeps_acting = FALSE + /// The outline it glows with through the tell + var/tell_color = BOUNTY_CHROME_TELL_COLOR + /// The sound at the start of the tell + var/tell_sound = 'sound/effects/seedling_chargeup.ogg' + /// Lines it may say as the tell starts (short, in character), or null + var/list/tell_lines + /// It catches everyone in an area: it never starts while someone outside the fight stands in area_turfs() + var/area_move = FALSE + /// Furthest a target may be for it to start, in tiles + var/max_range = BOUNTY_FIGHT_VISION + /// Nearest a target may be for it to start, in tiles + var/min_range = 0 + /// How long after it fires before the NPC starts another chrome move (at least BOUNTY_CHROME_MOVE_GAP) + var/recover_time = BOUNTY_CHROME_MOVE_GAP + /// A mini-boss gets it as an ability in its rotation (a tell-then-fire move); a move that only plans behaviours sets FALSE + var/boss_usable = TRUE + /// The NPC it is in + var/mob/living/carbon/human/npc/owner + /// The mini-boss ability wrapping it, if its owner is a mini-boss + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/boss_ability + /// world.time it last fired, 0 if never + var/last_fired = 0 + /// Weakrefs to the marks it put down for its tell, removed when the tell ends + var/list/marks + +/datum/bounty_chrome_move/Destroy() + clear_tell() + if(boss_ability) + boss_ability.move = null + boss_ability = null + owner = null + return ..() + +/// Goes into `npc`. Subtypes register what they need here; call parent first. +/datum/bounty_chrome_move/proc/attach(mob/living/carbon/human/npc/npc) + owner = npc + +/// Comes out of its NPC, which may be being deleted. Undo what attach() and the fight did; call parent last. +/datum/bounty_chrome_move/proc/detach() + clear_tell() + owner = null + +/// Whether its implant can be used now: the action is there, its chrome running and off cooldown (an action-less move is always ready) +/datum/bounty_chrome_move/proc/ready() + if(!action_type) + return TRUE + var/datum/action/action = bounty_chrome_action(owner, action_type) + return !!action?.IsAvailable() + +/** + * Whether it should start on `target` now: its owner can act, the target is someone it may hit, in + * sight and in range, the implant is ready, and for an area move nobody outside the fight stands where + * it lands. Subtypes add their own reasons and call parent. + */ +/datum/bounty_chrome_move/proc/can_start(atom/target) + if(!bounty_chrome_can_act(owner) || QDELETED(target) || !bounty_ai_may_hit(owner, target)) + return FALSE + var/distance = bounty_ai_dist(owner, target) + if(distance > max_range || distance < min_range || !bounty_ai_can_see(owner, target, max_range)) + return FALSE + if(!ready()) + return FALSE + if(area_move && !area_clear(target)) + return FALSE + return TRUE + +/// Whether nobody outside the fight stands where it would land on `target` (the bystander gate). A move whose implant spares its own side overrides it. +/datum/bounty_chrome_move/proc/area_clear(atom/target) + return bounty_chrome_area_clear(owner, area_turfs(target), target) + +/// The turfs it would catch if it fired on `target` now, for the bystander gate. Area moves override it. +/datum/bounty_chrome_move/proc/area_turfs(atom/target) + return list() + +/// What its action is clicked on (a click-to-activate action): `target`, or for a leap the turf to land on +/datum/bounty_chrome_move/proc/trigger_target(atom/target) + return target + +/** + * The tell on `target`: an outline on its owner, the sound, a line. Subtypes add marks (add_mark()) and + * call parent. Doesn't sleep. + */ +/datum/bounty_chrome_move/proc/tell(atom/target) + if(QDELETED(owner)) + return + owner.add_filter(tell_filter(), 2, outline_filter(1, tell_color)) + var/outline = owner.get_filter(tell_filter()) + if(outline) + // A pulse, faint to full: the colour's own alpha, as filters have no alpha of their own + animate(outline, color = "[tell_color]40", time = 0.15 SECONDS, loop = -1) + animate(color = "[tell_color]ff", time = 0.15 SECONDS) + if(tell_sound) + playsound(owner, tell_sound, 60, TRUE) + var/text = tell_text(target) + if(text) + owner.visible_message(span_danger(text)) + if(length(tell_lines)) + INVOKE_ASYNC(src, PROC_REF(say_line), pick(tell_lines)) + +/// What onlookers see as the tell starts, or null. Plain, in the world: "[owner]'s spine lights up." +/datum/bounty_chrome_move/proc/tell_text(atom/target) + return null + +/// Its owner says `line`. Sleeps (say()). +/datum/bounty_chrome_move/proc/say_line(line) + if(!QDELETED(owner) && owner.stat == CONSCIOUS) + owner.say(line, forced = "bounty chrome tell") + +/// The outline's filter name, its own per move +/datum/bounty_chrome_move/proc/tell_filter() + return "bounty_chrome_tell_[REF(src)]" + +/// Keeps `thing` (a mark on the floor) until the tell ends +/datum/bounty_chrome_move/proc/add_mark(datum/thing) + if(thing) + LAZYADD(marks, WEAKREF(thing)) + return thing + +/// Ends the tell's look: the outline and the marks go +/datum/bounty_chrome_move/proc/clear_tell() + if(!QDELETED(owner)) + owner.remove_filter(tell_filter()) + for(var/datum/weakref/mark_ref as anything in marks) + var/datum/thing = mark_ref.resolve() + if(!QDELETED(thing)) + qdel(thing) + marks = null + +/// The tell is over: it fires on `target` (which may be gone by now). Returns what effect() does. +/datum/bounty_chrome_move/proc/fire(atom/target) + last_fired = world.time + return effect(target) + +/// What it does once the tell is over: by default, Trigger() the implant's action. Returns TRUE if it did something. +/datum/bounty_chrome_move/proc/effect(atom/target) + if(!action_type) + return FALSE + return bounty_chrome_trigger(owner, action_type, trigger_target(target)) + +/// The tell was cut short (BOUNTY_CHROME_CANCEL_*): nothing fires. The look is already gone. +/datum/bounty_chrome_move/proc/cancel(reason) + return + +/// For a move that drives behaviours itself (a grab, blades out): queue them on `controller` and return TRUE to end the planning. Called every planning tick in a fight, before any move starts. +/datum/bounty_chrome_move/proc/plan(datum/ai_controller/controller, atom/target) + return FALSE + +/// A fight starts against `target` +/datum/bounty_chrome_move/proc/on_fight_start(atom/target) + return + +/// The fight is over +/datum/bounty_chrome_move/proc/on_fight_end() + return + +/// Every Life tick of its owner (none while it is dormant); `fighting` is bounty_chrome_in_fight(), `target` who it is going for +/datum/bounty_chrome_move/proc/on_tick(seconds_per_tick, fighting, atom/target) + return + +/// Its owner went down into crit +/datum/bounty_chrome_move/proc/on_downed() + return + +/// Its owner died: end anything running +/datum/bounty_chrome_move/proc/on_death() + return + +/// An EMP of `severity` reached its owner (the implant reboots on its own timer) +/datum/bounty_chrome_move/proc/on_emp(severity) + return + +// ===== AN NPC'S CHROME, IN A FIGHT ===== + +/** + * A bounty NPC's chrome moves, and the one tell it may have going. Added by bounty_chrome_equip(); adding + * it again adds the new keys' moves. The tell is held to tg's state through signals: crit, a stun, a + * knockdown, cuffs, death or an EMP cuts it short. + */ +/datum/component/bounty_chrome + dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS + /// The piece keys it carries, in order + var/list/keys = list() + /// Its moves (/datum/bounty_chrome_move), one per move type of each piece + var/list/moves = list() + /// The move whose tell is running, or null + var/datum/bounty_chrome_move/telling + /// Weakref to what that tell is aimed at + var/datum/weakref/tell_target + /// Goes up with each tell, so a stale timer does nothing + var/tell_serial = 0 + var/tell_timer + /// In a fight at the last look (bounty_chrome_in_fight()), for the fight's start and end + var/fighting = FALSE + /// world.time its next chrome move may start + var/next_move_at = 0 + +/datum/component/bounty_chrome/Initialize(list/new_keys) + if(!ishumannpc(parent)) + return COMPONENT_INCOMPATIBLE + add_keys(new_keys) + +/datum/component/bounty_chrome/InheritComponent(datum/component/new_comp, i_am_original, list/new_keys) + add_keys(new_keys) + +/datum/component/bounty_chrome/Destroy(force) + end_tell() + for(var/datum/bounty_chrome_move/move as anything in moves) + move.detach() + qdel(move) + moves.Cut() + tell_target = null + return ..() + +/datum/component/bounty_chrome/RegisterWithParent() + RegisterSignal(parent, COMSIG_LIVING_LIFE, PROC_REF(on_life)) + RegisterSignal(parent, COMSIG_HUMAN_NPC_DOWNED, PROC_REF(on_downed)) + RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(on_death)) + RegisterSignal(parent, COMSIG_ATOM_EMP_ACT, PROC_REF(on_emp)) + RegisterSignals(parent, list(SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), SIGNAL_ADDTRAIT(TRAIT_FLOORED)), PROC_REF(on_stunned)) + RegisterSignal(parent, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), PROC_REF(on_restrained)) + +/datum/component/bounty_chrome/UnregisterFromParent() + UnregisterSignal(parent, list( + COMSIG_LIVING_LIFE, + COMSIG_HUMAN_NPC_DOWNED, + COMSIG_LIVING_DEATH, + COMSIG_ATOM_EMP_ACT, + SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), + SIGNAL_ADDTRAIT(TRAIT_FLOORED), + SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), + )) + +/// Adds the moves of the pieces `new_keys` it doesn't have yet; a mini-boss gets each as an ability in its rotation +/datum/component/bounty_chrome/proc/add_keys(list/new_keys) + var/mob/living/carbon/human/npc/npc = parent + for(var/key in new_keys) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + if(!piece || (key in keys)) + continue + keys += key + for(var/move_type in piece.move_types) + var/datum/bounty_chrome_move/move = new move_type + moves += move + move.attach(npc) + bounty_chrome_grant_boss_ability(npc, move) + +/// Its move of `move_type`, or null +/datum/component/bounty_chrome/proc/move_of(move_type) + for(var/datum/bounty_chrome_move/move as anything in moves) + if(istype(move, move_type)) + return move + return null + +/// Notes the fight starting or ending, and tells the moves +/datum/component/bounty_chrome/proc/update_fight() + var/now = bounty_chrome_in_fight(parent) + if(now == fighting) + return + fighting = now + if(now) + next_move_at = max(next_move_at, world.time + BOUNTY_CHROME_OPENING) + var/atom/target = bounty_chrome_target(parent) + for(var/datum/bounty_chrome_move/move as anything in moves) + move.on_fight_start(target) + return + interrupt(BOUNTY_CHROME_CANCEL_GONE) + for(var/datum/bounty_chrome_move/move as anything in moves) + move.on_fight_end() + +/** + * The bounty_chrome planning subtree's work: nothing else is planned while a tell runs (unless the move + * keeps acting through it, tell_keeps_acting, when only no other move starts); in a fight, a + * move that plans its own behaviours goes first, then, past the gap since the last one, a move that can + * start does. Returns the subtree's result. Doesn't sleep. + */ +/datum/component/bounty_chrome/proc/plan(datum/ai_controller/controller, seconds_per_tick) + if(telling) + return telling.tell_keeps_acting ? null : SUBTREE_RETURN_FINISH_PLANNING + update_fight() + if(!fighting || !bounty_chrome_can_act(parent)) + return + var/atom/target = bounty_chrome_target(parent) + if(QDELETED(target)) + return + for(var/datum/bounty_chrome_move/move as anything in moves) + if(move.plan(controller, target)) + return SUBTREE_RETURN_FINISH_PLANNING + if(world.time < next_move_at) + return + var/list/ready = list() + for(var/datum/bounty_chrome_move/move as anything in moves) + if(move.action_type && move.can_start(target)) + ready += move + if(length(ready) && start_move(pick(ready), target)) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * Starts `move`'s tell on `target`: it stands still with its AI quiet, and after the tell the move + * fires, unless something cuts it short. Returns TRUE if the tell started. + */ +/datum/component/bounty_chrome/proc/start_move(datum/bounty_chrome_move/move, atom/target) + var/mob/living/carbon/human/npc/npc = parent + if(telling || !(move in moves) || !bounty_chrome_can_act(npc)) + return FALSE + tell_serial++ + telling = move + tell_target = target ? WEAKREF(target) : null + if(move.tell_holds_still) + ADD_TRAIT(npc, TRAIT_IMMOBILIZED, BOUNTY_CHROME_TRAIT) + if(!move.tell_keeps_acting) + npc.ai_controller?.CancelActions() + if(target) + npc.face_atom(target) + move.tell(target) + tell_timer = addtimer(CALLBACK(src, PROC_REF(finish_tell), tell_serial), max(move.tell_time, BOUNTY_CHROME_TELL_MIN), TIMER_STOPPABLE | TIMER_DELETE_ME) + return TRUE + +/// The tell under `serial` is over: the move fires, if its owner can still act +/datum/component/bounty_chrome/proc/finish_tell(serial) + if(serial != tell_serial || !telling) + return FALSE + var/datum/bounty_chrome_move/move = telling + var/atom/target = tell_target?.resolve() + tell_timer = null + end_tell() + if(!bounty_chrome_can_act(parent)) + move.cancel(BOUNTY_CHROME_CANCEL_STUNNED) + return FALSE + next_move_at = world.time + max(move.recover_time, BOUNTY_CHROME_MOVE_GAP) + move.fire(target) + return TRUE + +/// Ends the running tell's hold and look, without firing or cancelling it +/datum/component/bounty_chrome/proc/end_tell() + var/datum/bounty_chrome_move/move = telling + telling = null + tell_target = null + if(tell_timer) + deltimer(tell_timer) + tell_timer = null + if(!QDELETED(parent)) + REMOVE_TRAIT(parent, TRAIT_IMMOBILIZED, BOUNTY_CHROME_TRAIT) + move?.clear_tell() + +/// Cuts the running tell short for `reason` (BOUNTY_CHROME_CANCEL_*): nothing fires. A mini-boss's chrome wind-up is cut short too. +/datum/component/bounty_chrome/proc/interrupt(reason) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = parent + if(istype(boss) && istype(boss.boss_winding(), /datum/action/cooldown/mob_cooldown/bounty_boss/chrome)) + boss.boss_interrupt() + var/datum/bounty_chrome_move/move = telling + if(!move) + return FALSE + end_tell() + move.cancel(reason) + return TRUE + +/datum/component/bounty_chrome/proc/on_life(datum/source, seconds_per_tick, times_fired) + SIGNAL_HANDLER + update_fight() + var/atom/target = fighting ? bounty_chrome_target(parent) : null + for(var/datum/bounty_chrome_move/move as anything in moves) + move.on_tick(seconds_per_tick, fighting, target) + +/datum/component/bounty_chrome/proc/on_downed(datum/source) + SIGNAL_HANDLER + interrupt(BOUNTY_CHROME_CANCEL_DOWNED) + for(var/datum/bounty_chrome_move/move as anything in moves) + move.on_downed() + +/datum/component/bounty_chrome/proc/on_death(datum/source, gibbed) + SIGNAL_HANDLER + interrupt(BOUNTY_CHROME_CANCEL_DEATH) + fighting = FALSE + for(var/datum/bounty_chrome_move/move as anything in moves) + move.on_death() + +/datum/component/bounty_chrome/proc/on_emp(datum/source, severity, protection) + SIGNAL_HANDLER + if(protection & (EMP_PROTECT_SELF | EMP_PROTECT_CONTENTS)) + return + interrupt(BOUNTY_CHROME_CANCEL_EMP) + for(var/datum/bounty_chrome_move/move as anything in moves) + move.on_emp(severity) + +/datum/component/bounty_chrome/proc/on_stunned(datum/source) + SIGNAL_HANDLER + interrupt(BOUNTY_CHROME_CANCEL_STUNNED) + +/datum/component/bounty_chrome/proc/on_restrained(datum/source) + SIGNAL_HANDLER + interrupt(BOUNTY_CHROME_CANCEL_RESTRAINED) + +/** + * The AI's chrome: in the normal criminal's controller after bounty_fight_target (and in the + * companion's, C4). Nothing for an NPC with no chrome moves. + */ +/datum/ai_planning_subtree/bounty_chrome + +/datum/ai_planning_subtree/bounty_chrome/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/datum/component/bounty_chrome/chrome = controller.pawn?.GetComponent(/datum/component/bounty_chrome) + if(!chrome) + return + return chrome.plan(controller, seconds_per_tick) + +// ===== MINI-BOSSES ===== + +/// Gives mini-boss `npc` an ability in its rotation for `move`, if it is a mini-boss and the move is one its rotation can run +/proc/bounty_chrome_grant_boss_ability(mob/living/carbon/human/npc/npc, datum/bounty_chrome_move/move) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = npc + if(!istype(boss) || !move.boss_usable || !move.action_type || move.boss_ability) + return null + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability = new(boss) + ability.set_move(move) + ability.Grant(boss) + boss.boss_abilities += ability + return ability + +/** + * A mini-boss's chrome move as one of its abilities, so its rotation, its busy rule and its interrupts + * (tg's stuns, crit, cuffs) run it the way they run its kit's: the wind-up is the move's tell, the effect + * the implant's action. + */ +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome + name = "Chrome" + desc = "A wanted criminal's chrome." + cooldown_time = BOUNTY_CHROME_MOVE_GAP + /// The move it runs, one of its boss's own (/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/move + +// A chrome move with lines of its own says one of them in its tell (move.tell()): its kit's ability line ("Grenade!" before a roar) would be a second line, and the wrong one +/mob/living/carbon/human/npc/bounty_criminal/boss/boss_bark(suffix, fallback) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/winding = boss_winding() + if(suffix == "ability" && istype(winding) && length(winding.move?.tell_lines)) + return + return ..() + +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/Destroy() + if(move?.boss_ability == src) + move.boss_ability = null + move = null + return ..() + +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/proc/set_move(datum/bounty_chrome_move/new_move) + move = new_move + new_move.boss_ability = src + name = new_move.name + windup = max(new_move.tell_time, BOUNTY_CHROME_TELL_MIN) + cooldown_time = max(new_move.recover_time, BOUNTY_CHROME_MOVE_GAP) + +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/worth_using(atom/target) + return ..() && move && move.owner == owner && move.can_start(target) + +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/telegraph(atom/target) + move?.tell(target) + +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/effect(atom/target) + if(!move) + return + move.clear_tell() + move.fire(target) + +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/finish_windup(serial) + var/pending = serial && serial == pending_serial + . = ..() + // Its boss couldn't act when the wind-up ended: the tell's look goes too + if(pending && !. && move) + move.clear_tell() + move.cancel(BOUNTY_CHROME_CANCEL_STUNNED) + +/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/cancel_windup() + var/pending = pending_serial + . = ..() + if(pending && move) + move.clear_tell() + move.cancel(BOUNTY_CHROME_CANCEL_STUNNED) + +// ===== A MALFUNCTION ===== + +/** + * A bounty NPC's body with chrome in it, as others notice it: an EMP that knocks a piece out shows the + * malfunction (bounty_chrome_malfunction_fx()) for as long as the piece takes to reboot, and a chrome read + * is felt and answered (bounty_chrome_read_noticed()). On every criminal, decoys included (they carry + * their fugitive's chrome and must answer the same way), and on chromed companions. + */ +/datum/element/bounty_chrome_body + element_flags = ELEMENT_DETACH_ON_HOST_DESTROY + +/datum/element/bounty_chrome_body/Attach(datum/target) + . = ..() + if(!ishumannpc(target)) + return ELEMENT_INCOMPATIBLE + // Added again by bounty_chrome_equip() to a criminal that already has it: the same hooks + RegisterSignal(target, COMSIG_ATOM_EMP_ACT, PROC_REF(on_emp), override = TRUE) + RegisterSignal(target, COMSIG_CARBON_CHROME_READ, PROC_REF(on_read), override = TRUE) + +/datum/element/bounty_chrome_body/Detach(datum/source) + UnregisterSignal(source, list(COMSIG_ATOM_EMP_ACT, COMSIG_CARBON_CHROME_READ)) + return ..() + +/datum/element/bounty_chrome_body/proc/on_emp(mob/living/carbon/human/npc/source, severity, protection) + SIGNAL_HANDLER + if(protection & (EMP_PROTECT_SELF | EMP_PROTECT_CONTENTS)) + return + // The chrome takes the pulse after this signal (/mob/living/emp_act()): look a moment later + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_chrome_check_malfunction), WEAKREF(source)), 1) + +/datum/element/bounty_chrome_body/proc/on_read(mob/living/carbon/human/npc/source, mob/living/carbon/reader) + SIGNAL_HANDLER + bounty_chrome_read_noticed(source, reader) + +/// Whatever chrome of `npc_ref`'s an EMP just knocked out shows it, for as long as the longest reboot +/proc/bounty_chrome_check_malfunction(datum/weakref/npc_ref) + var/mob/living/carbon/human/npc/npc = npc_ref?.resolve() + if(QDELETED(npc) || npc.stat == DEAD) + return + var/longest = 0 + for(var/obj/item/organ/organ in npc.organs) + var/datum/component/cyberware/chrome = organ.GetComponent(/datum/component/cyberware) + if(!chrome?.emp_down) + continue + longest = max(longest, chrome.emp_timer ? timeleft(chrome.emp_timer) : 0) + if(longest <= 0) + return + var/fresh = !npc.has_status_effect(/datum/status_effect/bounty_chrome_malfunction) + bounty_chrome_malfunction_fx(npc, longest) + if(fresh) + npc.visible_message(span_warning("[npc]'s chrome sparks and stutters!")) + +/** + * Shows `npc`'s chrome malfunctioning for `duration`: arcs crawling over the body, tg's EMP sparkle, a + * flickering chrome-blue outline and light, twitches, and sparks spat onto the tiles around them with a + * crackle. Only a picture: nothing is hurt, set alight or switched off by it. A longer one extends it. + */ +/proc/bounty_chrome_malfunction_fx(mob/living/npc, duration) + if(QDELETED(npc) || npc.stat == DEAD || duration <= 0) + return null + return npc.apply_status_effect(/datum/status_effect/bounty_chrome_malfunction, duration) + +/// The arcs over a malfunctioning body, and their glow in the dark when `body` is given. For the overlay and the renders. +/proc/bounty_chrome_malfunction_arcs(atom/body) + . = list() + var/mutable_appearance/arcs = mutable_appearance('icons/effects/effects.dmi', "electricity", ABOVE_MOB_LAYER) + arcs.color = BOUNTY_CHROME_MALFUNCTION_MATRIX + . += arcs + . += mutable_appearance('icons/effects/effects.dmi', "empdisable", ABOVE_MOB_LAYER) + if(body) + . += emissive_appearance('icons/effects/effects.dmi', "electricity", body) + +/// The look of bounty_chrome_malfunction_fx(), for its duration. Purely visual; it ends early if they die. +/datum/status_effect/bounty_chrome_malfunction + id = "bounty_chrome_malfunction" + duration = 4 SECONDS + tick_interval = BOUNTY_CHROME_MALFUNCTION_PULSE + status_type = STATUS_EFFECT_REFRESH + alert_type = null + /// The arcs and the sparkle on the body + var/list/arcs + /// The flickering light they give off + var/obj/effect/dummy/lighting_obj/moblight/glow + +/datum/status_effect/bounty_chrome_malfunction/on_creation(mob/living/new_owner, new_duration) + if(new_duration > 0) + duration = new_duration + return ..() + +/datum/status_effect/bounty_chrome_malfunction/refresh(effect, new_duration) + duration = max(duration, world.time + max(new_duration, 0)) + +/datum/status_effect/bounty_chrome_malfunction/on_apply() + if(owner.stat == DEAD) + return FALSE + arcs = bounty_chrome_malfunction_arcs(owner) + owner.add_overlay(arcs) + owner.add_filter(BOUNTY_CHROME_MALFUNCTION_FILTER, 3, outline_filter(1, BOUNTY_CHROME_MALFUNCTION_COLOR)) + var/outline = owner.get_filter(BOUNTY_CHROME_MALFUNCTION_FILTER) + if(outline) + // A flicker, never steady + animate(outline, color = "#7fd4ff20", time = 0.1 SECONDS, loop = -1) + animate(color = "#7fd4ffff", time = 0.1 SECONDS) + animate(color = "#7fd4ff60", time = 0.2 SECONDS) + animate(color = "#c8f0ffff", time = 0.1 SECONDS) + glow = owner.mob_light(2, 1, BOUNTY_CHROME_MALFUNCTION_COLOR) + // A corpse's chrome is burnt out: the look ends the moment it dies + RegisterSignal(owner, COMSIG_LIVING_DEATH, PROC_REF(on_owner_death)) + playsound(owner, 'sound/effects/empulse.ogg', 40, TRUE) + playsound(owner, SFX_SPARKS, 60, TRUE) + pulse() + return TRUE + +/datum/status_effect/bounty_chrome_malfunction/tick(seconds_between_ticks) + if(owner.stat == DEAD) + qdel(src) + return + pulse() + +/// One beat of it: a twitch, sparks spat onto a tile or two around them, a crackle, the light jumping +/datum/status_effect/bounty_chrome_malfunction/proc/pulse() + if(prob(60)) + owner.Shake(rand(1, 2), rand(0, 1), 0.2 SECONDS) + glow?.set_light_power(pick(0.4, 1, 1.6)) + var/turf/here = get_turf(owner) + if(!here) + return + var/list/spots = list() + for(var/turf/spot as anything in RANGE_TURFS(1, here)) + if(spot != here && !isclosedturf(spot)) + spots += spot + for(var/i in 1 to rand(1, 2)) + if(!length(spots)) + break + var/turf/spot = pick_n_take(spots) + new /obj/effect/temp_visual/bounty_chrome_spark(spot, (here.x - spot.x) * ICON_SIZE_X / 2, (here.y - spot.y) * ICON_SIZE_Y / 2) + if(prob(50)) + playsound(owner, SFX_SPARKS, 35, TRUE, SILENCED_SOUND_EXTRARANGE) + +/datum/status_effect/bounty_chrome_malfunction/proc/on_owner_death(datum/source, gibbed) + SIGNAL_HANDLER + qdel(src) + +/datum/status_effect/bounty_chrome_malfunction/on_remove() + UnregisterSignal(owner, COMSIG_LIVING_DEATH) + if(arcs) + owner.cut_overlay(arcs) + arcs = null + owner.remove_filter(BOUNTY_CHROME_MALFUNCTION_FILTER) + QDEL_NULL(glow) + +/datum/status_effect/bounty_chrome_malfunction/Destroy() + QDEL_NULL(glow) + return ..() + +/// Sparks flung from a malfunctioning body onto a tile beside it: tg's spark art, and nothing else. Starts `from_x`, `from_y` pixels back toward the body. +/obj/effect/temp_visual/bounty_chrome_spark + icon = 'icons/effects/effects.dmi' + icon_state = "sparks" + layer = ABOVE_MOB_LAYER + duration = 0.5 SECONDS + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + +/obj/effect/temp_visual/bounty_chrome_spark/Initialize(mapload, from_x = 0, from_y = 0) + . = ..() + setDir(pick(GLOB.cardinals)) + pixel_x = from_x + pixel_y = from_y + animate(src, pixel_x = 0, pixel_y = 0, time = 0.2 SECONDS, easing = QUAD_EASING | EASE_OUT) + animate(alpha = 0, time = 0.3 SECONDS) + +// ===== A CHROME READ ===== + +/mob/living/carbon/human/npc + /// world.time it may next answer a chrome read (bounty_chrome_read_noticed()) + var/chrome_read_answer_at = 0 + +/** + * `reader` just read `npc`'s chrome with cyber optics, and it felt it (COMSIG_CARBON_CHROME_READ, + * cyberware_scan.dm): one that isn't fighting turns to the reader and tells them off, at most once every + * BOUNTY_CHROME_READ_NOTICE_COOLDOWN. Never while hiding. Everyone at a trader outpost answers the same + * way, the fugitive and its decoys alike. Returns TRUE if it answers. Doesn't sleep. + */ +/proc/bounty_chrome_read_noticed(mob/living/carbon/human/npc/npc, mob/living/reader) + if(!ishumannpc(npc) || !isliving(reader) || reader == npc || world.time < npc.chrome_read_answer_at) + return FALSE + if(npc.stat != CONSCIOUS || npc.client || bounty_chrome_in_fight(npc) || !length(cyberware_scannable_hardware(npc))) + return FALSE + var/mob/living/carbon/human/npc/bounty_criminal/criminal = npc + if(istype(criminal) && criminal.hidden) + return FALSE + npc.chrome_read_answer_at = world.time + BOUNTY_CHROME_READ_NOTICE_COOLDOWN + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_chrome_answer_read), npc, reader) + return TRUE + +/// `npc` looks round at `reader` and says something about being read. Sleeps (say()). +/proc/bounty_chrome_answer_read(mob/living/carbon/human/npc/npc, mob/living/reader) + if(QDELETED(npc) || QDELETED(reader) || npc.stat != CONSCIOUS) + return + if(isturf(npc.loc) && !npc.buckled && npc.body_position == STANDING_UP) + npc.face_atom(reader) + npc.say(pick("Who said you could scan me?", "Stop reading me, creep.", "Quit scanning me.", "Eyes off my chrome."), forced = "bounty chrome read") diff --git a/voidcrew/modules/bounties/bounty_combat_sense.dm b/voidcrew/modules/bounties/bounty_combat_sense.dm new file mode 100644 index 00000000000..d0dcbbff588 --- /dev/null +++ b/voidcrew/modules/bounties/bounty_combat_sense.dm @@ -0,0 +1,51 @@ +/** + * Combat sense for bounty fighters (voidcrew/modules/human_npcs/human_npc_combat_sense.dm): normal + * criminals and their companions. Meek criminals (they run), decoys (patrons) and bosses (their own + * stimulant and fallback, bounty_boss.dm) don't have it. + * + * What they carry: a Wanted normal criminal also packs a stimpack (bounty_ai_normal.dm, + * bounty_build_outfit(); every Most Wanted is a mini-boss with its own pens), used when it tires in a fight, when its style leaves a + * pocket free (brawler, club, bottle, shotgun; not pistol or knife). Petty criminals and companions carry + * none. Under stun fire a criminal whose style shoots or throws from range runs for + * cover; a brawler, knife, club or shotgun style charges the shooter. Cover stays on the criminal's leash + * (leash_ok(); a companion keeps to its criminal's), and the movement is the bounty AI's own leash pathing. + */ +/datum/npc_combat_sense/bounty + +/mob/living/carbon/human/npc/bounty_criminal/normal + npc_combat_sense = /datum/npc_combat_sense/bounty + +/mob/living/carbon/human/npc/bounty_companion + npc_combat_sense = /datum/npc_combat_sense/bounty + +/datum/npc_combat_sense/bounty/can_act(mob/living/carbon/human/npc, datum/ai_controller/controller) + if(!..()) + return FALSE + if(istype(npc, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = npc + return criminal.ai_can_act() && !criminal.hidden && !criminal.blended + if(istype(npc, /mob/living/carbon/human/npc/bounty_companion)) + var/mob/living/carbon/human/npc/bounty_companion/companion = npc + return companion.ai_can_fight() + return TRUE + +// A criminal shares the players' faction until its placement says otherwise: its gang is its side. +/datum/npc_combat_sense/bounty/allied(mob/living/carbon/human/npc, atom/shooter) + return bounty_ai_same_gang(npc, shooter) + +/datum/npc_combat_sense/bounty/in_fight(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + return bounty_ai_fighting(npc) || sense.under_fire() + +/// Its style's distance: a gun style's shooting range, 1 for the melee styles +/datum/npc_combat_sense/bounty/reach(mob/living/carbon/human/npc, datum/ai_controller/controller) + var/datum/bounty_style/style = bounty_ai_style(npc) + if(!style?.ranged) + return 1 + var/datum/ai_behavior/shoot = GET_AI_BEHAVIOR(style.ranged_behavior) + return shoot?.required_distance || BOUNTY_PISTOL_RANGE + +/datum/npc_combat_sense/bounty/tile_ok(mob/living/carbon/human/npc, datum/ai_controller/controller, turf/tile) + if(!..()) + return FALSE + var/mob/living/carbon/human/npc/bounty_criminal/side = bounty_ai_side_of(npc) + return isnull(side) || side.leash_ok(tile) diff --git a/voidcrew/modules/bounties/bounty_companions.dm b/voidcrew/modules/bounties/bounty_companions.dm index af7be6123ef..26eb0c8da65 100644 --- a/voidcrew/modules/bounties/bounty_companions.dm +++ b/voidcrew/modules/bounties/bounty_companions.dm @@ -23,6 +23,14 @@ * criminal's spawn context (/datum/npc_spawn_context/bounty_company), which is how they know all that * before they are dressed. * + * They back their criminal up (C4): at most one of a criminal's company carries a gun + * (bounty_roll_company()), and a posting rolls its company with its site, so the sighting can say who + * they were seen with and the same company comes back each time the site loads (bounty_placement.dm). + * Joining a fight, they get up first and get their weapon out BOUNTY_COMPANION_DRAW_DELAY after their + * criminal does, and their guns fire shorter pistol strings and SMG bursts (bounty_styles.dm). Now and + * then one carries a piece of real chrome, rarer than their criminal's (bounty_chrome_roll_companion()), + * installed in their body like a criminal's and driven by the same chrome subtree. + * * The shared vars are declared in bounty_types.dm and nowhere else (leader_ref); the rest here * have an `ai_` prefix. */ @@ -62,6 +70,17 @@ var/company_site_kind /// The /datum/outfit their rough clothes came from (bounty_site_clothes()), or null for their plain ones var/company_clothes + /// Their criminal's tier (BOUNTY_TIER_*), known as they are made: what their chrome rolls by + var/company_tier + /// Who the posting rolled them as (bounty_roll_company()): their style and chrome, or null to roll their own as they are dressed + var/list/company_member + /// Their criminal has an armed companion already: they roll no gun of their own + var/company_unarmed = FALSE + /// The chrome keys in their body (BOUNTY_CHROME_*), and whether that was settled as they were dressed + var/list/ai_chrome + var/ai_chrome_rolled = FALSE + /// world.time they are up and may get their weapon out, in a fight they just joined + var/ai_draw_at = 0 /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 @@ -70,10 +89,19 @@ if(!QDELETED(leader)) company_site_kind = leader.posting()?.placement_kind npc_always_site |= leader.npc_site + company_tier = leader.record?.tier + company_unarmed = bounty_company_armed(leader) else npc_always_site |= bounty_site_dress_for(order?.context) company_site_kind ||= bounty_site_kind_of(order?.context) - return ..() + // Who the posting rolled them as: the style they are dressed for, and their chrome + if(istype(company) && company.company_member) + company_member = company.company_member.Copy() + ai_style ||= company_member[BOUNTY_COMPANY_STYLE] + . = ..() + // Their chrome is in their body now (the base installed npc_cyberware): the AI side of it + if(length(ai_chrome)) + bounty_chrome_equip(src, ai_chrome) /mob/living/carbon/human/npc/bounty_companion/Destroy() ai_let_go() @@ -87,11 +115,23 @@ /** * 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. + * criminal's heavier one) and its spares, and a bruise pack. The style is the one the posting rolled + * for them, or picked here (never a second gun in their criminal's company), so the weapon they carry + * is the one they fight with. Their chrome is settled here too, once: the posting's, or a roll of their + * own (bounty_chrome_roll_companion()), into npc_cyberware, so the base installs it and the outfit table + * dresses them to show it. */ /mob/living/carbon/human/npc/bounty_companion/bounty_build_outfit(zone) - ai_style ||= pick_weight(list( + ai_style ||= bounty_roll_companion_style(no_gun = company_unarmed) + if(!ai_chrome_rolled) + ai_chrome_rolled = TRUE + var/list/keys = company_member ? company_member[BOUNTY_COMPANY_CHROME] : bounty_chrome_roll_companion(company_tier, ai_style) + ai_chrome = bounty_chrome_prepare_body(src, keys) + return bounty_fighter_outfit(BOUNTY_ARCHETYPE_NORMAL, zone, BOUNTY_TIER_PETTY, ai_style, FALSE, /obj/item/stack/medical/bruise_pack) + +/// Fighting style weights for a companion (BOUNTY_STYLE_* => weight): mostly fists and blades, a gun now and then +/proc/bounty_companion_style_weights() + return list( BOUNTY_STYLE_BRAWLER = 3, BOUNTY_STYLE_KNIFE = 2, BOUNTY_STYLE_CLUB = 2, @@ -100,8 +140,47 @@ 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) + ) + +/** + * A companion's fighting style (BOUNTY_STYLE_*), by weight. `no_gun` (their criminal has an armed + * companion already) rolls among the rest: fists, a knife, a bat or bottles. + */ +/proc/bounty_roll_companion_style(no_gun = FALSE) + var/list/weights = bounty_companion_style_weights() + if(no_gun) + for(var/key in weights.Copy()) + if(bounty_style_is_gun(key)) + weights -= key + return pick_weight(weights) + +/** + * The company of `count` companions for a criminal of `tier` (BOUNTY_TIER_*): one list per companion, + * its fighting style (BOUNTY_COMPANY_STYLE) and its chrome (BOUNTY_COMPANY_CHROME, rolled for that style, + * or null). At most one of them carries a gun, and that one comes first, so a server short of room for + * companions still spawns the armed one the sighting names. + */ +/proc/bounty_roll_company(count, tier) + var/list/company = list() + var/armed = FALSE + for(var/i in 1 to count) + var/style = bounty_roll_companion_style(no_gun = armed) + var/list/member = list(BOUNTY_COMPANY_STYLE = style, BOUNTY_COMPANY_CHROME = bounty_chrome_roll_companion(tier, style)) + if(bounty_style_is_gun(style)) + armed = TRUE + company.Insert(1, list(member)) + else + company += list(member) + return company + +/// Whether any of `leader`'s company carries a gun: their style is one (bounty_style_is_gun()) +/proc/bounty_company_armed(mob/living/carbon/human/npc/bounty_criminal/leader) + if(QDELETED(leader)) + return FALSE + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in leader.ai_companions()) + if(bounty_style_is_gun(buddy.ai_style)) + return TRUE + return FALSE // 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() @@ -208,11 +287,16 @@ ai_controller.set_blackboard_key(BB_BASIC_MOB_REINFORCEMENT_TARGET, leader) ai_enter_fight() -/// Up from their seat, drink down, at a run. The weapon comes out through the arm subtree (bounty_styles.dm). +/** + * Up from their seat, drink down, at a run. Their weapon comes out through the arm subtree + * (bounty_styles.dm) once they are up, BOUNTY_COMPANION_DRAW_DELAY later (bounty_companion_getting_up), + * a beat after their criminal's. + */ /mob/living/carbon/human/npc/bounty_companion/proc/ai_enter_fight() if(ai_in_fight) return ai_in_fight = TRUE + ai_draw_at = world.time + BOUNTY_COMPANION_DRAW_DELAY ai_put_drink_away() ai_stand_up() bounty_ai_set_pace(src, BOUNTY_RUN_SPEED) @@ -222,6 +306,7 @@ if(!ai_in_fight) return ai_in_fight = FALSE + ai_draw_at = 0 bounty_ai_set_pace(src, BOUNTY_CALM_SPEED) bounty_ai_holster(src) @@ -448,26 +533,32 @@ * 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). It is - * made with its criminal's spawn context, so it is dressed for where they are. + * made with its criminal's spawn context, so it is dressed for where they are. `member` (one entry of + * bounty_roll_company()) is who it is: its style and chrome; without it, it rolls its own. */ -/proc/bounty_spawn_companion(mob/living/carbon/human/npc/bounty_criminal/leader, turf/where, datum/callback/on_spawned, immediate = FALSE) +/proc/bounty_spawn_companion(mob/living/carbon/human/npc/bounty_criminal/leader, turf/where, datum/callback/on_spawned, immediate = FALSE, list/member) where = get_turf(where) if(QDELETED(leader) || !where) return null var/datum/npc_spawn_context/bounty_company/company = new(leader, null, "ordinary") company.company_leader_ref = WEAKREF(leader) + company.company_member = member 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. + * criminal it is made from), which criminal that is, and who the posting rolled the companion as, 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 + /// One entry of bounty_roll_company() (BOUNTY_COMPANY_STYLE, BOUNTY_COMPANY_CHROME), or null to roll their own + var/list/company_member /datum/npc_spawn_context/bounty_company/Destroy() company_leader_ref = null + company_member = null return ..() /** @@ -495,15 +586,25 @@ /** * Spawns `count` companions (clamped to BOUNTY_COMPANIONS_MIN-BOUNTY_COMPANIONS_MAX) on free tiles * 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. + * posting, as it is made. They are `company` (bounty_roll_company(), the posting's), and any more than + * it has are rolled here, never a second gun among them. Returns the companions already made: only with + * `immediate` (tests, admin tools), otherwise an empty list. */ -/mob/living/carbon/human/npc/bounty_criminal/proc/spawn_companions(count, immediate = FALSE) +/mob/living/carbon/human/npc/bounty_criminal/proc/spawn_companions(count, immediate = FALSE, list/company) . = list() count = clamp(count, BOUNTY_COMPANIONS_MIN, BOUNTY_COMPANIONS_MAX) var/turf/home = get_turf(src) if(!home || count <= 0) return + company = company ? company.Copy() : list() + if(length(company) < count) + var/armed = bounty_company_armed(src) + for(var/list/member as anything in company) + armed ||= bounty_style_is_gun(member[BOUNTY_COMPANY_STYLE]) + for(var/i in length(company) + 1 to count) + var/style = bounty_roll_companion_style(no_gun = armed) + armed ||= bounty_style_is_gun(style) + company += list(list(BOUNTY_COMPANY_STYLE = style, BOUNTY_COMPANY_CHROME = bounty_chrome_roll_companion(record?.tier, style))) var/list/spots = list() for(var/turf/tile as anything in RANGE_TURFS(1, home)) if(tile != home && ai_standable(tile)) @@ -515,7 +616,7 @@ for(var/i in 1 to count) if(!length(spots)) break - var/datum/human_npc_order/order = bounty_spawn_companion(src, pick_n_take(spots), null, immediate) + var/datum/human_npc_order/order = bounty_spawn_companion(src, pick_n_take(spots), null, immediate, company[i]) var/mob/living/carbon/human/npc/bounty_companion/buddy = order?.spawned_ref?.resolve() if(!QDELETED(buddy)) . += buddy @@ -535,9 +636,10 @@ // ===== AI ===== /** - * 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). + * A companion's controller: the trooper's peaceful pattern (retaliate, call the others in, get up, + * attack by style with the real weapon or their chrome, 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( @@ -549,6 +651,11 @@ /datum/ai_planning_subtree/flee_target/bounty, /datum/ai_planning_subtree/target_retaliate/bounty, /datum/ai_planning_subtree/call_reinforcements/bounty, + // Just joined the fight: up first, their criminal draws before they do + /datum/ai_planning_subtree/bounty_companion_getting_up, + // Their chrome, if they carry any: a tell, then the implant's own action (C0, bounty_chrome.dm) + /datum/ai_planning_subtree/bounty_chrome, + /datum/ai_planning_subtree/npc_combat_sense, /datum/ai_planning_subtree/bounty_arm, /datum/ai_planning_subtree/bounty_ranged, /datum/ai_planning_subtree/bounty_melee, @@ -628,6 +735,22 @@ if(QDELETED(threat) || bounty_ai_dist(companion, threat) >= (controller.blackboard[BB_BASIC_MOB_FLEE_DISTANCE] || BOUNTY_FLEE_DISTANCE)) return SUBTREE_RETURN_FINISH_PLANNING +/** + * Just in the fight (ai_enter_fight()), a companion gets up from where they were first: for + * BOUNTY_COMPANION_DRAW_DELAY they turn to face whoever they are going for, and no weapon comes out and + * no blow or shot is planned, so their criminal's draw comes first. Then the arm subtree draws as usual. + */ +/datum/ai_planning_subtree/bounty_companion_getting_up + +/datum/ai_planning_subtree/bounty_companion_getting_up/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_companion/companion = controller.pawn + if(!istype(companion) || !companion.ai_in_fight || world.time >= companion.ai_draw_at) + return + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(!QDELETED(target)) + companion.face_atom(target) + return SUBTREE_RETURN_FINISH_PLANNING + /// tg's retaliation, while they can still fight. Its list is filled by the controller's hooks, not tg's element. /datum/ai_planning_subtree/target_retaliate/bounty operational_datums = null diff --git a/voidcrew/modules/bounties/bounty_criminal.dm b/voidcrew/modules/bounties/bounty_criminal.dm index e9849f8b481..d4e10fb8479 100644 --- a/voidcrew/modules/bounties/bounty_criminal.dm +++ b/voidcrew/modules/bounties/bounty_criminal.dm @@ -68,11 +68,15 @@ 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) + // Its record's chrome joins npc_cyberware, so the base installs the real implants once it is dressed (C0, bounty_chrome.dm) + bounty_chrome_prepare(src) . = ..() add_traits(list(TRAIT_NO_TELEPORT, TRAIT_NOMOBSWAP), BOUNTY_BODY_TRAIT) AddComponent(/datum/component/bounty_body) body_hook_cuffs() body_toughness() + // Its chrome's moves (a mini-boss's in its ability rotation), and the EMP look (C0) + bounty_chrome_ready(src) /mob/living/carbon/human/npc/bounty_criminal/Destroy() if(body_leaves_proof()) @@ -126,6 +130,8 @@ return /mob/living/carbon/human/npc/bounty_criminal/boss/ghost if(BOUNTY_KIT_HEAVY) return /mob/living/carbon/human/npc/bounty_criminal/boss/heavy + if(BOUNTY_KIT_CYBERPSYCHO) + return /mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho return pick( /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac, diff --git a/voidcrew/modules/bounties/bounty_identity.dm b/voidcrew/modules/bounties/bounty_identity.dm index 8ed130ed47b..439a0e08695 100644 --- a/voidcrew/modules/bounties/bounty_identity.dm +++ b/voidcrew/modules/bounties/bounty_identity.dm @@ -75,6 +75,9 @@ GLOBAL_LIST_INIT(bounty_species_weights, list( record.style = bounty_roll_style(concealed = (placement_kind == BOUNTY_PLACEMENT_TRADER_OUTPOST)) if(BOUNTY_ARCHETYPE_BOSS) record.kit = bounty_roll_kit() + // C0 chrome (bounty_chrome.dm): rolled once, so the same criminal always carries the same chrome. The kingpin carries none. + if(placement_kind != BOUNTY_PLACEMENT_KINGPIN) + record.chrome = bounty_chrome_roll(tier, archetype, record.style, record.kit, bounty_chrome_kit_organs(record.kit)) record.alias = bounty_roll_alias(record) record.crime = bounty_roll_crime(tier) record.features = bounty_roll_features(record) @@ -124,6 +127,8 @@ GLOBAL_LIST_INIT(bounty_species_weights, list( BOUNTY_KIT_PYROMANIAC = 20, BOUNTY_KIT_DEMOLITIONIST = 18, BOUNTY_KIT_GHOST = 18, + // The rarest: its kit is its chrome (chrome/bounty_cyberpsycho.dm) + BOUNTY_KIT_CYBERPSYCHO = 8, ) return pick_weight(weights) diff --git a/voidcrew/modules/bounties/bounty_lair_mafia.dm b/voidcrew/modules/bounties/bounty_lair_mafia.dm index a95fbb281f5..4b45b10147b 100644 --- a/voidcrew/modules/bounties/bounty_lair_mafia.dm +++ b/voidcrew/modules/bounties/bounty_lair_mafia.dm @@ -157,7 +157,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) */ /proc/bounty_mafia_room_crew(area_type) var/type_text = "[area_type]" - var/static/marker = "/mafia_club/" + var/marker = "/mafia_club/" var/at = findtext(type_text, marker) if(!at) return null @@ -779,6 +779,8 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) /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 + if(cyberware_camo_hides(target, src)) // optical camo (cyberware_stealth.dm) + return FALSE var/turf/spot = get_turf(target) return spot && spot.z == z && get_dist(src, spot) <= BOUNTY_MOBSTER_CHASE diff --git a/voidcrew/modules/bounties/bounty_outfits.dm b/voidcrew/modules/bounties/bounty_outfits.dm index 3eff08fd633..0005b1fe614 100644 --- a/voidcrew/modules/bounties/bounty_outfits.dm +++ b/voidcrew/modules/bounties/bounty_outfits.dm @@ -29,6 +29,9 @@ return null var/outfit = npc.bounty_build_outfit(zone || ZONE_GREEN) outfit = npc.bounty_site_clothes(outfit) + // Chrome carriers dress light, so their worn chrome shows (C0, bounty_chrome.dm). A mini-boss wears its kit. + if(length(npc.npc_cyberware) && npc.bounty_dresses_to_show_chrome()) + outfit = bounty_chrome_expose_outfit(outfit, npc.npc_cyberware) return bounty_seal_outfit(npc, outfit, src) /** diff --git a/voidcrew/modules/bounties/bounty_outpost.dm b/voidcrew/modules/bounties/bounty_outpost.dm index 3dbff01d01f..9ac8cecbc28 100644 --- a/voidcrew/modules/bounties/bounty_outpost.dm +++ b/voidcrew/modules/bounties/bounty_outpost.dm @@ -856,6 +856,9 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( if(QDELETED(owner)) return owner.blended = FALSE + // Out of the act, the coat over its chrome comes off and the chrome shows (C0, bounty_chrome.dm). Decoys never drop the act. + if(!decoy && !leaving) + bounty_chrome_bare(owner) REMOVE_TRAIT(owner, TRAIT_NO_CONTAINMENT, BOUNTY_OUTPOST_TRAIT) REMOVE_TRAIT(owner, TRAIT_NO_STORAGE_INSERT, BOUNTY_OUTPOST_TRAIT) if(added_turret_faction) @@ -1402,6 +1405,15 @@ 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()). diff --git a/voidcrew/modules/bounties/bounty_placement.dm b/voidcrew/modules/bounties/bounty_placement.dm index 6e28641c1ca..0ca7fddbb2f 100644 --- a/voidcrew/modules/bounties/bounty_placement.dm +++ b/voidcrew/modules/bounties/bounty_placement.dm @@ -491,17 +491,42 @@ return BOUNTY_ACTIVITY_BLEND 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/carbon/human/npc/bounty_criminal/criminal) +/** + * The company a normal criminal keeps at its site (bounty_roll_company(): a style and chrome a + * companion, at most one of them armed): 0 to BOUNTY_MAX_COMPANIONS in every zone (12.3 C9: the zone + * scales pay, never the fight). At most one aboard a pirate ship, whose crew are company enough, and + * nobody at a trader outpost or with any other kind of criminal. + */ +/datum/criminal_bounty/proc/board_roll_company() + if(record?.archetype != BOUNTY_ARCHETYPE_NORMAL || placement_kind == BOUNTY_PLACEMENT_TRADER_OUTPOST) + return list() var/count = rand(0, BOUNTY_MAX_COMPANIONS) - // The crew aboard a pirate ship are company enough if(placement_kind == BOUNTY_PLACEMENT_NPC_SHIP) count = min(count, 1) - count = min(count, BOUNTY_MAX_LIVE_COMPANIONS - SScriminal_bounties.board_live_companions()) + return bounty_roll_company(count, record?.tier) + +/** + * The company its criminal keeps at its site now, rolled the first time it is asked for at a site + * (board_roll_company()) and kept while the bounty stays there: the sighting names it, and the same + * company comes back each time the site loads. A new site rolls a new one. + */ +/datum/criminal_bounty/proc/board_company() + var/obj/structure/overmap/where = site() + if(where && board_company_site?.resolve() != where) + board_company = null + board_company_site = WEAKREF(where) + if(isnull(board_company)) + board_company = board_roll_company() + return board_company + +/// Spawns the company the posting rolled (board_company()) beside its criminal, within the server's cap on live companions +/datum/criminal_bounty/proc/board_spawn_companions(mob/living/carbon/human/npc/bounty_criminal/criminal) + var/list/company = board_company() + var/count = min(length(company), BOUNTY_MAX_LIVE_COMPANIONS - SScriminal_bounties.board_live_companions()) if(count <= 0) return list() // 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) + criminal.spawn_companions(count, FALSE, company) /** * Makes the criminal a friend of the site's own, so it doesn't fight the hostiles native to where diff --git a/voidcrew/modules/bounties/bounty_posting.dm b/voidcrew/modules/bounties/bounty_posting.dm index 9da2acf8d26..ea5b3445ca4 100644 --- a/voidcrew/modules/bounties/bounty_posting.dm +++ b/voidcrew/modules/bounties/bounty_posting.dm @@ -53,8 +53,14 @@ 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 + /// The company its criminal keeps at its site (board_company(): bounty_roll_company(), a style and chrome a companion), null until rolled + var/list/board_company + /// Weakref to the site board_company was rolled for: a new site rolls a new one + var/datum/weakref/board_company_site /datum/criminal_bounty/Destroy() // close() is the way out; this catches an admin qdel that skipped it @@ -186,7 +192,7 @@ if(record && !record.mugshot) bounty_queue_mugshot(record) board_push_waypoint(ship) - ship.ship_notify("WANTED: now hunting [record?.name]. [board_place_text()].", "MISSION CONTROL", SHIP_NOTIFY_NOTICE, 'voidcrew/sound/notify.ogg', 50) + ship.ship_notify("WANTED: now hunting [record?.name]. [board_sighting_text()].", "MISSION CONTROL", SHIP_NOTIFY_NOTICE, 'voidcrew/sound/notify.ogg', 50) log_game("BOUNTY: [ship.name] is hunting the [board_log_name()]") board_arm() return TRUE @@ -282,6 +288,7 @@ 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) @@ -451,7 +458,7 @@ SScriminal_bounties.board_changed() for(var/obj/structure/overmap/ship/hunter as anything in hunter_ships()) board_push_waypoint(hunter) - hunter.ship_notify("WANTED: new sighting of [record?.name]. [board_place_text()].", "MISSION CONTROL", SHIP_NOTIFY_NOTICE, 'voidcrew/sound/notify.ogg', 50) + hunter.ship_notify("WANTED: new sighting of [record?.name]. [board_sighting_text()].", "MISSION CONTROL", SHIP_NOTIFY_NOTICE, 'voidcrew/sound/notify.ogg', 50) log_game("BOUNTY: the [board_log_name()] relisted") board_arm() return TRUE @@ -550,6 +557,32 @@ return "Seen at the [site_name]" return "Seen on [site_name]" +/// The sighting as the card and the notices give it: where they were seen, and who with ("Seen on Kepler IV with two friends, one armed") +/datum/criminal_bounty/proc/board_sighting_text() + var/company = board_company_text() + return company ? "[board_place_text()] [company]" : board_place_text() + +/// Who they were seen with (board_company()), or null for nobody: "with a friend", "with an armed friend", "with two friends", "with two friends, one armed" +/datum/criminal_bounty/proc/board_company_text() + if(board_relisting) + return null + var/list/company = board_company() + if(!length(company)) + return null + var/armed = 0 + for(var/list/member as anything in company) + if(bounty_style_is_gun(member[BOUNTY_COMPANY_STYLE])) + armed++ + if(length(company) == 1) + return armed ? "with an armed friend" : "with a friend" + var/friends = "with [length(company) == 2 ? "two" : length(company)] friends" + switch(armed) + if(0) + return friends + if(1) + return "[friends], one armed" + return "[friends], all armed" + /// How the poster says they're wanted: alive, dead or alive, or dead /datum/criminal_bounty/proc/board_terms() return "Wanted alive" @@ -591,7 +624,7 @@ "tier" = record?.tier || BOUNTY_TIER_PETTY, "terms" = board_terms(), "crime" = record?.crime, - "place" = board_place_text(), + "place" = board_sighting_text(), "zone" = board_zone_name(), "zone_color" = board_zone_color(), "mugshot_id" = record?.id, @@ -622,8 +655,17 @@ 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" : ""]" : ""]" @@ -647,6 +689,9 @@ lines += "Wanted for: [record.crime].
" lines += "[board_terms()].
" lines += "[board_place_text()], [board_zone_name()].
" + var/company = board_company_text() + if(company) + lines += "[capitalize(company)].
" // One feature is left off, so what the traders say about them still tells a hunter something new var/list/features = record?.feature_lines() if(length(features)) diff --git a/voidcrew/modules/bounties/bounty_styles.dm b/voidcrew/modules/bounties/bounty_styles.dm index d8e81df3fd2..2ecc5690d8a 100644 --- a/voidcrew/modules/bounties/bounty_styles.dm +++ b/voidcrew/modules/bounties/bounty_styles.dm @@ -25,10 +25,13 @@ * 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. + * hit (bounty_ai_line_blocked()), one step at a time at the body's own pace (bounty_ai_step()). 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. A gun fires at anyone it sees + * within BOUNTY_GUN_FIRE_RANGE while its holder walks in to BOUNTY_PISTOL_RANGE; the shotgun and the + * bottle keep to their own distance. A companion's gun is backup: shorter pistol strings and SMG bursts + * (companion_string, companion_burst). 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 @@ -188,10 +191,10 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) return TRUE return FALSE -/// One step sideways for a clear line to `target`, no further from them, on the leash +/// One step sideways for a clear line to `target`, no further from them, on the leash, and no sooner than the body's own next step (a person can't dart about faster than they walk) /proc/bounty_ai_sidestep(mob/living/fighter, atom/target) var/turf/here = get_turf(fighter) - if(!here || !isturf(fighter.loc)) + if(!here || !isturf(fighter.loc) || !bounty_ai_step_ready(fighter)) return FALSE var/list/options = list() for(var/direction in GLOB.alldirs) @@ -201,18 +204,18 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) options += next shuffle_inplace(options) for(var/turf/next as anything in options) - if(bounty_ai_step(fighter, next)) + if(bounty_ai_step(fighter, next, paced = TRUE)) return TRUE return FALSE -/// A step straight back from `target`, now and then, on the leash +/// A step straight back from `target`, now and then, on the leash, and no sooner than the body's own next step /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)) + if(world.time < controller.blackboard[BB_BOUNTY_BACKSTEP_AT] || !isturf(fighter.loc) || !bounty_ai_step_ready(fighter)) 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)) + if(!away || !bounty_ai_step(fighter, away, paced = TRUE)) return FALSE fighter.face_atom(target) return TRUE @@ -270,6 +273,9 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) /// 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 + /// A companion's burst and string, shorter: their gun is backup (null: the same as burst and string_shots) + var/companion_burst + var/companion_string /** * Puts this style's weapon and spares on `outfit` (an instance), the heavier weapon if `heavy`. The @@ -282,12 +288,16 @@ 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` +/// Trigger pulls in one burst for `fighter`: a companion's is companion_burst, if the style has one /datum/bounty_style/proc/burst_length(mob/living/carbon/fighter) + if(!isnull(companion_burst) && istype(fighter, /mob/living/carbon/human/npc/bounty_companion)) + return companion_burst return burst -/// Shots in one string for `fighter`, 0 for none +/// Shots in one string for `fighter`, 0 for none: a companion's is companion_string, if the style has one /datum/bounty_style/proc/string_length(mob/living/carbon/fighter) + if(!isnull(companion_string) && istype(fighter, /mob/living/carbon/human/npc/bounty_companion)) + return companion_string 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. @@ -487,6 +497,7 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) single_fire = TRUE string_shots = BOUNTY_PISTOL_STRING_SHOTS string_pause = BOUNTY_PISTOL_STRING_PAUSE + companion_string = BOUNTY_COMPANION_PISTOL_STRING /datum/bounty_style/pistol/equip(datum/outfit/outfit, heavy = FALSE) var/obj/item/gun/ballistic/gun_type = weapon_for(heavy) @@ -512,6 +523,7 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) burst = BOUNTY_SMG_BURST burst_gap = BOUNTY_SMG_BURST_GAP concealable = FALSE + companion_burst = BOUNTY_COMPANION_SMG_BURST /datum/bounty_style/smg/equip(datum/outfit/outfit, heavy = FALSE) var/obj/item/gun/ballistic/gun_type = weapon_for(heavy) @@ -796,17 +808,20 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) 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; 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. + * Shoots (or throws) at the target from the style's distance: walks in to required_distance, and fires + * at them on the way once it can see them within fire_range; 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; 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 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 + /// How far off they shoot at someone they can see, walking in or not + var/fire_range = BOUNTY_GUN_FIRE_RANGE /datum/ai_behavior/bounty_shoot/setup(datum/ai_controller/controller, target_key, targeting_strategy_key) . = ..() @@ -831,7 +846,7 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) 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)) + if(!can_see(fighter, target, fire_range)) style.end_burst(controller) return AI_BEHAVIOR_INSTANT var/winding = !!controller.blackboard[BB_BOUNTY_WINDUP_UNTIL] @@ -854,13 +869,15 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) bounty_ai_clear_windup(controller) controller.clear_blackboard_key(BB_BOUNTY_BURST_LEFT) -/// The shotgun closes in to BOUNTY_SHOTGUN_RANGE +/// The shotgun closes in to BOUNTY_SHOTGUN_RANGE, and fires from there: buckshot spreads too wide to hit much further off /datum/ai_behavior/bounty_shoot/close required_distance = BOUNTY_SHOTGUN_RANGE + fire_range = BOUNTY_SHOTGUN_RANGE -/// The bottle thrower stays BOUNTY_BOTTLE_RANGE off +/// The bottle thrower stays BOUNTY_BOTTLE_RANGE off, and throws from there /datum/ai_behavior/bounty_shoot/throw required_distance = BOUNTY_BOTTLE_RANGE + fire_range = BOUNTY_BOTTLE_RANGE // ===== MELEE ===== diff --git a/voidcrew/modules/bounties/bounty_suits.dm b/voidcrew/modules/bounties/bounty_suits.dm index 48f3d798efd..bd53920b656 100644 --- a/voidcrew/modules/bounties/bounty_suits.dm +++ b/voidcrew/modules/bounties/bounty_suits.dm @@ -11,13 +11,16 @@ * 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. + * suit; a Wanted criminal, who wears an armour vest, an armoured space suit; a mini-boss (every Most + * Wanted is one) a MODsuit of its kit's own theme (bounty_boss_kits.dm), put on and sealed by tg's own + * outfit path (quick_activation()) and running on a charged core. It is real gear, locked to them like + * the rest (D3, human_npc_gear.dm): it can't be stripped and never becomes loot, and that goes for a + * MODsuit's pieces, core, cell, modules and what its storage holds, all inside the body's contents. * - 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. + * and can come off again like on anyone. An empty slot takes one the ordinary way. A MODsuit's helmet or + * chestplate is the whole suit's: the suit comes off as one and is gone, everything in it with it. * - The pad gives the crew back everything they put on the body (bounty_return_crew_items()). */ @@ -100,12 +103,42 @@ GLOBAL_LIST_INIT(bounty_armoured_suits, list( /** * 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 + * a null helmet keeping its own (already sealed), or list(MODsuit control unit typepath). 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 mini-boss's MODsuit (bounty_sealed_gear()): a real tg suit of one theme, a BOUNTY_BOSS_MODSUIT_CELL in its + * standard core, and an expanded storage module for what its bag would hold, the suit taking the bag's place + * on its back. No other modules than the theme's own built-in ones. + */ +/obj/item/mod/control/pre_equipped/bounty_boss + applied_cell = BOUNTY_BOSS_MODSUIT_CELL + applied_modules = list(/obj/item/mod/module/storage/large_capacity) + +/// The Juggernaut's: a security suit, the nearest to its riot plates +/obj/item/mod/control/pre_equipped/bounty_boss/security + theme = /datum/mod_theme/security + +/// The Pyromaniac's: an atmospherics suit, fireproof like its fire suit +/obj/item/mod/control/pre_equipped/bounty_boss/atmospheric + theme = /datum/mod_theme/atmospheric + +/// The Demolitionist's: an engineering suit, as tough as its hard hat +/obj/item/mod/control/pre_equipped/bounty_boss/engineering + theme = /datum/mod_theme/engineering + +/// The Ghost's and the cyberpsycho's: a civilian suit, as light as what they wear in good air +/obj/item/mod/control/pre_equipped/bounty_boss/civilian + theme = /datum/mod_theme/civilian + +/// The Heavy's: a magnate suit, its energy armour that of the ablative coat it can't wear out there +/obj/item/mod/control/pre_equipped/bounty_boss/magnate + theme = /datum/mod_theme/magnate + /// 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) @@ -118,9 +151,25 @@ GLOBAL_LIST_INIT(bounty_armoured_suits, list( /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 +// A mini-boss's kit sets its own MODsuit (bounty_boss_kits.dm); one with none (the cyberpsycho) wears plain clothes, so a civilian one /mob/living/carbon/human/npc/bounty_criminal/boss/bounty_sealed_gear() - return pick(GLOB.bounty_soft_suits) + return list(/obj/item/mod/control/pre_equipped/bounty_boss/civilian) + +/** + * A MODsuit draws on its core while it runs (tg's MOD processing), and a dormant body is frozen in time + * (human_npc.dm): like a space suit's thermal regulator, the suit is paused while its wearer is dormant + * and runs again when it wakes, so its core doesn't run flat before anyone arrives. Performance only: a + * waking boss's suit is the same suit with the same charge, sealed all along. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/npc_set_suit_heating(on) + . = ..() + var/obj/item/mod/control/suit = back + if(!istype(suit)) + return + if(on) + START_PROCESSING(SSobj, suit) + else + STOP_PROCESSING(SSobj, suit) /mob/living/carbon/human/npc/bounty_companion/bounty_sealed_gear() return pick(GLOB.bounty_soft_suits) @@ -141,22 +190,33 @@ GLOBAL_LIST_INIT(bounty_armoured_suits, list( /** * `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). + * the air tank. Anything the old suit held moves to the backpack, as the base's layers do. A MODsuit goes + * on its back in place of its bag, what the bag held going in the suit's storage, and its suit and head + * slots are left for the chestplate and helmet it deploys (its gauntlets and boots go on over gloves and + * shoes). 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)) + if(!length(gear)) + return outfit + var/modsuit = ispath(gear[1], /obj/item/mod/control) + if(!modsuit && (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) + if(dressed.back || modsuit) LAZYADDASSOC(dressed.backpack_contents, dressed.suit_store, 1) dressed.suit_store = null + if(modsuit) + dressed.back = gear[1] + dressed.suit = null + dressed.head = null + return dressed dressed.suit = gear[1] var/obj/item/clothing/own_head = dressed.head if(ispath(gear[2], /obj/item/clothing/head)) @@ -185,6 +245,13 @@ GLOBAL_LIST_INIT(bounty_armoured_suits, list( * 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. */ +/// The MODsuit on its back, if `worn` is one of that suit's pieces +/mob/living/carbon/human/npc/bounty_criminal/proc/suits_modsuit_of(obj/item/worn) + var/obj/item/mod/control/suit = back + if(istype(suit) && (worn in suit.get_parts(all = TRUE))) + return suit + return null + /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 @@ -227,6 +294,9 @@ GLOBAL_LIST_INIT(bounty_armoured_suits, list( /** * 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. + * A MODsuit's helmet or chestplate takes the whole suit with it: it comes off its back (tg's own clean + * up unseals it and pulls its pieces back in, the gloves and shoes it covered going back on) and is gone, + * its core, modules and storage with it. * 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. */ @@ -241,7 +311,12 @@ GLOBAL_LIST_INIT(bounty_armoured_suits, list( return FALSE if(!user.temporarilyRemoveItemFromInventory(garment)) return FALSE - qdel(worn) + var/obj/item/mod/control/modsuit = suits_modsuit_of(worn) + if(modsuit) + temporarilyRemoveItemFromInventory(modsuit, force = TRUE) + qdel(modsuit) + else + 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 diff --git a/voidcrew/modules/bounties/bounty_types.dm b/voidcrew/modules/bounties/bounty_types.dm index 12943ae57fd..19c63aee04c 100644 --- a/voidcrew/modules/bounties/bounty_types.dm +++ b/voidcrew/modules/bounties/bounty_types.dm @@ -68,6 +68,8 @@ GLOBAL_LIST_EMPTY(bounty_prisoner_pool) var/style /// BOUNTY_KIT_* for a mini-boss, else null var/kit + /// The chrome they carry (BOUNTY_CHROME_* keys), rolled once with the record, or null (bounty_chrome.dm). Real implants in their body; a prisoner's isn't installed. + var/list/chrome /// Distinguishing features, as P1's feature keys; feature_lines() turns them into examine lines var/list/features /// What carries into the prison beyond the tier: P1's trait keys, which P7's danger helpers read diff --git a/voidcrew/modules/bounties/chrome/bounty_chrome_cascade.dm b/voidcrew/modules/bounties/chrome/bounty_chrome_cascade.dm new file mode 100644 index 00000000000..b4fbd38602a --- /dev/null +++ b/voidcrew/modules/bounties/chrome/bounty_chrome_cascade.dm @@ -0,0 +1,169 @@ +/** + * # Bounty chrome: the Cascade lattice + * + * Owner: C1. A criminal's Cascade lattice is the player's implant + * (/obj/item/organ/cyberimp/cyberware/cascade, ware_legend.dm): the surge, its eight seconds of + * speed, quicker blows, afterimages and dodge on the move, the six second crash, the minute's + * cooldown, and an EMP in the window crashing it, are all the implant's own. Nothing here changes + * them. This file is only how an NPC uses it (owner decision 5): + * - The tell (/datum/bounty_chrome_move/cascade, through C0's bounty_chrome.dm): a violet glow and + * a rising whine, standing still, for BOUNTY_CHROME_TELL_MIN; then the lattice's own Cascade Surge, + * Trigger()ed as a player's button press. It starts only with its target close and in sight, and + * never on a mini-boss whose kit fires the lattice itself (the Ghost's dash, bounty_boss_kits.dm): + * one lattice, one driver. + * - In the window its body has the lattice's speed, and its AI's own movement loop is paced by that + * body (the controller's movement_delay follows cached_multiplicative_slowdown), so a fighter who + * closes in runs a hunter down with no help from here. A gunman would stand and shoot, and the + * lattice only dodges on the move, so it strafes (strafe()): a step across its line to its target, + * never sooner than its body's own move delay allows, at most every BOUNTY_CASCADE_STRAFE_GAP, + * never while its AI is walking it and never off its leash (bounty_ai_step()). Each step leaves the + * lattice's afterimage, so the surge shows on a gunman too. + */ + +/// Furthest its target may be for it to surge, in tiles +#define BOUNTY_CASCADE_RANGE 7 +/// The glow through the tell +#define BOUNTY_CASCADE_COLOR "#c86bff" +/// How often the window's strafing looks for a step +#define BOUNTY_CASCADE_STRAFE_PULSE (0.1 SECONDS) +/// Shortest time between two strafing steps (its body's move delay may make it longer) +#define BOUNTY_CASCADE_STRAFE_GAP (0.4 SECONDS) + +/datum/bounty_chrome_move/cascade + piece_key = BOUNTY_CHROME_CASCADE + name = "Cascade surge" + action_type = /datum/action/cooldown/cyberware/cascade_surge + tell_time = BOUNTY_CHROME_TELL_MIN + tell_color = BOUNTY_CASCADE_COLOR + tell_sound = 'sound/effects/magic/charge.ogg' + tell_lines = list("Try and keep up.", "Watch this.", "Too slow.") + max_range = BOUNTY_CASCADE_RANGE + /// The window's strafing loop, while the lattice's window is open + var/strafe_timer + /// world.time its owner last took a step, by any means + var/last_step_at = 0 + /// world.time its next strafing step may come + var/next_strafe_at = 0 + /// The way its last strafing step went: the next one goes back the other way when it can, a zig-zag rather than a drift + var/last_strafe_dir = NONE + +/datum/bounty_chrome_move/cascade/Destroy() + stop_strafing() + return ..() + +/datum/bounty_chrome_move/cascade/detach() + stop_strafing() + return ..() + +/datum/bounty_chrome_move/cascade/can_start(atom/target) + if(kit_drives_lattice()) + return FALSE + return ..() + +/datum/bounty_chrome_move/cascade/tell_text(atom/target) + return "[owner]'s spine lights up with a rising whine." + +/datum/bounty_chrome_move/cascade/effect(atom/target) + . = ..() + if(.) + start_strafing() + +/datum/bounty_chrome_move/cascade/on_death() + stop_strafing() + +/// Whether its owner is a mini-boss whose kit fires this lattice itself (the Ghost's dash): the AI here never does too +/datum/bounty_chrome_move/cascade/proc/kit_drives_lattice() + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + return istype(boss) && (/obj/item/organ/cyberimp/cyberware/cascade in bounty_chrome_kit_organs(boss.boss_kit)) + +/// Whether the lattice's window is open on its owner now +/datum/bounty_chrome_move/cascade/proc/surging() + return !QDELETED(owner) && !!owner.has_status_effect(/datum/status_effect/cyberware_cascade_window) + +/// The window just opened: a fighter with a gun or bottles strafes until the window closes (a brawler or a mini-boss just closes in) +/datum/bounty_chrome_move/cascade/proc/start_strafing() + stop_strafing() + var/datum/bounty_style/style = bounty_ai_style(owner) + if(!style?.ranged || !surging()) + return + RegisterSignal(owner, COMSIG_MOVABLE_MOVED, PROC_REF(on_owner_moved)) + last_step_at = world.time + next_strafe_at = world.time + BOUNTY_CASCADE_STRAFE_GAP + strafe_timer = addtimer(CALLBACK(src, PROC_REF(strafe_pulse)), BOUNTY_CASCADE_STRAFE_PULSE, TIMER_STOPPABLE | TIMER_DELETE_ME | TIMER_LOOP) + +/// Stops the strafing loop. Safe at any time. +/datum/bounty_chrome_move/cascade/proc/stop_strafing() + if(strafe_timer) + deltimer(strafe_timer) + strafe_timer = null + if(owner) + UnregisterSignal(owner, COMSIG_MOVABLE_MOVED) + +/// One beat of the loop: a strafing step if one is due, and the loop ends with the window +/datum/bounty_chrome_move/cascade/proc/strafe_pulse() + if(!surging()) + stop_strafing() + return + strafe() + +/datum/bounty_chrome_move/cascade/proc/on_owner_moved(atom/movable/source, atom/old_loc, dir, forced) + SIGNAL_HANDLER + last_step_at = world.time + +/** + * A gunman in the lattice's window takes a step across its line to its target, keeping its distance and its + * sight of them, the way a player with a lattice keeps moving to keep the dodge: never sooner than its + * body's move delay after its last step, at most every BOUNTY_CASCADE_STRAFE_GAP, never while its AI + * is walking it, held still or not able to fight, and only on its leash (bounty_ai_step()). A fighter + * without a gun ready in hand closes in through its AI instead. Returns TRUE if it stepped. + */ +/datum/bounty_chrome_move/cascade/proc/strafe() + if(QDELETED(owner) || world.time < next_strafe_at || world.time < last_step_at + owner.cached_multiplicative_slowdown) + return FALSE + if(!surging() || !bounty_chrome_can_act(owner) || !bounty_chrome_in_fight(owner) || !bounty_ai_fighting(owner)) + return FALSE + if(owner.buckled || owner.pulledby || HAS_TRAIT(owner, TRAIT_IMMOBILIZED) || !(owner.mobility_flags & MOBILITY_MOVE)) + return FALSE + var/datum/ai_controller/controller = owner.ai_controller + if(QDELETED(controller) || controller.ai_movement?.moving_controllers[controller]) + return FALSE + var/datum/bounty_style/style = bounty_ai_style(owner) + if(!style?.ranged || !style.ready_in_hand(owner)) + return FALSE + var/atom/target = bounty_chrome_target(owner) + var/turf/here = get_turf(owner) + var/turf/aim = get_turf(target) + if(!here || !aim || aim.z != here.z) + return FALSE + var/distance = get_dist(here, aim) + if(distance < 2 || distance > BOUNTY_FIGHT_VISION) + return FALSE + var/list/sides = shuffle(strafe_dirs(here, aim)) + var/back = REVERSE_DIR(last_strafe_dir) + if(back in sides) + sides -= back + sides.Insert(1, back) + for(var/side in sides) + var/turf/spot = get_step(here, side) + if(!spot || isspaceturf(spot) || isopenspaceturf(spot) || get_dist(spot, aim) > distance || !can_see(spot, aim, BOUNTY_FIGHT_VISION)) + continue + // The glide its body's own pace gives a step, as its movement loop sets it + owner.set_glide_size(DELAY_TO_GLIDE_SIZE(owner.cached_multiplicative_slowdown)) + if(!bounty_ai_step(owner, spot)) + continue + next_strafe_at = world.time + BOUNTY_CASCADE_STRAFE_GAP + last_strafe_dir = side + owner.face_atom(target) + return TRUE + return FALSE + +/// The two cardinal steps across the line from `here` to `aim`: north and south of a target mostly east or west, east and west of one mostly north or south +/datum/bounty_chrome_move/cascade/proc/strafe_dirs(turf/here, turf/aim) + if(abs(aim.x - here.x) >= abs(aim.y - here.y)) + return list(NORTH, SOUTH) + return list(EAST, WEST) + +#undef BOUNTY_CASCADE_RANGE +#undef BOUNTY_CASCADE_COLOR +#undef BOUNTY_CASCADE_STRAFE_PULSE +#undef BOUNTY_CASCADE_STRAFE_GAP diff --git a/voidcrew/modules/bounties/chrome/bounty_chrome_deadeye.dm b/voidcrew/modules/bounties/chrome/bounty_chrome_deadeye.dm new file mode 100644 index 00000000000..a78ba8add97 --- /dev/null +++ b/voidcrew/modules/bounties/chrome/bounty_chrome_deadeye.dm @@ -0,0 +1,194 @@ +/// How far it locks on: the implant's tag range (CYBERWARE_DEADEYE_TAG_RANGE, ware_pro_combat.dm) +#define BOUNTY_DEADEYE_RANGE 9 +/// The lock's tell: red eyes and a red laser line on the mark, before the tag lands +#define BOUNTY_DEADEYE_TELL (1 SECONDS) +/// After a fight starts, how soon it locks on: early, so the tell runs while it draws and the first homing rounds come while the fight is young +#define BOUNTY_DEADEYE_OPENING (0.5 SECONDS) +/// The same for an SMG, if that style exists (a homing burst that early outguns most hunters) +#define BOUNTY_DEADEYE_OPENING_SMG (2 SECONDS) +/// How often a held tag checks the mark is still in sight and on its feet +#define BOUNTY_DEADEYE_WATCH (0.5 SECONDS) +/// The red of the eyes, the line and the outline: the implant's reticle red +#define BOUNTY_DEADEYE_RED "#ff3300" +/// The eye-colour priority of the red eyes while it holds a lock (over a cultist's) +#define BOUNTY_DEADEYE_EYES_PRIORITY (EYE_COLOR_CULT_PRIORITY + 10) + +/** + * # Deadeye link on a bounty gunman + * + * The optics players buy (/obj/item/organ/eyes/robotic/cyberware/deadeye, ware_pro_combat.dm), used as a + * player would: tag whoever it is shooting at, then shoot. The tag, its reticle on the mark, its three + * homing rounds, its 15 seconds and its 25 second cooldown are all the implant's; the AI picks the moment, + * shows it coming, and lets go when the mark gets away. + * + * - The moment: in a fight with a gun style (bounty_chrome_style_shoots()), at someone it may shoot who + * is on their feet and in sight within the tag's range. The first lock comes BOUNTY_DEADEYE_OPENING + * into the fight (BOUNTY_DEADEYE_OPENING_SMG with an SMG), then whenever the implant is off cooldown. + * - The tell, BOUNTY_DEADEYE_TELL: its eyes go red, a red laser line runs from it to the mark, a red + * outline pulses on it and the scope whirs. It keeps drawing, moving and shooting meanwhile + * (tell_keeps_acting): the lock costs it no shots, which is what makes the optics worth a gunman's while. + * Out of sight when the tell ends, the implant itself refuses the tag. + * - Then the implant's Deadeye Tag, Trigger()ed on the mark as a player's click: its next three rounds + * home in. The eyes stay red while the tag holds. + * - It lets go (the implant's own end_tag(), with its "lost it" chirp) the moment the mark is out of its + * sight or down, and when it goes down itself or the fight ends: breaking line of sight is the answer, + * and a homing round never chases someone round a corner or into crit. Letting go only ever costs it. + */ +/datum/bounty_chrome_move/deadeye + piece_key = BOUNTY_CHROME_DEADEYE + name = "Deadeye tag" + action_type = /datum/action/cooldown/cyberware/deadeye_tag + tell_time = BOUNTY_DEADEYE_TELL + tell_holds_still = FALSE + tell_keeps_acting = TRUE + tell_color = BOUNTY_DEADEYE_RED + tell_sound = 'sound/items/weapons/scope.ogg' + max_range = BOUNTY_DEADEYE_RANGE + /// The opening lock's timer + var/opening_timer + /// The held tag's sight check + var/watch_timer + /// Weakref to who it tagged, while the tag holds + var/datum/weakref/mark_ref + +/datum/bounty_chrome_move/deadeye/detach() + stop() + return ..() + +/datum/bounty_chrome_move/deadeye/Destroy() + stop() + return ..() + +/// Its optics, if they are in its owner +/datum/bounty_chrome_move/deadeye/proc/optics() + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = owner?.get_organ_slot(ORGAN_SLOT_EYES) + return istype(optics) ? optics : null + +/datum/bounty_chrome_move/deadeye/can_start(atom/target) + if(!..()) + return FALSE + var/mob/living/mark = target + if(!isliving(mark) || mark.stat != CONSCIOUS) + return FALSE + var/datum/bounty_style/style = bounty_ai_style(owner) + if(!bounty_chrome_style_shoots(style?.key)) + return FALSE + // One lock at a time: a tag still holding is the implant's to spend + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = optics() + return !optics?.tagged_ref?.resolve() + +/datum/bounty_chrome_move/deadeye/tell_text(atom/target) + return "[owner]'s eyes flash red." + +/datum/bounty_chrome_move/deadeye/tell(atom/target) + ..() + if(QDELETED(owner) || QDELETED(target)) + return + bounty_chrome_red_eyes(owner, REF(src), BOUNTY_DEADEYE_EYES_PRIORITY, TRUE, BOUNTY_DEADEYE_RED) + add_mark(owner.Beam(target, icon_state = "r_beam", time = tell_time, maxdistance = BOUNTY_DEADEYE_RANGE + 1)) + +/datum/bounty_chrome_move/deadeye/effect(atom/target) + . = ..() + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = optics() + if(!. || QDELETED(target) || optics?.tagged_ref?.resolve() != target) + eyes_off() + return + mark_ref = WEAKREF(target) + deltimer(watch_timer) + watch_timer = addtimer(CALLBACK(src, PROC_REF(watch)), BOUNTY_DEADEYE_WATCH, TIMER_STOPPABLE | TIMER_LOOP | TIMER_DELETE_ME) + +/datum/bounty_chrome_move/deadeye/cancel(reason) + eyes_off() + +/datum/bounty_chrome_move/deadeye/on_fight_start(atom/target) + deltimer(opening_timer) + opening_timer = addtimer(CALLBACK(src, PROC_REF(open)), opening_delay(), TIMER_STOPPABLE | TIMER_DELETE_ME) + +/datum/bounty_chrome_move/deadeye/on_fight_end() + deltimer(opening_timer) + opening_timer = null + let_go() + +/datum/bounty_chrome_move/deadeye/on_downed() + deltimer(opening_timer) + opening_timer = null + let_go() + +/datum/bounty_chrome_move/deadeye/on_death() + stop() + +/// How soon into a fight its first lock comes +/datum/bounty_chrome_move/deadeye/proc/opening_delay() +#ifdef BOUNTY_STYLE_SMG + var/datum/bounty_style/style = bounty_ai_style(owner) + if(style?.key == BOUNTY_STYLE_SMG) + return BOUNTY_DEADEYE_OPENING_SMG +#endif + return BOUNTY_DEADEYE_OPENING + +/// The opening lock, early in the fight: its tell starts now if it can (the framework's opening gap is for the other moves) +/datum/bounty_chrome_move/deadeye/proc/open() + opening_timer = null + var/datum/component/bounty_chrome/chrome = owner?.GetComponent(/datum/component/bounty_chrome) + if(!chrome?.fighting || chrome.telling) + return + var/atom/target = bounty_chrome_target(owner) + if(can_start(target)) + chrome.start_move(src, target) + +/// The held tag's look: it lets go when the mark is out of sight or down, or it can't shoot anyway; it stops looking once the implant has spent or dropped the tag +/datum/bounty_chrome_move/deadeye/proc/watch() + var/mob/living/mark = mark_ref?.resolve() + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = optics() + if(!mark || QDELETED(owner) || optics?.tagged_ref?.resolve() != mark) + stop() + return + if(owner.stat != CONSCIOUS || mark.stat != CONSCIOUS || !bounty_ai_can_see(owner, mark, BOUNTY_DEADEYE_RANGE)) + let_go(lost = TRUE) + +/// Lets go of its tag through the implant's own end_tag(), if it holds one. `lost`: the mark got away, and the optics chirp. +/datum/bounty_chrome_move/deadeye/proc/let_go(lost = FALSE) + var/mob/living/mark = mark_ref?.resolve() + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = optics() + if(mark && optics?.tagged_ref?.resolve() == mark) + optics.end_tag(owner) + if(lost && owner.stat == CONSCIOUS) + playsound(owner, 'sound/machines/synth/synth_no.ogg', 30, TRUE) + stop() + +/// Stops watching a tag (whatever became of it) and its eyes go back to their own colour +/datum/bounty_chrome_move/deadeye/proc/stop() + deltimer(watch_timer) + watch_timer = null + mark_ref = null + eyes_off() + +/datum/bounty_chrome_move/deadeye/proc/eyes_off() + if(owner) + bounty_chrome_red_eyes(owner, REF(src), BOUNTY_DEADEYE_EYES_PRIORITY, FALSE) + +/** + * Turns `npc`'s eyes `color` (on) or back (off) for `source`, at eye-colour `priority` (tg's own + * add_eye_color(), as a cultist's go red), and gives examine its "eyes are glowing" line. A look only. + * Each source keeps its own priority, so two of them never clear each other's. Redline uses it too. + */ +/proc/bounty_chrome_red_eyes(mob/living/carbon/human/npc, source, priority, on, color = BOUNTY_DEADEYE_RED) + if(!ishuman(npc) || QDELETED(npc)) + return + var/had = !isnull(LAZYACCESS(npc.eye_color_left_overrides, "[priority]")) + if(on) + ADD_TRAIT(npc, TRAIT_UNNATURAL_RED_GLOWY_EYES, source) + if(!had) + npc.add_eye_color(color, priority) + return + REMOVE_TRAIT(npc, TRAIT_UNNATURAL_RED_GLOWY_EYES, source) + if(had) + npc.remove_eye_color(priority) + +#undef BOUNTY_DEADEYE_RANGE +#undef BOUNTY_DEADEYE_TELL +#undef BOUNTY_DEADEYE_OPENING +#undef BOUNTY_DEADEYE_OPENING_SMG +#undef BOUNTY_DEADEYE_WATCH +#undef BOUNTY_DEADEYE_RED +#undef BOUNTY_DEADEYE_EYES_PRIORITY diff --git a/voidcrew/modules/bounties/chrome/bounty_chrome_gorilla.dm b/voidcrew/modules/bounties/chrome/bounty_chrome_gorilla.dm new file mode 100644 index 00000000000..30b56a46aa3 --- /dev/null +++ b/voidcrew/modules/bounties/chrome/bounty_chrome_gorilla.dm @@ -0,0 +1,816 @@ +/** + * # Bounty chrome: Gorilla Arms + * + * Owner: C2 (Mantis Blades and Gorilla Arms). Built on the chrome core, bounty_chrome.dm. + * + * The player's Gorilla Arms (voidcrew/modules/cyberware/ware_military_arms.dm), the real pair of myomer + * lattices, in a brawler, a brawler companion or a Juggernaut. Everything they do is the implant's: a punch + * from an arm whose own 4 second cooldown is over is its empowered punch (flat brute, wound bonus, a knock + * back a tile), the same punch on someone it holds in an aggressive grab hurls them across the room, and + * with both arms in it pries airlocks open by hand. The AI only chooses how to use them, with a tell of at + * least BOUNTY_CHROME_TELL_MIN before each big blow (owner decision 5): + * - Ordinary blows (/datum/ai_behavior/basic_melee_attack/human_npc/bounty/gorilla) are thrown with a fist + * whose punch isn't loaded, so they are plain punches. Its loaded fists wait for the two told moves. + * - The piston punch (/datum/bounty_chrome_move/gorilla_punch): it draws back a fist in an orange outline + * and the tile it aims at lights up, then it punches with a loaded arm: the implant's punch. Stepping off + * the lit tile makes it hit air. + * - The grab (/datum/bounty_chrome_move/gorilla_grab): with one fist just used and the other loaded, it + * reaches for someone beside it and takes hold, tg's own pull (the player's first ctrl-click), while an + * orange ring lights under them. A step away or Resist breaks that at once. If they stay, the grip + * tightens into tg's aggressive grab (the second ctrl-click); then two punches to the face with the used + * fist (tg's grapple pummel), and the loaded fist's punch, which on someone held fast is the implant's + * hurl. tg's grab rules hold throughout: Resist struggles free at tg's odds, a friend can pull them away, + * and a stun, a knockdown, cuffs or an EMP make it let go. It never grabs someone on the floor, held by + * someone else, or someone it just let go of (BOUNTY_GORILLA_GRAB_GUARD), and it never throws anyone + * toward a drop, lava or space. + * - Doors (/datum/bounty_chrome_move/gorilla_doors): when whoever it fights is behind a closed airlock + * near it, it puts a hand on the door out of combat mode, as the set bonus lets a player: an unpowered + * door gives at once, a powered one after the implant's slow pry, and bolts, welds and seals hold (the + * implant refuses them, and the AI leaves them alone). Only on its own ground (environment_damage_allowed()): + * never a ship, a hangar, an outpost, or a door with space or a big pressure difference behind it. + * + * A Juggernaut carrying the arms gets the grab as an ability in its own rotation (the core's adaptor); its + * own blows are its kit's melee, so the implant empowers them as it would a player's. + */ + +/// The piston punch's tell: the fist drawn back, long enough to step off the lit tile +#define BOUNTY_GORILLA_PUNCH_TELL (0.8 SECONDS) +/// The grab's tell, a hand on them: long enough to pull free before the grip tightens +#define BOUNTY_GORILLA_GRAB_TELL (0.8 SECONDS) +/// The first piston punch and the first grab of a fight come no sooner than these +#define BOUNTY_GORILLA_PUNCH_OPENING (1.5 SECONDS) +#define BOUNTY_GORILLA_GRAB_OPENING (3 SECONDS) +/// Between two grabs of one gorilla +#define BOUNTY_GORILLA_GRAB_COOLDOWN (12 SECONDS) +/// Someone it let go of isn't grabbed by it again for this long +#define BOUNTY_GORILLA_GRAB_GUARD (12 SECONDS) +/// Punches to the face before the finisher +#define BOUNTY_GORILLA_PUMMEL_PUNCHES 2 +/// It lets go after holding someone fast this long, whatever became of the punches +#define BOUNTY_GORILLA_HOLD_MAX (4 SECONDS) +/** + * A grab starts only while its used fist stays unloaded at least this long: the tell, the second + * ctrl-click and both face punches come a click apart (CLICK_CD_MELEE), so the face punches are plain + * ones and only the finisher is the implant's punch (its cooldown is per arm, CYBERWARE_GORILLA_PUNCH_COOLDOWN). + */ +#define BOUNTY_GORILLA_PUMMEL_FIST_LEFT (2.6 SECONDS) +/// How far the implant hurls someone held fast (CYBERWARE_GORILLA_HURL_RANGE), and knocks back anyone else +#define BOUNTY_GORILLA_HURL_RANGE 4 +#define BOUNTY_GORILLA_KNOCKBACK_RANGE 1 +/// Doors: how far one may be to go for, and how near its quarry has to be to it, out of sight, to be taken for behind it +#define BOUNTY_GORILLA_DOOR_REACH 2 +#define BOUNTY_GORILLA_BEHIND_RANGE 5 +/// Someone further off than this isn't worth breaking in for +#define BOUNTY_GORILLA_CHASE_RANGE 9 +/// Someone it lost sight of is still worth a door this long +#define BOUNTY_GORILLA_QUARRY_MEMORY (12 SECONDS) +/// A door it went for is left alone this long, so it doesn't paw at one that won't give +#define BOUNTY_GORILLA_DOOR_RETRY (10 SECONDS) +/// A door with more than this pressure (kPa) between its sides stays shut +#define BOUNTY_GORILLA_PRESSURE_GAP 20 +/// The arms' orange: the outline, and the ring under someone it reaches for (the mark art's red turned orange by a matrix) +#define BOUNTY_GORILLA_COLOR "#ff8a1f" +#define BOUNTY_GORILLA_MARK_MATRIX list(1, 0.54, 0.12, 0, 0, 0, 0, 0, 0) +/// Trait source for standing still while it holds someone +#define BOUNTY_GORILLA_TRAIT "bounty_chrome_gorilla" +/// What a mini-boss's boss_busy reads while it holds someone +#define BOUNTY_GORILLA_BOSS_BUSY "gorilla_hold" + +// ===== THE ARMS ===== + +/// The Gorilla Arms lattices in `npc` +/proc/bounty_gorilla_arms(mob/living/carbon/npc) + . = list() + if(QDELETED(npc)) + return + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in npc.organs) + . += arm + +/// Whether `arm`'s next punch is the implant's: its chrome running and its own cooldown over +/proc/bounty_gorilla_loaded(obj/item/organ/cyberimp/cyberware/gorilla_arms/arm) + var/datum/component/cyberware/chrome = arm?.GetComponent(/datum/component/cyberware) + if(!chrome?.is_running() || (arm.organ_flags & ORGAN_FAILING)) + return FALSE + return COOLDOWN_FINISHED(arm, slam_cooldown) + +/// How long until `arm`'s punch is loaded again: 0 if it is, INFINITY while its chrome is down (its punches are plain ones) +/proc/bounty_gorilla_reload_left(obj/item/organ/cyberimp/cyberware/gorilla_arms/arm) + var/datum/component/cyberware/chrome = arm?.GetComponent(/datum/component/cyberware) + if(!chrome?.is_running() || (arm.organ_flags & ORGAN_FAILING)) + return INFINITY + return COOLDOWN_TIMELEFT(arm, slam_cooldown) + +/// The free hand (a held index) on `arm`'s side of `npc`, or null +/proc/bounty_gorilla_hand(mob/living/carbon/npc, obj/item/organ/cyberimp/cyberware/gorilla_arms/arm) + return npc.get_empty_held_index_for_side(arm.zone == BODY_ZONE_R_ARM ? RIGHT_HANDS : LEFT_HANDS) + +/// The lattice in the arm of `npc`'s hand `index`, or null +/proc/bounty_gorilla_arm_of_hand(mob/living/carbon/npc, index) + var/zone = IS_RIGHT_INDEX(index) ? BODY_ZONE_R_ARM : BODY_ZONE_L_ARM + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in bounty_gorilla_arms(npc)) + if(arm.zone == zone) + return arm + return null + +/// An arm of `npc`'s whose punch is loaded and whose hand is free, or null +/proc/bounty_gorilla_loaded_arm(mob/living/carbon/npc) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in bounty_gorilla_arms(npc)) + if(bounty_gorilla_loaded(arm) && bounty_gorilla_hand(npc, arm)) + return arm + return null + +/** + * An arm of `npc`'s whose loaded punch would hurl someone it holds fast, or null. Only the real Gorilla + * Arms hurl (heavy_moves and a hurl_range: Brawler myomers never do), and the hurl shares the bearer's + * grab-move cooldown with the slam (hyperviolence_gorilla/gorilla_punch.dm, piston_hit()). + */ +/proc/bounty_gorilla_hurl_arm(mob/living/carbon/npc) + if(!TIMER_COOLDOWN_FINISHED(npc, COOLDOWN_GORILLA_GRAB_MOVE)) + return null + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in bounty_gorilla_arms(npc)) + if(arm.heavy_moves && arm.hurl_range > 0 && bounty_gorilla_loaded(arm) && bounty_gorilla_hand(npc, arm)) + return arm + return null + +/// A free hand of `npc`'s whose punch is a plain one (its arm's punch not loaded), the one furthest from loaded, or null +/proc/bounty_gorilla_plain_hand(mob/living/carbon/npc) + var/best + var/best_left = 0 + for(var/index in npc.get_empty_held_indexes()) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = bounty_gorilla_arm_of_hand(npc, index) + var/left = arm ? bounty_gorilla_reload_left(arm) : INFINITY + if(left > best_left) + best = index + best_left = left + return best + +/// Makes `npc`'s hand `index` the one it punches with. TRUE if it is. +/proc/bounty_gorilla_use_hand(mob/living/carbon/npc, index) + if(!index || npc.held_items[index]) + return FALSE + if(npc.active_hand_index != index) + npc.swap_hand(index, silent = TRUE) + return npc.active_hand_index == index + +/// Whether it has the two fists a grab needs: one loaded for the finisher that can hurl, and another that stays unloaded through the face punches +/proc/bounty_gorilla_fists_for_grab(mob/living/carbon/npc) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/finisher = bounty_gorilla_hurl_arm(npc) + if(!finisher) + return FALSE + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in bounty_gorilla_arms(npc)) + if(arm != finisher && bounty_gorilla_hand(npc, arm) && bounty_gorilla_reload_left(arm) >= BOUNTY_GORILLA_PUMMEL_FIST_LEFT) + return TRUE + return FALSE + +/// The way `npc` faces `victim` (face_atom()'s rule), which is the way the implant throws them +/proc/bounty_gorilla_facing(atom/npc, atom/victim) + var/dx = victim.x - npc.x + var/dy = victim.y - npc.y + if(abs(dx) < abs(dy)) + return dy > 0 ? NORTH : SOUTH + return dx > 0 ? EAST : WEST + +/// Whether nothing in the `tiles` tiles behind `victim`, seen from `npc`, is a drop, lava or space: where the implant would throw them +/proc/bounty_gorilla_safe_behind(atom/npc, mob/living/victim, tiles) + var/direction = bounty_gorilla_facing(npc, victim) + var/turf/spot = get_turf(victim) + for(var/i in 1 to tiles) + spot = get_step(spot, direction) + if(!spot || isclosedturf(spot)) + return TRUE + if(isspaceturf(spot) || isopenspaceturf(spot) || isgroundlessturf(spot) || islava(spot) || ischasm(spot)) + return FALSE + return TRUE + +// ===== ORDINARY BLOWS ===== + +/** + * A Gorilla Arms carrier's ordinary blows: the bounty brawler's melee (a punch, now and then a shove, + * bounty_styles.dm) thrown with a plain fist. Its loaded fists wait for the piston punch and the grab, + * which it tells first; with no plain fist free it stays on its target and throws nothing. A mech, or + * anything that isn't a person, takes whatever fist. + */ +/datum/ai_behavior/basic_melee_attack/human_npc/bounty/gorilla + +/datum/ai_behavior/basic_melee_attack/human_npc/bounty/gorilla/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) + var/mob/living/carbon/fighter = controller.pawn + var/atom/target = controller.blackboard[target_key] + if(isliving(target) && !human_npc_held_melee_weapon(fighter)) + if(!bounty_gorilla_use_hand(fighter, bounty_gorilla_plain_hand(fighter))) + return AI_BEHAVIOR_DELAY + return ..() + +// ===== THE PISTON PUNCH ===== + +/** + * The piston punch: a fist drawn back in an orange outline over the lit tile for BOUNTY_GORILLA_PUNCH_TELL, + * then a loaded fist's punch at whoever still stands there, the implant's own. It also runs the gorilla's + * fighting each planning tick (plan()): the grab first when it can start, then this, else its ordinary blows. + */ +/datum/bounty_chrome_move/gorilla_punch + piece_key = BOUNTY_CHROME_GORILLA + name = "piston punch" + tell_time = BOUNTY_GORILLA_PUNCH_TELL + tell_color = BOUNTY_GORILLA_COLOR + tell_sound = 'sound/machines/piston/piston_raise.ogg' + max_range = 1 + // A mini-boss's own blows are the implant's punches already: the grab is the move it gets + boss_usable = FALSE + /// world.time its first piston punch of this fight may start + var/opens_at = 0 + /// world.time this fight started + var/fight_started_at = 0 + /// The tile the fist is aimed at, through the tell + var/turf/aimed_turf + +/datum/bounty_chrome_move/gorilla_punch/detach() + aimed_turf = null + return ..() + +/datum/bounty_chrome_move/gorilla_punch/on_fight_start(atom/target) + fight_started_at = world.time + opens_at = world.time + BOUNTY_GORILLA_PUNCH_OPENING + +/datum/bounty_chrome_move/gorilla_punch/can_start(atom/target) + var/mob/living/victim = target + if(!isliving(victim) || !isturf(victim.loc) || !owner.Adjacent(victim) || bounty_gorilla_held_by_another(victim, owner) || HAS_TRAIT(owner, TRAIT_HANDS_BLOCKED)) + return FALSE + if(!..()) + return FALSE + if(!bounty_gorilla_loaded_arm(owner)) + return FALSE + return bounty_gorilla_safe_behind(owner, victim, BOUNTY_GORILLA_KNOCKBACK_RANGE) + +/datum/bounty_chrome_move/gorilla_punch/plan(datum/ai_controller/controller, atom/target) + var/datum/component/bounty_chrome/chrome = owner.GetComponent(/datum/component/bounty_chrome) + if(!chrome) + return FALSE + var/datum/bounty_chrome_move/gorilla_grab/grab = chrome.move_of(/datum/bounty_chrome_move/gorilla_grab) + if(grab) + if(grab.held_ref) + // It is holding someone: its grab's own clock throws the punches + return TRUE + if(grab.may_go_now() && grab.can_start(target) && chrome.start_move(grab, target)) + return TRUE + if(grab.pending(target)) + // The fist it just used is the one the face punches come from: it closes in for the grab and throws nothing meanwhile + controller.queue_behavior(/datum/ai_behavior/human_npc_close_in, BB_BASIC_MOB_CURRENT_TARGET, 1) + return TRUE + if(bounty_melee_chrome_may_start(owner, opens_at, fight_started_at) && can_start(target) && chrome.start_move(src, target)) + return TRUE + // Another piece's move that plans its own behaviours, and comes after this one, plans first: ending the planning here would starve it + var/after = chrome.moves.Find(src) + for(var/index in after + 1 to length(chrome.moves)) + var/datum/bounty_chrome_move/later = chrome.moves[index] + if(later.piece_key != BOUNTY_CHROME_GORILLA && later.plan(controller, target)) + return TRUE + // Another piece's move is ready: the core starts it, so planning goes on to it + if(world.time >= chrome.next_move_at) + for(var/datum/bounty_chrome_move/other as anything in chrome.moves) + if(other.action_type && other.can_start(target)) + return FALSE + // Its ordinary blows, with a plain fist. Anything in its hands fights by the style's own melee. + if(!isliving(target) || human_npc_held_melee_weapon(owner)) + return FALSE + controller.queue_behavior(/datum/ai_behavior/basic_melee_attack/human_npc/bounty/gorilla, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + return TRUE + +/datum/bounty_chrome_move/gorilla_punch/tell_text(atom/target) + return "[owner] draws back a chrome fist!" + +/datum/bounty_chrome_move/gorilla_punch/tell(atom/target) + ..() + aimed_turf = get_turf(target) + if(aimed_turf) + add_mark(new /obj/effect/temp_visual/bounty_boss_mark(aimed_turf, tell_time + 1)) + +/datum/bounty_chrome_move/gorilla_punch/effect(atom/target) + var/turf/spot = aimed_turf + aimed_turf = null + var/mob/living/victim = target + if(!isliving(victim) || QDELETED(victim) || get_turf(victim) != spot || !owner.Adjacent(victim)) + // They stepped off the lit tile + if(spot && owner.Adjacent(spot)) + owner.face_atom(spot) + owner.do_attack_animation(spot) + playsound(owner, 'sound/items/weapons/punchmiss.ogg', 50, TRUE) + owner.visible_message(span_warning("[owner]'s fist swings through empty air.")) + return FALSE + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = bounty_gorilla_loaded_arm(owner) + if(!arm || !bounty_gorilla_safe_behind(owner, victim, BOUNTY_GORILLA_KNOCKBACK_RANGE)) + return FALSE + if(!bounty_gorilla_use_hand(owner, bounty_gorilla_hand(owner, arm))) + return FALSE + owner.zone_selected = BODY_ZONE_CHEST + return !!owner.ai_controller?.ai_interact(target = victim, combat_mode = TRUE) + +/// Whether someone other than `npc` holds `victim` fast: it doesn't swing at someone who can't step off the lit tile, or grab them from another +/proc/bounty_gorilla_held_by_another(mob/living/victim, mob/living/npc) + return !!victim.pulledby && victim.pulledby != npc && victim.pulledby.grab_state >= GRAB_AGGRESSIVE + +// ===== THE GRAB ===== + +/** + * The grab and pummel. Its tell is a hand on them (tg's pull) and an orange ring under them for + * BOUNTY_GORILLA_GRAB_TELL; then tg's aggressive grab, two face punches with a plain fist and the loaded + * fist's hurl, each a click apart, driven by its own clock (pummel()), not the AI's planning. A mini-boss + * gets it as an ability in its rotation, busy while it holds on. + */ +/datum/bounty_chrome_move/gorilla_grab + piece_key = BOUNTY_CHROME_GORILLA + name = "grab" + tell_time = BOUNTY_GORILLA_GRAB_TELL + tell_color = BOUNTY_GORILLA_COLOR + tell_sound = 'sound/machines/piston/piston_lower.ogg' + max_range = 1 + /// world.time its next grab may start (its opener, then BOUNTY_GORILLA_GRAB_COOLDOWN) + var/grab_ready_at = 0 + /// world.time this fight started + var/fight_started_at = 0 + /// Who its hand is on through the tell + var/datum/weakref/reach_ref + /// Who it holds fast now + var/datum/weakref/held_ref + /// Face punches thrown in this hold + var/punches = 0 + /// Goes up with every hold and every let-go, so a stale timer does nothing + var/hold_serial = 0 + /// The next click of the hold, and the hold's own clock + var/step_timer + var/hold_timer + /// A mini-boss's busy serial while it holds on + var/boss_serial = 0 + /// REF() of someone it let go of -> world.time it may grab them again + var/list/guard + +/datum/bounty_chrome_move/gorilla_grab/attach(mob/living/carbon/human/npc/npc) + . = ..() + // A mini-boss runs it through its own rotation; the core wraps only moves with an implant action, so this one is wrapped here + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = npc + if(istype(boss) && !boss_ability) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability = new(boss) + ability.set_move(src) + ability.Grant(boss) + boss.boss_abilities += ability + +/datum/bounty_chrome_move/gorilla_grab/detach() + let_go() + reach_ref = null + guard = null + return ..() + +/datum/bounty_chrome_move/gorilla_grab/on_fight_start(atom/target) + fight_started_at = world.time + grab_ready_at = max(grab_ready_at, world.time + BOUNTY_GORILLA_GRAB_OPENING) + +/datum/bounty_chrome_move/gorilla_grab/on_fight_end() + let_go() + +/datum/bounty_chrome_move/gorilla_grab/on_downed() + let_go() + +/datum/bounty_chrome_move/gorilla_grab/on_death() + let_go() + +/datum/bounty_chrome_move/gorilla_grab/on_emp(severity) + // Its chrome glitching, it lets go + let_go() + +/datum/bounty_chrome_move/gorilla_grab/plan(datum/ai_controller/controller, atom/target) + // Holding someone, nothing else is planned: its own clock throws the punches + return !!held_ref + +/** + * Whether its other chrome lets the grab start now: past the gap after the last move fired, or straight + * after a piston punch, the fist that punch used being the one the face punches come from. + */ +/datum/bounty_chrome_move/gorilla_grab/proc/may_go_now() + var/datum/component/bounty_chrome/chrome = owner?.GetComponent(/datum/component/bounty_chrome) + if(!chrome || chrome.telling) + return FALSE + if(world.time >= chrome.next_move_at) + return TRUE + var/datum/bounty_chrome_move/gorilla_punch/punch = chrome.move_of(/datum/bounty_chrome_move/gorilla_punch) + if(!punch?.last_fired || punch.last_fired < fight_started_at) + return FALSE + return punch.last_fired > bounty_melee_chrome_last_move_at(owner, list(/datum/bounty_chrome_move/gorilla_punch)) + +/datum/bounty_chrome_move/gorilla_grab/can_start(atom/target) + var/mob/living/victim = target + if(held_ref || world.time < grab_ready_at || world.time < owner.next_move || HAS_TRAIT(owner, TRAIT_HANDS_BLOCKED) || !may_grab(victim)) + return FALSE + if(!..()) + return FALSE + if(!bounty_gorilla_fists_for_grab(owner)) + return FALSE + return bounty_gorilla_safe_behind(owner, victim, BOUNTY_GORILLA_HURL_RANGE) + +/// Whether a grab at `target` could follow as soon as it is beside them: its fists and its other chrome allow one now, and they are someone it may grab +/datum/bounty_chrome_move/gorilla_grab/proc/pending(atom/target) + if(held_ref || world.time < grab_ready_at || !may_go_now() || !bounty_gorilla_fists_for_grab(owner)) + return FALSE + var/mob/living/victim = target + return may_grab(victim, need_adjacent = FALSE) && bounty_ai_dist(owner, victim) <= 2 && bounty_chrome_can_act(owner) + +/** + * Whether it may take hold of `victim`: someone beside it (unless `need_adjacent` is FALSE), awake and on + * their feet on a tile of their own, whom tg's grab can take hold of and tighten on, not held by anyone + * else, and not someone it let go of in the last BOUNTY_GORILLA_GRAB_GUARD. + */ +/datum/bounty_chrome_move/gorilla_grab/proc/may_grab(mob/living/victim, need_adjacent = TRUE) + if(!isliving(victim) || QDELETED(victim) || victim == owner || !isturf(victim.loc) || victim.buckled || victim.anchored) + return FALSE + if(victim.stat != CONSCIOUS || victim.body_position == LYING_DOWN || (need_adjacent && !owner.Adjacent(victim))) + return FALSE + // tg's grab never tightens on these (grabbedby()) + if(issilicon(victim) || !(victim.status_flags & CANPUSH) || HAS_TRAIT(victim, TRAIT_PUSHIMMUNE)) + return FALSE + if(victim.pulledby && victim.pulledby != owner) + return FALSE + if(LAZYACCESS(guard, REF(victim)) > world.time) + return FALSE + return victim.can_be_pulled(owner, owner.pull_force) + +/datum/bounty_chrome_move/gorilla_grab/tell_text(atom/target) + return "[owner] reaches for [target] with both chrome hands!" + +/datum/bounty_chrome_move/gorilla_grab/tell(atom/target) + ..() + grab_ready_at = world.time + BOUNTY_GORILLA_GRAB_COOLDOWN + var/turf/spot = get_turf(target) + if(spot) + add_mark(new /obj/effect/temp_visual/bounty_boss_mark(spot, tell_time + 1, BOUNTY_GORILLA_MARK_MATRIX, "target_circle")) + var/mob/living/victim = target + if(!isliving(victim)) + return + // Its hand on them: tg's pull, a player's first ctrl-click. It hurts nobody, and a step or Resist breaks it. + reach_ref = WEAKREF(victim) + grab_click(victim) + +/// A player's ctrl-click on `victim`: tg's grab, a pull the first time and the grip tightened the next +/datum/bounty_chrome_move/gorilla_grab/proc/grab_click(mob/living/victim) + return !!owner.ai_controller?.ai_interact(target = victim, modifiers = list(CTRL_CLICK = TRUE)) + +/datum/bounty_chrome_move/gorilla_grab/cancel(reason) + // Cut short with its hand on them: it lets go + var/mob/living/victim = reach_ref?.resolve() + reach_ref = null + if(victim && !QDELETED(owner) && owner.pulling == victim && !held_ref) + owner.stop_pulling() + +/datum/bounty_chrome_move/gorilla_grab/effect(atom/target) + var/mob/living/victim = reach_ref?.resolve() + reach_ref = null + if(!isliving(victim) || victim != target || owner.pulling != victim) + return FALSE + if(!may_hold(victim)) + owner.stop_pulling() + return FALSE + // They stayed: the grip tightens, the second ctrl-click + grab_click(victim) + if(!holding(victim)) + if(owner.pulling == victim) + owner.stop_pulling() + return FALSE + start_hold(victim) + return TRUE + +/// Whether it holds `victim` fast now: tg's aggressive grab, its own +/datum/bounty_chrome_move/gorilla_grab/proc/holding(mob/living/victim) + return !QDELETED(owner) && !QDELETED(victim) && owner.pulling == victim && owner.grab_state >= GRAB_AGGRESSIVE + +/// Whether `victim` is someone it goes on holding: awake, on their feet and beside it +/datum/bounty_chrome_move/gorilla_grab/proc/may_hold(mob/living/victim) + return !QDELETED(victim) && victim.stat == CONSCIOUS && victim.body_position != LYING_DOWN && isturf(victim.loc) && owner.Adjacent(victim) + +/// Whether the hold goes on: it holds them fast, can still act with its hands, isn't cut off as a mini-boss, and they are still someone it holds +/datum/bounty_chrome_move/gorilla_grab/proc/hold_ok(mob/living/victim) + if(!holding(victim) || !may_hold(victim)) + return FALSE + if(!bounty_chrome_can_act(owner) || HAS_TRAIT(owner, TRAIT_HANDS_BLOCKED)) + return FALSE + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + if(istype(boss) && (boss.boss_busy != BOUNTY_GORILLA_BOSS_BUSY || boss.boss_busy_serial != boss_serial)) + return FALSE + return TRUE + +/// It holds `victim` fast: it stands still, and its clock throws the punches a click apart +/datum/bounty_chrome_move/gorilla_grab/proc/start_hold(mob/living/victim) + held_ref = WEAKREF(victim) + punches = 0 + hold_serial++ + // Struggled free, pulled away by a friend, thrown by the finisher: tg lets go, and it hears of it + RegisterSignal(owner, COMSIG_ATOM_NO_LONGER_PULLING, PROC_REF(on_no_longer_pulling)) + RegisterSignals(owner, list(SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), SIGNAL_ADDTRAIT(TRAIT_FLOORED), SIGNAL_ADDTRAIT(TRAIT_HANDS_BLOCKED), SIGNAL_ADDTRAIT(TRAIT_RESTRAINED)), PROC_REF(on_disabled)) + ADD_TRAIT(owner, TRAIT_IMMOBILIZED, BOUNTY_GORILLA_TRAIT) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + if(istype(boss)) + boss.boss_next_ability_at = max(boss.boss_next_ability_at, world.time + BOUNTY_GORILLA_HOLD_MAX) + boss_serial = boss.boss_set_busy(BOUNTY_GORILLA_BOSS_BUSY, BOUNTY_GORILLA_HOLD_MAX + 1 SECONDS) + hold_timer = addtimer(CALLBACK(src, PROC_REF(hold_expired), hold_serial), BOUNTY_GORILLA_HOLD_MAX, TIMER_STOPPABLE | TIMER_DELETE_ME) + next_click() + +/// Its next click of the hold, the moment its hand is free to click again +/datum/bounty_chrome_move/gorilla_grab/proc/next_click() + deltimer(step_timer) + step_timer = addtimer(CALLBACK(src, PROC_REF(pummel), hold_serial), max(owner.next_move - world.time, 1), TIMER_STOPPABLE | TIMER_DELETE_ME) + +/** + * One click of the hold under `serial`: a punch to the face with a plain fist while any are left, then + * the loaded fist's punch, the implant's hurl. With no loaded fist yet it holds on and waits, until the + * hold's own clock lets them go. If the hold broke meanwhile it lets go and nothing lands. Returns TRUE if + * it threw a punch. + */ +/datum/bounty_chrome_move/gorilla_grab/proc/pummel(serial) + step_timer = null + if(serial != hold_serial || !held_ref) + return FALSE + var/mob/living/victim = held_ref.resolve() + if(!hold_ok(victim)) + let_go() + return FALSE + if(world.time < owner.next_move) + next_click() + return FALSE + if(punches < BOUNTY_GORILLA_PUMMEL_PUNCHES) + var/plain = bounty_gorilla_plain_hand(owner) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/plain_arm = plain && bounty_gorilla_arm_of_hand(owner, plain) + if(plain && (!plain_arm || !bounty_gorilla_loaded(plain_arm))) + punches++ + punch(victim, plain) + if(serial == hold_serial && held_ref) + next_click() + return TRUE + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/finisher = bounty_gorilla_hurl_arm(owner) + if(!finisher) + // Its loaded fist isn't back yet: it holds on + step_timer = addtimer(CALLBACK(src, PROC_REF(pummel), hold_serial), 1, TIMER_STOPPABLE | TIMER_DELETE_ME) + return FALSE + if(!bounty_gorilla_safe_behind(owner, victim, BOUNTY_GORILLA_HURL_RANGE)) + let_go() + return FALSE + punch(victim, bounty_gorilla_hand(owner, finisher)) + // The fist lands a moment after the click (GORILLA_THRUST_LANDS), and only lands as the hurl while it still holds + // them. The hurl takes them out of its hands (tg ends the pull as they fly); if anything stopped it, it lets go then. + step_timer = addtimer(CALLBACK(src, PROC_REF(after_hurl), hold_serial), GORILLA_THRUST_LANDS + 1, TIMER_STOPPABLE | TIMER_DELETE_ME) + return TRUE + +/// The hurl's fist under `serial` has landed: if it still holds them, something stopped the hurl, and it lets go +/datum/bounty_chrome_move/gorilla_grab/proc/after_hurl(serial) + step_timer = null + if(serial == hold_serial && held_ref) + let_go() + +/// A punch to `victim`'s face with hand `index`: a player's click in combat mode, so tg's punch, or the implant's if that fist is loaded +/datum/bounty_chrome_move/gorilla_grab/proc/punch(mob/living/victim, index) + if(!bounty_gorilla_use_hand(owner, index)) + return FALSE + owner.zone_selected = BODY_ZONE_HEAD + return !!owner.ai_controller?.ai_interact(target = victim, combat_mode = TRUE) + +/// The hold's own clock under `serial` ran out: it lets go +/datum/bounty_chrome_move/gorilla_grab/proc/hold_expired(serial) + hold_timer = null + if(serial == hold_serial && held_ref) + let_go() + +/// tg let go of someone it pulled (inside stop_pulling()). If it was whoever it held, the hold is over. Must not sleep. +/datum/bounty_chrome_move/gorilla_grab/proc/on_no_longer_pulling(datum/source, atom/movable/was_pulling) + SIGNAL_HANDLER + if(was_pulling == held_ref?.resolve()) + end_hold() + +/// Stunned, knocked down, cuffed or its hands tied up mid-hold: it lets go. Inside a signal handler. +/datum/bounty_chrome_move/gorilla_grab/proc/on_disabled(datum/source) + SIGNAL_HANDLER + let_go() + +/// Lets go of whoever it holds, or has its hand on (tg's stop_pulling()). Safe at any time. +/datum/bounty_chrome_move/gorilla_grab/proc/let_go() + var/mob/living/victim = held_ref?.resolve() || reach_ref?.resolve() + end_hold() + reach_ref = null + if(victim && !QDELETED(owner) && owner.pulling == victim) + owner.stop_pulling() + +/// The hold is over: it may move again, a mini-boss is free, and whoever it held isn't grabbed by it again for a while +/datum/bounty_chrome_move/gorilla_grab/proc/end_hold() + if(!held_ref) + return + var/mob/living/victim = held_ref.resolve() + held_ref = null + punches = 0 + hold_serial++ + deltimer(step_timer) + step_timer = null + deltimer(hold_timer) + hold_timer = null + if(owner) + UnregisterSignal(owner, list(COMSIG_ATOM_NO_LONGER_PULLING, SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), SIGNAL_ADDTRAIT(TRAIT_FLOORED), SIGNAL_ADDTRAIT(TRAIT_HANDS_BLOCKED), SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) + REMOVE_TRAIT(owner, TRAIT_IMMOBILIZED, BOUNTY_GORILLA_TRAIT) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + if(istype(boss) && boss_serial && boss.boss_busy == BOUNTY_GORILLA_BOSS_BUSY && boss.boss_busy_serial == boss_serial) + boss.boss_clear_busy(boss_serial) + boss_serial = 0 + if(!victim) + return + // Forget the guards that are over, then guard this one + for(var/key in guard) + if(guard[key] <= world.time) + guard -= key + LAZYSET(guard, REF(victim), world.time + BOUNTY_GORILLA_GRAB_GUARD) + +// ===== DOORS ===== + +/** + * Doors. Whoever it fights got behind a closed airlock near it: it goes to the door and puts a hand on it + * out of combat mode, which the arms' set bonus turns into the implant's own pry (tg's door_pryer). Looked + * at every Life tick (on_tick()), since the one it fought may no longer be its target once out of sight. + */ +/datum/bounty_chrome_move/gorilla_doors + piece_key = BOUNTY_CHROME_GORILLA + name = "door pry" + boss_usable = FALSE + /// Who it was last fighting, and when it last saw them + var/datum/weakref/quarry_ref + var/quarry_seen_at = 0 + /// REF() of a door it went for -> world.time it may go for it again + var/list/tried + +/datum/bounty_chrome_move/gorilla_doors/detach() + quarry_ref = null + tried = null + return ..() + +/datum/bounty_chrome_move/gorilla_doors/plan(datum/ai_controller/controller, atom/target) + note_quarry(target) + return FALSE + +/datum/bounty_chrome_move/gorilla_doors/on_fight_end() + quarry_ref = null + +/datum/bounty_chrome_move/gorilla_doors/on_tick(seconds_per_tick, fighting, atom/target) + if(!fighting) + quarry_ref = null + return + note_quarry(target) + try_door() + +/// Remembers `target` as who it fights while it can see them +/datum/bounty_chrome_move/gorilla_doors/proc/note_quarry(atom/target) + if(!QDELETED(target) && (isliving(target) || ismecha(target)) && bounty_ai_can_see(owner, target, BOUNTY_GORILLA_CHASE_RANGE)) + quarry_ref = WEAKREF(target) + quarry_seen_at = world.time + +/// Whether the arms' set bonus is working: both arms in and synced, Gorilla or Brawler, so it can force doors +/datum/bounty_chrome_move/gorilla_doors/proc/can_pry() + return gorilla_synced(owner) || brawler_synced(owner) + +/** + * Whoever it is after and can't get at, its target out of sight or behind a closed glass door, or someone + * it lost sight of in the last BOUNTY_GORILLA_QUARRY_MEMORY: if a closed airlock near it is in the way, it + * goes for it, a step to it if need be, then a hand on it. Returns TRUE if it did something. + */ +/datum/bounty_chrome_move/gorilla_doors/proc/try_door() + if(!bounty_chrome_can_act(owner) || QDELETED(owner.ai_controller) || LAZYLEN(owner.do_afters) || HAS_TRAIT(owner, TRAIT_IMMOBILIZED) || HAS_TRAIT(owner, TRAIT_HANDS_BLOCKED) || !can_pry()) + return FALSE + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + if(istype(boss) && boss.boss_busy) + return FALSE + var/datum/component/bounty_chrome/chrome = owner.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/gorilla_grab/grab = chrome?.move_of(/datum/bounty_chrome_move/gorilla_grab) + if(chrome?.telling || grab?.held_ref) + return FALSE + var/atom/quarry = bounty_chrome_target(owner) + var/in_sight = FALSE + if(!QDELETED(quarry)) + in_sight = bounty_ai_can_see(owner, quarry, BOUNTY_GORILLA_CHASE_RANGE) + if(in_sight && owner.Adjacent(quarry)) + return FALSE + else + quarry = quarry_ref?.resolve() + if(QDELETED(quarry) || world.time > quarry_seen_at + BOUNTY_GORILLA_QUARRY_MEMORY) + return FALSE + var/turf/goal = get_turf(quarry) + if(!goal || goal.z != owner.z || get_dist(owner, goal) > BOUNTY_GORILLA_CHASE_RANGE || !bounty_ai_may_hit(owner, quarry)) + return FALSE + var/obj/machinery/door/airlock/door = find_door(goal, in_sight) + if(!door) + return FALSE + var/turf/here = get_turf(owner) + var/turf/door_turf = get_turf(door) + if(get_dist(here, door_turf) == 1 && (get_dir(here, door_turf) in GLOB.cardinals)) + LAZYSET(tried, REF(door), world.time + BOUNTY_GORILLA_DOOR_RETRY) + if(!human_npc_ready_empty_hand(owner)) + return FALSE + owner.face_atom(door) + // A hand on the door out of combat mode: the set bonus pries it (tg's door_pryer) + INVOKE_ASYNC(owner.ai_controller, TYPE_PROC_REF(/datum/ai_controller, ai_interact), door, FALSE) + return TRUE + return step_to_door(door) + +/** + * The closed airlock within BOUNTY_GORILLA_DOOR_REACH of it that stands between it and `goal`, nearest + * first: on the straight line to `goal` when it can see there (a glass door), or else nearer `goal` than + * it is and within BOUNTY_GORILLA_BEHIND_RANGE of it. Only one it may force (may_force()). + */ +/datum/bounty_chrome_move/gorilla_doors/proc/find_door(turf/goal, in_sight) + var/turf/here = get_turf(owner) + var/list/line = in_sight ? get_line(here, goal) : null + var/to_goal = get_dist(here, goal) + var/obj/machinery/door/airlock/best + var/best_score = INFINITY + for(var/turf/spot as anything in RANGE_TURFS(BOUNTY_GORILLA_DOOR_REACH, here)) + var/obj/machinery/door/airlock/door = locate() in spot + if(!door) + continue + if(in_sight) + if(!(spot in line)) + continue + else if(get_dist(spot, goal) >= to_goal || get_dist(spot, goal) > BOUNTY_GORILLA_BEHIND_RANGE) + continue + if(!may_force(door)) + continue + var/score = get_dist(here, spot) * 10 + get_dist(spot, goal) + if(score < best_score) + best = door + best_score = score + return best + +/** + * Whether it may go at `door`: shut and not bolted, welded or sealed (the implant won't force those), not + * one it went for a moment ago, on its side's own ground where it may break things + * (environment_damage_allowed(): never a ship, a hangar, an outpost or a trader outpost), and one that lets + * no air out when it opens. + */ +/datum/bounty_chrome_move/gorilla_doors/proc/may_force(obj/machinery/door/airlock/door) + if(QDELETED(door) || !door.density || door.operating || door.locked || door.welded || door.seal) + return FALSE + // A trader outpost's doors refuse the pry (hyperviolence_gorilla/gorilla_pry.dm) + if(gorilla_pry_refused(door)) + return FALSE + if(LAZYACCESS(tried, REF(door)) > world.time) + return FALSE + var/mob/living/carbon/human/npc/bounty_criminal/side = bounty_ai_side_of(owner) + if(!side || !side.environment_damage_allowed(get_turf(door))) + return FALSE + return bounty_gorilla_door_holds_air(door) + +/// One step to a free side of `door` beside it, on its side's leash. Returns TRUE if it moved. +/datum/bounty_chrome_move/gorilla_doors/proc/step_to_door(obj/machinery/door/airlock/door) + var/turf/here = get_turf(owner) + var/turf/door_turf = get_turf(door) + for(var/direction in GLOB.cardinals) + var/turf/beside = get_step(door_turf, direction) + if(!beside || get_dist(here, beside) != 1) + continue + if(bounty_ai_step(owner, beside)) + owner.face_atom(door) + return TRUE + return FALSE + +/** + * Whether opening `door` lets no air out: none of its open sides is space, open space or a drop, and the + * pressures on them are within BOUNTY_GORILLA_PRESSURE_GAP of each other. + */ +/proc/bounty_gorilla_door_holds_air(obj/machinery/door/door) + var/turf/spot = get_turf(door) + if(!spot) + return FALSE + var/lowest = INFINITY + var/highest = 0 + var/sides = 0 + for(var/direction in GLOB.cardinals) + var/turf/beside = get_step(spot, direction) + if(!beside || isclosedturf(beside)) + continue + if(isspaceturf(beside) || isopenspaceturf(beside) || isgroundlessturf(beside)) + return FALSE + var/datum/gas_mixture/air = beside.return_air() + var/pressure = air ? air.return_pressure() : 0 + lowest = min(lowest, pressure) + highest = max(highest, pressure) + sides++ + return sides >= 2 && highest - lowest <= BOUNTY_GORILLA_PRESSURE_GAP + +#undef BOUNTY_GORILLA_PUNCH_TELL +#undef BOUNTY_GORILLA_GRAB_TELL +#undef BOUNTY_GORILLA_PUNCH_OPENING +#undef BOUNTY_GORILLA_GRAB_OPENING +#undef BOUNTY_GORILLA_GRAB_COOLDOWN +#undef BOUNTY_GORILLA_GRAB_GUARD +#undef BOUNTY_GORILLA_PUMMEL_PUNCHES +#undef BOUNTY_GORILLA_HOLD_MAX +#undef BOUNTY_GORILLA_PUMMEL_FIST_LEFT +#undef BOUNTY_GORILLA_HURL_RANGE +#undef BOUNTY_GORILLA_KNOCKBACK_RANGE +#undef BOUNTY_GORILLA_DOOR_REACH +#undef BOUNTY_GORILLA_BEHIND_RANGE +#undef BOUNTY_GORILLA_CHASE_RANGE +#undef BOUNTY_GORILLA_QUARRY_MEMORY +#undef BOUNTY_GORILLA_DOOR_RETRY +#undef BOUNTY_GORILLA_PRESSURE_GAP +#undef BOUNTY_GORILLA_COLOR +#undef BOUNTY_GORILLA_MARK_MATRIX +#undef BOUNTY_GORILLA_TRAIT +#undef BOUNTY_GORILLA_BOSS_BUSY diff --git a/voidcrew/modules/bounties/chrome/bounty_chrome_mantis.dm b/voidcrew/modules/bounties/chrome/bounty_chrome_mantis.dm new file mode 100644 index 00000000000..d62e8810a72 --- /dev/null +++ b/voidcrew/modules/bounties/chrome/bounty_chrome_mantis.dm @@ -0,0 +1,354 @@ +/** + * # Bounty chrome: Mantis Blades + * + * Owner: C2 (Mantis Blades and Gorilla Arms). Built on the chrome core, bounty_chrome.dm. + * + * The player's Mantis Blades (voidcrew/modules/cyberware/ware_military_arms.dm), the real pair of forearm + * housings, in a criminal or companion who fights up close (the piece rolls only on brawlers, knife and + * club fighters). The NPC uses them the way a player does, through the housings' own buttons: + * - Blades out (/datum/bounty_chrome_move/mantis_blades). Once its fight starts it presses each housing's + * button, and the blade comes out into that hand with the implant's own sound and line. From then on the + * blades are its weapon: its melee swings the strongest thing it holds, and a hardlight blade's force, + * edge and wound bonus are the blade's own, so its cuts are tg's slash wounds and bleed as those do. A + * knife in that hand goes back in its pocket first. A bat has nowhere to go on a body, so that arm keeps + * the bat and the other arm's blade does the work. + * - The blades go back in when the fight is over, or it goes down, is cuffed or gives up: the button + * again, or the implant's own stow when it is past pressing buttons. An EMP stows them by itself (the + * implant), and they stay in through the reboot. + * - They never leave its body. While out a blade is NODROP and indestructible (the toolkit's Extend()), + * and it is locked gear like the rest of its kit (human_npc_gear.dm): it can't be disarmed, stripped or + * dropped, and one forced out of its hand is deleted. When it dies, or a housing is cut or taken out of + * it, the housing burns out to scrap and its blade goes with it (the human NPC base). + * - The lunge (/datum/bounty_chrome_move/mantis_lunge). With someone two to five tiles off in a clear + * line, it turns its blades on them in a blue outline and a blue line lights the floor up to them, then + * it presses a housing's own Mantis Lunge on them: the implant's telegraph, dash, cuts and knockdown and + * its 20 second cooldown, all as written. The dash runs down the line it showed (the implant's dash_aim), + * so a hunter who steps off it is missed. The AI only picks when: never at someone already on the floor, + * never down a line with anything solid or anyone standing on it (the dash would fall short), and never where the dash + * could carry it off its side's site or past a drop, lava or space (the implant moves its bearer by + * force, so the AI looks first). The first lunge may come a second into a fight. + */ + +/// The furthest any model's lunge reaches, in tiles. The housing's own lunge_range (ware_military_arms.dm) +/// decides the real reach (can_start()). +#define BOUNTY_MANTIS_LUNGE_RANGE 5 +/// The closest a target may be for a lunge: right beside them it is a swing, not a lunge +#define BOUNTY_MANTIS_LUNGE_MIN 2 +/// The tell before the lunge, the line lit on the floor; the implant's own telegraph follows it +#define BOUNTY_MANTIS_LUNGE_TELL (0.9 SECONDS) +/// The first lunge of a fight may start this long after the fight does +#define BOUNTY_MANTIS_OPENING (1 SECONDS) +/// A hand it couldn't empty for a blade is left alone this long before it tries again +#define BOUNTY_MANTIS_STOW_RETRY (10 SECONDS) +/// The tell's outline, in the hardlight blade's blue +#define BOUNTY_MANTIS_COLOR "#6cb8ff" +/// The line on the floor: the mark art is pure red, which a plain colour only darkens, so a matrix turns it the blade's blue +#define BOUNTY_MANTIS_MARK_MATRIX list(0.42, 0.72, 1, 0, 0, 0, 0, 0, 0) +/// How long the line stays lit once the lunge is pressed: the implant's 0.3 second wind-up and the run itself +#define BOUNTY_MANTIS_LINE_HOLD (0.5 SECONDS) + +// ===== HELPERS ===== + +/// The Mantis Blade housings in `npc`'s arms +/proc/bounty_mantis_housings(mob/living/carbon/npc) + . = list() + if(QDELETED(npc)) + return + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing in npc.organs) + . += housing + +/// Whether `housing`'s chrome is running, so its blade can come out +/proc/bounty_mantis_running(obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing) + var/datum/component/cyberware/chrome = housing?.GetComponent(/datum/component/cyberware) + return !!chrome?.is_running() + +/// `housing`'s own button, the one that puts its blade out and away +/proc/bounty_mantis_toggle(obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing) + return locate(/datum/action/item_action/organ_action/toggle/toolkit) in housing?.actions + +/// The hands (RIGHT_HANDS or LEFT_HANDS) `housing`'s blade comes out into +/proc/bounty_mantis_side(obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing) + return housing.zone == BODY_ZONE_R_ARM ? RIGHT_HANDS : LEFT_HANDS + +/// The blades `housing` keeps, out or in (the toolkit's items_list) +/proc/bounty_mantis_blades(obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing) + . = list() + for(var/datum/weakref/blade_ref as anything in housing?.items_list) + var/obj/item/blade = blade_ref?.resolve() + if(!QDELETED(blade)) + . += blade + +/** + * Puts every blade of `npc`'s that is out back in its housing: the housing's own button, or, when it is + * past pressing buttons (down in crit), the implant's own stow. Doesn't sleep. + */ +/proc/bounty_mantis_put_away(mob/living/carbon/npc) + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in bounty_mantis_housings(npc)) + if(!housing.blade_extended()) + continue + var/datum/action/toggle = bounty_mantis_toggle(housing) + if(toggle?.IsAvailable()) + toggle.Trigger() + if(housing.blade_extended()) + housing.Retract() + +/// Whether a dash must never cross `spot`: open space or a drop, lava, a chasm, space +/proc/bounty_mantis_drop(turf/spot) + return isspaceturf(spot) || isopenspaceturf(spot) || isgroundlessturf(spot) || islava(spot) || ischasm(spot) + +/// world.time `npc` last fired any chrome move, leaving out moves of `except_types`, or 0 if none has fired +/proc/bounty_melee_chrome_last_move_at(mob/living/carbon/human/npc/npc, list/except_types) + . = 0 + var/datum/component/bounty_chrome/chrome = npc?.GetComponent(/datum/component/bounty_chrome) + for(var/datum/bounty_chrome_move/move as anything in chrome?.moves) + if(except_types && is_type_in_list(move, except_types)) + continue + . = max(., move.last_fired) + +/** + * Whether `npc`'s other chrome lets a move whose own opener is at `opens_at` start now: past the gap the + * last move to fire left (the component's next_move_at), or, with none fired since the fight started at + * `fight_started_at`, past the move's own opener, which comes before the core's (BOUNTY_CHROME_OPENING). + */ +/proc/bounty_melee_chrome_may_start(mob/living/carbon/human/npc/npc, opens_at, fight_started_at) + if(world.time < opens_at) + return FALSE + var/datum/component/bounty_chrome/chrome = npc?.GetComponent(/datum/component/bounty_chrome) + if(!chrome || chrome.telling) + return FALSE + if(world.time >= chrome.next_move_at) + return TRUE + return bounty_melee_chrome_last_move_at(npc) < fight_started_at + +// ===== BLADES OUT ===== + +/** + * The blades, out for a fight and away after it. It plans nothing of its own: in a fight it presses a + * housing's button for each blade still in (plan(), and on_tick() for a mini-boss, which plans no chrome + * of its own), and out of it, down, cuffed or giving up it puts them away. + */ +/datum/bounty_chrome_move/mantis_blades + piece_key = BOUNTY_CHROME_MANTIS + name = "Mantis Blades" + // No tell: putting a blade out hurts nobody, and the implant shows and sounds it + boss_usable = FALSE + /// REF() of a housing -> world.time it may try again to empty that hand for its blade + var/list/stow_retry_at + +/datum/bounty_chrome_move/mantis_blades/attach(mob/living/carbon/human/npc/npc) + . = ..() + // A body dressed before its housings went in (a test, an admin's install) has its blades locked now, like its other gear + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in bounty_mantis_housings(npc)) + for(var/obj/item/blade as anything in bounty_mantis_blades(housing)) + npc.npc_lock_item(blade) + RegisterSignals(npc, list(SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), COMSIG_HUMAN_NPC_SURRENDERED), PROC_REF(on_out_of_it)) + +/datum/bounty_chrome_move/mantis_blades/detach() + if(owner) + UnregisterSignal(owner, list(SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), COMSIG_HUMAN_NPC_SURRENDERED)) + if(!QDELETED(owner)) + bounty_mantis_put_away(owner) + stow_retry_at = null + return ..() + +/datum/bounty_chrome_move/mantis_blades/plan(datum/ai_controller/controller, atom/target) + // In its fight and able to act: a blade out is this moment's click + if(!bounty_chrome_in_fight(owner) || !bounty_chrome_can_act(owner)) + return FALSE + return draw_one() + +/datum/bounty_chrome_move/mantis_blades/on_tick(seconds_per_tick, fighting, atom/target) + if(fighting && !blades_go_away()) + if(bounty_chrome_can_act(owner)) + draw_one() + return + bounty_mantis_put_away(owner) + +/datum/bounty_chrome_move/mantis_blades/on_fight_end() + bounty_mantis_put_away(owner) + +/datum/bounty_chrome_move/mantis_blades/on_downed() + bounty_mantis_put_away(owner) + +/datum/bounty_chrome_move/mantis_blades/on_death() + bounty_mantis_put_away(owner) + +/// Whether the blades go away for now: down in crit, cuffed, giving up or dead. A knockdown or a stun keeps them out, as it would a player's. +/datum/bounty_chrome_move/mantis_blades/proc/blades_go_away() + return QDELETED(owner) || owner.stat != CONSCIOUS || HAS_TRAIT(owner, TRAIT_CRITICAL_CONDITION) || HAS_TRAIT(owner, TRAIT_RESTRAINED) || owner.npc_surrendering + +/// Cuffed, or giving up: the blades go in. Inside a signal handler. +/datum/bounty_chrome_move/mantis_blades/proc/on_out_of_it(datum/source) + SIGNAL_HANDLER + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_mantis_put_away), owner) + +/** + * Puts out one blade that is still in, the way a player's button does: its housing's chrome running and + * its hand free. Returns TRUE if a blade came out. + */ +/datum/bounty_chrome_move/mantis_blades/proc/draw_one() + if(QDELETED(owner)) + return FALSE + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in bounty_mantis_housings(owner)) + if(housing.blade_extended() || !bounty_mantis_running(housing)) + continue + var/datum/action/toggle = bounty_mantis_toggle(housing) + if(!toggle?.IsAvailable() || !free_hand_for(housing)) + continue + toggle.Trigger() + if(housing.blade_extended()) + return TRUE + return FALSE + +/** + * Whether the hand `housing`'s blade comes out into is free, first putting away what it holds there if + * that has somewhere to go on its body (a knife into a pocket). Never drops anything. + */ +/datum/bounty_chrome_move/mantis_blades/proc/free_hand_for(obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing) + var/side = bounty_mantis_side(housing) + if(owner.get_empty_held_index_for_side(side)) + return TRUE + var/key = REF(housing) + if(world.time < LAZYACCESS(stow_retry_at, key)) + return FALSE + for(var/obj/item/held as anything in owner.get_held_items_for_side(side, all = TRUE)) + if(HAS_TRAIT(held, TRAIT_NODROP) || !held.equip_to_best_slot(owner)) + LAZYSET(stow_retry_at, key, world.time + BOUNTY_MANTIS_STOW_RETRY) + return FALSE + return !!owner.get_empty_held_index_for_side(side) + +// ===== THE LUNGE ===== + +/** + * The Mantis Lunge: the line lit on the floor and a blue outline for BOUNTY_MANTIS_LUNGE_TELL, then a + * housing's own Mantis Lunge pressed on the target, the housing with its blade out. + */ +/datum/bounty_chrome_move/mantis_lunge + piece_key = BOUNTY_CHROME_MANTIS + name = "Mantis Lunge" + action_type = /datum/action/cooldown/cyberware/mantis_lunge + tell_time = BOUNTY_MANTIS_LUNGE_TELL + tell_color = BOUNTY_MANTIS_COLOR + tell_lines = list("Hold still.", "You're mine.", "Got you now.") + max_range = BOUNTY_MANTIS_LUNGE_RANGE + min_range = BOUNTY_MANTIS_LUNGE_MIN + /// world.time its first lunge of this fight may start + var/opens_at = 0 + /// world.time this fight started + var/fight_started_at = 0 + /// The tile its tell's line ends on: the dash runs there, not to wherever the target has gone + var/turf/aimed_at + +/datum/bounty_chrome_move/mantis_lunge/on_fight_start(atom/target) + fight_started_at = world.time + opens_at = world.time + BOUNTY_MANTIS_OPENING + +/// A housing's Mantis Lunge it can press now: one whose blade is out, its chrome running and the lunge off cooldown +/datum/bounty_chrome_move/mantis_lunge/proc/lunge_action() + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in bounty_mantis_housings(owner)) + if(!housing.blade_extended()) + continue + var/datum/action/cooldown/cyberware/mantis_lunge/lunge = locate() in housing.actions + if(lunge?.owner == owner && lunge.IsAvailable()) + return lunge + return null + +/datum/bounty_chrome_move/mantis_lunge/ready() + return !!lunge_action() + +/datum/bounty_chrome_move/mantis_lunge/can_start(atom/target) + var/mob/living/victim = target + // The blades pass over someone on the floor: no lunge at them + if(!isliving(victim) || !isturf(victim.loc) || victim.body_position == LYING_DOWN) + return FALSE + if(!..()) + return FALSE + // Each model reaches as far as its own housing says + var/datum/action/cooldown/cyberware/mantis_lunge/lunge = lunge_action() + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = lunge?.organ + if(!istype(housing) || get_dist(owner, victim) > housing.lunge_range) + return FALSE + return line_clear(victim) + +/** + * Whether the implant's dash at `victim` carries it only over its own ground: nothing solid on the way + * (or it falls short), every tile on its side's leash, and no drop, lava or space beside the line either, + * since they may step aside during the tell and the dash goes where they are then. + */ +/datum/bounty_chrome_move/mantis_lunge/proc/line_clear(mob/living/victim) + var/mob/living/carbon/human/npc/bounty_criminal/side = bounty_ai_side_of(owner) + var/turf/start = get_turf(owner) + var/turf/aim = get_turf(victim) + // A companion whose criminal is gone has no ground of its own to dash over + if(!side || !start || !aim || start.z != aim.z) + return FALSE + for(var/turf/spot as anything in get_line(start, aim)) + if(spot == start) + continue + if(spot == aim) + break + // A standing body stops the dash as a wall does + if(spot.is_blocked_turf(source_atom = owner) || !side.leash_ok(spot)) + return FALSE + for(var/turf/beside as anything in RANGE_TURFS(1, spot)) + if(bounty_mantis_drop(beside)) + return FALSE + return TRUE + +/datum/bounty_chrome_move/mantis_lunge/plan(datum/ai_controller/controller, atom/target) + // Its own opener, a little before the core's: early enough to show inside a short fight + if(!bounty_melee_chrome_may_start(owner, opens_at, fight_started_at) || !can_start(target)) + return FALSE + var/datum/component/bounty_chrome/chrome = owner.GetComponent(/datum/component/bounty_chrome) + return !!chrome?.start_move(src, target) + +/datum/bounty_chrome_move/mantis_lunge/tell_text(atom/target) + return "[owner] turns [owner.p_their()] blades on [target]." + +/datum/bounty_chrome_move/mantis_lunge/tell(atom/target) + ..() + var/turf/start = get_turf(owner) + aimed_at = get_turf(target) + if(!start || !aimed_at) + return + // The way it will come, lit up to whoever it is aimed at + light_line(start, aimed_at, tell_time + 1, TRUE) + +/// Lights the floor from `start` to `aim` for `time`, kept as the tell's marks if `as_tell` +/datum/bounty_chrome_move/mantis_lunge/proc/light_line(turf/start, turf/aim, time, as_tell) + for(var/turf/spot as anything in get_line(start, aim)) + if(spot == start) + continue + var/obj/effect/mark = new /obj/effect/temp_visual/bounty_boss_mark(spot, time, BOUNTY_MANTIS_MARK_MATRIX, spot == aim ? "target_circle" : null) + if(as_tell) + add_mark(mark) + +/datum/bounty_chrome_move/mantis_lunge/effect(atom/target) + var/turf/aim = aimed_at + aimed_at = null + var/datum/action/cooldown/cyberware/mantis_lunge/lunge = lunge_action() + if(!lunge || !isliving(target) || QDELETED(target)) + return FALSE + // The dash goes down the line the tell showed + lunge.dash_aim = aim + if(!lunge.Trigger(target = target)) + lunge.dash_aim = null + return FALSE + // The line stays lit through the implant's own wind-up and the run + var/turf/start = get_turf(owner) + if(start && aim) + light_line(start, aim, BOUNTY_MANTIS_LINE_HOLD, FALSE) + return TRUE + +/datum/bounty_chrome_move/mantis_lunge/detach() + aimed_at = null + return ..() + +#undef BOUNTY_MANTIS_LUNGE_RANGE +#undef BOUNTY_MANTIS_LUNGE_MIN +#undef BOUNTY_MANTIS_LUNGE_TELL +#undef BOUNTY_MANTIS_OPENING +#undef BOUNTY_MANTIS_STOW_RETRY +#undef BOUNTY_MANTIS_COLOR +#undef BOUNTY_MANTIS_MARK_MATRIX +#undef BOUNTY_MANTIS_LINE_HOLD diff --git a/voidcrew/modules/bounties/chrome/bounty_chrome_piledriver.dm b/voidcrew/modules/bounties/chrome/bounty_chrome_piledriver.dm new file mode 100644 index 00000000000..811e2cfb7b8 --- /dev/null +++ b/voidcrew/modules/bounties/chrome/bounty_chrome_piledriver.dm @@ -0,0 +1,214 @@ +/** + * # Bounty chrome: the Meteor Piledriver + * + * Owner: C1. A criminal's Meteor Piledriver is the player's leg frame + * (/obj/item/organ/cyberimp/cyberware/piledriver, ware_legend.dm): the leap, its reach, the warning + * shadow, the 0.8 s in the air, the crush on whoever is still under it, the shockwave around it, and + * the minute's cooldown are all the implant's own, and nothing here changes them. Once it is in the + * air it comes down, as a player's leap does: shot or stunned up there, it still lands. This file is + * only how an NPC uses it (owner decision 5): + * - When: in a fight, with its target BOUNTY_PILEDRIVER_MIN_RANGE to BOUNTY_PILEDRIVER_MAX_RANGE tiles + * off and in sight (anyone closer it fights hand to hand), and a landing it can make: the target's + * own tile, or the nearest free tile beside them, that the implant itself would take (in reach, in + * sight, an open arc, a surface to land on) and that the NPC would choose: on its leash (a mini-boss + * also where its abilities may land), never space, a chasm or lava. + * - Never onto people outside its fight (C0's bystander gate, over everything the landing reaches), + * and never onto anyone already down. Checked when it decides and again when it jumps. + * - The tell: it drops into a crouch with its pistons whining and an amber glow, and a red reticle + * sits where it means to land, following its target, for BOUNTY_PILEDRIVER_CROUCH. Then the + * implant's own Meteor Leap, Trigger()ed onto the landing tile as a player's click; the implant puts + * its own warning shadow down there for the time it is in the air. + * - If the landing is gone when the crouch ends (its target got behind a wall, a bystander walked in, + * its target went down), the pistons hiss and settle and nothing fires. + * A target in a mech isn't leapt at: the landing can't reach anyone inside one. + */ + +/// Nearest a target may be for a leap, in tiles: anyone closer is fought hand to hand +#define BOUNTY_PILEDRIVER_MIN_RANGE 3 +/// Furthest a target may be for a leap, in tiles: a tile beside them stays in the implant's reach +#define BOUNTY_PILEDRIVER_MAX_RANGE 7 +/// The implant's own reach (CYBERWARE_PILEDRIVER_RANGE, ware_legend.dm) +#define BOUNTY_PILEDRIVER_REACH 8 +/// How far around the landing the implant's shockwave reaches (CYBERWARE_PILEDRIVER_IMPACT_RANGE, ware_legend.dm) +#define BOUNTY_PILEDRIVER_IMPACT 2 +/// The crouch before the leap: its tell +#define BOUNTY_PILEDRIVER_CROUCH (1 SECONDS) +/// Pixels it sinks in the crouch +#define BOUNTY_PILEDRIVER_DIP 3 +/// The glow through the crouch, piston amber +#define BOUNTY_PILEDRIVER_COLOR "#ffb347" +/// Offset source for the crouch +#define BOUNTY_PILEDRIVER_SOURCE "bounty_chrome_piledriver" + +/datum/bounty_chrome_move/piledriver + piece_key = BOUNTY_CHROME_PILEDRIVER + name = "Meteor leap" + action_type = /datum/action/cooldown/cyberware/piledriver_leap + tell_time = BOUNTY_PILEDRIVER_CROUCH + tell_color = BOUNTY_PILEDRIVER_COLOR + tell_sound = 'sound/machines/piston/piston_lower.ogg' + tell_lines = list("Heads up!", "Stay right there.", "Look up.") + area_move = TRUE + min_range = BOUNTY_PILEDRIVER_MIN_RANGE + max_range = BOUNTY_PILEDRIVER_MAX_RANGE + // Its time in the air on top of the usual gap + recover_time = 5 SECONDS + /// What the crouch is aimed at, while the reticle follows it + var/atom/movable/tracked + +/datum/bounty_chrome_move/piledriver/can_start(atom/target) + if(ismecha(target) || !..()) + return FALSE + var/turf/spot = landing_for(target) + return !isnull(spot) && !downed_in(impact_turfs(spot)) + +/datum/bounty_chrome_move/piledriver/area_turfs(atom/target) + var/turf/spot = landing_for(target) + return spot ? impact_turfs(spot) : list() + +/datum/bounty_chrome_move/piledriver/tell(atom/target) + ..() + if(QDELETED(owner)) + return + owner.add_offsets(BOUNTY_PILEDRIVER_SOURCE, z_add = -BOUNTY_PILEDRIVER_DIP) + place_aim_mark(landing_for(target)) + stop_tracking() + if(ismovable(target)) + tracked = target + RegisterSignal(tracked, COMSIG_MOVABLE_MOVED, PROC_REF(on_tracked_moved)) + RegisterSignal(tracked, COMSIG_QDELETING, PROC_REF(stop_tracking)) + +/datum/bounty_chrome_move/piledriver/tell_text(atom/target) + return "[owner] drops into a crouch, [owner.p_their()] leg pistons whining." + +/datum/bounty_chrome_move/piledriver/clear_tell() + stop_tracking() + // Only its own crouch: offsets put back while it is up in the air would drop it out of its leap's rise. No animation: the rise starts from here a moment later. + if(!QDELETED(owner) && (BOUNTY_PILEDRIVER_SOURCE in owner.offsets?[PIXEL_Z_OFFSET])) + owner.remove_offsets(BOUNTY_PILEDRIVER_SOURCE, animate = FALSE) + return ..() + +/** + * The crouch is over: it jumps at where its target stands now, as a player clicks where they see + * them, if it still may. Otherwise the pistons settle and nothing fires. + */ +/datum/bounty_chrome_move/piledriver/effect(atom/target) + var/turf/spot + if(!QDELETED(target) && !ismecha(target) && bounty_ai_may_hit(owner, target)) + spot = landing_for(target) + if(!spot || !bounty_chrome_area_clear(owner, impact_turfs(spot), target) || downed_in(impact_turfs(spot))) + settle() + return FALSE + return bounty_chrome_trigger(owner, action_type, spot) + +/// The crouch came to nothing: the pistons hiss and settle +/datum/bounty_chrome_move/piledriver/proc/settle() + if(QDELETED(owner) || owner.stat != CONSCIOUS) + return + playsound(owner, 'sound/machines/steam_hiss.ogg', 40, TRUE) + owner.visible_message(span_notice("[owner]'s leg pistons hiss and settle.")) + +/// Everything a landing on `spot` reaches: the tile, and the shockwave's ring around it +/datum/bounty_chrome_move/piledriver/proc/impact_turfs(turf/spot) + return RANGE_TURFS(BOUNTY_PILEDRIVER_IMPACT, spot) + +/// Whether anyone in `turfs` is down and still alive: it never lands on a person who is down +/datum/bounty_chrome_move/piledriver/proc/downed_in(list/turfs) + for(var/turf/spot as anything in turfs) + for(var/mob/living/person in spot) + if(person != owner && person.stat != CONSCIOUS && person.stat != DEAD) + return TRUE + return FALSE + +/** + * The tile a leap at `target` comes down on now, or null if there is none: their own tile if it may + * land there, else the free tile beside them nearest to it, never one next to where it stands. + * Geometry only: who it may jump at is can_start()'s and effect()'s. + */ +/datum/bounty_chrome_move/piledriver/proc/landing_for(atom/target) + var/turf/here = get_turf(owner) + var/turf/aim = get_turf(target) + if(!here || !aim || here.z != aim.z || !isturf(owner.loc)) + return null + var/datum/action/cooldown/cyberware/piledriver_leap/leap = bounty_chrome_action(owner, action_type) + if(!leap) + return null + if(landing_ok(here, aim, leap)) + return aim + var/turf/best + var/best_distance = INFINITY + for(var/turf/beside as anything in RANGE_TURFS(1, aim)) + var/from_here = get_dist(here, beside) + if(beside == aim || from_here < 2 || from_here >= best_distance) + continue + if(!landing_ok(here, beside, leap)) + continue + best = beside + best_distance = from_here + return best + +/** + * Whether it may land on `spot` from `here`: what the implant itself takes (in reach and in sight, a + * surface to land on, an open arc, Activate() in ware_legend.dm) and what the NPC chooses: never + * space, a chasm or lava, and only on its own ground (on_its_ground()). + */ +/datum/bounty_chrome_move/piledriver/proc/landing_ok(turf/here, turf/spot, datum/action/cooldown/cyberware/piledriver_leap/leap) + if(!spot || spot == here || get_dist(here, spot) > BOUNTY_PILEDRIVER_REACH) + return FALSE + if(isspaceturf(spot) || isopenspaceturf(spot) || islava(spot) || ischasm(spot)) + return FALSE + if(spot.is_blocked_turf(exclude_mobs = TRUE)) + return FALSE + if(!can_see(owner, spot, BOUNTY_PILEDRIVER_REACH) || leap.arc_blocker(here, spot)) + return FALSE + return on_its_ground(spot) + +/// Whether `spot` is ground it would land on: its leash (a companion its criminal's), and for a mini-boss where its abilities may land +/datum/bounty_chrome_move/piledriver/proc/on_its_ground(turf/spot) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner + if(istype(boss)) + return boss.boss_landing_ok(spot) + var/mob/living/carbon/human/npc/bounty_criminal/side = bounty_ai_side_of(owner) + if(side) + return side.leash_ok(spot) + return spot.can_cross_safely(owner) + +/// Puts the reticle on `spot`, or takes it away for a null one +/datum/bounty_chrome_move/piledriver/proc/place_aim_mark(turf/spot) + // The reticle is the only mark the crouch puts down (add_mark()) + var/obj/effect/temp_visual/bounty_boss_mark/mark + for(var/datum/weakref/mark_ref as anything in marks) + var/obj/effect/temp_visual/bounty_boss_mark/live = mark_ref.resolve() + if(!QDELETED(live)) + mark = live + break + if(!spot) + if(mark) + qdel(mark) + return + if(!mark) + // The bounty bosses' red floor mark (bounty_boss.dm) as a reticle, like every boss mark and the implant's own shadow; deleted when the crouch ends, its duration only a backstop + add_mark(new /obj/effect/temp_visual/bounty_boss_mark(spot, BOUNTY_PILEDRIVER_CROUCH * 3, null, "target_circle")) + return + mark.abstract_move(spot) + +/// Its target moved in the crouch: the reticle follows to where it would land now +/datum/bounty_chrome_move/piledriver/proc/on_tracked_moved(atom/movable/source, atom/old_loc, dir, forced) + SIGNAL_HANDLER + place_aim_mark(landing_for(source)) + +/// Stops following its target. Safe at any time. +/datum/bounty_chrome_move/piledriver/proc/stop_tracking() + SIGNAL_HANDLER + if(tracked) + UnregisterSignal(tracked, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING)) + tracked = null + +#undef BOUNTY_PILEDRIVER_MIN_RANGE +#undef BOUNTY_PILEDRIVER_MAX_RANGE +#undef BOUNTY_PILEDRIVER_REACH +#undef BOUNTY_PILEDRIVER_IMPACT +#undef BOUNTY_PILEDRIVER_CROUCH +#undef BOUNTY_PILEDRIVER_DIP +#undef BOUNTY_PILEDRIVER_COLOR +#undef BOUNTY_PILEDRIVER_SOURCE diff --git a/voidcrew/modules/bounties/chrome/bounty_chrome_redline.dm b/voidcrew/modules/bounties/chrome/bounty_chrome_redline.dm new file mode 100644 index 00000000000..16806ed7d64 --- /dev/null +++ b/voidcrew/modules/bounties/chrome/bounty_chrome_redline.dm @@ -0,0 +1,117 @@ +/// Percent of its health at or under which it burns: the AI's moment (the implant fires whenever its bearer presses it) +#define BOUNTY_REDLINE_HURT_BELOW 75 +/// Stamina lost at or over which it burns too: halfway to a stamina crit, so a baton or a disabler gets an answer before the floor +#define BOUNTY_REDLINE_WINDED_AT 50 +/// The tell: the chest speaker charging before the roar +#define BOUNTY_REDLINE_TELL (1 SECONDS) +/// How far the implant's roar reaches (CYBERWARE_REDLINE_ROAR_RANGE, ware_legend.dm): the bystander gate looks this far +#define BOUNTY_REDLINE_ROAR_RANGE 5 +/// The red of the tell's outline, its light and the eyes through the burn +#define BOUNTY_REDLINE_COLOR "#ff2a2a" +/// The eye-colour priority of the red eyes through the burn (over a cultist's) +#define BOUNTY_REDLINE_EYES_PRIORITY (EYE_COLOR_CULT_PRIORITY + 11) + +/** + * # Redline core on a bounty NPC + * + * The rage OS players buy (/obj/item/organ/cyberimp/cyberware/redline, ware_legend.dm), used the way a + * player would: once a fight has turned on them. The AI picks the moment and shows it coming; everything + * after the button press is the implant's own. + * + * - The moment: in a fight, hurt to BOUNTY_REDLINE_HURT_BELOW percent of its health or winded to + * BOUNTY_REDLINE_WINDED_AT stamina, and nobody outside the fight within the roar's reach (the bystander + * gate, owner decision 5): its own side and the site's people keep it shut. + * - The tell, BOUNTY_REDLINE_TELL: it stands still, a red outline pulses over it, the chest speaker + * crackles and glows red, and it says so. A stun, a knockdown, cuffs, crit or an EMP in the tell and + * nothing happens (the framework). + * - Then the implant's Redline Burn, Trigger()ed as a player's button: the roar (it staggers everyone in + * reach who isn't crew with the bearer, so the gate is checked again as it fires), 12 seconds of stun + * immunity, a red outline over it the whole time (the implant's, as on a player), 40% less brute and + * burn through its physiology, harder fists, 90 seconds of cooldown, then + * the crash: a hundred stamina, which floors it in stamina crit, and leaden legs. That collapse is the + * hunters' window. An EMP in the burn drops it straight into the crash, as it does a player. + * - Its eyes stay red through the burn (the implant's own lines say they flood red and drain), a look only. + */ +/datum/bounty_chrome_move/redline + piece_key = BOUNTY_CHROME_REDLINE + name = "Redline burn" + action_type = /datum/action/cooldown/cyberware/redline_burn + tell_time = BOUNTY_REDLINE_TELL + tell_color = BOUNTY_REDLINE_COLOR + tell_lines = list("That's it.", "Now you've done it.", "You want to see red?") + area_move = TRUE + +// Hurt first: it is cheap, and the bystander gate's look around (view()) only runs once it would burn +/datum/bounty_chrome_move/redline/can_start(atom/target) + return bounty_redline_hurt(owner) && ..() + +/// Whether `npc` is hurt or winded enough to burn its Redline +/proc/bounty_redline_hurt(mob/living/npc) + if(QDELETED(npc)) + return FALSE + return npc.health <= npc.maxHealth * BOUNTY_REDLINE_HURT_BELOW / 100 || npc.getStaminaLoss() >= BOUNTY_REDLINE_WINDED_AT + +// The implant's roar staggers only those outside its side (cyberware_is_ally()), so its own companions don't hold it back +/datum/bounty_chrome_move/redline/area_clear(atom/target) + return bounty_chrome_area_clear(owner, area_turfs(target), target, TRUE) + +/// The roar's reach: every tile it can see within BOUNTY_REDLINE_ROAR_RANGE, as the implant's roar looks (oview()) +/datum/bounty_chrome_move/redline/area_turfs(atom/target) + . = list() + if(QDELETED(owner)) + return + for(var/turf/spot in view(BOUNTY_REDLINE_ROAR_RANGE, owner)) + . += spot + +/datum/bounty_chrome_move/redline/tell_text(atom/target) + return "[owner]'s chest speaker crackles and starts to glow red." + +/datum/bounty_chrome_move/redline/tell(atom/target) + ..() + if(QDELETED(owner)) + return + add_mark(owner.mob_light(1.5, 1, BOUNTY_REDLINE_COLOR)) + owner.Shake(1, 0, tell_time) + +// Someone outside the fight stepped into the roar's reach during the tell: the button stays unpressed (the gate, owner decision 5) +/datum/bounty_chrome_move/redline/effect(atom/target) + if(!area_clear(target)) + return FALSE + . = ..() + if(. && owner.has_status_effect(/datum/status_effect/cyberware_redline_window)) + owner.apply_status_effect(/datum/status_effect/bounty_redline_eyes) + +/datum/bounty_chrome_move/redline/detach() + owner?.remove_status_effect(/datum/status_effect/bounty_redline_eyes) + return ..() + +/** + * Red eyes through a Redline burn on a bounty NPC: what the implant's roar and crash lines say happens + * ("eyes flood red", "the red drains out of their eyes"). A look only; it ends with the burn. + */ +/datum/status_effect/bounty_redline_eyes + id = "bounty_redline_eyes" + // Past the implant's 12 second window; it ends with the window, this is a backstop + duration = 15 SECONDS + tick_interval = 0.5 SECONDS + alert_type = null + +/datum/status_effect/bounty_redline_eyes/on_apply() + if(owner.stat == DEAD || !owner.has_status_effect(/datum/status_effect/cyberware_redline_window)) + return FALSE + bounty_chrome_red_eyes(owner, id, BOUNTY_REDLINE_EYES_PRIORITY, TRUE, BOUNTY_REDLINE_COLOR) + return TRUE + +/datum/status_effect/bounty_redline_eyes/tick(seconds_between_ticks) + if(owner.stat == DEAD || !owner.has_status_effect(/datum/status_effect/cyberware_redline_window)) + qdel(src) + +/datum/status_effect/bounty_redline_eyes/on_remove() + bounty_chrome_red_eyes(owner, id, BOUNTY_REDLINE_EYES_PRIORITY, FALSE) + +#undef BOUNTY_REDLINE_HURT_BELOW +#undef BOUNTY_REDLINE_WINDED_AT +#undef BOUNTY_REDLINE_TELL +#undef BOUNTY_REDLINE_ROAR_RANGE +#undef BOUNTY_REDLINE_COLOR +#undef BOUNTY_REDLINE_EYES_PRIORITY diff --git a/voidcrew/modules/bounties/chrome/bounty_cyberpsycho.dm b/voidcrew/modules/bounties/chrome/bounty_cyberpsycho.dm new file mode 100644 index 00000000000..6857a41546e --- /dev/null +++ b/voidcrew/modules/bounties/chrome/bounty_cyberpsycho.dm @@ -0,0 +1,348 @@ +/** + * # Bounty hunting: the cyberpsycho + * + * Owner: C6. A mini-boss kit (BOUNTY_KIT_CYBERPSYCHO) whose kit is its chrome, the rarest of the kits + * (bounty_roll_kit()). Everything but its fight is any mini-boss's: the Most Wanted posting and pay, its + * stimulants, a sealed suit where the air would kill it, capture, and in prison the Juggernaut's charge + * (its chrome stays out of prison, decision 7). + * + * Its chrome is the real implants (decisions 4 and 5), as many of the seven pieces as one body's organ + * slots take. Six go in, in this order (bounty_psycho_organs()): + * - the Redline core in the operating-system slot. The Cascade lattice needs the same slot; Redline is + * its phase two, so the lattice is the piece left out; + * - a Mantis Blade housing in its right arm and Gorilla Arms in its left, one of each pair; + * - the Meteor Piledriver in its legs, a Lazarus node by its heart, and Deadeye optics for eyes. + * Their load is 32 (10 + 3 + 3 + 8 + 5 + 3), over a body's 20. It is augmented beyond anyone else: its + * Redline core carries the Governor Delete's capacity (BOUNTY_PSYCHO_EXTRA_CAPACITY) through the real + * capacity hook, the cyberware component's capacity_bonus, which get_chrome_capacity(), the brownout + * monitor, the cradle and a chrome read all go by. It is set on the core as the core goes in, first, so + * nothing browns out on the way. Chrome taken out of it burns to scrap (the human NPC base), so no core + * with that headroom ever leaves its body. + * + * How it fights, through the boss rotation (bounty_boss.dm), one move at a time and each with its tell: + * - its blade is out of its right forearm while it fights, and its melee is that blade (Mantis Blades); + * - the Mantis Lunge down a lit line, the Meteor Leap under a reticle, and a piston punch with its Gorilla + * fist (C2's told punch, put in its rotation here, since its melee is the blade); + * - its Gorilla hand stays empty, so it can punch through glass it may break (boss_start_smash()); + * - the Redline is its phase two (psycho_burn_due()): hurt to BOUNTY_PSYCHO_BURN_HURT percent of its + * health, or winded by a stamina weapon (BOUNTY_PSYCHO_BURN_WINDED), it drops what it was winding up + * and burns: C3's tell, then the implant's stun-proof window, then its crash into stamina crit, which is + * the capture. Once a spawn. Until then it doesn't wear out and fall back; it burns instead. Its roar + * holds off for people outside its fight, never for its own companions (psycho_roar_clear()); + * - Lazarus stands it up out of crit by itself, the node's own jolt; its six minute recharge outlasts a + * fight; + * - the Deadeye optics are only its eyes: it carries no gun for the tag to steer. + * An EMP takes its chrome down on the real reboot timers, sparking (C0's malfunction look); one during the + * burn crashes it, and with its core down it tires like any other mini-boss. + */ + +/// Neural capacity its Redline core carries: the Governor Delete's (its chrome_capacity_bonus, ware_legend.dm) +#define BOUNTY_PSYCHO_EXTRA_CAPACITY 15 +/// Hurt to this percent of its health, it burns its Redline (C3's line for any carrier) +#define BOUNTY_PSYCHO_BURN_HURT 75 +/// Winded this far (stamina loss), it burns too: one disabler bolt or baton blow, so a stamina weapon gets an answer before the floor +#define BOUNTY_PSYCHO_BURN_WINDED 25 + +/// The cyberpsycho's chrome as organ typepaths, in the order they go in: the Redline core first, as it carries the headroom for the rest +/proc/bounty_psycho_organs() + return list( + /obj/item/organ/cyberimp/cyberware/redline, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + /obj/item/organ/cyberimp/cyberware/gorilla_arms/left, + /obj/item/organ/cyberimp/cyberware/piledriver, + /obj/item/organ/cyberimp/cyberware/lazarus, + /obj/item/organ/eyes/robotic/cyberware/deadeye, + ) + +/// The pieces (BOUNTY_CHROME_*) its chrome AI drives: every one but the Cascade lattice +/proc/bounty_psycho_keys() + return list(BOUNTY_CHROME_REDLINE, BOUNTY_CHROME_MANTIS, BOUNTY_CHROME_GORILLA, BOUNTY_CHROME_PILEDRIVER, BOUNTY_CHROME_LAZARUS, BOUNTY_CHROME_DEADEYE) + +// ===== THE BOSS ===== + +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho + name = "chromed criminal" + desc = "A twitching criminal with more chrome than skin." + boss_kit = BOUNTY_KIT_CYBERPSYCHO + /// Its Redline has burned once: its phase two is spent + var/psycho_burned = FALSE + +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/Initialize(mapload, datum/human_npc_order/order) + // Its kit is its chrome: the base installs it once it is dressed + npc_cyberware = bounty_psycho_organs() + . = ..() + psycho_wire_chrome() + RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_STUNIMMUNE), PROC_REF(psycho_burn_started)) + RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_STUNIMMUNE), PROC_REF(psycho_burn_ended)) + +// Its Redline core goes in first, with the headroom the rest of its chrome needs +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/npc_install_cyberware(ware_type) + var/obj/item/organ/ware = ..() + if(istype(ware, /obj/item/organ/cyberimp/cyberware/redline)) + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + if(chrome && !chrome.capacity_bonus) + chrome.capacity_bonus = BOUNTY_PSYCHO_EXTRA_CAPACITY + cyberware_reevaluate_brownout(src) + return ware + +/** + * Its chrome's AI, once the implants are in (C0's bounty_chrome_equip()): every piece's moves, and its + * rotation set to what this body can do. Its own lines say what is coming (boss_bark()), not each move's. + * Its Redline is its own move (/datum/bounty_chrome_move/redline/psycho), its phase two, in place of the + * one every carrier gets, and its Gorilla fist gets the piston punch. The Gorilla grab needs two Gorilla + * fists and the Deadeye tag a gun, and it has neither, so they stay out of its rotation. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_wire_chrome() + var/datum/component/bounty_chrome/chrome = bounty_chrome_equip(src, bounty_psycho_keys()) + if(!chrome) + return + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/unused in boss_abilities.Copy()) + if(istype(unused.move, /datum/bounty_chrome_move/redline) || istype(unused.move, /datum/bounty_chrome_move/gorilla_grab) || istype(unused.move, /datum/bounty_chrome_move/deadeye)) + boss_abilities -= unused + qdel(unused) + var/datum/bounty_chrome_move/redline/plain = chrome.move_of(/datum/bounty_chrome_move/redline) + if(plain) + chrome.moves -= plain + plain.detach() + qdel(plain) + psycho_add_move(chrome, /datum/bounty_chrome_move/redline/psycho) + psycho_add_move(chrome, /datum/bounty_chrome_move/gorilla_punch/psycho) + for(var/datum/bounty_chrome_move/move as anything in chrome.moves) + move.tell_lines = null + +/// Adds a move of `move_type` to its chrome AI `chrome`, as a move in its rotation (C0's adaptor). Returns the move. +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_add_move(datum/component/bounty_chrome/chrome, move_type) + var/datum/bounty_chrome_move/move = new move_type + chrome.moves += move + move.attach(src) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability = new(src) + ability.set_move(move) + ability.Grant(src) + boss_abilities += ability + return move + +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/bounty_build_outfit(zone) + return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/cyberpsycho)) + +// No bag over its spine rig: its stimulants and bruise pack ride in a bum bag, where it reaches them as any boss reaches its bag. The bag holds three, so its combat stimpack rides in a pocket. +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/boss_supplies(datum/outfit/outfit) + if(!istype(outfit)) + return outfit + outfit.belt = /obj/item/storage/belt/fannypack/black + LAZYINITLIST(outfit.belt_contents) + outfit.belt_contents[BOUNTY_BOSS_STIMULANT] = BOUNTY_BOSS_STIMULANTS + outfit.belt_contents[/obj/item/stack/medical/bruise_pack] = 1 + if(isnull(outfit.l_pocket)) + outfit.l_pocket = BOUNTY_BOSS_COMBAT_STIMULANT + else if(isnull(outfit.r_pocket)) + outfit.r_pocket = BOUNTY_BOSS_COMBAT_STIMULANT + return outfit + +// Its chrome is its kit: it dresses to show it (C0's bounty_chrome_expose_outfit()) +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/bounty_dresses_to_show_chrome() + return TRUE + +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/boss_gear_text() + return "[p_They()] can't keep still, and there's more chrome on [p_them()] than skin." + +/// Shorts and boots: its arms, chest and legs are chrome, and they show +/datum/outfit/bounty_boss/cyberpsycho + name = "Bounty mini-boss: Cyberpsycho" + uniform = /obj/item/clothing/under/shorts/black + gloves = null + +// ----- its phase two ----- + +/// Its Redline core, if it is in it +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_core() + return locate(/obj/item/organ/cyberimp/cyberware/redline) in organs + +/// Its Redline in its rotation, if it has one +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_burn_ability() + var/datum/component/bounty_chrome/chrome = GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/redline/psycho/burn = chrome?.move_of(/datum/bounty_chrome_move/redline/psycho) + return burn?.boss_ability + +/// Whether its phase two is still to come: it has never burned, and its Redline core is in it and running (an EMP or a brownout puts that off) +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_burn_pending() + if(psycho_burned) + return FALSE + var/obj/item/organ/core = psycho_core() + var/datum/component/cyberware/ware = core?.GetComponent(/datum/component/cyberware) + return !!ware?.is_running() + +/// Hurt or winded enough to burn +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_hurt_enough() + return health <= maxHealth * BOUNTY_PSYCHO_BURN_HURT / 100 || getStaminaLoss() >= BOUNTY_PSYCHO_BURN_WINDED + +/** + * Whether it burns its Redline now at `target` (or whoever it fights, for null): its phase two still to + * come, hurt or winded enough, in its fight, and a Redline move's own checks but its "hurt" reading (C3's + * line is any carrier's, this is its own): able to act, someone it may hit in sight, the implant ready, + * and nobody outside the fight within the roar's reach (psycho_roar_clear()). Never at someone it can't + * get at (boss_valid_target(): shot from behind glass it can't break, it takes cover instead, C5), so a + * crew can't spend its phase two from where it can't follow. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_burn_due(atom/target) + if(!boss_hostile || !psycho_burn_pending() || !psycho_hurt_enough()) + return FALSE + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/burn = psycho_burn_ability() + var/datum/bounty_chrome_move/redline/move = burn?.move + target ||= bounty_chrome_target(src) || boss_revenge_target() + if(!istype(move) || QDELETED(target) || !bounty_chrome_can_act(src) || !bounty_ai_may_hit(src, target) || !boss_valid_target(target)) + return FALSE + if(bounty_ai_dist(src, target) > move.max_range || !bounty_ai_can_see(src, target, move.max_range)) + return FALSE + return move.ready() && psycho_roar_clear(move.area_turfs(target), target) + +/** + * Whether its Redline's roar may go off over `turfs`: nobody stands there who is outside its fight and has + * a player behind them or is a person (C0's bystander gate, bounty_chrome_area_clear()), but its own + * companions don't count, and nor do creatures: a cyberpsycho doesn't mind staggering its friends. Its + * companions come in one for each extra hunter (OC-8), so C0's gate would keep its phase two shut in most + * fights against a crew. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_roar_clear(list/turfs, atom/aimed) + for(var/turf/spot as anything in turfs) + if(!isturf(spot)) + continue + var/list/people = list() + for(var/mob/living/person in spot) + people += person + for(var/obj/vehicle/sealed/mecha/mech in spot) + for(var/mob/living/pilot in mech.occupants) + people += pilot + for(var/mob/living/person as anything in people) + if(person == src || person.stat == DEAD || bounty_ai_same_gang(src, person)) + continue + if((person.mind || person.client || ishuman(person)) && !bounty_chrome_in_posse(src, person, aimed)) + return FALSE + return TRUE + +// Its phase two comes before any other move +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/boss_choose_ability(atom/target) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/burn = psycho_burn_ability() + if(burn && !QDELETED(target) && boss_can_use_ability() && burn.IsAvailable() && burn.worth_using(target)) + return burn + return ..() + +// A stamina weapon or a bad wound: it doesn't wait its turn to burn. A moment later, once the hit is done with. +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/boss_took_damage(damage, damagetype) + if(!psycho_burned && psycho_hurt_enough()) + addtimer(CALLBACK(src, PROC_REF(psycho_burn_now)), 1, TIMER_UNIQUE | TIMER_DELETE_ME) + +/** + * Burns its Redline now if it should (psycho_burn_due()): whatever it was winding up, or the glass it was + * punching, it drops, and the burn's tell starts in the next move's place. Not while it is up in a leap, + * holding on to someone or already winding the burn up. Returns TRUE if the tell started. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_burn_now() + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/burn = psycho_burn_ability() + if(QDELETED(src) || !burn || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED) || !boss_can_act()) + return FALSE + var/atom/target = bounty_chrome_target(src) || boss_revenge_target() + if(!burn.worth_using(target)) + return FALSE + if(boss_busy) + // A wind-up or a smash ("smash", BOUNTY_BOSS_BUSY_SMASH) gives way; anything else it sees through + if(boss_winding() == burn || (boss_busy != "windup" && boss_busy != "smash")) + return FALSE + boss_interrupt() + boss_next_ability_at = min(boss_next_ability_at, world.time) + boss_fallback_until = 0 + // Its own click, as its AI's Trigger() makes it: a timer's callback carries the usr of whoever hit it, and Trigger() would click as them + return !!burn.InterceptClickOn(src, null, target) + +// Tiring is what sets its Redline off: until its phase two is spent it burns instead of falling back, and burning, it doesn't tire +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/boss_is_worn_out() + if(psycho_burn_pending() || has_status_effect(/datum/status_effect/cyberware_redline_window)) + return FALSE + return ..() + +// The burn's tell gets its own lines, said over the cooldown on its talk +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/boss_bark(suffix, fallback) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/winding = boss_winding() + if(suffix == "ability" && istype(winding) && istype(winding.move, /datum/bounty_chrome_move/redline/psycho)) + if(boss_kit && stat == CONSCIOUS) + INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "[boss_kit]_redline", null, TRUE) + return + return ..() + +/// The implant's burn started (its window's stun immunity went on): its phase two is spent +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_burn_started(datum/source) + SIGNAL_HANDLER + var/datum/status_effect/window = /datum/status_effect/cyberware_redline_window + if(HAS_TRAIT_FROM(src, TRAIT_STUNIMMUNE, initial(window.id))) + psycho_burned = TRUE + +/// The burn is over (its stun immunity went), and the crash comes: it says so +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/proc/psycho_burn_ended(datum/source) + SIGNAL_HANDLER + if(psycho_burned && boss_kit && stat == CONSCIOUS) + INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "[boss_kit]_exhausted", null, TRUE) + +/** + * A player in its body (a brain transplant) loses its gear (the human NPC base's Login()), and the headroom + * only a cyberpsycho carries: with its core's capacity gone, its chrome browns out, all of it, as anyone's + * does over capacity. Admins driving it for an event keep it. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/Login() + . = ..() + if(!. || isnull(client) || client.holder) + return + var/obj/item/organ/core = psycho_core() + var/datum/component/cyberware/core_ware = core?.GetComponent(/datum/component/cyberware) + if(core_ware?.capacity_bonus) + core_ware.capacity_bonus = 0 + cyberware_reevaluate_brownout(src) + +// ===== ITS MOVES ===== + +/** + * The cyberpsycho's Redline, its phase two, in place of the one every carrier gets: C3's tell (the chest + * speaker glowing red, standing still) and the implant's burn, on its own rules (psycho_burn_due()) and its + * own roar gate (psycho_roar_clear()), checked again as the button is pressed. Wired by the cyberpsycho + * itself (psycho_wire_chrome()), so no other Redline carrier gets it. + */ +/datum/bounty_chrome_move/redline/psycho + piece_key = null + +/datum/bounty_chrome_move/redline/psycho/can_start(atom/target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = owner + return istype(psycho) && psycho.psycho_burn_due(target) + +// Someone outside the fight stepped into the roar's reach during the tell: the button stays unpressed +/datum/bounty_chrome_move/redline/psycho/effect(atom/target) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = owner + if(!istype(psycho) || !psycho.psycho_roar_clear(area_turfs(target), target)) + return FALSE + . = bounty_chrome_trigger(owner, action_type, trigger_target(target)) + if(. && owner.has_status_effect(/datum/status_effect/cyberware_redline_window)) + owner.apply_status_effect(/datum/status_effect/bounty_redline_eyes) + +/** + * Its Gorilla fist's piston punch as a move in its rotation: C2's punch, a fist drawn back over the lit + * tile for its tell, then the arm's own empowered punch. C2 leaves a mini-boss's Gorilla punches to its + * melee; this one's melee is its blade. Wired by the cyberpsycho itself (psycho_wire_chrome()), so no other + * Gorilla Arms carrier gets it. + */ +/datum/bounty_chrome_move/gorilla_punch/psycho + piece_key = null + boss_usable = TRUE + +// Its rotation throws it; it plans nothing of its own +/datum/bounty_chrome_move/gorilla_punch/psycho/plan(datum/ai_controller/controller, atom/target) + return FALSE + +// ===== THE BOUNTY PANEL ===== + +// "All of it" is the cyberpsycho: its body is the only one that carries it all (C0's seam) +/datum/bounty_admin_panel/admin_chrome_all(datum/bounty_record/record, list/kit_organs) + record.archetype = BOUNTY_ARCHETYPE_BOSS + record.kit = BOUNTY_KIT_CYBERPSYCHO + record.style = null + return list() + +#undef BOUNTY_PSYCHO_EXTRA_CAPACITY +#undef BOUNTY_PSYCHO_BURN_HURT +#undef BOUNTY_PSYCHO_BURN_WINDED diff --git a/voidcrew/modules/bounties/strings/bounty_criminals.json b/voidcrew/modules/bounties/strings/bounty_criminals.json index e87678a2b73..2461850b930 100644 --- a/voidcrew/modules/bounties/strings/bounty_criminals.json +++ b/voidcrew/modules/bounties/strings/bounty_criminals.json @@ -75,7 +75,8 @@ "pyromaniac": ["Matches", "Torch", "Cinders", "Smoky", "Blaze"], "demolitionist": ["Fuse", "Boomer", "Sticks", "Two-Fingers", "Detonator"], "ghost": ["Shade", "Blink", "Needle", "Nobody", "Quiet"], - "heavy": ["Gunner", "Big Iron", "Tank", "Belt", "Rattle"] + "heavy": ["Gunner", "Big Iron", "Tank", "Belt", "Rattle"], + "cyberpsycho": ["Static", "Glitch", "Hardwire", "Burnout", "Scrap Saint", "Sparks"] }, "features": { "scar": [ @@ -539,6 +540,25 @@ "Light them up!" ] }, + "pyromaniac_smoke": { + "any": [ + "Hold your breath.", + "Lights out.", + "Bit smoky in here.", + "Where'd I go?", + "Breathe deep.", + "Mind your eyes." + ] + }, + "pyromaniac_reload": { + "any": [ + "Hang on, changing tanks.", + "Fresh tank. Don't go anywhere.", + "Stay right there.", + "Just need a top-up.", + "Hold that thought." + ] + }, "pyromaniac_exhausted": { "any": [ "Running low on fuel...", @@ -678,6 +698,116 @@ "More targets. Fine.", "Hope you all brought armor." ] + }, + "juggernaut_cover": { + "any": [ + "Hiding back there? I'll wait.", + "Come out and face me.", + "You can't stay in there forever.", + "Come out from behind there!", + "I'll be right here when you come out.", + "Shooting from back there? Real brave." + ] + }, + "pyromaniac_cover": { + "any": [ + "Hiding? I can wait.", + "You'll have to come out sometime.", + "Come out, come out. It's warm out here.", + "I've got all day, and plenty of fuel.", + "Stay in there, then. I'll wait.", + "Shooting from back there? Come closer." + ] + }, + "demolitionist_cover": { + "any": [ + "Come out from behind there!", + "Hiding? I've got time.", + "You can't hide in there forever.", + "Shoot from back there all you like. I'll wait.", + "I know where you are.", + "Sooner or later, you come out." + ] + }, + "ghost_cover": { + "any": [ + "You'll come out eventually.", + "I'll be right here.", + "Hiding won't help you.", + "Take your time. I'm not going anywhere.", + "Come and find me.", + "I can wait all day." + ] + }, + "heavy_cover": { + "any": [ + "Can't hide in there forever.", + "Come out from behind there!", + "Stay in there, then. I'll wait.", + "Peek out again. Go on.", + "I've got all day.", + "Shooting from back there? Cute." + ] + }, + "cyberpsycho_intro": { + "any": [ + "Get out of my head!", + "Can you hear it humming? Can you?", + "More meat. Come here.", + "Don't look at me like that!", + "It won't stop. Nothing stops.", + "You're not real. None of you are real." + ] + }, + "cyberpsycho_ability": { + "any": [ + "Hold still!", + "There you are.", + "Got you now!", + "Come here!", + "Stay right there!", + "Don't run, meat!" + ] + }, + "cyberpsycho_redline": { + "any": [ + "Make it stop!", + "LOUDER!", + "Not now. Not now!", + "Everything's red.", + "Shut up! Shut up!", + "It's too loud!" + ] + }, + "cyberpsycho_exhausted": { + "any": [ + "Why is it so quiet?", + "Something's burning. Is that me?", + "I can't feel my arms.", + "Keep running, keep running...", + "My hands won't stop shaking.", + "Just let me sit down." + ] + }, + "cyberpsycho_posse": { + "any": [ + "More of you? Good. More meat.", + "All of you. I'll take all of you.", + "Bring the whole crew.", + "So many voices...", + "Line up.", + "Doesn't matter how many." + ] + }, + "cyberpsycho_cover": { + "any": [ + "Come out! Come OUT!", + "I can hear you breathing.", + "Where'd you go? Where'd you GO?", + "You can't stay in there forever!", + "Hiding won't help. I'll find you.", + "Come out and play." + ] } } } diff --git a/voidcrew/modules/cyberware/chrome_cradle.dm b/voidcrew/modules/cyberware/chrome_cradle.dm index ef2dc109b0a..495bcccf1ad 100644 --- a/voidcrew/modules/cyberware/chrome_cradle.dm +++ b/voidcrew/modules/cyberware/chrome_cradle.dm @@ -94,8 +94,6 @@ /obj/machinery/chrome_cradle/examine(mob/user) . = ..() - . += span_notice("Drag yourself (or a patient) onto the slab to lie back on it. Whoever's on the slab runs their own install; the rig won't take orders from anyone else.") - . += span_notice("Tune-ups run [CYBERWARE_TUNEUP_FEE] cr: EMP-scrambled and damaged chrome comes back to spec. Load cash into the slab or pay by ID.") if(loaded_credits) . += span_notice("The slab's cash slot holds [loaded_credits] cr.") if(length(tray)) @@ -226,6 +224,32 @@ playsound(src, 'sound/machines/click.ogg', 40, TRUE) SStgui.update_uis(src) +// ---- Arm choice -------------------------------------------------------- + +/** + * Seats an uninstalled arm housing on the patient's free arm when its own arm + * already holds one of the same kind, so a second Widowline goes on the other + * arm instead of racking the first. Starts from the housing's own arm every + * time, so a housing the cradle moved once doesn't stay moved for the next + * patient. With both arms taken (or no free arm to take it), it stays on its + * own arm and replaces as before. Cradle only: surgery picks its arm by + * the surgeon's target zone (pre_surgical_insertion()). + */ +/obj/machinery/chrome_cradle/proc/pick_cradle_arm(obj/item/organ/ware, mob/living/carbon/patient) + if(!istype(ware, /obj/item/organ/cyberimp/arm/toolkit/cyberware) || ware.owner || !istype(patient)) + return + var/home_zone = initial(ware.zone) + var/other_zone = home_zone == BODY_ZONE_R_ARM ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM + if(!length(ware.valid_zones) || !ware.valid_zones[home_zone] || !ware.valid_zones[other_zone]) + return + var/target_zone = home_zone + var/obj/item/organ/home_incumbent = patient.get_organ_slot(ware.valid_zones[home_zone]) + if(home_incumbent && home_incumbent.type == ware.type \ + && !patient.get_organ_slot(ware.valid_zones[other_zone]) && patient.get_bodypart(other_zone)) + target_zone = other_zone + if(ware.zone != target_zone) + ware.swap_zone(target_zone) + // ---- Sequences --------------------------------------------------------- /** @@ -239,7 +263,10 @@ if(!istype(patient) || QDELETED(ware)) return var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) - if(!chrome || !cyberware_insert_check(ware, patient)) + if(!chrome) + return + pick_cradle_arm(ware, patient) + if(!cyberware_insert_check(ware, patient)) return if(ware.loc != src && !patient.transferItemToLoc(ware, src)) balloon_alert(patient, "[ware.name] is stuck to you!") @@ -261,6 +288,8 @@ /// on the marked stage a spark shower plus Splice's mid-line. /obj/machinery/chrome_cradle/proc/run_sequence_stage(mid_stage = FALSE) playsound(src, 'sound/effects/servostep.ogg', 60, TRUE) + // The rig's arms move on the beat (cyberware_anim2.dm). + rig_beat(mid_stage) var/mob/living/patient = occupant if(istype(patient)) patient.do_jitter_animation(60) @@ -286,6 +315,8 @@ var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) if(!chrome) return + // The arms may have changed during the sequence; choose again before the recheck. + pick_cradle_arm(ware, patient) // Recheck the final set after the sequence delay, while every incumbent is // still installed. An intervening install or lost Governor must not evict it. if(!cyberware_insert_check(ware, patient)) @@ -317,6 +348,7 @@ SStgui.update_uis(src) return do_sparks(3, FALSE, src) + rig_boot_fx(patient) patient.flash_act(visual = 1) if(chrome.tier >= CYBERWARE_TIER_4) visible_message(span_notice("The parlor's neon stutters as the rig pulls the current it needs.")) @@ -370,6 +402,7 @@ for(var/timer in stage_timers) deltimer(timer) stage_timers.Cut() + rig_stop() busy = FALSE busy_action = null busy_ware = null @@ -408,7 +441,7 @@ if(any_repairable) return null if(only_brownout && length(installed)) - return "That chrome is browned out, not broken. Shed some load instead." + return "That chrome is browned out, not broken." return "Nothing needs a tune-up." /obj/machinery/chrome_cradle/proc/try_tune_up(mob/living/carbon/patient) @@ -662,6 +695,8 @@ else projected_load += chrome.chrome_load projected_capacity += chrome.capacity_bonus + // Show the arm the install would actually use (an uninstalled housing only). + pick_cradle_arm(selected_ware, patient) for(var/obj/item/organ/incumbent in selected_ware.cyberware_get_incumbents(patient)) evicts += incumbent.name projected_load -= get_installed_capacity_cost(incumbent) @@ -778,6 +813,7 @@ if(!ware.GetComponent(/datum/component/cyberware)) balloon_alert(patient, "not chrome!") return TRUE + pick_cradle_arm(ware, patient) if(!cyberware_insert_check(ware, patient, feedback_to = patient)) return TRUE begin_install(ware) @@ -807,6 +843,13 @@ return TRUE +// ---- Ship saves --------------------------------------------------------- + +// A cradle belongs to a parlor. A saved hull must never rebuild one (an admin test kit can +// drop one on a ship), or every load would hand that ship a free operating slab. +/obj/machinery/chrome_cradle/checkpoint_type() + return null + // ---- Outpost aggression ------------------------------------------------ // Attacking outpost property is aggression, the cradle included. diff --git a/voidcrew/modules/cyberware/chrome_hud.dm b/voidcrew/modules/cyberware/chrome_hud.dm new file mode 100644 index 00000000000..c8c2a10b63c --- /dev/null +++ b/voidcrew/modules/cyberware/chrome_hud.dm @@ -0,0 +1,198 @@ +/** + * # Chrome on the HUD + * + * Chrome abilities are fired from the chrome wheel (chrome_wheel.dm), so none + * of them gets an action button of its own. One "Chrome" button stands in for + * all of them: it shows the pick (what Use chrome fires) with its cooldown and + * offline state, and a click opens the wheel. + * + * A chrome ability is any action whose target is installed chrome (an organ + * carrying /datum/component/cyberware), plus the wheel's own Arm chrome. Every + * other action, printable tg implants included, keeps its button. + * + * Hiding is tg's own way to keep an action without a button (the ninja dash, + * energy_katana.dm): GiveAction() does nothing for it. The action is still + * granted, so it keeps its owner, its keydown signal, its check_flags signals, + * its cooldown and its click intercepts, and Trigger() works as before. It + * just never joins anyone's actions list (so the HUD, observers and riders + * never see it) and never gets a button. Code that used to look for a chrome + * ability in mob.actions asks get_chrome_wheel_actions() instead. + * + * The chips on the wheel and the Chrome button still wear each ability's own + * button look: chrome_ability_look() builds a button that never goes on a + * screen and copies it. + */ + +/// Whether this action is a chrome ability: fired from the chrome wheel, never +/// given a button of its own. +/datum/action/proc/is_chrome_ability() + var/obj/item/organ/ware = target + return istype(ware) && !!ware.GetComponent(/datum/component/cyberware) + +/datum/action/GiveAction(mob/viewer) + if(is_chrome_ability()) + return + return ..() + +// GiveAction() is the only way in, but a button must never be built for one by any other road either. +/datum/action/ShowTo(mob/viewer) + if(is_chrome_ability()) + return + return ..() + +/datum/action/Grant(mob/grant_to) + . = ..() + if(owner && is_chrome_ability()) + chrome_hud_sync(owner, gained = TRUE) + +/datum/action/Remove(mob/remove_from) + // Grant() hands over by setting the new owner first, then removing the old one. + var/mob/losing = remove_from || owner + . = ..() + if(losing && is_chrome_ability()) + chrome_hud_sync(losing) + +/// A chrome ability's button would have been redrawn (a cooldown ticking, an +/// ability armed, a stun): the Chrome button redraws instead if it shows this one. +/datum/action/build_all_button_icons(update_flags = ALL, force) + . = ..() + if(owner && is_chrome_ability()) + var/datum/component/chrome_wheel/wheel = owner.GetComponent(/datum/component/chrome_wheel) + wheel?.on_ability_changed(src) + +/** + * Brings the bearer's Chrome button and Arm chrome up to date with the chrome + * they carry. [gained] makes the wheel if the body has none yet. + */ +/proc/chrome_hud_sync(mob/living/carbon/bearer, gained = FALSE) + if(!iscarbon(bearer) || QDELETED(bearer)) + return + var/datum/component/chrome_wheel/wheel = gained ? get_chrome_wheel(bearer) : bearer.GetComponent(/datum/component/chrome_wheel) + wheel?.sync_abilities() + +// ---- Ability looks ----------------------------------------------------- + +/// The last look built for this action's chip or Chrome button, and what it was built from. +/datum/action/var/tmp/mutable_appearance/chrome_look +/datum/action/var/tmp/chrome_look_key + +/// What an ability's look is built from. A change here rebuilds it. +/proc/chrome_ability_look_key(datum/action/ability) + var/atom/thing = isatom(ability.target) ? ability.target : null + return "[ability.button_icon]|[ability.button_icon_state]|[ability.overlay_icon_state]|[ability.name]|[thing?.icon]|[thing?.icon_state]|[length(thing?.overlays)]" + +/** + * An ability's own button look, without its background, text, tint or + * position: built on a button that never goes on a screen, so it carries the + * same icon and item overlay a button would. A fresh copy each call. + */ +/proc/chrome_ability_look(datum/action/ability) + RETURN_TYPE(/mutable_appearance) + var/key = chrome_ability_look_key(ability) + if(!ability.chrome_look || ability.chrome_look_key != key) + var/atom/movable/screen/movable/action_button/button = ability.create_button() + var/mutable_appearance/look = new(button) + qdel(button) + look.underlays = list() + look.plane = FLOAT_PLANE + look.layer = FLOAT_LAYER + look.pixel_x = 0 + look.pixel_y = 0 + look.pixel_w = 0 + look.pixel_z = 0 + look.screen_loc = null + look.maptext = null + look.color = null + look.alpha = 255 + look.transform = matrix() + look.appearance_flags = NONE + ability.chrome_look = look + ability.chrome_look_key = key + return new /mutable_appearance(ability.chrome_look) + +// ---- The Chrome button ------------------------------------------------- + +/// The pick's look, frame and anything else the Chrome button laid over itself. +/atom/movable/screen/movable/action_button/var/list/chrome_overlays + +/** + * The one HUD button chrome gets. Shows the wheel's pick framed in cyan, or + * the wheel itself with no pick; red like the pick's own button when it can't + * be used, with its cooldown in seconds and a lit background while it is out + * or armed. A click opens the wheel, and a chip clicked there is picked and fired. + */ +/datum/action/chrome_button + name = "Chrome" + button_icon = CHROME_HUD_ICON + button_icon_state = "chrome" + background_icon_state = "bg_tech_blue" + default_button_position = SCRN_OBJ_INSERT_FIRST + +/datum/action/chrome_button/proc/get_wheel() + RETURN_TYPE(/datum/component/chrome_wheel) + var/datum/component/chrome_wheel/wheel = target + return istype(wheel) ? wheel : null + +/// The ability the button shows, or null. +/datum/action/chrome_button/proc/get_pick() + return get_wheel()?.get_button_pick() + +/datum/action/chrome_button/Trigger(mob/clicker, trigger_flags) + . = ..() + if(!.) + return FALSE + if(clicker && clicker != owner) + return FALSE + var/datum/component/chrome_wheel/wheel = get_wheel() + if(!wheel) + return FALSE + wheel.button_clicked() + return TRUE + +/datum/action/chrome_button/create_button() + var/atom/movable/screen/movable/action_button/button = ..() + // Placed like a cooldown button's count. + button.maptext_x = 4 + button.maptext_y = 2 + button.maptext_width = 32 + button.maptext_height = 16 + return button + +/datum/action/chrome_button/is_action_active(atom/movable/screen/movable/action_button/current_button) + var/datum/action/pick = get_pick() + return pick && chrome_wheel_ability_active(pick, owner) + +/datum/action/chrome_button/apply_button_background(atom/movable/screen/movable/action_button/current_button, force) + // Lit while the pick is out or armed. + background_icon_state = is_action_active(current_button) ? "bg_tech_blue_active" : "bg_tech_blue" + return ..() + +/datum/action/chrome_button/apply_button_icon(atom/movable/screen/movable/action_button/current_button, force) + // With a pick, the pick's own look is laid over an empty button instead. + current_button.icon = get_pick() ? null : button_icon + current_button.icon_state = button_icon_state + +/datum/action/chrome_button/apply_button_overlay(atom/movable/screen/movable/action_button/current_button, force) + . = ..() + if(current_button.chrome_overlays) + current_button.cut_overlay(current_button.chrome_overlays) + current_button.chrome_overlays = null + var/datum/action/pick = get_pick() + if(!pick) + return + // No RESET_COLOR: the button's red goes over the pick, as it did on the pick's own button. + var/list/laid = list(chrome_ability_look(pick), chrome_wheel_marker("module_selected")) + current_button.add_overlay(laid) + current_button.chrome_overlays = laid + +/datum/action/chrome_button/update_button_status(atom/movable/screen/movable/action_button/current_button, force) + . = ..() + current_button.maptext = "" + var/datum/action/pick = get_pick() + if(!pick) + return + var/cooldown_left = chrome_wheel_cooldown_left(pick) + if(cooldown_left) + current_button.maptext = MAPTEXT_TINY_UNICODE("[CEILING(cooldown_left / 10, 1)]") + if(chrome_wheel_offline(pick) || !pick.IsAvailable()) + current_button.color = pick.transparent_when_unavailable ? rgb(128, 0, 0, 128) : rgb(128, 0, 0) diff --git a/voidcrew/modules/cyberware/chrome_wheel.dm b/voidcrew/modules/cyberware/chrome_wheel.dm new file mode 100644 index 00000000000..0e4a86c3f8a --- /dev/null +++ b/voidcrew/modules/cyberware/chrome_wheel.dm @@ -0,0 +1,1482 @@ +/** + * # Chrome wheel + * + * One wheel holding every ability the bearer's chrome carries, so nobody has + * to hunt a row of action buttons mid-fight. Three keybinds drive it + * (chrome_wheel_keybindings.dm): + * + * - Chrome wheel: hold it and the wheel opens at the centre of the view. Point + * at a chip and let go, or click one, to pick it. A quick tap leaves the + * wheel open for a click instead; pressing the key again shuts it. + * - Use chrome: fires the picked ability on key down. + * - Use OS chrome: fires the OS-slot ware's ability on key down, whatever is + * picked. + * + * A chip IS the bearer's existing /datum/action, fired through the same + * Trigger() a button click would use. Cooldowns, ORGAN_FAILING, check_flags + * and click-to-target modes are the ability's own, and nothing here copies or + * replaces one. Abilities are collected generically from every installed + * organ carrying /datum/component/cyberware, so new ware shows up without + * touching this file. Chrome abilities get no HUD button of their own + * (chrome_hud.dm): the wheel owns the one "Chrome" button that shows the pick + * and opens the wheel, and the Arm chrome ability (chrome_wheel_arms.dm) that + * deploys every arm at once. + * + * Looks: an outline of the bearer's body inside a ring cut into one arc per + * body region. Each ware sits in a socket (chrome_wheel_socket()), a run of + * fixed positions on its region's arc, with a leader line from the socket to + * the part of the body it lives in. A socket's chrome changing never moves + * another socket's chips, and an empty socket keeps a dim outline. Pointing at + * a chip grows it and lights its arc, its leader and its body part in its + * tier's colour, and a fixed readout under the ring names it. The pick wears + * the chrome read's corner brackets, and the Chrome button shows it in the + * MOD-style "selected" frame on the HUD. + * + * Pointing is by bearing from the ring's centre, so a flick outward picks the + * chip in that direction without landing on it. Inside the body nothing is + * pointed at. + * + * Sub-options: an ability can offer choices through + * /datum/action/proc/chrome_wheel_options(), empty by default. The wheel does + * not show them; a pick made with select(ability, option_id) makes Use chrome + * call the ability's use_chrome_wheel_option() with that id instead of Trigger(). + * + * Mouse handling: BYOND only reports the mouse over things it can hit, so the + * open wheel lays a full-view cursor catcher (tg's, as the scope uses) under + * its mouse-transparent pieces. Every move and click lands on the catcher, and + * the chip is worked out from where the mouse is relative to the centre. + */ + +// Readout panel under the ring, in pixels from the bottom left of the centre +// tile (y up). The panel's top edge, left edge and size. +#define CHROME_WHEEL_READOUT_TOP -108 +#define CHROME_WHEEL_READOUT_LEFT -66 +#define CHROME_WHEEL_READOUT_WIDTH 164 +#define CHROME_WHEEL_READOUT_HEIGHT 25 + +/// Organ slots that sort first inside their socket, in this order. Any other +/// slot follows them, alphabetically by slot name. +GLOBAL_LIST_INIT(chrome_wheel_slot_order, list( + ORGAN_SLOT_EYES, + ORGAN_SLOT_CYBERWARE_EARS, + ORGAN_SLOT_CYBERWARE_RIGGER, + ORGAN_SLOT_CYBERWARE_REGISTRY, + ORGAN_SLOT_CYBERWARE_OS, + ORGAN_SLOT_CYBERWARE_SKIN, + ORGAN_SLOT_CYBERWARE_FILTER, + ORGAN_SLOT_CYBERWARE_STASH, + ORGAN_SLOT_CYBERWARE_LEGS, +)) + +/** + * Where each socket's chips sit on the ring. "start" is the bearing of its + * first chip in degrees clockwise from twelve o'clock, "turn" the way the rest + * follow (1 clockwise, -1 counter-clockwise), "fits" how many its arc holds + * before another row starts further out. "arc" is the ring arc it lights and + * "region" the body part. The art in chrome_wheel_ring.dmi is drawn to match. + */ +GLOBAL_LIST_INIT(chrome_wheel_sockets, list( + CHROME_WHEEL_SOCKET_EYES = list("start" = -9, "turn" = -1, "fits" = 2, "arc" = "head", "region" = "head"), + CHROME_WHEEL_SOCKET_HEAD = list("start" = 9, "turn" = 1, "fits" = 2, "arc" = "head", "region" = "head"), + CHROME_WHEEL_SOCKET_OS = list("start" = 47, "turn" = 1, "fits" = 2, "arc" = "os", "region" = "spine"), + CHROME_WHEEL_SOCKET_RIGHT_ARM = list("start" = 83, "turn" = 1, "fits" = 4, "arc" = "r_arm", "region" = "r_arm"), + CHROME_WHEEL_SOCKET_LEGS = list("start" = 180, "turn" = 1, "fits" = 3, "arc" = "legs", "region" = "legs"), + CHROME_WHEEL_SOCKET_LEFT_ARM = list("start" = -83, "turn" = -1, "fits" = 4, "arc" = "l_arm", "region" = "l_arm"), + CHROME_WHEEL_SOCKET_SKIN = list("start" = -47, "turn" = -1, "fits" = 2, "arc" = "skin", "region" = "torso"), +)) + +/// Positions a socket holds for one organ slot, filled or not, so the rest of +/// that socket never moves when the slot is filled or emptied. Socket => +/// list(slot, positions held). The OS owns the first chip of its arc. Chrome +/// optics own the first three of theirs (their own ability, the chrome read and +/// the zoom, cyberware_zoom.dm); the third starts the eyes' second row. Arm +/// chrome (chrome_wheel_arms.dm) owns the top of the right arm's arc, where it +/// meets the torso. +GLOBAL_LIST_INIT(chrome_wheel_reserved, list( + CHROME_WHEEL_SOCKET_OS = list(ORGAN_SLOT_CYBERWARE_OS, 1), + CHROME_WHEEL_SOCKET_EYES = list(ORGAN_SLOT_EYES, 3), + CHROME_WHEEL_SOCKET_RIGHT_ARM = list(CHROME_WHEEL_ARMS_KEY, 1), +)) + +// ---- Collection -------------------------------------------------------- + +/** + * Every ability the bearer's installed chrome gives them, then Arm chrome if + * they have it. Offline ware stays in (it shows dark, and firing it gives the + * ability's own feedback); ware that is not in the body has no owner on its + * actions and drops out on its own. + */ +/proc/get_chrome_wheel_actions(mob/living/carbon/bearer) + RETURN_TYPE(/list) + . = list() + for(var/obj/item/organ/ware as anything in get_installed_cyberware(bearer)) + for(var/datum/action/ability in ware.actions) + if(QDELETED(ability) || ability.owner != bearer || !ability.owner_has_control) + continue + . += ability + var/datum/component/chrome_wheel/wheel = bearer?.GetComponent(/datum/component/chrome_wheel) + var/datum/action/chrome_arms/arms = wheel?.arm_action + if(arms && !QDELETED(arms) && arms.owner == bearer) + . += arms + +/// The ability of whatever OS-slot chrome the bearer runs, or null. +/proc/get_os_chrome_action(mob/living/carbon/bearer) + for(var/obj/item/organ/ware as anything in get_installed_cyberware(bearer)) + if(ware.slot != ORGAN_SLOT_CYBERWARE_OS) + continue + for(var/datum/action/ability in ware.actions) + if(!QDELETED(ability) && ability.owner == bearer && ability.owner_has_control) + return ability + return null + +/// The bearer's chrome wheel, made on first use. Null for a body with no chrome +/// abilities and no wheel yet, so a plain body never grows the component. +/proc/get_chrome_wheel(mob/living/carbon/bearer) + if(!iscarbon(bearer)) + return null + var/datum/component/chrome_wheel/wheel = bearer.GetComponent(/datum/component/chrome_wheel) + if(wheel || !length(get_chrome_wheel_actions(bearer))) + return wheel + wheel = bearer.AddComponent(/datum/component/chrome_wheel) + wheel?.sync_abilities() + return wheel + +// ---- Sub-option hooks -------------------------------------------------- + +/** + * One choice an ability offers. [id] must stay the same between calls for the + * same choice: the wheel remembers a pick by id and asks the ability for its + * options again before firing it. + */ +/datum/chrome_wheel_option + /// Stable key for this choice within its ability. Non-empty text: a false + /// id reads as "no option" and would fire the ability itself. + var/id + /// What the readout calls the pick. + var/name + var/icon + var/icon_state + +/datum/chrome_wheel_option/New(id, name, icon, icon_state) + src.id = id + src.name = name + src.icon = icon + src.icon_state = icon_state + +/** + * Choices this ability offers on top of firing it plainly: a list of + * /datum/chrome_wheel_option, or null for none (the default, and every ability + * today). + */ +/datum/action/proc/chrome_wheel_options(mob/living/carbon/bearer) + RETURN_TYPE(/list) + return null + +/** + * Fires one of this ability's chrome wheel sub-options. The default fires the + * ability itself; an override stashes the choice first, then calls Trigger() + * so the button's availability checks and targeting still apply. + */ +/datum/action/proc/use_chrome_wheel_option(mob/living/carbon/bearer, option_id) + return Trigger(bearer) + +/// The option with this id that the ability offers right now, or null. +/proc/chrome_wheel_find_option(datum/action/ability, mob/living/carbon/bearer, option_id) + for(var/datum/chrome_wheel_option/option in ability?.chrome_wheel_options(bearer)) + if(option.id == option_id) + return option + return null + +// ---- Names ------------------------------------------------------------- + +/** + * What the wheel calls this ability: its own name, or for a ware's plain + * deploy or use button, the ware without its housing ("Mantis Blade", not + * "Toggle Mantis Blade housing (left)"). Override for a better one. + */ +/datum/action/proc/chrome_wheel_name() + var/obj/item/organ/ware = target + if(istype(ware) && (istype(src, /datum/action/item_action/organ_action/toggle) || istype(src, /datum/action/item_action/organ_action/use))) + var/static/regex/hardware = regex(@"(\s+(spool\s+)?housing|\s+drill fist)?(\s*\((left|right)\))?$", "i") + return hardware.Replace(format_text(ware.name), "") + return format_text(name) + +/// The name of the chrome an ability lives in, or "" for one that lives in nothing. +/proc/chrome_wheel_ware_name(datum/action/ability) + var/obj/item/organ/ware = ability?.target + return istype(ware) ? format_text(ware.name) : "" + +/// Display names, ability => text. +/proc/chrome_wheel_names(list/abilities) + RETURN_TYPE(/list) + . = list() + for(var/datum/action/ability as anything in abilities) + .[ability] = ability.chrome_wheel_name() + +// ---- Layout ------------------------------------------------------------ + +/// Which socket an organ's abilities sit in, from its slot and the zone it lives in. +/proc/chrome_wheel_socket(obj/item/organ/ware) + if(!istype(ware)) + return CHROME_WHEEL_SOCKET_OS + if(ware.slot == ORGAN_SLOT_EYES || ware.zone == BODY_ZONE_PRECISE_EYES) + return CHROME_WHEEL_SOCKET_EYES + if(ware.slot == ORGAN_SLOT_CYBERWARE_OS) + return CHROME_WHEEL_SOCKET_OS + if(ware.slot == ORGAN_SLOT_CYBERWARE_SKIN) + return CHROME_WHEEL_SOCKET_SKIN + switch(ware.zone) + if(BODY_ZONE_HEAD, BODY_ZONE_PRECISE_MOUTH) + return CHROME_WHEEL_SOCKET_HEAD + if(BODY_ZONE_R_ARM, BODY_ZONE_PRECISE_R_HAND) + return CHROME_WHEEL_SOCKET_RIGHT_ARM + if(BODY_ZONE_L_ARM, BODY_ZONE_PRECISE_L_HAND) + return CHROME_WHEEL_SOCKET_LEFT_ARM + if(BODY_ZONE_R_LEG, BODY_ZONE_L_LEG, BODY_ZONE_PRECISE_R_FOOT, BODY_ZONE_PRECISE_L_FOOT) + return CHROME_WHEEL_SOCKET_LEGS + // The chest and anything else: the OS's arc, after the OS. + return CHROME_WHEEL_SOCKET_OS + +/// Which socket an ability's chip sits in: its chrome's, or for Arm chrome the right arm's. +/proc/chrome_wheel_ability_socket(datum/action/ability) + if(istype(ability, /datum/action/chrome_arms)) + return CHROME_WHEEL_SOCKET_RIGHT_ARM + return chrome_wheel_socket(ability.target) + +/// What claims an ability a reserved position (GLOB.chrome_wheel_reserved): +/// its chrome's organ slot, or CHROME_WHEEL_ARMS_KEY for Arm chrome. +/proc/chrome_wheel_reserve_key(datum/action/ability) + if(istype(ability, /datum/action/chrome_arms)) + return CHROME_WHEEL_ARMS_KEY + var/obj/item/organ/ware = ability.target + return istype(ware) ? ware.slot : null + +/// Hand chrome rides its arm's socket, after the arm's own chrome, with its +/// own leader to the hand. +/proc/chrome_wheel_is_hand(obj/item/organ/ware) + if(!istype(ware)) + return FALSE + return ware.slot == ORGAN_SLOT_CYBERWARE_HANDS || ware.zone == BODY_ZONE_PRECISE_L_HAND || ware.zone == BODY_ZONE_PRECISE_R_HAND + +/// Where an organ slot ranks inside its socket. Unlisted slots rank last. +/proc/chrome_wheel_slot_rank(obj/item/organ/ware) + var/rank = istype(ware) ? GLOB.chrome_wheel_slot_order.Find(ware.slot) : 0 + return rank || length(GLOB.chrome_wheel_slot_order) + 1 + +/// Order inside a socket: hand chrome last, then ranked organ slots, other +/// slots by name, and each organ's own button order. +/proc/cmp_chrome_wheel_abilities(datum/action/first, datum/action/second) + var/obj/item/organ/first_ware = first.target + var/obj/item/organ/second_ware = second.target + // Abilities that live in no organ (Arm chrome) go last; their place is reserved anyway. + if(!isorgan(first_ware) || !isorgan(second_ware)) + return !isorgan(first_ware) - !isorgan(second_ware) + var/hand_gap = chrome_wheel_is_hand(first_ware) - chrome_wheel_is_hand(second_ware) + if(hand_gap) + return hand_gap + var/rank_gap = chrome_wheel_slot_rank(first_ware) - chrome_wheel_slot_rank(second_ware) + if(rank_gap) + return rank_gap + if(first_ware != second_ware) + var/first_slot = istype(first_ware) ? first_ware.slot : "" + var/second_slot = istype(second_ware) ? second_ware.slot : "" + return sorttext(second_slot, first_slot) || sorttext(second.name, first.name) + return LAZYFIND(first_ware.actions, first) - LAZYFIND(second_ware.actions, second) + +/// How many chips the socket's arc holds before another row starts. +/proc/chrome_wheel_socket_fits(socket) + var/list/spec = GLOB.chrome_wheel_sockets[socket] + return spec ? spec["fits"] : 1 + +/** + * Pixel offset from the centre of the view of position [index] in [socket], + * as list(x, y). Positions run along the socket's arc CHROME_WHEEL_STEP + * degrees apart; once the arc is full they start again a row further out. + */ +/proc/chrome_wheel_position(socket, index) + RETURN_TYPE(/list) + var/list/spec = GLOB.chrome_wheel_sockets[socket] + var/fits = spec["fits"] + var/row = round((index - 1) / fits) + var/angle = spec["start"] + spec["turn"] * ((index - 1) % fits) * CHROME_WHEEL_STEP + var/radius = CHROME_WHEEL_RADIUS + row * CHROME_WHEEL_ROW_GAP + return list(round(sin(angle) * radius, 1), round(cos(angle) * radius + CHROME_WHEEL_CENTRE_Y, 1)) + +/** + * Sorts the abilities into sockets: ability => list("socket", "index", + * "hand"). Where an ability lands depends only on its own socket's chrome, + * never on what the rest of the body carries. + */ +/proc/chrome_wheel_placements(list/abilities) + RETURN_TYPE(/list) + var/list/by_socket = list() + for(var/datum/action/ability as anything in abilities) + var/socket = chrome_wheel_ability_socket(ability) + if(!by_socket[socket]) + by_socket[socket] = list() + var/list/members = by_socket[socket] + members += ability + var/list/placements = list() + for(var/socket in by_socket) + var/list/members = sortTim(by_socket[socket], GLOBAL_PROC_REF(cmp_chrome_wheel_abilities)) + var/list/reserved = GLOB.chrome_wheel_reserved[socket] + var/reserved_slot = length(reserved) ? reserved[1] : null + var/reserved_count = length(reserved) ? reserved[2] : 0 + var/next_reserved = 1 + var/next_free = reserved_count + 1 + for(var/datum/action/ability as anything in members) + var/obj/item/organ/ware = ability.target + var/index + if(reserved_slot && chrome_wheel_reserve_key(ability) == reserved_slot && next_reserved <= reserved_count) + index = next_reserved++ + else + index = next_free++ + placements[ability] = list("socket" = socket, "index" = index, "hand" = chrome_wheel_is_hand(ware)) + return placements + +/// Where each ability's chip sits: ability => list(x, y), from the centre of the view. +/proc/chrome_wheel_layout(list/abilities) + RETURN_TYPE(/list) + var/list/placements = chrome_wheel_placements(abilities) + . = list() + for(var/datum/action/ability as anything in placements) + var/list/placement = placements[ability] + .[ability] = chrome_wheel_position(placement["socket"], placement["index"]) + +// ---- Pointing ---------------------------------------------------------- + +/// Bearing of an offset from the centre of the view, as seen from the ring's +/// centre: degrees clockwise from twelve o'clock. +/proc/chrome_wheel_bearing(x, y) + return delta_to_angle(x, y - CHROME_WHEEL_CENTRE_Y) + +/** + * Which of [points] (a list of list(x, y) chip centres) the mouse at offset + * (dx, dy) means, as an index, or 0 for none. Inside the body nothing is + * pointed at. A chip right under the mouse is the one meant; anywhere else, + * the mouse points at the chip whose bearing from the ring's centre is + * nearest its own, so a quick flick outward works without landing on it. + * [on_ring], if given, says which points a bearing can pick (the first row); + * the rest only answer the mouse right on them. With [reach], a bearing only + * picks within that many pixels of the ring's centre. + */ +/proc/chrome_wheel_pick(dx, dy, list/points, list/on_ring, reach) + var/ring_y = dy - CHROME_WHEEL_CENTRE_Y + var/from_centre = sqrt(dx ** 2 + ring_y ** 2) + if(from_centre < CHROME_WHEEL_DEADZONE) + return 0 + var/nearest = 0 + var/nearest_gap = INFINITY + for(var/i in 1 to length(points)) + var/list/point = points[i] + var/gap = sqrt((point[1] - dx) ** 2 + (point[2] - dy) ** 2) + if(gap < nearest_gap) + nearest = i + nearest_gap = gap + if(nearest_gap <= CHROME_WHEEL_PICK_RANGE) + return nearest + if(reach && from_centre > reach) + return 0 + var/mouse_bearing = delta_to_angle(dx, ring_y) + var/pointed = 0 + var/pointed_turn = INFINITY + for(var/i in 1 to length(points)) + if(on_ring && !on_ring[i]) + continue + var/list/point = points[i] + var/turn = abs(WRAP(mouse_bearing - chrome_wheel_bearing(point[1], point[2]) + 180, 0, 360) - 180) + if(turn < pointed_turn) + pointed = i + pointed_turn = turn + return pointed_turn <= CHROME_WHEEL_POINT_TOLERANCE ? pointed : 0 + +/// The mouse position in a screen mouse params string, as pixels from the +/// centre of the viewer's map: list(x, y), or null if the params have none. +/proc/chrome_wheel_mouse_offset(params, client/viewer) + if(!viewer) + return null + var/list/modifiers = params2list(params) + var/screen_loc = LAZYACCESS(modifiers, SCREEN_LOC) + if(!screen_loc) + return null + var/list/pixels = screen_loc_to_offset(screen_loc, viewer.view) + var/list/view_pixels = view_to_pixels(viewer.view) + // screen_loc_to_offset counts tiles from 1, so the first tile starts a tile in. + return list(pixels[1] - ICON_SIZE_X - view_pixels[1] / 2, pixels[2] - ICON_SIZE_Y - view_pixels[2] / 2) + +/// The key a bind sits on, without its modifiers: "ShiftV" is held while "V" +/// is. Bare modifier binds ("Alt") stay as they are. +/proc/chrome_wheel_raw_key(full_key) + var/raw = full_key + var/last_modifier + for(var/modifier in list("Alt", "Ctrl", "Shift")) + if(findtextEx(raw, modifier) == 1) + raw = copytext(raw, length(modifier) + 1) + last_modifier = modifier + return raw || last_modifier + +// ---- Looks ------------------------------------------------------------- + +/// The radial.dmi "module_selected" frame the Chrome button puts round the pick, shared. +/proc/chrome_wheel_marker(frame_state) + var/static/list/markers = list() + if(!markers[frame_state]) + markers[frame_state] = mutable_appearance('icons/hud/radial.dmi', frame_state, FLOAT_LAYER - 0.1) + return markers[frame_state] + +/** + * What an ability's chip shows: the ability's own button look, minus the + * button background and text (chrome_ability_look(), chrome_hud.dm), so the + * chip carries the same icon and item overlay a button would. + */ +/proc/chrome_wheel_ability_look(datum/action/ability) + RETURN_TYPE(/mutable_appearance) + var/mutable_appearance/look = chrome_ability_look(ability) + // Keeps its own colour, follows the chip's pop, and shrinks smoothly. + look.appearance_flags = RESET_COLOR | NO_CLIENT_COLOR + return look + +/// Whether an ability is "on" right now: a toggled arm with its hardware out, +/// or a click-to-target ability armed and waiting for the click. +/proc/chrome_wheel_ability_active(datum/action/ability, mob/living/carbon/bearer) + // Arm chrome is on while any arm has its hardware out. + if(istype(ability, /datum/action/chrome_arms)) + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/housing as anything in get_chrome_arm_housings(bearer)) + if(housing.chrome_arm_deployed()) + return TRUE + return FALSE + // The zoom is a toggle, not a click-to-target: it is on while the optics are zoomed. + if(istype(ability, /datum/action/cooldown/cyberware/optics_zoom)) + var/datum/action/cooldown/cyberware/optics_zoom/zoom = ability + var/obj/item/organ/eyes/robotic/cyberware/optics = zoom.organ + return istype(optics) && optics.is_zoomed() + if(istype(ability, /datum/action/cooldown)) + return bearer.click_intercept == ability + var/obj/item/organ/cyberimp/arm/toolkit/arm = ability.target + if(istype(arm) && istype(ability, /datum/action/item_action/organ_action/toggle)) + return arm.active_item && !(arm.active_item in arm) + return FALSE + +/// Deciseconds left on an ability's cooldown, 0 for one that has none. +/proc/chrome_wheel_cooldown_left(datum/action/ability) + var/datum/action/cooldown/timed = ability + return istype(timed) ? max(timed.next_use_time - world.time, 0) : 0 + +/// Whether the chrome an ability lives in is down: rebooting from an EMP, or +/// browned out over capacity. Arm chrome is down when every arm is. +/proc/chrome_wheel_offline(datum/action/ability) + if(istype(ability, /datum/action/chrome_arms)) + var/list/housings = get_chrome_arm_housings(ability.owner) + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/housing as anything in housings) + var/datum/component/cyberware/arm_chrome = housing.GetComponent(/datum/component/cyberware) + if(arm_chrome?.is_running()) + return FALSE + return length(housings) > 0 + var/obj/item/organ/ware = ability.target + var/datum/component/cyberware/chrome = istype(ware) ? ware.GetComponent(/datum/component/cyberware) : null + return chrome && !chrome.is_running() + +/// Whether an ability can't be used right now for any other reason than its +/// chrome being down or its cooldown: its button's own checks say no. +/proc/chrome_wheel_unavailable(datum/action/ability, cooldown_left) + // On cooldown IsAvailable() is FALSE anyway; the shade shows that instead. + return !cooldown_left && !ability.IsAvailable() + +/// The tier colour of the chrome an ability lives in. Arm chrome wears the +/// colour of the best arm hardware it deploys. +/proc/chrome_wheel_tier_color(datum/action/ability) + if(istype(ability, /datum/action/chrome_arms)) + var/best_tier = 0 + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/housing as anything in get_chrome_arm_housings(ability.owner)) + var/datum/component/cyberware/arm_chrome = housing.GetComponent(/datum/component/cyberware) + best_tier = max(best_tier, arm_chrome?.tier || 0) + return best_tier ? cyberware_tier_color(best_tier) : CHROME_WHEEL_HUD_COLOR + var/obj/item/organ/ware = ability.target + var/datum/component/cyberware/chrome = istype(ware) ? ware.GetComponent(/datum/component/cyberware) : null + return chrome ? cyberware_tier_color(chrome.tier) : CHROME_WHEEL_HUD_COLOR + +/// [color] taken [amount] of the way to white. +/proc/chrome_wheel_lighten(color, amount) + var/list/channels = rgb2num(color) + return rgb(round(channels[1] + (255 - channels[1]) * amount), round(channels[2] + (255 - channels[2]) * amount), round(channels[3] + (255 - channels[3]) * amount)) + +/// One of the chip art states as an overlay that keeps its own colour. +/proc/chrome_wheel_chip_piece(piece_state, piece_color, piece_alpha = 255) + var/mutable_appearance/piece = mutable_appearance(CHROME_WHEEL_ICON, piece_state, FLOAT_LAYER, appearance_flags = RESET_COLOR | NO_CLIENT_COLOR | PIXEL_SCALE) + piece.color = piece_color + piece.alpha = piece_alpha + return piece + +/// Sorts chips clockwise from twelve o'clock, the order they pop in. +/proc/cmp_chrome_wheel_bearing(atom/movable/screen/chrome_wheel/chip/first, atom/movable/screen/chrome_wheel/chip/second) + return chrome_wheel_bearing(first.chip_x, first.chip_y) - chrome_wheel_bearing(second.chip_x, second.chip_y) + +// ---- The wheel --------------------------------------------------------- + +/datum/component/chrome_wheel + /// The ability Use chrome fires. + var/datum/weakref/selected_ref + /// The id of the sub-option of that ability Use chrome fires instead, if one was picked. + var/selected_option + /// The ability whose buttons carry the selection frame. + var/datum/weakref/marked_ref + /// CHROME_WHEEL_CLOSED, CHROME_WHEEL_HELD or CHROME_WHEEL_CLICK. + var/wheel_mode = CHROME_WHEEL_CLOSED + /// REALTIMEOFDAY when the wheel key went down. + var/press_time = 0 + /// The client the wheel is drawn on, so it comes off that screen even after + /// the client has moved to another mob. + var/client/shown_to + /// Screen-centre object every visible part of the wheel hangs off. + var/atom/movable/screen/chrome_wheel/hub/hub + /// Full-view mouse tracker under the wheel. + var/atom/movable/screen/fullscreen/cursor_catcher/chrome_wheel/catcher + /// Every screen object the open wheel made, for teardown. + var/list/parts + /// One chip per ability. + var/list/chips + /// Leader key => list("leader", "node", "node_state", "alpha"): the line + /// from a socket (or a hand chip) to the body, and its dot on the body. + var/list/leaders + /// Arc name => its piece of ring art. + var/list/arcs + /// The body part lit under the chip pointed at. + var/atom/movable/screen/chrome_wheel/art/glow + /// The chip the mouse is on. + var/atom/movable/screen/chrome_wheel/chip/highlighted + /// Readout lines, and the pick mark it shows when nothing is pointed at. + var/atom/movable/screen/chrome_wheel/readout/readout_title + var/atom/movable/screen/chrome_wheel/readout/readout_sub + var/atom/movable/screen/chrome_wheel/readout/readout_status + var/atom/movable/screen/chrome_wheel/readout/readout_mark + /// What the readout last showed. + var/readout_state + /// First mouse position reported after opening. Nothing is pointed at until + /// the mouse leaves it, so a cursor that was resting somewhere when the + /// key went down picks nothing by accident. + var/list/mouse_start + /// Whether the mouse has left [mouse_start]. + var/mouse_moved = FALSE + /// A closed wheel still fading out: its client, its pieces and the timer + /// that takes them away. + var/client/fading_client + var/list/fading_parts + var/fading_timer + /// The second body-part glow, for a chip that lights both arms. + var/atom/movable/screen/chrome_wheel/art/glow_twin + /// Opened from the Chrome button: a chip clicked is fired as well as picked. + var/fire_on_pick = FALSE + /// The one HUD button chrome gets (chrome_hud.dm), while any chrome has an ability. + var/datum/action/chrome_button/hud_button + /// Arm chrome (chrome_wheel_arms.dm), while there is arm hardware to deploy. + var/datum/action/chrome_arms/arm_action + /// What the Chrome button last showed, so it only redraws on a change. + var/button_state + /// Set while sync_abilities() runs: granting and removing actions calls back into it. + var/syncing = FALSE + +/datum/component/chrome_wheel/Initialize() + if(!iscarbon(parent)) + return COMPONENT_INCOMPATIBLE + +/datum/component/chrome_wheel/RegisterWithParent() + RegisterSignal(parent, COMSIG_MOB_LOGOUT, PROC_REF(on_logout)) + RegisterSignal(parent, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_change)) + // Things the Chrome button shows that no button redraw announces: chrome going + // down or coming back (checked every Life), an EMP, arm hardware in or out of a hand. + RegisterSignal(parent, COMSIG_LIVING_LIFE, PROC_REF(on_life)) + RegisterSignal(parent, COMSIG_ATOM_EMP_ACT, PROC_REF(on_emp)) + RegisterSignals(parent, list(COMSIG_MOB_EQUIPPED_ITEM, COMSIG_MOB_UNEQUIPPED_ITEM), PROC_REF(on_hands_changed)) + // A stun drops whatever chrome was armed, like death or passing out does. + RegisterSignal(parent, SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), PROC_REF(on_incapacitated)) + +/datum/component/chrome_wheel/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_MOB_LOGOUT, COMSIG_MOB_STATCHANGE, COMSIG_LIVING_LIFE, COMSIG_ATOM_EMP_ACT, COMSIG_MOB_EQUIPPED_ITEM, COMSIG_MOB_UNEQUIPPED_ITEM, SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED))) + +/datum/component/chrome_wheel/Destroy(force) + close_wheel() + clear_fading() + unmark() + selected_ref = null + QDEL_NULL(hud_button) + QDEL_NULL(arm_action) + return ..() + +/datum/component/chrome_wheel/proc/on_logout(datum/source) + SIGNAL_HANDLER + close_wheel() + clear_fading() + +/datum/component/chrome_wheel/proc/on_stat_change(datum/source, new_stat, old_stat) + SIGNAL_HANDLER + if(new_stat != CONSCIOUS) + disarm() + if(new_stat >= UNCONSCIOUS) + close_wheel() + refresh_button() + +/datum/component/chrome_wheel/proc/on_incapacitated(datum/source) + SIGNAL_HANDLER + disarm() + +/// Drops the aim of a chrome ability armed and waiting for its click. The cooldown is untouched. +/datum/component/chrome_wheel/proc/disarm() + var/mob/living/carbon/bearer = parent + var/datum/action/cooldown/cyberware/armed = bearer.click_intercept + if(istype(armed) && armed.owner == bearer) + armed.unset_click_ability(bearer, refund_cooldown = TRUE) + refresh_button() + +/datum/component/chrome_wheel/proc/on_life(datum/source, seconds_per_tick, times_fired) + SIGNAL_HANDLER + refresh_button() + +/datum/component/chrome_wheel/proc/on_emp(datum/source, severity, protection) + SIGNAL_HANDLER + // The chrome takes the pulse after the body's signal; look once it has. + addtimer(CALLBACK(src, PROC_REF(refresh_button)), 1, TIMER_UNIQUE | TIMER_OVERRIDE) + +/datum/component/chrome_wheel/proc/on_hands_changed(datum/source, obj/item/item) + SIGNAL_HANDLER + refresh_button() + +// ---- HUD --------------------------------------------------------------- + +/** + * Gives or takes the Chrome button and Arm chrome to match the chrome the + * body carries now. Runs whenever a chrome ability is granted or removed + * (chrome_hud.dm), so the button comes with the first chrome ability and + * goes with the last. + */ +/datum/component/chrome_wheel/proc/sync_abilities() + if(syncing || QDELETED(src)) + return + var/mob/living/carbon/bearer = parent + if(QDELETED(bearer)) + return + syncing = TRUE + if(length(get_chrome_arm_housings(bearer))) + if(!arm_action) + arm_action = new(src) + if(arm_action.owner != bearer) + arm_action.Grant(bearer) + else if(arm_action) + QDEL_NULL(arm_action) + if(length(get_chrome_wheel_actions(bearer))) + if(!hud_button) + hud_button = new(src) + if(hud_button.owner != bearer) + hud_button.Grant(bearer) + else if(hud_button) + QDEL_NULL(hud_button) + syncing = FALSE + refresh_button(force = TRUE) + +/// The ability the Chrome button shows: a chrome ability armed and waiting for +/// its click (Use OS chrome can arm one that isn't the pick), else the pick, +/// while its chrome is still in this body. +/datum/component/chrome_wheel/proc/get_button_pick() + var/mob/living/carbon/bearer = parent + var/datum/action/cooldown/cyberware/armed = bearer?.click_intercept + if(istype(armed) && armed.owner == bearer && !QDELETED(armed)) + return armed + var/datum/action/ability = selected_ref?.resolve() + if(!ability || QDELETED(ability) || ability.owner != parent) + return null + return ability + +/// A chrome ability's button would have redrawn: so does the Chrome button, if it shows that one. +/datum/component/chrome_wheel/proc/on_ability_changed(datum/action/ability) + // Or the one it showed until now: a disarmed ability hands the button back to the pick. + if(ability == get_button_pick() || (button_state && findtext(button_state, REF(ability)))) + refresh_button() + +/// Redraws the Chrome button when what it shows has changed, or always with [force]. +/datum/component/chrome_wheel/proc/refresh_button(force = FALSE) + // No HUD shows it (no client, an NPC): a button made later is drawn current anyway. + if(!hud_button || QDELETED(hud_button) || !length(hud_button.viewers)) + button_state = null + return + var/mob/living/carbon/bearer = parent + var/datum/action/pick = get_button_pick() + var/state = "none" + if(pick) + var/cooldown_left = chrome_wheel_cooldown_left(pick) + state = "[REF(pick)]|[chrome_ability_look_key(pick)]|[CEILING(cooldown_left / 10, 1)]|[chrome_wheel_offline(pick)]|[pick.IsAvailable()]|[chrome_wheel_ability_active(pick, bearer)]" + if(!force && state == button_state) + return + button_state = state + hud_button.build_all_button_icons(ALL, TRUE) + +/// The Chrome button was clicked: open the wheel for the mouse, or shut it. +/datum/component/chrome_wheel/proc/button_clicked() + if(is_open()) + close_wheel() + return + open_wheel(CHROME_WHEEL_CLICK, fire = TRUE) + +/// The "Deploy arm chrome" key: fire Arm chrome, as its chip would. +/datum/component/chrome_wheel/proc/use_arms() + var/mob/living/carbon/bearer = parent + if(!arm_action || arm_action.owner != bearer) + bearer.balloon_alert(bearer, "no arm chrome!") + return FALSE + return fire(arm_action) + +/// Whether the wheel is on screen. +/datum/component/chrome_wheel/proc/is_open() + return wheel_mode != CHROME_WHEEL_CLOSED + +// ---- Keys -------------------------------------------------------------- + +/// Wheel key down: open the wheel, or shut one a tap left open. +/datum/component/chrome_wheel/proc/wheel_key_down() + switch(wheel_mode) + if(CHROME_WHEEL_CLICK) + close_wheel() + return + if(CHROME_WHEEL_HELD) + return + if(open_wheel(CHROME_WHEEL_HELD)) + press_time = REALTIMEOFDAY + +/// Wheel key up: after a tap the wheel stays open for a click; after a hold, +/// whatever the mouse is on is picked and the wheel closes. +/datum/component/chrome_wheel/proc/wheel_key_up() + if(wheel_mode != CHROME_WHEEL_HELD) + return + if(REALTIMEOFDAY - press_time < CHROME_WHEEL_HOLD_TIME) + wheel_mode = CHROME_WHEEL_CLICK + return + choose(highlighted) + +/** + * Whether a key the "Chrome wheel" bind sits on is still down. keyUp only + * reaches binds by their bare key (bindings_client.dm), so a bind on a + * modifier combo such as ShiftV never hears its own release; while the wheel + * is held open, this poll catches it instead. + */ +/datum/component/chrome_wheel/proc/wheel_key_held() + var/mob/living/carbon/bearer = parent + var/client/viewer = bearer.client + if(!viewer) + return FALSE + var/list/bindings = viewer.prefs?.key_bindings + for(var/full_key in LAZYACCESS(bindings, CHROME_WHEEL_KEYBIND)) + if(viewer.keys_held[chrome_wheel_raw_key(full_key)]) + return TRUE + return FALSE + +/// Use chrome: fire the picked ability. With nothing picked, a lone ability +/// is fired; with several, the wheel opens for a click. +/datum/component/chrome_wheel/proc/use_selected() + if(wheel_mode != CHROME_WHEEL_CLOSED) + if(highlighted) + select_chip(highlighted, quiet = TRUE) + close_wheel() + var/datum/action/ability = get_selected_ability() + if(ability) + return fire(ability, selected_option) + var/mob/living/carbon/bearer = parent + var/list/abilities = get_chrome_wheel_actions(bearer) + switch(length(abilities)) + if(0) + bearer.balloon_alert(bearer, "no chrome!") + if(1) + select(abilities[1]) + return fire(abilities[1]) + else + open_wheel(CHROME_WHEEL_CLICK) + return FALSE + +/// Use OS chrome: fire the OS-slot ware's ability, leaving the pick alone. +/datum/component/chrome_wheel/proc/use_os() + var/mob/living/carbon/bearer = parent + var/datum/action/ability = get_os_chrome_action(bearer) + if(!ability) + bearer.balloon_alert(bearer, "no OS chrome!") + return FALSE + return fire(ability) + +/** + * Fires an ability exactly as its button would: Trigger() with the bearer as + * the clicker, so availability feedback, cooldowns and targeting modes are the + * button's own. Paced like a keybound action button (action.dm keydown()). + */ +/datum/component/chrome_wheel/proc/fire(datum/action/ability, option_id) + var/mob/living/carbon/bearer = parent + if(bearer.next_click > world.time) + return FALSE + bearer.next_click = world.time + CLICK_CD_ACTIVATE_ABILITY + // Async because some triggers wait on the player: a multi-tool arm opens its own radial. + if(option_id) + INVOKE_ASYNC(ability, TYPE_PROC_REF(/datum/action, use_chrome_wheel_option), bearer, option_id) + else + INVOKE_ASYNC(ability, TYPE_PROC_REF(/datum/action, Trigger), bearer) + // A toggle (zoom, arm hardware) changes nothing a redraw announces. + refresh_button() + return TRUE + +// ---- Selection --------------------------------------------------------- + +/datum/component/chrome_wheel/proc/select(datum/action/ability, option_id) + selected_ref = WEAKREF(ability) + selected_option = option_id + mark(ability) + for(var/atom/movable/screen/chrome_wheel/chip/chip as anything in chips) + draw_chip(chip) + update_readout() + +/datum/component/chrome_wheel/proc/deselect() + selected_ref = null + selected_option = null + unmark() + +/// The picked ability, while it is still chrome in this body and its picked +/// option is still on offer. A pick that went stale is dropped. +/datum/component/chrome_wheel/proc/get_selected_ability() + var/datum/action/ability = selected_ref?.resolve() + if(!ability) + if(selected_ref) + deselect() + return null + var/mob/living/carbon/bearer = parent + if(!(ability in get_chrome_wheel_actions(bearer)) || (selected_option && !chrome_wheel_find_option(ability, bearer, selected_option))) + deselect() + return null + return ability + +/// Shows the pick on the Chrome button, and watches it for leaving the body. +/datum/component/chrome_wheel/proc/mark(datum/action/ability) + if(marked_ref?.resolve() != ability) + unmark() + marked_ref = WEAKREF(ability) + RegisterSignal(ability, COMSIG_ACTION_REMOVED, PROC_REF(on_marked_removed)) + refresh_button() + +/datum/component/chrome_wheel/proc/unmark() + var/datum/action/marked = marked_ref?.resolve() + marked_ref = null + if(marked) + UnregisterSignal(marked, COMSIG_ACTION_REMOVED) + refresh_button() + +/// The picked ability left this body (the ware was cut out, or moved to someone +/// else): drop the pick now, so it never follows it into another body. +/datum/component/chrome_wheel/proc/on_marked_removed(datum/action/source, mob/old_owner) + SIGNAL_HANDLER + if(old_owner == parent) + deselect() + +/// Picks the ability on [chip] while it is still chrome in this body. Returns +/// whether it did: a ware cut out while the wheel was held open drops out here, +/// so its chip can't be picked and the pick can't follow it into someone else. +/datum/component/chrome_wheel/proc/select_chip(atom/movable/screen/chrome_wheel/chip/chip, quiet = FALSE) + var/datum/action/ability = chip?.ability_ref?.resolve() + if(!ability || !(ability in get_chrome_wheel_actions(parent))) + return FALSE + select(ability) + if(!quiet) + var/mob/living/carbon/bearer = parent + bearer.balloon_alert(bearer, lowertext(chip.name)) + return TRUE + +/// Pick [chip] (or nothing, for null) and close the wheel. The pick lands at +/// once; the wheel stays up a moment longer for the lock and the fade. A wheel +/// opened from the Chrome button fires the pick as well. +/datum/component/chrome_wheel/proc/choose(atom/movable/screen/chrome_wheel/chip/chip) + var/fire_it = fire_on_pick + var/picked = chip && select_chip(chip, quiet = fire_it) + close_wheel(linger = TRUE, chosen = picked ? chip : null) + if(picked && fire_it) + var/datum/action/ability = get_selected_ability() + if(ability) + fire(ability, selected_option) + +// ---- Opening and closing ----------------------------------------------- + +/// Opens the wheel in [mode]. With [fire], a chip clicked is fired as well as picked. +/datum/component/chrome_wheel/proc/open_wheel(mode, fire = FALSE) + var/mob/living/carbon/bearer = parent + var/client/viewer = bearer.client + if(wheel_mode != CHROME_WHEEL_CLOSED || !viewer || bearer.stat >= UNCONSCIOUS) + return FALSE + var/list/abilities = get_chrome_wheel_actions(bearer) + if(!length(abilities)) + bearer.balloon_alert(bearer, "no chrome!") + return FALSE + clear_fading() + build_wheel(abilities) + + catcher = new + catcher.wheel = src + catcher.assign_to_mob(bearer) + catcher.update_for_view(viewer.view) + shown_to = viewer + viewer.screen += catcher + viewer.screen += hub + play_open() + + wheel_mode = mode + fire_on_pick = fire + mouse_start = null + mouse_moved = FALSE + START_PROCESSING(SSfastprocess, src) + return TRUE + +/** + * Makes every piece of the wheel for [abilities] and hangs it off a new hub, + * without putting anything on a screen. + */ +/datum/component/chrome_wheel/proc/build_wheel(list/abilities) + var/list/placements = chrome_wheel_placements(abilities) + var/list/names = chrome_wheel_names(abilities) + parts = list() + chips = list() + leaders = list() + arcs = list() + readout_state = null + hub = new + parts += hub + add_piece(/atom/movable/screen/chrome_wheel/art/backdrop) + add_piece(/atom/movable/screen/chrome_wheel/art, "body") + glow = add_piece(/atom/movable/screen/chrome_wheel/art, null, 2.2) + glow.alpha = 0 + glow_twin = add_piece(/atom/movable/screen/chrome_wheel/art, null, 2.2) + glow_twin.alpha = 0 + var/list/arc_names = list() + for(var/socket in GLOB.chrome_wheel_sockets) + arc_names |= GLOB.chrome_wheel_sockets[socket]["arc"] + for(var/arc_name in arc_names) + arcs[arc_name] = add_piece(/atom/movable/screen/chrome_wheel/art, "arc_[arc_name]", 2.25) + + // Which sockets hold chrome of their own, and which positions are taken. + var/list/occupied = list() + var/list/taken = list() + for(var/datum/action/ability as anything in placements) + var/list/placement = placements[ability] + taken["[placement["socket"]]|[placement["index"]]"] = TRUE + // Arm chrome borrows the right arm's arc; it doesn't make the right arm chromed. + if(!placement["hand"] && !istype(ability, /datum/action/chrome_arms)) + occupied[placement["socket"]] = TRUE + for(var/socket in GLOB.chrome_wheel_sockets) + add_leader(socket, socket, occupied[socket]) + if(!taken["[socket]|1"]) + var/list/point = chrome_wheel_position(socket, 1) + var/atom/movable/screen/chrome_wheel/empty_socket/outline = add_piece(/atom/movable/screen/chrome_wheel/empty_socket) + outline.pixel_x = point[1] + outline.pixel_y = point[2] + + for(var/datum/action/ability as anything in abilities) + var/list/placement = placements[ability] + var/socket = placement["socket"] + var/list/point = chrome_wheel_position(socket, placement["index"]) + var/atom/movable/screen/chrome_wheel/chip/chip = add_piece(/atom/movable/screen/chrome_wheel/chip) + chip.ability_ref = WEAKREF(ability) + chip.name = names[ability] + chip.socket = socket + chip.index = placement["index"] + chip.leader_key = socket + chip.region = GLOB.chrome_wheel_sockets[socket]["region"] + if(istype(ability, /datum/action/chrome_arms)) + // Lights both arms: their arcs, their leaders and the arms on the body. + chip.region = CHROME_WHEEL_REGION_ARMS + else if(placement["hand"]) + var/hand = (socket == CHROME_WHEEL_SOCKET_LEFT_ARM) ? "l_hand" : "r_hand" + chip.region = hand + // The ring art has a run to the hand from each first-row position. + if(chip.index <= chrome_wheel_socket_fits(socket)) + chip.leader_key = "[hand]_[chip.index]" + add_leader(chip.leader_key, hand, TRUE) + chip.chip_x = point[1] + chip.chip_y = point[2] + chip.pixel_x = point[1] + chip.pixel_y = point[2] + chips += chip + draw_chip(chip) + // Nothing is pointed at yet: the arcs start dim, as they are whenever the pointer leaves a chip. + light_up(null) + build_readout() + update_readout() + +/// A new piece of the wheel on the hub. [art_state] sets its icon state and +/// [piece_layer] its layer, when given. +/datum/component/chrome_wheel/proc/add_piece(piece_type, art_state, piece_layer) + var/atom/movable/screen/chrome_wheel/piece = new piece_type + if(art_state) + piece.icon_state = art_state + if(piece_layer) + piece.layer = piece_layer + parts += piece + hub.vis_contents += piece + return piece + +/// The leader for [key] and the dot where it meets the body, from the ring art. +/datum/component/chrome_wheel/proc/add_leader(key, art_key, filled) + if(leaders[key]) + return + var/atom/movable/screen/chrome_wheel/art/line = add_piece(/atom/movable/screen/chrome_wheel/art, "leader_[key]", 2.3) + var/atom/movable/screen/chrome_wheel/art/dot = add_piece(/atom/movable/screen/chrome_wheel/art, "node_[art_key]", 2.4) + leaders[key] = list("leader" = line, "node" = dot, "node_state" = "node_[art_key]", "alpha" = filled ? 100 : 40) + style_leader(key, null) + +/// The readout panel's frame and its empty text lines. +/datum/component/chrome_wheel/proc/build_readout() + var/left = CHROME_WHEEL_READOUT_LEFT + var/top = CHROME_WHEEL_READOUT_TOP + var/width = CHROME_WHEEL_READOUT_WIDTH + var/height = CHROME_WHEEL_READOUT_HEIGHT + add_readout_block(left, top - height, width, height, CHROME_WHEEL_PANEL_COLOR, 205, 4) + add_readout_block(left, top - 1, width, 1, CHROME_WHEEL_HUD_COLOR, 120, 4.1) + add_readout_block(left, top - height, width, 1, CHROME_WHEEL_HUD_COLOR, 120, 4.1) + add_readout_block(left, top - height, 1, height, CHROME_WHEEL_HUD_COLOR, 120, 4.1) + add_readout_block(left + width - 1, top - height, 1, height, CHROME_WHEEL_HUD_COLOR, 120, 4.1) + add_readout_block(left, top - 12, 2, 12, CHROME_WHEEL_HUD_COLOR, 255, 4.1) + // Text boxes are taller than their line and centred on it, as the chrome + // read sets them: Grand9K caps start 5 px under a 16 px box's top, + // TinyUnicode caps 8 px under a 17 px one. + readout_title = add_readout_text(left + 5, top - 11 - 2, width - 9, 16) + readout_sub = add_readout_text(left + 5, top - 9 - 13, width - 9, 17) + readout_status = add_readout_text(left + 5, top - 11 - 3, width - 10, 16) + readout_mark = add_piece(/atom/movable/screen/chrome_wheel/readout, "pick_glyph", 4.3) + readout_mark.color = CHROME_WHEEL_PICKED_COLOR + readout_mark.alpha = 0 + readout_mark.pixel_x = left + 140 + readout_mark.pixel_y = top - 22 + +/datum/component/chrome_wheel/proc/add_readout_block(x, y, width, height, block_color, block_alpha, block_layer) + var/atom/movable/screen/chrome_wheel/readout/block = add_piece(/atom/movable/screen/chrome_wheel/readout, null, block_layer) + block.color = block_color + block.alpha = block_alpha + block.transform = chrome_readout_quad(x, y, width, height) + return block + +/datum/component/chrome_wheel/proc/add_readout_text(x, y, width, height) + var/atom/movable/screen/chrome_wheel/readout/line = add_piece(/atom/movable/screen/chrome_wheel/readout, null, 4.2) + line.icon_state = null + line.maptext_x = x + line.maptext_y = y + line.maptext_width = width + line.maptext_height = height + return line + +/// Fades the wheel in and pops the chips out one after another, clockwise from the top. +/datum/component/chrome_wheel/proc/play_open() + hub.alpha = 0 + animate(hub, alpha = 255, time = 1) + var/list/order = sortTim(chips.Copy(), GLOBAL_PROC_REF(cmp_chrome_wheel_bearing)) + for(var/i in 1 to length(order)) + var/atom/movable/screen/chrome_wheel/chip/chip = order[i] + var/matrix/small = matrix(0.6, 0, 0, 0, 0.6, 0) + chip.transform = small + animate(chip, transform = small, time = (i - 1) * 0.08) + animate(transform = matrix(), time = 0.8, easing = BACK_EASING | EASE_OUT) + +/** + * Shuts the wheel and gives the mouse back to the world. With [linger] the + * pieces stay on screen a moment to fade, after [chosen] locks. + */ +/datum/component/chrome_wheel/proc/close_wheel(linger = FALSE, atom/movable/screen/chrome_wheel/chip/chosen) + STOP_PROCESSING(SSfastprocess, src) + wheel_mode = CHROME_WHEEL_CLOSED + fire_on_pick = FALSE + if(shown_to) + shown_to.screen -= catcher + QDEL_NULL(catcher) + if(linger && shown_to && hub) + clear_fading() + fading_client = shown_to + fading_parts = parts + if(chosen) + play_lock(chosen) + animate(hub, alpha = hub.alpha, time = chosen ? 1 : 0) + animate(alpha = 0, time = 1) + fading_timer = addtimer(CALLBACK(src, PROC_REF(fade_done)), CHROME_WHEEL_LINGER_TIME, TIMER_STOPPABLE | TIMER_CLIENT_TIME | TIMER_DELETE_ME) + else + shown_to?.screen -= hub + QDEL_LIST(parts) + shown_to = null + hub = null + parts = null + chips = null + leaders = null + arcs = null + glow = null + glow_twin = null + highlighted = null + readout_title = null + readout_sub = null + readout_status = null + readout_mark = null + readout_state = null + mouse_start = null + mouse_moved = FALSE + +/datum/component/chrome_wheel/proc/fade_done() + fading_timer = null + clear_fading() + +/// Takes a fading wheel off its screen now. +/datum/component/chrome_wheel/proc/clear_fading() + if(fading_timer) + deltimer(fading_timer) + fading_timer = null + if(fading_client && length(fading_parts)) + fading_client.screen -= fading_parts[1] + fading_client = null + QDEL_LIST(fading_parts) + +/// The pick locking on: its frame flashes white and the brackets snap in. +/datum/component/chrome_wheel/proc/play_lock(atom/movable/screen/chrome_wheel/chip/chip) + var/settled = chip.color + chip.color = "#ffffff" + animate(chip, color = "#ffffff", time = 0.5) + animate(color = settled, time = 0) + for(var/atom/movable/screen/chrome_wheel/bracket/corner as anything in chip.brackets) + if(!corner.alpha) + continue + var/final_x = corner.pixel_x + var/final_y = corner.pixel_y + corner.pixel_x = final_x + corner.out_x * 7 + corner.pixel_y = final_y + corner.out_y * 7 + corner.color = "#ffffff" + animate(corner, pixel_x = final_x, pixel_y = final_y, time = 1, easing = BACK_EASING | EASE_OUT) + animate(corner, color = "#ffffff", time = 0.5, flags = ANIMATION_PARALLEL) + animate(color = CHROME_WHEEL_PICKED_COLOR, time = 0) + +/// While open: catch a modifier bind's release, and keep the chips current. +/datum/component/chrome_wheel/process(seconds_per_tick) + if(wheel_mode == CHROME_WHEEL_CLOSED) + return PROCESS_KILL + if(wheel_mode == CHROME_WHEEL_HELD && !wheel_key_held()) + wheel_key_up() + if(wheel_mode == CHROME_WHEEL_CLOSED) + return PROCESS_KILL + for(var/atom/movable/screen/chrome_wheel/chip/chip as anything in chips) + draw_chip(chip) + update_readout() + +// ---- Drawing ----------------------------------------------------------- + +/** + * Brings a chip up to date: its frame in its tier colour (blinking red while + * the chrome is down), the ability's icon, the green inner line while it is + * deployed or armed, the pick's brackets, and a draining shade with seconds + * while it cools down. Bigger and brighter while pointed at. Redraws only on + * change. + */ +/datum/component/chrome_wheel/proc/draw_chip(atom/movable/screen/chrome_wheel/chip/chip) + var/mob/living/carbon/bearer = parent + var/datum/action/ability = chip.ability_ref?.resolve() + if(!ability) + if(chip.drawn_state != "gone") + chip.drawn_state = "gone" + chip.cut_overlays() + chip.underlays.Cut() + chip.alpha = 70 + return + var/datum/action/cooldown/timed = istype(ability, /datum/action/cooldown) ? ability : null + var/cooldown_left = timed ? max(timed.next_use_time - world.time, 0) : 0 + var/offline = chrome_wheel_offline(ability) + var/unavailable = !offline && chrome_wheel_unavailable(ability, cooldown_left) + var/hovered = (chip == highlighted) + var/picked = (selected_ref?.resolve() == ability) + var/active = chrome_wheel_ability_active(ability, bearer) + var/state = "[offline]|[unavailable]|[hovered]|[picked]|[active]|[timed?.next_use_time]|[!!cooldown_left]|[chrome_ability_look_key(ability)]" + if(state != chip.drawn_state) + chip.drawn_state = state + paint_chip(chip, ability, offline, unavailable, hovered, picked, active) + update_shade(chip, cooldown_left, timed ? max(timed.cooldown_time, cooldown_left) : 0) + if(hovered) + light_up(chip) + update_count(chip, cooldown_left) + +/datum/component/chrome_wheel/proc/paint_chip(atom/movable/screen/chrome_wheel/chip/chip, datum/action/ability, offline, unavailable, hovered, picked, active) + var/size = hovered ? 26 : 22 + chip.size = size + var/base_color = offline ? CHROME_WHEEL_OFFLINE_COLOR : chrome_wheel_tier_color(ability) + chip.icon_state = "frame_[size][offline ? "_blink" : ""]" + chip.color = hovered ? chrome_wheel_lighten(base_color, 0.35) : base_color + chip.alpha = 255 + chip.cut_overlays() + chip.underlays.Cut() + chip.underlays += chrome_wheel_chip_piece("fill_[size]") + if(hovered) + chip.add_overlay(chrome_wheel_chip_piece("halo_26", base_color, 90)) + var/mutable_appearance/look = chrome_wheel_ability_look(ability) + // The icon fills the chip but for a pixel all round. + var/scale = (size - 2) / ICON_SIZE_X + look.transform = matrix(scale, 0, 0, 0, scale, 0) + // Red like its button when it can't be used. + if(offline || unavailable) + look.color = ability.transparent_when_unavailable ? rgb(128, 0, 0, 128) : rgb(128, 0, 0) + chip.add_overlay(look) + if(active) + chip.add_overlay(chrome_wheel_chip_piece("deployed_[size]")) + draw_brackets(chip, picked) + +/// The pick's corner brackets, a couple of pixels clear of the chip's corners. +/datum/component/chrome_wheel/proc/draw_brackets(atom/movable/screen/chrome_wheel/chip/chip, picked) + if(!picked) + for(var/atom/movable/screen/chrome_wheel/bracket/corner as anything in chip.brackets) + corner.alpha = 0 + return + if(!chip.brackets) + chip.brackets = list() + for(var/corner_name in list("nw", "ne", "sw", "se")) + var/atom/movable/screen/chrome_wheel/bracket/corner = new + corner.icon_state = "bracket_[corner_name]" + corner.out_x = findtext(corner_name, "w") ? -1 : 1 + corner.out_y = findtext(corner_name, "n") ? 1 : -1 + chip.brackets += corner + chip.vis_contents += corner + // The bracket art has its corner pixel one in from the edge of its tile; a + // chip's brackets sit two pixels outside its corners. + var/reach = chip.size / 2 + 2 - 15 + for(var/atom/movable/screen/chrome_wheel/bracket/corner as anything in chip.brackets) + animate(corner) + corner.alpha = 255 + corner.color = CHROME_WHEEL_PICKED_COLOR + corner.pixel_x = corner.out_x * reach + corner.pixel_y = corner.out_y * reach + +/// The cooldown wipe: a dark block over the chip's inside that drains downward +/// to nothing as the cooldown runs out, with a faint line along its top. +/// Animated on the client, so it costs no ticks. +/datum/component/chrome_wheel/proc/update_shade(atom/movable/screen/chrome_wheel/chip/chip, cooldown_left, cooldown_total) + if(!cooldown_left) + for(var/atom/movable/screen/chrome_wheel/chip_part/part in list(chip.shade, chip.shade_edge)) + animate(part) + part.alpha = 0 + return + if(!chip.shade) + chip.shade = new + chip.shade.color = COLOR_BLACK + chip.shade_edge = new + chip.shade_edge.layer = 3.2 + chip.vis_contents += list(chip.shade, chip.shade_edge) + var/list/start = chrome_wheel_shade_shape(chip.size, cooldown_left / max(cooldown_total, 1)) + var/list/finish = chrome_wheel_shade_shape(chip.size, 0) + chip.shade.alpha = 185 + chip.shade.transform = start[1] + animate(chip.shade, transform = finish[1], time = cooldown_left) + chip.shade_edge.alpha = 110 + chip.shade_edge.transform = start[2] + animate(chip.shade_edge, transform = finish[2], time = cooldown_left) + +/** + * The cooldown wipe's shape on a chip of [size] with [fraction] of its + * cooldown left: list(shade transform, edge transform). The px state is a + * full tile, squashed to the chip's inside and sitting on its floor; the edge + * is the wipe's top row. + */ +/proc/chrome_wheel_shade_shape(size, fraction) + RETURN_TYPE(/list) + var/inside = size - 2 + var/height = max(inside * min(fraction, 1), 0.3) + return list( + matrix(inside / 32, 0, 0, 0, height / 32, -(inside - height) / 2), + matrix(inside / 32, 0, 0, 0, 1 / 32, max(height, 1) - inside / 2 - 0.5), + ) + +/// Whole seconds left on the cooldown, in the chip's bottom left corner. +/datum/component/chrome_wheel/proc/update_count(atom/movable/screen/chrome_wheel/chip/chip, cooldown_left) + var/seconds = cooldown_left ? CEILING(cooldown_left / 10, 1) : 0 + var/state = "[seconds]|[chip.size]" + if(state == chip.count_state) + return + chip.count_state = state + if(!seconds) + if(chip.count) + chip.count.maptext = null + return + if(!chip.count) + chip.count = new + chip.count.icon_state = null + chip.count.layer = 3.3 + chip.count.maptext_width = 32 + chip.count.maptext_height = 17 + chip.vis_contents += chip.count + // Box centred like the readout's lines (caps 8 px under a 17 px box's top), + // putting the number three pixels in from the chip's bottom left corner. + chip.count.maptext = chrome_readout_tiny_html("[seconds]") + chip.count.maptext_x = 16 - chip.size / 2 + 3 + chip.count.maptext_y = 18 - chip.size / 2 + +/// Sets a leader and its node to [lit_color], or back to the dim HUD colour for null. +/datum/component/chrome_wheel/proc/style_leader(key, lit_color) + var/list/leader = leaders?[key] + if(!leader) + return + var/atom/movable/screen/chrome_wheel/art/line = leader["leader"] + var/atom/movable/screen/chrome_wheel/art/dot = leader["node"] + if(lit_color) + line.color = lit_color + line.alpha = 235 + dot.icon_state = "[leader["node_state"]]_lit" + dot.color = chrome_wheel_lighten(lit_color, 0.6) + dot.alpha = 255 + return + line.color = CHROME_WHEEL_HUD_COLOR + line.alpha = leader["alpha"] + dot.icon_state = leader["node_state"] + dot.color = CHROME_WHEEL_HUD_COLOR + dot.alpha = min(255, leader["alpha"] + 60) + +/// Lights the arc, leader and body part of [chip] in its colour, and puts +/// everything else back. Null lights nothing. +/datum/component/chrome_wheel/proc/light_up(atom/movable/screen/chrome_wheel/chip/chip) + var/datum/action/ability = chip?.ability_ref?.resolve() + var/lit_color + if(ability) + lit_color = chrome_wheel_offline(ability) ? CHROME_WHEEL_OFFLINE_COLOR : chrome_wheel_tier_color(ability) + // Arm chrome lights both arms; anything else its own socket and body part. + var/both_arms = lit_color && chip.region == CHROME_WHEEL_REGION_ARMS + var/list/lit_leaders = list() + var/list/lit_arcs = list() + var/list/lit_regions = list() + if(both_arms) + for(var/arm_socket in list(CHROME_WHEEL_SOCKET_LEFT_ARM, CHROME_WHEEL_SOCKET_RIGHT_ARM)) + lit_leaders += arm_socket + lit_arcs += GLOB.chrome_wheel_sockets[arm_socket]["arc"] + lit_regions += GLOB.chrome_wheel_sockets[arm_socket]["region"] + else if(lit_color) + lit_leaders += chip.leader_key + lit_arcs += GLOB.chrome_wheel_sockets[chip.socket]["arc"] + lit_regions += chip.region + for(var/key in leaders) + style_leader(key, (key in lit_leaders) ? lit_color : null) + for(var/arc_name in arcs) + var/atom/movable/screen/chrome_wheel/art/arc = arcs[arc_name] + var/lit = (arc_name in lit_arcs) + arc.color = lit ? lit_color : CHROME_WHEEL_HUD_COLOR + arc.alpha = lit ? 200 : 80 + var/list/glows = list(glow, glow_twin) + for(var/i in 1 to length(glows)) + var/atom/movable/screen/chrome_wheel/art/body_glow = glows[i] + if(!body_glow) + continue + if(i > length(lit_regions)) + body_glow.alpha = 0 + continue + body_glow.icon_state = "glow_[lit_regions[i]]" + body_glow.color = lit_color + body_glow.alpha = 255 + +/** + * The readout under the ring: the chip pointed at, the chrome it lives in in + * its tier colour, and on the right how it stands ("14s", "offline", "out"). + * With nothing pointed at it shows the pick, dim, with a small bracket mark. + */ +/datum/component/chrome_wheel/proc/update_readout() + if(!readout_title) + return + var/mob/living/carbon/bearer = parent + var/atom/movable/screen/chrome_wheel/chip/shown = highlighted + var/datum/action/ability = shown?.ability_ref?.resolve() + var/idle = !ability + var/title + if(idle) + ability = get_selected_ability() + if(ability) + var/datum/chrome_wheel_option/option = selected_option ? chrome_wheel_find_option(ability, bearer, selected_option) : null + title = option ? option.name : ability.chrome_wheel_name() + else + title = shown.name + var/sub = ability ? chrome_wheel_ware_name(ability) : "" + var/sub_color = CHROME_WHEEL_DIM_COLOR + var/title_color = CHROME_WHEEL_DIM_COLOR + var/status + var/status_color + if(ability && !idle) + title_color = CHROME_WHEEL_NAME_COLOR + var/datum/action/cooldown/timed = istype(ability, /datum/action/cooldown) ? ability : null + var/cooldown_left = timed ? max(timed.next_use_time - world.time, 0) : 0 + if(chrome_wheel_offline(ability)) + status = "offline" + status_color = CHROME_WHEEL_OFFLINE_COLOR + sub_color = CHROME_WHEEL_OFFLINE_NAME_COLOR + else + sub_color = chrome_wheel_tier_color(ability) + if(chrome_wheel_ability_active(ability, bearer)) + status = timed ? "armed" : "out" + status_color = CHROME_WHEEL_DEPLOYED_COLOR + else if(cooldown_left) + status = "[CEILING(cooldown_left / 10, 1)]s" + status_color = "#ffffff" + var/state = "[idle]|[title]|[title_color]|[sub]|[sub_color]|[status]" + if(state == readout_state) + return + readout_state = state + var/static/datum/font/header_font = new /datum/font/grand9k/size_6pt() + var/static/datum/font/list_font = new /datum/font/tiny_unicode/size_12pt() + var/status_width = status ? header_font.get_metrics(status) + 6 : 0 + if(title) + title = chrome_readout_fit(title, header_font, CHROME_WHEEL_READOUT_WIDTH - 10 - status_width) + readout_title.maptext = chrome_readout_header_html(html_encode(title), title_color) + else + readout_title.maptext = null + if(sub) + sub = chrome_readout_fit(sub, list_font, CHROME_WHEEL_READOUT_WIDTH - 10) + readout_sub.maptext = chrome_readout_tiny_html("[html_encode(sub)]") + else + readout_sub.maptext = null + readout_status.maptext = status ? chrome_readout_header_html(status, status_color, "right") : null + readout_mark.alpha = (idle && ability) ? 200 : 0 + +// ---- Mouse ------------------------------------------------------------- + +/datum/component/chrome_wheel/proc/mouse_moved(params) + if(wheel_mode == CHROME_WHEEL_CLOSED) + return + var/list/offset = chrome_wheel_mouse_offset(params, shown_to) + if(!offset) + return + if(!mouse_moved) + if(!mouse_start) + mouse_start = offset + return + if(abs(offset[1] - mouse_start[1]) + abs(offset[2] - mouse_start[2]) < 4) + return + mouse_moved = TRUE + point_at(offset) + +/datum/component/chrome_wheel/proc/mouse_clicked(params) + if(wheel_mode == CHROME_WHEEL_CLOSED) + return + var/list/offset = chrome_wheel_mouse_offset(params, shown_to) + if(!offset) + close_wheel() + return + point_at(offset) + choose(highlighted) + +/// Highlights whatever the mouse at [offset] points at. A wheel opened from the +/// Chrome button fires what a click picks, so out past the ring a click picks nothing. +/datum/component/chrome_wheel/proc/point_at(list/offset) + var/list/points = list() + var/list/on_ring = list() + for(var/atom/movable/screen/chrome_wheel/chip/chip as anything in chips) + points += list(list(chip.chip_x, chip.chip_y)) + on_ring += chip.index <= chrome_wheel_socket_fits(chip.socket) + var/index = chrome_wheel_pick(offset[1], offset[2], points, on_ring, fire_on_pick ? CHROME_WHEEL_FIRE_REACH : null) + set_highlight(index ? chips[index] : null) + +/// Moves the highlight: the old chip shrinks back, the new one grows and lights its part of the body. +/datum/component/chrome_wheel/proc/set_highlight(atom/movable/screen/chrome_wheel/chip/chip) + if(chip == highlighted) + return + var/atom/movable/screen/chrome_wheel/chip/old = highlighted + highlighted = chip + if(old) + draw_chip(old) + if(chip) + draw_chip(chip) + else + light_up(null) + update_readout() + +#undef CHROME_WHEEL_READOUT_TOP +#undef CHROME_WHEEL_READOUT_LEFT +#undef CHROME_WHEEL_READOUT_WIDTH +#undef CHROME_WHEEL_READOUT_HEIGHT diff --git a/voidcrew/modules/cyberware/chrome_wheel_arms.dm b/voidcrew/modules/cyberware/chrome_wheel_arms.dm new file mode 100644 index 00000000000..4a84015724f --- /dev/null +++ b/voidcrew/modules/cyberware/chrome_wheel_arms.dm @@ -0,0 +1,111 @@ +/** + * # Arm chrome + * + * One ability that deploys or stows all of the bearer's arm hardware at once: + * the toolkit arms that put something in a hand (Mantis, Shiv and Scorch + * pairs, Widowline, Rockjaw, Fixer's, Ronin and Holdout, Bunker Buster). Arm + * chrome with nothing to hand out (Icepick, Skyhook, Graverobber, Angler, + * Gorilla) is left alone. + * + * If anything is out, everything goes back in. Otherwise every arm that can + * deploys: running chrome, its own button usable, a free hand on its side. + * A held item is never dropped to make room, so a full hand just keeps its + * arm stowed, and an EMP'd or browned-out arm stays put. A pair comes out + * together because both housings deploy in the same press. + * + * The bearer's chrome wheel owns the ability (chrome_wheel.dm sync_abilities()) + * and gives it a fixed chip at the top of the right arm's arc. It has no HUD + * button, like every chrome ability (chrome_hud.dm); the "Deploy arm chrome" + * key fires it (chrome_wheel_keybindings.dm). + */ +/datum/action/chrome_arms + name = "Arm chrome" + button_icon = CHROME_HUD_ICON + button_icon_state = "arms" + check_flags = AB_CHECK_CONSCIOUS + +/datum/action/chrome_arms/is_chrome_ability() + return TRUE + +/datum/action/chrome_arms/Trigger(mob/clicker, trigger_flags) + . = ..() + if(!.) + return FALSE + return chrome_arms_toggle(owner) + +/// The bearer's installed arm chrome that hands something out, deployed or not. +/proc/get_chrome_arm_housings(mob/living/carbon/bearer) + RETURN_TYPE(/list) + . = list() + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/housing in get_installed_cyberware(bearer)) + if(housing.chrome_arm_item()) + . += housing + +/** + * Stows every deployed arm if any is out, or else deploys every arm that can. + * Returns whether anything moved. + */ +/proc/chrome_arms_toggle(mob/living/carbon/bearer) + var/list/housings = get_chrome_arm_housings(bearer) + if(!length(housings)) + bearer?.balloon_alert(bearer, "no arm chrome!") + return FALSE + var/list/deployed = list() + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/housing as anything in housings) + if(housing.chrome_arm_deployed()) + deployed += housing + if(length(deployed)) + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/housing as anything in deployed) + housing.Retract() + return TRUE + if(HAS_TRAIT(bearer, TRAIT_INCAPACITATED)) + bearer.balloon_alert(bearer, "incapacitated!") + return FALSE + if(HAS_TRAIT(bearer, TRAIT_HANDS_BLOCKED)) + bearer.balloon_alert(bearer, "hands blocked!") + return FALSE + var/out = 0 + var/hands_full = FALSE + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/housing as anything in housings) + if(housing.chrome_arm_deploy()) + out++ + else if(housing.chrome_arm_can_run() && !housing.chrome_arm_hand_free()) + hands_full = TRUE + if(!out) + bearer.balloon_alert(bearer, hands_full ? "hands full!" : "chrome offline!") + return out > 0 + +/// The first thing this arm hands out, while it is still stowed in it or out in a hand; null for arm chrome with nothing to hand out. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/chrome_arm_item() + for(var/datum/weakref/item_ref as anything in items_list) + var/obj/item/stowed = item_ref.resolve() + if(stowed) + return stowed + return null + +/// Whether this arm's item is out of the housing. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/chrome_arm_deployed() + // The toolkit sets active_item before it knows a hand was free, so "out" is "not in us". + return active_item && !(active_item in src) + +/// Whether the chrome runs and its own deploy button could be pressed. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/chrome_arm_can_run() + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + if(!owner || !chrome?.is_running()) + return FALSE + var/datum/action/toggle = locate(/datum/action/item_action/organ_action/toggle) in actions + return !toggle || toggle.IsAvailable() + +/// Whether the hand on this arm's side is empty. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/chrome_arm_hand_free() + return !!owner?.get_empty_held_index_for_side(zone == BODY_ZONE_R_ARM ? RIGHT_HANDS : LEFT_HANDS) + +/// Puts this arm's first item in its hand, if the chrome runs and the hand is empty. Returns whether it came out. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/chrome_arm_deploy() + if(chrome_arm_deployed() || !chrome_arm_can_run() || !chrome_arm_hand_free()) + return FALSE + var/obj/item/augment = chrome_arm_item() + if(!augment || !(augment in src)) + return FALSE + Extend(augment) + return chrome_arm_deployed() diff --git a/voidcrew/modules/cyberware/chrome_wheel_hud.dm b/voidcrew/modules/cyberware/chrome_wheel_hud.dm new file mode 100644 index 00000000000..d3273eda2e3 --- /dev/null +++ b/voidcrew/modules/cyberware/chrome_wheel_hud.dm @@ -0,0 +1,142 @@ +/** + * Screen objects for the chrome wheel (chrome_wheel.dm). + * + * Everything the player sees hangs off one hub at the centre of the view, in + * its vis_contents, on the above-HUD plane. None of it takes the mouse: a + * near-invisible full-view catcher sits under it and reports every move and + * click to the wheel, which works out the chip from the mouse position. + * Every piece opts out of clear_screen(), because a knockdown rebuilds the HUD + * mid-hold; the wheel takes its own pieces off the screen when it closes. + * + * Pieces keep the alpha and transform of whatever they hang off, so the hub's + * fade reaches everything and a chip's pop carries its brackets, shade and + * count with it. Each sets its own colour. + * + * Layers, bottom up: backdrop, body, body glow, arcs, leaders, nodes, empty + * sockets, chips (and their shade, count and brackets), readout. + */ +/atom/movable/screen/chrome_wheel + icon = CHROME_WHEEL_ICON + icon_state = null + plane = ABOVE_HUD_PLANE + layer = 3 + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + vis_flags = VIS_INHERIT_PLANE + clear_with_screen = FALSE + appearance_flags = RESET_COLOR | NO_CLIENT_COLOR | PIXEL_SCALE + +/// The wheel's anchor at the centre of the view. Draws nothing itself. +/atom/movable/screen/chrome_wheel/hub + screen_loc = "CENTER" + +/** + * A piece of the 240x240 ring art (chrome_wheel_ring.dmi). The art is centred + * on the ring, which sits CHROME_WHEEL_CENTRE_Y above the middle of the view. + */ +/atom/movable/screen/chrome_wheel/art + icon = CHROME_WHEEL_RING_ICON + layer = 2.1 + pixel_x = -104 + pixel_y = -102 + +/// The soft dark backdrop. Stored at half size and drawn doubled, smoothly. +/atom/movable/screen/chrome_wheel/art/backdrop + icon_state = "scrim" + layer = 2 + appearance_flags = RESET_COLOR | NO_CLIENT_COLOR + +/atom/movable/screen/chrome_wheel/art/backdrop/Initialize(mapload, datum/hud/hud_owner) + . = ..() + transform = matrix(2, 0, 0, 0, 2, 0) + +/// The dim dashed outline of a socket with nothing in it. +/atom/movable/screen/chrome_wheel/empty_socket + icon_state = "socket" + layer = 2.5 + +/// One ability on the ring. +/atom/movable/screen/chrome_wheel/chip + icon_state = "frame_22" + /// The ability this chip fires. + var/datum/weakref/ability_ref + /// CHROME_WHEEL_SOCKET_* it sits in, and its position there, from 1. + var/socket + var/index = 1 + /// Which leader lights when it is pointed at: its socket's, or for hand + /// chrome its own run to the hand ("l_hand_2"). + var/leader_key + /// Which part of the body lights when it is pointed at. + var/region + /// Offset of its centre from the centre of the view, in pixels. + var/chip_x = 0 + var/chip_y = 0 + /// What the chip was last drawn as, so unchanged chips are left alone. + var/drawn_state + /// What its cooldown count last showed. + var/count_state + /// Size it was last drawn at: 22, or 26 while pointed at. + var/size = 22 + /// Cooldown wipe and its top edge, made the first time the chip cools down. + var/atom/movable/screen/chrome_wheel/chip_part/shade + var/atom/movable/screen/chrome_wheel/chip_part/shade_edge + /// Cooldown seconds. + var/atom/movable/screen/chrome_wheel/chip_part/count + /// The pick's corner brackets, made the first time this chip is picked. + var/list/brackets + +/atom/movable/screen/chrome_wheel/chip/Destroy() + vis_contents.Cut() + QDEL_NULL(shade) + QDEL_NULL(shade_edge) + QDEL_NULL(count) + QDEL_LIST(brackets) + ability_ref = null + return ..() + +/// Something drawn on a chip: the cooldown wipe, its edge or its count. +/atom/movable/screen/chrome_wheel/chip_part + icon_state = "px" + layer = 3.1 + +/// One corner of the lock brackets on the picked chip. +/atom/movable/screen/chrome_wheel/bracket + icon = CHROME_WHEEL_BRACKET_ICON + layer = 3.4 + color = CHROME_WHEEL_PICKED_COLOR + /// Which way is outward from the chip, for the snap in: -1 or 1 on each axis. + var/out_x = 0 + var/out_y = 0 + +/// A part of the readout panel under the ring: a flat block, or a line of text. +/atom/movable/screen/chrome_wheel/readout + icon_state = "px" + layer = 4 + +/** + * tg's cursor catcher (the scope's), lifted above the HUD so the mouse reaches + * the wheel wherever it is on the map. Its icon is white at alpha 1: invisible, + * but solid to the mouse. + */ +/atom/movable/screen/fullscreen/cursor_catcher/chrome_wheel + // overlay_fullscreen() appends a severity to the base state; nothing here goes + // through it, so name the state that exists. + icon_state = "fullscreen_blocker0" + plane = ABOVE_HUD_PLANE + layer = 1 + clear_with_screen = FALSE + /// The wheel to report to. + var/datum/component/chrome_wheel/wheel + +/atom/movable/screen/fullscreen/cursor_catcher/chrome_wheel/Destroy() + wheel = null + owner = null + return ..() + +/atom/movable/screen/fullscreen/cursor_catcher/chrome_wheel/MouseMove(location, control, params) + . = ..() + if(usr == owner) + wheel?.mouse_moved(params) + +/atom/movable/screen/fullscreen/cursor_catcher/chrome_wheel/Click(location, control, params) + if(usr == owner) + wheel?.mouse_clicked(params) diff --git a/voidcrew/modules/cyberware/chrome_wheel_keybindings.dm b/voidcrew/modules/cyberware/chrome_wheel_keybindings.dm new file mode 100644 index 00000000000..2578ebd6ab1 --- /dev/null +++ b/voidcrew/modules/cyberware/chrome_wheel_keybindings.dm @@ -0,0 +1,85 @@ +/** + * The chrome wheel's binds (chrome_wheel.dm). Defaults sit on V, the one free + * letter by the movement keys: hold V for the wheel, Shift+V fires the pick + * (beside tg's Shift+E/Q/B variants), Ctrl+V fires the OS and Alt+V deploys or + * stows all arm chrome (chrome_wheel_arms.dm). Alt alone is tg's "Block + * movement", held only for the moment the combo is down. All of them rebind in + * the keybind settings like any other. + */ +/datum/keybinding/living/chrome + +/datum/keybinding/living/chrome/can_use(client/user) + return iscarbon(user.mob) + +/// The bearer's wheel, or null with a "no chrome" balloon for a body without any. +/datum/keybinding/living/chrome/proc/get_wheel(client/user) + var/mob/living/carbon/bearer = user.mob + if(bearer.stat == DEAD) + return null + var/datum/component/chrome_wheel/wheel = get_chrome_wheel(bearer) + if(!wheel) + bearer.balloon_alert(bearer, "no chrome!") + return wheel + +/datum/keybinding/living/chrome/wheel + hotkey_keys = list("V") + name = CHROME_WHEEL_KEYBIND + full_name = "Chrome wheel" + description = "Hold to pick a chrome ability." + keybind_signal = COMSIG_KB_LIVING_CHROME_WHEEL_DOWN + +/datum/keybinding/living/chrome/wheel/down(client/user, turf/target) + . = ..() + if(.) + return + get_wheel(user)?.wheel_key_down() + return TRUE + +/datum/keybinding/living/chrome/wheel/up(client/user, turf/target) + . = ..() + if(.) + return + var/datum/component/chrome_wheel/wheel = user.mob.GetComponent(/datum/component/chrome_wheel) + wheel?.wheel_key_up() + +/datum/keybinding/living/chrome/use + hotkey_keys = list("ShiftV") + name = "use_chrome" + full_name = "Use chrome" + description = "Use the chrome ability picked on the wheel." + keybind_signal = COMSIG_KB_LIVING_USE_CHROME_DOWN + +/datum/keybinding/living/chrome/use/down(client/user, turf/target) + . = ..() + if(.) + return + get_wheel(user)?.use_selected() + return TRUE + +/datum/keybinding/living/chrome/use_os + hotkey_keys = list("CtrlV") + name = "use_os_chrome" + full_name = "Use OS chrome" + description = "Use your operating system chrome." + keybind_signal = COMSIG_KB_LIVING_USE_OS_CHROME_DOWN + +/datum/keybinding/living/chrome/use_os/down(client/user, turf/target) + . = ..() + if(.) + return + get_wheel(user)?.use_os() + return TRUE + +/datum/keybinding/living/chrome/deploy_arms + hotkey_keys = list("AltV") + name = "deploy_arm_chrome" + full_name = "Deploy arm chrome" + description = "Deploy or stow all your arm chrome." + keybind_signal = COMSIG_KB_LIVING_DEPLOY_ARM_CHROME_DOWN + +/datum/keybinding/living/chrome/deploy_arms/down(client/user, turf/target) + . = ..() + if(.) + return + get_wheel(user)?.use_arms() + return TRUE diff --git a/voidcrew/modules/cyberware/cyberware_anim.dm b/voidcrew/modules/cyberware/cyberware_anim.dm new file mode 100644 index 00000000000..0284e0a0c88 --- /dev/null +++ b/voidcrew/modules/cyberware/cyberware_anim.dm @@ -0,0 +1,1065 @@ +/** + * # Chrome animations + * + * Four pieces of motion that sit on top of chrome that already works. None of + * them changes what the chrome does or when: every proc here only draws, and + * the mechanics call into it after they have already happened. + * + * - Mantis blades swing out of the housing and fold back into it. + * - The Ghostskin field flickers in and out: hard steps of alpha with a + * pixel of jitter, and a sharper stutter when something knocks it down. + * - The Cascade's spine nodes ignite neck to hips, a ring rolls out across the + * floor, and the nodes die hips to neck when the crash hits. + * - An EMP fills every worn piece with static, arcs between them, kills them one + * after another, and they blink back on when they reboot. + * + * Two ways of drawing, chosen per effect: + * - One-shot frames ride a holder object in the bearer's vis_contents. A fresh + * object always plays its icon state from the first frame, which an overlay + * does not, so swings, arcs and sparks are holders that delete themselves. + * - Anything that must sit at the worn chrome's layer (under suits, gloves and + * hands) is a "look" on the worn overlay itself: the bodypart overlay asks + * the implant for its look when it draws, and the look is part of the limb's + * render key, so a look change is one update_body_parts() away. + * + * Nothing here loops on the server. Timers are one-shot and owned by the thing + * they animate, so they die with it. + */ + +#define CYBERWARE_ANIM_ICON 'voidcrew/modules/cyberware/icons/cyberware_anim.dmi' +#define CYBERWARE_ANIM_LARGE_ICON 'voidcrew/modules/cyberware/icons/cyberware_anim_large.dmi' +/// Batch-2 art: breathing LEDs and the looks of cyberware_anim2.dm. +#define CYBERWARE_ANIM2_ICON 'voidcrew/modules/cyberware/icons/cyberware_anim2.dmi' + +/// Worn looks. Null is the plain overlay. +#define CHROME_LOOK_STATIC "static" +#define CHROME_LOOK_DARK "dark" +#define CHROME_LOOK_FLASH "flash" +#define CHROME_LOOK_FOLD "fold" +/// Brownout looks (cyberware_anim2.dm): browned out, and the warm stutter on the way down or up. +#define CHROME_LOOK_BROWN "brown" +#define CHROME_LOOK_WARM "warm" + +/// Layer for a blade swing: just over the held item it turns into. +#define CHROME_ANIM_BLADE_LAYER (-(HANDS_LAYER - 0.5)) +/// Layer for arcs, sparks and crackle: over everything the bearer wears. +#define CHROME_ANIM_TOP_LAYER (-(HIGHEST_LAYER - 0.5)) +/// The mask on a far arm's picture: the near hand's held item, cut out of it. +#define CHROME_ANIM_ARM_COVER_FILTER "chrome_arm_cover" + +// ========================================================================= +// THE HOLDER +// ========================================================================= + +/** + * One short animation drawn on a bearer. Created per use and deleted after + * its lifetime, so its icon state always starts on the first frame. Inherits + * the bearer's facing and plane; clicks pass through it. + */ +/obj/effect/abstract/cyberware_anim + name = "chrome" + icon = CYBERWARE_ANIM_LARGE_ICON + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + vis_flags = VIS_INHERIT_DIR | VIS_INHERIT_PLANE + blocks_emissive = EMISSIVE_BLOCK_NONE + /// What we are drawn on. + var/atom/movable/bearer + /// The arm this is a picture of, "left" or "right", once it is sorted as one arm's (sort_as_arm()). + var/arm_side + /// What the near hand holds while this is the far arm's picture: it is cut out of it. + var/obj/item/arm_cover + +/obj/effect/abstract/cyberware_anim/Destroy() + detach() + return ..() + +/obj/effect/abstract/cyberware_anim/proc/detach() + set_arm_cover(null) + if(!bearer) + return + UnregisterSignal(bearer, list(COMSIG_QDELETING, COMSIG_ATOM_POST_DIR_CHANGE, COMSIG_MOB_UPDATE_HELD_ITEMS)) + bearer.vis_contents -= src + bearer = null + +/obj/effect/abstract/cyberware_anim/proc/on_bearer_deleted(datum/source) + SIGNAL_HANDLER + qdel(src) + +/** + * Plays [state] from [icon_file] on [bearer] for [lifetime], then deletes + * itself. Large-sheet states are 64x64 and get centred on the bearer's tile. + * [glow] adds an emissive twin, so the frames light up in the dark. + */ +/proc/cyberware_anim_play(atom/movable/bearer, icon_file, state, anim_layer, lifetime, glow = FALSE) + if(QDELETED(bearer) || !state) + return null + var/obj/effect/abstract/cyberware_anim/holder = new(null) + holder.bearer = bearer + holder.icon = icon_file + holder.icon_state = state + holder.layer = anim_layer + if(icon_file == CYBERWARE_ANIM_LARGE_ICON) + holder.pixel_x = -16 + holder.pixel_y = -16 + if(glow) + holder.add_overlay(emissive_appearance(icon_file, state, bearer)) + holder.RegisterSignal(bearer, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + bearer.vis_contents += holder + QDEL_IN(holder, lifetime) + return holder + +// ========================================================================= +// ONE ARM'S PICTURE +// ========================================================================= + +/** + * Sorts this picture as one of the [side] ("left" or "right") arm's from now on. A picture in vis_contents + * draws over every overlay of its bearer whatever its own float layer, held items included, and pictures draw + * over one another in the order they went in, whatever their float layers. So side on a far arm's picture + * would cover the near arm. Here what the near hand holds is cut out of the far arm's picture with a mask of + * that item's held sprite, for as long as it is drawn in that hand, and the near arm's pictures are put back + * on over it (under_near_arm()). Kept right as the bearer turns and as the hands redraw. The art itself + * leaves out the body where it hides a far arm. + */ +/obj/effect/abstract/cyberware_anim/proc/sort_as_arm(side) + if(QDELETED(bearer) || arm_side || !side) + return + arm_side = side + RegisterSignal(bearer, COMSIG_ATOM_POST_DIR_CHANGE, PROC_REF(on_arm_bearer_changed)) + RegisterSignal(bearer, COMSIG_MOB_UPDATE_HELD_ITEMS, PROC_REF(on_arm_bearer_changed)) + fit_to_facing() + +/// Sorts an arm's picture for the way its bearer faces and what the other hand shows right now. +/obj/effect/abstract/cyberware_anim/proc/fit_to_facing() + if(QDELETED(bearer) || !arm_side) + return + var/far = (bearer.dir == EAST && arm_side == "left") || (bearer.dir == WEST && arm_side == "right") + var/obj/item/near_item = far ? near_held_item() : null + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/near_blade = near_item + // A blade hidden under a picture of its own is not in the hand to be cut out: that picture is in front. + if(istype(near_blade) && world.time < near_blade.inhand_hidden_until) + near_item = null + set_arm_cover(near_item) + if(far) + under_near_arm() + +/** + * Puts the near arm's pictures back on over this far arm's picture: each is taken off its bearer and put + * straight back, in the order they were in. A picture put back in the same tick goes on playing where it was. + */ +/obj/effect/abstract/cyberware_anim/proc/under_near_arm() + var/list/near_pictures + for(var/obj/effect/abstract/cyberware_anim/other in bearer.vis_contents) + if(other.arm_side && other.arm_side != arm_side) + LAZYADD(near_pictures, other) + for(var/obj/effect/abstract/cyberware_anim/other as anything in near_pictures) + bearer.vis_contents -= other + bearer.vis_contents += other + +/// What the bearer holds in the hand on the other side from this arm. +/obj/effect/abstract/cyberware_anim/proc/near_held_item() + var/mob/living/holder = bearer + if(!isliving(holder)) + return null + for(var/obj/item/held in holder.held_items) + if(IS_LEFT_INDEX(holder.get_held_index_of_item(held)) != (arm_side == "left")) + return held + return null + +/// Cuts [item]'s held sprite out of this picture, or nothing out of it if null. +/obj/effect/abstract/cyberware_anim/proc/set_arm_cover(obj/item/item) + if(arm_cover) + UnregisterSignal(arm_cover, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING)) + var/icon/mask = item && cyberware_held_mask(item, bearer) + arm_cover = mask ? item : null + if(arm_cover) + RegisterSignals(arm_cover, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING), PROC_REF(on_arm_cover_gone)) + add_filter(CHROME_ANIM_ARM_COVER_FILTER, 1, alpha_mask_filter(icon = mask, flags = MASK_INVERSE)) + else if(arm_side) + remove_filter(CHROME_ANIM_ARM_COVER_FILTER) + +/obj/effect/abstract/cyberware_anim/proc/on_arm_cover_gone(datum/source) + SIGNAL_HANDLER + set_arm_cover(null) + +/obj/effect/abstract/cyberware_anim/proc/on_arm_bearer_changed(datum/source) + SIGNAL_HANDLER + fit_to_facing() + +/** + * The shape [item] has in [holder]'s hand, facing the way [holder] faces now, as a mask: the first frame of + * its held sprite. Null if it has none. Each sprite and facing is made once. + */ +/proc/cyberware_held_mask(obj/item/item, mob/living/holder) + if(!isliving(holder)) + return null + var/index = holder.get_held_index_of_item(item) + if(!index) + return null + var/file = IS_RIGHT_INDEX(index) ? item.righthand_file : item.lefthand_file + var/state = item.inhand_icon_state || item.icon_state + if(!file || !state || !icon_exists(file, state)) + return null + var/static/list/masks = list() + var/list/by_state = masks[file] + if(!by_state) + by_state = list() + masks[file] = by_state + var/key = "[state]-[holder.dir]" + . = by_state[key] + if(!.) + . = icon(file, state, holder.dir, 1) + by_state[key] = . + +// ========================================================================= +// WORN LOOKS +// ========================================================================= + +/// The EMP look the reboot show has put on this piece. Null means "whatever +/// the reboot state says": dark while down, plain otherwise. +/datum/component/cyberware/var/emp_look +/// The brownout look the brownout show has put on this piece. Null means +/// "whatever the brownout state says": browned out or plain. +/datum/component/cyberware/var/brownout_look + +/** + * The look this implant's worn overlay draws with right now, or null for the + * plain overlay. Read by the bodypart overlay on every draw. + */ +/obj/item/organ/cyberimp/proc/cyberware_worn_look() + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + if(!chrome) + return null + if(chrome.emp_look) + return chrome.emp_look + if(chrome.emp_down) + return CHROME_LOOK_DARK + if(chrome.brownout_look) + return chrome.brownout_look + if(chrome.browned_out) + return CHROME_LOOK_BROWN + return null + +/// What this implant adds to its limb's render key, so a look change redraws. +/obj/item/organ/cyberimp/proc/cyberware_worn_key() + return "[cyberware_worn_look()]" + +/** + * Dresses one implant's freshly built worn images in its current look. + * Called by /datum/bodypart_overlay/augment/cyberware before it adds + * emissive blockers, so a see-through image gets a see-through blocker. + */ +/obj/item/organ/cyberimp/proc/cyberware_dress_worn(list/imageset, image_layer, obj/item/bodypart/limb) + var/look = cyberware_worn_look() + if(!look) + return cyberware_dress_leds(imageset, image_layer, limb) + var/list/dressed = list() + for(var/image/part as anything in imageset) + var/glow = PLANE_TO_TRUE(part.plane) == EMISSIVE_PLANE + switch(look) + if(CHROME_LOOK_FOLD) + // The folded housing waits while the swing plays over it. + if(glow) + continue + part.alpha = 0 + if(CHROME_LOOK_DARK) + if(glow) + continue + part.color = list(0.18, 0.18, 0.2, 0.32, 0.32, 0.34, 0.08, 0.08, 0.1, 0.02, 0.02, 0.03) + if(CHROME_LOOK_FLASH) + if(glow) + continue + part.color = list(0.55, 0, 0, 0, 0.55, 0, 0, 0, 0.55, 0.42, 0.5, 0.55) + dressed += part + dressed += emissive_appearance(part.icon, part.icon_state, limb?.owner || limb, part.layer) + continue + if(CHROME_LOOK_STATIC) + if(!glow) + // Static clipped to the piece's own pixels. + part.appearance_flags |= KEEP_TOGETHER + var/mutable_appearance/noise = mutable_appearance('icons/effects/effects.dmi', "static_base", alpha = 170) + noise.blend_mode = BLEND_INSET_OVERLAY + part.overlays += noise + if(CHROME_LOOK_BROWN) + if(glow) + continue + part.color = list(0.62, 0, 0, 0, 0.62, 0, 0, 0, 0.66, 0, 0, 0) + if(CHROME_LOOK_WARM) + if(glow) + // A sagging supply: the lights still burn, weaker. + dressed += emissive_appearance(part.icon, part.icon_state, limb?.owner || limb, part.layer, alpha = 110) + continue + part.color = list(0.9, 0, 0, 0, 0.74, 0, 0, 0, 0.58, 0.05, 0.02, 0) + dressed += part + return dressed + +/** + * The plain look: any worn state with breathing LEDs in the batch-2 sheet + * gets them, and the breathing glow replaces the piece's own still glow. + * The LED states loop on their own, so a lit piece costs the server nothing. + */ +/obj/item/organ/cyberimp/proc/cyberware_dress_leds(list/imageset, image_layer, obj/item/bodypart/limb) + var/list/leds + for(var/image/part as anything in imageset) + if(PLANE_TO_TRUE(part.plane) == EMISSIVE_PLANE) + continue + var/led_state = "[part.icon_state]_led" + if(icon_exists(CYBERWARE_ANIM2_ICON, led_state)) + LAZYSET(leds, "[part.icon_state]", led_state) + if(!leds) + return imageset + var/list/dressed = list() + for(var/image/part as anything in imageset) + if(PLANE_TO_TRUE(part.plane) == EMISSIVE_PLANE) + var/glow_state = "[part.icon_state]" + if(length(glow_state) > 2 && copytext(glow_state, -2) == "_e" && leds[copytext(glow_state, 1, -2)]) + continue + dressed += part + for(var/worn_state in leds) + dressed += image(icon = CYBERWARE_ANIM2_ICON, icon_state = leds[worn_state], layer = image_layer) + dressed += emissive_appearance(CYBERWARE_ANIM2_ICON, "[leds[worn_state]]_e", limb?.owner || limb, image_layer) + return dressed + +// ========================================================================= +// MANTIS BLADES: UNFOLD AND FOLD +// ========================================================================= + +/// How long the blade swings out before the held blade takes over. +#define BLADE_UNFOLD_SWING (0.3 SECONDS) +/// The whole unfold, last sparks included. +#define BLADE_UNFOLD_TIME (0.4 SECONDS) +/// How long the folded housing waits while the blade folds back in. +#define BLADE_FOLD_SWING (0.3 SECONDS) +/// The whole fold, last sparks included. +#define BLADE_FOLD_TIME (0.5 SECONDS) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware + /// The swing playing on the bearer right now, if any. Weak: it deletes itself. + var/datum/weakref/blade_anim_ref + /// Until this world.time the folded housing is drawn see-through. + var/fold_hide_until = 0 + /// Timer that brings the folded housing back. + var/fold_timer + /// Colour of the flash at the hinge when the blade swings. + var/blade_flash_color = "#bfe6ff" + /// One hinge flash at a time, however fast the blade is toggled. + COOLDOWN_DECLARE(blade_flash_cooldown) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street + blade_flash_color = "#e8e0c8" + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch + blade_flash_color = "#ffb070" + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/cyberware_worn_look() + if(world.time < fold_hide_until) + return CHROME_LOOK_FOLD + return ..() + +/// The swing state for this housing, or null when the sheet has none. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/blade_anim_state(kind) + var/state = "[aug_overlay]_[kind]_[arm_side()]" + return icon_exists(CYBERWARE_ANIM_LARGE_ICON, state) ? state : null + +/// The swing playing on the bearer right now, if any. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/blade_anim() + return blade_anim_ref?.resolve() + +/// The arm this housing is in, as the art names it. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/arm_side() + return zone == BODY_ZONE_L_ARM ? "left" : "right" + +/// Plays [state] on the bearer for [lifetime] as this arm's picture: side on, the far arm's goes behind the near arm. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/play_blade_anim(state, lifetime) + var/obj/effect/abstract/cyberware_anim/swing = cyberware_anim_play(owner, CYBERWARE_ANIM_LARGE_ICON, state, CHROME_ANIM_BLADE_LAYER, lifetime) + swing?.sort_as_arm(arm_side()) + blade_anim_ref = WEAKREF(swing) + return swing + +/// Stops any swing and brings the folded housing back if it was waiting. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/stop_blade_anim() + qdel(blade_anim()) + blade_anim_ref = null + if(fold_timer) + deltimer(fold_timer) + fold_timer = null + fold_hide_until = 0 + +/// The blade swings out of the housing. Called once the blade is in a hand. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/play_blade_unfold(obj/item/blade) + var/state = blade_anim_state("unfold") + if(!state || !owner) + return + stop_blade_anim() + play_blade_anim(state, BLADE_UNFOLD_TIME) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/held_blade = blade + if(istype(held_blade)) + held_blade.hide_inhand_for(BLADE_UNFOLD_SWING) + blade_flash(0.7, BLADE_UNFOLD_SWING) + +/** + * The unfold ends on the guard and keeps it under its last sparks, so a blade is drawn while the held blade + * comes back, whenever that reaches the client. If the blade takes another pose or swings while the unfold is + * still on it, the unfold stops, so its guard is never drawn over the new picture, and the held blade shows at + * once unless something else is hiding it for longer. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/unfold_overtaken(obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade) + var/obj/effect/abstract/cyberware_anim/unfold = blade_anim() + if(isnull(unfold) || unfold.icon_state != blade_anim_state("unfold")) + return FALSE + stop_blade_anim() + if(blade.inhand_hidden_until <= world.time + BLADE_UNFOLD_SWING) + blade.show_inhand() + return TRUE + +/** + * The blade folds back into the housing. Called once it is stowed; the + * folded housing stays see-through until the swing has played. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/play_blade_fold() + var/state = blade_anim_state("fold") + if(!state || !owner) + return + stop_blade_anim() + play_blade_anim(state, BLADE_FOLD_TIME) + fold_hide_until = world.time + BLADE_FOLD_SWING + fold_timer = addtimer(CALLBACK(src, PROC_REF(end_fold_hide)), BLADE_FOLD_SWING, TIMER_STOPPABLE) + blade_flash(0.5, BLADE_FOLD_SWING) + +/// A brief light at the hinge while the blade swings. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/blade_flash(power, duration) + if(!COOLDOWN_FINISHED(src, blade_flash_cooldown)) + return + COOLDOWN_START(src, blade_flash_cooldown, duration) + owner.mob_light(1.5, power, blade_flash_color, duration) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/end_fold_hide() + fold_timer = null + fold_hide_until = 0 + owner?.update_body_parts() + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis + /// Until this world.time the blade is not drawn in the hand: the swing is. + var/inhand_hidden_until = 0 + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/hide_inhand_for(duration) + // A longer hide already running (the impale's or the scissor's blade art) is never cut short by a swing. + if(world.time + duration <= inhand_hidden_until) + return + inhand_hidden_until = world.time + duration + var/mob/holder = loc + if(ismob(holder)) + holder.update_held_items() + // Each hide ends on its own timer, and a timer ends nothing while a later hide still runs. + addtimer(CALLBACK(src, PROC_REF(inhand_hide_expired)), duration, TIMER_DELETE_ME) + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/inhand_hide_expired() + if(world.time < inhand_hidden_until) + return + show_inhand() + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/show_inhand() + if(!inhand_hidden_until) + return + inhand_hidden_until = 0 + var/mob/holder = loc + if(ismob(holder)) + holder.update_held_items() + +// The blade is in the hand from the first tick; only its drawing waits. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/build_worn_icon(default_layer = 0, default_icon_file = null, isinhands = FALSE, female_uniform = NO_FEMALE_UNIFORM, override_state = null, override_file = null) + . = ..() + if(isinhands && world.time < inhand_hidden_until) + var/mutable_appearance/standing = . + standing.alpha = 0 + +// ========================================================================= +// IMPACTS +// ========================================================================= + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis + /// What a hit with this blade plays over its target, in place of tg's flying blade. + var/impact_state = "impact_mantis" + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street + impact_state = "impact_shiv" + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch + impact_state = "impact_scorch" + +// The swinger's lunge stays; only the picture over the target changes. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/animate_attack(atom/movable/attacker, atom/attacked_atom, animation_type) + // The arm swings the blade (mantis_gore/mantis_swing.dm), and the impact waits for its strike. The swing is the + // picture on its own where there is no impact (a wall), never tg's flying blade beside it. + if(mantis_play_swing(attacker, attacked_atom)) + mantis_swing_impact(attacker, attacked_atom) + return + if(!cyberware_play_impact(attacker, attacked_atom, impact_state)) + return ..() + +// No picture over what a wire hits, nor tg's flying spool: the lash from the hand is its picture +// (hyperviolence/wire/wire_held.dm). Walls and floors keep tg's own. +/obj/item/melee/cyberware_monowire/animate_attack(atom/movable/attacker, atom/attacked_atom, animation_type) + if(!ismovable(attacked_atom)) + return ..() + +/** + * A chrome weapon's hit drawn over what it hit: a short slash, flash or + * crackle, upright even on someone lying down, and turned to come from the + * attacker's side. [mirrored] TRUE or FALSE turns it that way instead (the + * Mantis swing turns it by the hand that swung). Returns the holder, or null + * if there was nothing to draw on. + */ +/proc/cyberware_play_impact(atom/movable/attacker, atom/attacked_atom, impact_state, mirrored = null) + if(!impact_state || !ismovable(attacked_atom)) + return null + var/obj/effect/abstract/cyberware_anim/impact = cyberware_anim_play(attacked_atom, CYBERWARE_ANIM_ICON, impact_state, CHROME_ANIM_TOP_LAYER, 0.4 SECONDS, glow = impact_state != "impact_shiv") + if(!impact) + return null + impact.appearance_flags |= RESET_TRANSFORM + // The art swings in from the left; a blow from the right is mirrored, one from above or below either way. + if(isnull(mirrored)) + var/direction = get_dir(attacker, attacked_atom) + mirrored = (direction & WEST) || (!(direction & EAST) && prob(50)) + if(mirrored) + impact.transform = matrix(-1, 0, 0, 0, 1, 0) + return impact + +#undef BLADE_UNFOLD_SWING +#undef BLADE_UNFOLD_TIME +#undef BLADE_FOLD_SWING +#undef BLADE_FOLD_TIME + +// ========================================================================= +// GHOSTSKIN FIELD: THE SIGNAL FLICKER +// ========================================================================= + +/// How long the field takes to flicker in. +#define CLOAK_ENTER_TIME (0.6 SECONDS) + +/obj/item/organ/cyberimp/cyberware/ghostskin + /// world.time the field finishes flickering in. Moving under the field waits for it. + var/cloak_enter_until = 0 + +/** + * Hard 1 px jumps sideways alongside one of the alpha chains below. [steps] + * are (jump, hold) pairs; the jumps are relative and add up to nothing, so the + * bearer ends where it started however the chain is cut short. + */ +/proc/cyberware_cloak_jolt(mob/living/wearer, list/steps) + for(var/i in 1 to length(steps) step 2) + var/jump = steps[i] + var/hold = steps[i + 1] + if(i == 1) + animate(wearer, pixel_w = jump, time = 0, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + else + animate(pixel_w = jump, time = 0, flags = ANIMATION_RELATIVE) + if(hold) + animate(pixel_w = 0, time = hold, flags = ANIMATION_RELATIVE) + +/** + * The field comes up: the bearer's alpha stutters through hard steps and eases + * down to field alpha, jumping a pixel sideways on the way. While the field + * holds there is nothing on the bearer but that alpha. + */ +/obj/item/organ/cyberimp/cyberware/ghostskin/proc/cloak_flicker_in(mob/living/carbon/wearer) + cloak_enter_until = world.time + CLOAK_ENTER_TIME + var/faded = field_alpha + // The alpha chain first: it replaces whatever the bearer was animating. + animate(wearer, alpha = max(115, faded), time = 0) + animate(alpha = max(115, faded), time = 0.5) + animate(alpha = 230, time = 0) + animate(alpha = 230, time = 1) + animate(alpha = max(75, faded), time = 0) + animate(alpha = max(75, faded), time = 0.5) + animate(alpha = 180, time = 0) + animate(alpha = 180, time = 1) + animate(alpha = max(55, faded), time = 0) + animate(alpha = max(55, faded), time = 0.5) + animate(alpha = 125, time = 0) + animate(alpha = 125, time = 0.5) + animate(alpha = faded, time = 2, easing = SINE_EASING) + cyberware_cloak_jolt(wearer, list(1, 0.5, -1, 1, -1, 0.5, 1, 1, 1, 0.5, -1, 0.5)) + +/// The field runs out or is switched off: the flicker in reverse, back to full view. +/obj/item/organ/cyberimp/cyberware/ghostskin/proc/cloak_flicker_out(mob/living/carbon/wearer) + cloak_enter_until = 0 + var/faded = field_alpha + animate(wearer, alpha = 110, time = 0) + animate(alpha = 110, time = 0.5) + animate(alpha = max(60, faded), time = 0) + animate(alpha = max(60, faded), time = 0.5) + animate(alpha = 175, time = 0) + animate(alpha = 175, time = 0.5) + animate(alpha = 105, time = 0) + animate(alpha = 105, time = 0.5) + animate(alpha = 235, time = 0) + animate(alpha = 235, time = 0.5) + animate(alpha = 255, time = 1, easing = SINE_EASING) + cyberware_cloak_jolt(wearer, list(-1, 0.5, 1, 0.5, 1, 0.5, -1, 0.5, -1, 0.5, 1, 1)) + +/// The field is knocked down: full view, a dip, full view, with hard 2 px jolts. +/obj/item/organ/cyberimp/cyberware/ghostskin/proc/cloak_flicker_break(mob/living/carbon/wearer) + cloak_enter_until = 0 + animate(wearer, alpha = 255, time = 0) + animate(alpha = 255, time = 0.5) + animate(alpha = 140, time = 0) + animate(alpha = 140, time = 0.5) + animate(alpha = 255, time = 0) + animate(alpha = 255, time = 0.5) + cyberware_cloak_jolt(wearer, list(2, 0.5, -4, 0.5, 3, 0.5, -1, 0)) + +/// A quiet drop (the weave pulled, or switched off while not worn): straight back to full view. +/obj/item/organ/cyberimp/cyberware/ghostskin/proc/cloak_reset(mob/living/carbon/wearer) + cloak_enter_until = 0 + if(!QDELETED(wearer)) + animate(wearer, alpha = 255, time = 0) + +#undef CLOAK_ENTER_TIME + +// ========================================================================= +// CASCADE: SPINE NODES AND THE TIME RING +// ========================================================================= + +/// Time between node frames. +#define CASCADE_NODE_STEP (0.1 SECONDS) +/// When the ring rolls out: as the last node lights. +#define CASCADE_RING_DELAY (0.45 SECONDS) + +/obj/item/organ/cyberimp/cyberware/cascade + /// The spine node frame drawn over the lattice, or null for the plain one. + var/node_look + /// Node frames still to play, in order. + var/list/node_queue + /// Timer for the next node frame. + var/node_timer + /// Timer for the floor ring. + var/ring_timer + /// How far the ring rolls out (transform scale of a two-tile ring). + var/ring_scale = 3.3 + /// How bright the ring starts. + var/ring_alpha = 235 + /// How long the ring takes to roll out and fade. + var/ring_time = 0.65 SECONDS + +/obj/item/organ/cyberimp/cyberware/cascade/milspec + ring_scale = 2.7 + ring_alpha = 190 + ring_time = 0.55 SECONDS + +/obj/item/organ/cyberimp/cyberware/cascade/street + ring_scale = 2.2 + ring_alpha = 140 + ring_time = 0.45 SECONDS + +/obj/item/organ/cyberimp/cyberware/cascade/cyberware_worn_key() + return "[..()]-[node_look]" + +/obj/item/organ/cyberimp/cyberware/cascade/cyberware_dress_worn(list/imageset, image_layer, obj/item/bodypart/limb) + if(cyberware_worn_look() || !node_look) + return ..() + var/state = "[aug_overlay]_[node_look]" + if(!icon_exists(CYBERWARE_ANIM_ICON, state)) + return imageset + // The node frame replaces the lattice's own idle glow. + var/list/dressed = list() + for(var/image/part as anything in imageset) + if(PLANE_TO_TRUE(part.plane) == EMISSIVE_PLANE) + continue + dressed += part + dressed += cyberware_spine_node_images(CYBERWARE_ANIM_ICON, state, node_look != "dead", image_layer, limb?.owner || limb) + return dressed + +/** + * The images of one spine node frame. Lit nodes shine through whatever is worn on the back: they draw at + * CYBERWARE_SPINE_SHINE_LAYER, just over the backpack. Dark nodes stay with the housing, under the clothes. A + * frame with lit and dark nodes both is split in its sheet into "[state]_lit" and "[state]_dark". + */ +/proc/cyberware_spine_node_images(icon_file, state, lit, image_layer, atom/glow_owner) + var/list/images = list() + var/has_glow = icon_exists(icon_file, "[state]_e") + if(!lit) + images += image(icon = icon_file, icon_state = state, layer = image_layer) + if(has_glow) + images += emissive_appearance(icon_file, "[state]_e", glow_owner, image_layer) + return images + var/lit_state = state + if(icon_exists(icon_file, "[state]_lit")) + lit_state = "[state]_lit" + images += image(icon = icon_file, icon_state = "[state]_dark", layer = image_layer) + images += image(icon = icon_file, icon_state = lit_state, layer = -CYBERWARE_SPINE_SHINE_LAYER) + if(has_glow) + images += emissive_appearance(icon_file, "[state]_e", glow_owner, -CYBERWARE_SPINE_SHINE_LAYER) + return images + +/// Plays node frames one after another, then holds the last. +/obj/item/organ/cyberimp/cyberware/cascade/proc/play_node_looks(list/looks) + if(node_timer) + deltimer(node_timer) + node_timer = null + node_queue = looks.Copy() + advance_node_look() + +/obj/item/organ/cyberimp/cyberware/cascade/proc/advance_node_look() + node_timer = null + if(!length(node_queue)) + return + node_look = popleft(node_queue) + owner?.update_body_parts() + if(length(node_queue)) + node_timer = addtimer(CALLBACK(src, PROC_REF(advance_node_look)), CASCADE_NODE_STEP, TIMER_STOPPABLE) + +/// Back to the plain lattice, no frames pending, no ring on the way. +/obj/item/organ/cyberimp/cyberware/cascade/proc/clear_node_looks(mob/living/carbon/redraw) + if(node_timer) + deltimer(node_timer) + node_timer = null + if(ring_timer) + deltimer(ring_timer) + ring_timer = null + node_queue = null + if(isnull(node_look)) + return + node_look = null + redraw?.update_body_parts() + +/// The window opens: nodes ignite neck to hips, then the ring rolls out. +/obj/item/organ/cyberimp/cyberware/cascade/proc/play_window_open() + if(!owner) + return + play_node_looks(list("boot1", "boot2", "boot3", "boot4", "boot5", "lit")) + if(ring_timer) + deltimer(ring_timer) + ring_timer = addtimer(CALLBACK(src, PROC_REF(roll_ring)), CASCADE_RING_DELAY, TIMER_STOPPABLE) + +/obj/item/organ/cyberimp/cyberware/cascade/proc/roll_ring() + ring_timer = null + var/turf/here = get_turf(owner) + if(here) + new /obj/effect/temp_visual/cyberware_time_ring(here, ring_scale, ring_alpha, ring_time) + +/// The crash: nodes die hips to neck and stay dark. +/obj/item/organ/cyberimp/cyberware/cascade/proc/play_crash() + if(!owner) + return + if(ring_timer) + deltimer(ring_timer) + ring_timer = null + play_node_looks(list("crash1", "crash2", "crash3", "crash4", "crash5", "dead")) + +/// The lattice in the bearer's OS slot, if it is a Cascade. +/proc/cyberware_bearer_lattice(mob/living/bearer) + if(!iscarbon(bearer)) + return null + var/mob/living/carbon/carbon_bearer = bearer + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = carbon_bearer.get_organ_slot(ORGAN_SLOT_CYBERWARE_OS) + return istype(lattice) ? lattice : null + +/// Hook for the window's on_apply(). +/proc/cyberware_cascade_window_fx(mob/living/bearer) + cyberware_bearer_lattice(bearer)?.play_window_open() + +/// Hook for the window's on_remove(), after it has (or hasn't) applied the crash. +/proc/cyberware_cascade_window_end_fx(mob/living/bearer) + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = cyberware_bearer_lattice(bearer) + if(lattice && !bearer.has_status_effect(/datum/status_effect/cyberware_cascade_crash)) + lattice.clear_node_looks(bearer) + +/// Hook for the crash's on_apply(). +/proc/cyberware_cascade_crash_fx(mob/living/bearer) + cyberware_bearer_lattice(bearer)?.play_crash() + +/// Hook for the crash's on_remove(). +/proc/cyberware_cascade_crash_end_fx(mob/living/bearer) + cyberware_bearer_lattice(bearer)?.clear_node_looks(bearer) + +/// The floor ring that rolls out when a Cascade window opens. +/obj/effect/temp_visual/cyberware_time_ring + icon = CYBERWARE_ANIM_LARGE_ICON + icon_state = "time_ring" + pixel_x = -16 + pixel_y = -16 + layer = ABOVE_OPEN_TURF_LAYER + plane = FLOOR_PLANE + randomdir = FALSE + duration = 0.65 SECONDS + +/obj/effect/temp_visual/cyberware_time_ring/Initialize(mapload, max_scale = 3.3, peak_alpha = 235, ring_time = 0.65 SECONDS) + duration = ring_time + . = ..() + add_overlay(emissive_appearance(icon, icon_state, src)) + transform = matrix().Scale(0.2) + alpha = peak_alpha + animate(src, transform = matrix().Scale(max_scale), time = duration, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + animate(src, alpha = 0, time = duration, easing = QUAD_EASING | EASE_IN, flags = ANIMATION_PARALLEL) + +#undef CASCADE_NODE_STEP +#undef CASCADE_RING_DELAY + +// ========================================================================= +// EMP ON CHROME +// ========================================================================= + +/// From the hit to the first piece going dark. +#define EMP_SHOW_FIRST_DEATH (0.55 SECONDS) +/// Between one piece going dark and the next. +#define EMP_SHOW_DEATH_STAGGER (0.2 SECONDS) +/// How long the arcs crackle. +#define EMP_SHOW_ARC_TIME (0.8 SECONDS) +/// Most arcs drawn at once. +#define EMP_SHOW_MAX_ARCS 3 + +/** + * The EMP picture for one bearer. Each worn piece hit in a burst fills with + * static, arcs jump between the pieces, and they go dark one after another; + * the mechanical reboot timing is untouched, only the picture staggers. When a + * piece comes back it blinks bright, dark, then on. + * + * Looks live on each piece's cyberware component (emp_look), and clearing + * them always falls back to the right picture for the reboot state, so + * deleting this at any point leaves the bearer drawn correctly. + */ +/datum/component/chrome_emp_show + dupe_mode = COMPONENT_DUPE_UNIQUE + /// Pieces in the burst that have not gone dark yet. + var/list/datum/weakref/crackling = list() + /// Pieces whose look this show has set, so it can take them back off. + var/list/datum/weakref/touched = list() + /// When the current burst started; a later hit starts a new one. + var/burst_started = -1 + /// Pieces scheduled to go dark in the current burst. + var/burst_deaths = 0 + /// Holders this show is playing. + var/list/obj/effect/abstract/cyberware_anim/holders = list() + /// Steps still to run. At zero the show deletes itself. + var/pending = 0 + /// The current blink batch: pieces that rebooted on the same tick. + var/list/datum/weakref/blink_batch + /// When the current blink batch started. + var/blink_started = -1 + +/datum/component/chrome_emp_show/Initialize() + if(!iscarbon(parent)) + return COMPONENT_INCOMPATIBLE + +/datum/component/chrome_emp_show/RegisterWithParent() + RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(on_death)) + +/datum/component/chrome_emp_show/UnregisterFromParent() + UnregisterSignal(parent, COMSIG_LIVING_DEATH) + +/datum/component/chrome_emp_show/Destroy() + var/list/playing = holders.Copy() + holders.Cut() + QDEL_LIST(playing) + var/mob/living/carbon/bearer = parent + var/changed = FALSE + for(var/datum/weakref/piece_ref as anything in touched) + var/obj/item/organ/piece = piece_ref.resolve() + var/datum/component/cyberware/chrome = piece?.GetComponent(/datum/component/cyberware) + if(chrome?.emp_look) + chrome.emp_look = null + changed = TRUE + touched.Cut() + crackling.Cut() + if(changed && !QDELETED(bearer)) + bearer.update_body_parts() + return ..() + +/datum/component/chrome_emp_show/proc/on_death(datum/source) + SIGNAL_HANDLER + qdel(src) + +/// The show for [bearer], made if there isn't one. +/proc/chrome_emp_show_for(mob/living/carbon/bearer) + if(!iscarbon(bearer) || QDELETED(bearer) || bearer.stat == DEAD) + return null + return bearer.GetComponent(/datum/component/chrome_emp_show) || bearer.AddComponent(/datum/component/chrome_emp_show) + +/// Worn chrome only: the show draws on the worn overlay. +/proc/chrome_emp_show_wants(obj/item/organ/piece) + var/obj/item/organ/cyberimp/implant = piece + return istype(implant) && implant.bodypart_aug && implant.owner + +/// Region name a piece arcs from, matching the arc sheet. +/proc/chrome_emp_region(obj/item/organ/piece) + switch(piece.zone) + if(BODY_ZONE_R_ARM) + return "arm_r" + if(BODY_ZONE_L_ARM) + return "arm_l" + if(BODY_ZONE_R_LEG, BODY_ZONE_L_LEG) + return "legs" + return "chest" + +/// Hook for start_emp_reboot(): the piece was just knocked offline. +/proc/cyberware_emp_hit_fx(obj/item/organ/piece) + if(!chrome_emp_show_wants(piece)) + return + var/datum/component/chrome_emp_show/show = chrome_emp_show_for(piece.owner) + if(show) + show.hit(piece) + else + // No show on a corpse: just draw the piece dark. + piece.owner.update_body_parts() + +/// Hook for finish_emp_reboot(): the piece is back online. +/proc/cyberware_emp_reboot_fx(obj/item/organ/piece) + if(!chrome_emp_show_wants(piece)) + return + var/datum/component/chrome_emp_show/show = chrome_emp_show_for(piece.owner) + if(show) + show.blink(piece) + else + piece.owner.update_body_parts() + +/datum/component/chrome_emp_show/proc/set_look(obj/item/organ/piece, look) + var/datum/component/cyberware/chrome = piece.GetComponent(/datum/component/cyberware) + if(!chrome) + return + chrome.emp_look = look + touched |= WEAKREF(piece) + +/// A piece is hit: static now, dark on its turn. +/datum/component/chrome_emp_show/proc/hit(obj/item/organ/piece) + var/datum/weakref/piece_ref = WEAKREF(piece) + if(burst_started != world.time && !length(crackling)) + // A fresh burst. Everything hit this tick joins it; the crackle starts next tick. + burst_started = world.time + burst_deaths = 0 + pending++ + addtimer(CALLBACK(src, PROC_REF(start_burst)), 0) + set_look(piece, CHROME_LOOK_STATIC) + crackling |= piece_ref + var/dies_at = burst_started + EMP_SHOW_FIRST_DEATH + EMP_SHOW_DEATH_STAGGER * burst_deaths + burst_deaths++ + pending++ + addtimer(CALLBACK(src, PROC_REF(piece_dies), piece_ref), max(dies_at - world.time, 0.5)) + +/// The tick after the hit: show the static, throw the arcs, shake the bearer. +/datum/component/chrome_emp_show/proc/start_burst() + var/mob/living/carbon/bearer = parent + bearer.update_body_parts() + var/list/regions = list() + for(var/datum/weakref/piece_ref as anything in crackling) + var/obj/item/organ/piece = piece_ref.resolve() + if(piece?.owner == bearer) + regions |= chrome_emp_region(piece) + sortTim(regions, GLOBAL_PROC_REF(cmp_text_asc)) + var/list/arcs = list() + if(length(regions) == 1) + arcs += "chrome_arc_[regions[1]]" + else + for(var/i in 1 to length(regions) - 1) + arcs += "chrome_arc_[regions[i]]_[regions[i + 1]]" + if(length(regions) >= 3) + arcs += "chrome_arc_[regions[1]]_[regions[length(regions)]]" + for(var/i in 1 to min(length(arcs), EMP_SHOW_MAX_ARCS)) + add_holder(cyberware_anim_play(bearer, CYBERWARE_ANIM_LARGE_ICON, arcs[i], CHROME_ANIM_TOP_LAYER, EMP_SHOW_ARC_TIME, glow = TRUE)) + bearer.do_jitter_animation(0) + var/turf/here = get_turf(bearer) + if(here) + new /obj/effect/temp_visual/emp(here) + step_done() + +/// One piece's turn to go dark, with a spark where it dies. +/datum/component/chrome_emp_show/proc/piece_dies(datum/weakref/piece_ref) + crackling -= piece_ref + var/obj/item/organ/piece = piece_ref.resolve() + var/mob/living/carbon/bearer = parent + if(piece?.owner == bearer) + var/datum/component/cyberware/chrome = piece.GetComponent(/datum/component/cyberware) + if(chrome?.emp_look == CHROME_LOOK_STATIC) + chrome.emp_look = null + bearer.update_body_parts() + add_holder(cyberware_anim_play(bearer, CYBERWARE_ANIM_LARGE_ICON, "chrome_spark_[chrome_emp_region(piece)]", CHROME_ANIM_TOP_LAYER, 0.2 SECONDS, glow = TRUE)) + step_done() + +/// A piece is back: bright, dark, bright, on. Pieces back on the same tick blink together. +/datum/component/chrome_emp_show/proc/blink(obj/item/organ/piece) + crackling -= WEAKREF(piece) + if(blink_started != world.time) + blink_started = world.time + blink_batch = list() + var/list/batch = blink_batch + pending += 3 + addtimer(CALLBACK(src, PROC_REF(blink_step), batch, CHROME_LOOK_DARK), 0.5) + addtimer(CALLBACK(src, PROC_REF(blink_step), batch, CHROME_LOOK_FLASH), 2) + addtimer(CALLBACK(src, PROC_REF(blink_step), batch, null), 2.5) + blink_batch |= WEAKREF(piece) + set_look(piece, CHROME_LOOK_FLASH) + var/mob/living/carbon/bearer = parent + bearer.update_body_parts() + +/datum/component/chrome_emp_show/proc/blink_step(list/batch, look) + var/mob/living/carbon/bearer = parent + for(var/datum/weakref/piece_ref as anything in batch) + var/obj/item/organ/piece = piece_ref.resolve() + var/datum/component/cyberware/chrome = piece?.GetComponent(/datum/component/cyberware) + // A piece hit again mid-blink belongs to the new burst now. + if(!chrome || piece.owner != bearer || chrome.emp_down) + continue + chrome.emp_look = look + bearer.update_body_parts() + step_done() + +/datum/component/chrome_emp_show/proc/add_holder(obj/effect/abstract/cyberware_anim/holder) + if(!holder) + return + holders += holder + RegisterSignal(holder, COMSIG_QDELETING, PROC_REF(on_holder_deleted)) + +/datum/component/chrome_emp_show/proc/on_holder_deleted(datum/source) + SIGNAL_HANDLER + holders -= source + +/datum/component/chrome_emp_show/proc/step_done() + pending-- + if(pending <= 0 && !length(crackling)) + qdel(src) + +#undef EMP_SHOW_FIRST_DEATH +#undef EMP_SHOW_DEATH_STAGGER +#undef EMP_SHOW_ARC_TIME +#undef EMP_SHOW_MAX_ARCS + +// ========================================================================= +// CLEANUP +// ========================================================================= + +/** + * Takes every animation this organ is running off [old_owner] and resets its + * looks. Called when the chrome leaves a body and when it is deleted. + */ +/obj/item/organ/proc/cyberware_anim_clear(mob/living/carbon/old_owner) + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + if(chrome) + chrome.emp_look = null + chrome.brownout_look = null + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/cyberware_anim_clear(mob/living/carbon/old_owner) + . = ..() + stop_blade_anim() + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade in contents) + blade.inhand_hidden_until = 0 + +/obj/item/organ/cyberimp/cyberware/ghostskin/cyberware_anim_clear(mob/living/carbon/old_owner) + . = ..() + cloak_enter_until = 0 + +/obj/item/organ/cyberimp/cyberware/cascade/cyberware_anim_clear(mob/living/carbon/old_owner) + . = ..() + clear_node_looks() + +#undef CYBERWARE_ANIM_ICON +#undef CYBERWARE_ANIM_LARGE_ICON +#undef CYBERWARE_ANIM2_ICON +#undef CHROME_LOOK_STATIC +#undef CHROME_LOOK_DARK +#undef CHROME_LOOK_FLASH +#undef CHROME_LOOK_FOLD +#undef CHROME_LOOK_BROWN +#undef CHROME_LOOK_WARM +#undef CHROME_ANIM_BLADE_LAYER +#undef CHROME_ANIM_TOP_LAYER +#undef CHROME_ANIM_ARM_COVER_FILTER diff --git a/voidcrew/modules/cyberware/cyberware_anim2.dm b/voidcrew/modules/cyberware/cyberware_anim2.dm new file mode 100644 index 00000000000..7a799de2ca7 --- /dev/null +++ b/voidcrew/modules/cyberware/cyberware_anim2.dm @@ -0,0 +1,1045 @@ +/** + * # Chrome animations, second batch + * + * More motion on chrome that already works, built the same way as + * cyberware_anim.dm: every proc here only draws, and the mechanics call into + * it after they have already happened. Nothing here changes a number, a timer + * or who gets hit. + * + * - Redline Burn: nodes flash white and run red-hot, eyes flood red, a red + * halo breathes round the body and the roar rolls a ring across the floor. + * In the crash the outline gutters out, the spine runs white and the charge + * earths through the deck in arcs that fade; the nodes cool to grey and the + * body slumps a little. + * - Lazarus Node: a magenta charge crawls over the body through the windup, + * then a white jolt, a burst and a little spring as they come up. + * - Leaps: the Hopper crouches, kicks up dust and arcs over to where it lands, + * with a shadow running along the floor under it. The Piledriver glides to + * its mark and slams down with a ring and a cracked floor. + * - Weapon trails: a Scorch cut throws embers; the Widowline Arc's wire + * lashes out, a small crackle runs along it and sparks burst where it hit. + * - Brownout: worn chrome stutters, warms and dims together, and stutters + * back on when the load comes off. (The LEDs breathing at rest are part of + * the plain worn look in cyberware_anim.dm.) + * - Chrome cradle: the rig's arms come down on the servo beats, carry the ware + * in and sink it, and the patient glitches as it boots. + * + * Timers are one-shot and owned by the thing they animate, or global procs + * holding weak references, so nothing outlives what it draws on. + */ + +#define CYBERWARE_ANIM2_ICON 'voidcrew/modules/cyberware/icons/cyberware_anim2.dmi' +#define CYBERWARE_ANIM2_LARGE_ICON 'voidcrew/modules/cyberware/icons/cyberware_anim2_large.dmi' +#define CHROME_CRADLE_RIG_ICON 'voidcrew/modules/cyberware/icons/chrome_cradle_rig.dmi' + +/// Layer for flashes, arcs and bursts: over everything the bearer wears. +#define CHROME_ANIM2_TOP_LAYER (-(HIGHEST_LAYER - 0.5)) + +/// Worn looks shared with cyberware_anim.dm. +#define CHROME_LOOK_BROWN "brown" +#define CHROME_LOOK_WARM "warm" + +// ========================================================================= +// SHARED HELPERS +// ========================================================================= + +/// Plays a 64x64 state from the batch-2 sheet centred on [bearer]. +/proc/cyberware_anim2_play_large(atom/movable/bearer, state, lifetime, glow = TRUE) + var/obj/effect/abstract/cyberware_anim/holder = cyberware_anim_play(bearer, CYBERWARE_ANIM2_LARGE_ICON, state, CHROME_ANIM2_TOP_LAYER, lifetime, glow) + if(holder) + holder.pixel_x = -16 + holder.pixel_y = -16 + return holder + +/** + * A particle emitter riding [bearer] for [lifetime]. It stops making new + * particles after [emit_time] so the last ones fade out before it goes. + */ +/proc/cyberware_anim_particles(atom/movable/bearer, particles_type, anim_layer, emit_time, lifetime) + if(QDELETED(bearer)) + return null + var/obj/effect/abstract/cyberware_anim/holder = new(null) + holder.bearer = bearer + holder.icon = null + holder.layer = anim_layer + holder.particles = new particles_type + holder.RegisterSignal(bearer, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + bearer.vis_contents += holder + addtimer(CALLBACK(holder, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, stop_particles)), emit_time) + QDEL_IN(holder, lifetime) + return holder + +/obj/effect/abstract/cyberware_anim/proc/stop_particles() + if(particles) + particles.spawning = 0 + +/// Grey dust kicked up by a landing or a take-off. +/proc/cyberware_grey_dust(turf/where) + if(isnull(where)) + return null + var/obj/effect/temp_visual/mook_dust/dust = new(where) + dust.color = list(0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.2, 0.2, 0.2, 0.33, 0.33, 0.35) + return dust + +#define CHROME_FLASH_FILTER "cyberware_flash" + +/// A white flash over [target] that fades back to its own colours. +/proc/cyberware_flash_fx(atom/movable/target, fade_time = 0.25 SECONDS) + if(QDELETED(target)) + return + var/static/list/flash = list(0.4, 0, 0, 0, 0, 0.4, 0, 0, 0, 0, 0.4, 0, 0, 0, 0, 1, 0.6, 0.6, 0.62, 0) + target.add_filter(CHROME_FLASH_FILTER, 43, color_matrix_filter(flash)) + // Beside whatever else is moving the target: a plain animate() on its filter would end a fall or a shove + // already under way, and they would snap to the floor. + animate(target.get_filter(CHROME_FLASH_FILTER), color = COLOR_MATRIX_IDENTITY, time = fade_time, flags = ANIMATION_PARALLEL) + // A rebuild of the target's filters lands on the faded end, not the flash. + target.filter_data[CHROME_FLASH_FILTER]["color"] = COLOR_MATRIX_IDENTITY + addtimer(CALLBACK(target, TYPE_PROC_REF(/datum, remove_filter), CHROME_FLASH_FILTER), fade_time + 0.5) + +#undef CHROME_FLASH_FILTER + +// ========================================================================= +// GLITCH (a patient booting new chrome) +// ========================================================================= + +#define CHROME_GLITCH_SLICES "cyberware_glitch_slices" +#define CHROME_GLITCH_RED "cyberware_glitch_red" +#define CHROME_GLITCH_CYAN "cyberware_glitch_cyan" + +/** + * Tears [target] into shifted slices with a red and cyan fringe and a burst + * of static over it, for [duration]. With [flash] it whites out first. With + * [inset] the static keeps to the target's own pixels, which needs a target + * drawn as one piece (KEEP_TOGETHER, as people are). + */ +/proc/cyberware_glitch_fx(atom/movable/target, duration = 0.25 SECONDS, flash = FALSE, inset = FALSE) + if(QDELETED(target)) + return + target.add_filters(list( + list("name" = CHROME_GLITCH_SLICES, "priority" = 40, "params" = displacement_map_filter(icon(CYBERWARE_ANIM2_ICON, "glitch_slices"), size = 3)), + list("name" = CHROME_GLITCH_RED, "priority" = 41, "params" = drop_shadow_filter(x = -1, y = 0, size = 0, color = "#ff2020a0")), + list("name" = CHROME_GLITCH_CYAN, "priority" = 42, "params" = drop_shadow_filter(x = 1, y = 0, size = 0, color = "#20e0ffa0")), + )) + // The slices jump about, then settle. + var/slices = target.get_filter(CHROME_GLITCH_SLICES) + animate(slices, y = 7, time = 0.5) + animate(y = 13, size = 2, time = 0.5) + animate(y = 3, size = 0, time = max(duration - 1, 0.5)) + target.filter_data[CHROME_GLITCH_SLICES]["size"] = 0 + if(flash) + cyberware_flash_fx(target, duration * 0.5) + var/obj/effect/abstract/cyberware_anim/tear = cyberware_anim_play(target, CYBERWARE_ANIM2_ICON, "glitch_tear", CHROME_ANIM2_TOP_LAYER, duration) + if(tear && inset) + tear.blend_mode = BLEND_INSET_OVERLAY + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cyberware_glitch_end), WEAKREF(target)), duration) + +/proc/cyberware_glitch_end(datum/weakref/target_ref) + var/atom/movable/target = target_ref?.resolve() + if(QDELETED(target)) + return + target.remove_filter(list(CHROME_GLITCH_SLICES, CHROME_GLITCH_RED, CHROME_GLITCH_CYAN)) + +#undef CHROME_GLITCH_SLICES +#undef CHROME_GLITCH_RED +#undef CHROME_GLITCH_CYAN + +// ========================================================================= +// REDLINE BURN +// ========================================================================= + +#define REDLINE_LOOK_FLASH "flash" +/// The crash's first instant: the whole core lit white down the spine. +#define REDLINE_LOOK_SURGE "surge" +#define REDLINE_LOOK_HOT "hot" +#define REDLINE_LOOK_COOL1 "cool1" +#define REDLINE_LOOK_COOL2 "cool2" +#define REDLINE_SAG_FILTER "cyberware_redline_sag" +/// How long the white kick-in flash holds before the nodes run red. +#define REDLINE_FLASH_TIME (0.15 SECONDS) +/// The crash: how long the spine runs white before the charge leaves it for the floor. +#define REDLINE_SPINE_FLASH (0.1 SECONDS) +/// From the discharge to the nodes going grey. +#define REDLINE_COOL_STEP (0.35 SECONDS) +/// The outline's last stutters, drawn by a filter of its own once the window has taken its outline away. +#define REDLINE_GUTTER_FILTER "cyberware_redline_gutter" +/// The window's outline colour (CYBERWARE_REDLINE_OUTLINE_COLOR, ware_legend.dm), lit and out. +#define REDLINE_GUTTER_ON "#ff2a2a" +#define REDLINE_GUTTER_OUT "#ff2a2a00" +/// How long that outline stands at full strength before its first stutter. +#define REDLINE_GUTTER_HOLD (0.1 SECONDS) +/// How long the arcs stand on the deck, how often they change, and how long their tracks take to glow, cool and +/// fade after them. +#define REDLINE_ARC_TIME (0.15 SECONDS) +#define REDLINE_ARC_FLICKER (0.05 SECONDS) +#define REDLINE_GLOW_TIME (2.2 SECONDS) +/// How long the body takes to straighten up out of the slump when the crash ends. +#define REDLINE_STRAIGHTEN_TIME (0.3 SECONDS) +/// The sheet of deck effects, 96 px and centred on the bearer's tile. +#define CYBERWARE_GROUND_ICON 'voidcrew/modules/cyberware/icons/cyberware_ground.dmi' +/// The eyes during the burn. +#define REDLINE_EYE_COLOR "#ff2a1a" +/// The eyes as the red drains out of them. +#define REDLINE_EYE_DYING "#8a2420" + +/obj/item/organ/cyberimp/cyberware/redline + /// The node look drawn over the core, or null for the plain one. + var/burn_look + /// Timer for the next node look. + var/burn_look_timer + /// Who carries our filters and our death watch. + var/datum/weakref/burn_fx_ref + /// The red light the burn throws. + var/datum/weakref/burn_light_ref + +/obj/item/organ/cyberimp/cyberware/redline/cyberware_worn_key() + return "[..()]-[burn_look]" + +/obj/item/organ/cyberimp/cyberware/redline/cyberware_dress_worn(list/imageset, image_layer, obj/item/bodypart/limb) + if(cyberware_worn_look() || !burn_look) + return ..() + var/state = "[aug_overlay]_[burn_look]" + if(!icon_exists(CYBERWARE_ANIM2_ICON, state)) + return ..() + // The node look replaces the core's own glow. + var/list/dressed = list() + for(var/image/part as anything in imageset) + if(PLANE_TO_TRUE(part.plane) == EMISSIVE_PLANE) + continue + dressed += part + // Nodes that still glow shine through whatever is worn on the back; cold ones stay under it. + dressed += cyberware_spine_node_images(CYBERWARE_ANIM2_ICON, state, burn_look != REDLINE_LOOK_COOL2, image_layer, limb?.owner || limb) + if(burn_look == REDLINE_LOOK_HOT || burn_look == REDLINE_LOOK_FLASH || burn_look == REDLINE_LOOK_SURGE) + dressed += redline_eyes(limb, image_layer) + else if(burn_look == REDLINE_LOOK_COOL1) + // The crash: the red drains out of them. + dressed += redline_eyes(limb, image_layer, REDLINE_EYE_DYING, FALSE) + return dressed + +/// Red eyes for the burn, drawn from the bearer's own eye sprites so they sit where their eyes are. +/obj/item/organ/cyberimp/cyberware/redline/proc/redline_eyes(obj/item/bodypart/limb, image_layer, eye_color = REDLINE_EYE_COLOR, glow = TRUE) + var/mob/living/carbon/human/bearer = limb?.owner + if(!istype(bearer)) + return list() + var/obj/item/organ/eyes/eyes = bearer.get_organ_slot(ORGAN_SLOT_EYES) + var/obj/item/bodypart/head/head = bearer.get_bodypart(BODY_ZONE_HEAD) + if(!istype(eyes) || isnull(eyes.eye_icon_state) || !head) + return list() + if(bearer.check_obscured_slots() & ITEM_SLOT_EYES) + return list() + var/list/eye_images = list() + for(var/side in list("_l", "_r")) + var/mutable_appearance/eye = mutable_appearance('icons/mob/human/human_face.dmi', "[eyes.eye_icon_state][side]", image_layer, bearer) + eye.color = eye_color + if(head.worn_face_offset) + head.worn_face_offset.apply_offset(eye) + eye_images += eye + if(!glow) + continue + var/mutable_appearance/eye_glow = emissive_appearance(eye.icon, eye.icon_state, bearer, image_layer) + if(head.worn_face_offset) + head.worn_face_offset.apply_offset(eye_glow) + eye_images += eye_glow + return eye_images + +/obj/item/organ/cyberimp/cyberware/redline/proc/set_burn_look(look) + burn_look_timer = null + if(burn_look == look) + return + burn_look = look + owner?.update_body_parts() + +/obj/item/organ/cyberimp/cyberware/redline/proc/queue_burn_look(look, delay) + if(burn_look_timer) + deltimer(burn_look_timer) + burn_look_timer = addtimer(CALLBACK(src, PROC_REF(set_burn_look), look), delay, TIMER_STOPPABLE) + +/// The window opens: white-hot nodes, then red, red eyes and a red light. The red outline around the +/// body is the window's own (ware_legend.dm). +/obj/item/organ/cyberimp/cyberware/redline/proc/play_burn_window(mob/living/carbon/bearer) + if(QDELETED(bearer) || bearer != owner) + return + clear_burn_fx() + watch_burn_bearer(bearer) + set_burn_look(REDLINE_LOOK_FLASH) + queue_burn_look(REDLINE_LOOK_HOT, REDLINE_FLASH_TIME) + burn_light_ref = WEAKREF(bearer.mob_light(2, 0.7, "#ff3b22", burn_window + 2 SECONDS)) + +/// The roar: a red ring rolls out as far as it reaches. +/obj/item/organ/cyberimp/cyberware/redline/proc/play_burn_roar(mob/living/carbon/bearer, reach) + var/turf/here = get_turf(bearer) + if(here && reach > 0) + new /obj/effect/temp_visual/circle_wave/cyberware_roar(here, reach) + +/** + * The crash. The governor slams shut and the charge it was holding has to go somewhere: the outline gutters out, + * the red drains from the eyes, the spine runs white from neck to hips, and then the charge earths through the + * deck (see [/obj/item/organ/cyberimp/cyberware/redline/proc/ground_burn]). The body slumps. + */ +/obj/item/organ/cyberimp/cyberware/redline/proc/play_burn_crash(mob/living/carbon/bearer) + if(QDELETED(bearer) || bearer != owner) + return + stop_burn_glow(bearer) + watch_burn_bearer(bearer) + if(burn_look_timer) + deltimer(burn_look_timer) + set_burn_look(REDLINE_LOOK_SURGE) + burn_look_timer = addtimer(CALLBACK(src, PROC_REF(ground_burn)), REDLINE_SPINE_FLASH, TIMER_STOPPABLE) + // The window took its outline with it. Ours holds for a beat, then stutters out (gutter_burn). Both filters go + // on before the slump starts to move: adding a filter rebuilds every filter on the body from its stored values + // and drops whatever was animating. + bearer.add_filter(REDLINE_GUTTER_FILTER, 2, outline_filter(1, REDLINE_GUTTER_ON)) + bearer.add_filter(REDLINE_SAG_FILTER, 31, displacement_map_filter(icon(CYBERWARE_ANIM2_ICON, "sag_map"), size = 0)) + animate(bearer.get_filter(REDLINE_SAG_FILTER), size = 2, time = 0.3 SECONDS, easing = QUAD_EASING | EASE_OUT) + bearer.filter_data[REDLINE_SAG_FILTER]["size"] = 2 + addtimer(CALLBACK(src, PROC_REF(gutter_burn), WEAKREF(bearer), 1), REDLINE_GUTTER_HOLD) + +/** + * The outline's last stutters, one a call: out, back dimmer, out, back dimmer still, gone. + * + * Stepped on a timer and stored as it goes, not animated. A second filter animation started on a body in the same + * instant as the slump's does not play, and an outline left lit in its stored values comes back at full strength + * the next time anything rebuilds the body's filters. + */ +/obj/item/organ/cyberimp/cyberware/redline/proc/gutter_burn(datum/weakref/bearer_ref, step) + var/static/list/colours = list(REDLINE_GUTTER_OUT, "#ff2a2ab4", REDLINE_GUTTER_OUT, "#ff2a2a70") + var/static/list/holds = list(0.05 SECONDS, 0.1 SECONDS, 0.05 SECONDS, 0.05 SECONDS) + var/mob/living/carbon/bearer = bearer_ref?.resolve() + if(QDELETED(bearer) || !bearer.get_filter(REDLINE_GUTTER_FILTER)) + return + if(step > length(colours)) + bearer.remove_filter(REDLINE_GUTTER_FILTER) + return + bearer.modify_filter(REDLINE_GUTTER_FILTER, list("color" = colours[step])) + addtimer(CALLBACK(src, PROC_REF(gutter_burn), bearer_ref, step + 1), holds[step]) + +/** + * The charge leaves the spine for the floor. The nodes cool behind it, arcs crawl out across the deck under + * everybody's feet, and on a bearer still standing it runs down the legs first: behind the body, and in front of + * it only when the back is to the camera. + */ +/obj/item/organ/cyberimp/cyberware/redline/proc/ground_burn() + burn_look_timer = null + var/mob/living/carbon/bearer = burn_fx_ref?.resolve() + if(QDELETED(bearer) || bearer != owner) + return + set_burn_look(REDLINE_LOOK_COOL1) + queue_burn_look(REDLINE_LOOK_COOL2, REDLINE_COOL_STEP) + var/turf/deck = get_turf(bearer) + if(!isturf(bearer.loc) || isgroundlessturf(deck)) + return + var/lying = bearer.body_position == LYING_DOWN + new /obj/effect/temp_visual/cyberware_redline_ground(deck, lying) + playsound(deck, SFX_SPARKS, 40, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) + if(lying) + return + var/obj/effect/abstract/cyberware_anim/leg = cyberware_anim_play(bearer, CYBERWARE_ANIM2_ICON, "redline_legarc", CHROME_ANIM2_TOP_LAYER, REDLINE_ARC_TIME, glow = TRUE) + if(leg && !(bearer.dir & NORTH)) + leg.vis_flags |= VIS_UNDERLAY + +/// Takes the light off; the nodes and the slump stay. +/obj/item/organ/cyberimp/cyberware/redline/proc/stop_burn_glow(mob/living/carbon/bearer) + qdel(burn_light_ref?.resolve()) + burn_light_ref = null + +/obj/item/organ/cyberimp/cyberware/redline/proc/watch_burn_bearer(mob/living/carbon/bearer) + burn_fx_ref = WEAKREF(bearer) + RegisterSignal(bearer, COMSIG_LIVING_DEATH, PROC_REF(on_burn_bearer_death), override = TRUE) + +/obj/item/organ/cyberimp/cyberware/redline/proc/on_burn_bearer_death(datum/source) + SIGNAL_HANDLER + clear_burn_fx() + +/// Back to the plain core: no node look, no halo, light or slump. [straighten] eases a living body up out of the +/// slump (the crash running its course); otherwise the slump goes at once. +/obj/item/organ/cyberimp/cyberware/redline/proc/clear_burn_fx(straighten = FALSE) + if(burn_look_timer) + deltimer(burn_look_timer) + burn_look_timer = null + var/mob/living/carbon/bearer = burn_fx_ref?.resolve() + burn_fx_ref = null + stop_burn_glow(bearer) + if(!QDELETED(bearer)) + UnregisterSignal(bearer, COMSIG_LIVING_DEATH) + bearer.remove_filter(REDLINE_GUTTER_FILTER) + var/sag = bearer.get_filter(REDLINE_SAG_FILTER) + if(sag && straighten && bearer.stat != DEAD) + animate(sag, size = 0, time = REDLINE_STRAIGHTEN_TIME, easing = QUAD_EASING | EASE_OUT) + bearer.filter_data[REDLINE_SAG_FILTER]["size"] = 0 + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cyberware_redline_straightened), WEAKREF(bearer)), REDLINE_STRAIGHTEN_TIME) + else + bearer.remove_filter(REDLINE_SAG_FILTER) + if(isnull(burn_look)) + return + burn_look = null + if(!QDELETED(bearer)) + bearer.update_body_parts() + +/// The body is upright again: the slump's filter, flat by now, comes off. A slump put on since is left alone. +/proc/cyberware_redline_straightened(datum/weakref/bearer_ref) + var/mob/living/carbon/bearer = bearer_ref?.resolve() + if(QDELETED(bearer) || bearer.filter_data?[REDLINE_SAG_FILTER]?["size"]) + return + bearer.remove_filter(REDLINE_SAG_FILTER) + +/// The core in the bearer's OS slot, if it is a Redline model. +/proc/cyberware_bearer_redline(mob/living/bearer) + if(!iscarbon(bearer)) + return null + var/mob/living/carbon/carbon_bearer = bearer + var/obj/item/organ/cyberimp/cyberware/redline/core = carbon_bearer.get_organ_slot(ORGAN_SLOT_CYBERWARE_OS) + return istype(core) ? core : null + +/// Hook for the window's on_apply(). +/proc/cyberware_redline_window_fx(mob/living/bearer) + cyberware_bearer_redline(bearer)?.play_burn_window(bearer) + +/// Hook for the roar, with the reach it was given. +/proc/cyberware_redline_roar_fx(mob/living/bearer, reach) + cyberware_bearer_redline(bearer)?.play_burn_roar(bearer, reach) + +/// Hook for the window's on_remove(), after it has (or hasn't) applied the crash. +/proc/cyberware_redline_window_end_fx(mob/living/bearer) + var/obj/item/organ/cyberimp/cyberware/redline/core = cyberware_bearer_redline(bearer) + if(core && !bearer.has_status_effect(/datum/status_effect/cyberware_redline_crash)) + core.clear_burn_fx() + +/// Hook for the crash's on_apply(). +/proc/cyberware_redline_crash_fx(mob/living/bearer) + cyberware_bearer_redline(bearer)?.play_burn_crash(bearer) + +/// Hook for the crash's on_remove(). +/proc/cyberware_redline_crash_end_fx(mob/living/bearer) + cyberware_bearer_redline(bearer)?.clear_burn_fx(straighten = TRUE) + +/obj/item/organ/cyberimp/cyberware/redline/cyberware_anim_clear(mob/living/carbon/old_owner) + . = ..() + clear_burn_fx() + +/// The roar's ring, out as far as the roar reaches. It rolls across the floor, so it is drawn on the floor: under +/// everyone and everything standing in its way, whichever side of the bearer they are on. +/obj/effect/temp_visual/circle_wave/cyberware_roar + color = "#ff4a2a" + max_alpha = 200 + duration = 0.5 SECONDS + plane = FLOOR_PLANE + layer = ABOVE_OPEN_TURF_LAYER + +/obj/effect/temp_visual/circle_wave/cyberware_roar/Initialize(mapload, reach = 5) + // The 64 px ring, scaled so its edge lands [reach] tiles out. + amount_to_scale = reach + 0.5 + return ..() + +/** + * The Redline's charge earthing through the deck. Arcs crawl out across the floor under everybody's feet and + * flicker; the tracks they leave glow, cool to a scorch and fade to nothing. Nothing of it outlasts its duration. + * + * It is floor: on the floor plane, and shifted with pixel_w and pixel_z so the 96 px picture stays on its own + * tile's row. Shifted with pixel_y it would sort a row forward, and its glow would light the bearer through. + */ +/obj/effect/temp_visual/cyberware_redline_ground + icon = CYBERWARE_GROUND_ICON + icon_state = "redline_arcs_standing_1" + plane = FLOOR_PLANE + layer = ABOVE_OPEN_TURF_LAYER + pixel_w = -32 + pixel_z = -32 + randomdir = FALSE + duration = REDLINE_ARC_TIME + REDLINE_GLOW_TIME + light_range = 2 + light_power = 0.9 + light_color = "#ff5a3a" + /// Where on the tile the charge reaches the deck: "standing" at the feet, "lying" along the length of the back. + var/shape = "standing" + +/obj/effect/temp_visual/cyberware_redline_ground/Initialize(mapload, lying = FALSE) + . = ..() + shape = lying ? "lying" : "standing" + show_arcs(1) + addtimer(CALLBACK(src, PROC_REF(show_arcs), 2), REDLINE_ARC_FLICKER) + addtimer(CALLBACK(src, PROC_REF(show_arcs), 1), REDLINE_ARC_FLICKER * 2) + addtimer(CALLBACK(src, PROC_REF(leave_glow)), REDLINE_ARC_TIME) + +/// One of the two arc pictures, and the same picture again as its glow, so the two are never out of step. +/obj/effect/temp_visual/cyberware_redline_ground/proc/show_arcs(picture) + icon_state = "redline_arcs_[shape]_[picture]" + cut_overlays() + add_overlay(emissive_appearance(icon, icon_state, src)) + +/// The arcs are gone: their tracks glow, cool and fade. +/obj/effect/temp_visual/cyberware_redline_ground/proc/leave_glow() + icon_state = "redline_glow_[shape]" + cut_overlays() + add_overlay(emissive_appearance(icon, icon_state, src, alpha = 150)) + set_light(0) + animate(src, alpha = 255, time = REDLINE_GLOW_TIME * 0.15) + animate(color = "#6a5350", time = REDLINE_GLOW_TIME * 0.3) + animate(alpha = 0, time = REDLINE_GLOW_TIME * 0.5) + +#undef REDLINE_LOOK_FLASH +#undef REDLINE_LOOK_SURGE +#undef REDLINE_LOOK_HOT +#undef REDLINE_LOOK_COOL1 +#undef REDLINE_LOOK_COOL2 +#undef REDLINE_SAG_FILTER +#undef REDLINE_FLASH_TIME +#undef REDLINE_COOL_STEP +#undef REDLINE_SPINE_FLASH +#undef REDLINE_GUTTER_FILTER +#undef REDLINE_GUTTER_ON +#undef REDLINE_GUTTER_OUT +#undef REDLINE_GUTTER_HOLD +#undef REDLINE_ARC_TIME +#undef REDLINE_ARC_FLICKER +#undef REDLINE_STRAIGHTEN_TIME +#undef REDLINE_GLOW_TIME +#undef REDLINE_EYE_DYING +#undef CYBERWARE_GROUND_ICON +#undef REDLINE_EYE_COLOR + +// ========================================================================= +// LAZARUS NODE +// ========================================================================= + +#define LAZARUS_SPRING_OFFSET "cyberware_lazarus_spring" +#define LAZARUS_CHARGE_FILTER "cyberware_lazarus_charge" + +/obj/item/organ/cyberimp/cyberware/lazarus + /// Who carries the charge's magenta halo. + var/datum/weakref/charge_fx_ref + /// The charge glow on the chest through the windup. + var/datum/weakref/charge_glow_ref + /// The arcs crawling over the body through the windup. + var/datum/weakref/charge_arcs_ref + /// The magenta light of the charge. + var/datum/weakref/charge_light_ref + +/// The windup: the node charges, magenta arcs crawl out over the body. +/obj/item/organ/cyberimp/cyberware/lazarus/proc/play_charge_fx(mob/living/carbon/patient, windup) + clear_charge_fx() + if(QDELETED(patient)) + return + charge_glow_ref = WEAKREF(cyberware_anim_play(patient, CYBERWARE_ANIM2_ICON, "lazarus_charge", CHROME_ANIM2_TOP_LAYER, windup, glow = TRUE)) + charge_arcs_ref = WEAKREF(cyberware_anim2_play_large(patient, "lazarus_arcs", windup)) + charge_light_ref = WEAKREF(patient.mob_light(1.5, 0.8, "#e700e3", windup)) + // The whole body takes on the charge, brighter as it fills. + charge_fx_ref = WEAKREF(patient) + patient.add_filter(LAZARUS_CHARGE_FILTER, 33, drop_shadow_filter(x = 0, y = 0, size = 1, color = "#e700e340")) + animate(patient.get_filter(LAZARUS_CHARGE_FILTER), size = 2.5, color = "#e700e3b0", time = windup, easing = QUAD_EASING | EASE_IN) + patient.filter_data[LAZARUS_CHARGE_FILTER]["size"] = 2.5 + patient.filter_data[LAZARUS_CHARGE_FILTER]["color"] = "#e700e3b0" + +/// Takes the charge off whoever it is on. +/obj/item/organ/cyberimp/cyberware/lazarus/proc/clear_charge_fx() + qdel(charge_glow_ref?.resolve()) + qdel(charge_arcs_ref?.resolve()) + qdel(charge_light_ref?.resolve()) + charge_glow_ref = null + charge_arcs_ref = null + charge_light_ref = null + var/mob/living/carbon/patient = charge_fx_ref?.resolve() + charge_fx_ref = null + if(!QDELETED(patient)) + patient.remove_filter(LAZARUS_CHARGE_FILTER) + +/// The jolt: a white flash, a burst and a light, and a little spring off the floor. +/obj/item/organ/cyberimp/cyberware/lazarus/proc/play_jolt_fx(mob/living/carbon/patient) + clear_charge_fx() + if(QDELETED(patient)) + return + cyberware_anim2_play_large(patient, "lazarus_jolt", 0.5 SECONDS) + patient.mob_light(2.5, 1.4, "#ffe6ff", 0.3 SECONDS) + cyberware_flash_fx(patient, 0.25 SECONDS) + patient.add_offsets(LAZARUS_SPRING_OFFSET, z_add = 3, animate = FALSE) + addtimer(CALLBACK(patient, TYPE_PROC_REF(/mob/living, remove_offsets), LAZARUS_SPRING_OFFSET), 0.5) + +/obj/item/organ/cyberimp/cyberware/lazarus/cyberware_anim_clear(mob/living/carbon/old_owner) + . = ..() + clear_charge_fx() + +#undef LAZARUS_SPRING_OFFSET +#undef LAZARUS_CHARGE_FILTER + +// ========================================================================= +// LEAPS +// ========================================================================= + +/// Set at take-off to when the leap should be down. A leap whose landing never +/// runs is put back on the floor shortly after. +/mob/living/var/cyberware_leap_until = 0 +/// How the body's steps were animated before a leap switched that off, to put back once it has landed. +/mob/living/var/cyberware_leap_steps + +/// Where a leaping body draws among the things on its row: over anyone standing there, since it is above them. +#define CYBERWARE_LEAP_LAYER (ABOVE_MOB_LAYER + 0.05) +/// How long a leap that holds its height takes to come down at the end. +#define CYBERWARE_LEAP_SLAM (0.1 SECONDS) + +/// Where the body sits at rest, before any leap offset. +/proc/cyberware_leap_rest(mob/living/jumper, pixel) + var/base = jumper.base_pixel_z + switch(pixel) + if(PIXEL_W_OFFSET) + base = jumper.base_pixel_w + if(PIXEL_Y_OFFSET) + base = jumper.base_pixel_y + return base + jumper.has_offset(pixel = pixel) + +/** + * Take-off. The body arcs from [launch] over to [landing] and is down on the landing tile when [airtime] ends, so + * the landing's dust, ring and sound meet it there. With [height] under [peak] it rises to [peak] halfway and + * falls; with [height] at [peak] it climbs, holds that height over to its mark and drops in the last + * CYBERWARE_LEAP_SLAM of the flight. The body stays on its own tile until the landing moves it; only the drawing + * travels. + * + * The fall is started by a timer of its own, on the same clock as the landing: a server running slow holds the + * body up until its landing is nearly due, and never stands it on the tile ahead of its own impact. + * + * The run along the floor goes at an even pace and only the height eases, so the body never hangs at the top of + * its arc. The run up and down the screen is pixel_y, which carries the body's place in the front-to-back order + * along with it: it draws in front of what it has passed and behind what it hasn't. The height is pixel_z, which + * changes nothing but the drawing. On its row it draws over whoever stands there. + */ +/proc/cyberware_leap_takeoff_fx(mob/living/jumper, turf/launch, turf/landing, airtime, height, peak, obj/effect/afterimage) + if(QDELETED(jumper)) + return + if(afterimage) + // The crouch the pistons fired out of. + var/matrix/squash = matrix(afterimage.transform) + squash.Scale(1.08, 0.86) + squash.Translate(0, -2) + afterimage.transform = squash + cyberware_grey_dust(launch) + var/dx = 0 + var/dy = 0 + if(launch && landing) + dx = (landing.x - launch.x) * ICON_SIZE_X + dy = (landing.y - launch.y) * ICON_SIZE_Y + var/rest_w = cyberware_leap_rest(jumper, PIXEL_W_OFFSET) + var/rest_y = cyberware_leap_rest(jumper, PIXEL_Y_OFFSET) + var/rest_z = cyberware_leap_rest(jumper, PIXEL_Z_OFFSET) + if(jumper.layer == initial(jumper.layer) || jumper.layer == LYING_MOB_LAYER) + jumper.layer = CYBERWARE_LEAP_LAYER + // The landing moves the body onto a tile its drawing has already reached, so that move must not glide. The + // client only honours this for moves that come after it has heard of it, so it is set here, not at the landing. + if(jumper.animate_movement != NO_STEPS) + jumper.cyberware_leap_steps = jumper.animate_movement + jumper.animate_movement = NO_STEPS + animate(jumper, pixel_w = rest_w + dx, pixel_y = rest_y + dy, time = airtime, flags = ANIMATION_PARALLEL) + var/fall = airtime * 0.5 + var/rise = airtime * 0.5 + if(height >= peak) + fall = min(CYBERWARE_LEAP_SLAM, airtime * 0.5) + rise = (airtime - fall) * 0.4 + animate(jumper, pixel_z = rest_z + peak, time = rise, easing = QUAD_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cyberware_leap_fall_fx), WEAKREF(jumper), fall), airtime - fall) + if(dx || dy) + new /obj/effect/temp_visual/cyberware_leap_shadow(launch, dx, dy, airtime) + jumper.cyberware_leap_until = world.time + airtime + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cyberware_leap_failsafe), WEAKREF(jumper)), airtime + 0.5 SECONDS) + +/// The last of a leap: the body comes down over its landing tile, arriving as the landing is due. +/proc/cyberware_leap_fall_fx(datum/weakref/jumper_ref, fall) + var/mob/living/jumper = jumper_ref?.resolve() + if(QDELETED(jumper) || !jumper.cyberware_leap_until) + return + animate(jumper, pixel_z = cyberware_leap_rest(jumper, PIXEL_Z_OFFSET), time = fall, easing = QUAD_EASING | EASE_IN, flags = ANIMATION_PARALLEL) + +/** + * Touchdown: the arc has brought the body down over its landing tile, and the drawing goes back to the body. The + * move onto that tile, which the caller makes right after this, must not glide: the drawing is already there. + */ +/proc/cyberware_leap_touchdown_fx(mob/living/jumper) + if(QDELETED(jumper)) + return + jumper.cyberware_leap_until = 0 + if(jumper.layer == CYBERWARE_LEAP_LAYER) + jumper.layer = jumper.body_position == LYING_DOWN ? LYING_MOB_LAYER : initial(jumper.layer) + // Ends every track of the arc where it stands. + animate(jumper, pixel_w = cyberware_leap_rest(jumper, PIXEL_W_OFFSET), pixel_y = cyberware_leap_rest(jumper, PIXEL_Y_OFFSET), pixel_z = cyberware_leap_rest(jumper, PIXEL_Z_OFFSET), time = 0, flags = ANIMATION_END_NOW) + // Steps glide again once the landing's own move has gone out. + if(!isnull(jumper.cyberware_leap_steps)) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cyberware_leap_steps_back), WEAKREF(jumper)), 0.2 SECONDS) + +/// Gives a landed body its step animation back, unless it is already in the air again. +/proc/cyberware_leap_steps_back(datum/weakref/jumper_ref) + var/mob/living/jumper = jumper_ref?.resolve() + if(QDELETED(jumper) || jumper.cyberware_leap_until || isnull(jumper.cyberware_leap_steps)) + return + jumper.animate_movement = jumper.cyberware_leap_steps + jumper.cyberware_leap_steps = null + +/// A leap whose landing never ran (the pistons were pulled mid-air) is put back down. +/proc/cyberware_leap_failsafe(datum/weakref/jumper_ref) + var/mob/living/jumper = jumper_ref?.resolve() + if(QDELETED(jumper) || !jumper.cyberware_leap_until || world.time < jumper.cyberware_leap_until) + return + cyberware_leap_touchdown_fx(jumper) + +/// The Piledriver's impact: a ring rolls out over the shockwave and the floor cracks. +/proc/cyberware_piledriver_impact_fx(turf/where, reach) + if(isnull(where)) + return + new /obj/effect/temp_visual/circle_wave/cyberware_slam/floor(where, reach) + new /obj/effect/temp_visual/cyberware_impact_cracks(where, "damaged1", 255) + for(var/direction in GLOB.cardinals) + var/turf/next = get_step(where, direction) + if(next) + new /obj/effect/temp_visual/cyberware_impact_cracks(next, "damaged5", 140) + +/// The shadow that runs along the floor under a leap. +/obj/effect/temp_visual/cyberware_leap_shadow + icon = CYBERWARE_ANIM2_ICON + icon_state = "leap_shadow" + layer = BELOW_MOB_LAYER + randomdir = FALSE + duration = 0.3 SECONDS + +/obj/effect/temp_visual/cyberware_leap_shadow/Initialize(mapload, dx = 0, dy = 0, airtime = 0.2 SECONDS) + duration = airtime + 0.1 SECONDS + . = ..() + animate(src, pixel_x = dx, pixel_y = dy, time = airtime) + animate(src, transform = matrix().Scale(0.7), time = airtime * 0.5, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + animate(transform = matrix(), time = airtime * 0.5, easing = SINE_EASING | EASE_IN) + +/// The Piledriver's ring: grey, out over the shockwave. +/obj/effect/temp_visual/circle_wave/cyberware_slam + color = "#d8d4cc" + max_alpha = 220 + duration = 0.4 SECONDS + layer = BELOW_MOB_LAYER + +/obj/effect/temp_visual/circle_wave/cyberware_slam/Initialize(mapload, reach = 2) + amount_to_scale = reach + 0.5 + return ..() + +/// The same ring drawn on the floor, under everyone and everything standing in its way, whichever side of the +/// landing they are on. The Piledriver's own; the plain one is also what a Gorilla fist throws. +/obj/effect/temp_visual/circle_wave/cyberware_slam/floor + plane = FLOOR_PLANE + layer = ABOVE_OPEN_TURF_LAYER + +/// Cracks the Piledriver leaves in the floor. They fade on their own. +/obj/effect/temp_visual/cyberware_impact_cracks + icon = 'icons/turf/damaged.dmi' + icon_state = "damaged1" + plane = FLOOR_PLANE + layer = ABOVE_OPEN_TURF_LAYER + randomdir = FALSE + duration = 8 SECONDS + +/obj/effect/temp_visual/cyberware_impact_cracks/Initialize(mapload, state = "damaged1", peak_alpha = 255) + . = ..() + var/turf/here = loc + // Nothing to crack in space, open air or a chasm. + if(!isfloorturf(here)) + return INITIALIZE_HINT_QDEL + icon_state = state + alpha = peak_alpha + animate(src, alpha = peak_alpha, time = duration - 2 SECONDS) + animate(alpha = 0, time = 2 SECONDS) + +// ========================================================================= +// WEAPON TRAILS +// ========================================================================= + +/// A landed Scorch cut: embers fly off whoever it cut. The burning slash itself +/// is the blade's impact (cyberware_anim.dm), so nothing else is drawn on top. +/proc/cyberware_scorch_trail_fx(mob/living/user, mob/living/target) + var/turf/here = get_turf(target) + if(isnull(here)) + return + new /obj/effect/temp_visual/cyberware_scorch_embers(here) + +/// Only the embers: the picture is blank. +/obj/effect/temp_visual/cyberware_scorch_embers + layer = ABOVE_MOB_LAYER + randomdir = FALSE + duration = 0.7 SECONDS + +/obj/effect/temp_visual/cyberware_scorch_embers/Initialize(mapload) + . = ..() + particles = new /particles/embers/spark/cyberware_scorch + addtimer(CALLBACK(src, PROC_REF(stop_embers)), 1) + +/obj/effect/temp_visual/cyberware_scorch_embers/proc/stop_embers() + if(particles) + particles.spawning = 0 + +/// One burst of embers off a Scorch cut. +/particles/embers/spark/cyberware_scorch + count = 8 + spawning = 8 + lifespan = 0.6 SECONDS + fade = 0.4 SECONDS + velocity = generator(GEN_CIRCLE, 2, 3, SQUARE_RAND) + gravity = list(0, -0.15) + +/// A landed Widowline swing: the wire lashes out to whatever it hit, a thin +/// line in the wire's own colour ([state]) held for half a second. It leaves +/// the hand at ([origin_offset_x], [origin_offset_y]) from the middle of the +/// user's tile, and draws at [beam_layer] (under the body for a hand behind it). +/proc/cyberware_monowire_lash_fx(mob/living/user, atom/target, origin_offset_x = 0, origin_offset_y = 0, state = "monowire_lash", beam_layer = ABOVE_ALL_MOB_LAYER) + if(QDELETED(user) || QDELETED(target) || get_turf(user) == get_turf(target)) + return + user.Beam(target, icon_state = state, icon = CYBERWARE_ANIM2_ICON, time = 0.5 SECONDS, beam_type = /obj/effect/ebeam/wire_line, override_origin_pixel_x = user.pixel_x + origin_offset_x, override_origin_pixel_y = user.pixel_y + origin_offset_y, layer = beam_layer) + +/** + * The Arc's shock: a small crackle where the wire touched. No bolt, no flash, no sparks thrown about: the lash out to + * the target is the wire (wire_lash_at()). On a body it crackles at the part the wire cut (`zone`, else the middle); + * a body nearer the viewer than the wielder is touched on its far side, so it crackles behind that body. + */ +/proc/cyberware_arc_crackle_fx(mob/living/user, atom/target, zone) + if(QDELETED(user) || QDELETED(target)) + return + var/turf/there = get_turf(target) + var/turf/here = get_turf(user) + if(!there || !here) + return + var/obj/effect/temp_visual/cyberware_arc_crackle/crackle = new(there) + var/list/point = list(target.pixel_x, target.pixel_y) + if(isliving(target)) + point = wire_zone_point(target, zone || BODY_ZONE_CHEST) + // A visual shift only (pixel_w/pixel_z): it stays on the target's tile in the map's front-to-back order. + crackle.pixel_w = point[1] + crackle.pixel_z = point[2] + if(there.y < here.y && isliving(target)) + crackle.layer = BELOW_MOB_LAYER + +/obj/effect/temp_visual/cyberware_arc_crackle + icon = CYBERWARE_ANIM2_ICON + icon_state = "arc_crackle" + layer = ABOVE_MOB_LAYER + randomdir = FALSE + duration = 0.3 SECONDS + +/obj/effect/temp_visual/cyberware_arc_crackle/Initialize(mapload) + . = ..() + add_overlay(emissive_appearance(icon, icon_state, src)) + +// ========================================================================= +// BROWNOUT +// ========================================================================= + +/// Step between the frames of a brownout stutter. +#define BROWNOUT_STEP (0.1 SECONDS) + +/** + * The brownout picture for one bearer: every worn piece stutters, warms and + * dims together on the way down, and stutters back on on the way up. The + * brownout itself has already happened; this only plays the picture, and + * clearing it at any point leaves each piece drawn as its state says. + */ +/datum/component/chrome_brownout_show + dupe_mode = COMPONENT_DUPE_UNIQUE + /// Looks still to play, in order. + var/list/steps + /// Timer for the next look. + var/step_timer + /// Pieces whose look this show has set. + var/list/datum/weakref/touched = list() + +/datum/component/chrome_brownout_show/Initialize() + if(!iscarbon(parent)) + return COMPONENT_INCOMPATIBLE + +/datum/component/chrome_brownout_show/RegisterWithParent() + RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(on_death)) + +/datum/component/chrome_brownout_show/UnregisterFromParent() + UnregisterSignal(parent, COMSIG_LIVING_DEATH) + +/datum/component/chrome_brownout_show/Destroy() + if(step_timer) + deltimer(step_timer) + step_timer = null + var/changed = FALSE + for(var/datum/weakref/piece_ref as anything in touched) + var/obj/item/organ/piece = piece_ref.resolve() + var/datum/component/cyberware/chrome = piece?.GetComponent(/datum/component/cyberware) + if(chrome?.brownout_look) + chrome.brownout_look = null + changed = TRUE + touched.Cut() + var/mob/living/carbon/bearer = parent + if(changed && !QDELETED(bearer)) + bearer.update_body_parts() + return ..() + +/datum/component/chrome_brownout_show/proc/on_death(datum/source) + SIGNAL_HANDLER + qdel(src) + +/// Starts the stutter: down when [tripped], back up otherwise. +/datum/component/chrome_brownout_show/proc/play(tripped) + if(tripped) + steps = list(CHROME_LOOK_WARM, CHROME_LOOK_BROWN, CHROME_LOOK_WARM, CHROME_LOOK_BROWN, CHROME_LOOK_BROWN, CHROME_LOOK_WARM, CHROME_LOOK_BROWN) + else + steps = list(CHROME_LOOK_BROWN, CHROME_LOOK_WARM, CHROME_LOOK_BROWN, CHROME_LOOK_BROWN, CHROME_LOOK_WARM, CHROME_LOOK_BROWN) + if(step_timer) + deltimer(step_timer) + step_timer = null + advance() + +/datum/component/chrome_brownout_show/proc/advance() + step_timer = null + if(!length(steps)) + qdel(src) + return + var/look = popleft(steps) + var/mob/living/carbon/bearer = parent + for(var/obj/item/organ/piece as anything in get_installed_cyberware(bearer)) + var/obj/item/organ/cyberimp/implant = piece + if(!istype(implant) || !implant.bodypart_aug) + continue + var/datum/component/cyberware/chrome = piece.GetComponent(/datum/component/cyberware) + if(!chrome) + continue + chrome.brownout_look = look + touched |= WEAKREF(piece) + bearer.update_body_parts() + step_timer = addtimer(CALLBACK(src, PROC_REF(advance)), BROWNOUT_STEP, TIMER_STOPPABLE) + +/// Hook for the brownout monitor: [bearer]'s chrome just went down ([tripped]) or came back. +/proc/cyberware_brownout_fx(mob/living/carbon/bearer, tripped) + if(!iscarbon(bearer) || QDELETED(bearer)) + return + if(bearer.stat == DEAD) + // No show on a corpse: just draw it as it is. + bearer.update_body_parts() + return + var/datum/component/chrome_brownout_show/show = bearer.GetComponent(/datum/component/chrome_brownout_show) || bearer.AddComponent(/datum/component/chrome_brownout_show) + show?.play(tripped) + +#undef BROWNOUT_STEP + +// ========================================================================= +// CHROME CRADLE RIG +// ========================================================================= + +/// Layers on the cradle: the rig over the ware, both over the patient. +#define RIG_LAYER (ABOVE_MOB_LAYER + 0.02) +#define RIG_WARE_LAYER (ABOVE_MOB_LAYER + 0.01) +/// The gripper's tip, as pixel offsets of the carried ware's centre on the cradle tile: +/// tucked in the rig's head, then down on the patient's chest. Matches the rig sheet's gripper. +#define RIG_WARE_X 1 +#define RIG_WARE_PARKED_Y 21 +#define RIG_WARE_WORK_Y -4 +/// How long each move of the rig takes, matching its art. +#define RIG_GRIP_TIME (0.6 SECONDS) +#define RIG_PRESS_TIME (0.4 SECONDS) +#define RIG_RETRACT_TIME (0.3 SECONDS) + +/obj/machinery/chrome_cradle + /// The rig's current move, or null while it is parked. + var/rig_phase + /// The rig drawing that move. + var/datum/weakref/rig_ref + /// The ware in the gripper. + var/datum/weakref/rig_ware_ref + /// Timer that parks the rig once it has pulled back. + var/rig_park_timer + +/obj/machinery/chrome_cradle/update_overlays() + . = ..() + // The plinth and mast the rig stands on, behind the slab and under the patient. + var/mutable_appearance/frame = mutable_appearance(CHROME_CRADLE_RIG_ICON, "frame", layer - 0.01) + frame.pixel_x = -16 + frame.pixel_y = -16 + . += frame + if(rig_phase) + return + // The parked rig, over whoever lies on the slab. + var/mutable_appearance/rig = mutable_appearance(CHROME_CRADLE_RIG_ICON, "rig", RIG_LAYER) + rig.pixel_x = -16 + rig.pixel_y = -16 + . += rig + var/mutable_appearance/rig_glow = emissive_appearance(CHROME_CRADLE_RIG_ICON, "rig_e", src, RIG_LAYER) + rig_glow.pixel_x = -16 + rig_glow.pixel_y = -16 + . += rig_glow + +/// Plays one move of the rig: [phase] is a state of the rig sheet without its "rig_". +/obj/machinery/chrome_cradle/proc/play_rig(phase) + if(rig_park_timer) + deltimer(rig_park_timer) + rig_park_timer = null + qdel(rig_ref?.resolve()) + var/was_parked = isnull(rig_phase) + rig_phase = phase + if(was_parked) + update_appearance(UPDATE_OVERLAYS) + var/state = "rig_[phase]" + var/obj/effect/abstract/cyberware_anim/rig = cyberware_anim_play(src, CHROME_CRADLE_RIG_ICON, state, RIG_LAYER, CYBERWARE_INSTALL_TIME + 1 SECONDS) + if(!rig) + return + rig.pixel_x = -16 + rig.pixel_y = -16 + rig.add_overlay(emissive_appearance(CHROME_CRADLE_RIG_ICON, "[state]_e", src)) + rig_ref = WEAKREF(rig) + +/// A servo beat of the install: the arms come down, the gripper brings the ware, then presses it in. +/obj/machinery/chrome_cradle/proc/rig_beat(mid_stage) + if(busy_action != "install") + return + if(mid_stage) + play_rig("press") + var/obj/effect/abstract/cyberware_anim/carried = rig_ware_ref?.resolve() + if(carried) + animate(carried, pixel_y = RIG_WARE_WORK_Y - 3, transform = matrix().Scale(0.2), alpha = 0, time = RIG_PRESS_TIME, easing = QUAD_EASING | EASE_IN) + return + if(isnull(rig_phase) || rig_phase == "retract") + play_rig("arms_down") + return + play_rig("grip_down") + qdel(rig_ware_ref?.resolve()) + if(QDELETED(busy_ware)) + return + var/obj/effect/abstract/cyberware_anim/carried = cyberware_anim_play(src, busy_ware.icon, busy_ware.icon_state, RIG_WARE_LAYER, CYBERWARE_INSTALL_TIME) + if(!carried) + return + carried.transform = matrix().Scale(0.45) + carried.pixel_x = RIG_WARE_X + carried.pixel_y = RIG_WARE_PARKED_Y + // It comes out of the head: unseen at first, in view as it clears the pod. + carried.alpha = 0 + animate(carried, pixel_y = RIG_WARE_WORK_Y, time = RIG_GRIP_TIME, easing = CUBIC_EASING | EASE_OUT) + animate(carried, alpha = 255, time = 0.1 SECONDS, flags = ANIMATION_PARALLEL) + rig_ware_ref = WEAKREF(carried) + +/// The sequence is over, done or not: the rig pulls back and parks. +/obj/machinery/chrome_cradle/proc/rig_stop() + qdel(rig_ware_ref?.resolve()) + rig_ware_ref = null + if(isnull(rig_phase) || rig_phase == "retract") + return + play_rig("retract") + rig_park_timer = addtimer(CALLBACK(src, PROC_REF(park_rig)), RIG_RETRACT_TIME, TIMER_STOPPABLE) + +/obj/machinery/chrome_cradle/proc/park_rig() + rig_park_timer = null + qdel(rig_ref?.resolve()) + rig_ref = null + rig_phase = null + update_appearance(UPDATE_OVERLAYS) + +/// The ware boots in its new owner: a glitch runs over them. +/obj/machinery/chrome_cradle/proc/rig_boot_fx(mob/living/carbon/patient) + cyberware_glitch_fx(patient, 0.2 SECONDS, flash = TRUE, inset = TRUE) + +#undef RIG_LAYER +#undef RIG_WARE_LAYER +#undef RIG_WARE_X +#undef RIG_WARE_PARKED_Y +#undef RIG_WARE_WORK_Y +#undef RIG_GRIP_TIME +#undef RIG_PRESS_TIME +#undef RIG_RETRACT_TIME + +#undef CYBERWARE_LEAP_LAYER +#undef CYBERWARE_LEAP_SLAM +#undef CYBERWARE_ANIM2_ICON +#undef CYBERWARE_ANIM2_LARGE_ICON +#undef CHROME_CRADLE_RIG_ICON +#undef CHROME_ANIM2_TOP_LAYER +#undef CHROME_LOOK_BROWN +#undef CHROME_LOOK_WARM diff --git a/voidcrew/modules/cyberware/cyberware_base.dm b/voidcrew/modules/cyberware/cyberware_base.dm index 367f077f491..0836cb99609 100644 --- a/voidcrew/modules/cyberware/cyberware_base.dm +++ b/voidcrew/modules/cyberware/cyberware_base.dm @@ -20,38 +20,88 @@ * (autosurgeon.dm's "insertion failed!" path). */ /** - * The worn-chrome overlay: tg's augment overlay, drawn one notch higher. - * Stock augments sit at BODY_ADJ_LAYER, which the character-setup underwear - * layer paints over, a bra would cover a Cascade spine rig. Chrome instead - * draws at CYBERWARE_WORN_LAYER: over underwear and undershirts, still under - * eyes, damage, and every EQUIPPED clothing layer. One override covers the - * images, the emissive twins and the emissive blockers alike, because they - * all take their layer from bitflag_to_layer(). + * The worn-chrome overlay: tg's augment overlay, drawn higher. Stock augments + * sit at BODY_ADJ_LAYER, under underwear and every piece of clothing. Chrome + * draws at CYBERWARE_WORN_LAYER instead: over the jumpsuit, still under hands, + * gloves, shoes and suits. One override covers the images, the emissive twins + * and the emissive blockers alike, because they all take their layer from + * bitflag_to_layer(). + * + * Plating grown into the skin (worn_under_clothes) is skin: it stays where + * stock augments sit, under everything that is worn. */ /datum/bodypart_overlay/augment/cyberware /datum/bodypart_overlay/augment/cyberware/bitflag_to_layer(layer) if(layer == EXTERNAL_ADJACENT) + var/obj/item/organ/cyberimp/cyberware/ware = implant + if(istype(ware) && ware.worn_under_clothes) + return ..() return -CYBERWARE_WORN_LAYER return ..() +// Arm hardware whose worn sprite draws the folded item (the Mantis line) is not +// drawn while that item is out in a hand. Hiding here also drops the overlay from +// the limb's icon key, so update_body_parts() redraws the arm on the flip. +/datum/bodypart_overlay/augment/cyberware/can_draw_on_bodypart(obj/item/bodypart/bodypart_owner) + // A bearer being deleted can lose its chrome before its clothes, and taking + // the clothes off redraws the limbs while this overlay is still on them. + if(!implant) + return FALSE + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = implant + if(istype(arm_ware) && arm_ware.worn_overlay_hidden()) + return FALSE + return ..() + +/** + * The parent puts an emissive blocker over every image it draws, the glow + * included. Same layer, later in the list, so a Cascade or Redline would black + * out its own glow. Glows skip the blocker and go last, after every blocker of + * this overlay, the same order tg's worn clothing uses. + */ +/datum/bodypart_overlay/augment/cyberware/get_overlay(layer, obj/item/bodypart/limb) + layer = bitflag_to_layer(layer) + var/list/imageset = implant.get_overlay(layer, limb) + // EMP static, dark and blink looks, the folding housing, the spine nodes (cyberware_anim.dm). + imageset = implant.cyberware_dress_worn(imageset, layer, limb) + if(blocks_emissive == EMISSIVE_BLOCK_NONE || !limb) + return imageset + + var/list/all_images = list() + var/list/glows = list() + for(var/image/overlay as anything in imageset) + if(PLANE_TO_TRUE(overlay.plane) == EMISSIVE_PLANE) + glows += overlay + continue + all_images += overlay + all_images += emissive_blocker(overlay.icon, overlay.icon_state, limb, layer = overlay.layer, alpha = overlay.alpha) + return all_images + glows + +/// The animation look is part of the limb's render key, so changing it redraws the limb. +/datum/bodypart_overlay/augment/cyberware/generate_icon_cache() + . = ..() + if(implant) + . += implant.cyberware_worn_key() + /obj/item/organ/cyberimp/cyberware name = "cyberware" desc = "Aftermarket chrome. Someone sat in a parlor chair for this." icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' // Worn look: ware that reads from outside the body sets aug_overlay to a // state in this sheet and tg's bodypart-overlay pipeline draws it ON the - // bearer, over the character-setup underwear, under equipped clothing. + // bearer, over the jumpsuit, under suits and armour. // Stack enough chrome and you stop looking human. aug_icon = 'voidcrew/modules/cyberware/icons/cyberware_worn.dmi' organ_flags = ORGAN_ROBOTIC - failing_desc = "is dark and inert, browned out, EMP-scrambled, or plain broken." + failing_desc = "is dark and inert." /// Neural load this ware puts on its bearer. 0-12; see the tier bands. var/chrome_load = 1 /// CYBERWARE_TIER_*, drives accent colours and the parlor experience. var/tier = CYBERWARE_TIER_1 /// Chrome capacity this ware grants while installed (the Governor hook). var/chrome_capacity_bonus = 0 + /// TRUE for ware that is part of the skin: its worn look draws under clothes, not over the jumpsuit. + var/worn_under_clothes = FALSE /obj/item/organ/cyberimp/cyberware/Initialize(mapload) . = ..() @@ -121,11 +171,17 @@ * Every optic on this base carries the chrome read (cyberware_scan.dm), the * diagnostic bus is what makes chrome eyes chrome eyes. Subtypes that add * their own ability must keep the read in their actions_types list. + * + * Every optic also zooms (cyberware_zoom.dm). That button is added in + * Initialize() whenever optics_zoom is above 0, so it never goes in + * actions_types. */ /obj/item/organ/eyes/robotic/cyberware name = "cyberware optics" desc = "Aftermarket eyes. The irises catch the light in a way real ones don't." icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' + // The base is never sold; it borrows the plainest optics' sprite so it has one. + icon_state = "nightshade" actions_types = list(/datum/action/cooldown/cyberware/chrome_read) /// Neural load this ware puts on its bearer. var/chrome_load = 1 @@ -140,6 +196,8 @@ /obj/item/organ/eyes/robotic/cyberware/Initialize(mapload) . = ..() AddComponent(/datum/component/cyberware, chrome_load, tier, chrome_capacity_bonus) + // Zoom rides every optic on this base (cyberware_zoom.dm). + setup_optics_zoom() /obj/item/organ/eyes/robotic/cyberware/Destroy() var/turf/drop_turf = get_turf(src) @@ -198,6 +256,8 @@ name = "arm cyberware" desc = "Aftermarket arm hardware. Folds away until you want it." icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' + // The base is never sold; it borrows a plain arm housing's sprite so it has one. + icon_state = "fixers" // Worn look (see the cyberware base above): the arm pipeline derives // "[aug_overlay]_left/_right" from the installed zone on its own. No // separate hand states in our sheet, so the hand overlay stays off. @@ -209,6 +269,9 @@ var/tier = CYBERWARE_TIER_1 /// Chrome capacity this ware grants while installed. var/chrome_capacity_bonus = 0 + /// TRUE when the worn sprite draws the deployable folded into its housing + /// (the Mantis line). The worn overlay hides while that item is out in a hand. + var/hide_worn_while_deployed = FALSE /obj/item/organ/cyberimp/arm/toolkit/cyberware/Initialize(mapload) . = ..() @@ -241,6 +304,12 @@ if(!special) cyberware_boot_splash(arm_owner, src) +// tg's arm implants register these two on the bearer and never let go on removal, so a +// housing sold on or reinstalled elsewhere kept answering to the body it was pulled from. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/on_mob_remove(mob/living/carbon/arm_owner, special = FALSE, movement_flags) + . = ..() + UnregisterSignal(arm_owner, list(COMSIG_CARBON_POST_ATTACH_LIMB, COMSIG_KB_MOB_DROPITEM_DOWN)) + // Deploying and stowing arm hardware is the most visible thing a piece of // chrome does, so it is also the ink's most common cue: every toolkit arm // (Fixer's Fingers picking a tool off the radial, the Rockjaw drill, blades, @@ -254,12 +323,39 @@ // (augments_arms.dm), so "did it deploy" is "did it leave us", not "is it set". if(active_item && !(active_item in src)) cyberware_ink_pulse(owner, CYBERWARE_INK_HARD) + if(hide_worn_while_deployed) + // Any way out of the hand that isn't Retract() (a forced drop, a + // deleted blade) must put the folded sprite back as well. + RegisterSignal(active_item, COMSIG_ITEM_DROPPED, PROC_REF(on_deployed_item_dropped), override = TRUE) + play_blade_unfold(active_item) + owner.update_body_parts() /obj/item/organ/cyberimp/arm/toolkit/cyberware/Retract() var/mob/living/carbon/stowing_owner = owner + var/obj/item/stowing = active_item + // Only a blade coming out of the hand folds back in; one picked off the floor just stows. + var/was_held = stowing && stowing_owner?.is_holding(stowing) . = ..() if(.) cyberware_ink_pulse(stowing_owner, CYBERWARE_INK_SOFT) + if(hide_worn_while_deployed) + UnregisterSignal(stowing, COMSIG_ITEM_DROPPED) + if(was_held && owner) + play_blade_fold() + stowing_owner?.update_body_parts() + +/// TRUE while the worn overlay should not draw: this hardware's worn sprite +/// shows its item folded away, and that item is out in the bearer's hand. +/// Stowed, dropped, deleted or with no bearer, the overlay draws. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/worn_overlay_hidden() + return hide_worn_while_deployed && owner && active_item && owner.is_holding(active_item) + +/// Signal proc for [COMSIG_ITEM_DROPPED] on a deployed item whose folded sprite +/// is part of the worn overlay. Redraws the arm so the housing shows again. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/proc/on_deployed_item_dropped(obj/item/source, mob/user) + SIGNAL_HANDLER + UnregisterSignal(source, COMSIG_ITEM_DROPPED) + owner?.update_body_parts() /obj/item/organ/cyberimp/arm/toolkit/cyberware/emp_act(severity) . = ..() // toolkit's own EMP retract fires first @@ -296,12 +392,23 @@ /proc/cyberware_insert_check(obj/item/organ/ware, mob/living/carbon/target, silent = FALSE, mob/feedback_to) if(!iscarbon(target)) return FALSE + if(!cyberware_has_limb(ware, target, silent)) + return FALSE if(installed_capacity_check(target, list(ware), ware.cyberware_get_incumbents(target), silent)) return TRUE if(!silent && feedback_to && feedback_to != target) feedback_to.balloon_alert(feedback_to, "no neural headroom!") return FALSE +/// Whether the body still has the limb this ware lives in. Chrome cannot go into a limb that +/// is gone: the insert would seat it on a body with nothing to hold it. +/proc/cyberware_has_limb(obj/item/organ/ware, mob/living/carbon/target, silent = FALSE) + if(target.get_bodypart(deprecise_zone(ware.zone))) + return TRUE + if(!silent) + target.balloon_alert(target, "no limb for it!") + return FALSE + /** * Full gate for a live (non-special) Insert(): a legit install context must * be open for this receiver, and the netted capacity must fit. The context @@ -321,6 +428,9 @@ receiver.balloon_alert(receiver, "needs a real rig!") to_chat(receiver, span_warning("The autosurgeon chokes. This needs a real rig.")) return FALSE + // Even a forced window cannot seat chrome in a limb that is not there. + if(!cyberware_has_limb(ware, receiver)) + return FALSE if(!chrome.install_context_forced && !cyberware_insert_check(ware, receiver)) return FALSE chrome.clear_install_context() @@ -450,6 +560,65 @@ return FALSE return TRUE +/** + * A click made with a chrome ability armed belongs to the chrome, refused or + * not. tg's version returns FALSE on a refusal, and ClickOn() then carries on + * as an ordinary click: a held gun fires at whoever was out of reach, an empty + * hand punches whoever the ability would not take. So an armed ability takes + * the one click it is handed, and only that one. + * + * Chrome abilities have no button of their own to click off (chrome_hud.dm), + * so the aim must never outlive the click. A refusal (wrong target, out of + * reach, no line of sight) disarms: the ability's own balloon says why, and + * the next click is an ordinary one. A right-click disarms without trying. A + * button that has gone dark since it was armed (EMP, cooldown started + * elsewhere, stun) disarms too. None of these touch the cooldown. + * + * Only for a real click on an armed ability. Trigger() with a target (AI and + * scripted callers) pass through unchanged. + */ +/datum/action/cooldown/cyberware/InterceptClickOn(mob/living/clicker, params, atom/target) + var/armed = !isnull(clicker) && clicker.click_intercept == src + if(!armed) + return ..() + // The click is the player acting, so the idle drop no longer applies (a channel can outlast it). + stop_timer() + if(params && LAZYACCESS(params2list(params), RIGHT_CLICK)) + unset_click_ability(clicker, refund_cooldown = TRUE) + return TRUE + if(!IsAvailable(feedback = TRUE)) + unset_click_ability(clicker, refund_cooldown = TRUE) + return TRUE + if(..()) + return TRUE + // Refused. Only drop our own aim: a channel that slept may have let another ability arm meanwhile. + if(clicker.click_intercept == src) + unset_click_ability(clicker, refund_cooldown = TRUE) + return TRUE + +/// The timer that drops an aim left waiting. (Names reused on purpose: the CI build sits at DM's identifier limit.) +/datum/action/cooldown/cyberware/var/timeout_timer + +/datum/action/cooldown/cyberware/set_click_ability(mob/on_who) + . = ..() + stop_timer() + timeout_timer = addtimer(CALLBACK(src, PROC_REF(on_timeout)), 10 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/datum/action/cooldown/cyberware/unset_click_ability(mob/on_who, refund_cooldown = TRUE) + stop_timer() + return ..() + +/datum/action/cooldown/cyberware/proc/stop_timer() + if(timeout_timer) + deltimer(timeout_timer) + timeout_timer = null + +/// Armed and never clicked: the aim drops, cooldown untouched. +/datum/action/cooldown/cyberware/proc/on_timeout() + timeout_timer = null + if(owner?.click_intercept == src) + unset_click_ability(owner, refund_cooldown = TRUE) + /** * Is there a clear arc from [here] to [destination]? Shared by every leg * ware that throws its owner through the air: Hopper Pistons, Meteor diff --git a/voidcrew/modules/cyberware/cyberware_component.dm b/voidcrew/modules/cyberware/cyberware_component.dm index ef1b1480118..e7f79a889ef 100644 --- a/voidcrew/modules/cyberware/cyberware_component.dm +++ b/voidcrew/modules/cyberware/cyberware_component.dm @@ -66,6 +66,8 @@ if(emp_timer) deltimer(emp_timer) emp_timer = null + var/obj/item/organ/ware = parent + ware?.cyberware_anim_clear() install_context_ref = null install_context_forced = FALSE return ..() @@ -101,6 +103,8 @@ settle_passives(old_owner) set_browned_out(FALSE) cyberware_reevaluate_brownout(old_owner) + var/obj/item/organ/ware = parent + ware.cyberware_anim_clear(old_owner) /// Signal proc for [COMSIG_CARBON_GAIN_ORGAN] and [COMSIG_CARBON_LOSE_ORGAN] /// on the bearer. Every installed ware listens with its own component, so a @@ -131,6 +135,8 @@ if(emp_timer) deltimer(emp_timer) emp_timer = addtimer(CALLBACK(src, PROC_REF(finish_emp_reboot)), CYBERWARE_EMP_DOWNTIME / max(severity, 1), TIMER_STOPPABLE) + // Static, arcs, then dark (cyberware_anim.dm). Only the picture staggers. + cyberware_emp_hit_fx(parent) /datum/component/cyberware/proc/finish_emp_reboot() emp_timer = null @@ -141,6 +147,9 @@ var/obj/item/organ/ware = parent if(ware.owner && !(ware.organ_flags & ORGAN_FAILING)) ware.owner.balloon_alert(ware.owner, "[ware.name] back online") + cyberware_emp_reboot_fx(ware) + else + ware.owner?.update_body_parts() /// Cradle tune-up: cancels any pending EMP reboot and repairs the organ /// outright. Cannot fix a brownout, that is a load problem, not damage. @@ -149,9 +158,11 @@ deltimer(emp_timer) emp_timer = null emp_down = FALSE + emp_look = null var/obj/item/organ/ware = parent ware.set_organ_damage(0) update_failing() + ware.owner?.update_body_parts() /// Settles ORGAN_FAILING from our two failure sources. Careful not to clear /// a failure earned through organ damage: only lift the flag while the organ @@ -415,6 +426,9 @@ GLOBAL_LIST_INIT(installed_capacity_costs, list( newly_tripped = TRUE else any_recovered = TRUE + if(newly_tripped || any_recovered) + // Worn chrome stutters down or back up (cyberware_anim2.dm). + cyberware_brownout_fx(target, newly_tripped) if(newly_tripped) target.balloon_alert(target, "chrome brownout!") to_chat(target, span_boldwarning("Your chrome goes dark.")) diff --git a/voidcrew/modules/cyberware/cyberware_scan.dm b/voidcrew/modules/cyberware/cyberware_scan.dm index 8a7b1c3315e..05dc2b89ae7 100644 --- a/voidcrew/modules/cyberware/cyberware_scan.dm +++ b/voidcrew/modules/cyberware/cyberware_scan.dm @@ -22,6 +22,11 @@ * - Resolution belongs to the optics, not to the reader: the street-tier * Nightshade counts signatures, everything above it names them. * + * The reader sees the result drawn over the subject, for their eyes only + * (cyberware_scan_overlay.dm). Nothing goes to their chat. Bystanders see the + * reader's eyes flicker; the subject sees their own body flinch red and gets + * the chat line naming the reader. + * * The action rides the shared /datum/action/cooldown/cyberware bridge, so a * browned-out or EMP-scrambled set of eyes reads nothing at all. */ @@ -33,6 +38,14 @@ /// robotic that isn't parlor chrome. #define CYBERWARE_SCAN_UNRATED_COLOR "#8fa1a8" +// Reach and pacing belong to the optics, so a scout model can read further or +// faster. The defaults are the read's stock numbers. +/obj/item/organ/eyes/robotic/cyberware + /// How far this set of eyes can read a body, in tiles, with line of sight. + var/chrome_read_range = CYBERWARE_SCAN_RANGE + /// Cooldown on this set of eyes' chrome read. + var/chrome_read_cooldown = CYBERWARE_SCAN_COOLDOWN + // ---- Readout ----------------------------------------------------------- /** @@ -64,41 +77,90 @@ return "[text]" /** - * Builds the report for a body at the given resolution and hands back the - * styled lines. Split out from the action so the Cradle, an admin tool or a - * unit test can ask the same question without a pair of eyes involved. + * The short name a readout shows for one piece of hardware: no \improper, + * and no "(left)" or "(right)" on paired arm chrome. */ -/proc/cyberware_scan_readout(mob/living/carbon/target, resolution = CYBERWARE_SCAN_ITEMIZED) +/proc/cyberware_scan_label(obj/item/organ/ware) + var/static/regex/side_suffix = regex(@"\s*\((left|right)\)$", "i") + return side_suffix.Replace(format_text(ware.name), "") + +/** + * What a read resolves on a body, as data. The overlay + * (cyberware_scan_overlay.dm) draws it and cyberware_scan_readout() prints it, + * so both agree on what the bus can and can't see. + * + * Returns an associative list: `name` (the visible name), `count`, `load`, + * `capacity`, `resolution` and `entries`, one list per signature in organ + * order. At itemized resolution an entry carries `label`, `name`, `icon`, + * `icon_state`, `color`, `tier` (0 when unrated), `rated` and `offline`. At + * silhouette resolution entries are empty: the bus counts them and nothing + * else. + */ +/proc/cyberware_scan_report(mob/living/carbon/target, resolution = CYBERWARE_SCAN_ITEMIZED) RETURN_TYPE(/list) - . = list() if(!iscarbon(target)) - return - var/accent = CYBERWARE_COLOR_TIER_2 + return null // Masks and helmets beat the bus: a body reads as whatever it looks like. var/subject = target.name if(ishuman(target)) var/mob/living/carbon/human/human_target = target subject = human_target.get_visible_name() - . += cyberware_scan_line("CHROME READ: [uppertext(subject)]", accent) var/list/found = cyberware_scannable_hardware(target) - if(!length(found)) + var/list/entries = list() + for(var/obj/item/organ/ware as anything in found) + if(resolution < CYBERWARE_SCAN_ITEMIZED) + entries += list(list()) + continue + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + entries += list(list( + "label" = cyberware_scan_label(ware), + "name" = ware.name, + "icon" = ware.icon, + "icon_state" = ware.icon_state, + // Anything that isn't parlor chrome has no tier to report. + "color" = chrome ? cyberware_tier_color(chrome.tier) : CYBERWARE_SCAN_UNRATED_COLOR, + "tier" = chrome ? chrome.tier : 0, + "rated" = !!chrome, + "offline" = !!(ware.organ_flags & ORGAN_FAILING), + )) + return list( + "name" = subject, + "count" = length(found), + "load" = get_chrome_load(target), + "capacity" = get_chrome_capacity(target), + "resolution" = resolution, + "entries" = entries, + ) + +/** + * Builds the report for a body at the given resolution and hands back the + * styled lines. Split out from the action so the Cradle, an admin tool or a + * unit test can ask the same question without a pair of eyes involved. + */ +/proc/cyberware_scan_readout(mob/living/carbon/target, resolution = CYBERWARE_SCAN_ITEMIZED) + RETURN_TYPE(/list) + . = list() + var/list/report = cyberware_scan_report(target, resolution) + if(!report) + return + var/accent = CYBERWARE_COLOR_TIER_2 + . += cyberware_scan_line("CHROME READ: [uppertext(report["name"])]", accent) + + if(!report["count"]) . += cyberware_scan_line("NO HARDWARE SIGNATURE", accent) return - var/load = get_chrome_load(target) - var/capacity = get_chrome_capacity(target) - . += cyberware_scan_line("SIGNATURES [length(found)] · NEURAL LOAD [load]/[capacity]", accent) + var/load = report["load"] + var/capacity = report["capacity"] + . += cyberware_scan_line("SIGNATURES [report["count"]] · NEURAL LOAD [load]/[capacity]", accent) if(resolution < CYBERWARE_SCAN_ITEMIZED) . += cyberware_scan_line("BUS RESOLUTION TOO LOW: IDENTITIES UNRESOLVED", accent) else - for(var/obj/item/organ/ware as anything in found) - var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) - var/status = (ware.organ_flags & ORGAN_FAILING) ? " · OFFLINE" : "" - // Anything that isn't parlor chrome has no tier to report. - var/rating = chrome ? "T[chrome.tier]" : "UNRATED" - var/line_color = chrome ? cyberware_tier_color(chrome.tier) : CYBERWARE_SCAN_UNRATED_COLOR - . += cyberware_scan_line("» [uppertext(ware.name)] · [rating][status]", line_color) + for(var/list/entry as anything in report["entries"]) + var/status = entry["offline"] ? " · OFFLINE" : "" + var/rating = entry["rated"] ? (list("STREET", "PRO", "MILITARY", "LEGEND")[clamp(entry["tier"], 1, 4)]) : "UNRATED" + . += cyberware_scan_line("» [uppertext(entry["name"])] · [rating][status]", entry["color"]) if(load > capacity) . += cyberware_scan_line("LOAD OVER CEILING: SUBJECT BROWNED OUT", CYBERWARE_COLOR_TIER_3) @@ -106,12 +168,41 @@ /datum/action/cooldown/cyberware/chrome_read name = "Chrome Read" - desc = "Read a body's hardware bus: what's installed, what tier it is, and how loaded their nervous system is. They'll feel you do it." + desc = "Read the chrome in a body you can see. They'll feel you do it." button_icon = 'icons/mob/actions/actions_items.dmi' button_icon_state = "scan" ranged_mousepointer = 'icons/effects/mouse_pointers/scan_target.dmi' cooldown_time = CYBERWARE_SCAN_COOLDOWN click_to_activate = TRUE + /// The readout this read is drawing for our bearer. A new read replaces it. + var/datum/chrome_readout/current_readout + +/datum/action/cooldown/cyberware/chrome_read/New(Target, original = TRUE) + . = ..() + var/obj/item/organ/eyes/robotic/cyberware/optics = organ + if(istype(optics)) + cooldown_time = optics.chrome_read_cooldown + +/datum/action/cooldown/cyberware/chrome_read/Destroy() + QDEL_NULL(current_readout) + return ..() + +/// Swaps whatever we were showing for a fresh readout. A null report draws +/// the scatter. +/datum/action/cooldown/cyberware/chrome_read/proc/show_readout(mob/living/carbon/bearer, mob/living/carbon/subject, list/report) + QDEL_NULL(current_readout) + var/datum/chrome_readout/readout = new(bearer, subject, report, organ) + if(QDELETED(readout)) + return + current_readout = readout + RegisterSignal(readout, COMSIG_QDELETING, PROC_REF(on_readout_deleted)) + +/// Signal proc for [COMSIG_QDELETING] on our readout: it ended on its own +/// (expired, target gone, bearer logged out), so stop holding it. +/datum/action/cooldown/cyberware/chrome_read/proc/on_readout_deleted(datum/source) + SIGNAL_HANDLER + if(source == current_readout) + current_readout = null /datum/action/cooldown/cyberware/chrome_read/Activate(atom/target) var/obj/item/organ/eyes/robotic/cyberware/optics = organ @@ -128,36 +219,44 @@ if(bearer.is_blind()) bearer.balloon_alert(bearer, "optics dark!") return FALSE - if(!self_read && !can_see(bearer, subject, CYBERWARE_SCAN_RANGE)) + if(!self_read && !can_see(bearer, subject, optics.chrome_read_range)) bearer.balloon_alert(bearer, "no line of sight!") return FALSE - // Ghostskin scatters the handshake the same way it scatters NPC targeting. + // Ghostskin scatters the handshake the same way it scatters NPC targeting: + // the readout breaks up and drops without a lock. if(HAS_TRAIT(subject, TRAIT_CYBER_CAMO)) - bearer.balloon_alert(bearer, "signature scatter!") - to_chat(bearer, cyberware_scan_line("CHROME READ: SIGNAL SCATTER, NO LOCK", CYBERWARE_COLOR_TIER_3)) + show_readout(bearer, subject, null) + if(!self_read) + chrome_read_eye_glint(bearer) playsound(bearer, 'sound/machines/terminal/terminal_error.ogg', 20, TRUE) StartCooldown() return TRUE - var/list/report = cyberware_scan_readout(subject, optics.chrome_scan_resolution) - to_chat(bearer, jointext(report, "
")) + // The read draws over the subject for the reader alone; nothing goes to chat. + var/list/report = cyberware_scan_report(subject, optics.chrome_scan_resolution) + show_readout(bearer, subject, report) playsound(bearer, 'sound/machines/terminal/terminal_processing.ogg', 20, TRUE) if(!self_read) // The tell: anyone close enough sees the readout scroll across the eyes. // The subject only sits that message out when they're getting the - // louder one below instead. - var/subject_feels_it = length(cyberware_scannable_hardware(subject)) + // louder one below instead. The reader never gets it: it's their eyes. + chrome_read_eye_glint(bearer) + var/subject_feels_it = report["count"] bearer.visible_message( span_notice("[bearer]'s irises flicker with a scrolling readout."), vision_distance = 3, - ignored_mobs = subject_feels_it ? list(subject) : null, + ignored_mobs = subject_feels_it ? list(subject, bearer) : list(bearer), ) - // The subject's own hardware reports the unauthorized handshake. + // The subject's own hardware reports the unauthorized handshake: it + // flinches on their screen, and their chat names the reader. if(subject_feels_it) - if(can_see(subject, bearer, CYBERWARE_SCAN_RANGE)) + chrome_read_flinch(subject) + if(can_see(subject, bearer, optics.chrome_read_range)) to_chat(subject, span_warning("[bearer] is reading your hardware. Every piece you have just answered a handshake you never authorized.")) else to_chat(subject, span_warning("Your hardware answers a handshake you never authorized. Someone nearby is reading you.")) + // Whoever is read can answer it: a bounty NPC turns and tells the reader off (voidcrew/modules/bounties/bounty_chrome.dm) + SEND_SIGNAL(subject, COMSIG_CARBON_CHROME_READ, bearer) StartCooldown() return TRUE diff --git a/voidcrew/modules/cyberware/cyberware_scan_overlay.dm b/voidcrew/modules/cyberware/cyberware_scan_overlay.dm new file mode 100644 index 00000000000..9881ce2c342 --- /dev/null +++ b/voidcrew/modules/cyberware/cyberware_scan_overlay.dm @@ -0,0 +1,890 @@ +/** + * # Chrome read overlay + * + * What a chrome read (cyberware_scan.dm) looks like to the reader. Corner + * brackets snap onto the subject and lock while a red outline of their body + * pulses inside them. Then a panel opens beside the subject: their visible + * name, one socket per piece of hardware framed in its tier colour, a short + * name list and a load bar. The outline fades, the panel holds, and the + * brackets release as the panel fades out. + * + * - Street optics (silhouette resolution) fill the sockets with static and + * name nothing. + * - A Ghostskin subject breaks the lock: the brackets hunt, the outline + * flickers into static, the header garbles and "NO LOCK" flashes before it + * all drops. That version stays where the lock was tried instead of + * following someone the optics can't hold. + * - A body with no hardware gets the header and "no chrome". + * + * Every image is a client image shown to the reader alone, on + * ABOVE_LIGHTING_PLANE: it draws over darkness, and a flash or blindfold still + * hides it because blindness lives on FULLSCREEN_PLANE above it. The images are + * parented to the SUBJECT, so they follow them without any server work and, + * just like the subject, are never drawn through a wall. That is on purpose: + * the read needs line of sight to start, and the readout must not turn into a + * free wallhack for its whole hold. (/datum/cyberware_hud_mark is the opposite + * case: it parks on the viewer's turf to draw THROUGH walls.) + * + * All motion is animate() on the reader's client. The server builds the + * images once and runs one timer. + */ + +/// Itemized optics on a body with hardware. +#define READOUT_ITEMIZED "itemized" +/// Street optics: counts and load, nothing named. +#define READOUT_SILHOUETTE "silhouette" +/// Ghostskin: the lock breaks. +#define READOUT_SCATTER "scatter" +/// Nothing on the bus. +#define READOUT_CLEAN "clean" + +// Timeline, in deciseconds from the click. +/// Brackets snap (0-3) and lock (3-7) while the outline pulses; the panel opens here. +#define READOUT_LOCK_TIME 8.5 +/// Header fade-in plus the panel unfolding. +#define READOUT_OPEN_TIME 4.5 +#define READOUT_HOLD_TIME 60 +#define READOUT_CLEAN_HOLD_TIME 30 +#define READOUT_FADE_TIME 6 +/// A scattered read drops at this point, without ever locking. +#define READOUT_SCATTER_DROP_AT 18 +#define READOUT_SCATTER_FADE_TIME 3 + +// Geometry, in pixels from the subject's tile origin (y up). +/// Left edge of a panel opening on the right. +#define READOUT_PANEL_X 37 +/// Top edge of the panel. +#define READOUT_PANEL_TOP 45 +#define READOUT_SOCKETS_PER_ROW 6 +#define READOUT_MAX_SOCKETS 18 +#define READOUT_MAX_NAME_LINES 8 +#define READOUT_MIN_WIDTH 108 +#define READOUT_MAX_WIDTH 160 +#define READOUT_BAR_SEGMENTS 20 +/// The socket icon is 32 px drawn into an 18 px socket. +#define READOUT_SOCKET_ICON_SCALE 0.5625 + +// Colours. +/// The HUD frame: brackets, panel border, leader line. +#define READOUT_HUD_COLOR CYBERWARE_COLOR_TIER_2 +/// The targeting outline. A deep crimson, kept apart from the brighter +/// red-orange of "offline" and the pink of tier 3. +#define READOUT_LOCK_COLOR "#f01d3a" +#define READOUT_LOCK_FILL_COLOR "#c8102a" +#define READOUT_PANEL_COLOR "#060e12" +#define READOUT_NAME_COLOR "#e6fbff" +#define READOUT_DIM_COLOR "#8fa1a8" +#define READOUT_OFFLINE_COLOR "#ff5a4a" +#define READOUT_OFFLINE_NAME_COLOR "#7d8a90" +#define READOUT_STATIC_FRAME_COLOR "#6c7c83" +#define READOUT_GLINT_COLOR "#e9feff" + +#define READOUT_ICON 'voidcrew/modules/cyberware/icons/chrome_read.dmi' +#define READOUT_BAR_ICON 'voidcrew/modules/cyberware/icons/chrome_read_bar.dmi' + +/datum/chrome_readout + /// The only person this is drawn for. + var/mob/living/viewer + /// The body being read. + var/mob/living/target + /// The optics doing the reading. Pulling them ends the readout. + var/obj/item/organ/optics + /// What the images hang off: the subject, or for a scatter the turf they + /// stood on when the lock failed. + var/atom/anchor + /// READOUT_* look. + var/mode + /// The cyberware_scan_report() being drawn. Null for a scatter. + var/list/report + /// Every image, in draw order. + var/list/image/images = list() + /// One image per socket drawn. + var/list/image/sockets = list() + /// One image per name line drawn, "and N more" included. + var/list/image/name_lines = list() + /// image -> list of what play() needs to animate it: its kind, start time, + /// role ("lock", "panel", "socket", "name", "load") and kind-specific data. + var/list/cues = list() + /// The client the images went to. Held because a mob that logged out has none. + var/client/shown_to + /// Expiry timer. + var/timer_id + /// Deciseconds from creation until everything starts fading, and how long that takes. + var/fade_at + var/fade_time + /// Whole lifetime, deciseconds. + var/lifetime + /// Panel geometry. + var/panel_x + var/panel_width + var/panel_height + /// TRUE when the panel opens on the subject's left: the reader is to their right, or the right has no room. + var/flipped = FALSE + /// Pixel offset every image carries. Zero on the subject; on a turf it lines + /// the scatter up with where the subject was drawn. + var/base_w = 0 + var/base_z = 0 + +/datum/chrome_readout/New(mob/living/new_viewer, mob/living/new_target, list/new_report, obj/item/organ/new_optics, animated = TRUE) + . = ..() + viewer = new_viewer + target = new_target + report = new_report + optics = new_optics + if(isnull(report)) + mode = READOUT_SCATTER + else if(!report["count"]) + mode = READOUT_CLEAN + else if(report["resolution"] < CYBERWARE_SCAN_ITEMIZED) + mode = READOUT_SILHOUETTE + else + mode = READOUT_ITEMIZED + + if(mode == READOUT_SCATTER) + anchor = get_turf(target) + base_w = target.pixel_x + target.pixel_w + base_z = target.pixel_y + target.pixel_z + else + anchor = target + if(isnull(anchor)) + qdel(src) + return + + RegisterSignals(target, list(COMSIG_QDELETING, COMSIG_MOVABLE_Z_CHANGED), PROC_REF(end_readout)) + RegisterSignal(viewer, COMSIG_MOB_LOGOUT, PROC_REF(end_readout)) + if(viewer != target) + RegisterSignal(viewer, COMSIG_QDELETING, PROC_REF(end_readout)) + if(optics) + RegisterSignals(optics, list(COMSIG_ORGAN_REMOVED, COMSIG_QDELETING), PROC_REF(end_readout)) + + switch(mode) + if(READOUT_SCATTER) + fade_at = READOUT_SCATTER_DROP_AT + fade_time = READOUT_SCATTER_FADE_TIME + if(READOUT_CLEAN) + fade_at = READOUT_LOCK_TIME + READOUT_OPEN_TIME + READOUT_CLEAN_HOLD_TIME + fade_time = READOUT_FADE_TIME + else + fade_at = READOUT_LOCK_TIME + READOUT_OPEN_TIME + READOUT_HOLD_TIME + fade_time = READOUT_FADE_TIME + lifetime = fade_at + fade_time + 2 + + build_lock() + build_panel() + if(viewer.client) + shown_to = viewer.client + shown_to.images += images + // Animate only once the client holds the images, as balloon alerts and runechat do. + if(animated) + play() + timer_id = addtimer(CALLBACK(src, PROC_REF(expire)), lifetime, TIMER_STOPPABLE | TIMER_CLIENT_TIME | TIMER_DELETE_ME) + +/datum/chrome_readout/Destroy(force) + if(timer_id) + deltimer(timer_id) + timer_id = null + shown_to?.images -= images + shown_to = null + if(target) + UnregisterSignal(target, list(COMSIG_QDELETING, COMSIG_MOVABLE_Z_CHANGED)) + if(viewer) + UnregisterSignal(viewer, list(COMSIG_QDELETING, COMSIG_MOB_LOGOUT)) + if(optics) + UnregisterSignal(optics, list(COMSIG_ORGAN_REMOVED, COMSIG_QDELETING)) + images.Cut() + sockets.Cut() + name_lines.Cut() + cues.Cut() + viewer = null + target = null + optics = null + anchor = null + report = null + return ..() + +/// The hold and fade ran out. +/datum/chrome_readout/proc/expire() + timer_id = null + qdel(src) + +/** + * Signal proc for the ways a readout ends early: the subject deleted or moved + * to another z, the reader deleted or logged out (a new client starts with no + * images, and a ghost must see nothing), or the optics pulled or deleted. A + * subject who dies keeps theirs; it is a snapshot, and reading a corpse is fair. + */ +/datum/chrome_readout/proc/end_readout(datum/source) + SIGNAL_HANDLER + qdel(src) + +// ---- Building ---------------------------------------------------------- + +/// A blank image on the readout's plane, filed for showing and animating. +/datum/chrome_readout/proc/add_image(icon_file, icon_state, role, kind, at = 0) + var/image/drawn = icon_file ? image(icon_file, anchor, icon_state) : image(loc = anchor) + drawn.layer = ABOVE_ALL_MOB_LAYER + length(images) * 0.001 + // KEEP_APART: humans are KEEP_TOGETHER, and the readout must not be pulled + // into their group (their colour, alpha, height filters or lying turn). + drawn.appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM | KEEP_APART | PIXEL_SCALE + // Without this a click anywhere on the panel lands on the subject. + drawn.mouse_opacity = MOUSE_OPACITY_TRANSPARENT + SET_PLANE_EXPLICIT(drawn, ABOVE_LIGHTING_PLANE, anchor) + drawn.pixel_w = base_w + drawn.pixel_z = base_z + images += drawn + cues[drawn] = list("role" = role, "kind" = kind, "at" = at) + return drawn + +/// A flat rectangle: the white pixel state scaled to size. x/y is the bottom left. +/datum/chrome_readout/proc/add_quad(x, y, width, height, quad_color, quad_alpha, role, kind, at = 0) + var/image/quad = add_image(READOUT_ICON, "px", role, kind, at) + quad.color = quad_color + quad.alpha = quad_alpha + quad.transform = chrome_readout_quad(x, y, width, height) + return quad + +/** + * One line of maptext. `cap_row` is how many pixels below the panel's top edge + * the capitals start. The box is taller than the line and vertically centred, + * so the font's line height never shifts the text: Grand9K 6pt draws a 12 px + * cell with caps 3 px down it, TinyUnicode 12pt a 13 px cell with caps 6 px down. + */ +/datum/chrome_readout/proc/add_text(html, x, cap_row, width, tiny, role, kind, at = 0) + var/image/line = add_image(null, null, role, kind, at) + line.maptext = html + line.maptext_x = x + line.maptext_width = width + if(tiny) + line.maptext_height = 17 + line.maptext_y = READOUT_PANEL_TOP - 9 - cap_row + else + line.maptext_height = 16 + line.maptext_y = READOUT_PANEL_TOP - 11 - cap_row + return line + +/// Brackets, the red outline pulse, and for a scatter the static it breaks into. +/datum/chrome_readout/proc/build_lock() + // Draft C's reticle box: three pixels clear of a standing human sprite. + var/left = 4 + var/right = 26 + var/top = 31 + var/bottom = -2 + if(target.body_position == LYING_DOWN) + left = -2 + right = 33 + top = 26 + bottom = 4 + for(var/corner in list("nw", "ne", "sw", "se")) + var/west = findtext(corner, "w") + var/north = findtext(corner, "n") + var/image/bracket = add_image(READOUT_ICON, "bracket_[corner]", "lock", "bracket") + // The corner pixel sits at canvas column 1 or 30, row 30 or 1. + bracket.pixel_w += (west ? left - 1 : right - 30) + bracket.pixel_z += (north ? top - 30 : bottom - 1) + bracket.color = (mode == READOUT_SCATTER) ? "#ffffff" : READOUT_HUD_COLOR + cues[bracket]["out_w"] = west ? -1 : 1 + cues[bracket]["out_z"] = north ? 1 : -1 + + // The outline pulse, taken from the subject's own look at this moment. + var/image/fill = add_body_copy("lock", "lock_body") + var/list/fill_rgb = rgb2num(READOUT_LOCK_FILL_COLOR) + var/static/icon/stripes_mask = icon(READOUT_ICON, "stripes") + apply_filters(fill, list( + // Flat crimson at a third of the body's alpha... + list("type" = "color", "color" = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, fill_rgb[1] / 255, fill_rgb[2] / 255, fill_rgb[3] / 255, 0.33, 0, 0, 0, 0)), + // ...on every third row. + list("type" = "alpha", "icon" = stripes_mask), + )) + cues[fill]["roll"] = 2 + var/image/edge = add_body_copy("lock", "lock_body") + apply_filters(edge, chrome_read_edge_filters(READOUT_LOCK_COLOR)) + edge.alpha = 230 + + if(mode == READOUT_SCATTER) + // What the outline breaks into: tg's human-shaped static and a glitch strip. + var/image/noise = add_image('icons/effects/effects.dmi', "static", "lock", "static", 5) + noise.dir = target.dir + noise.transform = target.transform + noise.color = "#a8f3fb" + noise.alpha = 191 + cues[noise]["jitter"] = 2 + var/image/glitch = add_image('icons/effects/bitrunning.dmi', "glitch", "lock", "static", 5) + glitch.color = CYBERWARE_COLOR_TIER_3 + cues[glitch]["jitter"] = 3 + return + + // Two echoes of the outline swell out from it while the lock holds. + for(var/echo_at in list(3, 6)) + var/image/echo = add_body_copy("lock", "echo", echo_at) + apply_filters(echo, chrome_read_edge_filters(READOUT_LOCK_COLOR)) + var/matrix/start = matrix(target.transform) + var/matrix/finish = matrix(target.transform) + finish.Scale(1.25) + var/matrix/midway = matrix(target.transform) + midway.Scale(1.12) + cues[echo]["from"] = start + cues[echo]["to"] = finish + // Held mid-swell, so a frame captured without animation shows one. + echo.transform = midway + echo.alpha = 110 + +/// A copy of the subject's current look on the readout's plane. +/datum/chrome_readout/proc/add_body_copy(role, kind, at = 0) + var/image/copy = chrome_read_body_copy(target, anchor) + copy.layer = ABOVE_ALL_MOB_LAYER + length(images) * 0.001 + images += copy + cues[copy] = list("role" = role, "kind" = kind, "at" = at) + return copy + +/// Sets an image's filters from param lists, keeping the lists for anything that inspects the readout. +/datum/chrome_readout/proc/apply_filters(image/drawn, list/specs) + var/list/built = list() + for(var/list/spec as anything in specs) + built += filter(arglist(spec)) + drawn.filters = built + cues[drawn]["filters"] = specs + +/// The panel: frame, leader, header, sockets, names and load bar. +/datum/chrome_readout/proc/build_panel() + var/static/datum/font/header_font = new /datum/font/grand9k/size_6pt() + var/static/datum/font/list_font = new /datum/font/tiny_unicode/size_12pt() + var/open_at = (mode == READOUT_SCATTER) ? 5 : READOUT_LOCK_TIME + var/top = READOUT_PANEL_TOP + + // What goes in it. + var/list/entries = list() + var/socket_count = 0 + if(mode == READOUT_ITEMIZED) + entries = sort_entries(report["entries"]) + socket_count = min(length(entries), READOUT_MAX_SOCKETS) + else if(mode == READOUT_SILHOUETTE) + socket_count = min(report["count"], READOUT_MAX_SOCKETS) + var/rows = CEILING(socket_count / READOUT_SOCKETS_PER_ROW, 1) + + var/list/lines = list() + if(mode == READOUT_ITEMIZED) + var/shown = length(entries) + if(shown > READOUT_MAX_NAME_LINES) + shown = READOUT_MAX_NAME_LINES - 1 + for(var/i in 1 to shown) + var/list/entry = entries[i] + lines += list(list("label" = entry["label"], "color" = entry["color"], "offline" = entry["offline"])) + if(shown < length(entries)) + lines += list(list("label" = "and [length(entries) - shown] more", "color" = null, "offline" = FALSE)) + + var/list/noise + var/header_text + if(mode == READOUT_SCATTER) + var/visible_name = ishuman(target) ? target.get_visible_name() : target.name + noise = list() + for(var/i in 1 to 8) + noise += chrome_readout_noise(clamp(length_char(visible_name), 6, 16)) + header_text = noise[1] + else + header_text = report["name"] + + // Width from the real glyph metrics, never the client's MeasureText(). + var/status_width = 0 + if(mode == READOUT_CLEAN) + status_width = list_font.get_metrics("no chrome") + 8 + else if(mode == READOUT_SCATTER) + status_width = header_font.get_metrics("NO LOCK") + 8 + var/width = 5 + header_font.get_metrics(header_text) + 6 + status_width + if(socket_count) + width = max(width, min(socket_count, READOUT_SOCKETS_PER_ROW) * 24 + 2, 22 + READOUT_BAR_SEGMENTS * 4 + 5) + // A name line starts 9 px in and needs 4 px clear of the right border, + // counting the text outline. + var/offline_width = list_font.get_metrics(" offline") + for(var/list/line as anything in lines) + width = max(width, 9 + list_font.get_metrics(line["label"]) + (line["offline"] ? offline_width : 0) + 4) + width = clamp(width, READOUT_MIN_WIDTH, READOUT_MAX_WIDTH) + if(mode != READOUT_SCATTER) + header_text = chrome_readout_fit(header_text, header_font, width - 11 - status_width) + for(var/list/line as anything in lines) + line["label"] = chrome_readout_fit(line["label"], list_font, width - 13 - (line["offline"] ? offline_width : 0)) + + var/height = 13 + switch(mode) + if(READOUT_ITEMIZED) + height = 21 + 24 * rows + 7 * length(lines) + if(READOUT_SILHOUETTE) + height = 20 + 24 * rows + + // Open on the subject's far side from the reader, so the panel never lies over the reader or the ground + // between the two; on the near side only when the far side would run off the reader's screen. + var/turf/viewer_turf = get_turf(viewer) + var/turf/target_turf = get_turf(target) + flipped = FALSE + if(viewer_turf && target_turf) + // The left edge of the subject's tile on the reader's screen, in pixels from the middle of it. A zoom pans + // the screen through the client's own pixel offset. + var/tile_left = (target_turf.x - viewer_turf.x) * ICON_SIZE_X - ICON_SIZE_X / 2 - (viewer.client?.pixel_x || 0) + var/list/screen_pixels = view_to_pixels(viewer.client?.view || world.view) + var/half_screen = screen_pixels[1] / 2 + var/fits_right = tile_left + READOUT_PANEL_X + width <= half_screen + var/fits_left = tile_left - 5 - width >= -half_screen + flipped = target_turf.x < viewer_turf.x + if(flipped && !fits_left && fits_right) + flipped = FALSE + else if(!flipped && !fits_right && fits_left) + flipped = TRUE + panel_x = flipped ? (-5 - width) : READOUT_PANEL_X + panel_width = width + panel_height = height + + // Frame. The back and sides unfold down from the header. + var/image/back = add_quad(panel_x, top - height, width, height, READOUT_PANEL_COLOR, 205, "panel", "unfold", open_at) + cues[back]["from"] = chrome_readout_quad(panel_x, top - 11, width, 11) + add_quad(panel_x, top - 1, width, 1, READOUT_HUD_COLOR, 120, "panel", "fade", open_at) + var/image/border_bottom = add_quad(panel_x, top - height, width, 1, READOUT_HUD_COLOR, 120, "panel", "unfold", open_at) + cues[border_bottom]["from"] = chrome_readout_quad(panel_x, top - 11, width, 1) + var/image/border_left = add_quad(panel_x, top - height, 1, height, READOUT_HUD_COLOR, 120, "panel", "unfold", open_at) + cues[border_left]["from"] = chrome_readout_quad(panel_x, top - 11, 1, 11) + var/image/border_right = add_quad(panel_x + width - 1, top - height, 1, height, READOUT_HUD_COLOR, 120, "panel", "unfold", open_at) + cues[border_right]["from"] = chrome_readout_quad(panel_x + width - 1, top - 11, 1, 11) + add_quad(panel_x, top - 11, 2, 11, READOUT_HUD_COLOR, 255, "panel", "fade", open_at) + var/image/leader = add_image(READOUT_ICON, flipped ? "leader_flip" : "leader", "panel", "fade", open_at) + leader.pixel_w += flipped ? -5 : 5 + leader.pixel_z += 10 + + // Header: whatever name the body shows. + if(mode == READOUT_SCATTER) + var/image/garbled = add_text(chrome_readout_header_html(html_encode(header_text), "#9fb7bd"), panel_x + 5, 2, width - 9, FALSE, "panel", "noise", open_at) + var/list/noise_html = list() + for(var/noise_text in noise) + noise_html += chrome_readout_header_html(html_encode(noise_text), "#9fb7bd") + cues[garbled]["noise"] = noise_html + add_text(chrome_readout_header_html("NO LOCK", CYBERWARE_COLOR_TIER_3, "right"), panel_x + 5, 2, width - 9, FALSE, "panel", "blink", open_at + 1.5) + return + add_text(chrome_readout_header_html(html_encode(header_text), READOUT_NAME_COLOR), panel_x + 5, 2, width - 9, FALSE, "panel", "fade", open_at) + if(mode == READOUT_CLEAN) + add_text(chrome_readout_tiny_html("no chrome", "right"), panel_x + 5, 2, width - 9, TRUE, "panel", "fade", open_at + 1) + return + + // Sockets, wrapping six to a row. + for(var/i in 1 to socket_count) + var/column = (i - 1) % READOUT_SOCKETS_PER_ROW + var/row = round((i - 1) / READOUT_SOCKETS_PER_ROW) + var/image/socket + var/mutable_appearance/inlay + if(mode == READOUT_ITEMIZED) + var/list/entry = entries[i] + socket = add_image(READOUT_ICON, entry["offline"] ? "chip_blink" : "chip", "socket", "socket", open_at + 1.8 + (i - 1) * 0.5) + socket.color = entry["offline"] ? READOUT_OFFLINE_COLOR : entry["color"] + // Smoothly downscaled, so no PIXEL_SCALE on the ware itself. + inlay = mutable_appearance(entry["icon"], entry["icon_state"], appearance_flags = RESET_COLOR) + if(entry["offline"]) + inlay.color = list(0.29, 0.29, 0.29, 0.56, 0.56, 0.56, 0.11, 0.11, 0.11) + else + socket = add_image(READOUT_ICON, "chip", "socket", "socket", open_at + 1.8 + (i - 1) * 0.5) + socket.color = READOUT_STATIC_FRAME_COLOR + inlay = mutable_appearance('icons/effects/effects.dmi', "static_base", alpha = 110, appearance_flags = RESET_COLOR | PIXEL_SCALE) + inlay.color = "#bfbfbf" + inlay.transform = matrix(READOUT_SOCKET_ICON_SCALE, 0, 0, 0, READOUT_SOCKET_ICON_SCALE, 0) + socket.overlays += inlay + // The chip state's 20 px socket starts six pixels into its canvas. + socket.pixel_w += panel_x + 3 + column * 24 - 6 + socket.pixel_z += top - 33 - row * 24 - 6 + sockets += socket + + // Names, each with its tier as a small swatch. + var/names_top = 12 + 24 * rows + for(var/i in 1 to length(lines)) + var/list/line = lines[i] + var/cap_row = names_top + 7 * (i - 1) + var/inner + if(isnull(line["color"])) + inner = "[html_encode(line["label"])]" + else if(line["offline"]) + inner = "[html_encode(line["label"])] offline" + else + inner = "[html_encode(line["label"])]" + var/image/name_line = add_text(chrome_readout_tiny_html(inner), panel_x + 9, cap_row, width - 10, TRUE, "name", "fade", open_at + 2.6 + (i - 1) * 0.5) + if(!isnull(line["color"])) + var/mutable_appearance/swatch = mutable_appearance(READOUT_ICON, "bullet", appearance_flags = RESET_COLOR) + swatch.color = line["color"] + swatch.pixel_w = panel_x + 4 + swatch.pixel_z = top - 4 - cap_row + name_line.overlays += swatch + name_lines += name_line + + // Load, as a bar. Over the ceiling it pins full in the offline colour. + var/bar_row = names_top + (length(lines) ? 7 * length(lines) + 2 : 0) + var/load = report["load"] + var/capacity = max(report["capacity"], 1) + var/over = load > capacity + var/filled = over ? READOUT_BAR_SEGMENTS : clamp(round(load / capacity * READOUT_BAR_SEGMENTS), 0, READOUT_BAR_SEGMENTS) + var/image/bar = add_image(READOUT_BAR_ICON, "fill_[filled]", "load", "bar", open_at + 3.5) + bar.color = over ? READOUT_OFFLINE_COLOR : READOUT_HUD_COLOR + bar.underlays += mutable_appearance(READOUT_BAR_ICON, "track", appearance_flags = RESET_COLOR) + bar.pixel_w += panel_x + 22 + bar.pixel_z += top - 3 - bar_row + bar.maptext = chrome_readout_tiny_html("load") + bar.maptext_x = -18 + bar.maptext_y = -5 + bar.maptext_width = 20 + bar.maptext_height = 17 + cues[bar]["fill"] = filled + +/// Highest tier first, unrated last; ties keep organ order. +/datum/chrome_readout/proc/sort_entries(list/entries) + var/list/sorted = list() + for(var/rank in list(CYBERWARE_TIER_4, CYBERWARE_TIER_3, CYBERWARE_TIER_2, CYBERWARE_TIER_1, 0)) + for(var/list/entry as anything in entries) + if(entry["tier"] == rank) + sorted += list(entry) + return sorted + +// ---- Animation --------------------------------------------------------- + +/// Hands every image its timeline. Called once, after the client has them. +/datum/chrome_readout/proc/play() + for(var/image/drawn as anything in images) + var/list/cue = cues[drawn] + switch(cue["kind"]) + if("fade") + play_fade(drawn, cue["at"]) + if("unfold") + play_unfold(drawn, cue) + if("socket") + play_socket(drawn, cue["at"]) + if("bar") + play_bar(drawn, cue) + if("bracket") + play_bracket(drawn, cue) + if("lock_body") + play_lock_body(drawn, cue) + if("echo") + play_echo(drawn, cue) + if("static") + play_static(drawn, cue) + if("noise") + play_noise(drawn, cue) + if("blink") + play_blink(drawn, cue["at"]) + +/datum/chrome_readout/proc/play_fade(image/drawn, at, fade_in = 0.8) + var/hold_alpha = drawn.alpha + drawn.alpha = 0 + animate(drawn, alpha = 0, time = at) + animate(alpha = hold_alpha, time = fade_in) + animate(alpha = hold_alpha, time = max(fade_at - at - fade_in, 0)) + animate(alpha = 0, time = fade_time) + +/datum/chrome_readout/proc/play_unfold(image/drawn, list/cue) + var/at = cue["at"] + var/hold_alpha = drawn.alpha + var/matrix/full = drawn.transform + drawn.alpha = 0 + drawn.transform = cue["from"] + animate(drawn, alpha = 0, time = at) + animate(alpha = hold_alpha, time = 0.8) + animate(transform = full, time = 2.2, easing = CUBIC_EASING | EASE_OUT) + animate(alpha = hold_alpha, time = max(fade_at - at - 3, 0)) + animate(alpha = 0, time = fade_time) + +/// Sockets land white and settle into their tier colour. +/datum/chrome_readout/proc/play_socket(image/drawn, at) + var/hold_color = drawn.color + drawn.alpha = 0 + drawn.color = "#ffffff" + animate(drawn, alpha = 0, time = at) + animate(alpha = 255, time = 0.6) + animate(color = hold_color, time = 1) + animate(alpha = 255, time = max(fade_at - at - 1.6, 0)) + animate(alpha = 0, time = fade_time) + +/// The bar fills a segment at a time. +/datum/chrome_readout/proc/play_bar(image/drawn, list/cue) + var/at = cue["at"] + var/filled = cue["fill"] + drawn.alpha = 0 + drawn.icon_state = "fill_0" + animate(drawn, alpha = 0, time = at) + animate(alpha = 255, time = 1) + for(var/step in 1 to filled) + animate(icon_state = "fill_[step]", time = 4 / filled) + animate(alpha = 255, time = max(fade_at - at - 1 - (filled ? 4 : 0), 0)) + animate(alpha = 0, time = fade_time) + +/// Snap in from wide with an overshoot, flash through the lock, hold, then +/// release outward as everything fades. A scatter never locks: the brackets hunt. +/datum/chrome_readout/proc/play_bracket(image/drawn, list/cue) + var/final_w = drawn.pixel_w + var/final_z = drawn.pixel_z + var/out_w = cue["out_w"] + var/out_z = cue["out_z"] + var/hold_color = drawn.color + drawn.pixel_w = final_w + out_w * 16 + drawn.pixel_z = final_z + out_z * 16 + drawn.alpha = 0 + drawn.color = "#ffffff" + animate(drawn, pixel_w = final_w, pixel_z = final_z, alpha = 255, time = 3, easing = BACK_EASING | EASE_OUT) + if(mode == READOUT_SCATTER) + var/elapsed = 3 + while(elapsed < fade_at) + var/step = min(1, fade_at - elapsed) + animate(pixel_w = final_w + rand(-3, 3), pixel_z = final_z + rand(-3, 3), alpha = pick(255, 255, 120), time = step, easing = JUMP_EASING | EASE_IN) + elapsed += step + else + for(var/flash in 1 to 6) + animate(color = ISODD(flash) ? hold_color : "#ffffff", time = 4 / 6, easing = JUMP_EASING | EASE_IN) + animate(color = hold_color, time = max(fade_at - 7, 0), easing = JUMP_EASING | EASE_IN) + animate(pixel_w = final_w + out_w * 10, pixel_z = final_z + out_z * 10, alpha = 0, time = fade_time, easing = CUBIC_EASING | EASE_IN) + +/// The red outline: in as the brackets land, held through the lock, out as the +/// panel opens. On a scatter it flickers and slips instead, then gives way to static. +/datum/chrome_readout/proc/play_lock_body(image/drawn, list/cue) + var/hold_alpha = drawn.alpha + var/base = drawn.pixel_w + drawn.alpha = 0 + animate(drawn, alpha = 0, time = 2) + animate(alpha = hold_alpha, time = 2) + if(mode == READOUT_SCATTER) + for(var/flicker in 1 to 8) + animate(alpha = pick(hold_alpha, hold_alpha, round(hold_alpha * 0.3), 0), pixel_w = base + rand(-2, 2), time = 0.5, easing = JUMP_EASING | EASE_IN) + animate(alpha = 0, pixel_w = base, time = 2) + else + animate(alpha = hold_alpha, time = READOUT_LOCK_TIME - 4) + animate(alpha = 0, time = 4.5) + if(cue["roll"]) + // The stripes crawl down the body, a row at a time. + animate(drawn.filters[cue["roll"]], y = -1, time = 0.8, loop = -1, easing = JUMP_EASING | EASE_IN, flags = ANIMATION_PARALLEL) + animate(y = -2, time = 0.8, easing = JUMP_EASING | EASE_IN) + animate(y = 0, time = 0.8, easing = JUMP_EASING | EASE_IN) + +/// One outline echo swelling out and fading. +/datum/chrome_readout/proc/play_echo(image/drawn, list/cue) + drawn.alpha = 0 + drawn.transform = cue["from"] + animate(drawn, alpha = 0, time = cue["at"]) + animate(alpha = 204, time = 0) + animate(alpha = 0, transform = cue["to"], time = 5.5, easing = CUBIC_EASING | EASE_OUT) + +/// Scatter static: shivers in place until the read drops. +/datum/chrome_readout/proc/play_static(image/drawn, list/cue) + var/at = cue["at"] + var/jitter = cue["jitter"] + var/hold_alpha = drawn.alpha + var/base = drawn.pixel_w + drawn.alpha = 0 + animate(drawn, alpha = 0, time = at) + animate(alpha = hold_alpha, time = 1.5) + var/elapsed = at + 1.5 + while(elapsed < fade_at) + var/step = min(0.5, fade_at - elapsed) + animate(alpha = hold_alpha, pixel_w = base + rand(-jitter, jitter), time = step, easing = JUMP_EASING | EASE_IN) + elapsed += step + animate(alpha = 0, time = fade_time) + +/// Scatter header: the name never resolves. +/datum/chrome_readout/proc/play_noise(image/drawn, list/cue) + var/at = cue["at"] + var/list/noise_html = cue["noise"] + drawn.alpha = 0 + animate(drawn, alpha = 0, time = at) + animate(alpha = 255, time = 0.8) + var/elapsed = at + 0.8 + var/frame = 0 + while(elapsed < fade_at) + var/step = min(1, fade_at - elapsed) + animate(maptext = noise_html[(frame % length(noise_html)) + 1], time = step) + elapsed += step + frame++ + animate(alpha = 0, time = fade_time) + +/// "NO LOCK", three beats on and one off. +/datum/chrome_readout/proc/play_blink(image/drawn, at) + drawn.alpha = 0 + animate(drawn, alpha = 0, time = at) + var/elapsed = at + while(elapsed + 2 <= fade_at) + animate(alpha = 255, time = 1.5, easing = JUMP_EASING | EASE_IN) + animate(alpha = 0, time = 0.5, easing = JUMP_EASING | EASE_IN) + elapsed += 2 + animate(alpha = 255, time = max(fade_at - elapsed, 0), easing = JUMP_EASING | EASE_IN) + animate(alpha = 0, time = fade_time) + +// ---- Helpers ----------------------------------------------------------- + +/// Transform that draws the 32 px white state as a rectangle with its bottom left at x, y. +/proc/chrome_readout_quad(x, y, width, height) + return matrix(width / 32, 0, x + width / 2 - 16, 0, height / 32, y + height / 2 - 16) + +/// Grand9K header line (the map's default maptext font). +/proc/chrome_readout_header_html(text, text_color, align = "left") + return MAPTEXT("
[text]
") + +/// TinyUnicode list line. `inner` is already HTML. +/proc/chrome_readout_tiny_html(inner, align = "left") + return MAPTEXT_TINY_UNICODE("
[inner]
") + +/// Garbage of the given length for a header that won't resolve. Plain text; encode it for maptext. +/proc/chrome_readout_noise(length) + var/static/list/glyphs = list("#", "%", "&", "@", "$", "/", "\\", "|", "<", ">", "*") + var/garbage = "" + for(var/i in 1 to length) + garbage += pick(glyphs) + return garbage + +/// Trims text to fit max_width pixels in the given font, marking the cut. +/proc/chrome_readout_fit(text, datum/font/font, max_width) + if(font.get_metrics(text) <= max_width) + return text + var/trimmed = text + while(length_char(trimmed) > 1 && font.get_metrics("[trimmed]..") > max_width) + trimmed = copytext_char(trimmed, 1, length_char(trimmed)) + return "[trimmed].." + +/** + * Filter chain that turns a copy of a body into just its one-pixel outline in + * `edge_color`. The body goes black, gains a white outline, and a colour matrix + * then keys alpha off red: the white ring stays, the black body vanishes, and + * nothing is added where the image was already clear. + */ +/proc/chrome_read_edge_filters(edge_color) + var/list/edge_rgb = rgb2num(edge_color) + return list( + list("type" = "color", "color" = list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0)), + list("type" = "outline", "size" = 1, "color" = "#ffffff", "flags" = OUTLINE_SHARP | OUTLINE_SQUARE), + list("type" = "color", "color" = list(edge_rgb[1] / 255, edge_rgb[2] / 255, edge_rgb[3] / 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), + ) + +/** + * A client image wearing `body`'s current look, hung on `attach_to`, flattened + * out of everything that would tie it to the body's own rendering: no colour, + * alpha or filters of theirs, and on the readout's plane. Parented to the body + * itself it takes no pixel offset of its own (it inherits theirs); parked on a + * turf it keeps theirs so it lines up. + * + * Emissive overlays inside the copy keep their own plane and land exactly on + * the body's own emissives. + */ +/proc/chrome_read_body_copy(mob/living/body, atom/attach_to = body) + var/image/copy = image(loc = attach_to) + copy.appearance = body.appearance + copy.appearance_flags = KEEP_TOGETHER | KEEP_APART | RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM | PIXEL_SCALE + copy.color = null + copy.alpha = 255 + copy.filters = null + copy.blend_mode = BLEND_DEFAULT + copy.render_target = null + copy.render_source = null + copy.mouse_opacity = MOUSE_OPACITY_TRANSPARENT + if(attach_to == body) + copy.pixel_x = 0 + copy.pixel_y = 0 + copy.pixel_w = 0 + copy.pixel_z = 0 + copy.layer = ABOVE_ALL_MOB_LAYER + SET_PLANE_EXPLICIT(copy, ABOVE_LIGHTING_PLANE, attach_to) + return copy + +// ---- The subject and the bystanders ------------------------------------ + +/** + * The subject's own warning: their body flinches red twice, on their screen + * only. The chat line naming the reader is sent by the action. + */ +/proc/chrome_read_flinch(mob/living/subject) + var/client/subject_client = subject?.client + if(!subject_client) + return + var/image/flinch = chrome_read_flinch_image(subject) + subject_client.images += flinch + animate(flinch, alpha = 0, time = 1) + animate(alpha = 255, time = 0) + animate(alpha = 255, time = 1) + animate(alpha = 0, time = 0.6) + animate(alpha = 0, time = 0.4) + animate(alpha = 200, time = 0) + animate(alpha = 200, time = 0.8) + animate(alpha = 0, time = 1.5) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(remove_image_from_client), flinch, subject_client), 1 SECONDS, TIMER_CLIENT_TIME) + +/// The flinch image: the body in tier-three pink, a faint fill under a hard outline. +/proc/chrome_read_flinch_image(mob/living/subject) + var/image/flinch = chrome_read_body_copy(subject) + var/list/flinch_rgb = rgb2num(CYBERWARE_COLOR_TIER_3) + var/list/specs = chrome_read_edge_filters(CYBERWARE_COLOR_TIER_3) + // Same outline, but the body keeps a faint fill: alpha is 0.27 inside and + // 0.95 on the ring. + specs[3] = list("type" = "color", "color" = list(0, 0, 0, 0.68, 0, 0, 0, 0, 0, 0, 0, 0, flinch_rgb[1] / 255, flinch_rgb[2] / 255, flinch_rgb[3] / 255, 0.27, 0, 0, 0, 0)) + var/list/built = list() + for(var/list/spec as anything in specs) + built += filter(arglist(spec)) + flinch.filters = built + return flinch + +/** + * The tell anyone looking at the reader can see: their eyes flicker. It rides + * the reader through vis_contents, so it shows to whoever sees them. + */ +/proc/chrome_read_eye_glint(mob/living/carbon/reader) + var/mutable_appearance/glint = chrome_read_glint_appearance(reader) + if(!glint) + return + var/atom/movable/visual = reader.flick_overlay_view(glint, 0.5 SECONDS) + if(!visual) + return + visual.vis_flags |= VIS_INHERIT_DIR + animate(visual, alpha = 255, time = 1) + animate(alpha = 0, time = 0.5, easing = JUMP_EASING | EASE_IN) + animate(alpha = 255, time = 1, easing = JUMP_EASING | EASE_IN) + animate(alpha = 0, time = 0.5, easing = JUMP_EASING | EASE_IN) + animate(alpha = 255, time = 1, easing = JUMP_EASING | EASE_IN) + animate(alpha = 0, time = 1) + +/// The reader's eyes, lit. Null when there are no eyes to light or something covers them. +/proc/chrome_read_glint_appearance(mob/living/carbon/reader) + if(!ishuman(reader)) + return null + var/mob/living/carbon/human/human_reader = reader + var/obj/item/organ/eyes/eyes = human_reader.get_organ_slot(ORGAN_SLOT_EYES) + if(isnull(eyes?.eye_icon_state)) + return null + if(human_reader.check_obscured_slots() & ITEM_SLOT_EYES) + return null + var/eye_state = eyes.eye_icon_state + var/mutable_appearance/glint = mutable_appearance('icons/mob/human/human_face.dmi', "[eye_state]_l") + glint.overlays += mutable_appearance('icons/mob/human/human_face.dmi', "[eye_state]_r") + glint.overlays += emissive_appearance('icons/mob/human/human_face.dmi', "[eye_state]_l", reader) + glint.overlays += emissive_appearance('icons/mob/human/human_face.dmi', "[eye_state]_r", reader) + glint.color = READOUT_GLINT_COLOR + glint.dir = reader.dir + var/obj/item/bodypart/head/head = human_reader.get_bodypart(BODY_ZONE_HEAD) + head?.worn_face_offset?.apply_offset(glint) + return glint + +#undef READOUT_ITEMIZED +#undef READOUT_SILHOUETTE +#undef READOUT_SCATTER +#undef READOUT_CLEAN +#undef READOUT_LOCK_TIME +#undef READOUT_OPEN_TIME +#undef READOUT_HOLD_TIME +#undef READOUT_CLEAN_HOLD_TIME +#undef READOUT_FADE_TIME +#undef READOUT_SCATTER_DROP_AT +#undef READOUT_SCATTER_FADE_TIME +#undef READOUT_PANEL_X +#undef READOUT_PANEL_TOP +#undef READOUT_SOCKETS_PER_ROW +#undef READOUT_MAX_SOCKETS +#undef READOUT_MAX_NAME_LINES +#undef READOUT_MIN_WIDTH +#undef READOUT_MAX_WIDTH +#undef READOUT_BAR_SEGMENTS +#undef READOUT_SOCKET_ICON_SCALE +#undef READOUT_HUD_COLOR +#undef READOUT_LOCK_COLOR +#undef READOUT_LOCK_FILL_COLOR +#undef READOUT_PANEL_COLOR +#undef READOUT_NAME_COLOR +#undef READOUT_DIM_COLOR +#undef READOUT_OFFLINE_COLOR +#undef READOUT_OFFLINE_NAME_COLOR +#undef READOUT_STATIC_FRAME_COLOR +#undef READOUT_GLINT_COLOR +#undef READOUT_ICON +#undef READOUT_BAR_ICON diff --git a/voidcrew/modules/cyberware/cyberware_stealth.dm b/voidcrew/modules/cyberware/cyberware_stealth.dm index a56766082b9..9e1aee21738 100644 --- a/voidcrew/modules/cyberware/cyberware_stealth.dm +++ b/voidcrew/modules/cyberware/cyberware_stealth.dm @@ -4,14 +4,39 @@ * The Ghostskin Weave (ware_military.dm) fades its bearer to an alpha shimmer, * which fools humans but means nothing to NPC AI, basic mobs target by * reference, not by pixels. This file is the AI half of the camo: a trait the - * weave holds while active, and a chained override of the basic-mob targeting - * strategy that refuses camo'd targets beyond point-blank range. + * weave holds while active, one shared question (cyberware_camo_hides()), and + * the hooks that ask it for everything that hunts the bearer by sight. * - * The override lives HERE, in a cyberware-owned file, rather than in the + * Everything that grants TRAIT_CYBER_CAMO is hidden from: + * - basic mobs and human NPCs (the targeting strategy below, which every + * strategy subtype inherits through its own `..()` calls: the human NPC + * strategy, pirate crews and boarders, bounty criminals and their crews, + * ruin troopers and hermits, patrols, the club's people), + * - simple_animal hostiles (hermits, ice demons, polar bears, ...), + * - every porta_turret subtype: ruin and Syndicate turrets, hull defense + * turrets, player-built turrets, trader and player outpost turrets, including + * a player an outpost has marked, + * and, through one-line calls in the files that own them, the scripted target + * picks that never go through a /basic strategy: the club's people + * (mafia_target_ok()), the lich's thralls and the outpost experiment forms + * (their form's can_target()). + * + * What camo does NOT hide from: anything within CYBERWARE_CAMO_SPOT_RANGE + * tiles, the mobs in GLOB.cyberware_camo_piercing_types (megafauna, elites + * and the bosses that are still basic mobs), and every human NPC of boss rank + * (npc_rank HUMAN_NPC_RANK_BOSS: faction pirate bosses, the NT patrol's + * director, bounty bosses, the kingpin, the club's don). Ship weapons that + * target ships, not people, are not covered here. The street Flickerskin + * never grants the trait at all. + * + * The overrides live HERE, in a cyberware-owned file, rather than in the * shared AI files: defining the same proc a second time is this fork's blessed * way to patch upstream behavior (the later .dme include wraps the earlier - * definition, and `..()` calls straight into it). Nothing outside this module - * changes on disk. + * definition, and `..()` calls straight into it). That only works for a proc + * whose first definition is included BEFORE this file, so the hooks for the + * voidcrew files that include after it (the lich, the club, the experiment + * forms) are a single call to cyberware_camo_hides() in the proc that picks + * the target. * * TRAIT_CYBER_CAMO itself lives in voidcrew/_DEFINES/cyberware.dm, because * the chrome read (cyberware_scan.dm) is included ahead of this file and also @@ -23,6 +48,49 @@ /// fauna pack point-blank is still a bad idea. The PvP/PvE counterplay floor. #define CYBERWARE_CAMO_SPOT_RANGE 2 +/// Mobs that see straight through optical camo, whatever it is: megafauna, +/// mining elites and the bosses and mini bosses of the ruins, lairs, outposts +/// and vestiges that are still basic mobs. A typecache, so subtypes count. +/// Bosses that are people (human NPCs) see through it by rank instead, in +/// cyberware_camo_hides(). +GLOBAL_LIST_INIT(cyberware_camo_piercing_types, typecacheof(list( + /mob/living/simple_animal/hostile/megafauna, + /mob/living/basic/trooper/pirate/faction/boss, + /mob/living/simple_animal/hostile/asteroid/elite, + /mob/living/basic/boss, + /mob/living/basic/lich, + /mob/living/basic/hoarfrost_matriarch, + /mob/living/basic/bounty_lair_boss, + /mob/living/basic/outpost_experiment/horror, + /mob/living/basic/alien/queen/large/derelict, + /mob/living/basic/vestige_oracle, + /mob/living/basic/vestige_mutant, + /mob/living/basic/vestige_warframe, +))) + +/** + * Whether optical camo hides `target` from `viewer` right now: the target holds + * TRAIT_CYBER_CAMO, the viewer is further off than CYBERWARE_CAMO_SPOT_RANGE and + * the viewer is not one of the mobs that sees through it (a piercing type, or a + * human NPC of boss rank). `viewer` is whatever + * is doing the looking (a mob, a turret, a creature picking its next victim). + * Anything that is not a living mob is never hidden. + */ +/proc/cyberware_camo_hides(mob/living/target, atom/viewer) + if(!isliving(target) || !HAS_TRAIT(target, TRAIT_CYBER_CAMO)) + return FALSE + if(!viewer) + return TRUE + if(get_dist(viewer, target) <= CYBERWARE_CAMO_SPOT_RANGE) + return FALSE + if(is_type_in_typecache(viewer, GLOB.cyberware_camo_piercing_types)) + return FALSE + if(ishumannpc(viewer)) + var/mob/living/carbon/human/npc/person = viewer + if(person.npc_rank >= HUMAN_NPC_RANK_BOSS) + return FALSE + return TRUE + /** * Chained override of the stock basic targeting strategy (base definition: * code/datums/ai/basic_mobs/targeting_strategies/basic_targeting_strategy.dm). @@ -35,10 +103,49 @@ . = ..() if(!.) return - if(!isliving(the_target)) - return . - if(!HAS_TRAIT(the_target, TRAIT_CYBER_CAMO)) - return . - if(get_dist(living_mob, the_target) <= CYBERWARE_CAMO_SPOT_RANGE) - return . - return FALSE + if(cyberware_camo_hides(the_target, living_mob)) + return FALSE + return . + +/** + * The same for simple_animal hostiles, whose single gate is CanAttack() (base + * definition: code/modules/mob/living/simple_animal/hostile/hostile.dm). They + * ask it when they pick a target and again every tick they chase one, so a + * camo field that goes up mid-chase makes them lose the target. + */ +/mob/living/simple_animal/hostile/CanAttack(atom/the_target) + . = ..() + if(!.) + return + if(cyberware_camo_hides(the_target, src)) + return FALSE + return . + +/** + * Every porta_turret, however it finds its targets (the stock scan, the hull + * defense turret's, the outpost's), hands the list it wants to shoot at to + * tryToShootAt(). Anyone camo'd and out of spot range is dropped from it. A + * turret left with nothing behaves as one that found nothing (the cover goes + * back down) instead of standing up for a target it cannot see. + */ +/obj/machinery/porta_turret/tryToShootAt(list/atom/movable/targets) + var/hid_someone = FALSE + for(var/mob/living/candidate in targets.Copy()) + if(cyberware_camo_hides(candidate, src)) + targets -= candidate + hid_someone = TRUE + if(hid_someone && !length(targets)) + if(!always_up) + popDown() + return FALSE + return ..() + +/** + * Drops the bearer's camo field, if it is up. For the abilities that hurt someone without going + * through an attack the field listens for: a lunge, a landing. Same collapse as any other + * contact. + */ +/proc/cyberware_camo_drop(mob/living/carbon/bearer, reason = "field contact") + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = bearer?.get_organ_slot(ORGAN_SLOT_CYBERWARE_SKIN) + if(istype(weave)) + weave.break_camo(bearer, reason = reason) diff --git a/voidcrew/modules/cyberware/cyberware_zoom.dm b/voidcrew/modules/cyberware/cyberware_zoom.dm new file mode 100644 index 00000000000..1dff620378b --- /dev/null +++ b/voidcrew/modules/cyberware/cyberware_zoom.dm @@ -0,0 +1,244 @@ +/** + * # Optics zoom + * + * Every set of chrome optics (/obj/item/organ/eyes/robotic/cyberware and its + * subtypes) can zoom: one toggle button pans the bearer's camera toward the + * cursor, using tg's scope component (code/datums/components/scope.dm), the + * same one binoculars and rifle scopes use. How far it reaches is the optics' + * optics_zoom, passed straight through as the scope's range_modifier; better + * optics reach further, and the cheap ones slow their bearer while they look. + * + * The button rides the /datum/action/cooldown/cyberware bridge, so browned-out, + * EMP-scrambled or failing eyes can't zoom, and the chrome wheel collects it + * like any other chrome button. + * + * Zoom is look-only: + * - A zoomed bearer can't fire a gun (COMSIG_MOB_TRYING_TO_FIRE_GUN is refused, + * and a burst already under autofire stops when the zoom starts). + * - Their clicks on the zoomed view reach nothing on the map. The scope's + * fullscreen cursor catcher already eats them; check_click_intercept() below + * takes them before any click intercept or ClickOn() sees them. + * + * The zoom drops on its own when the eyes stop working or the bearer can't + * look: EMP, brownout or damage failure (chrome_passives_off()), the eyes + * coming out, blindness, a flash, a stun, knockdown or paralysis, any stat + * change (crit, sleep, death), and everything the scope already stops for + * (no client, climbing into a locker or a mech, the organ moving). + */ + +/obj/item/organ/eyes/robotic/cyberware + /// How far the zoom pans, as the scope's range_modifier: 1 reaches as far + /// again as the edge of the normal view, 2 twice that. 0 means no zoom. + var/optics_zoom = 1 + /// Slowdown while zoomed (a multiplicative_slowdown). 0 for none. + var/zoom_walk_penalty = 1 + /// Throttles the "can't aim" balloon, so autofire and click spam don't stack it. + COOLDOWN_DECLARE(zoom_aim_warning) + /// Throttles the iris tell, so flicking the zoom on and off can't flood chat. + COOLDOWN_DECLARE(zoom_tell) + +/// Gives these optics their zoom: the scope that does the panning, and the +/// button. Called from Initialize() on the optics base (cyberware_base.dm). +/obj/item/organ/eyes/robotic/cyberware/proc/setup_optics_zoom() + if(optics_zoom <= 0) + return + // ZOOM_METHOD_ITEM_ACTION with no item_action_type: the scope adds no button + // and no examine line of its own, and only zooms when we tell it to. + AddComponent(/datum/component/scope, range_modifier = optics_zoom, zoom_method = ZOOM_METHOD_ITEM_ACTION) + add_item_action(/datum/action/cooldown/cyberware/optics_zoom) + +/// Whether our bearer is looking through these optics' zoom right now. +/obj/item/organ/eyes/robotic/cyberware/proc/is_zoomed() + return owner && HAS_TRAIT_FROM(owner, TRAIT_CYBER_ZOOMED, REF(src)) + +/// Starts the zoom for our bearer. Returns TRUE if they are now zoomed. +/obj/item/organ/eyes/robotic/cyberware/proc/start_zoom() + var/mob/living/carbon/bearer = owner + if(!iscarbon(bearer) || is_zoomed()) + return FALSE + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + var/datum/component/scope/scope = GetComponent(/datum/component/scope) + if(!scope || !chrome?.is_running()) + return FALSE + if(bearer.is_blind()) + bearer.balloon_alert(bearer, "optics dark!") + return FALSE + if(!isturf(bearer.loc)) + bearer.balloon_alert(bearer, "can't see out!") + return FALSE + if(HAS_TRAIT(bearer, TRAIT_INCAPACITATED)) + return FALSE + // The scope refuses a clientless bearer and anyone already scoped (a rifle, + // binoculars), with its own balloon for the second. + if(!scope.zoom(bearer)) + return FALSE + engage_zoom(bearer) + return TRUE + +/** + * Our half of a zoom, once the scope is panning: the trait, the stop hooks, + * the gun block and the walk penalty. Split from start_zoom() because the scope + * needs a client, and a unit test has none. + */ +/obj/item/organ/eyes/robotic/cyberware/proc/engage_zoom(mob/living/carbon/bearer) + ADD_TRAIT(bearer, TRAIT_CYBER_ZOOMED, REF(src)) + // The scope stops itself for a few reasons of its own (no client, the bearer + // climbing into something); it drops TRAIT_USER_SCOPED when it does. + RegisterSignal(bearer, SIGNAL_REMOVETRAIT(TRAIT_USER_SCOPED), PROC_REF(on_scope_lost)) + RegisterSignal(bearer, COMSIG_MOB_TRYING_TO_FIRE_GUN, PROC_REF(on_zoomed_fire)) + RegisterSignal(bearer, COMSIG_MOB_STATCHANGE, PROC_REF(on_zoomed_stat_change)) + RegisterSignal(bearer, COMSIG_MOB_FLASHED, PROC_REF(on_zoomed_flashed)) + RegisterSignal(bearer, COMSIG_LIVING_STATUS_APPLIED, PROC_REF(on_zoomed_status)) + RegisterSignals(bearer, list(COMSIG_LIVING_STATUS_STUN, COMSIG_LIVING_STATUS_KNOCKDOWN, COMSIG_LIVING_STATUS_PARALYZE), PROC_REF(on_zoomed_stunned)) + if(zoom_walk_penalty) + bearer.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/cyberware_zoom, multiplicative_slowdown = zoom_walk_penalty) + // Autofire fires through process_fire() and never asks the signal above, so + // a burst already rolling when the zoom starts is stopped here instead. + for(var/obj/item/gun/held in bearer.held_items) + var/datum/component/automatic_fire/autofire = held.GetComponent(/datum/component/automatic_fire) + autofire?.stop_autofiring() + // The tell, the chrome read's pattern: only people close enough see it. + if(COOLDOWN_FINISHED(src, zoom_tell)) + COOLDOWN_START(src, zoom_tell, 5 SECONDS) + bearer.visible_message(span_notice("[bearer]'s irises whir and narrow."), vision_distance = 3, ignored_mobs = bearer) + update_zoom_button() + +/// Stops the zoom, scope and all. Safe to call when nothing is zoomed. +/obj/item/organ/eyes/robotic/cyberware/proc/stop_zoom(mob/living/carbon/bearer) + if(!bearer) + return + var/datum/component/scope/scope = GetComponent(/datum/component/scope) + // Only ever stop OUR scope: the fullscreen it clears is shared by every scope. + if(scope?.tracker && HAS_TRAIT_FROM(bearer, TRAIT_USER_SCOPED, REF(scope))) + scope.stop_zooming(bearer) // drops TRAIT_USER_SCOPED, so on_scope_lost() runs + disengage_zoom(bearer) + +/// Undoes engage_zoom(). Idempotent: the passive hook calls it on every flip. +/obj/item/organ/eyes/robotic/cyberware/proc/disengage_zoom(mob/living/carbon/bearer) + if(!bearer) + return + REMOVE_TRAIT(bearer, TRAIT_CYBER_ZOOMED, REF(src)) + UnregisterSignal(bearer, list( + SIGNAL_REMOVETRAIT(TRAIT_USER_SCOPED), + COMSIG_MOB_TRYING_TO_FIRE_GUN, + COMSIG_MOB_STATCHANGE, + COMSIG_MOB_FLASHED, + COMSIG_LIVING_STATUS_APPLIED, + COMSIG_LIVING_STATUS_STUN, + COMSIG_LIVING_STATUS_KNOCKDOWN, + COMSIG_LIVING_STATUS_PARALYZE, + )) + bearer.remove_movespeed_modifier(/datum/movespeed_modifier/cyberware_zoom) + update_zoom_button() + +/// The zoom button shows green while zoomed (the cooldown action's active look). +/obj/item/organ/eyes/robotic/cyberware/proc/update_zoom_button() + for(var/datum/action/cooldown/cyberware/optics_zoom/zoom in actions) + zoom.build_all_button_icons(UPDATE_BUTTON_STATUS) + +/// One short balloon when a zoomed bearer tries to shoot. +/obj/item/organ/eyes/robotic/cyberware/proc/refuse_zoomed_aim(mob/living/carbon/bearer) + if(!COOLDOWN_FINISHED(src, zoom_aim_warning)) + return + COOLDOWN_START(src, zoom_aim_warning, 1 SECONDS) + bearer.balloon_alert(bearer, "too zoomed in to aim!") + +// ---- Stop hooks ---------------------------------------------------------- + +/obj/item/organ/eyes/robotic/cyberware/chrome_passives_off(mob/living/carbon/bearer) + . = ..() + // EMP reboot, brownout, damage failure and removal all come through here. + stop_zoom(bearer) + +/obj/item/organ/eyes/robotic/cyberware/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) + stop_zoom(organ_owner) + return ..() + +/// Signal proc for [SIGNAL_REMOVETRAIT] of TRAIT_USER_SCOPED: the scope stopped. +/obj/item/organ/eyes/robotic/cyberware/proc/on_scope_lost(mob/living/carbon/source) + SIGNAL_HANDLER + disengage_zoom(source) + +/// Signal proc for [COMSIG_MOB_TRYING_TO_FIRE_GUN]: no shooting through the zoom. +/obj/item/organ/eyes/robotic/cyberware/proc/on_zoomed_fire(mob/living/carbon/source, obj/item/gun/gun, atom/target, flag, params) + SIGNAL_HANDLER + refuse_zoomed_aim(source) + return COMPONENT_CANCEL_GUN_FIRE + +/// Signal proc for [COMSIG_MOB_STATCHANGE]: crit, sleep and death end the zoom. +/obj/item/organ/eyes/robotic/cyberware/proc/on_zoomed_stat_change(mob/living/carbon/source, new_stat, old_stat) + SIGNAL_HANDLER + if(new_stat != CONSCIOUS) + stop_zoom(source) + +/// Signal proc for [COMSIG_MOB_FLASHED]. +/obj/item/organ/eyes/robotic/cyberware/proc/on_zoomed_flashed(mob/living/carbon/source) + SIGNAL_HANDLER + stop_zoom(source) + +/// Signal proc for [COMSIG_LIVING_STATUS_APPLIED]: going blind ends the zoom. +/obj/item/organ/eyes/robotic/cyberware/proc/on_zoomed_status(mob/living/carbon/source, datum/status_effect/effect) + SIGNAL_HANDLER + if(istype(effect, /datum/status_effect/grouped/blindness)) + stop_zoom(source) + +/// Signal proc for stun, knockdown and paralysis. Mirrors the scope's own check. +/obj/item/organ/eyes/robotic/cyberware/proc/on_zoomed_stunned(mob/living/carbon/source, amount = 0, ignore_canstun = FALSE) + SIGNAL_HANDLER + if(amount > 0) + stop_zoom(source) + +// ---- Clicking through the zoom ------------------------------------------- + +/** + * A click on the zoomed view, swallowed. Returns FALSE only for a click that + * isn't on our zoom, which the caller then handles as normal. + */ +/obj/item/organ/eyes/robotic/cyberware/proc/zoom_click(mob/living/carbon/bearer, atom/movable/screen/fullscreen/cursor_catcher/scope/tracker) + var/datum/component/scope/scope = GetComponent(/datum/component/scope) + if(!is_zoomed() || !scope || scope.tracker != tracker) + return FALSE + if(isgun(bearer.get_active_held_item())) + refuse_zoomed_aim(bearer) + return TRUE + +/** + * Zoomed clicks go to zoom_click() before the client's and the mob's click + * intercepts, so an armed ability never receives the scope's screen object as + * its target. The trait check keeps this to one lookup for everyone else. + */ +/mob/living/carbon/check_click_intercept(params, atom/A) + if(HAS_TRAIT(src, TRAIT_CYBER_ZOOMED) && istype(A, /atom/movable/screen/fullscreen/cursor_catcher/scope)) + var/obj/item/organ/eyes/robotic/cyberware/optics = get_organ_slot(ORGAN_SLOT_EYES) + if(istype(optics) && optics.zoom_click(src, A)) + return TRUE + return ..() + +// ---- The button ----------------------------------------------------------- + +/datum/action/cooldown/cyberware/optics_zoom + name = "Optic Zoom" + desc = "Focus your optics on something far off." + // tg's binoculars: reads as "look far", and stays clear of the Deadeye's crosshair. + button_icon = 'icons/obj/devices/tool.dmi' + button_icon_state = "binoculars" + +/datum/action/cooldown/cyberware/optics_zoom/chrome_wheel_name() + return "Zoom" + +/datum/action/cooldown/cyberware/optics_zoom/Activate(atom/target) + var/obj/item/organ/eyes/robotic/cyberware/optics = organ + if(!istype(optics) || !optics.owner) + return FALSE + if(optics.is_zoomed()) + optics.stop_zoom(optics.owner) + return TRUE + return optics.start_zoom() + +/datum/action/cooldown/cyberware/optics_zoom/is_action_active(atom/movable/screen/movable/action_button/current_button) + var/obj/item/organ/eyes/robotic/cyberware/optics = organ + return istype(optics) && optics.is_zoomed() + +/// The walk tax on cheap optics while they're zoomed. Strength set per optics. +/datum/movespeed_modifier/cyberware_zoom + variable = TRUE diff --git a/voidcrew/modules/cyberware/icons/chrome_cradle_rig.dmi b/voidcrew/modules/cyberware/icons/chrome_cradle_rig.dmi new file mode 100644 index 00000000000..8fb824341d4 Binary files /dev/null and b/voidcrew/modules/cyberware/icons/chrome_cradle_rig.dmi differ diff --git a/voidcrew/modules/cyberware/icons/chrome_hud.dmi b/voidcrew/modules/cyberware/icons/chrome_hud.dmi new file mode 100644 index 00000000000..2b65076978c Binary files /dev/null and b/voidcrew/modules/cyberware/icons/chrome_hud.dmi differ diff --git a/voidcrew/modules/cyberware/icons/chrome_read.dmi b/voidcrew/modules/cyberware/icons/chrome_read.dmi new file mode 100644 index 00000000000..9b3c41a776f Binary files /dev/null and b/voidcrew/modules/cyberware/icons/chrome_read.dmi differ diff --git a/voidcrew/modules/cyberware/icons/chrome_read_bar.dmi b/voidcrew/modules/cyberware/icons/chrome_read_bar.dmi new file mode 100644 index 00000000000..d35b976b5a2 Binary files /dev/null and b/voidcrew/modules/cyberware/icons/chrome_read_bar.dmi differ diff --git a/voidcrew/modules/cyberware/icons/chrome_wheel.dmi b/voidcrew/modules/cyberware/icons/chrome_wheel.dmi new file mode 100644 index 00000000000..a75f826549d Binary files /dev/null and b/voidcrew/modules/cyberware/icons/chrome_wheel.dmi differ diff --git a/voidcrew/modules/cyberware/icons/chrome_wheel_ring.dmi b/voidcrew/modules/cyberware/icons/chrome_wheel_ring.dmi new file mode 100644 index 00000000000..014ab351c38 Binary files /dev/null and b/voidcrew/modules/cyberware/icons/chrome_wheel_ring.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware.dmi b/voidcrew/modules/cyberware/icons/cyberware.dmi index 81028cb0dab..4b1b0b62816 100644 Binary files a/voidcrew/modules/cyberware/icons/cyberware.dmi and b/voidcrew/modules/cyberware/icons/cyberware.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_anim.dmi b/voidcrew/modules/cyberware/icons/cyberware_anim.dmi new file mode 100644 index 00000000000..f0b9f5ebf02 Binary files /dev/null and b/voidcrew/modules/cyberware/icons/cyberware_anim.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_anim2.dmi b/voidcrew/modules/cyberware/icons/cyberware_anim2.dmi new file mode 100644 index 00000000000..2e8607e159e Binary files /dev/null and b/voidcrew/modules/cyberware/icons/cyberware_anim2.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_anim2_large.dmi b/voidcrew/modules/cyberware/icons/cyberware_anim2_large.dmi new file mode 100644 index 00000000000..8004507e5b0 Binary files /dev/null and b/voidcrew/modules/cyberware/icons/cyberware_anim2_large.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_anim_large.dmi b/voidcrew/modules/cyberware/icons/cyberware_anim_large.dmi new file mode 100644 index 00000000000..e5d4d0fa35d Binary files /dev/null and b/voidcrew/modules/cyberware/icons/cyberware_anim_large.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_anim_monowire.dmi b/voidcrew/modules/cyberware/icons/cyberware_anim_monowire.dmi new file mode 100644 index 00000000000..354d6891846 Binary files /dev/null and b/voidcrew/modules/cyberware/icons/cyberware_anim_monowire.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_ground.dmi b/voidcrew/modules/cyberware/icons/cyberware_ground.dmi new file mode 100644 index 00000000000..3762c0e948b Binary files /dev/null and b/voidcrew/modules/cyberware/icons/cyberware_ground.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_lefthand.dmi b/voidcrew/modules/cyberware/icons/cyberware_lefthand.dmi index 8b0d00c3981..3b03a18474e 100644 Binary files a/voidcrew/modules/cyberware/icons/cyberware_lefthand.dmi and b/voidcrew/modules/cyberware/icons/cyberware_lefthand.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_righthand.dmi b/voidcrew/modules/cyberware/icons/cyberware_righthand.dmi index d06dac3ed36..6311eeb6592 100644 Binary files a/voidcrew/modules/cyberware/icons/cyberware_righthand.dmi and b/voidcrew/modules/cyberware/icons/cyberware_righthand.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_weapons.dmi b/voidcrew/modules/cyberware/icons/cyberware_weapons.dmi index ce1bf56b5a1..b18b988f8b8 100644 Binary files a/voidcrew/modules/cyberware/icons/cyberware_weapons.dmi and b/voidcrew/modules/cyberware/icons/cyberware_weapons.dmi differ diff --git a/voidcrew/modules/cyberware/icons/cyberware_worn.dmi b/voidcrew/modules/cyberware/icons/cyberware_worn.dmi index 0e7aaa2e187..8b0bc67e783 100644 Binary files a/voidcrew/modules/cyberware/icons/cyberware_worn.dmi and b/voidcrew/modules/cyberware/icons/cyberware_worn.dmi differ diff --git a/voidcrew/modules/cyberware/ripperdoc_catalog.dm b/voidcrew/modules/cyberware/ripperdoc_catalog.dm index 4dfd8a8e01a..fb69e6550ec 100644 --- a/voidcrew/modules/cyberware/ripperdoc_catalog.dm +++ b/voidcrew/modules/cyberware/ripperdoc_catalog.dm @@ -8,10 +8,12 @@ * * Balance shape mirrors Vex's counter: credits buy the street and pro-utility * ware, vouchers gate everything that changes how you fight. Splice's intake - * ledger buys back ONLY the ladder-base rungs, the street chrome a customer - * outgrows, at half list, credits only, so climbing a slot ladder feels like - * climbing and never becomes an arbitrage loop (you can't refund vouchers, and - * a removed piece resold at 50% is always a loss). + * ledger buys back every piece he sells for credits (owner D7), at half list, + * credits only, so climbing a slot ladder feels like climbing and never becomes + * an arbitrage loop (voucher chrome bought at a counter is never bought back, + * and a removed piece resold at 50% is always a loss). Found chrome with no + * trade-in row (voucher-shelf pieces and loot-only ones) sells on four price + * bands instead, which refuse anything bought at a counter. * * Splice is not the only source any more. The roster also rides the zone loot * tables (modules/loot/themes/) at the tier that matches what he charges for @@ -73,6 +75,33 @@ /datum/shop_sku/ripperdoc/rockjaw, /datum/shop_sku/ripperdoc/fixers, /datum/shop_sku/ripperdoc/dermal_mesh, + /datum/shop_sku/ripperdoc/ghostskin_street, + /datum/shop_sku/ripperdoc/mantis_street, + /datum/shop_sku/ripperdoc/governor_street, + /datum/shop_sku/ripperdoc/redline_street, + /datum/shop_sku/ripperdoc/cascade_street, + // The phase 2 street models, street passives and optics. + /datum/shop_sku/ripperdoc/spyglass, + /datum/shop_sku/ripperdoc/cuffer_wrists, + /datum/shop_sku/ripperdoc/medic_palms, + /datum/shop_sku/ripperdoc/subvocal_mic, + /datum/shop_sku/ripperdoc/fixers_street, + /datum/shop_sku/ripperdoc/muffler_ear, + /datum/shop_sku/ripperdoc/clotter_node, + /datum/shop_sku/ripperdoc/assay_optics, + /datum/shop_sku/ripperdoc/coolant_street, + /datum/shop_sku/ripperdoc/frostline, + /datum/shop_sku/ripperdoc/atlas_street, + /datum/shop_sku/ripperdoc/doppler_street, + /datum/shop_sku/ripperdoc/second_wind_deep, + /datum/shop_sku/ripperdoc/slipwire_street, + /datum/shop_sku/ripperdoc/hopper_street, + /datum/shop_sku/ripperdoc/adrenal_pump, + /datum/shop_sku/ripperdoc/gorilla_street, + /datum/shop_sku/ripperdoc/rockjaw_deepcore, + /datum/shop_sku/ripperdoc/ronin_holdout, + /datum/shop_sku/ripperdoc/longsight, + /datum/shop_sku/ripperdoc/hardweave, // ---- Pro Chrome (mixed) ---- /datum/shop_sku/ripperdoc/angler, /datum/shop_sku/ripperdoc/hemoglass, @@ -90,11 +119,20 @@ /datum/shop_sku/ripperdoc/atlas, /datum/shop_sku/ripperdoc/gorilla, /datum/shop_sku/ripperdoc/monowire, + /datum/shop_sku/ripperdoc/monowire_live, /datum/shop_sku/ripperdoc/rigger, /datum/shop_sku/ripperdoc/slabskin, /datum/shop_sku/ripperdoc/mantis, + /datum/shop_sku/ripperdoc/mantis_scorch, /datum/shop_sku/ripperdoc/ghostskin, /datum/shop_sku/ripperdoc/lazarus, + /datum/shop_sku/ripperdoc/governor_milspec, + /datum/shop_sku/ripperdoc/redline_milspec, + /datum/shop_sku/ripperdoc/cascade_milspec, + /datum/shop_sku/ripperdoc/hopper_milspec, + /datum/shop_sku/ripperdoc/slipwire_milspec, + /datum/shop_sku/ripperdoc/deadeye_milspec, + /datum/shop_sku/ripperdoc/lookout, // ---- Legend Chrome (the chase, always listed) ---- /datum/shop_sku/ripperdoc/governor_delete, /datum/shop_sku/ripperdoc/redline, @@ -104,12 +142,58 @@ /datum/shop_sku/ripperdoc/buster_rockets, ) buyback_types = list( - // The trade-in ladder: only the street rungs a customer outgrows. + // The trade-in ladder: every piece on the shelf priced in credits. /datum/shop_buyback/ripperdoc/nightshade, /datum/shop_buyback/ripperdoc/shock_coils, /datum/shop_buyback/ripperdoc/second_wind, /datum/shop_buyback/ripperdoc/dermal_mesh, /datum/shop_buyback/ripperdoc/scrapper, + // The cyberware lines' street models (ware_line_*.dm). + /datum/shop_buyback/ripperdoc/ghostskin_street, + /datum/shop_buyback/ripperdoc/mantis_street, + /datum/shop_buyback/ripperdoc/governor_street, + /datum/shop_buyback/ripperdoc/redline_street, + /datum/shop_buyback/ripperdoc/cascade_street, + // The phase 2 street models, street passives and optics. + /datum/shop_buyback/ripperdoc/spyglass, + /datum/shop_buyback/ripperdoc/cuffer_wrists, + /datum/shop_buyback/ripperdoc/medic_palms, + /datum/shop_buyback/ripperdoc/subvocal_mic, + /datum/shop_buyback/ripperdoc/fixers_street, + /datum/shop_buyback/ripperdoc/muffler_ear, + /datum/shop_buyback/ripperdoc/clotter_node, + /datum/shop_buyback/ripperdoc/assay_optics, + /datum/shop_buyback/ripperdoc/coolant_street, + /datum/shop_buyback/ripperdoc/frostline, + /datum/shop_buyback/ripperdoc/atlas_street, + /datum/shop_buyback/ripperdoc/doppler_street, + /datum/shop_buyback/ripperdoc/second_wind_deep, + /datum/shop_buyback/ripperdoc/slipwire_street, + /datum/shop_buyback/ripperdoc/hopper_street, + /datum/shop_buyback/ripperdoc/adrenal_pump, + /datum/shop_buyback/ripperdoc/gorilla_street, + /datum/shop_buyback/ripperdoc/rockjaw_deepcore, + /datum/shop_buyback/ripperdoc/ronin_holdout, + /datum/shop_buyback/ripperdoc/longsight, + /datum/shop_buyback/ripperdoc/hardweave, + // The rest of the credit shelf (owner D7). + /datum/shop_buyback/ripperdoc/hopper, + /datum/shop_buyback/ripperdoc/coolant, + /datum/shop_buyback/ripperdoc/fixers, + /datum/shop_buyback/ripperdoc/rockjaw, + /datum/shop_buyback/ripperdoc/gecko, + /datum/shop_buyback/ripperdoc/hemoglass, + /datum/shop_buyback/ripperdoc/angler, + /datum/shop_buyback/ripperdoc/registry_uplink, + /datum/shop_buyback/ripperdoc/cargo_cavity, + /datum/shop_buyback/ripperdoc/gastro, + /datum/shop_buyback/ripperdoc/chromatic_dermis, + /datum/shop_buyback/burnt_chrome, + // Found chrome that has no trade-in row, by price band. + /datum/shop_buyback/found_chrome/fitted, + /datum/shop_buyback/found_chrome/pro, + /datum/shop_buyback/found_chrome/military, + /datum/shop_buyback/found_chrome/legend, ) trader_lines = list( TRADER_LINE_GREETING = list( @@ -444,7 +528,7 @@ /datum/shop_sku/ripperdoc/cascade zone_permission = ZONE_PERMISSION_ELITE category = "Legend Chrome" - desc = "A Sandevistan reflex lattice in a sealed surgical case." + desc = "A full-spine reflex lattice in a sealed surgical case." item_path = /obj/item/organ/cyberimp/cyberware/cascade price_vouchers = 8 stock_min = 1 @@ -476,11 +560,21 @@ // ========================================================================= // SPLICE'S INTAKE LEDGER: the trade-in ladder -// Half list, credits only, street rungs only. Removed chrome resold here is +// Half list, credits only, credit-priced chrome only. Removed chrome resold here is // always a loss (you can't refund vouchers, and 50% never beats buying up the // ladder), so this reads as "trade up" and never as an arbitrage loop. +// +// The ripperdoc trade-in is the one ledger that takes chrome bought over a +// counter (owner decision, 2026-11-07): every other buyer and every export +// refuses anything carrying the trader-goods mark (trade/resale.dm). It holds +// because each entry pays half the lowest list price of the piece and a special +// takes at most 30% off, so a bought piece always sells back at a loss. The +// voidcrew_ripperdoc_resale unit test pins both halves of that. // ========================================================================= +/datum/shop_buyback/ripperdoc + buys_shop_stock = TRUE + /datum/shop_buyback/ripperdoc/nightshade name = "Nightshade Optics (pulled)" desc = "Old low-light eyes. Splice takes them off your hands when you move up to a targeting rig." @@ -492,7 +586,7 @@ /datum/shop_buyback/ripperdoc/shock_coils name = "Shock Coils (pulled)" - desc = "Reflex legs, lightly used. Trade-in credit toward the jump pistons." + desc = "Reflex legs, lightly used." category = "Trade-In" item_path = /obj/item/organ/cyberimp/cyberware/shock_coils pay_credits = 250 @@ -501,9 +595,11 @@ /datum/shop_buyback/ripperdoc/second_wind name = "Second Wind Bladder (pulled)" - desc = "A used air reserve. Worth half toward something with a longer bladder." + desc = "A used air reserve." category = "Trade-In" item_path = /obj/item/organ/cyberimp/cyberware/second_wind + // The Deep-lung is a subtype with its own, higher entry (ware_models_b.dm). + match_subtypes = FALSE pay_credits = 450 demand_min = 2 demand_max = 3 @@ -513,6 +609,8 @@ desc = "Light plating you've outgrown. Splice recycles the weave toward the heavy slab." category = "Trade-In" item_path = /obj/item/organ/cyberimp/cyberware/dermal_mesh + // The Hardweave is a subtype with its own, higher entry (ware_models_b.dm). + match_subtypes = FALSE pay_credits = 1000 demand_min = 1 demand_max = 2 @@ -526,3 +624,244 @@ pay_credits = 200 demand_min = 2 demand_max = 4 + +// ========================================================================= +// THE REST OF THE CREDIT SHELF (owner D7): every piece he sells for credits +// comes back at half list, credits only. Exact types, so a ladder rung above +// or below (Spring calves, Vaulter, Tinker's, Deepcore, Heat-sink) keeps its +// own entry or none. Ratchet's subtypes carry his wording. +// ========================================================================= + +/datum/shop_buyback/ripperdoc/hopper + name = "Hopper piston calves (pulled)" + desc = "Piston calves, still sprung." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/hopper + match_subtypes = FALSE + pay_credits = 1800 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/coolant + name = "Coolant Loop lattice (pulled)" + desc = "A drained coolant lattice." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/coolant + match_subtypes = FALSE + pay_credits = 1800 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/fixers + name = "Fixer's Fingers (pulled)" + desc = "A fingertip tool suite, pulled." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers + match_subtypes = FALSE + pay_credits = 900 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/rockjaw + name = "Rockjaw drill fist (pulled)" + desc = "A drill fist with plenty of bit left." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw + match_subtypes = FALSE + pay_credits = 600 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/gecko + name = "Gecko Grip palm pads (pulled)" + desc = "Palm pads, a bit worn." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/gecko + match_subtypes = FALSE + pay_credits = 450 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/hemoglass + name = "Hemoglass filter (pulled)" + desc = "A blood filter, flushed." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/hemoglass + match_subtypes = FALSE + pay_credits = 600 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/angler + name = "Harpoon Spool (pulled)" + desc = "A wrist spool and its line." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/angler + match_subtypes = FALSE + pay_credits = 600 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/registry_uplink + name = "Registry uplink (pulled)" + desc = "A registry uplink, pulled." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/registry_uplink + match_subtypes = FALSE + pay_credits = 600 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/cargo_cavity + name = "Cargo Cavity (pulled)" + desc = "An empty rib compartment." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/cargo_cavity + match_subtypes = FALSE + pay_credits = 500 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/gastro + name = "Gastro Reactor (pulled)" + desc = "A used stomach liner." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/gastro + match_subtypes = FALSE + pay_credits = 200 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/chromatic_dermis + name = "Chromatic Dermis ink suite (pulled)" + desc = "A sheet of circuit ink, peeled." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/chromatic_dermis + match_subtypes = FALSE + pay_credits = 200 + demand_min = 2 + demand_max = 3 + +/** + * Dead chrome off a dead (or opened-up) human NPC (/obj/item/burnt_chrome, human_npc.dm). Scrap money only: + * 50 cr is a fifth of the cheapest piece Splice sells for credits, so burning out bought chrome in a captive + * to sell the husk is always a loss, and the round's demand caps it. Not a ripperdoc trade-in row: those + * buy back shelf stock, and no shelf sells burnt chrome. + */ +/datum/shop_buyback/burnt_chrome + name = "Burnt-out chrome" + desc = "Dead implants. Splice strips them for the parts that didn't melt." + category = "Scrap" + item_path = /obj/item/burnt_chrome + pay_credits = 50 + demand_min = 4 + demand_max = 8 + +/datum/shop_buyback/burnt_chrome/street_doc + desc = "Dead implants. Ratchet melts them down for the metal." + +// ========================================================================= +// FOUND CHROME: the pieces no trade-in row takes +// Voucher-shelf chrome and loot-only chrome, out of caches or off the dead. +// Priced by band against the shelf: 1-voucher pieces pay 400 cr, 2-voucher +// pieces 900 cr (a paired arm counts as half its pair), 3-voucher and dearer +// pieces 1 voucher, the loot-only Piledriver 2. Each band names exact types, +// none of which any trade-in row matches, so no piece fits two rows. +// +// Not a /datum/shop_buyback/ripperdoc subtype on purpose: those take shop +// stock and pay credits only (voidcrew_ripperdoc_resale pins that). These +// refuse anything bought at a counter, so a voucher payout here only ever +// buys chrome nobody paid a shop for. +// ========================================================================= + +/datum/shop_buyback/found_chrome + category = "Found Chrome" + item_path = /obj/item/organ + icon_override = 'voidcrew/modules/cyberware/icons/cyberware.dmi' + /// Exact chrome types this band pays for + var/list/wanted_chrome + +/datum/shop_buyback/found_chrome/buyback_wanted_kind(obj/item/offered) + return (offered.type in wanted_chrome) && !shop_buyback_inside_body(offered) + +/datum/shop_buyback/found_chrome/matches(obj/item/offered) + if(!..() || !(offered.type in wanted_chrome)) + return FALSE + var/obj/item/organ/ware = offered + return !(ware.organ_flags & ORGAN_FAILING) + +/// The stock refusal keys off item_path, which here is every organ (buyback_listed.dm). +/datum/shop_buyback/found_chrome/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +/datum/shop_buyback/found_chrome/fitted + name = "fitted chrome" + desc = "Icepicks, sonar, field optics, grave hooks. Clean them up and they sell again." + icon_state_override = "icepick" + wanted_chrome = list( + /obj/item/organ/cyberimp/arm/toolkit/cyberware/icepick, + /obj/item/organ/cyberimp/cyberware/doppler, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/graverobber, + /obj/item/organ/eyes/robotic/cyberware/prospector, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/skyhook, + ) + pay_credits = 400 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/found_chrome/pro + name = "pro chrome" + desc = "Combat optics, reflex wiring, one arm of a matched pair. Splice knows who's shopping." + icon_state_override = "mantis" + wanted_chrome = list( + /obj/item/organ/eyes/robotic/cyberware/deadeye, + /obj/item/organ/cyberimp/cyberware/slipwire, + /obj/item/organ/cyberimp/cyberware/dead_channel, + /obj/item/organ/cyberimp/cyberware/atlas, + /obj/item/organ/cyberimp/cyberware/gorilla_arms, + /obj/item/organ/cyberimp/cyberware/gorilla_arms/left, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left, + ) + pay_credits = 900 + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/found_chrome/military + name = "military chrome" + desc = "Monowire, gun arms, slab plating, milspec builds. The big names too, if they still work." + icon_state_override = "ronin" + wanted_chrome = list( + /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/bunker_buster, + /obj/item/organ/cyberimp/cyberware/rigger, + /obj/item/organ/cyberimp/cyberware/slabskin, + /obj/item/organ/cyberimp/cyberware/ghostskin, + /obj/item/organ/cyberimp/cyberware/lazarus, + /obj/item/organ/eyes/robotic/cyberware/lookout, + /obj/item/organ/eyes/robotic/cyberware/deadeye/milspec, + /obj/item/organ/cyberimp/cyberware/slipwire/milspec, + /obj/item/organ/cyberimp/cyberware/hopper/milspec, + /obj/item/organ/cyberimp/cyberware/governor_delete/milspec, + /obj/item/organ/cyberimp/cyberware/redline/milspec, + /obj/item/organ/cyberimp/cyberware/cascade/milspec, + /obj/item/organ/cyberimp/cyberware/governor_delete, + /obj/item/organ/cyberimp/cyberware/redline, + /obj/item/organ/cyberimp/cyberware/cascade, + ) + pay_vouchers = 1 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/found_chrome/legend + name = "Piledriver" + desc = "Splice has never had one on the bench. He'd like to." + icon_state_override = "piledriver" + wanted_chrome = list(/obj/item/organ/cyberimp/cyberware/piledriver) + pay_vouchers = 2 + demand_min = 1 + demand_max = 1 diff --git a/voidcrew/modules/cyberware/street_doc_catalog.dm b/voidcrew/modules/cyberware/street_doc_catalog.dm new file mode 100644 index 00000000000..fbad68fc114 --- /dev/null +++ b/voidcrew/modules/cyberware/street_doc_catalog.dm @@ -0,0 +1,286 @@ +/** + * # The Back Bay: Ratchet, street ripperdoc + * + * Quartermain's chrome counter: a vendor stall in a storage bay off the depot's + * upper landing, with its own Chrome Cradle. Ratchet is a loader mechanic who + * started putting chrome in people, and the shelf shows it: street chrome only, + * nothing that needs a voucher. + * + * He lists the SAME /datum/shop_sku/ripperdoc types Splice does, not copies. + * Each shop builds its own SKU instances, so his stock is his own, but the + * price of a piece can never drift between the two counters. That matters + * because the cradle quotes one price per organ type + * (build_cyberware_price_index() in cradle_ui.dm), and because + * voidcrew_zone_shops/catalog pins the reputation gate of every SKU type that + * exists, so a parallel set of street-doc SKU types would need its own + * entries there for no gain. + * + * His intake ledger takes everything Splice's does at the same pay, even the + * credit chrome only Splice sells + * (subtypes of Splice's buybacks, with his own wording). Like Splice's, and + * unlike every other ledger, it takes chrome bought at a counter and pulled + * again (buys_shop_stock on /datum/shop_buyback/ripperdoc, ripperdoc_catalog.dm). + * Of Splice's found-chrome bands he runs only the two that pay credits: his + * counter never deals in vouchers either way. + * + * Catalog and NPC only: the organs live in ware_*.dm, the cradle in + * chrome_cradle.dm, the room on the Quartermain map + * (trader_outpost_outfitter.dmm). The NPC is a subtype of Splice's so the + * cradle's install patter (play_ripperdoc_bark()) comes out of his mouth. + */ + +/** + * Ratchet's look: a black robotics jumpsuit under a leather wader bib, the + * kind you hose down. Insulated gloves because half the job is wiring, welding + * goggles pushed up because the other half is welding, a hand-rolled cigarette, + * and a hand drill he uses on loaders and patients alike. Kept clear of Splice + * (no scrubs, no leather jacket) and of Sawbones (no head mirror). + * Purely cosmetic, the NPC snapshot only copies appearance. + */ +/datum/outfit/street_doc_ratchet + name = "Street ripperdoc" + uniform = /obj/item/clothing/under/rank/rnd/roboticist + suit = /obj/item/clothing/suit/apron/waders + gloves = /obj/item/clothing/gloves/color/yellow + shoes = /obj/item/clothing/shoes/workboots + glasses = /obj/item/clothing/glasses/welding/up + mask = /obj/item/cigarette/rollie + r_hand = /obj/item/screwdriver/power + +/datum/outpost_shop/vendor/street_doc + outpost_name = "\improper The Back Bay" + outpost_desc = "The depot's ripperdoc, in a storage bay he rents by the week." + trader_name = "Ratchet" + trader_outfit = /datum/outfit/street_doc_ratchet + trader_gender = MALE + trader_voice_pack = "goon.speak_3" + trader_voice_pitch = 0.88 + // A SKU whose category is missing here never renders on the storefront + // (voidcrew_shop_catalog checks it). Add the line models' category if it + // is not "Street Chrome". + categories = list( + "Street Chrome", + ) + sku_types = list( + // ---- Street Chrome (credits), Splice's own SKU types ---- + /datum/shop_sku/ripperdoc/chromatic_dermis, + /datum/shop_sku/ripperdoc/gastro, + /datum/shop_sku/ripperdoc/shock_coils, + /datum/shop_sku/ripperdoc/nightshade, + /datum/shop_sku/ripperdoc/scrapper, + /datum/shop_sku/ripperdoc/gecko, + /datum/shop_sku/ripperdoc/second_wind, + /datum/shop_sku/ripperdoc/cargo_cavity, + /datum/shop_sku/ripperdoc/rockjaw, + /datum/shop_sku/ripperdoc/fixers, + /datum/shop_sku/ripperdoc/dermal_mesh, + // ---- Street models from the cyberware lines (credit-priced T2) ---- + // CYBERWARE LINES: T2 SKUS START + /datum/shop_sku/ripperdoc/ghostskin_street, + /datum/shop_sku/ripperdoc/mantis_street, + /datum/shop_sku/ripperdoc/governor_street, + /datum/shop_sku/ripperdoc/redline_street, + /datum/shop_sku/ripperdoc/cascade_street, + // Phase 2: the street models, street passives and optics. Nothing + // priced in vouchers belongs here. + /datum/shop_sku/ripperdoc/spyglass, + /datum/shop_sku/ripperdoc/cuffer_wrists, + /datum/shop_sku/ripperdoc/medic_palms, + /datum/shop_sku/ripperdoc/subvocal_mic, + /datum/shop_sku/ripperdoc/fixers_street, + /datum/shop_sku/ripperdoc/muffler_ear, + /datum/shop_sku/ripperdoc/clotter_node, + /datum/shop_sku/ripperdoc/assay_optics, + /datum/shop_sku/ripperdoc/coolant_street, + /datum/shop_sku/ripperdoc/frostline, + /datum/shop_sku/ripperdoc/atlas_street, + /datum/shop_sku/ripperdoc/doppler_street, + /datum/shop_sku/ripperdoc/second_wind_deep, + /datum/shop_sku/ripperdoc/slipwire_street, + /datum/shop_sku/ripperdoc/hopper_street, + /datum/shop_sku/ripperdoc/adrenal_pump, + /datum/shop_sku/ripperdoc/gorilla_street, + /datum/shop_sku/ripperdoc/rockjaw_deepcore, + /datum/shop_sku/ripperdoc/ronin_holdout, + /datum/shop_sku/ripperdoc/longsight, + /datum/shop_sku/ripperdoc/hardweave, + // CYBERWARE LINES: T2 SKUS END + ) + buyback_types = list( + /datum/shop_buyback/burnt_chrome/street_doc, + /datum/shop_buyback/ripperdoc/nightshade/street_doc, + /datum/shop_buyback/ripperdoc/shock_coils/street_doc, + /datum/shop_buyback/ripperdoc/second_wind/street_doc, + /datum/shop_buyback/ripperdoc/dermal_mesh/street_doc, + /datum/shop_buyback/ripperdoc/scrapper/street_doc, + // CYBERWARE LINES: T2 BUYBACKS START + /datum/shop_buyback/ripperdoc/ghostskin_street/street_doc, + /datum/shop_buyback/ripperdoc/mantis_street/street_doc, + /datum/shop_buyback/ripperdoc/governor_street/street_doc, + /datum/shop_buyback/ripperdoc/redline_street/street_doc, + /datum/shop_buyback/ripperdoc/cascade_street/street_doc, + /datum/shop_buyback/ripperdoc/spyglass/street_doc, + /datum/shop_buyback/ripperdoc/cuffer_wrists/street_doc, + /datum/shop_buyback/ripperdoc/medic_palms/street_doc, + /datum/shop_buyback/ripperdoc/subvocal_mic/street_doc, + /datum/shop_buyback/ripperdoc/fixers_street/street_doc, + /datum/shop_buyback/ripperdoc/muffler_ear/street_doc, + /datum/shop_buyback/ripperdoc/clotter_node/street_doc, + /datum/shop_buyback/ripperdoc/assay_optics/street_doc, + /datum/shop_buyback/ripperdoc/coolant_street/street_doc, + /datum/shop_buyback/ripperdoc/frostline/street_doc, + /datum/shop_buyback/ripperdoc/atlas_street/street_doc, + /datum/shop_buyback/ripperdoc/doppler_street/street_doc, + /datum/shop_buyback/ripperdoc/second_wind_deep/street_doc, + /datum/shop_buyback/ripperdoc/slipwire_street/street_doc, + /datum/shop_buyback/ripperdoc/hopper_street/street_doc, + /datum/shop_buyback/ripperdoc/adrenal_pump/street_doc, + /datum/shop_buyback/ripperdoc/gorilla_street/street_doc, + /datum/shop_buyback/ripperdoc/rockjaw_deepcore/street_doc, + /datum/shop_buyback/ripperdoc/ronin_holdout/street_doc, + /datum/shop_buyback/ripperdoc/longsight/street_doc, + /datum/shop_buyback/ripperdoc/hardweave/street_doc, + // CYBERWARE LINES: T2 BUYBACKS END + // The rest of Splice's credit shelf, which Ratchet buys back even where he + // doesn't sell it (owner D7). + /datum/shop_buyback/ripperdoc/hopper/street_doc, + /datum/shop_buyback/ripperdoc/coolant/street_doc, + /datum/shop_buyback/ripperdoc/fixers/street_doc, + /datum/shop_buyback/ripperdoc/rockjaw/street_doc, + /datum/shop_buyback/ripperdoc/gecko/street_doc, + /datum/shop_buyback/ripperdoc/hemoglass/street_doc, + /datum/shop_buyback/ripperdoc/angler/street_doc, + /datum/shop_buyback/ripperdoc/registry_uplink/street_doc, + /datum/shop_buyback/ripperdoc/cargo_cavity/street_doc, + /datum/shop_buyback/ripperdoc/gastro/street_doc, + /datum/shop_buyback/ripperdoc/chromatic_dermis/street_doc, + // Found chrome with no trade-in row, on Splice's credit bands only. + /datum/shop_buyback/found_chrome/fitted/street_doc, + /datum/shop_buyback/found_chrome/pro/street_doc, + ) + trader_lines = list( + TRADER_LINE_GREETING = list( + "Shut the door, you're letting the good air out.", + "Chair's free. The chrome isn't.", + "Don't mind the bucket.", + "You want it fancy, the Undertow's that way. You want it today, sit down.", + ), + TRADER_LINE_SALE = list( + "Done. Lie down whenever you're ready.", + "Good pick. I've put in a hundred of those. Most of them still work.", + "Wipe the slab before you lie on it.", + "Pleasure doing business.", + "There you go. Don't tell Sarge what you paid.", + ), + TRADER_LINE_REFUSAL = list( + "Your ship's on the list. Can't help you.", + "Not today. Sarge would have my bay.", + "No. Go square it with the depot first.", + ), + TRADER_LINE_WARNING = list( + "Easy. The turrets in here don't miss.", + "Do that again and the whole depot stops serving you.", + "I patch people up. I'd rather not start with you.", + ), + TRADER_LINE_AGGRESSION = list( + "Out of my bay!", + "Sarge! Got one for you!", + "Wrong guy to swing at.", + ), + TRADER_LINE_IDLE = list( + "That cradle came off a wreck. Don't ask whose.", + "Splice has the nicer chair. I've got the shorter flight.", + "I used to fix loaders. An arm's just a small loader.", + "The drain in the floor? Don't worry about the drain.", + "Most of my customers come back. Some of them on purpose.", + "The dockhands keep asking for discounts. I keep saying no.", + ), + TRADER_LINE_RESTOCK = list( + "Convoy's in. New chrome, some of it barely used.", + "Fresh crate. Still smells like the last owner.", + "Restocked. Get in before the dockhands do.", + ), + ) + +// ========================================================================= +// RATCHET'S INTAKE LEDGER +// Splice's ledger entries with Ratchet's wording. Same goods, same pay. +// ========================================================================= + +/datum/shop_buyback/ripperdoc/nightshade/street_doc + desc = "Used low-light eyes." + +/datum/shop_buyback/ripperdoc/shock_coils/street_doc + desc = "Used calf pistons." + +/datum/shop_buyback/ripperdoc/second_wind/street_doc + desc = "A used air bladder." + +/datum/shop_buyback/ripperdoc/dermal_mesh/street_doc + desc = "Used subdermal plating." + +/datum/shop_buyback/ripperdoc/scrapper/street_doc + desc = "One used knuckle plate, either hand." + +/datum/shop_buyback/ripperdoc/ghostskin_street/street_doc + desc = "A used camo weave. Patchy, like they all are." + +/datum/shop_buyback/ripperdoc/mantis_street/street_doc + desc = "One used blade housing, either arm." + +/datum/shop_buyback/ripperdoc/governor_street/street_doc + desc = "A used governor patch. The tape's still on it." + +/datum/shop_buyback/ripperdoc/redline_street/street_doc + desc = "A used rage core. Smells burnt." + +/datum/shop_buyback/ripperdoc/cascade_street/street_doc + desc = "A used spinal rig, held together with tape." + +/datum/shop_buyback/ripperdoc/hopper/street_doc + desc = "Used piston calves." + +/datum/shop_buyback/ripperdoc/coolant/street_doc + desc = "A coolant lattice, drained." + +/datum/shop_buyback/ripperdoc/fixers/street_doc + desc = "Used fingertip tools." + +/datum/shop_buyback/ripperdoc/rockjaw/street_doc + desc = "A used drill fist." + +/datum/shop_buyback/ripperdoc/gecko/street_doc + desc = "Worn palm pads." + +/datum/shop_buyback/ripperdoc/hemoglass/street_doc + desc = "A used blood filter." + +/datum/shop_buyback/ripperdoc/angler/street_doc + desc = "A wrist harpoon, line and all." + +/datum/shop_buyback/ripperdoc/registry_uplink/street_doc + desc = "A used registry uplink." + +/datum/shop_buyback/ripperdoc/cargo_cavity/street_doc + desc = "An empty rib pocket." + +/datum/shop_buyback/ripperdoc/gastro/street_doc + desc = "A stomach liner, scrubbed. Mostly." + +/datum/shop_buyback/ripperdoc/chromatic_dermis/street_doc + desc = "Old circuit ink." + +/datum/shop_buyback/found_chrome/fitted/street_doc + desc = "Tool arms and field optics, pulled. He'll find them a new home." + +/datum/shop_buyback/found_chrome/pro/street_doc + desc = "Combat chrome, pulled. One blade or one fist is fine." + +// ========================================================================= +// THE NPC +// ========================================================================= + +/// Ratchet behind his counter. A ripperdoc subtype, so the cradle in his bay +/// talks through him during installs. +/mob/living/basic/outpost_trader/ripperdoc/street_doc + shop_type = /datum/outpost_shop/vendor/street_doc diff --git a/voidcrew/modules/cyberware/ware_arm_utility.dm b/voidcrew/modules/cyberware/ware_arm_utility.dm index 1c64088dd28..4b0bdaeec19 100644 --- a/voidcrew/modules/cyberware/ware_arm_utility.dm +++ b/voidcrew/modules/cyberware/ware_arm_utility.dm @@ -29,7 +29,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw name = "\improper Rockjaw drill fist" - desc = "A compact mining drill that folds out of the forearm. Anything it cracks gets vacuumed straight into an internal hopper, so you aren't crawling around the floor picking up your own ore." + desc = "A compact mining drill that folds out of the forearm, with a hopper that swallows whatever it cracks." icon_state = "rockjaw" chrome_load = 2 tier = CYBERWARE_TIER_1 @@ -58,7 +58,7 @@ /// diamond drill (0.2). The speed is part of what the 1,200 cr buys. /obj/item/pickaxe/drill/cyberware name = "rockjaw drill" - desc = "The business end of a Rockjaw drill fist. It only comes off the arm at a Chrome Cradle." + desc = "The business end of a Rockjaw drill fist." toolspeed = 0.5 /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/Destroy() @@ -160,7 +160,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers name = "\improper Fixer's Fingers" - desc = "A fingertip omnitool suite. Driver, wrench and cutters fold out of the knuckles, and the servo tendons behind them make everything you do with your hands quicker." + desc = "A fingertip omnitool suite. Driver, wrench and cutters fold out of the knuckles on quick servo tendons." icon_state = "fixers" chrome_load = 2 tier = CYBERWARE_TIER_1 @@ -170,6 +170,9 @@ /obj/item/wrench/cyborg, /obj/item/wirecutters/cyborg, ) + /// The action-speed modifier the servo tendons apply while the ware is running. + /// The model in the line (ware_line_models_a.dm) swaps in a weaker one. + var/datum/actionspeed_modifier/speed_modifier = /datum/actionspeed_modifier/cyberware_fixers // The tool-speed bonus rides the failing-gated passive layer (BAL-4): servo // tendons with an EMP reboot or a brownout are just fingers until the ware @@ -177,10 +180,10 @@ // idempotent and needs no applied-state guard. /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/chrome_passives_on(mob/living/carbon/bearer) . = ..() - bearer?.add_actionspeed_modifier(/datum/actionspeed_modifier/cyberware_fixers) + bearer?.add_actionspeed_modifier(speed_modifier) /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/chrome_passives_off(mob/living/carbon/bearer) . = ..() - bearer?.remove_actionspeed_modifier(/datum/actionspeed_modifier/cyberware_fixers) + bearer?.remove_actionspeed_modifier(speed_modifier) #undef CYBERWARE_ROCKJAW_SWEEP_DELAY diff --git a/voidcrew/modules/cyberware/ware_legend.dm b/voidcrew/modules/cyberware/ware_legend.dm index db50e79d8c2..58e909208b7 100644 --- a/voidcrew/modules/cyberware/ware_legend.dm +++ b/voidcrew/modules/cyberware/ware_legend.dm @@ -19,13 +19,19 @@ #define CYBERWARE_CASCADE_WINDOW (8 SECONDS) /// The price. #define CYBERWARE_CASCADE_CRASH (6 SECONDS) -/// Ranged dodge chance while moving during the window (shared arbiter; -/// highest-wins with Slipwire's 15, never additive). -#define CYBERWARE_CASCADE_DODGE_CHANCE 40 +/// Dodge chance during the window (shared arbiter; highest-wins with +/// Slipwire's 15, never additive): ranged fire while moving, blows any time. +#define CYBERWARE_CASCADE_DODGE_CHANCE 60 +/// Crit roll bonus for the bearer's own aimed hits during the window (crit_roll.dm). +#define CYBERWARE_CASCADE_CRIT_BONUS 18 /// Stamina dumped by the crash. #define CYBERWARE_CASCADE_CRASH_STAMINA 80 /// Degrees the afterimage hue moves per step of the trail. #define CYBERWARE_CASCADE_HUE_STEP 25 +/// Melee-cooldown multiplier during the window (lower is faster). +#define CYBERWARE_CASCADE_MELEE_MULT 0.5 +/// Starting opacity of a trail afterimage. +#define CYBERWARE_CASCADE_AFTERIMAGE_ALPHA 200 /** * # Cascade Lattice (T4, chest, OS slot, load 12) @@ -33,18 +39,24 @@ * The sandevistan-class flagship. Eight seconds where the world happens at * your speed: a full -1 gait (with reagent-modifier immunity for the * duration, no meth stacking, no sub-tick movement), melee cooldowns - * halved, and 40% ranged dodge while moving through the shared arbiter in - * ware_pro_combat.dm. Everyone nearby sees it: afterimages peel off every + * halved, 60% dodge through the shared arbiter in ware_pro_combat.dm (ranged + * fire while moving, blows whether moving or not), and +18 on the crit roll + * for the bearer's own aimed hits (crit_roll.dm). Everyone nearby sees it: afterimages peel off every * step, your victim's screen never had a chance, and the activation is an * audible time-tear. * * Then the heat bill: six seconds of crash, heavy stamina dump, leaden * slowdown, zero dodge. An EMP during the window skips straight to the * crash and re-arms the full sixty-second cooldown. + * + * Every number the window and the crash run on is a var here, so the lesser + * models in ware_line_sandy.dm retune by setting vars and swapping the action + * for a slower one. The status effects copy the numbers off the organ when the + * button is pressed and hold no reference back to it. */ /obj/item/organ/cyberimp/cyberware/cascade name = "\improper Cascade lattice" - desc = "A full-spine lattice of superconducting myelin, a real sandevistan, not one of the knockoffs. For eight seconds at a time you move and nobody else really does. Then all the heat it just made has to go somewhere, and it goes into you." + desc = "A full-spine lattice of superconducting myelin, the real thing, not one of the knockoffs. The bill comes afterward." icon_state = "cascade" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_OS @@ -54,6 +66,30 @@ aug_overlay = "cascade" emissive_overlay = TRUE actions_types = list(/datum/action/cooldown/cyberware/cascade_surge) + /// How long the window lasts. + var/window_duration = CYBERWARE_CASCADE_WINDOW + /// How long the crash lasts once the window ends. + var/crash_duration = CYBERWARE_CASCADE_CRASH + /// Stamina dumped on the bearer by the crash. + var/crash_stamina = CYBERWARE_CASCADE_CRASH_STAMINA + /// Dodge chance during the window: ranged fire while moving, blows any time. + var/window_dodge = CYBERWARE_CASCADE_DODGE_CHANCE + /// Crit roll bonus for the bearer's own aimed hits during the window. + var/window_crit_bonus = CYBERWARE_CASCADE_CRIT_BONUS + /// The gait the window grants. + var/datum/movespeed_modifier/window_speed = /datum/movespeed_modifier/cyberware_cascade + /// Melee-cooldown multiplier during the window (lower is faster). + var/window_melee_mult = CYBERWARE_CASCADE_MELEE_MULT + /// The bearer's screen tint during the window. + var/datum/client_colour/window_colour = /datum/client_colour/cyberware_cascade + /// A trail afterimage is left on every Nth step. + var/afterimage_interval = 1 + /// Starting opacity of a trail afterimage. + var/afterimage_alpha = CYBERWARE_CASCADE_AFTERIMAGE_ALPHA + /// The status alert shown while the window runs. + var/window_alert = /atom/movable/screen/alert/status_effect/cyberware_cascade + /// What the bearer reads on activation. + var/online_message = "CASCADE ONLINE." /obj/item/organ/cyberimp/cyberware/cascade/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() @@ -83,7 +119,7 @@ /datum/action/cooldown/cyberware/cascade_surge name = "Cascade Surge" - desc = "Eight seconds of overwhelming speed: melee cooldowns halved, 40% chance to dodge ranged fire while moving. Then six seconds of crash. An EMP mid-window crashes you instantly." + desc = "Eight seconds of overwhelming speed: melee cooldowns halved, hits land harder, and a 60% chance to dodge blows, or ranged fire on the move. Then six seconds of crash." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "act_cascade" cooldown_time = 60 SECONDS @@ -97,7 +133,8 @@ surger.balloon_alert(surger, "lattice still cycling!") return FALSE StartCooldown() - surger.apply_status_effect(/datum/status_effect/cyberware_cascade_window) + // The lattice hands the window its numbers (an organ-less call falls back to the T4 defaults). + surger.apply_status_effect(/datum/status_effect/cyberware_cascade_window, organ) return TRUE /** @@ -112,40 +149,86 @@ alert_type = /atom/movable/screen/alert/status_effect/cyberware_cascade /// Hue of the next afterimage, in degrees. Starts random so no two surges match. var/trail_hue = 0 + // The numbers below default to the T4 lattice and are overwritten from the + // organ that opened the window (see on_creation). Copied, never referenced. + /// Dodge chance while the window lives: ranged fire while moving, blows any time. + var/dodge_chance = CYBERWARE_CASCADE_DODGE_CHANCE + /// Crit roll bonus for the bearer's own aimed hits while the window lives. + var/crit_bonus = CYBERWARE_CASCADE_CRIT_BONUS + /// The gait the window grants. + var/datum/movespeed_modifier/speed_type = /datum/movespeed_modifier/cyberware_cascade + /// Melee-cooldown multiplier (lower is faster). + var/melee_mult = CYBERWARE_CASCADE_MELEE_MULT + /// The bearer's screen tint. + var/datum/client_colour/colour_type = /datum/client_colour/cyberware_cascade + /// A trail afterimage is left on every Nth step. + var/afterimage_interval = 1 + /// Starting opacity of a trail afterimage. + var/afterimage_alpha = CYBERWARE_CASCADE_AFTERIMAGE_ALPHA + /// What the bearer reads on activation. + var/online_message = "CASCADE ONLINE." + /// The crash this window rolls into. + var/crash_duration = CYBERWARE_CASCADE_CRASH + var/crash_stamina = CYBERWARE_CASCADE_CRASH_STAMINA + /// Steps taken so far, for the afterimage cadence. + var/steps_taken = 0 + +/// Optional second argument: the lattice whose numbers this window runs on. +/datum/status_effect/cyberware_cascade_window/on_creation(mob/living/new_owner, obj/item/organ/cyberimp/cyberware/cascade/lattice) + if(istype(lattice)) + duration = lattice.window_duration + alert_type = lattice.window_alert + dodge_chance = lattice.window_dodge + crit_bonus = lattice.window_crit_bonus + speed_type = lattice.window_speed + melee_mult = lattice.window_melee_mult + colour_type = lattice.window_colour + afterimage_interval = lattice.afterimage_interval + afterimage_alpha = lattice.afterimage_alpha + online_message = lattice.online_message + crash_duration = lattice.crash_duration + crash_stamina = lattice.crash_stamina + return ..() /datum/status_effect/cyberware_cascade_window/on_apply() trail_hue = rand(0, 359) - owner.add_movespeed_modifier(/datum/movespeed_modifier/cyberware_cascade) + owner.add_movespeed_modifier(speed_type) owner.add_movespeed_mod_immunities(id, /datum/movespeed_modifier/reagent) - cyberware_register_dodge_source(owner, id, CALLBACK(src, PROC_REF(get_dodge_chance))) + cyberware_register_dodge_source(owner, id, CALLBACK(src, PROC_REF(get_dodge_chance)), melee = TRUE) + owner.hv_crit_set_attacker_bonus(id, crit_bonus) RegisterSignal(owner, COMSIG_MOVABLE_MOVED, PROC_REF(on_move)) - owner.add_client_colour(/datum/client_colour/cyberware_cascade, id) + owner.add_client_colour(colour_type, id) playsound(owner, 'sound/effects/magic/timeparadox2.ogg', 70, TRUE) owner.visible_message( span_boldwarning("[owner] fractures into afterimages. Something under [owner.p_their()] skin is running far too fast!"), - span_boldnotice("CASCADE ONLINE. Eight seconds."), + span_boldnotice(online_message), ) owner.balloon_alert(owner, "cascade online") + cyberware_cascade_window_fx(owner) return TRUE /datum/status_effect/cyberware_cascade_window/on_remove() - owner.remove_movespeed_modifier(/datum/movespeed_modifier/cyberware_cascade) + owner.remove_movespeed_modifier(speed_type) owner.remove_movespeed_mod_immunities(id, /datum/movespeed_modifier/reagent) cyberware_unregister_dodge_source(owner, id) + owner.hv_crit_set_attacker_bonus(id, null) UnregisterSignal(owner, COMSIG_MOVABLE_MOVED) owner.remove_client_colour(id) if(!QDELETED(owner) && owner.stat != DEAD) - owner.apply_status_effect(/datum/status_effect/cyberware_cascade_crash) + owner.apply_status_effect(/datum/status_effect/cyberware_cascade_crash, crash_duration, crash_stamina) + if(!QDELETED(owner)) + cyberware_cascade_window_end_fx(owner) return ..() -/// Melee cooldowns halved for the window (changeNext_move multiplies these in). +/// Melee cooldowns scaled for the window (changeNext_move multiplies these in). /datum/status_effect/cyberware_cascade_window/nextmove_modifier() - return 0.5 + return melee_mult -/// Dodge-source callback for the shared arbiter: flat 40 while the window -/// lives (the arbiter itself enforces moving-only and point-blank rules). +/// Dodge-source callback for the shared arbiter: flat chance while the window +/// lives (the arbiter itself enforces the moving-only and point-blank rules +/// for shots, and the pinned rules for blows). /datum/status_effect/cyberware_cascade_window/proc/get_dodge_chance() - return CYBERWARE_CASCADE_DODGE_CHANCE + return dodge_chance /// Signal proc for [COMSIG_MOVABLE_MOVED]: one afterimage per step, the /// telegraph everyone in the fight can read. Each step shifts the hue, so the @@ -154,16 +237,19 @@ SIGNAL_HANDLER if(!isturf(old_loc)) return - new /obj/effect/temp_visual/decoy/fading/cascade(old_loc, owner, trail_hue) + steps_taken++ + if(steps_taken % afterimage_interval) // cheaper chrome leaves a sparser trail + return + new /obj/effect/temp_visual/decoy/fading/cascade(old_loc, owner, trail_hue, afterimage_alpha) trail_hue = (trail_hue + CYBERWARE_CASCADE_HUE_STEP) % 360 /// One afterimage in the Cascade trail, washed in a single hue. /obj/effect/temp_visual/decoy/fading/cascade duration = 8 -/obj/effect/temp_visual/decoy/fading/cascade/Initialize(mapload, atom/mimiced_atom, hue = 0) +/obj/effect/temp_visual/decoy/fading/cascade/Initialize(mapload, atom/mimiced_atom, hue = 0, start_alpha = CYBERWARE_CASCADE_AFTERIMAGE_ALPHA) . = ..() - alpha = 200 + alpha = start_alpha color = cascade_tint_matrix(hue) animate(src, alpha = 0, time = duration) // restart the parent's fade from the new alpha @@ -185,19 +271,34 @@ /atom/movable/screen/alert/status_effect/cyberware_cascade name = "Cascade Window" - desc = "The lattice has the world in slow motion. Make it count. Six seconds of crash follows either way." + desc = "The lattice has the world in slow motion. Make it count." icon_state = "radiation_shield" +/// The lesser models' alert (ware_line_sandy.dm), with no crash timer in the text. +/atom/movable/screen/alert/status_effect/cyberware_cascade/aftermarket + name = "Reflex Window" + desc = "The rig has the world in slow motion. Make it count." + /// The bill. No dodge source, no speed, the opposite of all of it. /datum/status_effect/cyberware_cascade_crash id = "cyberware_cascade_crash" duration = CYBERWARE_CASCADE_CRASH tick_interval = STATUS_EFFECT_NO_TICK alert_type = null + /// Stamina dumped on the bearer when the crash lands. + var/crash_stamina = CYBERWARE_CASCADE_CRASH_STAMINA + +/// Optional arguments: crash length and stamina dump, from the window that ended. +/datum/status_effect/cyberware_cascade_crash/on_creation(mob/living/new_owner, crash_duration, stamina_dump) + if(isnum(crash_duration)) + duration = crash_duration + if(isnum(stamina_dump)) + crash_stamina = stamina_dump + return ..() /datum/status_effect/cyberware_cascade_crash/on_apply() owner.add_movespeed_modifier(/datum/movespeed_modifier/cyberware_cascade_crash) - owner.adjustStaminaLoss(CYBERWARE_CASCADE_CRASH_STAMINA) + owner.adjustStaminaLoss(crash_stamina) owner.add_client_colour(/datum/client_colour/cyberware_cascade_crash, id) playsound(owner, 'sound/machines/warning-buzzer.ogg', 50, TRUE) owner.visible_message( @@ -205,6 +306,7 @@ span_userdanger("The lattice dumps its heat. Your whole body seizes up and everything slows to a crawl."), ) owner.balloon_alert(owner, "cascade crash!") + cyberware_cascade_crash_fx(owner) return TRUE /datum/status_effect/cyberware_cascade_crash/on_remove() @@ -212,6 +314,8 @@ owner.remove_client_colour(id) if(!QDELETED(owner) && owner.stat != DEAD) owner.balloon_alert(owner, "systems restabilized") + if(!QDELETED(owner)) + cyberware_cascade_crash_end_fx(owner) return ..() /datum/movespeed_modifier/cyberware_cascade @@ -250,6 +354,8 @@ #define CYBERWARE_REDLINE_CRASH_STAMINA 100 /// Crash slowdown duration. #define CYBERWARE_REDLINE_CRASH (5 SECONDS) +/// The outline a bearer wears through the window. +#define CYBERWARE_REDLINE_OUTLINE_COLOR "#ff2a2a" /** * # Redline Core (T4, chest, OS slot, load 10) @@ -271,7 +377,7 @@ */ /obj/item/organ/cyberimp/cyberware/redline name = "\improper Redline core" - desc = "A combat governor rebuilt to fail open. Twelve seconds with every safety limit switched off at once, announced by a chest speaker nobody told you was in there." + desc = "A combat governor rebuilt to fail open, announced by a chest speaker nobody told you was in there." icon_state = "redline" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_OS @@ -281,6 +387,29 @@ aug_overlay = "redline" emissive_overlay = TRUE actions_types = list(/datum/action/cooldown/cyberware/redline_burn) + // The burn's tuning lives on the organ so a cheaper or rougher model (see + // ware_line_berserk.dm) retunes it by setting vars. The defaults below ARE + // the Redline core's numbers. The defines stay as those defaults. + /// Length of the burn window. + var/burn_window = CYBERWARE_REDLINE_WINDOW + /// Incoming brute/burn multiplier during the window. + var/burn_damage_mult = CYBERWARE_REDLINE_DAMAGE_MULT + /// Flat bonus to unarmed strikes during the window. + var/burn_melee_bonus = CYBERWARE_REDLINE_MELEE_BONUS + /// Whether the window grants stun and baton immunity. + var/burn_stun_immune = TRUE + /// Roar reach in tiles. 0 keeps the announcement but staggers nobody. + var/burn_roar_range = CYBERWARE_REDLINE_ROAR_RANGE + /// Crash slowdown duration. + var/burn_crash = CYBERWARE_REDLINE_CRASH + /// Stamina dumped by the crash. + var/burn_crash_stamina = CYBERWARE_REDLINE_CRASH_STAMINA + /// Cooldown on the Redline Burn button. + var/burn_cooldown = 90 SECONDS + /// Button tooltip. Null keeps the Redline Burn action's own text. + var/burn_action_desc + /// Status alert text while the window is open. Null keeps the alert's own text. + var/burn_alert_desc /obj/item/organ/cyberimp/cyberware/redline/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() @@ -312,12 +441,22 @@ /datum/action/cooldown/cyberware/redline_burn name = "Redline Burn" - desc = "Twelve seconds of stun immunity, 40% damage resistance and harder fists, opened with a staggering roar. Ends in a stamina collapse. An EMP mid-window collapses you instantly." + desc = "Twelve seconds of stun immunity, 40% damage resistance and harder fists, opened with a staggering roar. Ends in a collapse." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "act_redline" cooldown_time = 90 SECONDS click_to_activate = FALSE +/datum/action/cooldown/cyberware/redline_burn/New(Target, original = TRUE) + . = ..() + // The core this button belongs to sets its own cooldown and tooltip. + var/obj/item/organ/cyberimp/cyberware/redline/core = organ + if(!istype(core)) + return + cooldown_time = core.burn_cooldown + if(core.burn_action_desc) + desc = core.burn_action_desc + /datum/action/cooldown/cyberware/redline_burn/Activate(atom/target) if(!isliving(owner)) return FALSE @@ -326,7 +465,7 @@ burner.balloon_alert(burner, "core still venting!") return FALSE StartCooldown() - burner.apply_status_effect(/datum/status_effect/cyberware_redline_window) + burner.apply_status_effect(/datum/status_effect/cyberware_redline_window, organ) return TRUE /** @@ -382,47 +521,93 @@ /// roll, so the next arming is skipped. See suppress_topup() for why this /// can't just clear the armed state. var/topup_suppressed = FALSE + // Tuning. The defaults are the Redline core's own numbers; on_creation() + // replaces them with the installed core's when one is passed in. + /// Incoming brute/burn multiplier. + var/damage_mult = CYBERWARE_REDLINE_DAMAGE_MULT + /// Flat bonus to unarmed strikes. + var/melee_bonus = CYBERWARE_REDLINE_MELEE_BONUS + /// Whether the window grants stun and baton immunity. + var/stun_immune = TRUE + /// Roar reach in tiles, 0 for the announcement only. + var/roar_range = CYBERWARE_REDLINE_ROAR_RANGE + /// Handed to the crash this window rolls into. + var/crash_duration = CYBERWARE_REDLINE_CRASH + var/crash_stamina = CYBERWARE_REDLINE_CRASH_STAMINA + /// Replaces the alert's description, if set. + var/alert_desc + +/// Pass the core whose numbers this burn runs on. Without one the window uses +/// the Redline core's own. +/datum/status_effect/cyberware_redline_window/on_creation(mob/living/new_owner, obj/item/organ/cyberimp/cyberware/redline/core) + if(istype(core)) + duration = core.burn_window + damage_mult = core.burn_damage_mult + melee_bonus = core.burn_melee_bonus + stun_immune = core.burn_stun_immune + roar_range = core.burn_roar_range + crash_duration = core.burn_crash + crash_stamina = core.burn_crash_stamina + alert_desc = core.burn_alert_desc + . = ..() + if(. && linked_alert && alert_desc) + linked_alert.desc = alert_desc /datum/status_effect/cyberware_redline_window/on_apply() // The anti-stun implant's buff pattern: traits plus damage-slowdown immunity. - owner.add_traits(list(TRAIT_STUNIMMUNE, TRAIT_BATON_RESISTANCE), id) + if(stun_immune) + owner.add_traits(list(TRAIT_STUNIMMUNE, TRAIT_BATON_RESISTANCE), id) owner.add_movespeed_mod_immunities(id, /datum/movespeed_modifier/damage_slowdown) if(ishuman(owner)) var/mob/living/carbon/human/human_owner = owner - human_owner.physiology.brute_mod *= CYBERWARE_REDLINE_DAMAGE_MULT - human_owner.physiology.burn_mod *= CYBERWARE_REDLINE_DAMAGE_MULT + human_owner.physiology.brute_mod *= damage_mult + human_owner.physiology.burn_mod *= damage_mult if(iscarbon(owner)) var/mob/living/carbon/carbon_owner = owner for(var/obj/item/bodypart/arm/limb in carbon_owner.bodyparts) - limb.unarmed_damage_low += CYBERWARE_REDLINE_MELEE_BONUS - limb.unarmed_damage_high += CYBERWARE_REDLINE_MELEE_BONUS + limb.unarmed_damage_low += melee_bonus + limb.unarmed_damage_high += melee_bonus buffed_parts += limb RegisterSignal(owner, COMSIG_LIVING_EARLY_UNARMED_ATTACK, PROC_REF(on_early_unarmed_attack)) RegisterSignal(owner, COMSIG_LIVING_UNARMED_ATTACK, PROC_REF(on_unarmed_attack)) owner.add_client_colour(/datum/client_colour/cyberware_redline, id) + // Everyone can see a bearer is burning: a red outline for the whole window, gone when it ends or they die + owner.add_filter(id, 2, outline_filter(1, CYBERWARE_REDLINE_OUTLINE_COLOR)) + RegisterSignal(owner, COMSIG_LIVING_DEATH, PROC_REF(on_bearer_death)) owner.balloon_alert(owner, "REDLINE") INVOKE_ASYNC(src, PROC_REF(roar)) + // Red-hot nodes, red eyes, a red light (cyberware_anim2.dm). + cyberware_redline_window_fx(owner) return TRUE +/// The burn's outline goes out with its bearer +/datum/status_effect/cyberware_redline_window/proc/on_bearer_death(mob/living/source, gibbed) + SIGNAL_HANDLER + source.remove_filter(id) + /datum/status_effect/cyberware_redline_window/on_remove() - owner.remove_traits(list(TRAIT_STUNIMMUNE, TRAIT_BATON_RESISTANCE), id) + if(stun_immune) + owner.remove_traits(list(TRAIT_STUNIMMUNE, TRAIT_BATON_RESISTANCE), id) owner.remove_movespeed_mod_immunities(id, /datum/movespeed_modifier/damage_slowdown) if(ishuman(owner)) var/mob/living/carbon/human/human_owner = owner - human_owner.physiology.brute_mod /= CYBERWARE_REDLINE_DAMAGE_MULT - human_owner.physiology.burn_mod /= CYBERWARE_REDLINE_DAMAGE_MULT + human_owner.physiology.brute_mod /= damage_mult + human_owner.physiology.burn_mod /= damage_mult for(var/obj/item/bodypart/arm/limb as anything in buffed_parts) if(QDELETED(limb)) continue - limb.unarmed_damage_low -= CYBERWARE_REDLINE_MELEE_BONUS - limb.unarmed_damage_high -= CYBERWARE_REDLINE_MELEE_BONUS + limb.unarmed_damage_low -= melee_bonus + limb.unarmed_damage_high -= melee_bonus buffed_parts.Cut() - UnregisterSignal(owner, list(COMSIG_LIVING_EARLY_UNARMED_ATTACK, COMSIG_LIVING_UNARMED_ATTACK)) + UnregisterSignal(owner, list(COMSIG_LIVING_EARLY_UNARMED_ATTACK, COMSIG_LIVING_UNARMED_ATTACK, COMSIG_LIVING_DEATH)) + owner.remove_filter(id) bypassed_victim = null bypassed_penetration = 0 owner.remove_client_colour(id) if(!QDELETED(owner) && owner.stat != DEAD) - owner.apply_status_effect(/datum/status_effect/cyberware_redline_crash) + owner.apply_status_effect(/datum/status_effect/cyberware_redline_crash, crash_duration, crash_stamina) + if(!QDELETED(owner)) + cyberware_redline_window_end_fx(owner) return ..() /** @@ -436,11 +621,19 @@ return playsound(owner, 'sound/effects/magic/demon_attack1.ogg', 90, TRUE) playsound(owner, 'sound/effects/magic/repulse.ogg', 60, TRUE) + if(roar_range <= 0) + // A core with no roar behind it still announces itself, just doesn't shake anything. + owner.visible_message( + span_boldwarning("[owner]'s eyes flood red and the speaker in [owner.p_their()] chest blares!"), + span_boldwarning("Your chest speaker blares."), + ) + return owner.visible_message( span_boldwarning("[owner]'s eyes flood red and a speaker-drone ROAR shakes the deck!"), span_boldwarning("You ROAR."), ) - for(var/mob/living/victim in oview(CYBERWARE_REDLINE_ROAR_RANGE, owner)) + cyberware_redline_roar_fx(owner, roar_range) + for(var/mob/living/victim in oview(roar_range, owner)) if(victim.stat == DEAD) continue if(cyberware_is_ally(owner, victim)) @@ -551,7 +744,7 @@ return var/target_zone = victim.get_random_valid_zone(owner.zone_selected) victim.apply_damage( - CYBERWARE_REDLINE_MELEE_BONUS, + melee_bonus, BRUTE, target_zone, victim.run_armor_check(target_zone, MELEE, armour_penetration = penetration, silent = TRUE), @@ -561,7 +754,7 @@ /atom/movable/screen/alert/status_effect/cyberware_redline name = "Redline Burn" - desc = "Every safety limit off at once. Stuns don't land, hits don't hurt much, and your fists hit a great deal harder. You collapse when it ends." + desc = "Every safety limit is off at once." icon_state = "radiation_shield" /datum/status_effect/cyberware_redline_crash @@ -569,16 +762,29 @@ duration = CYBERWARE_REDLINE_CRASH tick_interval = STATUS_EFFECT_NO_TICK alert_type = null + /// Stamina dumped on apply. + var/stamina_dump = CYBERWARE_REDLINE_CRASH_STAMINA + +/// The window hands over its core's crash length and stamina dump. Without +/// them the crash is the Redline core's own. +/datum/status_effect/cyberware_redline_crash/on_creation(mob/living/new_owner, new_duration, new_stamina_dump) + if(!isnull(new_duration)) + duration = new_duration + if(!isnull(new_stamina_dump)) + stamina_dump = new_stamina_dump + return ..() /datum/status_effect/cyberware_redline_crash/on_apply() owner.add_movespeed_modifier(/datum/movespeed_modifier/cyberware_redline_crash) - owner.adjustStaminaLoss(CYBERWARE_REDLINE_CRASH_STAMINA) + owner.adjustStaminaLoss(stamina_dump) owner.add_client_colour(/datum/client_colour/cyberware_redline_crash, id) owner.visible_message( span_warning("[owner] sags as the red drains out of [owner.p_their()] eyes."), span_userdanger("The core slams shut and your legs go out from under you."), ) owner.balloon_alert(owner, "redline collapse!") + // The outline gutters out, the charge earths through the deck, the nodes cool, the body slumps (cyberware_anim2.dm). + cyberware_redline_crash_fx(owner) return TRUE /datum/status_effect/cyberware_redline_crash/on_remove() @@ -586,6 +792,8 @@ owner.remove_client_colour(id) if(!QDELETED(owner) && owner.stat != DEAD) owner.balloon_alert(owner, "core recovered") + if(!QDELETED(owner)) + cyberware_redline_crash_end_fx(owner) return ..() /datum/movespeed_modifier/cyberware_redline_crash @@ -684,7 +892,7 @@ */ /obj/item/organ/cyberimp/cyberware/piledriver name = "\improper Meteor Piledriver frame" - desc = "Prototype launch pistons sleeved over both legs, running into a gyroscopic landing computer that aims you at the floor. It wants an open lane to throw you down, and everyone underneath gets a shadow to look at before you get there." + desc = "Prototype launch pistons sleeved over both legs, running into a gyroscopic landing computer that aims you at the floor." icon_state = "piledriver" zone = BODY_ZONE_L_LEG slot = ORGAN_SLOT_CYBERWARE_LEGS @@ -706,7 +914,9 @@ desc = "Something very heavy is about to land on this exact spot." icon = 'icons/mob/telegraphing/telegraph_96x96.dmi' icon_state = "target_largebox" - layer = BELOW_MOB_LAYER + // Painted on the floor: under whoever stands in it, on every row it covers. + plane = FLOOR_PLANE + layer = LOWER_RUNE_LAYER pixel_x = -32 pixel_y = -32 alpha = 0 @@ -718,11 +928,13 @@ /datum/action/cooldown/cyberware/piledriver_leap name = "Meteor Leap" - desc = "Launch onto any tile you can see with a clear arc to it, or onto somebody standing on one. Walls, windows and shut doors stop the jump. A shadow warns everyone underneath first. A direct hit crushes whoever is still there: heavy brute, broken bones, flat on the deck. Everything within two tiles is knocked flat and thrown." + desc = "Launch onto a tile you can see, or onto somebody standing on one. A direct hit crushes whoever is still there, and everything within two tiles is knocked flat." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "act_piledriver" cooldown_time = 60 SECONDS click_to_activate = TRUE + // A stunned, paralysed or bound body does not get to leap out of it. + check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED | AB_CHECK_IMMOBILE /datum/action/cooldown/cyberware/piledriver_leap/Activate(atom/target) if(!isliving(owner)) @@ -732,6 +944,10 @@ var/turf/here = get_turf(jumper) if(isnull(destination) || isnull(here) || destination == here) return FALSE + // The landing crushes whoever is under it, so it is not for a pacifist. + if(HAS_TRAIT(jumper, TRAIT_PACIFISM)) + to_chat(jumper, span_warning("You don't want to harm other living beings!")) + return FALSE if(jumper.buckled || !isturf(jumper.loc)) jumper.balloon_alert(jumper, "can't launch from here!") return FALSE @@ -749,6 +965,8 @@ if(arc_blocker(here, destination)) jumper.balloon_alert(jumper, "no room for the arc!") return FALSE + // The shadow goes down and the landing hurts someone. + cyberware_camo_drop(jumper) StartCooldown() // Liftoff: locked in for the whole arc, committed, like everything // with this much telegraph. The TILE is what gets locked, never the mob, @@ -757,15 +975,15 @@ jumper.face_atom(destination) var/launch_message = "You launch. The landing computer handles the rest." if(isliving(target)) - launch_message = "You launch. The landing computer locks the tile [target] is standing on, if [target.p_they()] move[target.p_s()], you come down on empty deck." + launch_message = "You launch. The landing computer locks onto [target]." jumper.visible_message( span_boldwarning("[jumper]'s leg pistons CRACK the deck and [jumper.p_they()] launch[jumper.p_es()] skyward!"), span_warning(launch_message), ) playsound(here, 'sound/effects/gravhit.ogg', 70, TRUE) - new /obj/effect/temp_visual/mook_dust(here) new /obj/effect/temp_visual/cyberware_piledriver_shadow(destination) - animate(jumper, pixel_z = 64, time = CYBERWARE_PILEDRIVER_AIRTIME * 0.5, flags = ANIMATION_RELATIVE, easing = QUAD_EASING|EASE_OUT) + // Up off the deck and over to the mark; the body stays on its tile until it lands (cyberware_anim2.dm). + cyberware_leap_takeoff_fx(jumper, here, destination, CYBERWARE_PILEDRIVER_AIRTIME, 64, 64) addtimer(CALLBACK(src, PROC_REF(land), destination), CYBERWARE_PILEDRIVER_AIRTIME) return TRUE @@ -783,7 +1001,7 @@ if(QDELETED(jumper)) return jumper.remove_traits(list(TRAIT_IMMOBILIZED, TRAIT_HANDS_BLOCKED), REF(src)) - animate(jumper, pixel_z = -64, time = 0.1 SECONDS, flags = ANIMATION_RELATIVE) + cyberware_leap_touchdown_fx(jumper) if(jumper.stat == DEAD) return // The marked tile can stop existing mid-flight (someone blows the floor out @@ -812,7 +1030,8 @@ crushed += pinned jumper.forceMove(final) playsound(final, 'sound/effects/meteorimpact.ogg', 90, TRUE) - new /obj/effect/temp_visual/mook_dust(final) + cyberware_grey_dust(final) + cyberware_piledriver_impact_fx(final, CYBERWARE_PILEDRIVER_IMPACT_RANGE) for(var/mob/living/victim as anything in crushed) crush_victim(jumper, victim) for(var/mob/living/victim in oview(CYBERWARE_PILEDRIVER_IMPACT_RANGE, final)) @@ -899,6 +1118,7 @@ #undef CYBERWARE_REDLINE_ROAR_RANGE #undef CYBERWARE_REDLINE_CRASH_STAMINA #undef CYBERWARE_REDLINE_CRASH +#undef CYBERWARE_REDLINE_OUTLINE_COLOR #undef CYBERWARE_PILEDRIVER_RANGE #undef CYBERWARE_PILEDRIVER_AIRTIME #undef CYBERWARE_PILEDRIVER_IMPACT_RANGE diff --git a/voidcrew/modules/cyberware/ware_line_berserk.dm b/voidcrew/modules/cyberware/ware_line_berserk.dm new file mode 100644 index 00000000000..6bdde5d925d --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_berserk.dm @@ -0,0 +1,91 @@ +/** + * # The Berserk line: cheaper cores for the Redline slot + * + * Two earlier models of the Redline core. Same chest OS slot as the Redline + * (and Cascade), so fitting one evicts the other. Same burn, retuned: every + * number lives in a var on /obj/item/organ/cyberimp/cyberware/redline + * (ware_legend.dm) and a model sets its own here. + * + * | | window | damage | punch | stun immune | roar | crash | cooldown | load | + * |---|---|---|---|---|---|---|---|---| + * | street | 8 s | x0.8 | +3 | no | none | 6 s | 90 s | 4 | + * | milspec | 10 s | x0.7 | +5 | yes | 4 tiles | 5 s | 105 s | 8 | + * | Redline | 12 s | x0.6 | +8 | yes | 5 tiles | 5 s | 90 s | 10 | + * + * The chest speaker announcement stays on every model: it is the telegraph. + * The street core has no roar to follow it, so it announces and staggers + * nobody. Crash stamina stays at the Redline's 100 on all three. + * + * The street core cycles as fast as the Redline itself (final balance pass, + * review-balance change 5): at 120 s it was the worst T2 OS pick. What keeps it + * the bottom rung is the short, soft window, no stun immunity and no roar. + */ + +/// Street: bench-built, sold for credits. Burns for less time, softens less and +/// does not hold off stuns. +/obj/item/organ/cyberimp/cyberware/redline/street + name = "\improper Hothead core" + desc = "A combat governor soldered together on a back-room bench out of parts from two others. The chest speaker rattles when it runs." + icon_state = "redline_street" + chrome_load = 4 + tier = CYBERWARE_TIER_2 + aug_overlay = "redline_street" + burn_window = 8 SECONDS + burn_damage_mult = 0.8 + burn_melee_bonus = 3 + burn_stun_immune = FALSE + burn_roar_range = 0 + burn_crash = 6 SECONDS + burn_cooldown = 90 SECONDS + burn_action_desc = "Eight seconds of damage resistance and harder fists, announced by the chest speaker. Ends in a collapse." + burn_alert_desc = "The safeties are loosened, not gone." + +/// Milspec: surplus assault issue. Close to the Redline, a size smaller. +/obj/item/organ/cyberimp/cyberware/redline/milspec + name = "\improper Vanguard core" + desc = "A surplus assault governor, still stencilled with someone else's unit number. The chest speaker is military grade, which means loud." + icon_state = "redline_milspec" + chrome_load = 8 + tier = CYBERWARE_TIER_3 + aug_overlay = "redline_milspec" + burn_window = 10 SECONDS + burn_damage_mult = 0.7 + burn_melee_bonus = 5 + burn_stun_immune = TRUE + burn_roar_range = 4 + burn_crash = 5 SECONDS + burn_cooldown = 90 SECONDS + burn_action_desc = "Ten seconds of stun immunity, 30% damage resistance and harder fists, opened with a staggering roar. Ends in a collapse." + burn_alert_desc = "The safeties are off." + +// ========================================================================= +// SPLICE SKUs (wired into the vendors at integration, not here) +// ========================================================================= + +/datum/shop_sku/ripperdoc/redline_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/redline/street + price_credits = 3000 + +/datum/shop_sku/ripperdoc/redline_milspec + zone_permission = ZONE_PERMISSION_ADVANCED + category = "Military Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/redline/milspec + price_vouchers = 4 + +// ========================================================================= +// TRADE-IN: the street model only +// Half list, credits only, exact type. The milspec core is paid for in +// vouchers and is never bought back. +// ========================================================================= + +/datum/shop_buyback/ripperdoc/redline_street + name = "Hothead Core (pulled)" + desc = "A pulled rage governor, scorched where the safeties used to be." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/redline/street + match_subtypes = FALSE + pay_credits = 1500 + demand_min = 1 + demand_max = 2 diff --git a/voidcrew/modules/cyberware/ware_line_camo.dm b/voidcrew/modules/cyberware/ware_line_camo.dm new file mode 100644 index 00000000000..21561b3900f --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_camo.dm @@ -0,0 +1,67 @@ +/** + * # Camo line: the street weave + * + * The cheap rung under the Ghostskin Weave (ware_military_body.dm), on the same + * skin slot, so installing one evicts the other. It reuses the whole Ghostskin + * field, signals, break triggers and all, and only retunes the vars the parent + * exposes: a shorter, patchier fade that fools players and never mobs. + * + * This file is included BEFORE ware_military_body.dm, so it cannot use the + * CYBERWARE_GHOSTSKIN_* defines (they are defined and #undef'd over there). + * Every number below is a plain var override instead. + * + * What hides_from_mobs = FALSE buys, in practice: no TRAIT_CYBER_CAMO, so + * cyberware_stealth.dm never refuses the bearer as a target (basic mobs, + * simple_animal hostiles, turrets and the scripted hunters it names) and + * cyberware_scan.dm never scatters a chrome read on them. All of it is keyed + * on that one trait. + */ + +/obj/item/organ/cyberimp/cyberware/ghostskin/street + name = "\improper Flickerskin weave" + desc = "A budget subdermal weave of refraction cells, mostly salvage. Switched on, you go blurry at the edges, which is not the same as gone." + icon_state = "ghostskin_street" + chrome_load = 2 + tier = CYBERWARE_TIER_2 + actions_types = list(/datum/action/cooldown/cyberware/ghostskin_cloak/street) + // Mostly faded, but never as faint as the full weave. Moving flares it + // well above that. + field_alpha = 60 + ripple_alpha = 170 + field_duration = 7 SECONDS + hides_from_mobs = FALSE + +/obj/item/organ/cyberimp/cyberware/ghostskin/street/engage_feedback(mob/living/carbon/wearer) + playsound(wearer, 'voidcrew/sound/machines/cloaking/on.ogg', 35, TRUE) + wearer.visible_message( + span_warning("[wearer] flickers and goes patchy!"), + span_notice("The weave stutters on and smears the light around you. Not all of it."), + ) + +/datum/action/cooldown/cyberware/ghostskin_cloak/street + desc = "Seven seconds of patchy optical camo." + cooldown_time = 45 SECONDS + +// ========================================================================= +// SPLICE SKUS +// Not listed on any vendor from here: the lead adds the path to Splice's +// sku_types and to the street doc's, and the buyback to buyback_types. +// ========================================================================= + +/datum/shop_sku/ripperdoc/ghostskin_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/ghostskin/street + price_credits = 2400 + stock_min = 1 + stock_max = 2 + +/// Trade-in at half list, credits only, like the other street rungs. +/datum/shop_buyback/ripperdoc/ghostskin_street + name = "Flickerskin weave (pulled)" + desc = "A patchy camo weave you've outgrown." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/ghostskin/street + pay_credits = 1200 + demand_min = 1 + demand_max = 2 diff --git a/voidcrew/modules/cyberware/ware_line_governor.dm b/voidcrew/modules/cyberware/ware_line_governor.dm new file mode 100644 index 00000000000..9de41c9a7fa --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_governor.dm @@ -0,0 +1,75 @@ +/** + * # The Governor line + * + * Two cheaper rungs under Governor Delete (ware_legend.dm), so a crew can buy + * a little headroom early and climb to the real thing. All three sit in the + * chest OS slot, so fitting one evicts another, and they evict Cascade and + * Redline too: the cost of headroom is the operating-system slot, same as the + * parent. Load is 0 on every rung. + * + * The parent already reads its bonus from `chrome_capacity_bonus`, so the + * rungs only retune that var and `tier`; there is no behaviour of their own. + * Delete has no downside beyond the slot, so there is none to scale down. + * + * Swapping down is safe by construction. The install gate nets the evicted + * governor's bonus out (installed_capacity_check), so a swap that would leave + * the body over its new ceiling is refused up front with the incumbent still + * online. Pulling a governor out is never blocked: whatever is then over the + * ceiling browns out until load drops, like any other capacity loss. + * + * Rung bonus limit load tier + * Patch +5 25 0 T2 (street, sold for credits) + * Bypass +10 30 0 T3 (military, sold for vouchers) + * Delete +15 35 0 T4 (ware_legend.dm) + */ + +/// T2: a hand-fitted patch over the limiter instead of a clean removal. +/obj/item/organ/cyberimp/cyberware/governor_delete/street + name = "\improper Governor Patch" + desc = "A neural governor with the limiter taped over rather than removed. The tape has seen some things." + icon_state = "governor_delete_street" + chrome_load = 0 + chrome_capacity_bonus = 5 + tier = CYBERWARE_TIER_2 + +/// T3: the limiter jumpered out of the circuit, surplus-grade work. +/obj/item/organ/cyberimp/cyberware/governor_delete/milspec + name = "\improper Governor Bypass" + desc = "A neural governor with its limiter jumpered out of the circuit. The surplus stencil is still on the casing." + icon_state = "governor_delete_milspec" + chrome_load = 0 + chrome_capacity_bonus = 10 + tier = CYBERWARE_TIER_3 + +// ========================================================================= +// SPLICE SKUS: not listed on any vendor yet, the integration pass adds them +// to the Chop Shop's sku_types (and the street doc's, for the Patch). +// ========================================================================= + +/datum/shop_sku/ripperdoc/governor_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/governor_delete/street + price_credits = 2500 + +/datum/shop_sku/ripperdoc/governor_milspec + zone_permission = ZONE_PERMISSION_ADVANCED + category = "Military Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/governor_delete/milspec + price_vouchers = 3 + +// ========================================================================= +// TRADE-IN: the Patch is the rung a customer outgrows, half list in credits. +// Not listed on any buyback_types yet, same integration pass as above. The +// Bypass costs vouchers, which can't be refunded, so it has no entry. +// ========================================================================= + +/datum/shop_buyback/ripperdoc/governor_street + name = "Governor Patch (pulled)" + desc = "A taped-over governor, pulled." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/governor_delete/street + match_subtypes = FALSE + pay_credits = 1250 + demand_min = 1 + demand_max = 2 diff --git a/voidcrew/modules/cyberware/ware_line_mantis.dm b/voidcrew/modules/cyberware/ware_line_mantis.dm new file mode 100644 index 00000000000..2505e971bf1 --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_mantis.dm @@ -0,0 +1,182 @@ +/** + * # Mantis Blades line: the Shiv and Scorch models + * + * Two more ways to buy the same forearm blades (ware_military_arms.dm): + * - Shiv Blades, the street model. A duller blade, no lunge, light on the + * nervous system, sold for credits in the yellow zone and bought back. + * - Scorch Blades, the fire model. Mantis in every number, but every cut + * sets the target alight and the lunge lights them harder. + * + * Both are subtypes of the Mantis housing, so they share its arm hardware slot: + * installing one evicts the other. Both ship as cased pairs (left and right), + * like the parent. The tuning rides vars on the housing (lunge_range, + * lunge_bonus, lunge_fire_stacks and friends), so a model retunes by setting + * them, not by copying the lunge. + */ + +// ---- Fire -------------------------------------------------------------- + +/** + * Puts fire stacks on a living target and lights them. The only fire this + * line makes. It never touches the attacker and never lights a turf: any + * heat the surroundings get is what a burning mob already gives off. Corpses + * are left alone, so a body is never cooked out from under a revive or a salvage. + * Returns TRUE if the target caught fire just now. + */ +/proc/cyberware_scorch_target(mob/living/victim, stacks) + if(!istype(victim) || QDELETED(victim) || victim.stat == DEAD || stacks <= 0) + return FALSE + victim.adjust_fire_stacks(stacks) + return victim.ignite_mob() + +// ---- Blades -------------------------------------------------------------- + +/** + * The Shiv's blade. The same hardlight on a worse emitter: dull grey, and it + * hits softer. + */ +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street + name = "shiv blade" + desc = "A dull grey sliver of hardlight with no shine to it. It still cuts." + icon_state = "mantis_street" + base_icon_state = "mantis_street" + inhand_icon_state = "mantis_street_guard" + force = 14 + +/** + * The Scorch's blade. Cuts like a Mantis, then lights what it cut. The edge runs + * orange and the blade throws a little firelight while it is out. + */ +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch + name = "scorch blade" + desc = "A forearm's length of hardlight gone orange along the edge. The air above it shimmers." + icon_state = "mantis_scorch" + base_icon_state = "mantis_scorch" + inhand_icon_state = "mantis_scorch_guard" + light_range = 2 + light_power = 1 + light_color = LIGHT_COLOR_FIRE + /// Fire stacks each landed cut puts on its target. + var/fire_stacks_per_hit = 2 + +// The glow is only for a blade that is out. Stowed inside the housing it is dark. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch/equipped(mob/user, slot, initial = FALSE) + . = ..() + set_light_on(TRUE) + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch/dropped(mob/user, silent = FALSE) + . = ..() + set_light_on(FALSE) + +// Only a cut that landed burns (the parent's attack() decides that), never the wielder. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch/on_cut_landed(mob/living/target, mob/living/user) + . = ..() + // Embers off the cut; the blade's impact is the slash (cyberware_anim2.dm). + cyberware_scorch_trail_fx(user, target) + if(cyberware_scorch_target(target, fire_stacks_per_hit)) + log_combat(user, target, "set alight", src, "(scorch blade)") + +// ---- Shiv Blades (street) ------------------------------------------------ + +/** + * # Shiv Blades (T2, arms, arm hardware slots, load 2 per arm / 4 the pair) + * + * The street answer to Mantis Blades: the same hardlight forearm housing built + * from salvage. The blade is weaker and there is no lunge, so no button besides + * the blade toggle. Cheap in credits and light on the nervous system, and Splice + * takes a pulled housing back toward the real thing. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street + name = "\improper Shiv Blade housing (right)" + desc = "A forearm housing with the serial plate filed off and an emitter wired in by someone who skipped the manual." + icon_state = "mantis_street" + chrome_load = 2 + tier = CYBERWARE_TIER_2 + aug_overlay = "mantis_street" + items_to_create = list(/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street) + actions_types = list(/datum/action/item_action/organ_action/toggle/toolkit) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/left + name = "\improper Shiv Blade housing (left)" + zone = BODY_ZONE_L_ARM + slot = ORGAN_SLOT_LEFT_ARM_AUG + +/obj/item/cyberware_pair_case/mantis_street + name = "\improper Shiv Blades case" + desc = "A scuffed clamshell case with two forearm housings jammed into mismatched foam." + ware_types = list( + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/left, + ) + +// ---- Scorch Blades (fire) ------------------------------------------------ + +/** + * # Scorch Blades (T3, arms, arm hardware slots, load 4 per arm / 8 the pair) + * + * Mantis Blades with a heat sink grafted onto the emitter rail. The blade, the + * lunge and the cooldown are the Mantis numbers. What is added is fire: each cut + * leaves the target burning, and the lunge lights them harder. It heats the + * wrist, but never sets the wearer alight. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch + name = "\improper Scorch Blade housing (right)" + desc = "A forearm housing with a heat sink grafted onto the emitter rail. The wrist runs warm even with nothing out." + icon_state = "mantis_scorch" + chrome_load = 4 + tier = CYBERWARE_TIER_3 + aug_overlay = "mantis_scorch" + items_to_create = list(/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch) + lunge_fire_stacks = 4 + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left + name = "\improper Scorch Blade housing (left)" + zone = BODY_ZONE_L_ARM + slot = ORGAN_SLOT_LEFT_ARM_AUG + +/obj/item/cyberware_pair_case/mantis_scorch + name = "\improper Scorch Blades case" + desc = "A heavy clamshell case, scorched at the corners, with two forearm housings set in heat-proof foam." + ware_types = list( + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left, + ) + +// ---- The parlor's shelf -------------------------------------------------- + +/datum/shop_sku/ripperdoc/mantis_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + name = "Shiv Blades (pair)" + desc = "A cased pair of cheap forearm blades." + item_path = /obj/item/cyberware_pair_case/mantis_street + price_credits = 2400 + stock_min = 1 + stock_max = 2 + fixed_price = TRUE + contract_reward = FALSE + +/datum/shop_sku/ripperdoc/mantis_scorch + zone_permission = ZONE_PERMISSION_ELITE + category = "Military Chrome" + name = "Scorch Blades (pair)" + desc = "A cased pair of forearm blades with heat sinks on the emitter rails." + item_path = /obj/item/cyberware_pair_case/mantis_scorch + price_vouchers = 4 + stock_min = 1 + stock_max = 1 + convoys_per_unit = 3 + fixed_price = TRUE + contract_reward = FALSE + +/// Half the credit price of one housing, either side, as the other street rungs +/// pay. Credits only, so turning a pair around is always a loss. +/datum/shop_buyback/ripperdoc/mantis_street + name = "Shiv Blade housing (pulled)" + desc = "A secondhand forearm housing, either side." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street + match_subtypes = TRUE + pay_credits = 600 + demand_min = 2 + demand_max = 4 diff --git a/voidcrew/modules/cyberware/ware_line_models_a.dm b/voidcrew/modules/cyberware/ware_line_models_a.dm new file mode 100644 index 00000000000..01f1147c904 --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_models_a.dm @@ -0,0 +1,418 @@ +/** + * # Cheaper and harder models of six wares + * + * Seven new models, each a subtype of the ware it sits under in the same slot, + * so fitting one evicts the other. The parent's tuning lives in vars (the Hopper + * leap, the Gorilla punches, the Fixer's tool-speed modifier), and a model + * retunes by setting them. + * + * model parent tier load price where + * Spring calves Hopper pistons T1 2 1,800 cr yellow + * Vaulter pistons Hopper pistons T3 4 3 vouchers advanced + * Brawler myomers Gorilla Arms T2 2 per arm 2,000 cr the pair yellow + * Tinker's fingers Fixer's Fingers T1 1 700 cr public + * Deepcore drill fist Rockjaw T2 3 2,400 cr public + * Holdout housing Popup Ronin T2 3 2,400 cr yellow + * + * Leg ladder: Shock Coils, Spring calves, Hopper, Vaulter, Meteor Piledriver. + * The Vaulter carries the Coils' soft landing and dry footing, which the Hopper + * itself never had, so stepping up to it costs no safety. + * + * Sold at Splice's counter, and the credit-priced ones at the street doc's + * (ripperdoc_catalog.dm, street_doc_catalog.dm). All of them also ride the + * zone loot tables (modules/loot/themes/). + */ + +// ========================================================================= +// SPRING CALVES (street Hopper) +// ========================================================================= + +/** + * # Spring calves (T1, legs, load 2) + * + * The cheap way into a jump: coil springs on the calves instead of pistons. A + * short hop that takes a while to wind back up. Nothing else. + */ +/obj/item/organ/cyberimp/cyberware/hopper/street + name = "\improper Spring calves" + desc = "Industrial coil springs sleeved over both calves and bolted straight to the shin. They squeak." + icon_state = "hopper_street" + chrome_load = 2 + tier = CYBERWARE_TIER_1 + aug_overlay = "hopper_street" + leap_range = 3 + leap_cooldown = 14 SECONDS + leap_action_desc = "Leap up to three tiles over gaps, tables and people." + +// ========================================================================= +// VAULTER PISTONS (milspec Hopper) +// ========================================================================= + +/** + * # Vaulter pistons (T3, legs, load 4) + * + * Military leg pistons: a longer jump on a shorter clock, with shock plates + * under the heel. Keeps the Shock Coils' soft landing and dry footing, minus the + * Coils' knockdown and stun trims, which stay with the Coils. + */ +/obj/item/organ/cyberimp/cyberware/hopper/milspec + name = "\improper Vaulter pistons" + desc = "Decommissioned military leg pistons, shock-plated at the heel. Somebody ground the serial number off and left the warning stencil." + icon_state = "hopper_milspec" + chrome_load = 4 + tier = CYBERWARE_TIER_3 + aug_overlay = "hopper_milspec" + organ_traits = list(TRAIT_NO_SLIP_WATER) + leap_range = 5 + leap_cooldown = 6 SECONDS + leap_action_desc = "Leap up to five tiles over gaps, tables and people." + +/obj/item/organ/cyberimp/cyberware/hopper/milspec/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) + . = ..() + RegisterSignal(organ_owner, COMSIG_LIVING_Z_IMPACT, PROC_REF(on_z_impact)) + +/obj/item/organ/cyberimp/cyberware/hopper/milspec/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) + . = ..() + UnregisterSignal(organ_owner, COMSIG_LIVING_Z_IMPACT) + +/// Signal proc for [COMSIG_LIVING_Z_IMPACT]: the Shock Coils' soft landing. Big +/// multi-level drops still stagger. +/obj/item/organ/cyberimp/cyberware/hopper/milspec/proc/on_z_impact(datum/source, levels, turf/fell_on) + SIGNAL_HANDLER + if(organ_flags & ORGAN_FAILING) + return NONE + new /obj/effect/temp_visual/mook_dust(fell_on) + cyberware_ink_pulse(owner, CYBERWARE_INK_SOFT) + if(levels >= 2) + owner.adjust_staggered_up_to(STAGGERED_SLOWDOWN_LENGTH * levels, 10 SECONDS) + owner.visible_message( + span_notice("[owner] lands on [fell_on] with a piston hiss."), + span_notice("Your heel plates soak up the impact."), + ) + return ZIMPACT_CANCEL_DAMAGE | ZIMPACT_NO_MESSAGE | ZIMPACT_NO_SPIN + +// ========================================================================= +// BRAWLER MYOMERS (street Gorilla Arms) +// ========================================================================= + +/** + * # Brawler myomers (T2, arms, arm hardware slots, load 2 per arm / 4 the pair) + * + * Gorilla Arms bought cheap: lighter punches, slower, a lighter smash on + * structures (still enough to dent an airlock, plain or reinforced). Rock still + * breaks. A grabbed victim is never hurled; a grab-click on the floor or a table + * slams them, lighter and on a longer clock than the Gorilla's + * (hyperviolence_gorilla/gorilla_punch.dm). No haymaker, no flex. + * + * Both arms sync into their own set bonus (cyberware_brawler below), never the + * Gorilla's, so one of these beside a real Gorilla arm syncs nothing. The synced + * pair forces powered airlocks slower than the Gorilla, gets a lighter ground + * pound with no daze (gorilla_pound.dm), and has the limb rip as its only + * finisher (gorilla_finisher.dm). Trader outpost doors refuse a pry or a punch. + */ +/obj/item/organ/cyberimp/cyberware/gorilla_arms/street + name = "\improper Brawler myomers (right)" + desc = "Off-the-shelf myomer strips grafted along the forearm. You don't look any stronger for it. You just stop losing arm wrestles." + icon_state = "gorilla_street" + chrome_load = 2 + tier = CYBERWARE_TIER_2 + aug_overlay = "gorilla_street_right" + punch_damage = 14 + structure_damage = BRAWLER_STRUCTURE_DAMAGE + punch_cooldown_time = 5 SECONDS + smash_cooldown_time = 1.5 SECONDS + hurl_range = 0 + pair_bonus = /datum/status_effect/organ_set_bonus/cyberware_brawler + // No hurl, haymaker or flex; the pair's pound and finisher are its own (hyperviolence_gorilla/) + heavy_moves = FALSE + slam_floor_damage = BRAWLER_SLAM_FLOOR_DAMAGE + slam_floor_stamina = BRAWLER_SLAM_FLOOR_STAMINA + slam_table_damage = BRAWLER_SLAM_TABLE_DAMAGE + slam_table_stamina = BRAWLER_SLAM_TABLE_STAMINA + slam_knockdown = BRAWLER_SLAM_KNOCKDOWN + slam_table_break = BRAWLER_SLAM_TABLE_BREAK + grab_move_cooldown = BRAWLER_GRAB_MOVE_COOLDOWN + slam_overhead = FALSE + slam_full_fx = FALSE + fist_word = "myomer-driven" + snap_strain = 4 + punch_wound_bonus = BRAWLER_PUNCH_WOUND_BONUS + impact_state = "impact_brawler" + +/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left + name = "\improper Brawler myomers (left)" + zone = BODY_ZONE_L_ARM + slot = ORGAN_SLOT_LEFT_ARM_AUG + aug_overlay = "gorilla_street_left" + +/** + * The synced Brawler pair: forces powered airlocks slower than the Gorilla and grants the light ground + * pound. No flex. Its own id, so gorilla_synced() never counts it and a mixed pair syncs into neither. + */ +/datum/status_effect/organ_set_bonus/cyberware_brawler + parent_type = /datum/status_effect/organ_set_bonus/cyberware_gorilla + id = "organ_set_bonus_cyberware_brawler" + bonus_activate_text = span_notice("Your myomers sync up.") + bonus_deactivate_text = span_notice("Your myomers fall out of sync.") + pry_time = BRAWLER_PRY_TIME + pound_type = /datum/action/cooldown/cyberware/gorilla_pound/brawler + flexes = FALSE + +/obj/item/cyberware_pair_case/gorilla_arms/street + name = "\improper Brawler myomers case" + desc = "A scuffed clamshell case with two bundles of myomer strips zip-tied into the foam." + ware_types = list( + /obj/item/organ/cyberimp/cyberware/gorilla_arms/street, + /obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left, + ) + +// ========================================================================= +// TINKER'S FINGERS (street Fixer's Fingers) +// ========================================================================= + +/// Tinker's fingers' servo speed-up: a tenth off every timed action, to the +/// Fixer's quarter. Its own key, so it never replaces the Fixer's. +/datum/actionspeed_modifier/cyberware_fixers/street + multiplicative_slowdown = -0.1 + +/** + * # Tinker's fingers (T1, arm aug, load 1) + * + * The same three tools in the knuckles and cheaper servos behind them. A green + * crew's way into the arm slot the Fixer's Fingers hold at yellow. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street + name = "\improper Tinker's fingers" + desc = "A fingertip tool suite in a housing that has been opened and closed more times than the warranty allows. Driver, wrench and cutters, all slightly loose." + icon_state = "fixers_street" + chrome_load = 1 + tier = CYBERWARE_TIER_1 + speed_modifier = /datum/actionspeed_modifier/cyberware_fixers/street + +// ========================================================================= +// DEEPCORE DRILL FIST (heavy Rockjaw) +// ========================================================================= + +/// The Deepcore's drill: between the Rockjaw's drill (0.5) and the diamond +/// drill (0.2). +/obj/item/pickaxe/drill/cyberware/deepcore + name = "deepcore drill" + desc = "A long drill bit with a diamond collar, wired straight into the forearm. It isn't coming off without a surgeon." + toolspeed = 0.3 + +/** + * # Deepcore drill fist (T2, arm aug, load 3) + * + * The Rockjaw with a heavier drill on the arm. The ore hopper and its button + * are the Rockjaw's own. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore + name = "\improper Deepcore drill fist" + desc = "A heavy drill folded into the forearm, built for rock the usual drills give up on." + icon_state = "rockjaw_deepcore" + chrome_load = 3 + tier = CYBERWARE_TIER_2 + items_to_create = list(/obj/item/pickaxe/drill/cyberware/deepcore) + +// ========================================================================= +// HOLDOUT HOUSING (street Popup Ronin) +// ========================================================================= + +/** + * The holdout's cylinder: six chambers of ordinary .38, thumbed in one round at + * a time. A speedloader feeds it a round per click, not the whole cylinder. + */ +/obj/item/ammo_box/magazine/internal/cylinder/rev38/cyberware_holdout + name = "holdout cylinder" + multiload = FALSE + +/** + * The gun the housing unfolds: a snub-nosed revolver on the stock chassis. NODROP + * while deployed comes from the toolkit Extend, so it can't be disarmed; Retract + * and EMP stow it. It leaves the shop loaded, and every reload after that is by + * hand, round by round. + */ +/obj/item/gun/ballistic/revolver/cyberware_holdout + name = "holdout revolver" + desc = "A snub-nosed revolver small enough to fold into a forearm. Uses .38 Special rounds." + icon = 'voidcrew/modules/cyberware/icons/cyberware_weapons.dmi' + icon_state = "ronin_holdout" + inhand_icon_state = "ronin_holdout" + lefthand_file = 'voidcrew/modules/cyberware/icons/cyberware_lefthand.dmi' + righthand_file = 'voidcrew/modules/cyberware/icons/cyberware_righthand.dmi' + accepted_magazine_type = /obj/item/ammo_box/magazine/internal/cylinder/rev38/cyberware_holdout + fire_sound = 'sound/items/weapons/gun/revolver/shot.ogg' + fire_delay = 0.4 SECONDS + /// How long each round takes to thumb into the cylinder. + var/reload_time = 1 SECONDS + +/// TRUE when a chamber is empty or holds a spent casing, so a round can go in. +/obj/item/gun/ballistic/revolver/cyberware_holdout/proc/cylinder_has_room() + if(!magazine) + return FALSE + for(var/slot in magazine.stored_ammo) + if(isnull(slot)) + return TRUE + // A path is a round the cylinder hasn't spawned yet, which is a live one. + if(!istype(slot, /obj/item/ammo_casing)) + continue + var/obj/item/ammo_casing/casing = slot + if(!casing.loaded_projectile) + return TRUE + return FALSE + +// Thumbing a round in takes a moment. A full cylinder is refused without a wait. +/obj/item/gun/ballistic/revolver/cyberware_holdout/load_gun(obj/item/ammo, mob/living/user) + if(user && cylinder_has_room() && !do_after(user, reload_time, target = src)) + return FALSE + return ..() + +/** + * # Holdout housing (T2, one arm, aug slot, load 3) + * + * A fold-out forearm revolver for the yellow zone: six shots of ordinary .38, + * loaded by hand. Anyone who looks at the bearer sees the housing in the arm. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout + name = "\improper Holdout housing" + desc = "A forearm housing with a snub-nosed revolver folded inside. Not much to look at, which is the idea." + icon_state = "ronin_holdout" + chrome_load = 3 + tier = CYBERWARE_TIER_2 + aug_overlay = "ronin_holdout" + items_to_create = list(/obj/item/gun/ballistic/revolver/cyberware_holdout) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout/on_mob_insert(mob/living/carbon/arm_owner, special = FALSE, movement_flags) + . = ..() + RegisterSignal(arm_owner, COMSIG_ATOM_EXAMINE, PROC_REF(on_owner_examined)) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout/on_mob_remove(mob/living/carbon/arm_owner, special = FALSE, movement_flags) + . = ..() + UnregisterSignal(arm_owner, COMSIG_ATOM_EXAMINE) + +/// Signal proc for [COMSIG_ATOM_EXAMINE] on the bearer: the housing shows in the +/// arm to anyone who looks, suit or no suit. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout/proc/on_owner_examined(mob/living/carbon/source, mob/user, list/examine_list) + SIGNAL_HANDLER + examine_list += span_notice("[source.p_They()] [source.p_have()] a revolver housing set into [source.p_their()] [parse_zone(zone)].") + +// ========================================================================= +// SPLICE SKUS: on the Chop Shop's sku_types (ripperdoc_catalog.dm), and the +// credit-priced ones on the Back Bay's too (street_doc_catalog.dm). +// ========================================================================= + +/datum/shop_sku/ripperdoc/hopper_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/hopper/street + price_credits = 1800 + +/datum/shop_sku/ripperdoc/hopper_milspec + zone_permission = ZONE_PERMISSION_ADVANCED + category = "Military Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/hopper/milspec + price_vouchers = 3 + +/datum/shop_sku/ripperdoc/gorilla_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + name = "Brawler Myomers (pair)" + desc = "A cased pair of cheap myomer forearms." + item_path = /obj/item/cyberware_pair_case/gorilla_arms/street + price_credits = 2000 + stock_min = 1 + stock_max = 2 + fixed_price = TRUE + contract_reward = FALSE + +/datum/shop_sku/ripperdoc/fixers_street + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street + price_credits = 700 + +/datum/shop_sku/ripperdoc/rockjaw_deepcore + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore + price_credits = 2400 + +/datum/shop_sku/ripperdoc/ronin_holdout + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + desc = "A snub-nosed revolver folded into a chrome forearm." + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout + price_credits = 2400 + stock_min = 1 + stock_max = 2 + fixed_price = TRUE + contract_reward = FALSE + +// ========================================================================= +// INTAKE LEDGERS: half the shelf price, credits only, like the other street +// rungs. The Vaulter costs vouchers, which can't be refunded, so it has no +// entry. Ratchet's subtypes carry his wording and are listed beside Splice's. +// ========================================================================= + +/datum/shop_buyback/ripperdoc/hopper_street + name = "Spring calves (pulled)" + desc = "Used calf springs. They squeak." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/hopper/street + match_subtypes = FALSE + pay_credits = 900 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/hopper_street/street_doc + desc = "A used pair of calf springs." + +/datum/shop_buyback/ripperdoc/gorilla_street + name = "Brawler myomers (pulled)" + desc = "One myomer arm, either side." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/gorilla_arms/street + match_subtypes = TRUE + pay_credits = 500 + demand_min = 2 + demand_max = 4 + +/datum/shop_buyback/ripperdoc/gorilla_street/street_doc + desc = "One used myomer arm, either side." + +/datum/shop_buyback/ripperdoc/fixers_street + name = "Tinker's fingers (pulled)" + desc = "A used fingertip tool suite." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street + match_subtypes = FALSE + pay_credits = 350 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/fixers_street/street_doc + desc = "A used set of fingertip tools, a bit loose." + +/datum/shop_buyback/ripperdoc/rockjaw_deepcore + name = "Deepcore drill fist (pulled)" + desc = "A used drill fist. The bit's still sharp." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore + match_subtypes = FALSE + pay_credits = 1200 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/rockjaw_deepcore/street_doc + desc = "A used drill fist, ore hopper and all." + +/datum/shop_buyback/ripperdoc/ronin_holdout + name = "Holdout housing (pulled)" + desc = "A used revolver housing." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout + match_subtypes = FALSE + pay_credits = 1200 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/ronin_holdout/street_doc + desc = "A used revolver housing, cylinder and all." diff --git a/voidcrew/modules/cyberware/ware_line_sandy.dm b/voidcrew/modules/cyberware/ware_line_sandy.dm new file mode 100644 index 00000000000..303ff54f346 --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_sandy.dm @@ -0,0 +1,132 @@ +/** + * # The Cascade line: street and service-grade reflex rigs + * + * Two cheaper ways into the chest OS slot's speed core, both subtypes of the + * Cascade Lattice (ware_legend.dm) so they share its slot, its EMP rule, its + * crash-on-removal rule and its window code. Installing any of the three + * evicts the other two, and the Redline family sits in the same slot, so a + * crew climbs this ladder by swapping in the next rung. + * + * Each rung trades window strength for a worse bill: the lower the model, the + * slower the gait, the thinner the dodge and the melee boost, and the longer + * and nastier the crash. Window length stays nearly flat. The telegraphs are + * the same at every rung (the activation, the afterimages, the crash), just + * duller and sparser on the cheap chrome. + * + * model window gait dodge crit melee crash stamina cooldown load + * street 6 s -0.5 30 +9 x0.75 8 s 90 120 s 6 + * service 7 s -0.75 45 +14 x0.6 7 s 90 90 s 9 + * Cascade T4 8 s -1 60 +18 x0.5 6 s 80 60 s 12 + * + * The dodge covers ranged fire while moving and blows whether moving or not + * (the shared arbiter in ware_pro_combat.dm). The crit column is added to the + * aimed-crit roll of the bearer's own hits (crit_roll.dm): on a 25+ damage + * hit's 1 to 90 roll that is about +10, +15 and +20 points of chance. + * + * Sold at Splice's counter. The street model is credits, behind the yellow + * step, and trades in at the Intake ledger; the service model is vouchers + * behind the advanced step. + */ + +// ========================================================================= +// STREET MODEL (T2) +// ========================================================================= + +/obj/item/organ/cyberimp/cyberware/cascade/street + name = "spliced reflex rig" + desc = "A spinal reflex rig cobbled together from salvaged parts and a lot of tape. The scorch marks came with it." + icon_state = "cascade_street" + chrome_load = 6 + tier = CYBERWARE_TIER_2 + aug_overlay = "cascade_street" + actions_types = list(/datum/action/cooldown/cyberware/cascade_surge/street) + window_duration = 6 SECONDS + crash_duration = 8 SECONDS + crash_stamina = 90 + window_dodge = 30 + window_crit_bonus = 9 + window_speed = /datum/movespeed_modifier/cyberware_cascade/street + window_melee_mult = 0.75 + window_colour = /datum/client_colour/cyberware_cascade/street + afterimage_interval = 3 + afterimage_alpha = 120 + window_alert = /atom/movable/screen/alert/status_effect/cyberware_cascade/aftermarket + online_message = "REFLEX RIG ONLINE." + +/datum/action/cooldown/cyberware/cascade_surge/street + name = "Reflex Surge" + desc = "Six seconds of speed: melee cooldowns cut by a quarter, hits land harder, and a 30% chance to dodge blows, or ranged fire on the move. Then eight seconds of crash." + cooldown_time = 120 SECONDS + +/datum/movespeed_modifier/cyberware_cascade/street + multiplicative_slowdown = -0.5 + +/// The street rig's screen: the lattice's tint, a quarter as strong. +/datum/client_colour/cyberware_cascade/street + color = list(1.025, 0, 0.02, 0.0125, 1.0125, 0.025, 0.025, 0, 1.05) + +// ========================================================================= +// SERVICE MODEL (T3) +// ========================================================================= + +/obj/item/organ/cyberimp/cyberware/cascade/milspec + name = "service reflex lattice" + desc = "A decommissioned military reflex lattice. The serial plate has been ground off, but the stencilling on the casing is still there." + icon_state = "cascade_milspec" + chrome_load = 9 + tier = CYBERWARE_TIER_3 + aug_overlay = "cascade_milspec" + actions_types = list(/datum/action/cooldown/cyberware/cascade_surge/milspec) + window_duration = 7 SECONDS + crash_duration = 7 SECONDS + crash_stamina = 90 + window_dodge = 45 + window_crit_bonus = 14 + window_speed = /datum/movespeed_modifier/cyberware_cascade/milspec + window_melee_mult = 0.6 + window_colour = /datum/client_colour/cyberware_cascade/milspec + afterimage_interval = 2 + afterimage_alpha = 160 + window_alert = /atom/movable/screen/alert/status_effect/cyberware_cascade/aftermarket + online_message = "LATTICE ONLINE." + +/datum/action/cooldown/cyberware/cascade_surge/milspec + name = "Reflex Surge" + desc = "Seven seconds of speed: melee cooldowns cut by 40%, hits land harder, and a 45% chance to dodge blows, or ranged fire on the move. Then seven seconds of crash." + cooldown_time = 90 SECONDS + +/datum/movespeed_modifier/cyberware_cascade/milspec + multiplicative_slowdown = -0.75 + +/// The service lattice's screen: the lattice's tint, half as strong. +/datum/client_colour/cyberware_cascade/milspec + color = list(1.05, 0, 0.04, 0.025, 1.025, 0.05, 0.05, 0, 1.1) + +// ========================================================================= +// SPLICE SKUs and INTAKE LEDGER +// The lead wires these into /datum/outpost_shop/vendor/ripperdoc (sku_types, +// buyback_types) and the zone loot tables at integration. +// ========================================================================= + +/datum/shop_sku/ripperdoc/cascade_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/cascade/street + price_credits = 3600 + +/datum/shop_sku/ripperdoc/cascade_milspec + zone_permission = ZONE_PERMISSION_ADVANCED + category = "Military Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/cascade/milspec + price_vouchers = 4 + +/// Half list, credits only, like the rest of the ladder's street rungs. +/datum/shop_buyback/ripperdoc/cascade_street + name = "Spliced Reflex Rig (pulled)" + desc = "A taped-together spinal rig. Splice strips it for parts toward a proper lattice." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/cascade/street + match_subtypes = FALSE + pay_credits = 1800 + demand_min = 1 + demand_max = 2 diff --git a/voidcrew/modules/cyberware/ware_line_widowline.dm b/voidcrew/modules/cyberware/ware_line_widowline.dm new file mode 100644 index 00000000000..d01e197a7ef --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_widowline.dm @@ -0,0 +1,234 @@ +/** + * # Widowline line: the Arc model + * + * The Widowline monowire (ware_military_arms.dm) with a capacitor stack on the + * spool. Everything the plain wire does still happens, and every landed hit + * adds a shock on top: + * + * - Living targets take a little burn and a short stagger. The current goes in + * through the wire itself, so it is run with SHOCK_NOGLOVES and insulated + * gloves do nothing. Everything else tg's shock code already honours still + * applies: TRAIT_SHOCKIMMUNE, insulating suits and species or physiology + * shock coefficients. A target the shock can't reach takes only the plain + * cut: no burn, no stagger, no arc. + * - Silicons, mechs and robotic mobs (MOB_ROBOTIC) take a heavy burn bonus. + * The plain wire is nearly useless against them (its demolition_mod), and + * this is what makes up for it. Silicons shrug electrocute_act off by signal, + * so they get the bonus alone. + * - A turret, a ship laser turret, a console or a camera is knocked out for a + * few seconds. Never a raw emp_act: an EMP blacks out an APC for a minute, + * pops airlocks open, drains a laser turret's cell and scrambles a + * porta-turret's targeting flags. Each family is cut through its own + * machinery (the Icepick Jack's precedent), consoles lose power briefly, and + * anything that answers tg's on_saboteur() hook (cameras) goes through that. + * Outpost property and the trader outposts' concourse are immune. + * + * The through-cut is untouched: the body behind takes the plain cut, not the shock. + */ + +/// Burn of the shock itself, on top of the cut and the wire's own charge. +#define CYBERWARE_ARC_SHOCK_BURN 5 +/// Stagger a landed shock leaves, and the most it stacks to. +#define CYBERWARE_ARC_STAGGER (2 SECONDS) +#define CYBERWARE_ARC_STAGGER_CAP (4 SECONDS) +/// Burn bonus on silicons, mechs and robotic mobs. +#define CYBERWARE_ARC_ROBOTIC_BONUS 25 +/// How long a shorted turret, console or camera stays dark. +#define CYBERWARE_ARC_JAM_DURATION (5 SECONDS) +/// Gap before the same wire can short another machine. +#define CYBERWARE_ARC_JAM_RECHARGE (15 SECONDS) + +/** + * The wire. Plain Widowline numbers (force, burn, cleave, reach, armour + * penetration, demolition_mod) are inherited as they are; the vars here are + * the shock rider only. All of it keys off afterattack(), which only runs for + * a swing that actually landed, on a mob or on an object that can be hit. + */ +/obj/item/melee/cyberware_monowire/live + name = "\improper Widowline Arc monowire" + desc = "A weighted spool of monomolecular line with a capacitor stack feeding it. It smells of ozone and ticks like a cooling engine." + icon_state = "monowire_live" + inhand_icon_state = "monowire_live" + /// Burn of the shock on a living target. + var/shock_burn = CYBERWARE_ARC_SHOCK_BURN + /// Stagger a landed shock leaves. + var/stagger_time = CYBERWARE_ARC_STAGGER + /// Most stagger the shock stacks to. + var/stagger_cap = CYBERWARE_ARC_STAGGER_CAP + /// Burn bonus on silicons, mechs and robotic mobs. + var/robotic_bonus = CYBERWARE_ARC_ROBOTIC_BONUS + /// How long a shorted machine stays down. + var/jam_duration = CYBERWARE_ARC_JAM_DURATION + /// Gap before this wire can short another machine. + var/jam_recharge = CYBERWARE_ARC_JAM_RECHARGE + /// The stack recharging after a machine was shorted. + COOLDOWN_DECLARE(jam_cooldown) + +/obj/item/melee/cyberware_monowire/live/afterattack(atom/target, mob/user, list/modifiers, list/attack_modifiers) + . = ..() + if(!isliving(user) || QDELETED(target) || target == user) + return + // The lash out to what it hit is every wire's (ware_military_arms.dm); the shock is this one's. + if(isliving(target)) + discharge_into_mob(target, user) + else if(ismecha(target)) + discharge_into_mech(target, user) + else if(ismachinery(target)) + discharge_into_machine(target, user) + +/// On a body while the Arc's charge goes into it: no shock shake (do_jitter_animation()). +#define TRAIT_ARC_NO_SHAKE "arc_no_shake" + +/mob/living/do_jitter_animation(jitter_amount = 100) + if(HAS_TRAIT(src, TRAIT_ARC_NO_SHAKE)) + return + return ..() + +/// The shock on whatever it went into: a small crackle where the wire touched +/// (cyberware_anim2.dm). The lash is the picture, never a bolt or a shower of sparks. +/obj/item/melee/cyberware_monowire/live/proc/arc_visuals(atom/target, mob/living/user) + cyberware_arc_crackle_fx(user, target, lash_zone || check_zone(user?.zone_selected)) + playsound(target, SFX_SPARKS, 50, TRUE) + cyberware_ink_pulse(user, CYBERWARE_INK_SOFT) + +/** + * The shock into a living target. Returns TRUE if anything landed. + * Dead and shock-immune targets are skipped entirely; see the file header for + * what counts as shock-immune. + */ +/obj/item/melee/cyberware_monowire/live/proc/discharge_into_mob(mob/living/target, mob/living/user) + if(target.stat == DEAD || HAS_TRAIT(target, TRAIT_SHOCKIMMUNE)) + return FALSE + var/jolted = FALSE + var/is_silicon = issilicon(target) + // No stun, no message, no skeleton flash, no jitter: the lash and its + // crackle are the tell, and the stagger is the whole effect on the body. + // tg's shock shakes a body for over two seconds whatever jitter it is + // given, so the shake is held off while the charge goes in. + if(!is_silicon) + ADD_TRAIT(target, TRAIT_ARC_NO_SHAKE, REF(src)) + jolted = target.electrocute_act(shock_burn, user, 1, SHOCK_NOGLOVES | SHOCK_NOSTUN | SHOCK_SUPPRESS_MESSAGE | SHOCK_NO_HUMAN_ANIM, 0, 0, 0) ? TRUE : FALSE + REMOVE_TRAIT(target, TRAIT_ARC_NO_SHAKE, REF(src)) + if(is_silicon || (target.mob_biotypes & MOB_ROBOTIC)) + var/bonus_zone = target.get_random_valid_zone(user.zone_selected) + target.apply_damage( + robotic_bonus, + BURN, + bonus_zone, + target.run_armor_check(bonus_zone, ENERGY, armour_penetration = armour_penetration, silent = TRUE), + ) + jolted = TRUE + if(!jolted) + return FALSE + arc_visuals(target, user) + if(!QDELETED(target)) + target.adjust_staggered_up_to(stagger_time, stagger_cap) + return TRUE + +/// The burn bonus into a mech's armour. The pilot is not touched. +/obj/item/melee/cyberware_monowire/live/proc/discharge_into_mech(obj/vehicle/sealed/mecha/mech, mob/living/user) + if(QDELETED(mech) || mech.atom_integrity <= 0 || HAS_TRAIT(mech, TRAIT_OUTPOST_PROPERTY) || is_trader_outpost_protected(mech)) + return FALSE + mech.take_damage(robotic_bonus, BURN, ENERGY, FALSE, get_dir(mech, user), armour_penetration) + arc_visuals(mech, user) + return TRUE + +/** + * Shorts a machine out for a few seconds, if it is one that can be. Returns + * TRUE if it went dark. The recharge only starts on a machine that actually + * went dark, so a wasted swing at a vending machine costs nothing. + */ +/obj/item/melee/cyberware_monowire/live/proc/discharge_into_machine(obj/machinery/machine, mob/living/user) + if(QDELETED(machine) || HAS_TRAIT(machine, TRAIT_OUTPOST_PROPERTY) || is_trader_outpost_protected(machine)) + return FALSE + if(!COOLDOWN_FINISHED(src, jam_cooldown) || !jam_machine(machine)) + // Still crackles, goes nowhere. + do_sparks(1, TRUE, machine) + return FALSE + COOLDOWN_START(src, jam_cooldown, jam_recharge) + arc_visuals(machine, user) + machine.visible_message(span_warning("[machine] crackles and goes dark.")) + return TRUE + +/// Cuts the machine through its own family's machinery. Returns TRUE if it was knocked out. +/obj/item/melee/cyberware_monowire/live/proc/jam_machine(obj/machinery/machine) + if(machine.machine_stat & BROKEN) + return FALSE + if(istype(machine, /obj/machinery/porta_turret)) + // Outpost sanctuary turrets are immune, as against the Icepick Jack. + if(istype(machine, /obj/machinery/porta_turret/outpost)) + return FALSE + var/obj/machinery/porta_turret/turret = machine + if(!COOLDOWN_FINISHED(turret, disabled_time)) + return FALSE + turret.set_disabled(jam_duration) + return TRUE + if(istype(machine, /obj/machinery/ship_combat/laser_turret)) + var/obj/machinery/ship_combat/laser_turret/laser = machine + // Its fire cooldown is also its normal reload; never shorten that. + if(COOLDOWN_TIMELEFT(laser, fire_cooldown) >= jam_duration) + return FALSE + COOLDOWN_START(laser, fire_cooldown, jam_duration) + return TRUE + if(istype(machine, /obj/machinery/computer)) + return cyberware_arc_power_cut(machine, jam_duration) + // Cameras answer here; anything else with no answer is left alone. + return !!machine.on_saboteur(src, jam_duration) + +/** + * Drops a machine's power for a moment, the same flag an area blackout sets + * and the same way back: power_change() works the real state out again. + * Returns FALSE for a machine that is already down or draws no power. + */ +/proc/cyberware_arc_power_cut(obj/machinery/machine, duration) + if(machine.use_power == NO_POWER_USE || (machine.machine_stat & (NOPOWER | BROKEN | MAINT | EMPED))) + return FALSE + machine.set_machine_stat(machine.machine_stat | NOPOWER) + SEND_SIGNAL(machine, COMSIG_MACHINERY_POWER_LOST) + machine.update_appearance() + machine.set_light(0) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cyberware_arc_power_restore), machine), duration) + return TRUE + +/// End of a power cut. Global so it survives the machine being deleted meanwhile. +/proc/cyberware_arc_power_restore(obj/machinery/machine) + if(QDELETED(machine)) + return + // power_change() leaves a broken machine's flags alone, so a machine that + // broke while it was dark would stay unpowered after it was repaired. + if(machine.machine_stat & BROKEN) + machine.set_machine_stat(machine.machine_stat & ~NOPOWER) + machine.power_change() + +/** + * # Widowline Arc spool housing (T3, one arm, aug slot, load 6) + * + * The Widowline spool housing, stepped up. Same slot, same arm, so installing + * one evicts the other. Sold at the Chop Shop for vouchers and never bought + * back, like the plain Widowline. + */ +/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live + name = "\improper Widowline Arc spool housing" + desc = "A wrist spool wound with monomolecular line, with a capacitor stack bolted on where the safety used to be." + icon_state = "monowire_live" + chrome_load = 6 + items_to_create = list(/obj/item/melee/cyberware_monowire/live) + +/datum/shop_sku/ripperdoc/monowire_live + zone_permission = ZONE_PERMISSION_ELITE + category = "Military Chrome" + item_path = /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live + price_vouchers = 5 + stock_min = 1 + stock_max = 1 + convoys_per_unit = 3 + fixed_price = TRUE + contract_reward = FALSE + +#undef CYBERWARE_ARC_SHOCK_BURN +#undef CYBERWARE_ARC_STAGGER +#undef CYBERWARE_ARC_STAGGER_CAP +#undef CYBERWARE_ARC_ROBOTIC_BONUS +#undef CYBERWARE_ARC_JAM_DURATION +#undef CYBERWARE_ARC_JAM_RECHARGE +#undef TRAIT_ARC_NO_SHAKE diff --git a/voidcrew/modules/cyberware/ware_line_zoom.dm b/voidcrew/modules/cyberware/ware_line_zoom.dm new file mode 100644 index 00000000000..e826a570699 --- /dev/null +++ b/voidcrew/modules/cyberware/ware_line_zoom.dm @@ -0,0 +1,210 @@ +/** + * # The optics line: zoom by tier + * + * Every chrome optic zooms (cyberware_zoom.dm). Reach climbs with the tier, and + * the dedicated scout optics reach half a step further than combat or survey + * optics of the same tier. The cheap ones slow their bearer while zoomed. + * + * model tier load zoom walk tax read other + * Spyglass 1 1 1.0 1.0 silhouette nothing + * Assay 1 1 1.0 1.0 silhouette short ore pulse, no caches + * Nightshade 1 1 1.0 1.0 silhouette unchanged + * Prospector 2 2 1.5 0.5 itemized unchanged + * Deadeye 2 3 1.5 0.5 itemized unchanged + * Longsight 2 2 2.0 none itemized, 9 nothing + * Marksman link 3 4 2.0 none itemized 4 tracked shots, 10 tiles, 18 s + * Lookout 3 3 2.5 none itemized, 11 8 s read, low-light + * + * Binoculars (4) stay the reach ceiling, since they cost both hands. All of + * these ride ORGAN_SLOT_EYES, so installing one replaces whatever eyes the + * bearer had. Spyglass, Longsight and Lookout are their own types on the optics + * base; Assay optics subtype the Prospector and the Marksman link the Deadeye, + * so they keep their parents' ability code. + */ + +// ========================================================================= +// SPYGLASS OPTICS (T1) +// ========================================================================= + +/obj/item/organ/eyes/robotic/cyberware/spyglass + name = "spyglass optics" + desc = "Cheap chrome eyes with a telescoping lens behind each iris. They see a long way and not much else." + icon_state = "spyglass" + eye_color_left = "#7a6a4f" + eye_color_right = "#7a6a4f" + iris_overlay = null + chrome_load = 1 + tier = CYBERWARE_TIER_1 + chrome_scan_resolution = CYBERWARE_SCAN_SILHOUETTE + optics_zoom = 1 + zoom_walk_penalty = 1 + +// ========================================================================= +// ASSAY OPTICS (T1), the Prospector's street model +// ========================================================================= + +/obj/item/organ/eyes/robotic/cyberware/prospector/street + name = "assay optics" + desc = "Surveyor eyes off a mining co-op's bargain shelf. The pulse is short and the lenses are scratched, but ore still lights up through the rock." + icon_state = "prospector_street" + eye_color_left = "#8a6a1f" + eye_color_right = "#8a6a1f" + chrome_load = 1 + tier = CYBERWARE_TIER_1 + chrome_scan_resolution = CYBERWARE_SCAN_SILHOUETTE + actions_types = list( + /datum/action/cooldown/cyberware/prospector_pulse/assay, + /datum/action/cooldown/cyberware/chrome_read, + ) + optics_zoom = 1 + zoom_walk_penalty = 1 + pulse_range = 5 + pulse_marks_caches = FALSE + +/datum/action/cooldown/cyberware/prospector_pulse/assay + desc = "Ping ore veins through rock." + cooldown_time = 15 SECONDS + +// ========================================================================= +// LONGSIGHT OPTICS (T2 scout) +// ========================================================================= + +/obj/item/organ/eyes/robotic/cyberware/longsight + name = "longsight optics" + desc = "Scout optics with a long lens stack behind each iris. They pick out a face across a hangar bay." + icon_state = "longsight" + eye_color_left = "#3f6f8f" + eye_color_right = "#3f6f8f" + iris_overlay = null + chrome_load = 2 + tier = CYBERWARE_TIER_2 + optics_zoom = 2 + zoom_walk_penalty = 0 + chrome_read_range = 9 + +// ========================================================================= +// MARKSMAN LINK (T3), the Deadeye's service model +// ========================================================================= + +/obj/item/organ/eyes/robotic/cyberware/deadeye/milspec + name = "marksman link" + desc = "Service-grade targeting optics, the unit stencil still on the housing. The coprocessor is a generation newer than the Deadeye's." + icon_state = "deadeye_milspec" + chrome_load = 4 + tier = CYBERWARE_TIER_3 + actions_types = list( + /datum/action/cooldown/cyberware/deadeye_tag/marksman, + /datum/action/cooldown/cyberware/chrome_read, + ) + optics_zoom = 2 + zoom_walk_penalty = 0 + tag_range = 10 + tag_shots = 4 + tag_duration = 15 SECONDS + +/datum/action/cooldown/cyberware/deadeye_tag/marksman + name = "Marksman Tag" + desc = "Tag a hostile in view. Your next four shots track them." + cooldown_time = 18 SECONDS + +// ========================================================================= +// LOOKOUT OPTICS (T3 scout) +// ========================================================================= + +/obj/item/organ/eyes/robotic/cyberware/lookout + name = "lookout optics" + desc = "Military spotter eyes with a low-light amplifier. Made for lying on a ridge and watching a camp for hours." + icon_state = "lookout" + eye_color_left = "#2d4a2a" + eye_color_right = "#2d4a2a" + iris_overlay = null + // The Nightshade's dark floor, without its green. + lighting_cutoff = LIGHTING_CUTOFF_MEDIUM + chrome_load = 3 + tier = CYBERWARE_TIER_3 + optics_zoom = 2.5 + zoom_walk_penalty = 0 + chrome_read_range = 11 + chrome_read_cooldown = 8 SECONDS + +// ========================================================================= +// SPLICE SKUs and INTAKE LEDGER +// Listed on /datum/outpost_shop/vendor/ripperdoc (sku_types, buyback_types) +// and on the street doc's lists (the credit-priced three and their +// /street_doc trade-ins). The optics also ride the zone loot tables. +// ========================================================================= + +/datum/shop_sku/ripperdoc/spyglass + category = "Street Chrome" + desc = "A pair of chrome telescoping optics." + item_path = /obj/item/organ/eyes/robotic/cyberware/spyglass + price_credits = 400 + stock_min = 1 + stock_max = 3 + +/datum/shop_sku/ripperdoc/assay_optics + category = "Street Chrome" + desc = "A pair of budget surveyor optics." + item_path = /obj/item/organ/eyes/robotic/cyberware/prospector/street + price_credits = 900 + +/datum/shop_sku/ripperdoc/longsight + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + desc = "A pair of long-lens scout optics." + item_path = /obj/item/organ/eyes/robotic/cyberware/longsight + price_credits = 2400 + +/datum/shop_sku/ripperdoc/deadeye_milspec + zone_permission = ZONE_PERMISSION_ADVANCED + category = "Military Chrome" + item_path = /obj/item/organ/eyes/robotic/cyberware/deadeye/milspec + price_vouchers = 3 + +/datum/shop_sku/ripperdoc/lookout + zone_permission = ZONE_PERMISSION_ADVANCED + category = "Military Chrome" + item_path = /obj/item/organ/eyes/robotic/cyberware/lookout + price_vouchers = 3 + +/// Half list, credits only, like the rest of the ladder's credit rungs. +/datum/shop_buyback/ripperdoc/spyglass + name = "Spyglass Optics (pulled)" + desc = "Cheap zoom eyes. Splice takes them toward a better pair." + category = "Trade-In" + item_path = /obj/item/organ/eyes/robotic/cyberware/spyglass + match_subtypes = FALSE + pay_credits = 200 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/assay_optics + name = "Assay Optics (pulled)" + desc = "Budget surveyor eyes, lenses scratched." + category = "Trade-In" + item_path = /obj/item/organ/eyes/robotic/cyberware/prospector/street + match_subtypes = FALSE + pay_credits = 450 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/longsight + name = "Longsight Optics (pulled)" + desc = "Scout eyes, lenses intact. Splice strips the glass for a spotter rig." + category = "Trade-In" + item_path = /obj/item/organ/eyes/robotic/cyberware/longsight + match_subtypes = FALSE + pay_credits = 1200 + demand_min = 1 + demand_max = 2 + +// Ratchet's ledger: the same entries in his words, same pay. + +/datum/shop_buyback/ripperdoc/spyglass/street_doc + desc = "Used zoom eyes." + +/datum/shop_buyback/ripperdoc/assay_optics/street_doc + desc = "Used survey eyes. Scratched, like they all are." + +/datum/shop_buyback/ripperdoc/longsight/street_doc + desc = "Used scout eyes." diff --git a/voidcrew/modules/cyberware/ware_military_arms.dm b/voidcrew/modules/cyberware/ware_military_arms.dm index cb46862d5ea..eef698851ac 100644 --- a/voidcrew/modules/cyberware/ware_military_arms.dm +++ b/voidcrew/modules/cyberware/ware_military_arms.dm @@ -23,7 +23,7 @@ */ /obj/item/cyberware_pair_case name = "cyberware pair case" - desc = "A foam-lined clamshell case for a matched set of chrome. Crack it open in hand." + desc = "A foam-lined clamshell case for a matched set of chrome." icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' icon_state = "ware_case" w_class = WEIGHT_CLASS_NORMAL @@ -39,7 +39,7 @@ . = ..() if(length(contents)) . += span_notice("Nestled in the foam: [english_list(contents)].") - . += span_notice("Use it in hand to crack it open.") + /obj/item/cyberware_pair_case/attack_self(mob/user, modifiers) . = ..() @@ -61,7 +61,7 @@ /obj/item/cyberware_pair_case/gorilla_arms name = "\improper Gorilla Arms case" - desc = "A heavy clamshell case stenciled with a fist. Two myomer lattices inside, one per arm. The Cradle installs the pair in one sitting." + desc = "A heavy clamshell case stenciled with a fist. Two myomer lattices inside, one per arm." ware_types = list( /obj/item/organ/cyberimp/cyberware/gorilla_arms, /obj/item/organ/cyberimp/cyberware/gorilla_arms/left, @@ -114,7 +114,7 @@ */ /obj/item/organ/cyberimp/cyberware/gorilla_arms name = "\improper Gorilla Arms myomer lattice (right)" - desc = "A myomer weave anchored bone-deep through the arm. You don't look any stronger for it; you just start pulling closed airlocks open with your bare hands." + desc = "A myomer weave anchored bone-deep through the arm. You don't look any stronger for it; doors just stop being your problem." icon_state = "gorilla" zone = BODY_ZONE_R_ARM slot = ORGAN_SLOT_RIGHT_ARM_AUG @@ -128,6 +128,23 @@ aug_overlay = "gorilla_right" /// Rate limit on this arm's empowered hits. COOLDOWN_DECLARE(slam_cooldown) + // The defines above are the Gorilla defaults. They live in vars so the other + // models of the line (ware_line_models_a.dm) can retune by setting them. + /// Flat brute per empowered punch. + var/punch_damage = CYBERWARE_GORILLA_PUNCH_DAMAGE + /// Damage per structure/machine smash. + var/structure_damage = CYBERWARE_GORILLA_STRUCTURE_DAMAGE + /// Gap between empowered punches, per arm. + var/punch_cooldown_time = CYBERWARE_GORILLA_PUNCH_COOLDOWN + /// Gap between structure smashes / rock breaks, per arm. + var/smash_cooldown_time = CYBERWARE_GORILLA_SMASH_COOLDOWN + /// How far an aggressively-grabbed victim gets hurled. 0 or less: no hurl, + /// the grabbed victim takes the ordinary slam. + var/hurl_range = CYBERWARE_GORILLA_HURL_RANGE + /// Whether a matched pair of these pries closed airlocks (the set bonus). + var/pries_doors = TRUE + /// The set bonus a matched pair of this model syncs into. Each model has its own, so a mixed pair syncs into neither. + var/pair_bonus = /datum/status_effect/organ_set_bonus/cyberware_gorilla /obj/item/organ/cyberimp/cyberware/gorilla_arms/left name = "\improper Gorilla Arms myomer lattice (left)" @@ -137,7 +154,11 @@ /obj/item/organ/cyberimp/cyberware/gorilla_arms/Initialize(mapload) . = ..() - AddElement(/datum/element/organ_set_bonus, /datum/status_effect/organ_set_bonus/cyberware_gorilla) + if(pries_doors && pair_bonus) + AddElement(/datum/element/organ_set_bonus, pair_bonus) + // Each real arm winds up a haymaker; both share the pistons' cooldown (hyperviolence_gorilla/gorilla_haymaker.dm) + if(heavy_moves) + add_item_action(/datum/action/cooldown/cyberware/gorilla_haymaker) /** * Worn-chrome overlay hook. Gorilla Arms replace the limb outright, hand @@ -146,12 +167,11 @@ * sits well above CYBERWARE_WORN_LAYER, so a plate drawn only at the chrome * layer gets painted back over by bare knuckles. * - * One image cannot fix that. The hand already draws above UNIFORM_LAYER, so - * anything stacked over the hand is also stacked over the jumpsuit, and the - * chrome layer exists precisely to stay under worn clothing. Instead we do what - * tg's own toolkit augments do (augments_arms.dm's hand_state): the arm plate - * keeps the chrome layer and hides under sleeves, and a separate "_hand" plate - * rides at the hand's own layer, where gloves still cover it like real skin. + * Lifting the whole arm plate above the hand would also lift it over the worn + * ID. Instead we do what tg's own toolkit augments do (augments_arms.dm's + * hand_state): the arm plate keeps the chrome layer, over the sleeve, and a + * separate "_hand" plate rides at the hand's own layer, where gloves still + * cover it like real skin. * * The sheet may ship without the hand plate. Then this is a no-op and the arm * plate renders alone, exactly as it did before. @@ -198,7 +218,28 @@ source.do_attack_animation(rock, ATTACK_EFFECT_SMASH) playsound(rock, 'sound/effects/meteorimpact.ogg', 30, TRUE) rock.gets_drilled(source, 1) - COOLDOWN_START(src, slam_cooldown, CYBERWARE_GORILLA_SMASH_COOLDOWN) + COOLDOWN_START(src, slam_cooldown, smash_cooldown_time) + return COMPONENT_CANCEL_ATTACK_CHAIN + + // Someone held in an aggressive grab, brought down on the floor or a table (hyperviolence_gorilla/gorilla_punch.dm). + // Before the structure smash, so a table click while grabbing slams them instead of caving the table in. + switch(try_slam(source, target, active_hand)) + if(GORILLA_SLAM_DONE) + COOLDOWN_START(src, slam_cooldown, punch_cooldown_time) + return COMPONENT_CANCEL_ATTACK_CHAIN + if(GORILLA_SLAM_PASS) + return NONE + + // A trader outpost's doors hold against a fist as they do against a pry, and trying counts against you + // (hyperviolence_gorilla/gorilla_pry.dm). + if(istype(target, /obj/machinery/door) && gorilla_pry_refused(target)) + source.changeNext_move(CLICK_CD_MELEE) + source.do_attack_animation(target, ATTACK_EFFECT_SMASH) + playsound(target, 'sound/items/weapons/tap.ogg', 50, TRUE) + target.balloon_alert(source, "it won't budge!") + gorilla_pry_aggression(target, source) + source.log_message("punched [target] at a trader outpost, located at [loc_name(target)].", LOG_GAME) + COOLDOWN_START(src, slam_cooldown, smash_cooldown_time) return COMPONENT_CANCEL_ATTACK_CHAIN // Structures, girders, machines cave in. Loose items are beneath us. @@ -213,11 +254,12 @@ span_danger("[source] caves [smashed] in with a piston-driven fist!"), span_danger("You cave [smashed] in!"), ) - smashed.take_damage(CYBERWARE_GORILLA_STRUCTURE_DAMAGE, BRUTE, MELEE) - COOLDOWN_START(src, slam_cooldown, CYBERWARE_GORILLA_SMASH_COOLDOWN) + smashed.take_damage(structure_damage, BRUTE, MELEE) + COOLDOWN_START(src, slam_cooldown, smash_cooldown_time) return COMPONENT_CANCEL_ATTACK_CHAIN - if(!isliving(target)) + // A pacifist's punch at a living thing is the ordinary punch, which refuses it. + if(!isliving(target) || HAS_TRAIT(source, TRAIT_PACIFISM)) return NONE if(!source.can_unarmed_attack()) return COMPONENT_SKIP_ATTACK @@ -227,37 +269,19 @@ if(ishuman(living_target)) var/mob/living/carbon/human/human_target = living_target - if(human_target.check_block(source, CYBERWARE_GORILLA_PUNCH_DAMAGE, "[source]'s piston punch")) + if(human_target.check_block(source, punch_damage, "[source]'s piston punch")) source.do_attack_animation(living_target) playsound(living_target.loc, 'sound/items/weapons/punchmiss.ogg', 25, TRUE, -1) log_combat(source, living_target, "attempted to piston-punch", "gorilla arms") return COMPONENT_CANCEL_ATTACK_CHAIN - // The one damage line. Flat, wounding, honest. - var/grabbed_hurl = living_target.pulledby == source && source.grab_state >= GRAB_AGGRESSIVE - source.do_attack_animation(living_target, ATTACK_EFFECT_SMASH) - playsound(living_target.loc, 'sound/items/weapons/punch1.ogg', 40, TRUE, -1) - var/target_zone = living_target.get_random_valid_zone(source.zone_selected) - var/armor_block = living_target.run_armor_check(target_zone, MELEE, armour_penetration = active_hand.unarmed_effectiveness) - living_target.apply_damage(CYBERWARE_GORILLA_PUNCH_DAMAGE, BRUTE, target_zone, armor_block, wound_bonus = 10) - - if(source.body_position != LYING_DOWN) - var/atom/throw_target = get_edge_target_turf(living_target, source.dir) - if(grabbed_hurl) - living_target.safe_throw_at(throw_target, CYBERWARE_GORILLA_HURL_RANGE, 2, source) - living_target.visible_message( - span_danger("[source] hurls [living_target] across the room!"), - span_userdanger("[source] hurls you across the room!"), - ) - else - living_target.throw_at(throw_target, 1, rand(1, 4), source, gentle = TRUE) - living_target.visible_message( - span_danger("[source] slams [living_target] with a piston-driven fist!"), - span_userdanger("[source] slams you with a piston-driven fist!"), - ) - to_chat(source, span_danger("You slam [living_target]!")) - log_combat(source, living_target, "piston-punched", "gorilla arms") - COOLDOWN_START(src, slam_cooldown, CYBERWARE_GORILLA_PUNCH_COOLDOWN) + // Someone in crit or stunned, with the aimed zone picking the finisher (hyperviolence_gorilla/gorilla_finisher.dm). + if(gorilla_try_finisher(source, living_target)) + return COMPONENT_CANCEL_ATTACK_CHAIN + + // The one damage line, through #509, with the knockback on the safe path (hyperviolence_gorilla/gorilla_punch.dm). + piston_hit(source, living_target, active_hand) + COOLDOWN_START(src, slam_cooldown, punch_cooldown_time) return COMPONENT_CANCEL_ATTACK_CHAIN /** @@ -270,23 +294,42 @@ id = "organ_set_bonus_cyberware_gorilla" organs_needed = 2 required_biotype = NONE - bonus_activate_text = span_notice("Your Gorilla Arms sync up. You can force closed airlocks by hand now. Walk up and pull, out of combat mode.") - bonus_deactivate_text = span_notice("Your arms fall out of sync. Doors stay shut again.") + bonus_activate_text = span_notice("Your Gorilla Arms sync up.") + bonus_deactivate_text = span_notice("Your arms fall out of sync.") + /// How long the pair takes to force a powered airlock. + var/pry_time = GORILLA_PRY_TIME + /// The ground pound chip the pair grants. + var/pound_type = /datum/action/cooldown/cyberware/gorilla_pound + /// Whether the arms flex as they sync. + var/flexes = TRUE /datum/status_effect/organ_set_bonus/cyberware_gorilla/enable_bonus(obj/item/organ/inserted_organ) . = ..() if(!.) return - owner.AddElement(/datum/element/door_pryer, pry_time = 4 SECONDS, interaction_key = DOAFTER_SOURCE_GORILLA_PRY) + // The pry refuses trader outpost doors and plays the strain (hyperviolence_gorilla/gorilla_pry.dm) + owner.AddElement(/datum/element/door_pryer/gorilla, pry_time = pry_time, interaction_key = DOAFTER_SOURCE_GORILLA_PRY) + // The ground pound chip, and the flex as the arms come online (hyperviolence_gorilla/gorilla_pound.dm) + grant_pound() + if(flexes) + gorilla_flex(owner) /datum/status_effect/organ_set_bonus/cyberware_gorilla/disable_bonus(obj/item/organ/removed_organ) . = ..() - owner.RemoveElement(/datum/element/door_pryer, pry_time = 4 SECONDS, interaction_key = DOAFTER_SOURCE_GORILLA_PRY) + owner.RemoveElement(/datum/element/door_pryer/gorilla, pry_time = pry_time, interaction_key = DOAFTER_SOURCE_GORILLA_PRY) + take_pound() + +/datum/status_effect/organ_set_bonus/cyberware_gorilla/on_remove() + take_pound() + return ..() // ========================================================================= // MANTIS BLADES // ========================================================================= +// These four are the Mantis defaults. The housing reads them into vars so the +// other models in the line (ware_line_mantis.dm) can retune by setting vars. + /// Lunge reach in tiles. #define CYBERWARE_MANTIS_LUNGE_RANGE 5 /// Bonus brute the arriving lunge lands PER BLADE (cap 10 per ADDENDUM 2). @@ -296,6 +339,10 @@ /// How long a connecting lunge floors its target. Above the module's usual /// 1-1.5s band because the lunge is telegraphed and on a 20 second clock. #define CYBERWARE_MANTIS_LUNGE_KNOCKDOWN (2 SECONDS) +/// How long a shown-line dash (dash_aim) takes per tile: a real run down the line, one tick a step. +#define CYBERWARE_MANTIS_LUNGE_STEP (0.5) +/// How long tg's attack lunge takes to reach its target (do_attack_animation()): the arrival's cut lands no sooner. +#define CYBERWARE_MANTIS_LUNGE_THRUST (0.1 SECONDS) /** * The blade itself: hardlight, ~20 force (cap 22), sharp, wounding. Only @@ -305,13 +352,14 @@ * * Every sprite comes off the cyberware sheets rather than the stock hardlight * sword: this is a long blade running forward past the hand out of a forearm - * housing, not something anybody is gripping. The held sprite is blade only. - * The housing is already on the bearer's arm as the organ's aug_overlay, and - * drawing a second one in the hand put a metal brick over their bicep. + * housing, not something anybody is gripping. The held sprite is the blade + * along the forearm. The organ's worn overlay (the housing with the blade + * folded in) hides while the blade is out, see hide_worn_while_deployed. * - * base_icon_state comes along for the ride purely so it cannot disagree with - * icon_state; update_icon_state() only consults it when sword_color_icon is - * set, which it never is here. + * base_icon_state names the blade's model for its held poses: the held sprite + * is "[base_icon_state]_[pose]" (voidcrew/modules/mantis_gore/), the raised + * guard while nothing else is going on. update_icon_state() only consults it + * when sword_color_icon is set, which it never is here. */ /obj/item/melee/energy/blade/hardlight/cyberware_mantis name = "mantis blade" @@ -319,12 +367,41 @@ icon = 'voidcrew/modules/cyberware/icons/cyberware_weapons.dmi' icon_state = "mantis" base_icon_state = "mantis" - inhand_icon_state = "mantis" - lefthand_file = 'voidcrew/modules/cyberware/icons/cyberware_lefthand.dmi' - righthand_file = 'voidcrew/modules/cyberware/icons/cyberware_righthand.dmi' + inhand_icon_state = "mantis_guard" + lefthand_file = MANTIS_LEFTHAND_ICON + righthand_file = MANTIS_RIGHTHAND_ICON force = 20 armour_penetration = 10 wound_bonus = 10 + /// Set by afterattack() during attack()'s parent call, which only a swing that + /// connected reaches. attack()'s own FALSE can't tell a cut from a pacifist's + /// pulled swing or a signal-skipped one. The Widowline does the same. + var/swing_landed = FALSE + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/attack(mob/living/target, mob/living/user, list/modifiers, list/attack_modifiers) + // A head swing at someone dying is the scissor, not a cut (mantis_gore/mantis_scissor.dm). + if(mantis_swing_taken(target, user)) + return TRUE + swing_landed = FALSE + // What the cut does to the body is read while the hit resolves, so its lines join the attack line. + mantis_watch_cut(target, user) + . = ..() + mantis_unwatch_cut(target) + var/landed = swing_landed + swing_landed = FALSE + // Only a cut that landed counts: not a blocked or cancelled swing, not a pulled + // one. Never the wielder, whoever is in the way. + if(. || !landed || QDELETED(target) || target == user) + return + on_cut_landed(target, user) + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/afterattack(atom/target, mob/user, list/modifiers, list/attack_modifiers) + . = ..() + swing_landed = TRUE + +/// A swing with this blade connected with [target]. The line's models add to it. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/on_cut_landed(mob/living/target, mob/living/user) + return /** * # Mantis Blades (T3, arms, aug slots, load 3 per arm / 6 the pair) @@ -343,6 +420,8 @@ chrome_load = 3 tier = CYBERWARE_TIER_3 aug_overlay = "mantis" + // The worn housing sprite carries the folded blade, so it hides while the blade is out. + hide_worn_while_deployed = TRUE items_to_create = list(/obj/item/melee/energy/blade/hardlight/cyberware_mantis) // A blade sliding out of a forearm housing and snapping back into it, the // cursed katana's pair (mining_loot/cursed_katana.dm), not a baton's ratchet. @@ -352,6 +431,17 @@ /datum/action/item_action/organ_action/toggle/toolkit, /datum/action/cooldown/cyberware/mantis_lunge, ) + /// Lunge reach in tiles. + var/lunge_range = CYBERWARE_MANTIS_LUNGE_RANGE + /// Bonus brute the arriving lunge lands per blade out. + var/lunge_bonus = CYBERWARE_MANTIS_LUNGE_BONUS + /// Delay between the wind-up and the dash. + var/lunge_telegraph = CYBERWARE_MANTIS_LUNGE_TELEGRAPH + /// How long a connecting lunge floors its target. + var/lunge_knockdown = CYBERWARE_MANTIS_LUNGE_KNOCKDOWN + /// Fire stacks the arriving lunge puts on its target (and lights them + /// with). 0 for no fire. The most of any blade that arrives lands, not the sum. + var/lunge_fire_stacks = 0 /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left name = "\improper Mantis Blade housing (left)" @@ -369,32 +459,46 @@ /datum/action/cooldown/cyberware/mantis_lunge name = "Mantis Lunge" - desc = "Dash up to five tiles onto a target with the blade leading, cutting them open and dropping them on arrival. The blade must be extended. With both blades out, both land." + desc = "Dash up to five tiles onto a target, cutting them open and dropping them on arrival." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "act_mantis_lunge" cooldown_time = 20 SECONDS click_to_activate = TRUE + // A stunned, paralysed or bound body, or one with its hands tied, does not lunge. + check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED | AB_CHECK_IMMOBILE | AB_CHECK_HANDS_BLOCKED + /// Set by a bearer that showed its line before pressing (a bounty NPC's tell): the next press runs down + /// that line to this tile with real movement (dash()) instead of the ordinary lunge. Spent by the press. + var/turf/dash_aim /** - * How many mantis blades this owner has out right now. Every housing grants - * exactly one of these buttons, so counting the buttons whose blade is - * extended counts the blades that will arrive. + * The housings whose blade is out right now and will arrive with the lunge. + * Every lunging housing grants exactly one of these buttons, so walking the + * buttons whose blade is extended finds the blades. A model with no lunge + * button never lands in this list. */ -/datum/action/cooldown/cyberware/mantis_lunge/proc/count_extended_blades() +/datum/action/cooldown/cyberware/mantis_lunge/proc/get_extended_housings() + var/list/housings = list() if(!owner) - return 0 - var/blades = 0 - for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge_action in owner.actions) + return housings + // Chrome abilities have no button and so never join mob.actions (chrome_hud.dm). + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge_action in get_chrome_wheel_actions(owner)) var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = lunge_action.organ if(istype(housing) && housing.blade_extended()) - blades++ - return blades + housings += housing + return housings + +/// How many mantis blades this owner has out right now. +/datum/action/cooldown/cyberware/mantis_lunge/proc/count_extended_blades() + return length(get_extended_housings()) /datum/action/cooldown/cyberware/mantis_lunge/Activate(atom/target) var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = organ if(!istype(housing) || !isliving(owner)) return FALSE var/mob/living/lunger = owner + if(HAS_TRAIT(lunger, TRAIT_PACIFISM)) + to_chat(lunger, span_warning("You don't want to harm other living beings!")) + return FALSE if(!housing.blade_extended()) lunger.balloon_alert(lunger, "extend the blade first!") return FALSE @@ -405,15 +509,22 @@ lunger.balloon_alert(lunger, "no target!") return FALSE var/mob/living/victim = target + var/turf/aim = dash_aim + dash_aim = null if(victim == lunger || victim.stat == DEAD) lunger.balloon_alert(lunger, "no target!") return FALSE - if(get_dist(lunger, victim) > CYBERWARE_MANTIS_LUNGE_RANGE || !can_see(lunger, victim, CYBERWARE_MANTIS_LUNGE_RANGE)) + if(get_dist(lunger, victim) > housing.lunge_range || !can_see(lunger, victim, housing.lunge_range)) lunger.balloon_alert(lunger, "out of reach!") return FALSE + // The blade is about to be used on someone. + cyberware_camo_drop(lunger) + // A shown line out of reach is no line: the ordinary lunge + if(aim && (aim.z != lunger.z || get_dist(lunger, aim) > housing.lunge_range)) + aim = null // One lunge clock across both housings: start every mantis_lunge button // this owner has, ours included. - for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge_action in lunger.actions) + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge_action in get_chrome_wheel_actions(lunger)) lunge_action.StartCooldown() // The telegraph: readable wind-up before the dash lands. lunger.face_atom(victim) @@ -422,58 +533,193 @@ span_boldwarning("[lunger] drops low, mantis blade[both_blades ? "s" : ""] laid flat along [lunger.p_their()] [both_blades ? "arms" : "arm"]!"), span_warning("You coil for the lunge."), ) + // The blades go flat along the arms for the wind-up (mantis_gore/mantis_poses.dm). + mantis_pose_blades(get_extended_housings(), MANTIS_POSE_LUNGE) playsound(lunger, 'sound/items/weapons/sear.ogg', 50, TRUE) - addtimer(CALLBACK(src, PROC_REF(do_lunge), WEAKREF(victim)), CYBERWARE_MANTIS_LUNGE_TELEGRAPH) + addtimer(CALLBACK(src, PROC_REF(do_lunge), WEAKREF(victim), null, FALSE, aim), housing.lunge_telegraph) return TRUE -/// The dash itself: walk the line to the target with a decoy per tile, -/// stop adjacent, land the bonus cut once per blade and floor them. -/datum/action/cooldown/cyberware/mantis_lunge/proc/do_lunge(datum/weakref/victim_ref) +/// The dash itself: walk the line to the target, stop adjacent, land the bonus +/// cut once per blade and floor them. [range] is how far it may reach (a charged +/// leap reaches further, mantis_gore/mantis_charge.dm); [charged] is TRUE for a +/// leap out of a crouch. With a shown line ([aim], from dash_aim) it runs down +/// that line instead (dash()). +/datum/action/cooldown/cyberware/mantis_lunge/proc/do_lunge(datum/weakref/victim_ref, range, charged = FALSE, turf/aim) var/mob/living/lunger = owner - if(QDELETED(lunger) || lunger.incapacitated || !isturf(lunger.loc)) + if(QDELETED(lunger)) + return + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = organ + if(!istype(housing)) return + // The blades go back to the guard however the dash ends. + var/list/posed = get_extended_housings() + if(lunger.incapacitated || !isturf(lunger.loc)) + mantis_pose_blades(posed, MANTIS_POSE_GUARD) + return + if(isnull(range)) + range = housing.lunge_range var/mob/living/victim = victim_ref?.resolve() if(QDELETED(victim) || victim.stat == DEAD) lunger.balloon_alert(lunger, "target lost!") + mantis_pose_blades(posed, MANTIS_POSE_GUARD) + return + if(aim) + if(aim.z != lunger.z) + lunger.balloon_alert(lunger, "target lost!") + mantis_pose_blades(posed, MANTIS_POSE_GUARD) + return + INVOKE_ASYNC(src, PROC_REF(dash), lunger, victim_ref, aim, range, charged, posed) return + // The ordinary lunge: walk the line to the target with a decoy per tile and stop adjacent var/turf/victim_turf = get_turf(victim) - if(!victim_turf || get_dist(lunger, victim_turf) > CYBERWARE_MANTIS_LUNGE_RANGE + 1) + if(!victim_turf || get_dist(lunger, victim_turf) > range + 1) lunger.balloon_alert(lunger, "target lost!") + mantis_pose_blades(posed, MANTIS_POSE_GUARD) return playsound(lunger, 'sound/items/weapons/bladeslice.ogg', 60, TRUE) - for(var/turf/step_turf as anything in get_line(get_turf(lunger), victim_turf)) - if(step_turf == get_turf(lunger)) + var/turf/start = get_turf(lunger) + var/list/passed = list() + for(var/turf/step_turf as anything in get_line(start, victim_turf)) + if(step_turf == start) continue if(step_turf == victim_turf) break if(step_turf.is_blocked_turf(exclude_mobs = TRUE)) break - new /obj/effect/temp_visual/decoy/fading/halfsecond(lunger.loc, lunger) + // Never over a drop, into lava or out into space: the dash stops at the edge. + if(mantis_lunge_unsafe_turf(step_turf)) + break + passed += lunger.loc lunger.forceMove(step_turf) + // Hardlight afterimages and a streak down the line, and the body glides into place (mantis_gore/mantis_lunge_fx.dm). + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/lunge_blade = housing.active_item + var/glide = mantis_lunge_dash_fx(lunger, start, passed, charged, istype(lunge_blade) ? lunge_blade.base_icon_state : "mantis") if(!lunger.Adjacent(victim)) lunger.balloon_alert(lunger, "fell short!") + // The blades stay flat while the body is still gliding in. + mantis_lunge_settle(posed, glide) return + land_lunge(lunger, victim, housing, lunge_blade, charged, posed, start, glide) + +/** + * A shown-line dash (dash_aim, a bounty NPC's tell): a real run down the line it showed, a tile a tick with + * a decoy per tile, up to the tile before `aim`. Anything that stops a walker stops it there: a wall, a + * window, a shut door, a standing body, a stun or a grab. The lunge lands only where the line said: on a + * target still on the marked tile, or one who stepped into its way, next to it where it stops. Anyone who + * stepped off the line is missed. It goes no further than [range] tiles, never over a drop, lava or + * space, and leaves the lunge's afterimages and streak behind it (mantis_gore/mantis_lunge_fx.dm). + * [posed] are the blades laid flat for the wind-up: they go back to the guard however it ends. + */ +/datum/action/cooldown/cyberware/mantis_lunge/proc/dash(mob/living/lunger, datum/weakref/victim_ref, turf/aim, range, charged = FALSE, list/posed) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = organ + if(!istype(housing)) + mantis_pose_blades(posed, MANTIS_POSE_GUARD) + return + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/lunge_blade = housing.active_item + var/model = istype(lunge_blade) ? lunge_blade.base_icon_state : "mantis" + var/turf/start = get_turf(lunger) + var/turf/stopped_at + var/dash_dir = get_dir(start, aim) + var/steps = 0 + playsound(lunger, 'sound/items/weapons/bladeslice.ogg', 60, TRUE) + for(var/turf/step_turf as anything in get_line(start, aim)) + if(step_turf == start) + continue + if(steps >= range || mantis_lunge_unsafe_turf(step_turf)) + break + if(step_turf == aim || QDELETED(lunger) || lunger.incapacitated || lunger.body_position == LYING_DOWN || !isturf(lunger.loc) || lunger.pulledby?.grab_state > GRAB_PASSIVE) + break + var/blocked = FALSE + for(var/mob/living/body in step_turf) + if(body.density) + blocked = TRUE + break + if(blocked) + stopped_at = step_turf + break + var/turf/from = lunger.loc + lunger.set_glide_size(DELAY_TO_GLIDE_SIZE(CYBERWARE_MANTIS_LUNGE_STEP)) + if(!lunger.Move(step_turf, get_dir(from, step_turf)) || lunger.loc != step_turf) + break + steps++ + // The lunge's wake on the tile it just left: hardlight afterimages and the streak. + mantis_dash_ghost(WEAKREF(lunger), WEAKREF(from), dash_dir, steps / (range + 1), model) + sleep(CYBERWARE_MANTIS_LUNGE_STEP) + if(QDELETED(lunger) || lunger.stat != CONSCIOUS) + mantis_pose_blades(posed, MANTIS_POSE_GUARD) + return + var/mob/living/victim = victim_ref?.resolve() + var/turf/victim_turf = get_turf(victim) + if(QDELETED(victim) || victim.stat == DEAD || (victim_turf != aim && victim_turf != stopped_at) || !lunger.Adjacent(victim)) + lunger.balloon_alert(lunger, "fell short!") + mantis_pose_blades(posed, MANTIS_POSE_GUARD) + return + // The run was real movement: the body is already there. + land_lunge(lunger, victim, housing, lunge_blade, charged, posed, null, 0) + +/// The arrival: the bonus cut once per blade, and they go down. [housing] is the housing that lunged and +/// [lunge_blade] its blade, [charged] is TRUE for a leap out of a crouch, and [posed] are the blades laid +/// flat for the wind-up. [from] is where the ordinary lunge set out, for the impale's glide in; a shown-line +/// dash ran here on its own feet and gives none. [glide] is how long the body still takes to glide in +/// (mantis_lunge_dash_fx()): the impact, the knockdown and the blades' return to the guard wait for it, and for +/// the body's thrust at the target when it is already there. +/datum/action/cooldown/cyberware/mantis_lunge/proc/land_lunge(mob/living/lunger, mob/living/victim, obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing, obj/item/melee/energy/blade/hardlight/cyberware_mantis/lunge_blade, charged = FALSE, list/posed, turf/from, glide = 0) // Both housings deployed means both blades arrive. Floored at one: a blade // stowed during the 0.3s telegraph shouldn't eat the whole cooldown for // nothing when the dash still connected. - var/blades = max(count_extended_blades(), 1) + var/list/blade_housings = get_extended_housings() + if(!length(blade_housings)) + blade_housings = list(housing) + var/blades = length(blade_housings) + // Judged as they arrive, before the arrival cut: someone already hurt or down. + var/skewer = mantis_can_impale(lunger, victim, blade_housings) lunger.face_atom(victim) - lunger.do_attack_animation(victim, ATTACK_EFFECT_SLASH) + lunger.do_attack_animation(victim, no_effect = TRUE) + // The cut lands as the body does, and not before its thrust has reached them. + var/lands_in = max(glide, CYBERWARE_MANTIS_LUNGE_THRUST) + // The blade's own impact over the target (both blades for a pounce), and a burst of light and dust (mantis_gore/mantis_lunge_fx.dm). + mantis_lunge_arrival_fx(lunger, victim, istype(lunge_blade) ? lunge_blade.impact_state : "impact_mantis", charged && blades > 1, lands_in) + // The arrival counts toward the lunger's kill (mantis_gore/mantis_cuts.dm). + mantis_note_hit(victim, lunger) // One armor roll for the arrival, reused per blade. Both land in the same // instant on the same plate, and it keeps the armor message to one line. var/armor_block = victim.run_armor_check(BODY_ZONE_CHEST, MELEE) - for(var/i in 1 to blades) + var/lunge_fire = 0 + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/blade_housing as anything in blade_housings) victim.apply_damage( - CYBERWARE_MANTIS_LUNGE_BONUS, + blade_housing.lunge_bonus, BRUTE, BODY_ZONE_CHEST, armor_block, wound_bonus = 10, sharpness = SHARP_EDGED, ) - victim.Knockdown(CYBERWARE_MANTIS_LUNGE_KNOCKDOWN) - if(blades > 1) + lunge_fire = max(lunge_fire, blade_housing.lunge_fire_stacks) + if(lunge_fire) + cyberware_scorch_target(victim, lunge_fire) + // Both blades into someone already hurt: held up on them, then ripped free (mantis_gore/mantis_impale.dm). + // The knockdown waits for the rip. + if(skewer && !QDELETED(victim) && victim.stat != DEAD && mantis_start_impale(src, lunger, victim, blade_housings, housing.lunge_knockdown, from, charged ? 2 : MANTIS_LUNGE_GLIDE)) + log_combat(lunger, victim, "mantis-lunged and impaled", "mantis blades ([blades] landed)") + playsound(victim, 'sound/effects/wounds/pierce3.ogg', 70, TRUE) + return + // The blades stay flat through the glide and come back to the guard as the body lands, and they go down + // then, with the impact (mantis_gore/mantis_lunge_fx.dm). + mantis_lunge_settle(posed, lands_in) + mantis_lunge_knockdown(victim, housing.lunge_knockdown, lands_in) + if(charged) + if(blades > 1) + victim.visible_message( + span_danger("[lunger] springs at [victim] and shuts both blades on [victim.p_them()], dropping [victim.p_them()]!"), + span_userdanger("[lunger] springs at you. Both blades land at once and your legs go out from under you!"), + ) + else + victim.visible_message( + span_danger("[lunger] springs at [victim], opens [victim.p_them()] up and puts [victim.p_them()] down!"), + span_userdanger("[lunger] springs at you. The blade is already in you, and the floor comes up fast!"), + ) + else if(blades > 1) victim.visible_message( span_danger("[lunger] flickers across the gap and shuts both blades on [victim] like a trap, dropping [victim.p_them()]!"), span_userdanger("[lunger] flickers across the gap. Both blades land at once and your legs go out from under you!"), @@ -483,7 +729,7 @@ span_danger("[lunger] flickers across the gap, opens [victim] up on arrival and puts [victim.p_them()] down!"), span_userdanger("[lunger] flickers across the gap. The blade is already in you, and the floor comes up fast!"), ) - log_combat(lunger, victim, "mantis-lunged", "mantis blades ([blades] landed)") + log_combat(lunger, victim, charged ? "mantis-leapt" : "mantis-lunged", "mantis blades ([blades] landed)") playsound(victim, 'sound/items/weapons/bladeslice.ogg', 70, TRUE) // ========================================================================= @@ -506,14 +752,16 @@ * * The damage splits 3:1. The cut is brute and carries the wounding; the charge * running down the line is burn, flat and unwounding. Both halves ignore armor - * and both halves cleave. + * and both halves carry through. * - * Every landed hit cleaves through mobs adjacent to the victim with line of - * sight, allies filtered out, for CYBERWARE_MONOWIRE_CLEAVE_MULT of both. + * Every landed hit carries on into one body at most: the one standing right + * behind the victim along the swing, allies filtered out, for + * CYBERWARE_MONOWIRE_CLEAVE_MULT of both, never taking a limb. The + * through-cut, severs and the garrote live in voidcrew/modules/hyperviolence/wire/. */ /obj/item/melee/cyberware_monowire name = "\improper Widowline monowire" - desc = "A weighted spool of monomolecular line, run live. At rest it's a glitter in the air. Swung, it goes through plate and the person wearing it in the same motion, and through whoever is standing next to them." + desc = "A weighted spool of monomolecular line, run live. At rest it's a glitter in the air." icon = 'voidcrew/modules/cyberware/icons/cyberware_weapons.dmi' icon_state = "monowire" inhand_icon_state = "monowire" @@ -533,65 +781,57 @@ attack_verb_continuous = list("garrotes", "flenses", "lashes", "bisects") attack_verb_simple = list("garrote", "flense", "lash", "bisect") hitsound = 'voidcrew/sound/monowire1.ogg' + /// Cleave fraction of the wire's damage dealt to secondary targets. + var/cleave_mult = CYBERWARE_MONOWIRE_CLEAVE_MULT + /// Burn the charged line adds on top of the cut, every hit. + var/charge_burn = CYBERWARE_MONOWIRE_BURN + /// Set by afterattack() during attack()'s parent call. Only a swing that + /// connected gets that far, and attack()'s own return can't tell a hit from + /// a pacifist's pulled swing or a signal-skipped one (both return FALSE). + var/swing_landed = FALSE /obj/item/melee/cyberware_monowire/attack(mob/living/target, mob/living/user, list/modifiers, list/attack_modifiers) // The parent plays hitsound partway through the swing, so pick which of the // line's two voices we are before handing off. hitsound = pick('voidcrew/sound/monowire1.ogg', 'voidcrew/sound/monowire2.ogg') + swing_landed = FALSE + // The cut rides the hit: clean severs and the through-cut land + // while tg resolves it, so their lines join its message (hyperviolence/wire/wire_cut.dm). + wire_cut_begin(target, user) . = ..() - // A truthy return means the swing was blocked or cancelled outright, no - // cut landed, so nothing burns and nothing carries through. - if(. || QDELETED(target) || !isliving(user)) + var/landed = swing_landed + swing_landed = FALSE + // No cut landed (blocked, cancelled, pulled), so nothing burns. + if(. || !landed || QDELETED(target) || !isliving(user)) + wire_cut_end(target) return // The charge on the line, on top of the cut. Silent armor check: the parent - // already announced the penetration for this same swing. + // already announced the penetration for this same swing. Still part of the clean + // cut: a wound the cut just opened throws no blood when the charge lands on it. var/burn_zone = target.get_random_valid_zone(user.zone_selected) target.apply_damage( - CYBERWARE_MONOWIRE_BURN, + charge_burn, BURN, burn_zone, target.run_armor_check(burn_zone, MELEE, armour_penetration = armour_penetration, silent = TRUE), ) + wire_cut_end(target) - var/cleaved_anyone = FALSE - for(var/mob/living/nearby in orange(1, target)) - if(nearby == user || nearby == target || nearby.stat == DEAD) - continue - if(!can_see(target, nearby, 1)) - continue - if(cyberware_is_ally(user, nearby)) - continue - // One roll for both halves: it is one pass of the same wire. - var/cleave_block = nearby.run_armor_check(BODY_ZONE_CHEST, MELEE, armour_penetration = armour_penetration) - nearby.apply_damage( - force * CYBERWARE_MONOWIRE_CLEAVE_MULT, - BRUTE, - BODY_ZONE_CHEST, - cleave_block, - wound_bonus = wound_bonus, - sharpness = SHARP_EDGED, - ) - nearby.apply_damage( - CYBERWARE_MONOWIRE_BURN * CYBERWARE_MONOWIRE_CLEAVE_MULT, - BURN, - BODY_ZONE_CHEST, - cleave_block, - ) - to_chat(nearby, span_userdanger("[user]'s monowire carries through into you!")) - cleaved_anyone = TRUE - if(cleaved_anyone) - user.visible_message( - span_danger("The wire sings through everything beside [target]!"), - span_danger("The wire carries through the whole cluster."), - ) - playsound(target, 'sound/items/weapons/bladeslice.ogg', 50, TRUE) +/obj/item/melee/cyberware_monowire/afterattack(atom/target, mob/user, list/modifiers, list/attack_modifiers) + . = ..() + swing_landed = TRUE + if(!isliving(user) || QDELETED(target) || target == user) + return + // The wire lashes out of the hand to what it hit (hyperviolence/wire/wire_held.dm), standing in for the held wire. + wire_lash_at(user, target, lash_zone) + lash_zone = null /** * # Widowline Monowire (T3, one arm, aug slot, load 5) * - * A single-arm spool housing deploying the wire above. Reach two, hits the - * crowd around whatever it lands on, and armor does nothing to slow it down. + * A single-arm spool housing deploying the wire above. Reach two, carries on + * into whoever stands behind what it lands on, and armor does nothing to slow it down. * What it can't do is hard targets: a quarter demolition mod means walls, * doors and machines shrug it off. Bring it to bodies, not to bulkheads. */ @@ -602,7 +842,8 @@ chrome_load = 5 tier = CYBERWARE_TIER_3 items_to_create = list(/obj/item/melee/cyberware_monowire) - extend_sound = 'sound/items/weapons/batonextend.ogg' + extend_sound = 'voidcrew/sound/monowire_deploy.ogg' + retract_sound = 'voidcrew/sound/monowire_retract.ogg' // ========================================================================= // POPUP RONIN SMG @@ -634,7 +875,7 @@ */ /obj/item/ammo_box/magazine/cyberware_ronin name = "\improper Ronin flush-feed magazine (10x24mm)" - desc = "A flush-feed magazine keyed to the Popup Ronin's action and nothing else's. Holds twenty caseless rounds." + desc = "A flush-feed magazine keyed to the Popup Ronin's action and nothing else's." icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' icon_state = "ronin_mag" base_icon_state = "ronin_mag" @@ -681,7 +922,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin name = "\improper Popup Ronin housing" - desc = "A forearm rig that unfolds a skeletal machine-pistol into your grip and folds it away again just as fast. The mag well only takes Ronin flush-feed magazines." + desc = "A forearm rig that unfolds a skeletal machine-pistol into your grip and folds it away again just as fast." icon_state = "ronin" chrome_load = 5 tier = CYBERWARE_TIER_3 @@ -723,7 +964,7 @@ /obj/item/ammo_casing/cyberware_buster name = "30mm shaped rocket" - desc = "A stubby shaped-charge rocket in the Buster's proprietary 30mm. All of the blast goes forward and stops at the first thing it hits." + desc = "A stubby shaped-charge rocket in the Buster's proprietary 30mm." icon_state = "low_yield_rocket" base_icon_state = "low_yield_rocket" caliber = CYBERWARE_CALIBER_BUSTER @@ -771,7 +1012,7 @@ */ /obj/item/gun/ballistic/revolver/cyberware_buster name = "\improper Bunker Buster micro-rocket pod" - desc = "A two-tube rocket pod that rides folded along the forearm. The munitions are shaped, so the blast goes into the target instead of the room, and instead of your hull." + desc = "A two-tube rocket pod that rides folded along the forearm." icon = 'voidcrew/modules/cyberware/icons/cyberware_weapons.dmi' icon_state = "bunker_buster" inhand_icon_state = "bunker_buster" @@ -797,7 +1038,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/bunker_buster name = "\improper Bunker Buster housing" - desc = "A reinforced forearm bay built around two rocket tubes, with a recoil bed where your radius used to be. Takes proprietary 30mm shaped rockets, so make both count." + desc = "A reinforced forearm bay built around two rocket tubes, with a recoil bed where your radius used to be." icon_state = "bunker_buster" chrome_load = 5 tier = CYBERWARE_TIER_3 @@ -815,6 +1056,8 @@ #undef CYBERWARE_MANTIS_LUNGE_BONUS #undef CYBERWARE_MANTIS_LUNGE_TELEGRAPH #undef CYBERWARE_MANTIS_LUNGE_KNOCKDOWN +#undef CYBERWARE_MANTIS_LUNGE_STEP +#undef CYBERWARE_MANTIS_LUNGE_THRUST #undef CYBERWARE_MONOWIRE_CLEAVE_MULT #undef CYBERWARE_MONOWIRE_BURN #undef CYBERWARE_CALIBER_RONIN diff --git a/voidcrew/modules/cyberware/ware_military_body.dm b/voidcrew/modules/cyberware/ware_military_body.dm index 6bd4b6d118f..ffd818d7dd5 100644 --- a/voidcrew/modules/cyberware/ware_military_body.dm +++ b/voidcrew/modules/cyberware/ware_military_body.dm @@ -10,7 +10,7 @@ // GHOSTSKIN WEAVE // ========================================================================= -/// Cloak alpha. NEVER 0: a shimmer stays readable point-blank. +/// Cloak alpha. NEVER 0: a faint outline stays readable point-blank. #define CYBERWARE_GHOSTSKIN_ALPHA 40 /// How long a camo field holds before it collapses on its own. #define CYBERWARE_GHOSTSKIN_DURATION (10 SECONDS) @@ -19,17 +19,17 @@ * # Ghostskin Weave (T3, chest, skin slot, load 5) * * A dermal mesh of refraction cells: ten seconds of optical camo on a - * 30-second clock. Players see a heat-shimmer outline (alpha 40, never full - * invisibility) that ripples brighter when you move; NPC targeting honors + * 30-second clock. Players see a faint outline (alpha 40, never full + * invisibility) that flashes brighter when you move; NPC targeting honors * TRAIT_CYBER_CAMO through the hook in cyberware_stealth.dm, but anything * within two tiles spots you anyway. The field collapses the instant you - * attack, shoot, get struck, get cuffed, or eat an EMP, the break-trigger - * list is the MOD stealth module's, plus gunfire (nothing uncounterable + * attack, shoot, throw, get struck, get cuffed, or eat an EMP, the break-trigger + * list is the MOD stealth module's, plus gunfire and throws (nothing uncounterable * fires from inside a cloak on this server). */ /obj/item/organ/cyberimp/cyberware/ghostskin name = "\improper Ghostskin weave" - desc = "A subdermal lattice of refraction cells. Switched on, you're a faint heat-shimmer and not much else. Swing at anyone and the field drops, mid-swing, out in the open." + desc = "A subdermal lattice of refraction cells. Switched on, you flicker out until there's barely anything of you left to see." icon_state = "ghostskin" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_SKIN @@ -41,11 +41,28 @@ var/camo_active = FALSE /// Timer for the field's natural collapse. var/camo_timer + /// Alpha the bearer fades to while the field is up. Never 0. + var/field_alpha = CYBERWARE_GHOSTSKIN_ALPHA + /// How long the field holds before it collapses on its own. + var/field_duration = CYBERWARE_GHOSTSKIN_DURATION + /// Alpha the bearer flashes up to for a step when moving under the field. + /// Must stay above field_alpha, motion is meant to make you MORE visible. + var/ripple_alpha = 90 + /// Whether the field takes the bearer out of NPC targeting and scatters a + /// chrome read (TRAIT_CYBER_CAMO). Cheaper weaves only fool players. + var/hides_from_mobs = TRUE /obj/item/organ/cyberimp/cyberware/ghostskin/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() break_camo(organ_owner, silent = TRUE) +/// The field runs on the weave: it collapses the moment the weave goes offline, +/// a brownout or damage, the same as an EMP drops it. +/obj/item/organ/cyberimp/cyberware/ghostskin/chrome_passives_off(mob/living/carbon/bearer) + . = ..() + if(camo_active) + break_camo(bearer, reason = "weave offline", silent = (owner != bearer)) + /obj/item/organ/cyberimp/cyberware/ghostskin/emp_act(severity) . = ..() if(. & EMP_PROTECT_SELF) @@ -53,22 +70,26 @@ if(camo_active) break_camo(owner, reason = "EMP discharge") -/// Raises the field: shimmer alpha, camo trait, break triggers, expiry clock. +/// Raises the field: field alpha, camo trait, break triggers, expiry clock. /obj/item/organ/cyberimp/cyberware/ghostskin/proc/engage_camo(mob/living/carbon/wearer) if(camo_active || !wearer) return camo_active = TRUE - ADD_TRAIT(wearer, TRAIT_CYBER_CAMO, REF(src)) - animate(wearer, alpha = CYBERWARE_GHOSTSKIN_ALPHA, time = 1 SECONDS) - playsound(wearer, 'voidcrew/sound/machines/cloaking/on.ogg', 60, TRUE) - wearer.visible_message( - span_warning("[wearer] ripples and thins to a heat-shimmer outline!"), - span_notice("The weave bends the light around you. Ten seconds."), - ) + if(hides_from_mobs) + ADD_TRAIT(wearer, TRAIT_CYBER_CAMO, REF(src)) + // Flickers down to field_alpha over 0.6 s (cyberware_anim.dm). The var holds field_alpha at once. + cloak_flicker_in(wearer) + engage_feedback(wearer) // The MOD stealth break list (modules_ninja.dm), minus bump-off, plus - // gunfire, shooting from inside a cloak breaks it here. - RegisterSignal(wearer, COMSIG_LIVING_UNARMED_ATTACK, PROC_REF(on_unarmed_attack)) + // gunfire and throwing: shooting or throwing from inside a cloak breaks it here. + // The early signal too: a fist that takes over the attack (Gorilla, Scrapper) cancels the + // chain before the late one is ever sent. + RegisterSignals(wearer, list(COMSIG_LIVING_EARLY_UNARMED_ATTACK, COMSIG_LIVING_UNARMED_ATTACK), PROC_REF(on_unarmed_attack)) RegisterSignal(wearer, COMSIG_ATOM_BULLET_ACT, PROC_REF(on_bullet_act)) + RegisterSignal(wearer, COMSIG_LIVING_ELECTROCUTE_ACT, PROC_REF(on_shocked)) + // Being mauled by an animal, a mob, a mech or a xeno is being hit too: the + // field is what keeps those mobs off you (cyberware_stealth.dm), so a bite at + // point-blank range has to drop it. RegisterSignals(wearer, list( COMSIG_MOB_ITEM_ATTACK, COMSIG_ATOM_ATTACKBY, @@ -76,19 +97,38 @@ COMSIG_ATOM_HITBY, COMSIG_ATOM_HULK_ATTACK, COMSIG_ATOM_ATTACK_PAW, + COMSIG_ATOM_ATTACK_ANIMAL, + COMSIG_ATOM_ATTACK_BASIC_MOB, + COMSIG_ATOM_ATTACK_MECH, + COMSIG_MOB_ATTACK_ALIEN, COMSIG_CARBON_CUFF_ATTEMPTED, COMSIG_MOB_FIRED_GUN, + COMSIG_MOB_THROW, COMSIG_LIVING_DEATH, ), PROC_REF(on_break_trigger)) RegisterSignal(wearer, COMSIG_MOVABLE_MOVED, PROC_REF(on_camo_move)) - camo_timer = addtimer(CALLBACK(src, PROC_REF(on_field_expired)), CYBERWARE_GHOSTSKIN_DURATION, TIMER_STOPPABLE) + camo_timer = addtimer(CALLBACK(src, PROC_REF(on_field_expired)), field_duration, TIMER_STOPPABLE) + +/// The sound and chat lines that go with the field coming up. Split out so a +/// cheaper weave can tell it differently. +/obj/item/organ/cyberimp/cyberware/ghostskin/proc/engage_feedback(mob/living/carbon/wearer) + playsound(wearer, 'voidcrew/sound/machines/cloaking/on.ogg', 60, TRUE) + wearer.visible_message( + span_warning("[wearer] flickers and fades almost out of sight!"), + span_notice("The weave bends the light around you."), + ) /obj/item/organ/cyberimp/cyberware/ghostskin/proc/on_field_expired() camo_timer = null - break_camo(owner, reason = "field capacity spent") + break_camo(owner, reason = "field capacity spent", gentle = TRUE) -/// Collapses the field and returns the bearer to full visibility. -/obj/item/organ/cyberimp/cyberware/ghostskin/proc/break_camo(mob/living/carbon/wearer, reason, silent = FALSE) +/** + * Collapses the field and returns the bearer to full visibility. A [gentle] + * drop (the field ran out or was switched off) flickers back out; anything + * that knocks it down stutters back with sparks; a [silent] one just snaps + * back. + */ +/obj/item/organ/cyberimp/cyberware/ghostskin/proc/break_camo(mob/living/carbon/wearer, reason, silent = FALSE, gentle = FALSE) if(!camo_active) return camo_active = FALSE @@ -99,6 +139,7 @@ return REMOVE_TRAIT(wearer, TRAIT_CYBER_CAMO, REF(src)) UnregisterSignal(wearer, list( + COMSIG_LIVING_EARLY_UNARMED_ATTACK, COMSIG_LIVING_UNARMED_ATTACK, COMSIG_ATOM_BULLET_ACT, COMSIG_MOB_ITEM_ATTACK, @@ -107,16 +148,28 @@ COMSIG_ATOM_HITBY, COMSIG_ATOM_HULK_ATTACK, COMSIG_ATOM_ATTACK_PAW, + COMSIG_ATOM_ATTACK_ANIMAL, + COMSIG_ATOM_ATTACK_BASIC_MOB, + COMSIG_ATOM_ATTACK_MECH, + COMSIG_MOB_ATTACK_ALIEN, + COMSIG_LIVING_ELECTROCUTE_ACT, COMSIG_CARBON_CUFF_ATTEMPTED, COMSIG_MOB_FIRED_GUN, + COMSIG_MOB_THROW, COMSIG_LIVING_DEATH, COMSIG_MOVABLE_MOVED, )) - animate(wearer, alpha = 255, time = 0.5 SECONDS) - if(!silent) + // The way back to full view is the exit's own (cyberware_anim.dm). + if(silent) + cloak_reset(wearer) + else if(gentle) + cloak_flicker_out(wearer) + else + cloak_flicker_break(wearer) do_sparks(2, TRUE, wearer) + if(!silent) wearer.visible_message( - span_danger("[wearer] shimmers back into full view!"), + span_danger("[wearer] flickers back into full view!"), span_warning("The weave collapses[reason ? ", [reason]" : ""]. You are visible."), ) @@ -133,6 +186,15 @@ return break_camo(owner, reason = "field contact") +/// Signal proc for [COMSIG_LIVING_ELECTROCUTE_ACT]: a real jolt (a live door) +/// drops the field. Hallucinated shocks and +/// ones the gloves fully insulate don't. +/obj/item/organ/cyberimp/cyberware/ghostskin/proc/on_shocked(datum/source, shock_damage, shock_source, siemens_coeff, flags) + SIGNAL_HANDLER + if((flags & SHOCK_ILLUSION) || shock_damage <= 0 || siemens_coeff <= 0) + return + break_camo(owner, reason = "field shorted") + /// Signal proc for [COMSIG_ATOM_BULLET_ACT]: hostile rounds pop the field. /obj/item/organ/cyberimp/cyberware/ghostskin/proc/on_bullet_act(datum/source, obj/projectile/projectile) SIGNAL_HANDLER @@ -140,19 +202,22 @@ return break_camo(owner, reason = "field disrupted") -/// Signal proc for [COMSIG_MOVABLE_MOVED]: the moving-shimmer ripple. +/// Signal proc for [COMSIG_MOVABLE_MOVED]: the moving flash. /// Motion makes you briefly MORE visible. Free counterplay for sharp eyes. /obj/item/organ/cyberimp/cyberware/ghostskin/proc/on_camo_move(datum/source) SIGNAL_HANDLER var/mob/living/wearer = owner if(!wearer || !camo_active) return - animate(wearer, alpha = 90, time = 0.15 SECONDS) - animate(alpha = CYBERWARE_GHOSTSKIN_ALPHA, time = 0.35 SECONDS) + // Still flickering in; the bearer is more visible than this already. + if(world.time < cloak_enter_until) + return + animate(wearer, alpha = ripple_alpha, time = 0.15 SECONDS) + animate(alpha = field_alpha, time = 0.35 SECONDS) /datum/action/cooldown/cyberware/ghostskin_cloak name = "Ghostskin Field" - desc = "Ten seconds of optical camo. Attacking, shooting, taking a hit or an EMP drops the field. Anyone standing right next to you still sees you." + desc = "Ten seconds of optical camo." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "act_ghostskin" cooldown_time = 30 SECONDS @@ -164,7 +229,7 @@ return FALSE if(weave.camo_active) // Manual early collapse; the cooldown was already paid. - weave.break_camo(owner, reason = "disengaged") + weave.break_camo(owner, reason = "disengaged", gentle = TRUE) return TRUE StartCooldown() weave.engage_camo(owner) @@ -199,7 +264,7 @@ */ /obj/item/organ/cyberimp/cyberware/slabskin name = "\improper Slabskin plate" - desc = "Sintered ceramic scales grown into the skin in overlapping courses. Bullets leave scuffs and a noise like a dropped pan, and not a great deal else." + desc = "A keel and rib plates of sintered ceramic, grown into the skin of the chest and back. Bullets leave scuffs, when they don't bounce off with a noise like a dropped pan." icon_state = "slabskin" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_DERMAL @@ -207,9 +272,12 @@ chrome_load = 6 tier = CYBERWARE_TIER_3 aug_overlay = "slabskin" + worn_under_clothes = TRUE /// TRUE while the plate armor is mixed into the bearer's physiology. /// Guards the failing-gated passive hooks against double add/subtract. var/plate_armor_applied = FALSE + /// Percent of bullets from the front that glance off, through the shared dodge arbiter. The top of the dermal ladder. + var/deflect_chance = 45 /obj/item/organ/cyberimp/cyberware/slabskin/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() @@ -217,6 +285,7 @@ /obj/item/organ/cyberimp/cyberware/slabskin/chrome_passives_on(mob/living/carbon/bearer) . = ..() + cyberware_register_deflect_source(bearer, REF(src), CALLBACK(src, PROC_REF(get_deflect_chance))) if(plate_armor_applied || !ishuman(bearer)) return plate_armor_applied = TRUE @@ -225,6 +294,7 @@ /obj/item/organ/cyberimp/cyberware/slabskin/chrome_passives_off(mob/living/carbon/bearer) . = ..() + cyberware_unregister_deflect_source(bearer, REF(src)) if(!plate_armor_applied) return plate_armor_applied = FALSE // reset before the validity skip, or the plate never re-arms after a bearer deletes @@ -237,6 +307,12 @@ . = ..() UnregisterSignal(organ_owner, COMSIG_MOB_APPLY_DAMAGE) +/// Deflect-source callback: nothing while failing. +/obj/item/organ/cyberimp/cyberware/slabskin/proc/get_deflect_chance() + if(organ_flags & ORGAN_FAILING) + return 0 + return deflect_chance + /** * Signal proc for [COMSIG_MOB_APPLY_DAMAGE]: the telegraph. Solid brute or * burn hits spark and ping off the plate where everyone can see them. @@ -285,7 +361,7 @@ */ /obj/item/organ/cyberimp/cyberware/lazarus name = "\improper Lazarus node" - desc = "A capacitor bank sunk fist-deep in the chest, wired straight across the heart. When you go down it spends a second charging up, then shocks you back onto your feet. Rebuilding that charge takes a lot longer." + desc = "A capacitor bank sunk fist-deep in the chest, wired straight across the heart. It has strong views on you staying down." icon_state = "lazarus" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_HEART_AID @@ -304,7 +380,7 @@ if(COOLDOWN_FINISHED(src, jolt_cooldown)) . += span_notice("The charge bank reads READY.") else - . += span_notice("The charge bank reads RECHARGING, [DisplayTimeText(COOLDOWN_TIMELEFT(src, jolt_cooldown))] left.") + . += span_notice("The charge bank reads RECHARGING.") /obj/item/organ/cyberimp/cyberware/lazarus/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() @@ -320,6 +396,7 @@ . = ..() jolting = FALSE jolt_generation++ + clear_charge_fx() /** * Signal proc for [COMSIG_MOB_STATCHANGE]: fires the windup on the @@ -328,6 +405,8 @@ */ /obj/item/organ/cyberimp/cyberware/lazarus/proc/on_stat_change(mob/living/carbon/source, new_stat, old_stat) SIGNAL_HANDLER + if(new_stat == DEAD) + clear_charge_fx() if(jolting) return var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) @@ -348,6 +427,8 @@ playsound(source, 'sound/machines/defib/defib_charge.ogg', 75, TRUE) source.set_jitter_if_lower(4 SECONDS) source.do_jitter_animation(200) + // Magenta charge and arcs crawling over the body (cyberware_anim2.dm). + play_charge_fx(source, CYBERWARE_LAZARUS_WINDUP) addtimer(CALLBACK(src, PROC_REF(jolt), jolt_generation, WEAKREF(source)), CYBERWARE_LAZARUS_WINDUP) /// The discharge: heal to 30%, clear the floor out from under every stun, @@ -357,6 +438,8 @@ if(!jolting || windup_generation != jolt_generation) return jolting = FALSE + // The windup is over whether or not the jolt fires: a patient who got up on their own keeps no glow. + clear_charge_fx() var/mob/living/carbon/patient = intended_patient?.resolve() if(QDELETED(src) || QDELETED(patient) || patient != owner) return @@ -390,6 +473,7 @@ patient.set_resting(FALSE, silent = TRUE, instant = TRUE) playsound(patient, 'sound/machines/defib/defib_zap.ogg', 100, TRUE) do_sparks(3, TRUE, patient) + play_jolt_fx(patient) patient.emote("gasp") patient.set_jitter_if_lower(20 SECONDS) patient.visible_message( @@ -402,11 +486,8 @@ // ATLAS FRAME // ========================================================================= -/// Held by a bearer whose skeleton simply does not break. Blocks the whole -/// bone wound series, dislocations, hairline fractures, compound fractures, -/// at the wound system's own gate, and nothing else. Every other wound series -/// lands on its bearer exactly as it lands on anyone. -#define TRAIT_CYBERWARE_UNBREAKABLE_BONES "cyberware_unbreakable_bones" +// TRAIT_CYBERWARE_UNBREAKABLE_BONES lives in voidcrew/_DEFINES/cyberware.dm +// so the street frame (ware_models_b.dm) can name it too. /** * # Atlas Frame (T3, chest, frame slot, load 4) @@ -423,7 +504,7 @@ */ /obj/item/organ/cyberimp/cyberware/atlas name = "\improper Atlas frame" - desc = "A titanium truss bolted through the spine and ribs. Nothing breaks your bones and nothing takes a limb off you. Everything softer than bone is still your problem, and anything you throw leaves your hand like it was fired." + desc = "A titanium truss bolted through the spine and ribs, so the skeleton stops being the weak point." icon_state = "atlas" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_FRAME @@ -431,15 +512,27 @@ chrome_load = 4 tier = CYBERWARE_TIER_3 organ_traits = list(TRAIT_NODISMEMBER, TRAIT_CYBERWARE_UNBREAKABLE_BONES) + /// Tiles added to the range of anything the bearer throws. With no speed + /// bonus either, the throw hook is never armed. + var/throw_range_bonus = 2 + /// Speed added to anything the bearer throws. + var/throw_speed_bonus = 1 + /// Whether a throw of the bearer by something else travels half as far. + var/resists_knockback = TRUE + /// The line examine adds on top of the organ's own. Null for none. + var/frame_examine = null /obj/item/organ/cyberimp/cyberware/atlas/examine(mob/user) . = ..() - . += span_notice("Covers the skeleton only: no dislocations, no fractures, and no losing a limb. Slashes, punctures, burns and bleeding are untouched.") + if(frame_examine) + . += span_notice(frame_examine) /obj/item/organ/cyberimp/cyberware/atlas/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() - RegisterSignal(organ_owner, COMSIG_MOB_THROW, PROC_REF(on_owner_throws)) - RegisterSignal(organ_owner, COMSIG_MOVABLE_PRE_THROW, PROC_REF(on_owner_thrown)) + if(throw_range_bonus || throw_speed_bonus) + RegisterSignal(organ_owner, COMSIG_MOB_THROW, PROC_REF(on_owner_throws)) + if(resists_knockback) + RegisterSignal(organ_owner, COMSIG_MOVABLE_PRE_THROW, PROC_REF(on_owner_thrown)) /obj/item/organ/cyberimp/cyberware/atlas/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() @@ -472,8 +565,8 @@ SIGNAL_HANDLER if(throw_args[4] != owner) // someone else's throw, somehow return - throw_args[2] += 2 // range - throw_args[3] += 1 // speed + throw_args[2] += throw_range_bonus // range + throw_args[3] += throw_speed_bonus // speed /obj/item/organ/cyberimp/cyberware/atlas/proc/clear_throw_hooks(list/candidates) for(var/atom/movable/candidate as anything in candidates) @@ -565,7 +658,7 @@ */ /obj/item/organ/cyberimp/cyberware/rigger name = "\improper Rigger socket" - desc = "A skull jack that patches a ship's helm straight into your head. Anywhere aboard, you can fly it, as long as the ship still has a helm console for the socket to talk to, and as long as you don't mind walking while you do it." + desc = "A skull jack that patches a ship's helm straight into your head." icon_state = "rigger" zone = BODY_ZONE_HEAD slot = ORGAN_SLOT_CYBERWARE_RIGGER @@ -580,7 +673,6 @@ /obj/item/organ/cyberimp/cyberware/rigger/examine(mob/user) . = ..() - . += span_notice("Opens the helm of whatever ship its bearer stands on, from anywhere on it. It borrows a real console. A hull with no helm left has nothing to answer with.") if(!owner) return if(!linked_ship) @@ -727,12 +819,12 @@ return FALSE if(!linked_ship) pilot.balloon_alert(pilot, "no hull to reach") - to_chat(pilot, span_warning("The socket casts around for a hull and finds solid ground. You have to be aboard a ship.")) + to_chat(pilot, span_warning("The socket casts around for a hull and finds solid ground.")) return FALSE var/obj/machinery/computer/helm/console = find_console() if(!console) pilot.balloon_alert(pilot, "no helm answering!") - to_chat(pilot, span_warning("Nothing aboard [linked_ship] answers the uplink. The socket borrows a helm console, and there isn't a working one left on the ship.")) + to_chat(pilot, span_warning("Nothing aboard [linked_ship] answers the uplink.")) return FALSE if(!console.check_crew_access(pilot)) return FALSE @@ -743,7 +835,7 @@ cyberware_ink_pulse(pilot, CYBERWARE_INK_HARD) pilot.visible_message( span_notice("The jack behind [pilot]'s ear lights up, and [pilot.p_their()] eyes go somewhere else."), - span_notice("The uplink catches [console] aboard [linked_ship]. You are flying the ship from here, at a walk."), + span_notice("The uplink catches [console] aboard [linked_ship]. You are flying the ship from here."), ) console.ui_interact(pilot) return TRUE @@ -778,7 +870,7 @@ /datum/action/cooldown/cyberware/rigger_uplink name = "Helm Uplink" - desc = "Open the ship's helm from wherever you're standing. You move at a walk while it's up, and it drops if you leave the hull, black out, or lose the socket." + desc = "Open the ship's helm from wherever you're standing. You walk slowly while it's up." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "rigger" cooldown_time = 5 SECONDS @@ -847,5 +939,4 @@ #undef CYBERWARE_LAZARUS_COOLDOWN #undef CYBERWARE_LAZARUS_WINDUP #undef CYBERWARE_LAZARUS_HEAL_TO -#undef TRAIT_CYBERWARE_UNBREAKABLE_BONES #undef CYBERWARE_RIGGER_SLOWDOWN diff --git a/voidcrew/modules/cyberware/ware_models_b.dm b/voidcrew/modules/cyberware/ware_models_b.dm new file mode 100644 index 00000000000..7de0991d93c --- /dev/null +++ b/voidcrew/modules/cyberware/ware_models_b.dm @@ -0,0 +1,315 @@ +/** + * # Street and service models, set B + * + * Cheaper and sideways models of the plating, frame, seal, nervous and ear + * wares. Every one is a subtype of the ware it undercuts and sits in the same + * slot, so fitting one evicts the other. The parents keep their numbers; the + * models only set the vars the parents expose. + * + * model parent slot load tier sold for + * Hardweave plating Dermal Mesh dermal 3 T2 3,000 cr (yellow) + * Strut frame Atlas Frame frame 2 T2 1,500 cr (yellow) + * Deep-lung bladder Second Wind seal 2 T2 1,800 cr + * Heat-sink lining Coolant Loops seal 1 T1 1,500 cr + * Frostline lining (new) seal 1 T1 1,500 cr + * Twitchwire Slipwire nervous 2 T1 1,800 cr (yellow) + * Weaver shunt Slipwire nervous 5 T3 3 vouchers (advanced) + * Thumper ear Heartbeat Dop. ears 1 T1 1,500 cr (yellow) + * + * The seal slot now holds five choices (Second Wind, Deep-lung, Heat-sink, + * Frostline, Coolant). It stays a single slot, so none of them combine: an + * air bladder and a cold lining never share a body. + * + * Dodge goes through the shared arbiter (ware_pro_combat.dm), which rolls the + * single highest live source, so the Twitchwire and the Weaver shunt can never + * stack with a Cascade window or each other. + * + * Splice's shelf, the street doc's shelf (ripperdoc_catalog.dm, + * street_doc_catalog.dm) and the zone loot tables list the SKUs, ledger + * entries and organs below. + */ + +// ========================================================================= +// HARDWEAVE PLATING (T2): the middle of the dermal ladder +// ========================================================================= + +/// Between the Mesh and the Slabskin Plate: more of the same, none of the +/// plate's bomb, fire and acid cover. +/datum/armor/cyberware_hardweave + melee = 20 + bullet = 20 + laser = 15 + energy = 10 + wound = 10 + +/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave + name = "\improper Hardweave plating" + desc = "Rib plates over the chest and back with a layered polymer weave sewn in below them, a size up from the usual mesh. Rounds that come in at an angle skip off. The scarring is the part nobody mentions." + icon_state = "dermal_mesh_hardweave" + aug_overlay = "dermal_mesh_hardweave" + chrome_load = 3 + tier = CYBERWARE_TIER_2 + mesh_armor = /datum/armor/cyberware_hardweave + deflect_chance = 30 + +// ========================================================================= +// STRUT FRAME (T2): the bones and nothing else +// ========================================================================= + +/obj/item/organ/cyberimp/cyberware/atlas/street + name = "\improper Strut frame" + desc = "Steel struts bolted along the long bones. It holds you together and has no opinion about the rest." + icon_state = "atlas_street" + chrome_load = 2 + tier = CYBERWARE_TIER_2 + // Bones only: limbs can still come off, throws are plain, and a shove + // carries you as far as it carries anyone. + organ_traits = list(TRAIT_CYBERWARE_UNBREAKABLE_BONES) + throw_range_bonus = 0 + throw_speed_bonus = 0 + resists_knockback = FALSE + frame_examine = null + +// ========================================================================= +// DEEP-LUNG BLADDER (T2): a longer breath +// ========================================================================= + +/obj/item/organ/cyberimp/cyberware/second_wind/deep + name = "\improper Deep-lung bladder" + desc = "An oversized air bladder packed in around the ribs, for people who spend their shifts on the wrong side of an airlock." + icon_state = "second_wind_deep" + chrome_load = 2 + tier = CYBERWARE_TIER_2 + reserve = 360 SECONDS + max_reserve = 360 SECONDS + refill_rate = 24 SECONDS + +// ========================================================================= +// HEAT-SINK LINING (T1): the heat half of Coolant Loops +// ========================================================================= + +/obj/item/organ/cyberimp/cyberware/coolant/street + name = "\improper Heat-sink lining" + desc = "A lining of finned aluminium stitched in under the ribs, so the heat has somewhere to go. It ticks as it cools." + icon_state = "coolant_street" + chrome_load = 1 + tier = CYBERWARE_TIER_1 + // Heat exposure and the fire scrub stay; burns land at full strength. + burn_mult = 1 + +// ========================================================================= +// FROSTLINE LINING (T1): the cold twin +// ========================================================================= + +/** + * # Frostline lining (T1, chest, seal slot, load 1) + * + * The mirror of the Coolant Loops' heat immunity: the cold stops hurting and + * nothing else changes. It does not breathe for you, so vacuum still kills + * through low pressure, and as the seal slot is single it never sits beside + * an air bladder. + */ +/obj/item/organ/cyberimp/cyberware/frostline + name = "\improper Frostline lining" + desc = "A quilted heating lining stitched in under the ribs, for work on planets that never get warm." + icon_state = "frostline" + zone = BODY_ZONE_CHEST + slot = ORGAN_SLOT_CYBERWARE_SEAL + w_class = WEIGHT_CLASS_SMALL + chrome_load = 1 + tier = CYBERWARE_TIER_1 + organ_traits = list(TRAIT_RESISTCOLD) + +// ========================================================================= +// TWITCHWIRE (T1) and WEAVER SHUNT (T3): the rungs around the Slipwire +// ========================================================================= + +/// The Twitchwire's dodge: a flinch more than a sidestep. +/obj/item/organ/cyberimp/cyberware/slipwire/street + name = "\improper Twitchwire" + desc = "A cheap reflex splice into the spinal trunk. Your legs flinch a little before you tell them to." + icon_state = "slipwire_street" + chrome_load = 2 + tier = CYBERWARE_TIER_1 + dodge_chance = 8 + gait_modifier = null + +/obj/item/organ/cyberimp/cyberware/slipwire/milspec + name = "\improper Weaver shunt" + desc = "A military reflex shunt wired the length of the spine. It was built for people who get shot at for a living." + icon_state = "slipwire_milspec" + chrome_load = 5 + tier = CYBERWARE_TIER_3 + dodge_chance = 20 + gait_modifier = /datum/movespeed_modifier/cyberware_slipwire/weaver + +/datum/movespeed_modifier/cyberware_slipwire/weaver + multiplicative_slowdown = -0.15 + +// ========================================================================= +// THUMPER EAR (T1): short, loud sonar +// ========================================================================= + +/obj/item/organ/cyberimp/cyberware/doppler/street + name = "\improper Thumper ear" + desc = "A budget sonar transceiver socketed in behind the ear. It thumps like a bass drum from the inside." + icon_state = "doppler_street" + chrome_load = 1 + tier = CYBERWARE_TIER_1 + sonar_range = 5 + contact_fade = 3 SECONDS + ping_volume_bonus = 10 + +// ========================================================================= +// SPLICE SKUS: on the Chop Shop's sku_types, and the credit ones on the +// street doc's too. +// ========================================================================= + +/datum/shop_sku/ripperdoc/hardweave + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave + price_credits = 3000 + +/datum/shop_sku/ripperdoc/atlas_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/atlas/street + price_credits = 1500 + +/datum/shop_sku/ripperdoc/second_wind_deep + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/second_wind/deep + price_credits = 1800 + +/datum/shop_sku/ripperdoc/coolant_street + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/coolant/street + price_credits = 1500 + +/datum/shop_sku/ripperdoc/frostline + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/frostline + price_credits = 1500 + +/datum/shop_sku/ripperdoc/slipwire_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/slipwire/street + price_credits = 1800 + +/datum/shop_sku/ripperdoc/slipwire_milspec + zone_permission = ZONE_PERMISSION_ADVANCED + category = "Military Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/slipwire/milspec + price_vouchers = 3 + +/datum/shop_sku/ripperdoc/doppler_street + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/doppler/street + price_credits = 1500 + +// ========================================================================= +// TRADE-IN: half list, credits only, exact type. The Weaver shunt costs +// vouchers, which can't be refunded, so it has no entry. Each entry also has +// the street doc's own wording below. +// +// Names stay siblings of the parent entries (second_wind_deep, not +// second_wind/deep) so a model never inherits its parent's price. The +// parent's own entries (second_wind, dermal_mesh) still match these models +// through match_subtypes, at the parent's lower rate. +// ========================================================================= + +/datum/shop_buyback/ripperdoc/hardweave + name = "Hardweave Plating (pulled)" + desc = "Heavy weave, cut out. Splice recycles it toward the plate." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave + match_subtypes = FALSE + pay_credits = 1500 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/atlas_street + name = "Strut Frame (pulled)" + desc = "A bolted-in bone frame, pulled. Splice strips it for the full truss." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/atlas/street + match_subtypes = FALSE + pay_credits = 750 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/second_wind_deep + name = "Deep-Lung Bladder (pulled)" + desc = "A big air bladder, used. Splice patches and resells." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/second_wind/deep + match_subtypes = FALSE + pay_credits = 900 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/coolant_street + name = "Heat-Sink Lining (pulled)" + desc = "A finned lining, pulled. Splice melts it down toward the full loop." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/coolant/street + match_subtypes = FALSE + pay_credits = 750 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/frostline + name = "Frostline Lining (pulled)" + desc = "A quilted heater lining, pulled. Splice resells these to the ice crews." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/frostline + match_subtypes = FALSE + pay_credits = 750 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/slipwire_street + name = "Twitchwire (pulled)" + desc = "A cheap reflex splice, pulled. Splice trades it up toward the real shunt." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/slipwire/street + match_subtypes = FALSE + pay_credits = 900 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/doppler_street + name = "Thumper Ear (pulled)" + desc = "A loud little sonar, pulled. Splice takes it toward a quieter one." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/doppler/street + match_subtypes = FALSE + pay_credits = 750 + demand_min = 1 + demand_max = 2 + +// ---- Ratchet's wording ---------------------------------------------------- + +/datum/shop_buyback/ripperdoc/hardweave/street_doc + desc = "Used armour weave. Heavy." + +/datum/shop_buyback/ripperdoc/atlas_street/street_doc + desc = "A used bone frame. Still rattles." + +/datum/shop_buyback/ripperdoc/second_wind_deep/street_doc + desc = "A used big air bladder." + +/datum/shop_buyback/ripperdoc/coolant_street/street_doc + desc = "A used heat-sink lining. Still warm." + +/datum/shop_buyback/ripperdoc/frostline/street_doc + desc = "A used heater lining." + +/datum/shop_buyback/ripperdoc/slipwire_street/street_doc + desc = "A used reflex splice. Twitchy." + +/datum/shop_buyback/ripperdoc/doppler_street/street_doc + desc = "A used sonar ear. Loud." diff --git a/voidcrew/modules/cyberware/ware_pro_combat.dm b/voidcrew/modules/cyberware/ware_pro_combat.dm index 5fd06eb5f91..9a7e77c66a0 100644 --- a/voidcrew/modules/cyberware/ware_pro_combat.dm +++ b/voidcrew/modules/cyberware/ware_pro_combat.dm @@ -6,11 +6,17 @@ * * - /datum/component/cyberware_dodge: THE one projectile-dodge arbiter. * Slipwire registers a 15% source here, Cascade Lattice (ware_legend.dm) - * registers a 40% source during its window, and the component rolls the + * registers a 60% source during its window, and the component rolls the * single HIGHEST live source. Never additive: Slipwire + Cascade together - * is still 40%, not 49%. Any future dodge chrome must register a source + * is still 60%, not 75%. Any future dodge chrome must register a source * through cyberware_register_dodge_source() rather than hanging its own - * COMSIG_ATOM_PRE_BULLET_ACT handler. + * COMSIG_ATOM_PRE_BULLET_ACT handler. A source registered with melee = TRUE + * (the Cascade line's windows) also dodges blows, through tg's own + * check_block() via COMSIG_LIVING_CHECK_BLOCK, so a dodged blow is a real + * miss and never fake damage. The same arbiter rolls the dermal plating's + * bullet deflection (see cyberware_register_deflect_source()), capped so a + * dodge and a deflect together never stop more than CYBERWARE_AVOID_CAP + * percent of shots. * - cyberware_is_ally(): the crew filter for auto-targeting ware (Deadeye's * tag, Widowline's cleave). Allies are people who share a ship team with * you; NPC boarders standing on your deck are NOT allies, and rival players @@ -22,6 +28,12 @@ /// A dodge source only fires while its bearer moved within this window. #define CYBERWARE_DODGE_MOVE_WINDOW (1 SECONDS) +/// The shortest gap between two dodge lines from a bearer nobody is playing (an NPC under fire). +#define CYBERWARE_DODGE_LINE_GAP (1.5 SECONDS) +/// Dodge and deflect together never stop more than this percent of shots. +#define CYBERWARE_AVOID_CAP 60 +/// Stamina each deflected bullet costs the bearer, so focused fire still wears them down. +#define CYBERWARE_DEFLECT_STAMINA 5 /** * The one dodge roll for all cyberware. Lives on the mob; wares and status @@ -36,13 +48,26 @@ * fading decoy and a bullet-miss crack. Dodging reads to the shooter. * - COMPONENT_BULLET_PIERCED means the round keeps flying into whoever is * behind; accepted as flavor. + * - Melee sources dodge damaging blows (weapons, fists, claws and bites) + * whether moving or not, but never grabs, tackles or shoves (zero-damage + * attempts), and never once the bearer is pinned: lying down, stunned, + * cuffed, buckled, held in an aggressive grab or in a finisher's hold. + * A melee dodge blurs in place; it never steps the bearer out of reach. */ /datum/component/cyberware_dodge dupe_mode = COMPONENT_DUPE_UNIQUE /// key -> /datum/callback returning that source's live dodge chance. var/list/dodge_sources = list() + /// key -> /datum/callback for the sources that also dodge blows. Each is in dodge_sources too. + var/list/melee_sources = list() + /// key -> /datum/callback returning that source's live bullet-deflect chance (the dermal plating). + var/list/deflect_sources = list() + /// Dodge and deflect together never stop more than this percent of shots. + var/avoid_cap = CYBERWARE_AVOID_CAP /// world.time of the bearer's last move. var/last_move_time = 0 + /// world.time a dodge was last announced: an NPC under fire says it at most once every CYBERWARE_DODGE_LINE_GAP, so chat isn't flooded + var/last_message_at = -INFINITY /datum/component/cyberware_dodge/Initialize() if(!isliving(parent)) @@ -51,12 +76,15 @@ /datum/component/cyberware_dodge/RegisterWithParent() RegisterSignal(parent, COMSIG_ATOM_PRE_BULLET_ACT, PROC_REF(on_pre_bullet_act)) RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) + RegisterSignal(parent, COMSIG_LIVING_CHECK_BLOCK, PROC_REF(on_check_block)) /datum/component/cyberware_dodge/UnregisterFromParent() - UnregisterSignal(parent, list(COMSIG_ATOM_PRE_BULLET_ACT, COMSIG_MOVABLE_MOVED)) + UnregisterSignal(parent, list(COMSIG_ATOM_PRE_BULLET_ACT, COMSIG_MOVABLE_MOVED, COMSIG_LIVING_CHECK_BLOCK)) /datum/component/cyberware_dodge/Destroy() dodge_sources = null + melee_sources = null + deflect_sources = null return ..() /// Signal proc for [COMSIG_MOVABLE_MOVED]: timestamp the movement window. @@ -64,30 +92,146 @@ SIGNAL_HANDLER last_move_time = world.time -/// Signal proc for [COMSIG_ATOM_PRE_BULLET_ACT]: the actual dodge roll. +/** + * Signal proc for [COMSIG_ATOM_PRE_BULLET_ACT]: the dodge roll, then the + * deflect roll. One handler for both, so the cap on the two together holds + * no matter which chrome registered first. + */ /datum/component/cyberware_dodge/proc/on_pre_bullet_act(mob/living/source, obj/projectile/hitting_projectile, def_zone, piercing_hit, blocked) SIGNAL_HANDLER - if(world.time - last_move_time > CYBERWARE_DODGE_MOVE_WINDOW) - return NONE - if(source.stat != CONSCIOUS || source.body_position == LYING_DOWN || source.buckled) - return NONE if(!istype(hitting_projectile) || !hitting_projectile.is_hostile_projectile()) return NONE + var/dodge_chance = live_dodge_chance(source, hitting_projectile) + if(dodge_chance > 0 && prob(dodge_chance)) + INVOKE_ASYNC(src, PROC_REF(perform_sidestep), source, hitting_projectile) + return COMPONENT_BULLET_PIERCED + var/deflect_chance = min(live_deflect_chance(source, hitting_projectile), cyberware_deflect_cap(dodge_chance, avoid_cap)) + if(deflect_chance <= 0 || !prob(deflect_chance)) + return NONE + glance(source, hitting_projectile) + return COMPONENT_BULLET_PIERCED + +/// The dodge chance against this shot right now: 0 unless the bearer is moving, upright and not point-blank. +/datum/component/cyberware_dodge/proc/live_dodge_chance(mob/living/source, obj/projectile/hitting_projectile) + if(!length(dodge_sources)) + return 0 + if(world.time - last_move_time > CYBERWARE_DODGE_MOVE_WINDOW) + return 0 + if(source.stat != CONSCIOUS || source.body_position == LYING_DOWN || source.buckled) + return 0 // Point-blank shots always land: an adjacent shooter is inside the // reflex loop. This is the anti-"unhittable in a brawl" rule. var/atom/shooter = hitting_projectile.firer if(shooter && shooter != source && get_dist(source, shooter) <= 1) - return NONE - var/best_chance = 0 - for(var/key in dodge_sources) - var/datum/callback/chance_callback = dodge_sources[key] + return 0 + return best_chance(dodge_sources) + +/** + * The deflect chance against this shot right now. Only real bullets (and + * each buckshot pellet on its own, since every pellet is its own projectile) + * glance off; lasers, energy and everything else never do. The plate only + * covers what the bearer is facing: a shot into the back always lands. + */ +/datum/component/cyberware_dodge/proc/live_deflect_chance(mob/living/source, obj/projectile/hitting_projectile) + if(!length(deflect_sources)) + return 0 + if(!istype(hitting_projectile, /obj/projectile/bullet) || hitting_projectile.armor_flag != BULLET) + return 0 + if(source.stat == DEAD) + return 0 + if(cyberware_shot_from_behind(source, hitting_projectile)) + return 0 + return best_chance(deflect_sources) + +/** + * The real glance: the bullet's heading turns back off the plate at a random + * angle and the round keeps flying (COMPONENT_BULLET_PIERCED, the same exit + * tg's own reflect takes), so it can still hit whoever stands in its new + * path. It loses energy like any tg ricochet. The bearer stays in the + * bullet's impacted list, so it can't come back for them. + */ +/datum/component/cyberware_dodge/proc/glance(mob/living/source, obj/projectile/bullet) + bullet.set_angle(SIMPLIFY_DEGREES(bullet.angle + pick(-1, 1) * rand(100, 170))) + bullet.damage *= bullet.ricochet_decay_damage + bullet.stamina *= bullet.ricochet_decay_damage + INVOKE_ASYNC(src, PROC_REF(perform_glance), source, bullet.name) + +/// The visible and physical half of a glance: sparks, a ping, and the stamina the hit still costs. +/datum/component/cyberware_dodge/proc/perform_glance(mob/living/source, bullet_name) + if(QDELETED(source)) + return + do_sparks(1, TRUE, source) + playsound(source, SFX_RICOCHET, 60, TRUE) + source.adjustStaminaLoss(CYBERWARE_DEFLECT_STAMINA) + if(source.client || world.time - last_message_at >= CYBERWARE_DODGE_LINE_GAP) + last_message_at = world.time + source.visible_message( + span_danger("\The [bullet_name] glances off [source]!"), + span_danger("\The [bullet_name] glances off you!"), + ) + +/// The highest live chance among these sources. Never additive. +/datum/component/cyberware_dodge/proc/best_chance(list/sources) + . = 0 + for(var/key in sources) + var/datum/callback/chance_callback = sources[key] var/chance = chance_callback?.Invoke() if(isnum(chance)) - best_chance = max(best_chance, chance) + . = max(., chance) + +/// Signal proc for [COMSIG_LIVING_CHECK_BLOCK]: the melee dodge roll, from tg's own check_block(). +/datum/component/cyberware_dodge/proc/on_check_block(mob/living/source, atom/hit_by, damage, attack_text, attack_type, armour_penetration, damage_type) + SIGNAL_HANDLER + if(!length(melee_sources) || !cyberware_can_dodge_blow(source, hit_by, damage, attack_text, attack_type)) + return FAILED_BLOCK + var/best_chance = best_chance(melee_sources) if(best_chance <= 0 || !prob(best_chance)) - return NONE - INVOKE_ASYNC(src, PROC_REF(perform_sidestep), source, hitting_projectile) - return COMPONENT_BULLET_PIERCED + return FAILED_BLOCK + INVOKE_ASYNC(src, PROC_REF(perform_blow_dodge), source, attack_text) + return SUCCESSFUL_BLOCK + +/// The visible half of a dodged blow: the same blur decoy, a whiff, and a line. No step. +/datum/component/cyberware_dodge/proc/perform_blow_dodge(mob/living/source, attack_text) + if(QDELETED(source)) + return + new /obj/effect/temp_visual/decoy/fading/halfsecond(source.loc, source) + playsound(source, 'sound/items/weapons/punchmiss.ogg', 50, TRUE) + if(source.client || world.time - last_message_at >= CYBERWARE_DODGE_LINE_GAP) + last_message_at = world.time + source.visible_message( + span_danger("[source] blurs out of the way of [attack_text]!"), + span_danger("You blur out of the way of [attack_text]!"), + ) + +/** + * Whether the bearer can dodge this blow at all. Only damaging melee and + * unarmed blows from someone else; never while the bearer is down, stunned, + * cuffed, buckled, held tight, or in a finisher's hold, so grabs, finishers, + * the garrote and executions are never dodged once they have started. + */ +/proc/cyberware_can_dodge_blow(mob/living/bearer, atom/hit_by, damage, attack_text, attack_type) + if(attack_type != MELEE_ATTACK && attack_type != UNARMED_ATTACK) + return FALSE + if(!isnum(damage) || damage <= 0) + // tg checks a person's bare hands before it knows what they do, with no damage and the + // attacker's name as the text. Only a hand thrown in combat mode counts; a grab + // ("[name]'s grab"), a tackle and a friendly touch never do. + if(!isliving(hit_by)) + return FALSE + var/mob/living/attacker = hit_by + if(!attacker.combat_mode || attack_text != attacker.name) + return FALSE + if(hit_by == bearer || (isitem(hit_by) && hit_by.loc == bearer)) + return FALSE + if(bearer.stat != CONSCIOUS || bearer.body_position == LYING_DOWN || bearer.buckled) + return FALSE + if(HAS_TRAIT(bearer, TRAIT_INCAPACITATED) || HAS_TRAIT(bearer, TRAIT_FLOORED) || HAS_TRAIT(bearer, TRAIT_RESTRAINED) || HAS_TRAIT(bearer, TRAIT_IMMOBILIZED)) + return FALSE + if(bearer.pulledby && bearer.pulledby.grab_state >= GRAB_AGGRESSIVE) + return FALSE + if(bearer.has_status_effect(/datum/status_effect/hv_finisher_hold)) + return FALSE + return TRUE /// The visible half of a successful dodge: blur decoy, bullet-miss crack, /// and a one-tile sidestep perpendicular to the shot when the floor allows. @@ -96,10 +240,12 @@ return new /obj/effect/temp_visual/decoy/fading/halfsecond(source.loc, source) playsound(source, SFX_BULLET_MISS, 60, TRUE) - source.visible_message( - span_danger("[source] blurs sideways out of [dodged]'s path!"), - span_danger("You blur out of [dodged]'s path!"), - ) + if(source.client || world.time - last_message_at >= CYBERWARE_DODGE_LINE_GAP) + last_message_at = world.time + source.visible_message( + span_danger("[source] blurs sideways out of [dodged]'s path!"), + span_danger("You blur out of [dodged]'s path!"), + ) var/incoming_dir = QDELETED(dodged) ? source.dir : dodged.dir var/list/side_dirs = shuffle(list(turn(incoming_dir, 90), turn(incoming_dir, -90))) for(var/step_dir in side_dirs) @@ -111,12 +257,17 @@ * arbiter component on first use. The callback is polled per incoming * projectile and must return the source's CURRENT chance, return 0 while * disabled (ORGAN_FAILING etc.) rather than unregistering per-flicker. + * With melee = TRUE the same chance also dodges blows (see on_check_block()). */ -/proc/cyberware_register_dodge_source(mob/living/bearer, key, datum/callback/chance_callback) +/proc/cyberware_register_dodge_source(mob/living/bearer, key, datum/callback/chance_callback, melee = FALSE) if(!istype(bearer) || !key || !chance_callback) return var/datum/component/cyberware_dodge/arbiter = bearer.LoadComponent(/datum/component/cyberware_dodge) arbiter.dodge_sources[key] = chance_callback + if(melee) + arbiter.melee_sources[key] = chance_callback + else + arbiter.melee_sources -= key /// Removes a keyed dodge source; the arbiter cleans itself up with the last one. /proc/cyberware_unregister_dodge_source(mob/living/bearer, key) @@ -124,9 +275,46 @@ if(!arbiter) return arbiter.dodge_sources -= key - if(!length(arbiter.dodge_sources)) + arbiter.melee_sources -= key + if(!length(arbiter.dodge_sources) && !length(arbiter.deflect_sources)) + qdel(arbiter) + +/** + * Adds (or refreshes) a keyed bullet-deflect source on the bearer, through + * the same arbiter as the dodge. The callback returns the source's CURRENT + * chance. Never additive: the highest live source rolls. + */ +/proc/cyberware_register_deflect_source(mob/living/bearer, key, datum/callback/chance_callback) + if(!istype(bearer) || !key || !chance_callback) + return + var/datum/component/cyberware_dodge/arbiter = bearer.LoadComponent(/datum/component/cyberware_dodge) + arbiter.deflect_sources[key] = chance_callback + +/// Removes a keyed deflect source; the arbiter cleans itself up with the last source of either kind. +/proc/cyberware_unregister_deflect_source(mob/living/bearer, key) + var/datum/component/cyberware_dodge/arbiter = bearer?.GetComponent(/datum/component/cyberware_dodge) + if(!arbiter) + return + arbiter.deflect_sources -= key + if(!length(arbiter.dodge_sources) && !length(arbiter.deflect_sources)) qdel(arbiter) +/** + * The most a deflect may roll after a dodge roll at dodge_chance missed, so + * that dodge and deflect together never stop more than avoid_cap + * percent of shots: dodge + (1 - dodge) * deflect <= cap. + */ +/proc/cyberware_deflect_cap(dodge_chance, avoid_cap = CYBERWARE_AVOID_CAP) + dodge_chance = clamp(dodge_chance, 0, 100) + if(dodge_chance >= avoid_cap) + return 0 + return (avoid_cap - dodge_chance) * 100 / (100 - dodge_chance) + +/// Whether this shot is travelling the way the bearer faces, so it strikes them in the back. +/proc/cyberware_shot_from_behind(mob/living/bearer, obj/projectile/shot) + var/offset = SIMPLIFY_DEGREES(shot.angle - dir2angle(bearer.dir) + 180) - 180 + return abs(offset) < 90 + // ---- Shared ally filter ------------------------------------------------ /** @@ -158,6 +346,9 @@ return TRUE if(!istype(user) || !istype(target)) return FALSE + // A bounty criminal's own companions and creatures (voidcrew/modules/bounties) + if(bounty_ai_same_gang(user, target)) + return TRUE var/datum/team/user_team = cyberware_crew_team(user) if(!user_team) return FALSE @@ -189,7 +380,7 @@ */ /obj/item/organ/eyes/robotic/cyberware/deadeye name = "\improper Deadeye link" - desc = "Milspec optics built around a target-processing coprocessor. Paint someone and the link walks your next few rounds onto them, whatever the barrel was actually pointed at." + desc = "Military optics built around a targeting coprocessor. It decides where your rounds go, and you aren't consulted." icon_state = "deadeye" chrome_load = 3 tier = CYBERWARE_TIER_2 @@ -197,6 +388,14 @@ /datum/action/cooldown/cyberware/deadeye_tag, /datum/action/cooldown/cyberware/chrome_read, ) + optics_zoom = 1.5 + zoom_walk_penalty = 0.5 + /// How far a tag can be planted, and how far homing keeps correcting. + var/tag_range = CYBERWARE_DEADEYE_TAG_RANGE + /// Homing shots granted per tag. + var/tag_shots = CYBERWARE_DEADEYE_TAG_SHOTS + /// How long a tag lasts, spent or not. + var/tag_duration = CYBERWARE_DEADEYE_TAG_DURATION /// Weakref to the currently tagged target. var/datum/weakref/tagged_ref /// Homing shots remaining on the current tag. @@ -217,14 +416,14 @@ /obj/item/organ/eyes/robotic/cyberware/deadeye/proc/start_tag(mob/living/target) end_tag(owner) tagged_ref = WEAKREF(target) - shots_left = CYBERWARE_DEADEYE_TAG_SHOTS + shots_left = tag_shots RegisterSignal(owner, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, PROC_REF(on_owner_fired)) target.add_filter(CYBERWARE_DEADEYE_MARK_FILTER, 2, list("type" = "outline", "color" = "#ff3300", "size" = 1)) new /obj/effect/temp_visual/smartgun_target(get_turf(target)) playsound(owner, 'sound/machines/synth/synth_yes.ogg', 30, TRUE) owner.balloon_alert(owner, "target tagged") to_chat(target, span_userdanger("A red targeting glint settles on you!")) - tag_timer = addtimer(CALLBACK(src, PROC_REF(on_tag_expired)), CYBERWARE_DEADEYE_TAG_DURATION, TIMER_STOPPABLE) + tag_timer = addtimer(CALLBACK(src, PROC_REF(on_tag_expired)), tag_duration, TIMER_STOPPABLE) /obj/item/organ/eyes/robotic/cyberware/deadeye/proc/on_tag_expired() tag_timer = null @@ -255,7 +454,7 @@ if(!istype(projectile)) return var/mob/living/target = tagged_ref?.resolve() - if(QDELETED(target) || target.stat == DEAD || target.z != user.z || get_dist(user, target) > CYBERWARE_DEADEYE_TAG_RANGE) + if(QDELETED(target) || target.stat == DEAD || target.z != user.z || get_dist(user, target) > tag_range) end_tag(user) return projectile.set_homing_target(target) @@ -267,7 +466,7 @@ /datum/action/cooldown/cyberware/deadeye_tag name = "Deadeye Tag" - desc = "Tag a hostile in view. Your next three shots track them automatically. The tag refuses to take a crewmate." + desc = "Tag a hostile in view. Your next three shots track them." button_icon = 'icons/mob/actions/actions_items.dmi' button_icon_state = "sniper_zoom" cooldown_time = 25 SECONDS @@ -287,7 +486,7 @@ if(cyberware_is_ally(owner, victim)) owner.balloon_alert(owner, "friendly, tag refused!") return FALSE - if(!can_see(owner, victim, CYBERWARE_DEADEYE_TAG_RANGE)) + if(!can_see(owner, victim, optics.tag_range)) owner.balloon_alert(owner, "no line of sight!") return FALSE StartCooldown() @@ -309,17 +508,22 @@ * sidestep (never point-blank, never while browned out) plus a small * always-on gait boost. The dodge itself lives in the shared arbiter above; * this organ just contributes a source whose chance drops to zero the moment - * the ware is EMP-scrambled or browned out. + * the ware is EMP-scrambled or browned out. The chance and the gait boost are + * vars, so the street and service models (ware_models_b.dm) retune them. */ /obj/item/organ/cyberimp/cyberware/slipwire name = "\improper Slipwire reflex shunt" - desc = "A reflex arc spliced in parallel with the spinal trunk. While you're moving it sidesteps incoming fire on its own, roughly one shot in seven misses because your body moved before you told it to." + desc = "A reflex arc spliced in parallel with the spinal trunk. Your body gets out of the way before you've decided to." icon_state = "slipwire" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_NERVOUS w_class = WEIGHT_CLASS_SMALL chrome_load = 4 tier = CYBERWARE_TIER_2 + /// Percent of hostile projectiles dodged while the bearer is moving. + var/dodge_chance = CYBERWARE_SLIPWIRE_DODGE_CHANCE + /// The gait boost the ware adds while it runs. Null for none. + var/datum/movespeed_modifier/gait_modifier = /datum/movespeed_modifier/cyberware_slipwire /obj/item/organ/cyberimp/cyberware/slipwire/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() @@ -335,17 +539,19 @@ // add/remove is idempotent and needs no applied-state guard. /obj/item/organ/cyberimp/cyberware/slipwire/chrome_passives_on(mob/living/carbon/bearer) . = ..() - bearer?.add_movespeed_modifier(/datum/movespeed_modifier/cyberware_slipwire) + if(gait_modifier) + bearer?.add_movespeed_modifier(gait_modifier) /obj/item/organ/cyberimp/cyberware/slipwire/chrome_passives_off(mob/living/carbon/bearer) . = ..() - bearer?.remove_movespeed_modifier(/datum/movespeed_modifier/cyberware_slipwire) + if(gait_modifier) + bearer?.remove_movespeed_modifier(gait_modifier) /// Dodge-source callback: dead weight while failing, 15% otherwise. /obj/item/organ/cyberimp/cyberware/slipwire/proc/get_dodge_chance() if(organ_flags & ORGAN_FAILING) return 0 - return CYBERWARE_SLIPWIRE_DODGE_CHANCE + return dodge_chance /datum/movespeed_modifier/cyberware_slipwire multiplicative_slowdown = -0.1 @@ -391,7 +597,7 @@ */ /obj/item/organ/cyberimp/cyberware/dead_channel name = "\improper Dead Channel pain editor" - desc = "A signal processor clamped over the pain nerves. You stop feeling injuries entirely, which keeps you upright and moving where anyone else would fold. The catch is that you can't tell how bad it's gotten. The colour draining out of the world is the only gauge you get." + desc = "A signal processor clamped over the pain nerves. Nothing hurts. That isn't the same as nothing being wrong." icon_state = "dead_channel" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_NERVOUS @@ -608,7 +814,7 @@ */ /obj/item/organ/cyberimp/cyberware/hopper name = "\improper Hopper piston calves" - desc = "Paired myomer pistons sleeved over both calves. Four tiles of flat jump on demand, over railings, tables and whoever's in the way. Flat is the operative word: they will not put you over a wall." + desc = "Paired myomer pistons sleeved over both calves, for clearing railings, tables and whoever's in the way." icon_state = "hopper" zone = BODY_ZONE_L_LEG slot = ORGAN_SLOT_CYBERWARE_LEGS @@ -622,14 +828,34 @@ tier = CYBERWARE_TIER_2 aug_overlay = "hopper" actions_types = list(/datum/action/cooldown/cyberware/hopper_leap) + // The models in the line (ware_line_models_a.dm) retune these by setting vars. + /// Leap distance in tiles. + var/leap_range = CYBERWARE_HOPPER_RANGE + /// Gap between leaps. The button reads it when it is built. + var/leap_cooldown = 8 SECONDS + /// Tooltip for the button when this model's numbers differ from the button's + /// own text. Null keeps the button's own. + var/leap_action_desc /datum/action/cooldown/cyberware/hopper_leap name = "Piston Leap" - desc = "Leap up to four tiles over gaps, tables and people, onto any open floor you can see with a clear lane to it. Walls, windows and shut doors stop the jump." + desc = "Leap up to four tiles over gaps, tables and people." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "act_hopper" cooldown_time = 8 SECONDS click_to_activate = TRUE + // A stunned, paralysed or bound body does not get to leap out of it. + check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED | AB_CHECK_IMMOBILE + +/datum/action/cooldown/cyberware/hopper_leap/New(Target, original = TRUE) + . = ..() + // The pistons this button belongs to set its cooldown and tooltip. + var/obj/item/organ/cyberimp/cyberware/hopper/pistons = organ + if(!istype(pistons)) + return + cooldown_time = pistons.leap_cooldown + if(pistons.leap_action_desc) + desc = pistons.leap_action_desc /datum/action/cooldown/cyberware/hopper_leap/Activate(atom/target) if(!isliving(owner)) @@ -642,10 +868,12 @@ if(jumper.buckled || !isturf(jumper.loc)) jumper.balloon_alert(jumper, "can't jump from here!") return FALSE - if(get_dist(here, destination) > CYBERWARE_HOPPER_RANGE) + var/obj/item/organ/cyberimp/cyberware/hopper/pistons = organ + var/leap_range = istype(pistons) ? pistons.leap_range : CYBERWARE_HOPPER_RANGE + if(get_dist(here, destination) > leap_range) jumper.balloon_alert(jumper, "too far!") return FALSE - if(!can_see(jumper, destination, CYBERWARE_HOPPER_RANGE)) + if(!can_see(jumper, destination, leap_range)) jumper.balloon_alert(jumper, "no line of sight!") return FALSE if(destination.is_blocked_turf() || islava(destination) || ischasm(destination)) @@ -656,12 +884,13 @@ return FALSE StartCooldown() playsound(here, 'sound/items/weapons/punchmiss.ogg', 40, TRUE, -1) - new /obj/effect/temp_visual/decoy/fading/halfsecond(here, jumper) + var/obj/effect/temp_visual/decoy/fading/halfsecond/afterimage = new(here, jumper) jumper.visible_message( span_warning("[jumper]'s legs fire like pistons and [jumper.p_they()] vault[jumper.p_s()] into the air!"), span_notice("You fire the pistons and leap."), ) - animate(jumper, pixel_z = 20, time = CYBERWARE_HOPPER_AIRTIME, flags = ANIMATION_RELATIVE, easing = QUAD_EASING|EASE_OUT) + // A crouch, dust, and an arc over to the landing; the body stays on its tile until it lands (cyberware_anim2.dm). + cyberware_leap_takeoff_fx(jumper, here, destination, CYBERWARE_HOPPER_AIRTIME, 20, 26, afterimage) addtimer(CALLBACK(src, PROC_REF(land), destination), CYBERWARE_HOPPER_AIRTIME) return TRUE @@ -671,7 +900,7 @@ var/mob/living/jumper = owner if(QDELETED(jumper)) return - animate(jumper, pixel_z = -20, time = 0.1 SECONDS, flags = ANIMATION_RELATIVE) + cyberware_leap_touchdown_fx(jumper) var/turf/final = destination if(QDELETED(final) || final.is_blocked_turf()) final = null @@ -683,10 +912,13 @@ jumper.balloon_alert(jumper, "landing fouled!") return jumper.forceMove(final) - new /obj/effect/temp_visual/mook_dust(final) + cyberware_grey_dust(final) playsound(final, 'sound/effects/gravhit.ogg', 50, TRUE) #undef CYBERWARE_DODGE_MOVE_WINDOW +#undef CYBERWARE_DODGE_LINE_GAP +#undef CYBERWARE_AVOID_CAP +#undef CYBERWARE_DEFLECT_STAMINA #undef CYBERWARE_DEADEYE_TAG_RANGE #undef CYBERWARE_DEADEYE_TAG_SHOTS #undef CYBERWARE_DEADEYE_TAG_DURATION diff --git a/voidcrew/modules/cyberware/ware_pro_utility.dm b/voidcrew/modules/cyberware/ware_pro_utility.dm index 1c560463f0e..5bc0bbe3499 100644 --- a/voidcrew/modules/cyberware/ware_pro_utility.dm +++ b/voidcrew/modules/cyberware/ware_pro_utility.dm @@ -189,7 +189,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/icepick name = "\improper Icepick Jack" - desc = "A slim data spike folded into the wrist, tipped in monocrystal. Turret IFF buses and door motor controllers all run the same handful of protocols, and the spike knows every one of them. Outpost security hardware is the one exception; nobody has cracked that firmware." + desc = "A slim data spike folded into the wrist, tipped in monocrystal. Turrets and door motors both talk to it a little too easily." icon_state = "icepick" chrome_load = 3 tier = CYBERWARE_TIER_2 @@ -229,7 +229,7 @@ /datum/action/cooldown/cyberware/icepick/suppress name = "Icepick: Suppress" - desc = "Spike a hostile turret in line of sight to knock it offline for a while, or slowly force open a bolted or unpowered door you're standing at." + desc = "Spike a hostile turret in sight to knock it offline, or force open a bolted or unpowered door." // Both channels are on the same spike, so both need their own face on the // HUD: two identical buttons is a misclick waiting to happen. button_icon_state = "act_icepick_suppress" @@ -346,7 +346,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/skyhook name = "\improper Skyhook wrist winch" - desc = "A barbed anchor over a spooled monofilament winch, built through the wrist bones. Fire it into anything solid within seven tiles and hold on." + desc = "A barbed anchor over a spooled monofilament winch, built through the wrist bones. It goes into anything solid and reels you in after it." icon_state = "skyhook" chrome_load = 3 tier = CYBERWARE_TIER_2 @@ -359,6 +359,8 @@ button_icon_state = "skyhook" cooldown_time = 8 SECONDS click_to_activate = TRUE + // A stunned, paralysed or bound body, or one with its hands tied, does not winch itself out. + check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED | AB_CHECK_IMMOBILE | AB_CHECK_HANDS_BLOCKED /// The zipline visual for the current pull. var/datum/beam/zipline /// Traits worn for the duration of the pull, per the grapple gun. @@ -431,7 +433,7 @@ */ /obj/item/organ/eyes/robotic/cyberware/prospector name = "\improper Prospector Suite optics" - desc = "Amber-ringed surveyor eyes. Blink the command and they thump out a resonance pulse: ore veins light up straight through the rock, and any cache transponders in range echo back with them. The handheld scanner needs line of sight. These don't." + desc = "Amber-ringed surveyor eyes that can see ore through solid rock. The pulse that does it makes your skull hum." icon_state = "prospector" eye_color_left = "#b8860b" eye_color_right = "#b8860b" @@ -442,6 +444,12 @@ /datum/action/cooldown/cyberware/prospector_pulse, /datum/action/cooldown/cyberware/chrome_read, ) + optics_zoom = 1.5 + zoom_walk_penalty = 0.5 + /// How far the resonance pulse reaches, through rock, in tiles. + var/pulse_range = CYBERWARE_PROSPECTOR_RANGE + /// Whether the pulse also flags zone loot caches. + var/pulse_marks_caches = TRUE /// Cache marks the last pulse raised, so pulling the optics takes them out /// with it instead of leaving blips on a client that no longer owns them. var/list/hud_marks = list() @@ -472,10 +480,14 @@ var/mob/living/carbon/bearer = organ.owner var/obj/item/organ/eyes/robotic/cyberware/prospector/optics = organ var/list/marks = istype(optics) ? optics.hud_marks : null - mineral_scan_pulse(get_turf(bearer), CYBERWARE_PROSPECTOR_RANGE, scanner = bearer) + var/pulse_range = istype(optics) ? optics.pulse_range : CYBERWARE_PROSPECTOR_RANGE + mineral_scan_pulse(get_turf(bearer), pulse_range, scanner = bearer) playsound(bearer, 'sound/machines/sonar-ping.ogg', 25, TRUE) + if(istype(optics) && !optics.pulse_marks_caches) + StartCooldown() + return TRUE var/caches = 0 - for(var/obj/structure/closet/crate/zone_loot/cache in range(CYBERWARE_PROSPECTOR_RANGE, bearer)) + for(var/obj/structure/closet/crate/zone_loot/cache in range(pulse_range, bearer)) // Marks go up through the rock the same way the ore reveal does, a // cache you can already see was never the thing worth pinging for. cyberware_hud_mark(bearer, cache, "#ffb347", 6 SECONDS, registry = marks) @@ -498,7 +510,7 @@ */ /obj/item/organ/cyberimp/cyberware/hemoglass name = "\improper Hemoglass filter" - desc = "A dialysis loop in borosilicate, teed into the vena cava. It strips poisons, chems and radiation out of your blood a little faster than most things can put them in. Party mode tells it to leave the recreational chems alone." + desc = "A dialysis loop in borosilicate, teed into the vena cava. It cleans your blood faster than most things can foul it. There's a switch for evenings when you'd rather it didn't." icon_state = "hemoglass" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_FILTER @@ -513,7 +525,7 @@ /obj/item/organ/cyberimp/cyberware/hemoglass/ui_action_click() party_mode = !party_mode - owner.balloon_alert(owner, party_mode ? "party mode, recreational channels open" : "filter scrubbing everything") + owner.balloon_alert(owner, party_mode ? "party mode" : "scrubbing everything") /obj/item/organ/cyberimp/cyberware/hemoglass/on_life(seconds_per_tick, times_fired) . = ..() @@ -542,13 +554,17 @@ * * Circulating coolant woven through the torso: heat exposure damage is * trait-gated off, burns hit at half strength, and open flame on you gets - * starved down fast. Deliberately NOT fireproof, enough flamer fuel still - * wins, which keeps the buyable MOD flamethrower an honest counter. Sits + * starved down fast. In practice that makes a human bearer fireproof: fire + * stacks only hurt a human through body heat (fire_stacks.dm harm_human()), + * and TRAIT_RESISTHEAT gates that damage off (_species.dm), so a burning + * bearer loses clothes, not skin. The cheap Heat-sink lining + * (ware_models_b.dm) carries the same trait. Burn damage dealt outright + * (a laser, say) still lands, halved here. Sits * on the seal ladder above Second Wind: pick your climate. */ /obj/item/organ/cyberimp/cyberware/coolant name = "\improper Coolant Loop lattice" - desc = "Kilometres of microbore coolant line threaded between muscle and skin: a full climate system for your body. You can work in lava country and walk out of fires that would cook anyone else. It eats a lot of chrome load to run." + desc = "Kilometres of microbore coolant line threaded between muscle and skin, which makes you a climate system with a pulse." icon_state = "coolant" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_SEAL @@ -556,6 +572,9 @@ chrome_load = 3 tier = CYBERWARE_TIER_2 organ_traits = list(TRAIT_RESISTHEAT) + /// Multiplier on the bearer's burn damage while running. 1 leaves burns alone + /// and applies no physiology mod at all. + var/burn_mult = 0.5 /// TRUE while the burn-halving physiology mod is applied. Guards the /// failing-gated passive hooks against double multiply/divide. var/coolant_mod_applied = FALSE @@ -567,11 +586,11 @@ // Physiology persists across species changes (physiology.dm:1). /obj/item/organ/cyberimp/cyberware/coolant/chrome_passives_on(mob/living/carbon/bearer) . = ..() - if(coolant_mod_applied || !ishuman(bearer)) + if(coolant_mod_applied || !ishuman(bearer) || burn_mult == 1) return coolant_mod_applied = TRUE var/mob/living/carbon/human/human_bearer = bearer - human_bearer.physiology.burn_mod *= 0.5 + human_bearer.physiology.burn_mod *= burn_mult /obj/item/organ/cyberimp/cyberware/coolant/chrome_passives_off(mob/living/carbon/bearer) . = ..() @@ -581,7 +600,7 @@ if(!ishuman(bearer) || QDELETED(bearer)) return var/mob/living/carbon/human/human_bearer = bearer - human_bearer.physiology.burn_mod /= 0.5 + human_bearer.physiology.burn_mod /= burn_mult /obj/item/organ/cyberimp/cyberware/coolant/on_life(seconds_per_tick, times_fired) . = ..() @@ -615,7 +634,7 @@ */ /obj/item/organ/cyberimp/cyberware/doppler name = "\improper Heartbeat Doppler" - desc = "A sonar transceiver socketed into the bone behind your ear. Anything alive and moving within nine tiles shows up through walls; anything holding still doesn't register at all. The ping is quiet, but it's out loud, so you're not the only one who knows it's running." + desc = "A sonar transceiver socketed into the bone behind your ear. It paints whatever is moving nearby, walls or no walls, and the ping is louder than the brochure said." icon_state = "doppler" zone = BODY_ZONE_HEAD slot = ORGAN_SLOT_CYBERWARE_EARS @@ -625,6 +644,12 @@ actions_types = list(/datum/action/item_action/organ_action/toggle) /// Whether the sonar is running. var/active = FALSE + /// How far the sonar reaches, in tiles. + var/sonar_range = CYBERWARE_DOPPLER_RANGE + /// How long a contact stays painted after its last step. + var/contact_fade = CYBERWARE_DOPPLER_FADE + /// Added to the ping's volume, on top of the distance falloff. + var/ping_volume_bonus = 0 /// Living things in range we hold movement and death hooks on. Assoc for /// the O(1) membership test; the values are dummies. var/list/watched = list() @@ -694,7 +719,7 @@ return next_sweep = world.time + CYBERWARE_DOPPLER_SWEEP var/list/in_range = list() - for(var/mob/living/contact in range(CYBERWARE_DOPPLER_RANGE, owner)) + for(var/mob/living/contact in range(sonar_range, owner)) if(contact == owner || contact.stat == DEAD) continue in_range[contact] = TRUE @@ -742,14 +767,14 @@ /obj/item/organ/cyberimp/cyberware/doppler/proc/paint_contact(mob/living/contact) if(!active || (organ_flags & ORGAN_FAILING) || QDELETED(owner) || QDELETED(contact)) return - if(contact.stat == DEAD || get_dist(owner, contact) > CYBERWARE_DOPPLER_RANGE || contact.z != owner.z) + if(contact.stat == DEAD || get_dist(owner, contact) > sonar_range || contact.z != owner.z) unwatch_contact(contact) return var/datum/cyberware_hud_mark/blip = contacts[contact] if(blip) - blip.refresh(CYBERWARE_DOPPLER_FADE) + blip.refresh(contact_fade) return - cyberware_hud_mark(owner, contact, "#9fd8ff", CYBERWARE_DOPPLER_FADE, "sonar_ping_small", contacts, contact) + cyberware_hud_mark(owner, contact, "#9fd8ff", contact_fade, "sonar_ping_small", contacts, contact) /// Signal proc for [COMSIG_MOVABLE_MOVED] on the bearer: the set of things /// close enough to hook changed. The blips re-aim themselves. @@ -792,7 +817,7 @@ if(nearest_mover == INFINITY) return // Louder as they close; audible around you either way. That's the deal. - var/ping_volume = clamp(45 - nearest_mover * 3, 15, 45) + var/ping_volume = clamp(45 - nearest_mover * 3, 15, 45) + ping_volume_bonus playsound(owner, 'sound/machines/sonar-ping.ogg', ping_volume, TRUE) if(nearest_mover <= 3) // close contact: the beep doubles up addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(playsound), owner, 'sound/machines/sonar-ping.ogg', ping_volume, TRUE), 0.4 SECONDS) @@ -812,7 +837,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/graverobber name = "\improper Graverobber's Jack" - desc = "An arm-mounted data spike that reads intel out of dead bodies. Spend three seconds on an adjacent corpse and nearby loot caches and hostile patrols get marked on your HUD." + desc = "An arm-mounted data spike for going through the implants of the recently dead." icon_state = "graverobber" chrome_load = 2 tier = CYBERWARE_TIER_2 @@ -821,12 +846,6 @@ /// with it instead of leaving blips on a client that no longer owns them. var/list/hud_marks = list() -/obj/item/organ/cyberimp/arm/toolkit/cyberware/graverobber/examine(mob/user) - . = ..() - . += span_notice("Once installed, use the Data-Spike the Dead ability on a dead body next to you. The read takes 3 seconds. It marks loot caches within [CYBERWARE_GRAVEROBBER_SWEEP_RANGE] tiles in amber and hostile patrols in red on your HUD for a few seconds.") - . += span_notice("Occasionally a read recovers a vault phrase, marking caches within [CYBERWARE_GRAVEROBBER_DEEP_SWEEP_RANGE] tiles instead.") - . += span_notice("Each body can only be read once, and the spike takes 20 seconds to recharge between reads.") - /obj/item/organ/cyberimp/arm/toolkit/cyberware/graverobber/on_mob_remove(mob/living/carbon/arm_owner, special = FALSE, movement_flags) clear_marks() return ..() @@ -912,7 +931,7 @@ */ /obj/item/organ/cyberimp/arm/toolkit/cyberware/angler name = "\improper Harpoon Spool" - desc = "A forearm winch spooled with monofilament under a barbed head. Fired, it drags loose gear and small creatures to you from six tiles out, anything heavier drags you instead." + desc = "A forearm winch spooled with monofilament under a barbed head. It reels in whatever it hits, or you toward it, depending on who's heavier." icon_state = "angler" chrome_load = 2 tier = CYBERWARE_TIER_2 @@ -920,7 +939,7 @@ /datum/action/cooldown/cyberware/harpoon name = "Harpoon Barb" - desc = "Fire the barb up to six tiles: loose items and small creatures come to you. Anything heavier drags you a tile toward it instead." + desc = "Fire the barb up to six tiles. Loose items and small creatures come to you; anything heavier pulls you toward it." button_icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' button_icon_state = "angler" cooldown_time = 8 SECONDS @@ -928,7 +947,8 @@ /datum/action/cooldown/cyberware/harpoon/Activate(atom/target) var/mob/living/carbon/bearer = organ.owner - if(isturf(target) || QDELETED(target)) + // Clicking yourself fires the barb at nothing: a line from the bearer to the bearer. + if(isturf(target) || QDELETED(target) || target == bearer) bearer.balloon_alert(bearer, "barb skitters off!") return FALSE if(get_dist(bearer, target) > CYBERWARE_ANGLER_RANGE || !(target in view(CYBERWARE_ANGLER_RANGE, bearer))) diff --git a/voidcrew/modules/cyberware/ware_second_wind.dm b/voidcrew/modules/cyberware/ware_second_wind.dm index 6330c5ecf31..75a98197b43 100644 --- a/voidcrew/modules/cyberware/ware_second_wind.dm +++ b/voidcrew/modules/cyberware/ware_second_wind.dm @@ -41,15 +41,21 @@ /obj/item/organ/cyberimp/cyberware/second_wind name = "\improper Second Wind bladder" - desc = "A vacuum-cured polymer bladder plumbed around the lungs. When the air runs out it kicks in with a hiss and gives you about three minutes to do something about it, then refills off every breath you take normally. You'll know when it's running: the mask-breathing is loud and the indicator is hard to miss." + desc = "A vacuum-cured polymer bladder plumbed around the lungs. When the air runs out it takes over with a hiss." icon_state = "second_wind" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_SEAL w_class = WEIGHT_CLASS_SMALL chrome_load = 1 tier = CYBERWARE_TIER_1 - /// Breathable reserve remaining, in deciseconds of breathing covered. + /// Breathable reserve remaining, in deciseconds of breathing covered. A + /// model with a bigger bladder sets this to its max_reserve too, a var + /// initialiser can't read another var. var/reserve = CYBERWARE_SECOND_WIND_RESERVE + /// The most reserve the bladder holds. + var/max_reserve = CYBERWARE_SECOND_WIND_RESERVE + /// Reserve regained per normal breath in breathable air. + var/refill_rate = CYBERWARE_SECOND_WIND_REFILL /// TRUE while feeding the owner from reserve, for the engage/disengage beats. var/engaged = FALSE /// Whether the low-reserve warning has already fired this engagement, so @@ -65,7 +71,7 @@ /obj/item/organ/cyberimp/cyberware/second_wind/examine(mob/user) . = ..() var/seconds_left = round(reserve / (1 SECONDS)) - . += span_notice("The reserve gauge reads [seconds_left] seconds of air[reserve < CYBERWARE_SECOND_WIND_RESERVE ? ", refilling while its bearer breathes normally" : " (full)"].") + . += span_notice("The reserve gauge reads [seconds_left] seconds of air.") /obj/item/organ/cyberimp/cyberware/second_wind/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() @@ -116,15 +122,15 @@ if(environment_is_breathable(source)) if(engaged) set_engaged(source, FALSE) - if(reserve < CYBERWARE_SECOND_WIND_RESERVE) - reserve = min(reserve + CYBERWARE_SECOND_WIND_REFILL, CYBERWARE_SECOND_WIND_RESERVE) + if(reserve < max_reserve) + reserve = min(reserve + refill_rate, max_reserve) low_warned = FALSE return NONE if(reserve <= 0) if(engaged) set_engaged(source, FALSE) source.balloon_alert(source, "air reserve empty!") - to_chat(source, span_userdanger("Your Second Wind bladder collapses empty. You are breathing vacuum.")) + to_chat(source, span_userdanger("Your [format_text(name)] collapses empty. You are breathing vacuum.")) playsound(source, 'sound/machines/buzz/buzz-sigh.ogg', 40, TRUE) return NONE if(!engaged) @@ -133,7 +139,7 @@ update_alert(source) if(!low_warned && reserve <= CYBERWARE_SECOND_WIND_LOW) low_warned = TRUE - to_chat(source, span_warning("Your bladder gauge drops into the red, [round(reserve / (1 SECONDS))] seconds of air left.")) + to_chat(source, span_warning("Your bladder gauge drops into the red.")) playsound(source, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) // This IS a successful breath as far as the body is concerned. source.failed_last_breath = FALSE @@ -148,10 +154,10 @@ engaged = new_state if(engaged) INVOKE_ASYNC(source, TYPE_PROC_REF(/mob, emote), "gasp") - source.balloon_alert(source, "second wind engages") + source.balloon_alert(source, "[LOWER_TEXT(format_text(name))] engages") source.visible_message( span_notice("[source] takes a sharp breath, and something under [source.p_their()] ribs starts working."), - span_notice("SEAL ENGAGED. The bladder takes your breathing off you. You have [round(reserve / (1 SECONDS))] seconds of air."), + span_notice("SEAL ENGAGED. The bladder takes your breathing off you."), span_hear("You hear a pneumatic hiss and the rhythm of mask breathing."), vision_distance = COMBAT_MESSAGE_RANGE, ) @@ -160,7 +166,7 @@ breath_loop?.start(source) update_alert(source) return - source.balloon_alert(source, "second wind disengages") + source.balloon_alert(source, "[LOWER_TEXT(format_text(name))] disengages") to_chat(source, span_notice("SEAL RELEASED. You are breathing the room again.")) cyberware_ink_pulse(source, CYBERWARE_INK_SOFT) breath_loop?.stop() @@ -182,7 +188,9 @@ var/seconds_left = round(reserve / (1 SECONDS)) var/running_low = reserve <= CYBERWARE_SECOND_WIND_LOW indicator.color = running_low ? "#ffb347" : "#4dd8e6" - indicator.desc = "Your Second Wind bladder is doing your breathing for you. [seconds_left] second\s of reserve air left[running_low ? ". Find air." : "."]" + // Named for the bladder actually fitted, so a Deep-lung never reads as a Second Wind. + indicator.name = "[format_text(name)] engaged" + indicator.desc = "Your [format_text(name)] is doing your breathing for you. The gauge reads [seconds_left] second\s." /** * Whether the mob's surroundings hold enough oxygen to breathe unassisted: diff --git a/voidcrew/modules/cyberware/ware_street.dm b/voidcrew/modules/cyberware/ware_street.dm index 4ca0296974c..9fe5c186db2 100644 --- a/voidcrew/modules/cyberware/ware_street.dm +++ b/voidcrew/modules/cyberware/ware_street.dm @@ -68,7 +68,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( */ /obj/item/organ/cyberimp/cyberware/chromatic_dermis name = "\improper Chromatic Dermis ink suite" - desc = "Programmable tattoo ink and the spider-legged injector that lays it under the skin. The traces light up whenever the rest of your chrome does something: a punch landing, a tool folding out, the air bladder kicking in. Colour and pattern are set at a Chrome Cradle." + desc = "Programmable tattoo ink and the spider-legged injector that lays it under the skin. The traces light up whenever the rest of your chrome gets to work." icon_state = "chromatic_dermis" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_INK @@ -276,7 +276,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( */ /obj/item/organ/eyes/robotic/cyberware/nightshade name = "\improper Nightshade optics" - desc = "Matte black eyes that render a dark room in green. Living bodies in range pick up a soft glow only you can see, so an unlit corridor isn't cover any more. They aren't thermals, so a flashbang hits you no harder than it would normal eyes. The diagnostic bus is the stock one: it counts how much chrome someone is carrying, but can't name any of it." + desc = "Matte black eyes that render a dark room in green. Living bodies pick up a soft glow only you can see." icon_state = "nightshade" eye_color_left = "#1d3b2a" eye_color_right = "#1d3b2a" @@ -409,7 +409,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( */ /obj/item/organ/cyberimp/cyberware/scrapper name = "\improper Scrapper's Knuckles" - desc = "Milled knuckle caps grafted along the metacarpals, right-arm fit. Your punches land harder, and against plating and machine housings they land about twice as hard again." + desc = "Milled knuckle caps grafted along the metacarpals, right-arm fit. Hinges and housings come off worse." icon_state = "scrapper" zone = BODY_ZONE_R_ARM slot = ORGAN_SLOT_RIGHT_ARM_AUG @@ -423,7 +423,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( aug_overlay = "scrapper_right" /obj/item/organ/cyberimp/cyberware/scrapper/left - desc = "Milled knuckle caps grafted along the metacarpals, left-arm fit. Your punches land harder, and against plating and machine housings they land about twice as hard again." + desc = "Milled knuckle caps grafted along the metacarpals, left-arm fit. Hinges and housings come off worse." zone = BODY_ZONE_L_ARM slot = ORGAN_SLOT_LEFT_ARM_AUG aug_overlay = "scrapper_left" @@ -458,6 +458,9 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( var/is_structure_target = ismachinery(target) || isstructure(target) if(!isliving(target) && !is_structure_target) return NONE + // A pacifist's punch at a living thing is the ordinary punch, which refuses it. + if(isliving(target) && HAS_TRAIT(source, TRAIT_PACIFISM)) + return NONE // Past the last "not our punch" guard: this swing is ours from here on, so // stand Redline's bypass top-up down before we take the chain away. The // roll below reads the hand's unarmed damage, which already carries the @@ -517,7 +520,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( /obj/item/storage/case/cyberware/scrapper name = "\improper Scrapper's Knuckles case" - desc = "A foam-lined chrome case holding a matched pair of Scrapper's Knuckles, one per arm. Each side installs separately, though the rig will do both in one sitting." + desc = "A foam-lined chrome case holding a matched pair of Scrapper's Knuckles, one per arm." /obj/item/storage/case/cyberware/scrapper/PopulateContents() new /obj/item/organ/cyberimp/cyberware/scrapper(src) @@ -535,7 +538,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( */ /obj/item/organ/cyberimp/cyberware/shock_coils name = "\improper Shock Coil calf pistons" - desc = "Spring-loaded pistons sistered along the calf bones. You get back on your feet much faster after a knockdown, keep your footing on wet decking, and walk away from drops that would break an ankle." + desc = "Spring-loaded pistons sistered along the calf bones, so the floor gets less say in things." icon_state = "shock_coils" zone = BODY_ZONE_L_LEG slot = ORGAN_SLOT_CYBERWARE_LEGS @@ -622,7 +625,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( */ /obj/item/organ/cyberimp/cyberware/gastro name = "\improper Gastro Reactor" - desc = "A ceramic-lined digester where your stomach used to be. Rot, floor scrapings, whatever was in the back of the fridge. It all burns the same, faster than a real gut and without the food poisoning." + desc = "A ceramic-lined digester where your stomach used to be. Rot, floor scrapings, whatever was in the back of the fridge: it all burns the same." icon_state = "gastro" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_GUT @@ -668,7 +671,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( */ /obj/item/organ/cyberimp/cyberware/cargo_cavity name = "\improper Cargo Cavity" - desc = "A shielded compartment plumbed into the ribcage, sized for one small item. Scanners read straight past it and a pat-down won't find it." + desc = "A shielded compartment plumbed into the ribcage, sized for one small item." icon_state = "cargo_cavity" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_STASH @@ -742,10 +745,14 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( * add/subtract pair per flip is the whole lifecycle; re-applying on species * gain would stack the armor. The pair rides the failing-gated passive hooks * (BAL-4): EMP-scrambled or browned-out mesh armors nothing. + * + * The dermal ladder (Mesh, Hardweave, Slabskin) also turns bullets: a + * passive deflect source in the shared dodge arbiter (ware_pro_combat.dm), + * 15/30/45% by rung, front arc only, rides the same passive hooks. */ /obj/item/organ/cyberimp/cyberware/dermal_mesh name = "\improper Dermal Mesh weave" - desc = "A subdermal lattice of impact polymer. It won't stop anything serious, but knives and small arms hurt noticeably less and the skin over it doesn't tear so easily." + desc = "A subdermal lattice of impact polymer. It won't stop anything serious, but now and then a round skips off it." icon_state = "dermal_mesh" zone = BODY_ZONE_CHEST slot = ORGAN_SLOT_CYBERWARE_DERMAL @@ -753,13 +760,17 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( chrome_load = 2 tier = CYBERWARE_TIER_1 aug_overlay = "dermal_mesh" + worn_under_clothes = TRUE /// Armor mixed into the bearer's physiology while installed and running. var/datum/armor/mesh_armor = /datum/armor/cyberware_dermal_mesh /// TRUE while mesh_armor is mixed in; guards against double add/subtract. var/mesh_armor_applied = FALSE + /// Percent of bullets from the front that glance off, through the shared dodge arbiter. + var/deflect_chance = 15 /obj/item/organ/cyberimp/cyberware/dermal_mesh/chrome_passives_on(mob/living/carbon/bearer) . = ..() + cyberware_register_deflect_source(bearer, REF(src), CALLBACK(src, PROC_REF(get_deflect_chance))) if(mesh_armor_applied || !ishuman(bearer)) return mesh_armor_applied = TRUE @@ -768,6 +779,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( /obj/item/organ/cyberimp/cyberware/dermal_mesh/chrome_passives_off(mob/living/carbon/bearer) . = ..() + cyberware_unregister_deflect_source(bearer, REF(src)) if(!mesh_armor_applied) return mesh_armor_applied = FALSE // reset before the validity skip, see Shock Coils @@ -776,6 +788,12 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( var/mob/living/carbon/human/human_bearer = bearer human_bearer.physiology.armor = human_bearer.physiology.armor.subtract_other_armor(mesh_armor) +/// Deflect-source callback: nothing while failing. +/obj/item/organ/cyberimp/cyberware/dermal_mesh/proc/get_deflect_chance() + if(organ_flags & ORGAN_FAILING) + return 0 + return deflect_chance + // ---- 11. Gecko Grips --------------------------------------------------- /** @@ -807,7 +825,7 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( */ /obj/item/organ/cyberimp/cyberware/gecko name = "\improper Gecko Grip palm pads" - desc = "Setae pads laminated into the palms, running the same trick geckos do. Your hands clamp shut on whatever you're holding when you go down, so nobody strips your gun off you, and you can cross tables like flat ground and catch a ledge on the way into a chasm. Cuffs still work fine." + desc = "Setae pads laminated into the palms, running the same trick geckos do. Whatever you're holding stays held." icon_state = "gecko" zone = BODY_ZONE_R_ARM slot = ORGAN_SLOT_CYBERWARE_HANDS @@ -832,19 +850,32 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( RegisterSignal(organ_owner, COMSIG_MOB_EQUIPPED_ITEM, PROC_REF(on_item_equipped)) RegisterSignal(organ_owner, COMSIG_MOB_UNEQUIPPED_ITEM, PROC_REF(on_item_unequipped)) RegisterSignal(organ_owner, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) - passtable_on(organ_owner, REF(src)) // Whatever they were already holding when the pads went in. for(var/obj/item/held in organ_owner.held_items) guard_item(held) - if(catch_ready) - ADD_TRAIT(organ_owner, TRAIT_CHASM_STOPPER, REF(src)) /obj/item/organ/cyberimp/cyberware/gecko/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() drop_guards() UnregisterSignal(organ_owner, list(COMSIG_MOB_EQUIPPED_ITEM, COMSIG_MOB_UNEQUIPPED_ITEM, COMSIG_MOVABLE_MOVED)) - passtable_off(organ_owner, REF(src)) - REMOVE_TRAIT(organ_owner, TRAIT_CHASM_STOPPER, REF(src)) + +// Tables as flat ground and the chasm catch ride the failing-gated passive layer: dark pads +// (EMP, brownout, damage) do neither. The catch used to stay armed through a pulse, and a +// bearer whose pads were dark could cross a chasm because the arming trait was never spent. +/obj/item/organ/cyberimp/cyberware/gecko/chrome_passives_on(mob/living/carbon/bearer) + . = ..() + if(isnull(bearer)) + return + passtable_on(bearer, REF(src)) + if(catch_ready) + ADD_TRAIT(bearer, TRAIT_CHASM_STOPPER, REF(src)) + +/obj/item/organ/cyberimp/cyberware/gecko/chrome_passives_off(mob/living/carbon/bearer) + . = ..() + if(isnull(bearer)) + return + passtable_off(bearer, REF(src)) + REMOVE_TRAIT(bearer, TRAIT_CHASM_STOPPER, REF(src)) /obj/item/organ/cyberimp/cyberware/gecko/Destroy() drop_guards() @@ -968,7 +999,9 @@ GLOBAL_LIST_INIT(cyberware_ink_palette, list( /obj/item/organ/cyberimp/cyberware/gecko/proc/rearm_catch() catch_ready = TRUE - if(owner) + // Dark pads re-arm too, the trait goes back on with the passive layer. + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + if(owner && chrome?.passives_online) ADD_TRAIT(owner, TRAIT_CHASM_STOPPER, REF(src)) owner.balloon_alert(owner, "grips re-set") diff --git a/voidcrew/modules/cyberware/ware_street_passives.dm b/voidcrew/modules/cyberware/ware_street_passives.dm new file mode 100644 index 00000000000..d5a50c516eb --- /dev/null +++ b/voidcrew/modules/cyberware/ware_street_passives.dm @@ -0,0 +1,454 @@ +/** + * # Street passives + * + * Six cheap pieces of chrome that do one quiet thing each and have no button: + * + * - Clotter node (heart aux, T1): bleed slower. + * - Adrenal pump (heart aux, T2): answers a bad run of stamina damage once + * in a while. Shares the heart aux slot with the Clotter node. + * - Medic's palms (hands, T1): nitrile-glove speed without the glove. + * - Cuffer's wrists (hands, T1): quicker cuffing. Sideways to the Medic's + * palms and the Gecko Grip, which sit in the same slot. + * - Subvocal mic (larynx, T1): radio talk goes no further than the speaker. + * - Muffler ear (ears, T1): earmuff-grade protection from a bang. Sideways to + * the Heartbeat Doppler, same slot. + * + * Every effect rides the failing-gated passive layer (chrome_passives_on/off in + * cyberware_base.dm), so an EMP, a brownout or a damage failure switches it off + * and a tune-up hands it back. All tuning is in vars on the organ. + * + * The Subvocal mic needs two small hooks in the speech path. Both are chained + * overrides at the bottom of this file, nothing upstream is edited. + * + * SKUs and trade-ins are defined at the bottom. + */ + +/// Held by a mob whose radio talk is not overheard. Granted by the Subvocal mic. +#define TRAIT_CYBER_SUBVOCAL "cyber_subvocal" +/// The red the Adrenal pump leaves on its bearer for the length of the rush. +#define CYBERWARE_ADRENAL_FLUSH "#ff8f8f" + +// ========================================================================= +// CLOTTER NODE +// ========================================================================= + +/** + * # Clotter node (T1, chest, heart aux slot, load 1) + * + * Halves the blood the bearer loses. The multiplier is mixed into the human + * physiology, which survives species changes, so there is one multiply and one + * divide per flip, and the factor actually applied is remembered so retuning the + * var on a live organ cannot desync the pair. Rides the failing-gated passive + * hooks like the Dermal Mesh does. + */ +/obj/item/organ/cyberimp/cyberware/clotter_node + name = "\improper Clotter node" + desc = "A reservoir of clotting gel plumbed into the heart. Cuts stop sooner than they should." + icon_state = "clotter_node" + zone = BODY_ZONE_CHEST + slot = ORGAN_SLOT_CYBERWARE_HEART_AUX + w_class = WEIGHT_CLASS_SMALL + chrome_load = 1 + tier = CYBERWARE_TIER_1 + /// Multiplier on the blood the bearer loses. + var/bleed_multiplier = 0.5 + /// The multiplier currently mixed into the bearer, or null when none is. + var/applied_bleed_multiplier + +/obj/item/organ/cyberimp/cyberware/clotter_node/chrome_passives_on(mob/living/carbon/bearer) + . = ..() + if(!isnull(applied_bleed_multiplier) || !ishuman(bearer)) + return + var/mob/living/carbon/human/human_bearer = bearer + applied_bleed_multiplier = bleed_multiplier + human_bearer.physiology.bleed_mod *= applied_bleed_multiplier + +/obj/item/organ/cyberimp/cyberware/clotter_node/chrome_passives_off(mob/living/carbon/bearer) + . = ..() + if(isnull(applied_bleed_multiplier)) + return + var/removed_multiplier = applied_bleed_multiplier + applied_bleed_multiplier = null // reset before the validity skip, see Shock Coils + if(!ishuman(bearer) || QDELETED(bearer)) + return + var/mob/living/carbon/human/human_bearer = bearer + human_bearer.physiology.bleed_mod /= removed_multiplier + +// ========================================================================= +// ADRENAL PUMP +// ========================================================================= + +/** + * # Adrenal pump (T2, chest, heart aux slot, load 2) + * + * When a run of stamina damage takes the bearer to the trigger level, the pump + * dumps a shot of adrenaline: part of the stamina loss comes off and the bearer + * is quicker on their feet for a few seconds. The tell is deliberate: a heartbeat + * thud anyone nearby can hear and a red flush on the bearer. + * + * The wait before it fires again is stored on the organ as the world.time it is + * ready at, so pulling the pump and refitting it never resets the wait. + * + * It answers damage from outside only. The crashes of the Cascade and Redline + * lines dump stamina as their own price, and a pump that took the sting out of + * that price would make the cheap heart ware a cure for the legend ware's bill, so + * the check runs one tick after the damage (the crash status is not on the bearer + * yet at the moment of the dump) and stands down while either crash is running. + */ +/obj/item/organ/cyberimp/cyberware/adrenal_pump + name = "\improper Adrenal pump" + desc = "A pump of synthetic adrenaline wired into the heart. The sort of thing a doctor tells you not to try at home." + icon_state = "adrenal_pump" + zone = BODY_ZONE_CHEST + slot = ORGAN_SLOT_CYBERWARE_HEART_AUX + w_class = WEIGHT_CLASS_SMALL + chrome_load = 2 + tier = CYBERWARE_TIER_2 + /// Stamina loss at or above which the pump fires. + var/trigger_stamina = 70 + /// Stamina loss taken off when it fires. + var/stamina_relief = 40 + /// How long the bearer is quicker for. + var/rush_duration = 3 SECONDS + /// How long the pump takes to charge again after firing. + var/recharge_time = 4 MINUTES + /// world.time at which the pump is ready to fire. Lives on the organ, so + /// removing and refitting it keeps the wait. + var/ready_at = 0 + /// TRUE while a firing check is queued, so one volley of damage queues one check. + var/discharge_queued = FALSE + +/obj/item/organ/cyberimp/cyberware/adrenal_pump/examine(mob/user) + . = ..() + . += span_notice("Its status light is [world.time < ready_at ? "amber" : "green"].") + +/obj/item/organ/cyberimp/cyberware/adrenal_pump/chrome_passives_on(mob/living/carbon/bearer) + . = ..() + if(isnull(bearer)) + return + RegisterSignal(bearer, COMSIG_LIVING_STAMINA_UPDATE, PROC_REF(on_stamina_update), override = TRUE) + +/obj/item/organ/cyberimp/cyberware/adrenal_pump/chrome_passives_off(mob/living/carbon/bearer) + . = ..() + discharge_queued = FALSE + if(isnull(bearer)) + return + UnregisterSignal(bearer, COMSIG_LIVING_STAMINA_UPDATE) + +/// Signal proc for [COMSIG_LIVING_STAMINA_UPDATE]: cheap tests only, the pump +/// itself fires from the queued check. +/obj/item/organ/cyberimp/cyberware/adrenal_pump/proc/on_stamina_update(mob/living/source) + SIGNAL_HANDLER + if(discharge_queued || source != owner || world.time < ready_at) + return + if(source.stat != CONSCIOUS || source.getStaminaLoss() < trigger_stamina) + return + discharge_queued = TRUE + addtimer(CALLBACK(src, PROC_REF(discharge)), 1) // next tick, see the header + +/// The queued check. Everything is tested again: the bearer may have recovered, +/// been knocked out, lost the chrome or be riding out a crash. +/obj/item/organ/cyberimp/cyberware/adrenal_pump/proc/discharge() + discharge_queued = FALSE + var/mob/living/carbon/bearer = owner + if(QDELETED(src) || QDELETED(bearer) || world.time < ready_at) + return + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + if(!chrome?.is_running()) + return + if(bearer.stat != CONSCIOUS || bearer.getStaminaLoss() < trigger_stamina) + return + if(bearer.has_status_effect(/datum/status_effect/cyberware_cascade_crash) || bearer.has_status_effect(/datum/status_effect/cyberware_redline_crash)) + return + // Spent first: the relief below re-enters the stamina signal. + ready_at = world.time + recharge_time + bearer.adjustStaminaLoss(-stamina_relief) + bearer.apply_status_effect(/datum/status_effect/cyberware_adrenal_rush, rush_duration) + playsound(bearer, 'sound/effects/singlebeat.ogg', 100, TRUE, 2) + bearer.visible_message( + span_warning("[bearer] flushes red, heart thudding loud enough to hear."), + span_userdanger("Your heart slams and the exhaustion drops away."), + ) + bearer.balloon_alert(bearer, "adrenaline!") + cyberware_ink_pulse(bearer, CYBERWARE_INK_HARD) + +/// The burst of speed, and the flush that shows it. +/datum/status_effect/cyberware_adrenal_rush + id = "cyberware_adrenal_rush" + duration = 3 SECONDS + tick_interval = STATUS_EFFECT_NO_TICK + alert_type = null + +/// Optional argument: how long the rush lasts, from the pump that fired it. +/datum/status_effect/cyberware_adrenal_rush/on_creation(mob/living/new_owner, rush_duration) + if(isnum(rush_duration)) + duration = rush_duration + return ..() + +/datum/status_effect/cyberware_adrenal_rush/on_apply() + owner.add_movespeed_modifier(/datum/movespeed_modifier/cyberware_adrenal_rush) + owner.add_atom_colour(CYBERWARE_ADRENAL_FLUSH, TEMPORARY_COLOUR_PRIORITY) + return TRUE + +/datum/status_effect/cyberware_adrenal_rush/on_remove() + owner.remove_movespeed_modifier(/datum/movespeed_modifier/cyberware_adrenal_rush) + owner.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY, CYBERWARE_ADRENAL_FLUSH) + return ..() + +/datum/movespeed_modifier/cyberware_adrenal_rush + multiplicative_slowdown = -0.4 + +// ========================================================================= +// MEDIC'S PALMS +// ========================================================================= + +/** + * # Medic's palms (T1, arm, hands slot, load 1) + * + * The nitrile-glove pair of traits (quicker chemistry, quicker fireman carry) + * without taking up the glove slot. Same slot as the Gecko Grip and the Cuffer's + * wrists, so a body wears one of the three. + */ +/obj/item/organ/cyberimp/cyberware/medic_palms + name = "\improper Medic's palms" + desc = "Sterile palm plates with a better grip than any nitrile glove. Saves a trip to the glove dispenser." + icon_state = "medic_palms" + zone = BODY_ZONE_R_ARM + slot = ORGAN_SLOT_CYBERWARE_HANDS + w_class = WEIGHT_CLASS_SMALL + chrome_load = 1 + tier = CYBERWARE_TIER_1 + organ_traits = list(TRAIT_FASTMED, TRAIT_QUICKER_CARRY) + +// ========================================================================= +// CUFFER'S WRISTS +// ========================================================================= + +/** + * # Cuffer's wrists (T1, arm, hands slot, load 1) + * + * Cuffs go on in three quarters of the time (TRAIT_FAST_CUFFING, the same trait + * as combat gloves). For bounty hunters and anyone else who ties people up for a + * living. + */ +/obj/item/organ/cyberimp/cyberware/cuffer_wrists + name = "\improper Cuffer's wrists" + desc = "Reinforced wrist actuators with a lot of practice at closing around other people's wrists." + icon_state = "cuffer_wrists" + zone = BODY_ZONE_R_ARM + slot = ORGAN_SLOT_CYBERWARE_HANDS + w_class = WEIGHT_CLASS_SMALL + chrome_load = 1 + tier = CYBERWARE_TIER_1 + organ_traits = list(TRAIT_FAST_CUFFING) + +// ========================================================================= +// SUBVOCAL MIC +// ========================================================================= + +/** + * # Subvocal mic (T1, head, larynx slot, load 1) + * + * Radio talk is whispered at range 1 today, so the person next to you hears it. + * With the mic it goes no further than the speaker. The trait is the whole ware; + * the speech hooks at the bottom of this file read it. + */ +/obj/item/organ/cyberimp/cyberware/subvocal_mic + name = "\improper Subvocal mic" + desc = "A throat mic sutured to the vocal cords. Radio chatter goes out the wire instead of the room." + icon_state = "subvocal_mic" + zone = BODY_ZONE_HEAD + slot = ORGAN_SLOT_CYBERWARE_LARYNX + w_class = WEIGHT_CLASS_SMALL + chrome_load = 1 + tier = CYBERWARE_TIER_1 + organ_traits = list(TRAIT_CYBER_SUBVOCAL) + +/// TRUE between a radio line the Subvocal mic quieted and the send_speech() call +/// that carries it, which follows straight on with no wait in between. +/mob/living/var/cyberware_subvocal_pending = FALSE + +/** + * Chained override of the human radio branch (base definition: + * code/modules/mob/living/carbon/human/human_say.dm, which sets the whisper + * range when it returns REDUCE_RANGE). A bearer's radio line is marked here; + * the send_speech() override below spends the mark. A line the radio swallowed + * (NOPASS) never reaches send_speech and is not marked. + */ +/mob/living/carbon/human/radio(message, list/message_mods = list(), list/spans, language) + cyberware_subvocal_pending = FALSE + . = ..() + if((. & REDUCE_RANGE) && !(. & NOPASS) && HAS_TRAIT(src, TRAIT_CYBER_SUBVOCAL)) + cyberware_subvocal_pending = TRUE + +/** + * Chained override of living speech output. A marked radio line is spoken at + * range 0: the bearer and anyone on their tile hear it, a neighbour one tile off + * gets the usual eavesdropper's garble, nobody else hears anything. The voice + * bark layer wraps this one and still plays its blip at the old range. + */ +/mob/living/send_speech(message_raw, message_range = 6, obj/source = src, bubble_type = bubble_icon, list/spans, datum/language/message_language = null, list/message_mods = list(), forced = null, tts_message, list/tts_filter) + if(cyberware_subvocal_pending) + cyberware_subvocal_pending = FALSE + message_range = 0 + return ..(message_raw, message_range, source, bubble_type, spans, message_language, message_mods, forced, tts_message, tts_filter) + +// ========================================================================= +// MUFFLER EAR +// ========================================================================= + +/** + * # Muffler ear (T1, head, ears slot, load 1) + * + * Takes one point off the intensity of a bang, which is exactly what earmuffs do + * (code/datums/components/earprotection.dm, sender soundbang_act in + * carbon_defense.dm). The listener is registered by the passive hooks, so an + * offline ear hears the bang in full. Same slot as the Heartbeat Doppler. + */ +/obj/item/organ/cyberimp/cyberware/muffler_ear + name = "\improper Muffler ear" + desc = "Baffles set into the ear canal. Earmuffs you can't leave on the bridge." + icon_state = "muffler_ear" + zone = BODY_ZONE_HEAD + slot = ORGAN_SLOT_CYBERWARE_EARS + w_class = WEIGHT_CLASS_SMALL + chrome_load = 1 + tier = CYBERWARE_TIER_1 + /// Intensity taken off a bang. + var/bang_reduction = 1 + +/obj/item/organ/cyberimp/cyberware/muffler_ear/chrome_passives_on(mob/living/carbon/bearer) + . = ..() + if(isnull(bearer)) + return + RegisterSignal(bearer, COMSIG_CARBON_SOUNDBANG, PROC_REF(on_soundbang), override = TRUE) + +/obj/item/organ/cyberimp/cyberware/muffler_ear/chrome_passives_off(mob/living/carbon/bearer) + . = ..() + if(isnull(bearer)) + return + UnregisterSignal(bearer, COMSIG_CARBON_SOUNDBANG) + +/// Signal proc for [COMSIG_CARBON_SOUNDBANG]: the intensity rides in a list so +/// listeners can change it. +/obj/item/organ/cyberimp/cyberware/muffler_ear/proc/on_soundbang(datum/source, list/reflist) + SIGNAL_HANDLER + reflist[1] -= bang_reduction + +// ========================================================================= +// SHOP SKUS: on the Chop Shop's sku_types and on the street doc's. +// ========================================================================= + +/datum/shop_sku/ripperdoc/clotter_node + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/clotter_node + price_credits = 900 + +/datum/shop_sku/ripperdoc/adrenal_pump + zone_permission = ZONE_PERMISSION_YELLOW + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/adrenal_pump + price_credits = 2400 + +/datum/shop_sku/ripperdoc/medic_palms + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/medic_palms + price_credits = 600 + +/datum/shop_sku/ripperdoc/cuffer_wrists + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/cuffer_wrists + price_credits = 500 + +/datum/shop_sku/ripperdoc/subvocal_mic + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/subvocal_mic + price_credits = 600 + +/datum/shop_sku/ripperdoc/muffler_ear + category = "Street Chrome" + item_path = /obj/item/organ/cyberimp/cyberware/muffler_ear + price_credits = 700 + +// ========================================================================= +// TRADE-IN: half list, credits only. Ratchet's entries (/street_doc) differ +// only in wording. +// ========================================================================= + +/datum/shop_buyback/ripperdoc/clotter_node + name = "Clotter node (pulled)" + desc = "A used clotting-gel reservoir." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/clotter_node + match_subtypes = FALSE + pay_credits = 450 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/clotter_node/street_doc + desc = "A used gel reservoir. Still sticky." + +/datum/shop_buyback/ripperdoc/adrenal_pump + name = "Adrenal pump (pulled)" + desc = "A used adrenaline pump. Splice takes these off your hands." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/adrenal_pump + match_subtypes = FALSE + pay_credits = 1200 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/ripperdoc/adrenal_pump/street_doc + desc = "A used heart pump. Handle it gently." + +/datum/shop_buyback/ripperdoc/medic_palms + name = "Medic's palms (pulled)" + desc = "Used sterile palm plates." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/medic_palms + match_subtypes = FALSE + pay_credits = 300 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/medic_palms/street_doc + desc = "Used palm plates. Washed, mostly." + +/datum/shop_buyback/ripperdoc/cuffer_wrists + name = "Cuffer's wrists (pulled)" + desc = "Used wrist actuators." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/cuffer_wrists + match_subtypes = FALSE + pay_credits = 250 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/cuffer_wrists/street_doc + desc = "Used wrist actuators. They've seen some arrests." + +/datum/shop_buyback/ripperdoc/subvocal_mic + name = "Subvocal mic (pulled)" + desc = "A used throat mic." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/subvocal_mic + match_subtypes = FALSE + pay_credits = 300 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/subvocal_mic/street_doc + desc = "A used throat mic. Don't ask what it heard." + +/datum/shop_buyback/ripperdoc/muffler_ear + name = "Muffler ear (pulled)" + desc = "Used ear baffles." + category = "Trade-In" + item_path = /obj/item/organ/cyberimp/cyberware/muffler_ear + match_subtypes = FALSE + pay_credits = 350 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/ripperdoc/muffler_ear/street_doc + desc = "Used ear baffles. Quiet ones." diff --git a/voidcrew/modules/drug_smuggling/mission.dm b/voidcrew/modules/drug_smuggling/mission.dm index 7255eb52cae..108fe1f2349 100644 --- a/voidcrew/modules/drug_smuggling/mission.dm +++ b/voidcrew/modules/drug_smuggling/mission.dm @@ -292,6 +292,7 @@ fail("No mission pad to deliver the formula chip to.") return formula = new(chip_turf) + mission_pad_delivery_effect(chip_turf) formula.recipe = recipe servant?.ship_notify("Formula chip for '[recipe.street_name]' delivered to your mission pad. Examine it for the shopping list.", "DRUG RUN", SHIP_NOTIFY_NOTICE, 'voidcrew/sound/notify.ogg', 50) @@ -433,6 +434,8 @@ fail("Nowhere to deliver the finished batch, contract void.") return var/obj/item/mission_recovery/drug_product/product = new(product_turf) + if(!preferred_turf) + mission_pad_delivery_effect(product_turf) // the pad fallback: it arrives like any other delivery product.configure(recipe, purity_tier) bind_item(product) register_quest_atom(product) @@ -496,6 +499,10 @@ var/respawns_left = 1 /// Guard so notify_when_loaded() is never double-registered var/awaiting_load = FALSE + /// Where the current harvest scene was laid; a replacement grows near it + var/turf/scene_anchor + /// How far from the cache a replacement specimen may grow + var/regrow_radius = 6 /datum/ingredient_site/New(datum/mission/drug_run/mission, list/entry) ..() @@ -508,6 +515,7 @@ release_item(delete_uncollected = TRUE) QDEL_NULL(site_target) mission = null + scene_anchor = null return ..() /** @@ -554,6 +562,7 @@ site_target?.notify_when_loaded() return spawned = TRUE + scene_anchor = scene_turf new /obj/structure/ingredient_cache(scene_turf) var/obj/item/drug_ingredient/ingredient = new ingredient_type(get_nearby_open_turf(scene_turf)) watch_item(ingredient) @@ -608,7 +617,7 @@ site_target.notify_when_loaded() return if(respawns_left > 0) - var/turf/retry_turf = site_target.get_spawn_turf() + var/turf/retry_turf = find_regrowth_turf() if(retry_turf) respawns_left-- var/obj/item/drug_ingredient/replacement = new ingredient_type(retry_turf) @@ -639,6 +648,24 @@ if(mission.active) mission.push_site_waypoint(src) +/** + * Where a replacement specimen grows: clear ground a few tiles from the cache, + * out of the crew's sight when there is any. Falls back to the whole site when + * the camp has no room (or the anchor isn't on this site any more). + */ +/datum/ingredient_site/proc/find_regrowth_turf() + if(scene_anchor && site_target.contains_turf(scene_anchor)) + var/list/nearby = list() + for(var/turf/open/tile in RANGE_TURFS(regrow_radius, scene_anchor)) + if(isgroundlessturf(tile) || tile.is_blocked_turf(exclude_mobs = TRUE)) + continue + if(istype(get_area(tile), /area/shuttle) || !site_target.contains_turf(tile)) + continue + nearby += tile + if(length(nearby)) + return pick_unwatched_turf(nearby) + return site_target.get_spawn_turf() + /// Stops watching the live field ingredient; optionally removes it outright /datum/ingredient_site/proc/release_item(delete_uncollected = FALSE) var/obj/item/drug_ingredient/ingredient = item_ref?.resolve() diff --git a/voidcrew/modules/hyperviolence/wire/_wire_defines.dm b/voidcrew/modules/hyperviolence/wire/_wire_defines.dm new file mode 100644 index 00000000000..82e4214f29e --- /dev/null +++ b/voidcrew/modules/hyperviolence/wire/_wire_defines.dm @@ -0,0 +1,83 @@ +// Widowline monowire x hyperviolence (voidcrew/modules/hyperviolence/wire/): defines private to this part. +// The folder sorts after cyberware/ and every other hyperviolence part on purpose: it overrides procs both +// declare, and an override included before its declaration is silently dead. + +/// Clean cuts, seams, the through-cut and blood beams, the garrote loop and taut wire. +#define WIRE_GORE_ICON 'voidcrew/modules/hyperviolence/wire/icons/wire_gore.dmi' +/// The wire swinging out of its spool and reeling back in, with blood-flick twins. +#define WIRE_HELD_ANIM_ICON 'voidcrew/modules/cyberware/icons/cyberware_anim_monowire.dmi' +/// The held wire's spool on its own, as each hand draws it ("_left", "_right"): what is left in +/// the hand while the wire is out of it as a line. +#define WIRE_SPOOL_ICON 'voidcrew/modules/hyperviolence/wire/icons/wire_spool.dmi' + +/// On a body a Widowline is cutting right now: no flying hitsplatter, drips instead of floor splatter, +/// and a limb tg's own wound roll would tear off is left for the wire to take off clean. +#define TRAIT_HV_CLEAN_CUT "hv_clean_cut" + +/// An aimed cut takes off an arm or leg already this damaged (percent of its max damage) before the hit. +/// Whole percents: in DM's floats 50 * 0.6 is a hair over 30, and a limb at exactly 60% would never qualify. +#define WIRE_SEVER_AT 60 +/// The same on someone already down. +#define WIRE_SEVER_AT_DOWN 20 +/// A crossing cut takes a limb off at this share of the usual damage (percent). +#define WIRE_CROSS_SEVER_SHARE 50 +/// With a wire out in each hand, every this many landed hits cross both through the target. +#define WIRE_CROSS_HITS 3 +/// Landed hits further apart than this start the count again. +#define WIRE_CROSS_WINDOW (3 SECONDS) + +/// From the hit to the severed limb sliding off the body. +#define WIRE_CUT_DELAY (0.5 SECONDS) +/// The slide along the cut, and the fall after it. +#define WIRE_SLIDE_TIME (0.2 SECONDS) +#define WIRE_FALL_TIME (0.15 SECONDS) +/// Someone on their feet whose leg the wire took goes down once the leg is on the floor... +#define WIRE_LEG_FALL_DELAY (WIRE_CUT_DELAY + WIRE_SLIDE_TIME + WIRE_FALL_TIME) +/// ...knocked down as long as a shove knocks a person down. +#define WIRE_LEG_KNOCKDOWN SHOVE_KNOCKDOWN_HUMAN +/// Blood the Arc's seared cut loses, as a fraction of a plain sever's. +#define WIRE_ARC_BLEED_MULT 0.25 +/// How long a seared stump smokes. +#define WIRE_ARC_SMOKE_TIME (3 SECONDS) +/// A seared stump's blood layer and bone. +#define WIRE_BURNT_STUMP_COLOR "#2a1b15" +#define WIRE_BURNT_BONE_COLOR "#7a6a60" + +/// Blood on the wire: wet and dripping for this long after a cut, stained for this long. +#define WIRE_WET_TIME (15 SECONDS) +#define WIRE_STAINED_TIME (30 SECONDS) +/// Most drips one wet spell leaves. +#define WIRE_MAX_DRIPS 8 +/// Drops a wet wire throws when it cracks back into the spool. +#define WIRE_FLICK_DROPS 6 + +/// The swing out of the spool and back in. +#define WIRE_SWING_TIME (0.4 SECONDS) +/// A lash's line fades out over this long. +#define WIRE_LASH_FADE (0.5 SECONDS) +/// The wire hanging in the hand isn't drawn for this long into a lash, while the line out of the grip stands in for it, +/// and is back as the line fades: never two wires from one hand, never an empty one. +#define WIRE_LASH_HIDE (0.45 SECONDS) +/// The alpha a lash's line is down to by then, held until it goes. +#define WIRE_LASH_TRACE 40 + +/// The garrote's wait after an attempt that got a grip, and after one that didn't. +#define WIRE_GARROTE_COOLDOWN (20 SECONDS) +#define WIRE_GARROTE_MISS_COOLDOWN (5 SECONDS) +/// Worn and plated cover at the neck (crit gate rating, the wire's penetration not counted) that turns the garrote. +#define WIRE_GARROTE_COVER 25 +/// World layer between a body lying on the floor and one standing: the garrote's wire facing away, which runs from the +/// hands hidden behind the garroter to the neck of the body lying beyond them. +#define WIRE_BETWEEN_LAYER (LYING_MOB_LAYER + 0.05) +/// World layer of a body the garrote holds up in front of a garroter facing the viewer: over the garroter, under the +/// near side of the loop. +#define WIRE_PULLED_LAYER (MOB_LAYER + 0.02) +/// Most blood the garrote pours into the pool under the neck: a pool that keeps to its tile (blood/blood_pools.dm). +#define WIRE_GARROTE_POOL_CAP 190 + +/// Mob overlay layers. The held limb: over the jumpsuit and the stump, under the ID, belt, suit and hands. +#define WIRE_GHOST_LAYER (-(HV_STUMP_FRESH_LAYER - 0.1)) +/// The wire swinging out of or into a hand: just over the held item it turns into. +#define WIRE_SWING_LAYER (-(HANDS_LAYER - 0.5)) +/// Flashes, seams and loops: over everything the body wears. +#define WIRE_FX_LAYER (-(HIGHEST_LAYER - 0.5)) diff --git a/voidcrew/modules/hyperviolence/wire/icons/wire_gore.dmi b/voidcrew/modules/hyperviolence/wire/icons/wire_gore.dmi new file mode 100644 index 00000000000..934ff94ec8e Binary files /dev/null and b/voidcrew/modules/hyperviolence/wire/icons/wire_gore.dmi differ diff --git a/voidcrew/modules/hyperviolence/wire/icons/wire_spool.dmi b/voidcrew/modules/hyperviolence/wire/icons/wire_spool.dmi new file mode 100644 index 00000000000..9cdd5983610 Binary files /dev/null and b/voidcrew/modules/hyperviolence/wire/icons/wire_spool.dmi differ diff --git a/voidcrew/modules/hyperviolence/wire/wire_cut.dm b/voidcrew/modules/hyperviolence/wire/wire_cut.dm new file mode 100644 index 00000000000..a6a78e85757 --- /dev/null +++ b/voidcrew/modules/hyperviolence/wire/wire_cut.dm @@ -0,0 +1,317 @@ +/** + * # The Widowline's cut + * + * What a landed wire swing does to the bodies it passes through, on top of its damage + * (cyberware/ware_military_arms.dm): + * - It cuts clean (wire_seams.dm): no fan of blood, a thin line and a few drops. + * - An aimed cut takes off an arm or leg that is already badly hurt (WIRE_SEVER_AT of its max damage before + * the hit), or less hurt on someone already down (WIRE_SEVER_AT_DOWN). Never a corpse, never through an + * Atlas frame (tg's can_dismember()), never an ally. The limb is off at the hit; it stays drawn on for a + * beat and slides off after (wire_sever_fx.dm). Someone on their feet who loses a leg goes down once it has + * dropped (wire_leg_fall()): tg's own knockdown, so the fall is tg's and they get up again on one leg. + * - The Arc's charged wire sears the stump shut: little blood, no spray (wire_sever_fx.dm). + * - It carries on into one body standing right behind the target, along the swing's line, and nobody else, as a + * line of the one hit message. Hurting someone at a trader outpost this way counts as an attack there. + * - With a wire out in each hand, every third landed hit in a row crosses both through the target: both wires + * lash out, and the sever takes a limb at half the usual damage. + * - The aimed sever, the crossing cut and the garrote are the wielder's moves, open to whoever + * hv_wire_moves_allowed() lets use them (wire_users.dm); the rest belongs to the weapon. + * + * The hooks run inside the hit: wire_cut_begin() before the parent attack(), on_cut() from the target's + * own damage signal while tg resolves it, wire_cut_end() after. + */ + +/obj/item/melee/cyberware_monowire + /// The body this swing is cutting, from wire_cut_begin() to wire_cut_end(). + var/mob/living/cutting + /// Whether that body was already dead when the swing began. + var/cut_on_corpse = FALSE + /// Whether that body was already down when the swing began. + var/cut_on_downed = FALSE + /// The zone this swing was aimed at, read when it began: the target doll, or what wire_aimed_swing() was told. + var/cut_aim + /// The next landed hit crosses, whatever the count (wire_crossing_swing()). + var/force_cross = FALSE + /// The body zone the last landed cut went into, for the lash drawn after the hit (wire_lash_at()). + var/lash_zone + /// The next lash this wire draws is its half of a crossing cut, through the middle of the chest (wire_lash_at()). + var/lash_crossing = FALSE + /// Who the last landed cut carried on into, right behind its target (wire_cleave()): the lash drawn after the hit + /// runs on to them (wire_lash_through()). + var/datum/weakref/lash_through + +/mob/living + /// Landed Widowline hits in a row with a wire out in each hand, and when the last one landed. + var/wire_cross_hits = 0 + var/wire_cross_last = 0 + +/// Opens the cut on `target`: it cuts clean, and the damage signal tells us where it landed. +/obj/item/melee/cyberware_monowire/proc/wire_cut_begin(mob/living/target, mob/living/user) + if(!isliving(target) || !isliving(user) || QDELETED(target)) + return + cutting = target + cut_on_corpse = target.stat == DEAD + cut_on_downed = hv_finisher_is_down(target) + cut_aim = user.zone_selected + // A crossing cut whose lash was never drawn (its target gone) doesn't carry over to this swing. Nor a through-cut's. + lash_crossing = FALSE + lash_through = null + ADD_TRAIT(target, TRAIT_HV_CLEAN_CUT, REF(src)) + RegisterSignal(target, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_cut), override = TRUE) + +/// Closes the cut on `target`. +/obj/item/melee/cyberware_monowire/proc/wire_cut_end(mob/living/target) + if(isliving(target)) + UnregisterSignal(target, COMSIG_MOB_AFTER_APPLY_DAMAGE) + REMOVE_TRAIT(target, TRAIT_HV_CLEAN_CUT, REF(src)) + target.hv_wire_owed_sever = null + cutting = null + cut_aim = null + +/// The swing landed: the wire's brute damage was just applied to `source`. +/obj/item/melee/cyberware_monowire/proc/on_cut(mob/living/source, damage_dealt, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item, wound_clothing) + SIGNAL_HANDLER + if(source != cutting || attacking_item != src || damagetype != BRUTE) + return + // One cut per swing: the burn rider and anything the hit sets off are not cuts. + UnregisterSignal(source, COMSIG_MOB_AFTER_APPLY_DAMAGE) + var/mob/living/user = loc + if(!isliving(user)) + return + var/obj/item/bodypart/cut_part = isbodypart(def_zone) ? def_zone : null + lash_zone = cut_part ? cut_part.body_zone : check_zone(def_zone) + var/cross = wire_count_landed(user) + var/obj/item/bodypart/severed = wire_try_sever(source, user, def_zone, damage_dealt, attack_direction || get_dir(user, source), cross) + // The lash meets the limb that comes off, whichever part the blow landed on. + if(severed) + lash_zone = severed.body_zone + if(cross) + wire_cross_lash(user, source) + if(severed) + // The cut shows when the limb slides off (wire_sever_fx.dm), and the wire comes away wet then too. + addtimer(CALLBACK(src, PROC_REF(wire_bloody), source), WIRE_CUT_DELAY) + else + wire_bloody(source, def_zone) + wire_cleave(source, user, clean = !isnull(severed) || cross) + +// ---- The crossing cut ---- + +/// How many Widowlines `user` has out. +/proc/wire_count_held(mob/living/user) + . = 0 + for(var/obj/item/melee/cyberware_monowire/wire in user.held_items) + .++ + +/// Whether the next landed hit is the crossing one. +/obj/item/melee/cyberware_monowire/proc/wire_cross_due(mob/living/user) + if(!hv_wire_moves_allowed(user) || wire_count_held(user) < 2) + return FALSE + if(force_cross) + return TRUE + return user.wire_cross_hits >= WIRE_CROSS_HITS - 1 && world.time - user.wire_cross_last <= WIRE_CROSS_WINDOW + +/// Counts a landed hit. Returns TRUE if it is the crossing one. +/obj/item/melee/cyberware_monowire/proc/wire_count_landed(mob/living/user) + if(wire_count_held(user) < 2 || !hv_wire_moves_allowed(user)) + user.wire_cross_hits = 0 + return FALSE + if(force_cross) + user.wire_cross_hits = 0 + return TRUE + if(world.time - user.wire_cross_last > WIRE_CROSS_WINDOW) + user.wire_cross_hits = 0 + user.wire_cross_hits++ + user.wire_cross_last = world.time + if(user.wire_cross_hits < WIRE_CROSS_HITS) + return FALSE + user.wire_cross_hits = 0 + return TRUE + +/// The other wire's lash in a crossing cut follows this wire's by this much. +#define WIRE_CROSS_LASH_LAG (0.1 SECONDS) + +/** + * The crossing cut: the other hand's wire lashes into the target a beat after this one's. Each line runs from its own + * hand through the middle of the target's chest and a little past it, so the two cross there (wire_lash_at()). + */ +/obj/item/melee/cyberware_monowire/proc/wire_cross_lash(mob/living/swinger, mob/living/target) + swinger.mob_light(2, 1, cross_light_color(), 0.3 SECONDS) + lash_crossing = TRUE + for(var/obj/item/melee/cyberware_monowire/other in swinger.held_items) + if(other == src) + continue + addtimer(CALLBACK(other, PROC_REF(wire_lash_at), swinger, target, lash_zone, TRUE), WIRE_CROSS_LASH_LAG) + playsound(target, 'sound/items/weapons/bladeslice.ogg', 60, TRUE) + +/obj/item/melee/cyberware_monowire/proc/cross_light_color() + return "#ff8cf8" + +/obj/item/melee/cyberware_monowire/live/cross_light_color() + return "#9fe4ff" + +// ---- Severing ---- + +/// Whether this wire may take `limb` off: an arm or leg, on a body that was alive when the swing began +/// (`corpse`), that can lose it (an Atlas frame can't), and that isn't the wielder's ally. +/obj/item/melee/cyberware_monowire/proc/wire_can_sever(obj/item/bodypart/limb, mob/living/user, corpse) + if(isnull(corpse)) + corpse = cut_on_corpse + var/mob/living/carbon/victim = limb?.owner + if(!victim || corpse || !(limb.body_zone in GLOB.hv_wire_sever_zones)) + return FALSE + if(!limb.can_dismember() || HAS_TRAIT(victim, TRAIT_GODMODE)) + return FALSE + return !cyberware_is_ally(user, victim) + +/** + * Takes the limb the cut landed on, if it was aimed there and was hurt enough before the hit, or the limb tg's + * own roll wanted off this hit. Returns the severed limb, or null. + */ +/obj/item/melee/cyberware_monowire/proc/wire_try_sever(mob/living/source, mob/living/user, def_zone, damage_dealt, spray_dir, cross) + if(!iscarbon(source)) + return null + var/mob/living/carbon/victim = source + var/obj/item/bodypart/owed = victim.hv_wire_owed_sever + victim.hv_wire_owed_sever = null + if(owed?.owner == victim && wire_can_sever(owed, user)) + return wire_sever(owed, user, spray_dir, cross) + // The aimed sever is a move of the wielder's (wire_users.dm); tg's own roll above is the weapon's. + if(!hv_wire_moves_allowed(user)) + return null + var/obj/item/bodypart/limb = isbodypart(def_zone) ? def_zone : victim.get_bodypart(check_zone(def_zone)) + if(!limb || limb.owner != victim || check_zone(cut_aim) != limb.body_zone) + return null + if(!wire_can_sever(limb, user)) + return null + var/needed = cut_on_downed ? WIRE_SEVER_AT_DOWN : WIRE_SEVER_AT + if(cross) + needed = needed * WIRE_CROSS_SEVER_SHARE / 100 + if(round((limb.get_damage() - damage_dealt) * 100) < round(limb.max_damage * needed)) + return null + return wire_sever(limb, user, spray_dir, cross) + +// Its full penetration is for its cuts. At #509's crit gates a collar, helmet or plating counts against it as +// against any blade (owner D33): the crit roll treats it as no penetration at all. +/obj/item/melee/cyberware_monowire/hv_crit_armour_pen() + return 0 + +/// Whether this wire sears what it cuts on `victim` shut. Only the Arc's charge, and only where its shock reaches. +/obj/item/melee/cyberware_monowire/proc/wire_sears(mob/living/victim) + return FALSE + +/obj/item/melee/cyberware_monowire/live/wire_sears(mob/living/victim) + return !HAS_TRAIT(victim, TRAIT_SHOCKIMMUNE) + +/** + * Takes `limb` off at the hit. The body is real at once (the arm is gone, its hand's grip with it); the picture + * lags: the limb stays drawn on until it slides off (wire_sever_fx.dm). Returns the severed limb, or null. + */ +/obj/item/melee/cyberware_monowire/proc/wire_sever(obj/item/bodypart/limb, mob/living/user, spray_dir, cross) + var/mob/living/carbon/victim = limb.owner + var/zone = limb.body_zone + var/zone_name = limb.plaintext_zone + var/seared = wire_sears(victim) + // Drawn while the limb is still on, so it can be held there. + var/obj/effect/abstract/cyberware_anim/wire_ghost/ghost = wire_ghost_limb(victim, limb, seared, spray_dir) + LAZYSET(victim.hv_stump_reveal_at, zone, world.time + WIRE_CUT_DELAY) + if(seared) + LAZYSET(victim.hv_stump_burnt, zone, TRUE) + // tg pulls the shoes off a leg that comes off; they go with the leg. + var/obj/item/shoes = (zone == BODY_ZONE_L_LEG || zone == BODY_ZONE_R_LEG) && ishuman(victim) ? victim.get_item_by_slot(ITEM_SLOT_FEET) : null + // No blood on the floor yet: it starts when the limb slides off (wire_ghost/slide()). + ADD_TRAIT(victim, TRAIT_HV_CLEAN_CUT, "wire_sever") + var/obj/item/bodypart/severed = hv_wire_take_part(limb, seared ? WOUND_BURN : WOUND_SLASH, seared ? WIRE_ARC_BLEED_MULT : 1, splatter = FALSE) + REMOVE_TRAIT(victim, TRAIT_HV_CLEAN_CUT, "wire_sever") + if(!severed) + LAZYREMOVE(victim.hv_stump_reveal_at, zone) + LAZYREMOVE(victim.hv_stump_burnt, zone) + qdel(ghost) + return null + if(seared) + severed.wire_char() + else + severed.wire_clean_look() + ghost?.hold_severed(severed) + if(shoes) + ghost?.hold_shoes(shoes) + wire_seam_fx(victim, zone, seared) + if(seared) + victim.hv_add_hit_line("[victim]'s [zone_name] drops away, the stump seared shut!", HV_LINE_HUGE, "Your [zone_name] drops away, the stump seared shut!", DEFAULT_MESSAGE_RANGE) + else + victim.hv_add_hit_line("[victim]'s [zone_name] comes away clean!", HV_LINE_HUGE, "Your [zone_name] comes away clean!", DEFAULT_MESSAGE_RANGE) + log_combat(user, victim, "severed the [zone_name] of", src, cross ? "(crossing cut)" : null) + if(zone == BODY_ZONE_L_LEG || zone == BODY_ZONE_R_LEG) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_leg_fall), victim, zone), WIRE_LEG_FALL_DELAY) + return severed + +/// Someone still on their feet without the leg in `zone` goes down: tg's knockdown, as a shove gives. +/proc/wire_leg_fall(mob/living/carbon/victim, zone) + if(QDELETED(victim) || victim.stat == DEAD || victim.body_position != STANDING_UP || victim.get_bodypart(zone)) + return + if(victim.movement_type & (FLYING | FLOATING)) + return + victim.Knockdown(WIRE_LEG_KNOCKDOWN) + +// ---- Through ---- + +/** + * The wire carries on past the target into one body at most: the first one standing on the tile right behind it, along + * the swing, that the swing's lash can run on through the target to (wire_through_line()). It is picked by that same + * line before anything is cut, so whoever the wire carries into always gets the line (wire_lash_through()), even when + * the target's own cut shows as well (`clean`: a limb coming off, a crossing cut). Nobody else beside the target is + * touched. The cut deals the wire's cleave share, cuts clean, and never takes a limb off. Its line joins the hit's message. + */ +/obj/item/melee/cyberware_monowire/proc/wire_cleave(mob/living/target, mob/living/user, clean = FALSE) + var/mob/living/behind = wire_through_target(target, user) + if(!behind) + return + var/direction = get_dir(user, target) + wire_cleave_cut(behind, user) + if(QDELETED(behind)) + return + wire_through_fx(user, target, behind, direction, clean) + lash_through = WEAKREF(behind) + target.hv_add_hit_line("The wire carries through into [behind]!", HV_LINE_BOLD) + to_chat(behind, span_userdanger("The wire carries through into you!")) + playsound(target, 'sound/items/weapons/bladeslice.ogg', 50, TRUE) + +/// Who a swing at `target` carries on into (wire_cleave()): the first living body, not the wielder's crew, on the tile +/// right behind it along the swing that a line can run to from the hand through `target`, or null. Not a garrote's blow. +/obj/item/melee/cyberware_monowire/proc/wire_through_target(mob/living/target, mob/living/user) + if(garrote_no_cleave || !isliving(target) || !isliving(user)) + return null + var/turf/from = get_turf(user) + var/turf/first = get_turf(target) + if(!from || !first || from == first) + return null + var/turf/behind_turf = get_step(first, get_dir(from, first)) + if(!behind_turf) + return null + for(var/mob/living/candidate in behind_turf) + if(candidate == user || candidate == target || candidate.stat == DEAD) + continue + if(!can_see(target, candidate, 1)) + continue + if(cyberware_is_ally(user, candidate)) + continue + if(!wire_through_line(user, target, candidate)) + continue + return candidate + return null + +/// One cut on `behind`: both halves of the wire's damage at the cleave share, one armour roll, cut clean. A limb tg's +/// wound roll wanted stays on: only the swing's own target loses limbs to the wire. +/obj/item/melee/cyberware_monowire/proc/wire_cleave_cut(mob/living/behind, mob/living/user) + // A cleave is an attack like the swing itself, so trader outposts see it. + GLOB.outpost_pvp_enforcement?.register_pvp_aggression(behind, user) + var/cleave_block = behind.run_armor_check(BODY_ZONE_CHEST, MELEE, armour_penetration = armour_penetration) + ADD_TRAIT(behind, TRAIT_HV_CLEAN_CUT, REF(src)) + behind.apply_damage(force * cleave_mult, BRUTE, BODY_ZONE_CHEST, cleave_block, wound_bonus = wound_bonus, sharpness = SHARP_EDGED, attack_direction = get_dir(user, behind)) + if(!QDELETED(behind)) + behind.apply_damage(charge_burn * cleave_mult, BURN, BODY_ZONE_CHEST, cleave_block) + if(QDELETED(behind)) + return + REMOVE_TRAIT(behind, TRAIT_HV_CLEAN_CUT, REF(src)) + behind.hv_wire_owed_sever = null + +#undef WIRE_CROSS_LASH_LAG diff --git a/voidcrew/modules/hyperviolence/wire/wire_garrote.dm b/voidcrew/modules/hyperviolence/wire/wire_garrote.dm new file mode 100644 index 00000000000..41ec6366450 --- /dev/null +++ b/voidcrew/modules/hyperviolence/wire/wire_garrote.dm @@ -0,0 +1,1415 @@ +/** + * # The garrote + * + * A Widowline wielder standing over someone lying on the floor who can't fight back (in crit, or stunned: + * lying down alone isn't enough; on their feet, or strapped into a chair or bed, never) loops the wire round + * their neck with a combat click at the head or mouth. It is #509's finisher engine (hyperviolence/finishers/) + * run by a person: a real aggressive grab, interruptible the same ways. + * + * - Wind-up (1 s): the wire loops round the neck and glints. No mark over the victim (owner D34): the loop + * and the struggle are the tell. It holds nobody, so pulling the victim clear, or them coming round, ends it. + * - Hold (1.5 s): the grab, the wire goes taut and bites, the victim thrashes. The garroter stays leaned in over + * them from the throw to the cut, and leans further in for the kill: never back. + * - Kill (0.5 s into the stage): in hard crit the head comes off (an Atlas frame keeps it); otherwise the + * throat is slit, #509's carotid crit. A sealed helmet, an armoured collar or plating that would stop + * the throat crit turns the wire, and it lands as an ordinary blow at the head instead. + * - The Widowline Arc's wire takes the head off whatever state the victim is in, unless an Atlas frame keeps it + * or a helmet, collar or plating turns the wire as above. A garroter with a wire in each hand counts as the + * Arc's if either wire is (arc_wire()). + * - Broken by #509's rules: the grab broken or pulled apart, the garroter hurt (WIRE_GARROTE_INTERRUPT + * health), stunned, cuffed or out of their wire, the victim dying first, the timeout. Also by the victim + * getting up off the floor or being strapped to something, at any point before the kill. + * + * Only wielders that hv_wire_moves_allowed() lets use the wire's moves (wire_users.dm) can start one. It + * refuses allies, starts the outpost's self-defence clock like any attack, and the wielder waits + * WIRE_GARROTE_COOLDOWN after one that got a grip, WIRE_GARROTE_MISS_COOLDOWN after one that didn't. + */ + +/// Health the garroter can lose before letting go. +#define WIRE_GARROTE_INTERRUPT 20 +/// The wind-up: the wire shoots from the hand to the neck, then winds round it. +#define WIRE_GARROTE_REACH_TIME (0.3 SECONDS) +/// The garroter leans in (the wind-up's lunge, drawn over tg's offset time) before the wire leaves the hand. +#define WIRE_GARROTE_LEAN_TIME UPDATE_TRANSFORM_ANIMATION_TIME +#define WIRE_GARROTE_WIND_TIME (0.3 SECONDS) +/// Steps the flying wire is drawn out in. +#define WIRE_GARROTE_THROW_BEATS 6 +/// Steps a strand slides in with the body in, as the hold pulls it to the garroter's feet. +#define WIRE_GARROTE_SLIDE_BEATS 8 +/// A body turned end for end at the wind-up swings round over this long, not in one frame. +#define WIRE_GARROTE_TURN_TIME (0.24 SECONDS) +/// The pool under the neck spreads from a spot to its full size over this long. +#define WIRE_GARROTE_POOL_TIME (1.8 SECONDS) +/// The head's drop from the neck to the floor. +#define WIRE_GARROTE_HEAD_FALL_TIME (0.2 SECONDS) +/// Pixels below the neck the pool goes facing away, where the dropped head lies against the stump. +#define WIRE_GARROTE_POOL_DROP_NORTH 6 +/// One beat of the victim's thrashing in the hold. +#define WIRE_GARROTE_JOLT_TIME (0.05 SECONDS) +/// A garroted body's last twitches begin this long after it has slumped back onto its tile. +#define WIRE_GARROTE_TWITCH_WAIT (0.6 SECONDS) +/// A line of wire starts this far before the middle of the pixel at its base, so that pixel is always drawn. +#define WIRE_LINE_BACK 0.5 +/// Trait source: a body held still from bobbing while wire_shake() shakes it. +#define WIRE_SHAKE_TRAIT "wire_shake" + +/mob/living + /// The garrote can be tried again from this world.time. + var/wire_garrote_ready_at = 0 + +/obj/item/melee/cyberware_monowire + /// The garrote this wire is in, if any. + var/datum/hv_finisher/garrote/garrote_running + /// TRUE while the garrote swings the wire for real, so the swing isn't taken for a new garrote. + var/garrote_blow = FALSE + /// TRUE while the garrote's own blow lands: it cuts the victim alone, never anyone behind (wire_through_target()). + var/garrote_no_cleave = FALSE + +/obj/item/melee/cyberware_monowire/pre_attack(atom/target, mob/living/user, list/modifiers, list/attack_modifiers) + . = ..() + if(. || garrote_blow) + return + // Busy round someone's neck. + if(garrote_running) + return TRUE + if(wire_try_garrote(target, user)) + return TRUE + +/// Someone the wire can be looped round: lying on the floor (wire_garrote_on_floor()) and unable to fight it off, in +/// crit or stunned. Lying down alone doesn't count, and neither does a stun that leaves them on their feet. +/proc/wire_garrote_helpless(mob/living/victim) + return wire_garrote_on_floor(victim) && (victim.stat >= SOFT_CRIT || HAS_TRAIT(victim, TRAIT_INCAPACITATED)) + +/// Lying on the floor, not strapped into a chair or bed: where a garrote's victim has to stay from the first loop to the cut. +/proc/wire_garrote_on_floor(mob/living/victim) + return victim.body_position == LYING_DOWN && !victim.buckled + +/// Starts a garrote on `target` if this click asks for one (combat mode, the head or mouth on the target doll) +/// and it can begin. Returns TRUE if it began. +/obj/item/melee/cyberware_monowire/proc/wire_try_garrote(atom/target, mob/living/user) + if(!isliving(user) || !user.combat_mode) + return FALSE + if(user.zone_selected != BODY_ZONE_HEAD && user.zone_selected != BODY_ZONE_PRECISE_MOUTH) + return FALSE + return wire_start_garrote(user, target) + +/** + * The garrote itself, with no click behind it: the entry point for anything that isn't a mouse (an NPC's AI, + * later). Same rules as a player's: the wielder's moves gate (wire_users.dm), no pacifists, the wait between + * tries, and the finisher's own can_start(). Returns TRUE if it began. + */ +/obj/item/melee/cyberware_monowire/proc/wire_start_garrote(mob/living/user, mob/living/target) + if(!iscarbon(target) || !iscarbon(user) || HAS_TRAIT(user, TRAIT_PACIFISM) || garrote_running) + return FALSE + if(!hv_wire_moves_allowed(user)) + return FALSE + if(world.time < user.wire_garrote_ready_at) + return FALSE + var/datum/hv_finisher/garrote/garrote = new(user, target, CALLBACK(src, PROC_REF(garrote_ended))) + garrote.wire = src + if(!garrote.start()) + qdel(garrote) + return FALSE + garrote_running = garrote + return TRUE + +/// The garrote ended, however it ended. +/obj/item/melee/cyberware_monowire/proc/garrote_ended(datum/hv_finisher/garrote/garrote, result) + if(garrote_running == garrote) + garrote_running = null + // Not from inside its own stop(): the engine still has a line or two to run. + QDEL_IN(garrote, 1) + +// ---- The finisher ---- + +/datum/hv_finisher/garrote + name = "garrote" + interrupt_damage = WIRE_GARROTE_INTERRUPT + zone_preference = list(BODY_ZONE_HEAD) + stages = list( + /datum/hv_finisher_stage/windup/garrote, + /datum/hv_finisher_stage/hold/garrote, + /datum/hv_finisher_stage/kill/garrote, + /datum/hv_finisher_stage/recover, + ) + /// The wire round the neck + var/obj/item/melee/cyberware_monowire/wire + /// The loop drawn round the neck: its far side, behind the neck, and its near side + var/list/loop_refs + /// The wire in flight from the hand to the neck: one straight line. It lies there, slack, until the hold pulls it taut. + var/list/reach_refs + /// Timers of the wind-up's beats + var/list/windup_timers + /// The strands of wire from the garroter's hands to the neck + var/list/strand_refs + /// The far side of the loop, drawn among the victim's own overlays under the body + var/mutable_appearance/loop_back + /// The victim's layer before the hold drew them over a garroter facing the viewer, or null + var/victim_old_layer + /// Timer of the victim's struggle in the hold + var/struggle_timer + /// Where the two were drawn as the grip was taken, before the hold drew them into place: + /// list(garroter pixel_x, pixel_y, victim pixel_x, pixel_y) + var/list/pull_from + /// TRUE from the hold's strands until the wire comes off the neck: no wire is drawn hanging in the garroter's hands + var/hands_hidden = FALSE + /// Other Widowlines the garroter holds, hidden from their hands meanwhile + var/list/off_hand_refs + +/datum/hv_finisher/garrote/Destroy() + . = ..() + clear_wire_fx() + wire = null + +/** + * The finisher's own victim check (hv_finisher_valid_victim()) refuses anyone who shares a faction with the + * attacker, which is every player with every other. This is the same check without that: alive, helpless, + * on the floor beside the garroter with a head, not strapped down, not already being finished, not an ally. + */ +/datum/hv_finisher/garrote/can_start() + if(QDELETED(user) || user.stat != CONSCIOUS || HAS_TRAIT(user, TRAIT_INCAPACITATED) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED)) + return FALSE + if(!hv_wire_moves_allowed(user)) + return FALSE + if(QDELETED(wire) || !user.is_holding(wire)) + return FALSE + if(!iscarbon(victim) || QDELETED(victim) || victim == user || victim.stat == DEAD || HAS_TRAIT(victim, TRAIT_GODMODE)) + return FALSE + if(!wire_garrote_helpless(victim) || victim.has_status_effect(/datum/status_effect/hv_finisher_hold)) + return FALSE + if(!victim.get_bodypart(BODY_ZONE_HEAD)) + return FALSE + if(victim.buckled || !isturf(victim.loc) || !isturf(user.loc) || victim.z != user.z) + return FALSE + if(cyberware_is_ally(user, victim)) + return FALSE + return get_dist(user, victim) <= 1 && user.Adjacent(victim) + +/datum/hv_finisher/garrote/start() + . = ..() + if(!.) + return + user.wire_garrote_ready_at = world.time + WIRE_GARROTE_MISS_COOLDOWN + // A garrote is an attack: the trader outpost's guards see it from the first loop. + GLOB.outpost_pvp_enforcement?.register_pvp_aggression(victim, user) + cyberware_camo_drop(user) + +/datum/hv_finisher/garrote/take_grip() + if(!gripped && !QDELETED(user) && !QDELETED(victim)) + pull_from = drawn_offsets() + . = ..() + if(. && !QDELETED(user)) + user.wire_garrote_ready_at = world.time + WIRE_GARROTE_COOLDOWN + +/datum/hv_finisher/garrote/safety_check() + . = ..() + if(. || completed) + return + if(QDELETED(wire) || !user.is_holding(wire)) + return HV_FINISHER_ATTACKER_DOWN + // Up off the floor or strapped to something, they're out of it, held or not: the grab alone doesn't keep them down. + if(!wire_garrote_on_floor(victim)) + return HV_FINISHER_LOST_GRIP + // The wind-up holds nobody: come round enough to fight it off, they're out of it. + if(!gripped && !wire_garrote_helpless(victim)) + return HV_FINISHER_LOST_GRIP + +/datum/hv_finisher/garrote/stop(reason) + clear_wire_fx() + restore_victim_layer() + return ..() + +/** + * Letting go puts the body back all at once: the grab's pull, the hold's drag and the layer it was drawn on go + * together, so nothing moves again when the finisher ends. The kill lets go itself (let_go_at_kill()); this is for + * any other way the grip ends. + */ +/datum/hv_finisher/garrote/release_grip() + . = ..() + if(!QDELETED(victim)) + victim.remove_offsets(HV_FINISHER_OFFSET) + restore_victim_layer() + +/** + * The kill lets the body go as the wire goes through: the grab's pull and the hold's drag come off together, and + * it slumps back onto its own tile in one short move. The garroter straightens out of the lean over the same move, + * here rather than as the finisher ends, so neither of them moves again after it. Returns how long the move takes: + * the head, the pool and anything else laid out after the kill wait for it and go where the body rests. + */ +/datum/hv_finisher/garrote/proc/let_go_at_kill() + if(QDELETED(victim)) + return 0 + var/old_x = victim.pixel_x + var/old_y = victim.pixel_y + victim.remove_offsets(HV_FINISHER_OFFSET, animate = FALSE) + // Taken off here rather than by tg's let-go, which would slide it back on its own clock. + if(user?.pulling == victim) + victim.remove_offsets(GRABBING_TRAIT, animate = FALSE) + // A body drawn up over a garroter facing the viewer stays over their legs until it has dropped clear. + var/drawn_up_from = victim_old_layer + victim_old_layer = null + release_grip() + var/new_x = victim.pixel_x + var/new_y = victim.pixel_y + var/settle_time = 0 + if(new_x != old_x || new_y != old_y) + settle_time = clamp(round(sqrt((new_x - old_x) ** 2 + (new_y - old_y) ** 2) / 6, 0.5), 2, 4) + victim.pixel_x = old_x + victim.pixel_y = old_y + // Parallel, like tg's own offset moves, so the turn of a body falling or a death shudder runs on beside it. + animate(victim, pixel_x = new_x, pixel_y = new_y, time = settle_time, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + if(!isnull(drawn_up_from)) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_garrote_lay_back), victim, drawn_up_from), settle_time) + // The lean off now: the recover stage's pose and the finisher's end then find nothing left to move. + if(!QDELETED(user)) + var/user_old_x = user.pixel_x + var/user_old_y = user.pixel_y + user.add_offsets(HV_FINISHER_OFFSET, null, 0, 0, animate = FALSE) + if(user.pixel_x != user_old_x || user.pixel_y != user_old_y) + var/user_new_x = user.pixel_x + var/user_new_y = user.pixel_y + user.pixel_x = user_old_x + user.pixel_y = user_old_y + animate(user, pixel_x = user_new_x, pixel_y = user_new_y, time = max(settle_time, 2), easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + return settle_time + +/// A body the garrote drew up over its garroter goes back to `old_layer`, unless something else has changed it since. +/proc/wire_garrote_lay_back(mob/living/body, old_layer) + if(!QDELETED(body) && body.layer == WIRE_PULLED_LAYER) + body.layer = old_layer + +/datum/hv_finisher/garrote/proc/restore_victim_layer() + if(isnull(victim_old_layer)) + return + if(!QDELETED(victim) && victim.layer == WIRE_PULLED_LAYER) + victim.layer = victim_old_layer + victim_old_layer = null + +/// The wire's blow, never the heaviest thing in the garroter's hands. +/datum/hv_finisher/garrote/real_blow(zone, extra_wound_bonus = 0) + if(QDELETED(user) || QDELETED(victim) || QDELETED(wire) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || !user.is_holding(wire)) + return FALSE + var/mob/living/carbon/attacker = user + if(attacker.get_active_held_item() != wire) + var/index = attacker.get_held_index_of_item(wire) + if(!index) + return FALSE + attacker.swap_hand(index, silent = TRUE) + user.zone_selected = zone + user.face_atom(victim) + var/old_combat_mode = user.combat_mode + user.set_combat_mode(TRUE) + var/old_wound_bonus = wire.wound_bonus + wire.wound_bonus += extra_wound_bonus + wire.garrote_blow = TRUE + wire.garrote_no_cleave = TRUE + wire.melee_attack_chain(user, victim) + if(!QDELETED(wire)) + wire.garrote_blow = FALSE + wire.garrote_no_cleave = FALSE + wire.wound_bonus = old_wound_bonus + if(!QDELETED(user)) + user.set_combat_mode(old_combat_mode) + user.changeNext_move(CLICK_CD_MELEE) + return TRUE + +/** + * No mark over the victim (owner D34). The garroter leans in (the stage's lunge) and the wire shoots straight from the + * hand to the neck. Once it is there it drags the body round head first to them, if it lay the other way, and winds + * round the neck; then it hangs there loose, glinting, while they struggle. + */ +/datum/hv_finisher/garrote/on_windup(duration) + // Thrown once the lean has carried the hand to where the throw starts. + throw_wire(WIRE_GARROTE_LEAN_TIME) + // The wire leaves its hand: from then on it is drawn in flight and round the neck, not hanging there. A wire in the + // other hand hangs on until the hold runs a strand from that hand too (draw_wire()). + LAZYADD(windup_timers, addtimer(CALLBACK(src, PROC_REF(hide_thrown_wire)), WIRE_GARROTE_LEAN_TIME, TIMER_STOPPABLE | TIMER_DELETE_ME)) + LAZYADD(windup_timers, addtimer(CALLBACK(src, PROC_REF(wire_arrives), duration - WIRE_GARROTE_LEAN_TIME - WIRE_GARROTE_REACH_TIME), WIRE_GARROTE_LEAN_TIME + WIRE_GARROTE_REACH_TIME, TIMER_STOPPABLE | TIMER_DELETE_ME)) + +/** + * The throw: the thrown wire is drawn in flight and then round the neck, so its hand doesn't draw it hanging there. Only + * that hand's: a second Widowline in the other hand hangs there through the throw and the wind-up, until the hold runs a + * strand from that hand too (hide_hands()). show_hands() puts it back, however the garrote ends. + */ +/datum/hv_finisher/garrote/proc/hide_thrown_wire() + if(hands_hidden || !running || QDELETED(user) || QDELETED(wire) || !user.is_holding(wire)) + return + hide_held_wire(wire) + +/** + * From the hold on, a strand runs from each hand to the neck, so neither hand draws a wire hanging in it: not the one + * thrown, nor a second Widowline in the other hand, held now or taken up while the garrote lasts. Hidden as the strands + * go up (draw_wire()), so a wire never shows in a hand and as a strand from it at once, nor in neither. show_hands() + * puts them back, however the garrote ends. + */ +/datum/hv_finisher/garrote/proc/hide_hands() + if(hands_hidden || !running || QDELETED(user)) + return + hands_hidden = TRUE + for(var/obj/item/melee/cyberware_monowire/held in user.held_items) + hide_held_wire(held) + RegisterSignal(user, COMSIG_MOB_EQUIPPED_ITEM, PROC_REF(on_user_equipped)) + +/datum/hv_finisher/garrote/proc/hide_held_wire(obj/item/melee/cyberware_monowire/held) + // The timeout only backs show_hands() up. Its spool stays in the hand: the wire runs out of it. + held.hide_inhand_for(longest_duration(), spool = TRUE) + if(held != wire) + LAZYOR(off_hand_refs, WEAKREF(held)) + +/// A Widowline swung out into a hand while the strands run isn't drawn there either: a strand runs from that hand. +/datum/hv_finisher/garrote/proc/on_user_equipped(mob/living/source, obj/item/equipped, slot) + SIGNAL_HANDLER + if((slot & ITEM_SLOT_HANDS) && istype(equipped, /obj/item/melee/cyberware_monowire)) + hide_held_wire(equipped) + +/// The wire is off the neck: every wire the garroter holds is drawn in the hand again. +/datum/hv_finisher/garrote/proc/show_hands() + if(hands_hidden) + hands_hidden = FALSE + if(user) + UnregisterSignal(user, COMSIG_MOB_EQUIPPED_ITEM) + if(!QDELETED(wire)) + wire.show_inhand() + for(var/datum/weakref/held_ref as anything in off_hand_refs) + var/obj/item/melee/cyberware_monowire/held = held_ref.resolve() + if(!QDELETED(held)) + held.show_inhand() + off_hand_refs = null + +/// TRUE while the garrote is still in its wind-up, the wire loose round the neck. +/datum/hv_finisher/garrote/proc/winding_up() + return running && !QDELETED(user) && !QDELETED(victim) && istype(current_stage, /datum/hv_finisher_stage/windup) + +/** + * The thrown wire reaches the neck: it drags the body round head first to the garroter, if it lay the other way, and + * then winds round the neck. `rest` is what is left of the wind-up. + */ +/datum/hv_finisher/garrote/proc/wire_arrives(rest) + if(!winding_up()) + return + var/turn_time = face_victim_in() + if(!turn_time) + wind_loop(rest) + return + LAZYADD(windup_timers, addtimer(CALLBACK(src, PROC_REF(wind_loop), rest - turn_time), turn_time, TIMER_STOPPABLE | TIMER_DELETE_ME)) + +/** + * The pixel the wire leaves the garroter's `side` hand from (wire_hand_point(), wire_held.dm): the one the held wire's + * spool lights for each facing, by its lower left corner in pixels from the middle of the tile. A line of wire is + * drawn from the middle of this pixel. Facing the viewer both hands show at the sides. Facing away they show at the + * sides too, but the wire runs forward from them, through the garroter's body, so both count as behind it; in profile + * the far hand does. list(x, y, behind) + */ +/datum/hv_finisher/garrote/proc/hand_point(side) + return wire_hand_point(user, side) + +/** + * Where a line of wire from the garroter's `side` hand is drawn from: the hand (hand_point()), except facing away. + * Facing away it runs from the hands, hidden in front of the garroter, to the neck beyond their head; drawn from the + * hands it showed through the gaps between head and shoulders as a stray pixel each. It is drawn from behind the head + * instead, on the same line, so it shows only once it clears the head. list(x, y, behind) + */ +/datum/hv_finisher/garrote/proc/line_origin(side) + if(user.dir == NORTH) + return side == "left" ? list(-4, 8, TRUE) : list(2, 8, TRUE) + return hand_point(side) + +/** + * The world layer for wire leaving a hand. Wire from a hand in front goes over both bodies. Wire from a hand behind + * the garroter goes under them, so their torso, back and head hide it: + * - Facing away (both hands) it goes over the one lying beyond them, so it shows from where it clears the garroter to + * the neck. + * - In profile (the far hand) it goes round the back of the neck: under the one lying there too, so it shows between + * the hand and the head, and their head and neck hide the rest, while the near hand's runs over them. + */ +/datum/hv_finisher/garrote/proc/strand_layer(behind) + if(!behind) + return wire_line_layer(FALSE) + return wire_behind_neck(behind) ? BELOW_MOB_LAYER : WIRE_BETWEEN_LAYER + +/// TRUE for wire from a hand `behind` the garroter that goes round the back of the neck, under the body lying there: +/// the far hand's, in profile. +/datum/hv_finisher/garrote/proc/wire_behind_neck(behind) + return behind && (user.dir & (EAST | WEST)) + +/** + * A new line of wire from a hand `behind` or not. It goes on the garroter's turf, except wire round the back of the + * neck (wire_behind_neck()) with the body on the row behind the garroter's (lying a tile up and to the side): that goes + * on the body's row, since the map sorts a row in front over a row behind whatever their layers. pixel_z draws it back + * where it would be on the garroter's turf, so its pixel_x and pixel_y count from there as ever. + */ +/datum/hv_finisher/garrote/proc/new_line(behind) + var/turf/from = get_turf(user) + if(!from) + return null + if(wire_behind_neck(behind) && !QDELETED(victim) && victim.y > user.y) + from = locate(user.x, victim.y, user.z) || from + var/obj/effect/abstract/wire_reach/line = new(from) + line.pixel_z = (user.y - from.y) * ICON_SIZE_Y + return line + +/// "left" or "right": the hand the wire is in. +/datum/hv_finisher/garrote/proc/wire_side() + return wire?.held_side(user) || "right" + +/** + * The wire in flight: thrown from the hand, its end flies straight to the neck, the line paying out behind it. One + * sprite, stretched and turned every beat, so the line stays as thin as the hanging filament. It lies there, slack, + * until the hold. Unseen for `delay` first. + */ +/datum/hv_finisher/garrote/proc/throw_wire(delay = 0) + clear_reach() + var/turf/from = get_turf(user) + if(!from || QDELETED(victim)) + return + var/side = wire_side() + var/list/hand = line_origin(side) + var/hand_x = user.pixel_x + hand[1] + var/hand_y = user.pixel_y + hand[2] + // Thrown at the pixel of the loop this hand's strand will meet, so it lands on the loop as it winds on. + var/list/meet = loop_point(side) + var/span_x = meet[1] - (hand_x + 0.5) + var/span_y = meet[2] - (hand_y + 0.5) + var/step = WIRE_GARROTE_REACH_TIME / WIRE_GARROTE_THROW_BEATS + var/obj/effect/abstract/wire_reach/line = new_line(hand[3]) + line.icon_state = "wire_reach[wire_suffix()]" + // In flight, wire from a hand behind the garroter passes over the body lying there and under the garroter. In profile + // it goes round the back of the neck once it winds on (land_reach()). + line.layer = hand[3] ? WIRE_BETWEEN_LAYER : strand_layer(FALSE) + line.add_overlay(emissive_appearance(line.icon, line.icon_state, line)) + line.pixel_x = hand_x + line.pixel_y = hand_y + // A pixel of wire leaving the hand toward the neck. + line.transform = wire_throw_shape(span_x, span_y, 1) + if(delay) + line.alpha = 0 + animate(line, alpha = 0, time = delay) + for(var/beat in 1 to WIRE_GARROTE_THROW_BEATS) + var/flown = beat / WIRE_GARROTE_THROW_BEATS + var/matrix/shape = wire_throw_shape(span_x, span_y, flown * wire_line_length(span_x, span_y)) + if(beat == 1 && !delay) + animate(line, transform = shape, time = step) + else + animate(alpha = 255, transform = shape, time = step) + LAZYADD(reach_refs, WEAKREF(line)) + // Never outlives the garrote, whatever ends it. + QDEL_IN(line, longest_duration()) + +/datum/hv_finisher/garrote/proc/clear_reach() + for(var/datum/weakref/line_ref as anything in reach_refs) + qdel(line_ref.resolve()) + reach_refs = null + +/** + * The garrote's thrown wire (wire_reach, half a tile of line running up a half pixel left of the middle) drawn from + * the middle of the pixel at its base to the middle of the pixel (`span_x`, `span_y`) away and half a pixel on, so it + * covers the pixel it lands on. `length` draws only that much of it along the same bearing. It starts half a pixel + * before the middle of its base pixel too: a line that starts on the middle itself draws that pixel on some bearings + * and not on others, and the wire would leave the hand a pixel out. + */ +/proc/wire_throw_shape(span_x, span_y, length) + var/matrix/shape = matrix() + shape.Translate(0.5, 0) + shape.Scale(1, (max(isnull(length) ? wire_line_length(span_x, span_y) : length, 1) + WIRE_LINE_BACK) / 16) + shape.Translate(0, -WIRE_LINE_BACK) + shape.Turn(arctan(span_y, span_x)) + shape.Translate(0.5, 0.5) + return shape + +/// How long a line of wire from the middle of one pixel to the middle of another (`span_x`, `span_y`) away is drawn: +/// half a pixel more, to the far side of the pixel it ends on. +/proc/wire_line_length(span_x, span_y) + return sqrt(span_x ** 2 + span_y ** 2) + 0.5 + +/** + * The thrown wire's end put on the loop where the neck is drawn as it lands. It was aimed where the neck was drawn as + * it left the hand, and anything that moves the body in flight leaves it short of the loop (recorded once, two pixels + * short facing the viewer). Wound on, it is drawn as the hold's strand from its hand will be: from the far hand in + * profile, round the back of the neck, under the body it flew over. + */ +/datum/hv_finisher/garrote/proc/land_reach() + var/datum/weakref/line_ref = LAZYACCESS(reach_refs, 1) + var/obj/effect/abstract/wire_reach/line = line_ref?.resolve() + if(!line) + return + // The throw's beats end here anyway; ended now, it is drawn as they leave it (whole, lit) before it is moved. + animate(line) + line.transform = reach_to_neck(line, victim.transform) + line.layer = strand_layer(line_origin(wire_side())[3]) + +/// The end of the throw: the wire winds round the neck and is held there, loose, for the rest of the wind-up (`rest`). +/datum/hv_finisher/garrote/proc/wind_loop(rest) + if(!winding_up()) + return + land_reach() + show_loop("draw") + // Wound on, it hangs loose until the hold pulls it tight. With no time left for that, the hold takes it from here. + if(rest > WIRE_GARROTE_WIND_TIME) + LAZYADD(windup_timers, addtimer(CALLBACK(src, PROC_REF(show_loop), "loop"), WIRE_GARROTE_WIND_TIME, TIMER_STOPPABLE | TIMER_DELETE_ME)) + var/obj/effect/abstract/cyberware_anim/glint = cyberware_anim_play(user, WIRE_GORE_ICON, "wire_glint[wire_suffix()]", WIRE_FX_LAYER, 0.3 SECONDS, glow = TRUE) + if(glint) + // On the hand's pixel: the glint's picture is centred on the pixel down and right of its icon's middle. + var/list/hand = hand_point(wire_side()) + glint.pixel_x = hand[1] + glint.pixel_y = hand[2] + 1 + +/// The wire in flight. Nothing to click. +/obj/effect/abstract/wire_reach + name = "wire" + icon = WIRE_GORE_ICON + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + appearance_flags = PIXEL_SCALE | TILE_BOUND + /// A taut strand's far end, on the neck, from its base in the hand: list(x, y) pixels. Null for any other line. + var/list/span + /// "left" or "right": the hand a taut strand runs from. Null for any other line. + var/hand_side + +/** + * A taut strand on a neck that thrashes: its far end jolts by each of `jolts` (wire_jolts()) in turn, a beat apart, + * as the body does, while its base stays in the hand. Linear, so the end runs straight to each spot, as the body does. + */ +/obj/effect/abstract/wire_reach/proc/jolt_end(list/jolts) + if(!span) + return + var/first = TRUE + for(var/list/jolt as anything in jolts) + var/matrix/shape = wire_strand_shape(span[1] + jolt[1], span[2] + jolt[2]) + if(first) + animate(src, transform = shape, time = WIRE_GARROTE_JOLT_TIME, flags = ANIMATION_LINEAR_TRANSFORM) + first = FALSE + else + animate(transform = shape, time = WIRE_GARROTE_JOLT_TIME, flags = ANIMATION_LINEAR_TRANSFORM) + +/// "" for the plain wire's colours, "_live" for the Arc's. +/datum/hv_finisher/garrote/proc/wire_suffix() + return istype(wire, /obj/item/melee/cyberware_monowire/live) ? "_live" : "" + +/** + * A body lying beside the garroter is turned head first to them, as tg turns a body dragged sideways: the wire on its + * neck drags it round. tg turns one lying the other way round in a single frame; this swings it round instead, through + * head toward the viewer, and the thrown wire's end stays on the neck as it goes. Returns how long the turn takes, 0 if + * it already lay that way. + */ +/datum/hv_finisher/garrote/proc/face_victim_in() + if(QDELETED(victim) || victim.body_position != LYING_DOWN) + return 0 + var/toward = get_dir(victim, user) + var/new_angle + if(toward & EAST) + new_angle = LYING_ANGLE_EAST + else if(toward & WEST) + new_angle = LYING_ANGLE_WEST + if(isnull(new_angle) || victim.lying_angle == new_angle) + return 0 + var/end_for_end = REVERSE_ANGLE(new_angle) == victim.lying_angle + var/matrix/before = matrix(victim.transform) + victim.set_lying_angle(new_angle) + var/matrix/after = matrix(victim.transform) + var/datum/weakref/line_ref = LAZYACCESS(reach_refs, 1) + var/obj/effect/abstract/wire_reach/line = line_ref?.resolve() + if(!end_for_end) + // tg's own turn. + if(line) + animate(line, transform = reach_to_neck(line, after), time = UPDATE_TRANSFORM_ANIMATION_TIME) + return UPDATE_TRANSFORM_ANIMATION_TIME + var/matrix/halfway = matrix(before) + halfway.Turn(new_angle == LYING_ANGLE_WEST ? 90 : -90) + victim.transform = before + animate(victim, transform = halfway, time = WIRE_GARROTE_TURN_TIME / 2, easing = SINE_EASING | EASE_IN) + animate(transform = after, time = WIRE_GARROTE_TURN_TIME / 2, easing = SINE_EASING | EASE_OUT) + if(line) + animate(line, transform = reach_to_neck(line, halfway), time = WIRE_GARROTE_TURN_TIME / 2, easing = SINE_EASING | EASE_IN) + animate(transform = reach_to_neck(line, after), time = WIRE_GARROTE_TURN_TIME / 2, easing = SINE_EASING | EASE_OUT) + return WIRE_GARROTE_TURN_TIME + +/// The thrown wire `line` drawn from where it left the hand to the loop on the neck of the victim turned to `body_shape`. +/datum/hv_finisher/garrote/proc/reach_to_neck(obj/effect/abstract/wire_reach/line, matrix/body_shape) + var/list/meet = loop_point(wire_side(), body_shape) + return wire_throw_shape(meet[1] - (line.pixel_x + 0.5), meet[2] - (line.pixel_y + 0.5)) + +/** + * Where the strand from the garroter's `side` hand meets the loop, as the loop is drawn now (or with the body turned + * to `shape`): the middle of one of the near half's pixels, in pixels from the middle of the garroter's tile. + * list(x, y) + * + * On a body lying down the loop shows as a short line up and down across the neck. In profile the near hand's strand + * meets its lower end over the head, and the far hand's its upper end round the back of the neck, the head hiding it + * (strand_layer()), so the two show as two strands. Facing the viewer both meet its top, the end toward the garroter; + * facing away both meet it at the neck, since its lower end is hidden behind the garroter's head. On a body on its feet + * (none is garroted: only for one getting up before the garrote lets go) the loop lies across the neck: facing toward or + * away each strand meets the end on its own side, and in profile the near one the end toward the garroter, the far one + * the middle. + */ +/datum/hv_finisher/garrote/proc/loop_point(side, matrix/shape) + if(!shape) + shape = victim.transform + var/list/drawn = list() + for(var/list/spot as anything in wire_loop_line(victim.dir)) + drawn += list(wire_pixel_drawn(shape, spot[1], spot[2])) + var/list/first = drawn[1] + var/list/middle = drawn[2] + var/list/last = drawn[3] + var/behind = hand_point(side)[3] + var/list/meet + if(abs(first[2] - last[2]) > abs(first[1] - last[1])) + var/list/upper = first[2] > last[2] ? first : last + var/list/lower = upper == first ? last : first + switch(user.dir) + if(NORTH) + meet = middle + if(SOUTH) + meet = upper + else + meet = behind ? upper : lower + else + var/list/leftmost = first[1] < last[1] ? first : last + var/list/rightmost = leftmost == first ? last : first + if(user.dir & (EAST | WEST)) + meet = behind ? middle : ((user.dir & EAST) ? leftmost : rightmost) + else + meet = hand_point(side)[1] < 0 ? leftmost : rightmost + return list(meet[1] + victim.pixel_x + (victim.x - user.x) * ICON_SIZE_X, meet[2] + victim.pixel_y + (victim.y - user.y) * ICON_SIZE_Y) + +/** + * The loop's near half as wire_gore.dmi draws it (garrote_tight_front): a line of wire one pixel high and seven long + * across the neck, a pixel below where the jaw meets it, on the row the slit throat is drawn on. The middles of its + * end pixels and of its middle one, in pixels from the middle of the icon, for the body facing `facing` (its picture + * facing east is a pixel to the right). list(list(x, y) first, middle, last) + */ +/proc/wire_loop_line(facing) + var/left = facing == EAST ? -2.5 : -3.5 + return list(list(left, 5.5), list(left + 3, 5.5), list(left + 6, 5.5)) + +/** + * The middle of the pixel that a picture's pixel, its middle (`x`, `y`) from the middle of the icon, is drawn on once + * `shape` turns and moves it, from the same middle. list(x, y) + * Rounded down, not to the nearest: a quarter turn leaves the middle of a pixel on the middle of another, give or take + * the rounding in the turn. + */ +/proc/wire_pixel_drawn(matrix/shape, x, y) + return list(round(shape.a * x + shape.b * y + shape.c) + 0.5, round(shape.d * x + shape.e * y + shape.f) + 0.5) + +/// Where the victim's neck is drawn, in pixels from the middle of its tile before its own offsets: 6 px above the +/// middle of an upright body, turned with a lying one (or as `shape`, a transform, would turn it). list(x, y) +/datum/hv_finisher/garrote/proc/neck_offset(matrix/shape) + if(!shape) + shape = victim.transform + return list(round(shape.b * 6 + shape.c), round(shape.e * 6 + shape.f)) + +/** + * Where the neck should be in the hold, in pixels from the middle of the garroter's tile. list(x, y) + * - In profile the body stays on the floor: drawn in until its head lies just clear of the garroter's feet, never + * lifted, so the wire runs taut down from the hands to the neck. + * - Facing away the neck is beyond the garroter, drawn just over their head, not hidden behind it. + * - Facing the viewer the body is drawn up against the garroter's shins, the neck between their feet, under the + * hands held apart. + */ +/datum/hv_finisher/garrote/proc/hold_point() + if(user.dir & (EAST | WEST)) + return list((user.dir & EAST ? 17 : -17) + user.pixel_x, neck_point()[2]) + if(user.dir & NORTH) + return list(user.pixel_x, 16 + user.pixel_y) + return list(user.pixel_x, -13 + user.pixel_y) + +/// Where the neck is drawn now (or with the body turned to `shape`), in pixels from the middle of the garroter's tile. +/// list(x, y) +/datum/hv_finisher/garrote/proc/neck_point(matrix/shape) + var/list/neck = neck_offset(shape) + return list(neck[1] + victim.pixel_x + (victim.x - user.x) * ICON_SIZE_X, neck[2] + victim.pixel_y + (victim.y - user.y) * ICON_SIZE_Y) + +/// Where the neck is drawn now, in pixels from the middle of the victim's own tile. list(x, y) +/datum/hv_finisher/garrote/proc/neck_on_tile() + var/list/neck = neck_offset() + return list(neck[1] + victim.pixel_x, neck[2] + victim.pixel_y) + +/** + * The hold draws the neck to hold_point(). The grab already pulls the body 12 px toward the garroter (and turns a + * body dragged sideways head first); this corrects it from there, either way. Drawn only, and taken off with the + * grab's pull at the kill (let_go_at_kill()). + */ +/datum/hv_finisher/garrote/proc/pull_close() + if(QDELETED(user) || QDELETED(victim)) + return + var/list/neck = neck_point() + var/list/target = hold_point() + victim.add_offsets(HV_FINISHER_OFFSET, x_add = clamp(target[1] - neck[1], -12, 12), y_add = clamp(target[2] - neck[2], -12, 12), animate = FALSE) + slide_in() + // Facing the viewer, the body is drawn up in front of the garroter's legs, not behind them. + if(user.dir == SOUTH && victim.y < user.y && isnull(victim_old_layer)) + victim_old_layer = victim.layer + victim.layer = WIRE_PULLED_LAYER + +/** + * The body slides in as one move, from where it was drawn before the grab (pull_from) to where the grab's pull and the + * hold's drag put it, over the time the strands slide in with it (draw_wire()). tg slides the grab's pull (passive, + * then aggressive) and the drag as separate moves on top of each other, and recorded, the body fell a pixel behind + * the strands' ends on the neck for the first frames of the longest pull. + */ +/datum/hv_finisher/garrote/proc/slide_in() + if(!pull_from) + return + var/to_x = victim.pixel_x + var/to_y = victim.pixel_y + if(to_x == pull_from[3] && to_y == pull_from[4]) + return + // Ends tg's own slides, so they don't run on top of this one. + animate(victim) + // No floating bob meanwhile, as tg's own offset moves hold it off. + ADD_TRAIT(victim, TRAIT_NO_FLOATING_ANIM, WIRE_SHAKE_TRAIT) + addtimer(TRAIT_CALLBACK_REMOVE(victim, TRAIT_NO_FLOATING_ANIM, WIRE_SHAKE_TRAIT), UPDATE_TRANSFORM_ANIMATION_TIME, TIMER_UNIQUE | TIMER_OVERRIDE) + victim.pixel_x = pull_from[3] + victim.pixel_y = pull_from[4] + animate(victim, pixel_x = to_x, pixel_y = to_y, time = UPDATE_TRANSFORM_ANIMATION_TIME) + +/// The victim thrashes in the wire from `delay` on, for `duration`. +/datum/hv_finisher/garrote/proc/struggle(delay, duration) + if(struggle_timer) + deltimer(struggle_timer) + struggle_timer = addtimer(CALLBACK(src, PROC_REF(thrash), duration), delay, TIMER_STOPPABLE | TIMER_DELETE_ME) + +/** + * The victim thrashes in the wire for `duration`: the body jolts round wherever it is drawn now, and the ends of the + * strands on its neck jolt with it, beat for beat, so the wire stays on the neck. The hands' ends stay put. + */ +/datum/hv_finisher/garrote/proc/thrash(duration) + struggle_timer = null + if(QDELETED(victim) || !running) + return + var/list/jolts = wire_jolts(2, 1, duration) + wire_shake(victim, jolts = jolts) + for(var/datum/weakref/strand_ref as anything in strand_refs) + var/obj/effect/abstract/wire_reach/strand = strand_ref.resolve() + strand?.jolt_end(jolts) + +/// A shake's beats, one each WIRE_GARROTE_JOLT_TIME for `duration`: list(x, y) offsets of up to `shift_x` and `shift_y` +/// pixels from where the shaken thing is drawn, the last one back where it was. +/proc/wire_jolts(shift_x, shift_y, duration) + . = list() + for(var/i in 1 to max(round(duration / WIRE_GARROTE_JOLT_TIME) - 1, 2)) + . += list(list(rand(-shift_x, shift_x), rand(-shift_y, shift_y))) + . += list(list(0, 0)) + +/** + * tg's Shake() without its slip (its first beat sets pixel_y from pixel_x, a jump on a body drawn off its tile's + * middle): jitters `body` up to `shift_x` and `shift_y` pixels round where it is drawn now, then puts it back there. + * `jolts` (wire_jolts()) are the beats to use, for something else drawn on the body to follow them. + * + * Its own animation, not one run in parallel as tg's is: recorded on a lying body, a parallel shake (absolute or + * relative steps alike) showed each jolt at about twice its size, so nothing following the jolts could keep with it. + * Being its own animation it would stop a floating body's bob, so the bob is held off until the shake is over. + */ +/proc/wire_shake(atom/movable/body, shift_x, shift_y, duration, list/jolts) + if(QDELETED(body)) + return + if(!length(jolts)) + jolts = wire_jolts(shift_x, shift_y, duration) + ADD_TRAIT(body, TRAIT_NO_FLOATING_ANIM, WIRE_SHAKE_TRAIT) + addtimer(TRAIT_CALLBACK_REMOVE(body, TRAIT_NO_FLOATING_ANIM, WIRE_SHAKE_TRAIT), length(jolts) * WIRE_GARROTE_JOLT_TIME, TIMER_UNIQUE | TIMER_OVERRIDE) + var/start_x = body.pixel_x + var/start_y = body.pixel_y + var/first = TRUE + for(var/list/jolt as anything in jolts) + if(first) + animate(body, pixel_x = start_x + jolt[1], pixel_y = start_y + jolt[2], time = WIRE_GARROTE_JOLT_TIME) + first = FALSE + else + animate(pixel_x = start_x + jolt[1], pixel_y = start_y + jolt[2], time = WIRE_GARROTE_JOLT_TIME) + +/** + * Draws the loop round the victim's neck: `kind` "draw" (winding on), "loop" (hanging loose) or "tight" (drawing + * tight over the hold). Its far side is drawn under the body, so the neck hides it and only its ends show; its near + * side over the body. + */ +/datum/hv_finisher/garrote/proc/show_loop(kind) + clear_loop() + if(QDELETED(victim) || !running) + return + var/lifetime = longest_duration() + // One of the body's own overlays, so the neck and head drawn over it hide it. + loop_back = mutable_appearance(WIRE_GORE_ICON, "garrote_[kind]_back[wire_suffix()]", -(TOTAL_LAYERS + 0.5)) + victim.add_overlay(loop_back) + // Over the garroter's legs, which the body lies against; facing away, over the neck but under the garroter. + var/near_layer = user.dir == NORTH ? WIRE_BETWEEN_LAYER : ABOVE_MOB_LAYER + var/obj/effect/abstract/cyberware_anim/near_side = cyberware_anim_play(victim, WIRE_GORE_ICON, "garrote_[kind]_front[wire_suffix()]", near_layer, lifetime, glow = TRUE) + loop_refs = list(WEAKREF(near_side)) + +/datum/hv_finisher/garrote/proc/clear_loop() + for(var/datum/weakref/loop_ref as anything in loop_refs) + qdel(loop_ref.resolve()) + loop_refs = null + if(loop_back) + victim?.cut_overlay(loop_back) + loop_back = null + +/// Where the garroter and the victim are drawn now: list(garroter pixel_x, pixel_y, victim pixel_x, pixel_y) +/datum/hv_finisher/garrote/proc/drawn_offsets() + return list(user.pixel_x, user.pixel_y, victim.pixel_x, victim.pixel_y) + +/** + * The wire from the garroter's hands to the neck, one strand a hand, in the wire's own colour: one line of wire + * each, stretched from the hand to the neck. A strand from a hand behind the garroter's body (the far hand in profile, + * both facing away) is drawn under the garroter, so the torso hides it (strand_layer()). Whatever wire was drawn before (the + * slack throw, or the strands before a lean) goes as these go up. + * + * `slide_from` (drawn_offsets(), or null) is where the two were drawn before a move that is sliding them into place + * now, over tg's offset time: the strands start from there and slide with them, so they stay on the hands and the + * neck all the way. + */ +/datum/hv_finisher/garrote/proc/draw_wire(duration, list/slide_from) + clear_reach() + clear_strands() + var/turf/from = get_turf(user) + if(!from || QDELETED(user) || QDELETED(victim)) + return + // Never a strand from a hand that still draws a wire hanging in it. + hide_hands() + var/list/start = slide_from || drawn_offsets() + for(var/side in list("left", "right")) + var/list/hand = line_origin(side) + var/hand_x = user.pixel_x + hand[1] + var/hand_y = user.pixel_y + hand[2] + // From the middle of the hand's pixel to the middle of the loop's, where the loop is drawn: whole pixels. + var/list/meet = loop_point(side) + var/span_x = meet[1] - (hand_x + 0.5) + var/span_y = meet[2] - (hand_y + 0.5) + var/start_hand_x = hand_x + start[1] - user.pixel_x + var/start_hand_y = hand_y + start[2] - user.pixel_y + var/start_span_x = span_x + (start[3] - victim.pixel_x) - (start[1] - user.pixel_x) + var/start_span_y = span_y + (start[4] - victim.pixel_y) - (start[2] - user.pixel_y) + var/obj/effect/abstract/wire_reach/strand = new_line(hand[3]) + strand.icon_state = "wire_taut[wire_suffix()]" + strand.layer = strand_layer(hand[3]) + strand.add_overlay(emissive_appearance(strand.icon, strand.icon_state, strand)) + strand.pixel_x = start_hand_x + strand.pixel_y = start_hand_y + strand.span = list(span_x, span_y) + strand.hand_side = side + strand.transform = wire_strand_shape(start_span_x, start_span_y) + if(start_hand_x != hand_x || start_hand_y != hand_y || start_span_x != span_x || start_span_y != span_y) + // Linear, as the body's slide in is (slide_in()), so the far end keeps step with the neck all the way. In beats: + // each beat ends on the strand's true shape for where its two ends are by then, and the matrix is blended + // straight from one beat's shape to the next. Blended in one go from the first shape to the last, a strand that + // turns far on the way (40 degrees, facing the viewer) is drawn thinner than a pixel in between, and recorded + // it showed a pixel missing for the first frames of the pull. + var/beat_time = UPDATE_TRANSFORM_ANIMATION_TIME / WIRE_GARROTE_SLIDE_BEATS + for(var/beat in 1 to WIRE_GARROTE_SLIDE_BEATS) + var/done = beat / WIRE_GARROTE_SLIDE_BEATS + var/beat_x = start_hand_x + (hand_x - start_hand_x) * done + var/beat_y = start_hand_y + (hand_y - start_hand_y) * done + var/matrix/shape = wire_strand_shape(start_span_x + (span_x - start_span_x) * done, start_span_y + (span_y - start_span_y) * done) + if(beat == 1) + animate(strand, pixel_x = beat_x, pixel_y = beat_y, transform = shape, time = beat_time, flags = ANIMATION_LINEAR_TRANSFORM) + else + animate(pixel_x = beat_x, pixel_y = beat_y, transform = shape, time = beat_time, flags = ANIMATION_LINEAR_TRANSFORM) + LAZYADD(strand_refs, WEAKREF(strand)) + QDEL_IN(strand, duration) + +/** + * A taut strand of wire from the middle of the pixel at its base to the middle of the pixel (`span_x`, `span_y`) away, + * and half a pixel past each, so it covers the pixel it starts on and the pixel it ends on whatever its bearing (a line + * that starts on the middle of a pixel draws that pixel on some bearings and not on others: recorded, the strand's end + * in the hand blinked a pixel off the hand as its other end thrashed with the neck). The sprite is a tile-long line + * running up a half pixel left of the middle: it is moved onto the middle and up to start there, stretched, moved back + * half a pixel and turned, then moved to the middle of the base pixel. The base pixel stays covered under any blend of + * two of these, so a strand tweened between two keeps its base in the hand and runs its far end straight from one spot + * to the other. + */ +/proc/wire_strand_shape(span_x, span_y) + var/matrix/shape = matrix() + shape.Translate(0.5, ICON_SIZE_Y / 2) + shape.Scale(1, (wire_line_length(span_x, span_y) + WIRE_LINE_BACK) / ICON_SIZE_Y) + shape.Translate(0, -WIRE_LINE_BACK) + shape.Turn(arctan(span_y, span_x)) + shape.Translate(0.5, 0.5) + return shape + +/** + * The garroter has just been leaned somewhere else (the kill's lean), sliding there over tg's offset time: each strand's + * end in the hand slides with the hand, and its end on the neck stays put. The strands already up are moved, not taken + * down and drawn again. Returns FALSE if there are none to move. + */ +/datum/hv_finisher/garrote/proc/lean_wire() + if(QDELETED(user) || QDELETED(victim)) + return FALSE + var/moved = FALSE + for(var/datum/weakref/strand_ref as anything in strand_refs) + var/obj/effect/abstract/wire_reach/strand = strand_ref.resolve() + if(QDELETED(strand) || !strand.hand_side) + continue + var/list/hand = line_origin(strand.hand_side) + var/hand_x = user.pixel_x + hand[1] + var/hand_y = user.pixel_y + hand[2] + var/list/meet = loop_point(strand.hand_side) + strand.span = list(meet[1] - (hand_x + 0.5), meet[2] - (hand_y + 0.5)) + animate(strand, pixel_x = hand_x, pixel_y = hand_y, transform = wire_strand_shape(strand.span[1], strand.span[2]), time = UPDATE_TRANSFORM_ANIMATION_TIME, flags = ANIMATION_LINEAR_TRANSFORM) + moved = TRUE + return moved + +/datum/hv_finisher/garrote/proc/clear_strands() + for(var/datum/weakref/strand_ref as anything in strand_refs) + qdel(strand_ref.resolve()) + strand_refs = null + +/datum/hv_finisher/garrote/proc/clear_wire_fx() + for(var/timer in windup_timers) + deltimer(timer) + windup_timers = null + if(struggle_timer) + deltimer(struggle_timer) + struggle_timer = null + clear_reach() + clear_loop() + clear_strands() + show_hands() + +/// TRUE if the garrote is the Arc's: the wire round the neck, or the one in the garroter's other hand. A pair with +/// one Arc wire beheads as the Arc does. +/datum/hv_finisher/garrote/proc/arc_wire() + if(istype(wire, /obj/item/melee/cyberware_monowire/live)) + return TRUE + return !isnull(locate(/obj/item/melee/cyberware_monowire/live) in user?.held_items) + +/** + * The kill: the head off in hard crit (with the Arc's wire, whenever no helmet, collar or plating turns it), else + * the throat slit, else (turned by a helmet, collar or plating) an ordinary blow with the wire. Lines go out while + * the head is still on, since they name it. + */ +/datum/hv_finisher/garrote/proc/kill(spray_dir) + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + if(!head) + return + var/seared = wire.wire_sears(victim) + // Where the body is drawn while the wire goes through, for where the head comes off and the blood bursts from. + var/list/body_offsets = list(victim.pixel_x, victim.pixel_y, victim.pixel_w, victim.pixel_z) + var/list/cut_neck = neck_on_tile() + var/head_side = (get_dir(victim, user) & (EAST | NORTH)) ? 1 : -1 + var/facing = user.dir + clear_wire_fx() + // The garroter lets go as the wire goes through, and the body drops back once, here. The pool and the smoke go + // where it comes to rest, once it is there. + var/settle_time = let_go_at_kill() + var/list/rest_neck = neck_on_tile() + // Facing away, the snap is between the two bodies, not over the garroter's head. + cyberware_anim_play(victim, WIRE_GORE_ICON, "garrote_snap[wire_suffix()]", facing == NORTH ? WIRE_BETWEEN_LAYER : ABOVE_MOB_LAYER, 0.6 SECONDS, glow = TRUE) + var/datum/hv_crit/throat/throat = locate() in GLOB.hv_crits + var/blocker = wire_turned_by(head, throat) + if(head.can_dismember() && (victim.stat >= HARD_CRIT || (!blocker && arc_wire()))) + victim.hv_add_hit_line("[user] draws the wire through [victim]'s neck!", HV_LINE_HUGE, null, DEFAULT_MESSAGE_RANGE) + if(seared) + LAZYSET(victim.hv_stump_burnt, BODY_ZONE_HEAD, TRUE) + // What tg pulls off a head as it comes off: laid by the dropped head, not stood up on the body. + var/list/worn = list() + for(var/obj/item/thing in list(victim.glasses, victim.ears, victim.wear_mask, victim.head)) + worn += thing + // Dropped, brain and all, as #509's finishers drop a head: where the neck was, at the garroter's feet. None of + // tg's own blood on the floor (a seared neck doesn't bleed there at all); the garrote lays its own. + if(hv_wire_take_part(head, seared ? WOUND_BURN : WOUND_SLASH, 0, FALSE)) + // The animation pass twitches a fresh corpse a few times, starting at once. Not while the body is still + // slumping back onto its tile: its twitches begin once it lies still. + if(victim.stat == DEAD) + victim.hv_vis_twitches(2, settle_time + WIRE_GARROTE_TWITCH_WAIT) + wire_neck_blood_loss(victim, seared) + wire_drop_head(head, victim, body_offsets, head_side, facing, worn, list(rest_neck[1] - cut_neck[1], rest_neck[2] - cut_neck[2])) + // Facing away, the head lies against the stump, below the body's line, with the garroter just beyond it: a pool + // centred on the neck would show only above the shoulders. It goes a little lower, and shows round the head. + var/list/pool_at = facing == NORTH ? list(rest_neck[1], rest_neck[2] - WIRE_GARROTE_POOL_DROP_NORTH) : rest_neck + finish_blood(spray_dir, seared, cut_neck, rest_neck, settle_time, pool_at) + log_combat(user, victim, "garroted the head off", wire) + return + LAZYREMOVE(victim.hv_stump_burnt, BODY_ZONE_HEAD) + if(!blocker && throat) + // No direction: tg would throw its flying splatter down a straight line. The garrote's blood is finish_blood(). + var/datum/wound/slit = hv_crit_apply_wound(head, throat.wound_type, null, wire) + if(slit) + victim.hv_add_hit_line("[user] jerks the wire across [victim]'s throat!") + throat.announce(victim, spray_dir) + wire_open_throat(victim, slit) + finish_blood(spray_dir, seared, cut_neck, rest_neck, settle_time) + log_combat(user, victim, "garroted the throat of", wire) + return + if(blocker) + victim.hv_add_hit_line("The wire catches on [victim]'s [blocker]!", HV_LINE_BOLD, "The wire catches on your [blocker]!") + real_blow(BODY_ZONE_HEAD, kill_wound_bonus) + +/// The blood a head coming off loses, as tg's dismemberment bleeds it, without the floor splatter tg's bleed() lays +/// (the garrote lays its own blood). A seared neck loses a little. +/proc/wire_neck_blood_loss(mob/living/carbon/body, seared) + if(QDELETED(body) || HAS_TRAIT(body, TRAIT_GODMODE) || !body.can_bleed()) + return + body.blood_volume = max(body.blood_volume - round(rand(40, 80) * (seared ? WIRE_ARC_BLEED_MULT : 1)), 0) + +/** + * The head comes off the end of the neck where the wire cut it, a few pixels clear of it, and drops to the floor at + * the garroter's feet: it doesn't follow the body as that falls back (`settle`, the body's move after the cut), except + * facing away, where the garroter's feet are the wrong side of them and it would lie against their own head. Turned + * as the body lay; an ordinary head again once moved. What the head wore (`worn`, already on the floor) lies beside + * it. `facing` is the garroter's. + */ +/proc/wire_drop_head(obj/item/bodypart/head/head, mob/living/body, list/body_offsets, side, facing, list/worn, list/settle) + if(QDELETED(head) || !isturf(head.loc)) + return + // On the body its middle is 9 px up; it lies 4 px further out, off the end of the neck. Its picture is + // shifted by (px_x, px_y) to sit mid-tile, after its transform. + head.transform = wire_part_pose(list(0, 9), side * 10, list(side * 2, 13), body, head.px_x, head.px_y) + head.pixel_x = body_offsets[1] + head.pixel_y = body_offsets[2] + head.pixel_w = body_offsets[3] + head.pixel_z = body_offsets[4] + // Down to the floor: furthest facing the viewer, where the hold drew the body up off it. + var/shift_x = 0 + var/fall = facing == SOUTH ? 8 : 5 + if(facing == NORTH) + shift_x = LAZYACCESS(settle, 1) || 0 + fall = 2 - (LAZYACCESS(settle, 2) || 0) + animate(head, pixel_x = head.pixel_x + shift_x, pixel_y = head.pixel_y - fall, time = WIRE_GARROTE_HEAD_FALL_TIME, easing = QUAD_EASING | EASE_IN) + head.RegisterSignal(head, COMSIG_MOVABLE_MOVED, TYPE_PROC_REF(/obj/item/bodypart, wire_stand_up), override = TRUE) + if(!length(worn)) + return + // Where its middle lands, and which way along the floor the head points from the neck. + var/matrix/shape = body.transform + var/head_x = shape.a * side * 2 + shape.b * 13 + shape.c + body_offsets[1] + shift_x + var/head_y = shape.d * side * 2 + shape.e * 13 + shape.f + body_offsets[2] - fall + var/away_x = shape.b > 0.5 ? 1 : (shape.b < -0.5 ? -1 : 0) + var/laid = 0 + for(var/obj/item/thing as anything in worn) + if(QDELETED(thing) || thing.loc != head.loc) + continue + wire_lay_by_head(thing, round(head_x - away_x * (7 + laid * 5)), round(head_y - 3), away_x) + laid++ + +/** + * Something that came off with the head lies on the floor at (`spot_x`, `spot_y`) on its tile, on its side and a little + * smaller than tg's dropped-item picture, unseen until the head has landed. Drawn as any item again once moved. + */ +/proc/wire_lay_by_head(obj/item/thing, spot_x, spot_y, away_x) + var/matrix/lying = matrix() + lying.Scale(0.7) + lying.Turn(away_x < 0 ? -90 : 90) + thing.transform = lying + thing.pixel_x = spot_x + thing.pixel_y = spot_y + thing.alpha = 0 + animate(thing, alpha = 0, time = WIRE_GARROTE_HEAD_FALL_TIME) + animate(alpha = 255, time = 0.1 SECONDS) + thing.RegisterSignal(thing, COMSIG_MOVABLE_MOVED, TYPE_PROC_REF(/obj/item, wire_garrote_pick_up), override = TRUE) + +/// An item wire_lay_by_head() laid out, once moved: drawn as any item. +/obj/item/proc/wire_garrote_pick_up() + SIGNAL_HANDLER + UnregisterSignal(src, COMSIG_MOVABLE_MOVED) + animate(src, alpha = 255, time = 0) + transform = matrix() + pixel_x = base_pixel_x + pixel_y = base_pixel_y + +/** + * The open neck empties. Blood bursts out all round where the wire cut it (`cut_neck`, from the middle of the victim's + * tile) and lands in a rough ring of drops and splats over the floor about the neck, the garroter included; it wets + * the garroter's hands, then their clothes and feet as the drops come down; and once the body has come to rest + * (`settle_time` on), a pool spreads under the neck there (`rest_neck`, or `pool_at`) over the next couple of seconds. + * A seared one only smokes, from there. + */ +/datum/hv_finisher/garrote/proc/finish_blood(spray_dir, seared, list/cut_neck, list/rest_neck, settle_time = 0, list/pool_at) + if(QDELETED(victim)) + return + if(seared) + if(settle_time) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_neck_smoke), victim, rest_neck), settle_time) + else + wire_neck_smoke(victim, rest_neck) + playsound(victim, 'sound/effects/wounds/sizzle1.ogg', 60, TRUE) + return + var/turf/neck_turf = get_turf(victim) + if(!neck_turf || victim.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return + var/list/blood_dna = victim.get_blood_dna_list() + var/list/viruses = victim.get_static_viruses() + if(!pool_at) + pool_at = rest_neck + if(settle_time) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_pool_under), neck_turf, pool_at[1], pool_at[2], blood_dna, viruses), settle_time) + else + wire_pool_under(neck_turf, pool_at[1], pool_at[2], blood_dna, viruses) + wire_blood_burst(neck_turf, cut_neck[1], cut_neck[2], wire_blood_color(victim), blood_dna) + if(QDELETED(user)) + return + // The hands are at the neck: wet at once. The clothes and feet as the drops come down on them. + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_garrote_soak), user, neck_turf, blood_dna, viruses, 1), 0.15 SECONDS) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_garrote_soak), user, neck_turf, blood_dna, viruses, 2), 0.45 SECONDS) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_garrote_soak), user, neck_turf, blood_dna, viruses, 3), 0.8 SECONDS) + +/// One beat of the garroter getting the neck's blood on them: 1 the hands, 2 the front of the clothes and a few +/// splats round their feet, 3 the rest of them and their shoes. +/proc/wire_garrote_soak(mob/living/soaked, turf/neck_turf, list/blood_dna, list/viruses, beat) + if(QDELETED(soaked)) + return + var/mob/living/carbon/human/dressed = ishuman(soaked) ? soaked : null + switch(beat) + if(1) + if(dressed) + dressed.add_blood_DNA_to_items(blood_dna, ITEM_SLOT_GLOVES | ITEM_SLOT_HANDS, viruses) + else + soaked.add_blood_DNA(blood_dna, viruses) + if(2) + dressed?.add_blood_DNA_to_items(blood_dna, ITEM_SLOT_ICLOTHING | ITEM_SLOT_OCLOTHING, viruses) + var/turf/feet = get_turf(soaked) + if(feet && feet != neck_turf && !isgroundlessturf(feet)) + for(var/i in 1 to 2) + var/obj/effect/decal/cleanable/blood/drip/wire_flick/drop = new(feet, null, blood_dna) + if(!QDELETED(drop)) + drop.pixel_x = rand(-9, 9) + drop.pixel_y = rand(-12, 0) + if(3) + soaked.hv_blood_drench(blood_dna, viruses) + dressed?.add_blood_DNA_to_items(blood_dna, ITEM_SLOT_FEET, viruses) + +/// A seared neck smokes a little: thin wisps rising off the stump where the body lies, not turned with the body. +/obj/effect/abstract/wire_neck_smoke + name = "smoke" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + // Over the body on the floor, under anyone standing. + layer = WIRE_BETWEEN_LAYER + +/obj/effect/abstract/wire_neck_smoke/proc/stop_smoking() + particles?.spawning = 0 + +/particles/smoke/steam/mild/wire_neck + color = "#a29c98" + scale = 0.4 + grow = 0.02 + spawning = 0.6 + lifespan = 1.2 SECONDS + fade = 0.8 SECONDS + position = list(0, 0, 0) + velocity = list(0, 0.5, 0) + gravity = list(0, 0.5) + friction = 0.15 + drift = generator(GEN_SPHERE, 0, 0.5, NORMAL_RAND) + +/// Smoke off a seared neck at (`neck[1]`, `neck[2]`) from the middle of `body`'s tile, for a second, gone soon after. +/proc/wire_neck_smoke(mob/living/body, list/neck) + var/turf/spot = get_turf(body) + if(!spot) + return + var/obj/effect/abstract/wire_neck_smoke/smoke = new(spot) + smoke.pixel_x = neck[1] + smoke.pixel_y = neck[2] + smoke.particles = new /particles/smoke/steam/mild/wire_neck + addtimer(CALLBACK(smoke, TYPE_PROC_REF(/obj/effect/abstract/wire_neck_smoke, stop_smoking)), 1.2 SECONDS) + QDEL_IN(smoke, 2.4 SECONDS) + +/** + * The pool under the neck: tg's blood decal for the tile, filled to a pool size that keeps to the tile + * (blood/blood_pools.dm). A fresh one is centred on the neck and spreads out from a spot under it over + * WIRE_GARROTE_POOL_TIME; a pool already on the tile stays put and steps up through the sizes as it fills. + */ +/proc/wire_pool_under(turf/neck_turf, neck_x, neck_y, list/blood_dna, list/viruses) + if(isgroundlessturf(neck_turf)) + return + var/obj/effect/decal/cleanable/blood/pool + for(var/obj/effect/decal/cleanable/blood/found in neck_turf) + if(found.type == /obj/effect/decal/cleanable/blood && !found.dried && !QDELETED(found)) + pool = found + break + if(pool) + pool.add_blood_DNA(blood_dna) + pool.hv_pool_lobe_tried |= (NORTH | SOUTH | EAST | WEST) + for(var/step in 0 to 3) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_pool_fill), pool), step * 0.45 SECONDS) + return + pool = new /obj/effect/decal/cleanable/blood(neck_turf, viruses, blood_dna) + if(QDELETED(pool)) + return + pool.base_pixel_x = clamp(neck_x, -8, 8) + pool.base_pixel_y = clamp(neck_y, -12, 8) + pool.pixel_x = pool.base_pixel_x + pool.pixel_y = pool.base_pixel_y + // It keeps to the neck's tile: it never runs onto the tiles beside it, however much the body bleeds into it. + pool.hv_pool_lobe_tried |= (NORTH | SOUTH | EAST | WEST) + // Its whole size at once, so the picture doesn't change as it spreads; the spreading is drawn. + pool.adjust_bloodiness(WIRE_GARROTE_POOL_CAP - pool.bloodiness) + var/matrix/spot = matrix() + spot.Scale(0.15) + pool.transform = spot + // Parallel: tg's drying runs on the decal's own animation. + animate(pool, transform = matrix(), time = WIRE_GARROTE_POOL_TIME, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + +/// One beat of the garrote's pool filling, never past WIRE_GARROTE_POOL_CAP. +/proc/wire_pool_fill(obj/effect/decal/cleanable/blood/pool) + if(QDELETED(pool) || pool.bloodiness >= WIRE_GARROTE_POOL_CAP) + return + pool.adjust_bloodiness(min(40, WIRE_GARROTE_POOL_CAP - pool.bloodiness)) + +/** + * Blood bursts from a wound at (`from_x`, `from_y`) pixels from the middle of `origin` and lands round it: `count` drops + * thrown at uneven reach (`reach` pixels, give or take a few), landing as drips, and every third a heavier splat. With + * no `bearing` they go every way, no two in a row alike, so it lands as a broken ring; with one (degrees, 0 north) + * they go within `spread` degrees either side of it, a short spray rather than a line. + */ +/proc/wire_blood_burst(turf/origin, from_x, from_y, blood_color, list/blood_dna, count = 10, bearing = null, spread = 0, list/reach = list(9, 13, 17, 22, 26)) + var/start = rand(0, 359) + var/list/splatted = list() + for(var/i in 1 to count) + var/angle = isnull(bearing) ? start + i * (360 / count) + rand(-14, 14) : bearing + rand(-spread, spread) + var/distance = pick(reach) + rand(-2, 2) + var/land_x = from_x + round(sin(angle) * distance) + var/land_y = from_y + round(cos(angle) * distance) + var/height = 3 + rand(0, 5) + var/flight = round(1.5 + distance / 14, 0.5) + new /obj/effect/temp_visual/wire_blood_drop(origin, list(from_x, from_y, land_x, land_y, height, flight, 0), blood_color, blood_dna) + if(i % 3) + continue + // One splat to a tile. + var/tile_x = floor((land_x + 16) / 32) + var/tile_y = floor((land_y + 16) / 32) + var/turf/landing = locate(origin.x + tile_x, origin.y + tile_y, origin.z) + if(!landing || (landing in splatted) || isgroundlessturf(landing) || (landing != origin && hv_blood_spray_blocked(landing))) + continue + splatted += landing + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_ring_splat), landing, land_x - tile_x * 32, land_y - tile_y * 32, blood_dna), flight) + +/// A heavy splat of the ring, tg's small splatter, landing at (`pixel_x`, `pixel_y`) on `landing`. +/proc/wire_ring_splat(turf/landing, pixel_x, pixel_y, list/blood_dna) + if(!landing) + return + var/obj/effect/decal/cleanable/blood/splatter/splat = new(landing, null, blood_dna) + if(QDELETED(splat)) + return + // tg's splatter art is drawn round the middle of its tile. + splat.pixel_x = clamp(pixel_x, -12, 12) + splat.pixel_y = clamp(pixel_y, -12, 12) + +/// The open throat, drawn on the neck for as long as the wound in it is there. +/obj/effect/abstract/cyberware_anim/wire_throat + name = "slit throat" + icon = WIRE_GORE_ICON + icon_state = "throat_open" + /// The wound it shows + var/datum/wound/slit + +/obj/effect/abstract/cyberware_anim/wire_throat/Destroy() + slit = null + return ..() + +/obj/effect/abstract/cyberware_anim/wire_throat/proc/on_lose_wound(datum/source, datum/wound/lost) + SIGNAL_HANDLER + if(lost == slit) + qdel(src) + +/obj/effect/abstract/cyberware_anim/wire_throat/proc/on_lose_limb(datum/source, obj/item/bodypart/lost) + SIGNAL_HANDLER + if(lost?.body_zone == BODY_ZONE_HEAD) + qdel(src) + +/// Draws the throat `slit` opened on `victim`, in their blood's colour, until the wound closes or the head is gone. +/proc/wire_open_throat(mob/living/carbon/victim, datum/wound/slit) + if(QDELETED(victim) || !slit) + return + var/obj/effect/abstract/cyberware_anim/wire_throat/mark = new(null) + mark.slit = slit + // Over the collar of whatever they wear, under anything worn round the neck. + mark.layer = -(NECK_LAYER + 0.5) + mark.appearance_flags |= RESET_COLOR + mark.color = wire_blood_color(victim) + mark.bearer = victim + mark.RegisterSignal(victim, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + mark.RegisterSignal(victim, COMSIG_CARBON_LOSE_WOUND, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim/wire_throat, on_lose_wound)) + mark.RegisterSignal(victim, COMSIG_CARBON_REMOVE_LIMB, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim/wire_throat, on_lose_limb)) + victim.vis_contents += mark + +/// What stops the wire at the throat ("helmet", "collar", "plating"), or null. The same gates as #509's +/// throat crit, with the wire's penetration not counted (the crit gates never count it). +/datum/hv_finisher/garrote/proc/wire_turned_by(obj/item/bodypart/head/head, datum/hv_crit/throat/throat) + var/mob/living/carbon/human/dressed = ishuman(victim) ? victim : null + if(throat?.blocked_on_carbon(victim, head, wire)) + if(victim.is_mouth_covered(ITEM_SLOT_HEAD)) + return "helmet" + return "collar" + if(hv_crit_cover_rating(victim, head, MELEE, 0) >= WIRE_GARROTE_COVER) + if(dressed?.head || dressed?.wear_mask) + return "helmet" + if(dressed?.wear_neck) + return "collar" + return "plating" + return null + +// ---- Stages ---- + +/datum/hv_finisher_stage/windup/garrote + duration = 1 SECONDS + rise = 0 + // Leans in to throw the wire. + lunge = 3 + enter_range = COMBAT_MESSAGE_RANGE + +// The gore pass rears every finisher's attacker up for its wind-up, bigger and tipped back away from the victim +// (visuals/finisher_motion.dm): a beast looming over its kill. A garroter leans in to throw the wire, and the wire +// leaves the hand where the hand is drawn, so that picture is taken straight back off, before any client sees it. +/datum/hv_finisher_stage/windup/garrote/enter() + . = ..() + if(host && !QDELETED(host.user)) + host.user.hv_vis_stop(list(HV_VIS_TAG_REAR)) + +/datum/hv_finisher_stage/windup/garrote/enter_message() + return "[host.user] loops the wire around [host.victim]'s neck." + +/datum/hv_finisher_stage/windup/garrote/enter_self_message() + return "A wire loops around your neck!" + +/datum/hv_finisher_stage/hold/garrote + duration = 1.5 SECONDS + // Stays leaned in over the body, into the pull. + lunge = 3 + enter_sound = 'voidcrew/sound/monowire2.ogg' + enter_volume = 50 + enter_range = COMBAT_MESSAGE_RANGE + +/datum/hv_finisher_stage/hold/garrote/enter() + . = ..() + var/datum/hv_finisher/garrote/garrote = host + garrote.pull_close() + garrote.show_loop("tight") + // Taut until the kill beat cuts it (kill() takes them down; the time is only the garrote's own backstop), sliding in + // with the bodies from where they were before the grab. + garrote.draw_wire(garrote.longest_duration(), garrote.pull_from) + // Drawn in to the hands first, then the thrashing. + garrote.struggle(UPDATE_TRANSFORM_ANIMATION_TIME, duration - UPDATE_TRANSFORM_ANIMATION_TIME) + +/datum/hv_finisher_stage/hold/garrote/enter_message() + return "[host.user] pulls the wire tight!" + +/datum/hv_finisher_stage/hold/garrote/enter_self_message() + return "The wire bites into your neck!" + +/datum/hv_finisher_stage/kill/garrote + duration = 1 SECONDS + effect_delay = 0.5 SECONDS + // Leans further in as the wire goes through. + lunge = 5 + +/datum/hv_finisher_stage/kill/garrote/enter() + var/datum/hv_finisher/garrote/garrote = host + var/list/before_lean = garrote.drawn_offsets() + . = ..() + // The strands stay on the hands as the lean takes them forward: the hold's own strands, which last until the cut. + if(garrote.running && !garrote.lean_wire()) + garrote.draw_wire(effect_delay + 0.1 SECONDS, before_lean) + +/datum/hv_finisher_stage/kill/garrote/effect() + var/datum/hv_finisher/garrote/garrote = host + garrote.kill(away_dir()) + +#undef WIRE_GARROTE_INTERRUPT +#undef WIRE_GARROTE_REACH_TIME +#undef WIRE_GARROTE_LEAN_TIME +#undef WIRE_GARROTE_WIND_TIME +#undef WIRE_GARROTE_THROW_BEATS +#undef WIRE_GARROTE_SLIDE_BEATS +#undef WIRE_GARROTE_TURN_TIME +#undef WIRE_GARROTE_POOL_TIME +#undef WIRE_GARROTE_HEAD_FALL_TIME +#undef WIRE_GARROTE_POOL_DROP_NORTH +#undef WIRE_GARROTE_JOLT_TIME +#undef WIRE_GARROTE_TWITCH_WAIT +#undef WIRE_LINE_BACK +#undef WIRE_SHAKE_TRAIT diff --git a/voidcrew/modules/hyperviolence/wire/wire_held.dm b/voidcrew/modules/hyperviolence/wire/wire_held.dm new file mode 100644 index 00000000000..690dbcfc46a --- /dev/null +++ b/voidcrew/modules/hyperviolence/wire/wire_held.dm @@ -0,0 +1,856 @@ +/** + * # The Widowline in the hand + * + * - Deploying and stowing: the wire swings out of the spool and reels back in (WIRE_HELD_ANIM_ICON), played + * on the wielder while the held wire itself is not drawn, like the Mantis unfold. + * - While the wire is out of the hand as a line (a lash, the garrote's thrown wire and strands) the hanging wire isn't + * drawn there, but its spool is (WIRE_SPOOL_ICON): the line comes out of the spool's lit pixel. + * - Blood: a cut that draws blood leaves the wire wet (dripping) for WIRE_WET_TIME, then stained until + * WIRE_STAINED_TIME, drawn from greyscale states tinted to the blood. Stowing a wet wire cracks a fan of + * drops off it that land spread over the floor ahead. Only the picture clears: the blood's DNA stays on the wire until it is washed. + * tg's generic item stain is not drawn on the wire, which draws its own. + * - The Arc's charged wire burns its blood off: it never shows any. + */ + +/obj/item/melee/cyberware_monowire + /// Blood on the wire: wet and dripping until this world.time, stained until this one. + var/wet_until = 0 + var/stained_until = 0 + /// The blood look drawn now: 0 clean, 1 stained, 2 wet. + var/shown_blood_stage = 0 + /// Drips this wet spell still has in it. + var/drips_left = 0 + /// Timer of the next drip, and of the next change of look. + var/drip_timer + var/dry_timer + /// Until this world.time the wire isn't drawn hanging in the hand: its swing is, or a line of it out to something. + var/inhand_hidden_until = 0 + /// Until this world.time its spool isn't drawn in the hand either: the swing out of the spool draws its own. + var/inhand_bare_until = 0 + +/obj/item/melee/cyberware_monowire/Initialize(mapload) + . = ..() + RegisterSignal(src, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(on_wash)) + +/obj/item/melee/cyberware_monowire/Destroy() + if(garrote_running) + QDEL_NULL(garrote_running) + if(drip_timer) + deltimer(drip_timer) + drip_timer = null + if(dry_timer) + deltimer(dry_timer) + dry_timer = null + return ..() + +// ---- Blood on the wire ---- + +/// Whether this wire never shows blood. +/obj/item/melee/cyberware_monowire/proc/wire_stays_clean() + return FALSE + +/obj/item/melee/cyberware_monowire/live/wire_stays_clean() + return TRUE + +/// 2 while the wire is wet, 1 while it is stained, else 0. +/obj/item/melee/cyberware_monowire/proc/blood_stage() + if(world.time < wet_until) + return 2 + if(world.time < stained_until) + return 1 + return 0 + +/// A landed cut on `victim` at `def_zone`: if it drew blood, the wire is wet with it. +/obj/item/melee/cyberware_monowire/proc/wire_bloody(mob/living/victim, def_zone) + if(wire_stays_clean() || QDELETED(victim)) + return + if(isbodypart(def_zone)) + var/obj/item/bodypart/limb = def_zone + if(!limb.can_bleed()) + return + if(victim.can_bleed(BLOOD_COVER_ITEMS) != BLEED_SPLATTER) + return + add_mob_blood(victim) + wet_until = world.time + WIRE_WET_TIME + stained_until = world.time + WIRE_STAINED_TIME + drips_left = WIRE_MAX_DRIPS + if(!drip_timer) + drip_timer = addtimer(CALLBACK(src, PROC_REF(drip)), rand(1 SECONDS, 2 SECONDS), TIMER_STOPPABLE) + update_blood_look() + +/// Redraws the blood if its look changed, and waits for the next change. +/obj/item/melee/cyberware_monowire/proc/update_blood_look() + if(dry_timer) + deltimer(dry_timer) + dry_timer = null + var/stage = blood_stage() + if(stage != shown_blood_stage) + shown_blood_stage = stage + update_appearance(UPDATE_OVERLAYS) + var/mob/holder = loc + if(ismob(holder)) + holder.update_held_items() + // Wet dries to a stain, a stain to clean: wait for whichever comes next. + if(stage) + dry_timer = addtimer(CALLBACK(src, PROC_REF(update_blood_look)), (stage == 2 ? wet_until : stained_until) - world.time + 1, TIMER_STOPPABLE) + +/// A drop off the tip while the wire is out and wet. +/obj/item/melee/cyberware_monowire/proc/drip() + drip_timer = null + if(blood_stage() < 2 || drips_left <= 0) + return + var/mob/living/holder = loc + if(!isliving(holder)) + return + var/turf/below = holder.loc + if(isturf(below) && !isgroundlessturf(below) && below.has_gravity() && length(GET_ATOM_BLOOD_DNA(src))) + // Off the tip, which hangs to the floor: not wherever tg's drip would land, which can be the wielder's hip. + var/obj/effect/decal/cleanable/blood/drip/wire_flick/drop = new(below, null, GET_ATOM_BLOOD_DNA(src)) + if(!QDELETED(drop)) + drop.wire_place(holder.pixel_x + wire_tip_x(holder, held_side(holder) || "right") + rand(-2, 2), holder.pixel_y - 13 + rand(-1, 1)) + drips_left-- + drip_timer = addtimer(CALLBACK(src, PROC_REF(drip)), rand(1 SECONDS, 2 SECONDS), TIMER_STOPPABLE) + +/// Where the tip of a wire held in the `side` hand ("left" or "right") of `holder` touches the floor, in pixels across +/// from the middle of its tile, as the held wire is drawn (cyberware_lefthand.dmi, cyberware_righthand.dmi). +/proc/wire_tip_x(mob/living/holder, side) + var/right = side != "left" + switch(holder.dir) + if(EAST) + return right ? 1 : 6 + if(WEST) + return right ? -7 : -1 + if(NORTH) + return right ? 9 : -10 + return right ? -10 : 9 + +/// A wash takes the blood off, look and all. +/obj/item/melee/cyberware_monowire/proc/on_wash(datum/source, clean_types) + SIGNAL_HANDLER + if(!(clean_types & CLEAN_TYPE_BLOOD) || !(wet_until || stained_until)) + return NONE + clear_blood_look() + return COMPONENT_CLEANED + +/// The blood stops showing. Its DNA stays. +/obj/item/melee/cyberware_monowire/proc/clear_blood_look() + wet_until = 0 + stained_until = 0 + drips_left = 0 + if(drip_timer) + deltimer(drip_timer) + drip_timer = null + update_blood_look() + +/obj/item/melee/cyberware_monowire/update_overlays() + . = ..() + var/stage = blood_stage() + if(!stage) + return + var/mutable_appearance/blood = mutable_appearance(icon, "monowire_blood[stage]", appearance_flags = RESET_COLOR) + blood.color = get_blood_dna_color() || BLOOD_COLOR_RED + . += blood + +/obj/item/melee/cyberware_monowire/worn_overlays(mutable_appearance/standing, isinhands = FALSE, icon_file) + . = ..() + if(!isinhands || world.time < inhand_hidden_until) + return + var/stage = blood_stage() + if(!stage || !icon_exists(icon_file, "monowire_blood[stage]")) + return + var/mutable_appearance/blood = mutable_appearance(icon_file, "monowire_blood[stage]", appearance_flags = RESET_COLOR) + blood.color = get_blood_dna_color() || BLOOD_COLOR_RED + . += blood + +// tg's stain over the whole item would sit on the spool long after the wire has dried; the wire draws its own. +/datum/forensics/check_blood() + if(istype(parent, /obj/item/melee/cyberware_monowire)) + return + return ..() + +// ---- Out of the spool and back ---- + +/** + * The wire isn't drawn hanging in the hand for `duration`. With `spool` its spool still is: the wire is out of the hand + * as a line (a lash, the garrote's), which comes out of the spool. Without, nothing of it is: its swing out of the + * spool is being played, spool and all. + */ +/obj/item/melee/cyberware_monowire/proc/hide_inhand_for(duration, spool = FALSE) + // A shorter hide (a swing out of the spool) never cuts a longer one (a garrote's) short. + inhand_hidden_until = max(inhand_hidden_until, world.time + duration) + if(!spool) + inhand_bare_until = max(inhand_bare_until, world.time + duration) + // A hide that runs on past a swing's draws the spool from the end of the swing. + if(inhand_bare_until > world.time && inhand_bare_until < inhand_hidden_until) + addtimer(CALLBACK(src, PROC_REF(redraw_inhand)), inhand_bare_until - world.time, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_NO_HASH_WAIT) + var/mob/holder = loc + if(ismob(holder)) + holder.update_held_items() + addtimer(CALLBACK(src, PROC_REF(show_inhand)), inhand_hidden_until - world.time, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_NO_HASH_WAIT) + +/obj/item/melee/cyberware_monowire/proc/show_inhand() + if(!inhand_hidden_until) + return + inhand_hidden_until = 0 + inhand_bare_until = 0 + redraw_inhand() + +/obj/item/melee/cyberware_monowire/proc/redraw_inhand() + var/mob/holder = loc + if(ismob(holder)) + holder.update_held_items() + +// The wire is in the hand from the first tick; only its drawing waits for the swing, or for the line of it that is out. +/obj/item/melee/cyberware_monowire/build_worn_icon(default_layer = 0, default_icon_file = null, isinhands = FALSE, female_uniform = NO_FEMALE_UNIFORM, override_state = null, override_file = null) + if(!isinhands || world.time >= inhand_hidden_until) + return ..() + // Out of the hand as a line: the spool it comes out of stays. + var/spool_state = "[inhand_icon_state]_[default_icon_file == lefthand_file ? "left" : "right"]" + if(world.time >= inhand_bare_until && icon_exists(WIRE_SPOOL_ICON, spool_state)) + return ..(default_layer, default_icon_file, isinhands, female_uniform, spool_state, WIRE_SPOOL_ICON) + . = ..() + var/mutable_appearance/standing = . + standing.alpha = 0 + +/// "left" or "right": the hand `user` holds this wire in, or null. +/obj/item/melee/cyberware_monowire/proc/held_side(mob/living/user) + var/index = user?.get_held_index_of_item(src) + if(!index) + return null + return IS_LEFT_INDEX(index) ? "left" : "right" + +/** + * The pixel the wire leaves the `side` hand ("left" or "right") of `holder` from: the one the held wire's spool lights, + * where the wire comes out of it, for each facing (the bright pixel in the spool of the "monowire" states in + * cyberware_lefthand.dmi and cyberware_righthand.dmi; the far hand in profile shows no spool, only the hand's edge). + * By its lower left corner, in pixels from the middle of the tile: a line of wire is drawn from the middle of this + * pixel. Also whether that hand is behind the body as the body faces: the far hand in profile, and both hands of a body + * facing away. The hands hang at the hips; in profile the near hand is at the middle of the body and the far one just + * shows at its front edge. The garrote's wire leaves the same pixels. list(x, y, behind) + */ +/proc/wire_hand_point(mob/living/holder, side) + var/right = side != "left" + switch(holder.dir) + if(EAST) + return right ? list(-2, -3, FALSE) : list(4, -3, TRUE) + if(WEST) + return right ? list(-5, -3, TRUE) : list(1, -3, FALSE) + if(NORTH) + return right ? list(7, -3, TRUE) : list(-8, -3, TRUE) + return right ? list(-8, -3, FALSE) : list(7, -3, FALSE) + +/// The world layer for a line of wire leaving a hand: over the bodies, or under them for a hand behind its body. +/proc/wire_line_layer(behind) + return behind ? BELOW_MOB_LAYER : ABOVE_ALL_MOB_LAYER + +/** + * A segment of a line of wire drawn with Beam(). tg's segments all sit at ABOVE_ALL_MOB_LAYER whatever layer the beam + * is given (their picture inherits the segment's layer), so a line that has to pass behind a body takes its beam's. + */ +/obj/effect/ebeam/wire_line + +/obj/effect/ebeam/wire_line/Initialize(mapload, beam_owner) + . = ..() + // Turned to the bearing without smoothing, so the line stays one pixel wide. + appearance_flags |= PIXEL_SCALE + if(owner?.beam_layer) + layer = owner.beam_layer + +/// The overlay layer on its wielder for the wire swinging in a hand: over the hands, or under the whole body for +/// the far hand in profile, so the torso hides what passes behind it. +/proc/wire_swing_layer(mob/living/holder, side) + if(holder.dir & (EAST | WEST)) + var/list/hand = wire_hand_point(holder, side) + if(hand[3]) + return -(TOTAL_LAYERS + 0.5) + return WIRE_SWING_LAYER + +/** + * The pixel the `zone` part of `body` is drawn on, by its lower left corner in pixels from the middle of its tile: as + * it stands and faces (wire_part_offset()), turned with it when it lies, then moved by its offsets. list(x, y) + */ +/proc/wire_zone_point(mob/living/body, zone) + var/list/at = wire_part_offset(zone, body.dir) + var/matrix/shape = body.transform + // The pixel its middle lands in. + var/middle_x = at[1] + 0.5 + var/middle_y = at[2] + 0.5 + return list(floor(shape.a * middle_x + shape.b * middle_y + shape.c) + body.pixel_x, floor(shape.d * middle_x + shape.e * middle_y + shape.f) + body.pixel_y) + +/** + * The pixel of the `zone` part of a standing human body facing `facing` that a line of wire lands on, by its lower left + * corner in pixels from the middle of its tile. An arm or leg: the pixel in the middle of the cut across its shoulder + * or hip, the middle of the "wire_cut_" seam's line, where the limb comes away. The body's right is the screen's + * left facing south and its right facing north. Side on, the far arm and leg (wire_limb_far()) are hidden behind the + * near ones, the leg drawn a pixel ahead of it; the chest is the middle of the torso. list(x, y) + */ +/proc/wire_part_offset(zone, facing) + switch(zone) + if(BODY_ZONE_HEAD) + return list(-1, 9) + if(BODY_ZONE_R_ARM, BODY_ZONE_L_ARM) + switch(facing) + if(EAST) + return list(-3, 3) + if(WEST) + return list(2, 3) + // Facing north the body's right is on the screen's right. + var/screen_right = (zone == BODY_ZONE_R_ARM) == (facing == NORTH) + return list(screen_right ? 5 : -7, 1) + if(BODY_ZONE_R_LEG, BODY_ZONE_L_LEG) + switch(facing) + if(EAST) + return list(zone == BODY_ZONE_R_LEG ? 0 : 1, -9) + if(WEST) + return list(zone == BODY_ZONE_L_LEG ? 0 : -1, -9) + var/screen_right = (zone == BODY_ZONE_R_LEG) == (facing == NORTH) + return list(screen_right ? 2 : -4, -7) + return list(facing == WEST ? 0 : -1, -1) + +/** + * A landed swing: the wire lashes from the hand holding it to the part of `target` it cut (`zone`, else the part the + * wielder aimed at), ending on the shoulder or hip of a limb it takes off (wire_zone_point()): one straight thin line in + * its own colour that fades out over half a second. It is the wire: the one hanging in the hand isn't drawn until the + * line fades (wire_lash_hide()). A stretched line, not tg's Beam(): a beam's segments are drawn over every body + * whatever layer they are given, and this one must pass behind some. `cross`: this wire's half of a crossing cut, + * which runs on through the middle of the chest so that it crosses the other hand's there (also set for the next lash + * by wire_cross_lash()). The line starts where the hand rests and doesn't follow it through tg's lunge + * (do_attack_animation()): a client plays that lean already under way when it sees it, and plays the new line from its + * start, so a line moved along with the lean ran ahead of the hand and stopped short of it. + * + * The map draws whatever stands lower on the screen (its tile plus pixel_y) over what stands higher, whatever the + * layer, and orders things level with each other by layer. The line is drawn in two pieces that meet where it leaves + * the wielder's tile, each sorted against its own body, a few pixels in front of it or behind it: + * - The hand's piece, on the wielder's tile: over him from a hand in front of his body, under him from one behind it + * (the far hand side on, both hands facing away). + * - The target's piece, on the target's tile: under the target where the line meets it behind its body + * (wire_lash_behind()), else over it. Up a row from the wielder, a piece over a leg goes at once, as the line snaps + * through it: left on, it runs along the leg and paints it. + * From a wielder facing the viewer, a line that would slant across his own legs lands out to the hand's side on the + * limb it cuts, if it can clear them there (wire_lash_clear_legs()). + * + * The line runs from the middle of the pixel the wire leaves the hand from (wire_hand_point()) to the middle of the + * pixel it lands on (wire_zone_point()), and covers both, whichever way it runs. Both pieces are cut from that one + * line (wire_lash_shape()), so they meet without a step; only the target's piece carries the wire's bright end. + * + * A swing that carried on into someone standing right behind its target draws wire_lash_through() instead. + */ +/// How fast the piece of a lash that runs along a leg beyond the wielder goes. +#define WIRE_LASH_SNAP_FADE (0.25 SECONDS) +/// How far past the middle of the chest each line of a crossing cut runs, in pixels. +#define WIRE_CROSS_PAST 6 +/// tg's lunge moves the wielder up to 8 pixels along pixel_y, which moves him in the map's front-to-back order: the +/// hand's piece sorts this far in front of him (or behind), so a lean toward or away from the viewer never crosses it. +#define WIRE_LASH_ROW_HAND 9 +/// The target's piece sorts this far in front of the target (or behind): a body lying down is drawn a few pixels lower +/// (tg's lying offset), and so in front of anything placed level with its tile. +#define WIRE_LASH_ROW_TARGET 4 +/// The line starts this far before the middle of the pixel it leaves the hand from, so that pixel is always drawn. +#define WIRE_LASH_BACK 0.5 + +/obj/item/melee/cyberware_monowire/proc/wire_lash_at(mob/living/user, atom/target, zone, cross = FALSE) + var/turf/from = get_turf(user) + var/turf/hit = get_turf(target) + cross = cross || lash_crossing + lash_crossing = FALSE + var/mob/living/through = lash_through?.resolve() + lash_through = null + if(!from || !hit || from == hit || from.z != hit.z) + return + // The swing carried on into someone right behind its target: the one line runs on to them, past a limb it took off + // or the middle of a crossing cut, so they see what cut them. The other wire of a crossing cut still crosses. + if(through && isliving(target) && wire_lash_through(user, target, through)) + return + zone = zone || check_zone(user.zone_selected) + var/list/hand = wire_hand_point(user, held_side(user) || "right") + // The pixel the line leaves and the pixel it lands on, by their lower left corners: the first from the middle of the + // wielder's tile, the second from the middle of the target's. + var/hand_x = user.pixel_x + hand[1] + var/hand_y = user.pixel_y + hand[2] + var/tile_x = (hit.x - from.x) * ICON_SIZE_X + var/tile_y = (hit.y - from.y) * ICON_SIZE_Y + var/end_x = target.pixel_x + var/end_y = target.pixel_y + var/behind = FALSE + if(isliving(target)) + var/list/part = wire_zone_point(target, cross ? BODY_ZONE_CHEST : zone) + end_x = part[1] + end_y = part[2] + behind = wire_lash_behind(user, target, zone, hand[3], cross) + if(cross) + var/run_x = tile_x + end_x - hand_x + var/run_y = tile_y + end_y - hand_y + var/run = max(sqrt(run_x ** 2 + run_y ** 2), 1) + end_x += round(run_x * WIRE_CROSS_PAST / run) + end_y += round(run_y * WIRE_CROSS_PAST / run) + else if(hit.y < from.y && user.dir == SOUTH && user.body_position != LYING_DOWN) + end_x = wire_lash_clear_legs(user, hand_x, hand_y + 0.5, tile_x + end_x, tile_y + end_y + 0.5) - tile_x + wire_lash_hide(user) + // From the middle of the one pixel to the middle of the other. + var/span_x = tile_x + end_x - hand_x + var/span_y = tile_y + end_y - hand_y + var/length = sqrt(span_x ** 2 + span_y ** 2) + if(length < 1) + return + // How far along it leaves the wielder's tile: by its side beside him, else by its foot or head. + var/along = 1 + if(hit.y == from.y) + if(span_x) + along = (SIGN(tile_x) * ICON_SIZE_X / 2 - (hand_x + 0.5)) / span_x + else if(span_y) + along = (SIGN(tile_y) * ICON_SIZE_Y / 2 - (hand_y + 0.5)) / span_y + along = clamp(along, 0, 1) + // The hand's piece: from just before the middle of the hand's pixel, so that pixel is always drawn, to the edge. + var/hand_row = user.pixel_y + (hand[3] ? WIRE_LASH_ROW_HAND : -WIRE_LASH_ROW_HAND) + if(along * length >= 0.5) + wire_line_piece(from, hand_x, hand_y, wire_lash_shape(span_x, span_y, -WIRE_LASH_BACK, along * length, 0.5, 0.5), lash_run_state(), wire_line_layer(hand[3]), hand_row) + // The target's piece: on from the edge, to just past the middle of the pixel it lands on. It is placed on the pixel + // the edge point falls in, and the rest of the way to that point is in its shape, so the two pieces are one line. + var/edge_x = hand_x + 0.5 + span_x * along - tile_x + var/edge_y = hand_y + 0.5 + span_y * along - tile_y + var/base_x = floor(edge_x) + var/base_y = floor(edge_y) + var/snap = hit.y > from.y && !behind && !cross && (zone == BODY_ZONE_L_LEG || zone == BODY_ZONE_R_LEG) + var/target_row = target.pixel_y + (behind ? WIRE_LASH_ROW_TARGET : -WIRE_LASH_ROW_TARGET) + wire_line_piece(hit, base_x, base_y, wire_lash_shape(span_x, span_y, 0, (1 - along) * length + 0.5, edge_x - base_x, edge_y - base_y), lash_state(), behind ? BELOW_MOB_LAYER : ABOVE_MOB_LAYER, target_row, fade = snap ? WIRE_LASH_SNAP_FADE : WIRE_LASH_FADE) + +/** + * The lash of a swing that carried on through `target` into `behind`, standing right behind it (wire_cleave()): the one + * line runs on, straight from the hand to the middle of `behind`'s chest, the last part it cut, through `target` on the + * way. No light of its own and no line of blood: it is the wire. Cut from one line like any lash (wire_lash_shape()), + * in four pieces, each sorted against its own body: + * - The hand's piece, on the wielder's tile, as in any lash. + * - On `target`'s tile, up to where the line passes its chest: over it, or under one standing nearer the viewer than + * the wielder, met on its far side (wire_lash_behind()). + * - On from there to the edge of `behind`'s tile the wire has gone through `target` and out of its other side: under + * it where it went in over it, over it where it went in under it. Inside a body or behind one, it isn't seen. Over + * a body lying on the floor all the way. + * - On `behind`'s tile, to its chest, with the wire's bright end: over it or under it by the same rule. + * Returns FALSE, with nothing drawn, if the three don't stand so that a line can run through them in that order. + */ +/obj/item/melee/cyberware_monowire/proc/wire_lash_through(mob/living/user, mob/living/target, mob/living/behind) + var/list/line = wire_through_line(user, target, behind) + if(!line) + return FALSE + var/turf/from = get_turf(user) + var/turf/first = get_turf(target) + var/turf/last = get_turf(behind) + var/list/hand = wire_hand_point(user, held_side(user) || "right") + var/start_x = line[1] + var/start_y = line[2] + var/span_x = line[3] + var/span_y = line[4] + var/length = line[5] + var/leaves = line[6] + var/passes = line[7] + var/enters = line[8] + // The hand's pixel, by its lower left corner. + var/hand_x = start_x - 0.5 + var/hand_y = start_y - 0.5 + wire_lash_hide(user) + if(leaves >= 0.5) + wire_line_piece(from, hand_x, hand_y, wire_lash_shape(span_x, span_y, -WIRE_LASH_BACK, leaves, 0.5, 0.5), lash_run_state(), wire_line_layer(hand[3]), user.pixel_y + (hand[3] ? WIRE_LASH_ROW_HAND : -WIRE_LASH_ROW_HAND)) + var/under = wire_lash_behind(user, target, BODY_ZONE_CHEST, hand[3], FALSE) + var/under_after = target.body_position == LYING_DOWN ? under : !under + wire_lash_stretch(first, from, start_x, start_y, span_x, span_y, length, leaves, passes, lash_run_state(), under, target.pixel_y) + wire_lash_stretch(first, from, start_x, start_y, span_x, span_y, length, passes, enters, lash_run_state(), under_after, target.pixel_y) + wire_lash_stretch(last, from, start_x, start_y, span_x, span_y, length, enters, length + 0.5, lash_state(), wire_lash_behind(user, behind, BODY_ZONE_CHEST, hand[3], FALSE), behind.pixel_y) + return TRUE + +/** + * The line a through-cut's lash runs along (wire_lash_through()): straight from the middle of the pixel the wire leaves + * `user`'s hand from to the middle of the pixel in the middle of `behind`'s chest, through `target` on the way. Null if + * the three don't stand so that a line can run through them in that order. list(start_x, start_y, span_x, span_y, + * length, leaves, passes, enters): where it starts and how far it runs, in pixels from the middle of the wielder's + * tile, its length, and how far along it, in pixels, it leaves the wielder's tile, passes the first body's chest and + * enters the second's tile. The wire's through-cut picks who it carries into by this same line (wire_through_target()). + */ +/obj/item/melee/cyberware_monowire/proc/wire_through_line(mob/living/user, mob/living/target, mob/living/behind) + var/turf/from = get_turf(user) + var/turf/first = get_turf(target) + var/turf/last = get_turf(behind) + if(QDELETED(behind) || !from || !first || !last || from.z != first.z || from.z != last.z || from == first || first == last || from == last) + return null + // The second body stands straight on along the swing: the step from the first body to it runs the same way as the + // way from the wielder to the first body. A swing at a knight's move has no body straight behind its target. + var/reach_x = first.x - from.x + var/reach_y = first.y - from.y + var/past_x = last.x - first.x + var/past_y = last.y - first.y + if(reach_x * past_y != reach_y * past_x || reach_x * past_x + reach_y * past_y <= 0) + return null + var/list/hand = wire_hand_point(user, held_side(user) || "right") + var/hand_x = user.pixel_x + hand[1] + var/hand_y = user.pixel_y + hand[2] + // The pixel it passes on the first body and the pixel it lands on, by their lower left corners from the middle of + // each body's own tile; the tiles, from the middle of the wielder's. + var/list/chest = wire_zone_point(target, BODY_ZONE_CHEST) + var/list/end = wire_zone_point(behind, BODY_ZONE_CHEST) + var/first_x = (first.x - from.x) * ICON_SIZE_X + var/first_y = (first.y - from.y) * ICON_SIZE_Y + var/last_x = (last.x - from.x) * ICON_SIZE_X + var/last_y = (last.y - from.y) * ICON_SIZE_Y + // From the middle of the hand's pixel to the middle of the one it lands on. + var/start_x = hand_x + 0.5 + var/start_y = hand_y + 0.5 + var/span_x = last_x + end[1] - hand_x + var/span_y = last_y + end[2] - hand_y + var/length = sqrt(span_x ** 2 + span_y ** 2) + if(length < 1) + return null + var/leaves = length * wire_line_crosses(start_x, start_y, span_x, span_y, first.y == from.y, SIGN(first_x) * ICON_SIZE_X / 2, SIGN(first_y) * ICON_SIZE_Y / 2) + var/enters = length * wire_line_crosses(start_x, start_y, span_x, span_y, last.y == first.y, last_x - SIGN(last_x - first_x) * ICON_SIZE_X / 2, last_y - SIGN(last_y - first_y) * ICON_SIZE_Y / 2) + if(enters < leaves) + return null + var/passes = clamp(((first_x + chest[1] - hand_x) * span_x + (first_y + chest[2] - hand_y) * span_y) / length, leaves, enters) + return list(start_x, start_y, span_x, span_y, length, leaves, passes, enters) + +/** + * Where a through-cut's line (wire_through_line()) cuts the two bodies: the pixel it passes on `target`, level with the + * middle of its chest, and the pixel it ends on in the middle of `behind`'s chest, each by its lower left corner from + * the middle of that body's own tile. Their blood leaves from there (wire_through_fx()). list(list(x, y), list(x, y)), + * or null if no line runs through the three. + */ +/obj/item/melee/cyberware_monowire/proc/wire_through_cuts(mob/living/user, mob/living/target, mob/living/behind) + var/list/line = wire_through_line(user, target, behind) + if(!line) + return null + var/turf/from = get_turf(user) + var/turf/first = get_turf(target) + var/along = line[7] / line[5] + var/pass_x = line[1] + line[3] * along - (first.x - from.x) * ICON_SIZE_X + var/pass_y = line[2] + line[4] * along - (first.y - from.y) * ICON_SIZE_Y + return list(list(floor(pass_x), floor(pass_y)), wire_zone_point(behind, BODY_ZONE_CHEST)) + +/** + * One stretch of a lash's line beyond the wielder's tile, from `from_length` to `to_length` pixels along it, on the + * tile `where` of the body it is sorted against: `under` it or over it, `row` being that body's pixel_y. The line + * starts (`start_x`, `start_y`) from the middle of the wielder's tile `from` and runs (`span_x`, `span_y`), `length` + * long. The piece is placed on the pixel its first point falls in, and the rest of the way to that point is in its + * shape, so that consecutive stretches are one line (wire_lash_shape()). + */ +/obj/item/melee/cyberware_monowire/proc/wire_lash_stretch(turf/where, turf/from, start_x, start_y, span_x, span_y, length, from_length, to_length, state, under, row) + if(to_length - from_length < 0.5) + return + var/at_x = start_x + span_x * from_length / length - (where.x - from.x) * ICON_SIZE_X + var/at_y = start_y + span_y * from_length / length - (where.y - from.y) * ICON_SIZE_Y + var/base_x = floor(at_x) + var/base_y = floor(at_y) + wire_line_piece(where, base_x, base_y, wire_lash_shape(span_x, span_y, 0, to_length - from_length, at_x - base_x, at_y - base_y), state, under ? BELOW_MOB_LAYER : ABOVE_MOB_LAYER, row + (under ? WIRE_LASH_ROW_TARGET : -WIRE_LASH_ROW_TARGET)) + +/// How far along a line from (`start_x`, `start_y`) running (`span_x`, `span_y`) it crosses the edge between two tiles: +/// the upright edge at `edge_x` for tiles side by side (`level`), else the level one at `edge_y`. From 0 to 1. +/proc/wire_line_crosses(start_x, start_y, span_x, span_y, level, edge_x, edge_y) + if(level) + return span_x ? clamp((edge_x - start_x) / span_x, 0, 1) : 1 + return span_y ? clamp((edge_y - start_y) / span_y, 0, 1) : 1 + +#undef WIRE_LASH_SNAP_FADE +#undef WIRE_CROSS_PAST +#undef WIRE_LASH_ROW_HAND +#undef WIRE_LASH_ROW_TARGET +#undef WIRE_LASH_BACK + +/** + * A stretch of a lash's line, as a transform for one of its pieces (the "wire_lash" states of WIRE_GORE_ICON: half a + * tile of line running up from the middle of the icon, a half pixel left of it). The whole line runs from a point + * toward one (`span_x`, `span_y`) away; this piece is the stretch from `from_length` to `to_length` pixels along it, + * the point itself being (`at_x`, `at_y`) from the lower left corner of the pixel the piece is placed on: (0.5, 0.5) + * for the middle of that pixel. Two pieces of one line given the same bearing and consecutive stretches meet exactly. + */ +/proc/wire_lash_shape(span_x, span_y, from_length, to_length, at_x, at_y) + var/matrix/shape = matrix() + shape.Translate(0.5, 0) + shape.Scale(1, max(to_length - from_length, 0.5) / 16) + shape.Translate(0, from_length) + shape.Turn(arctan(span_y, span_x)) + shape.Translate(at_x, at_y) + return shape + +/** + * Whether a lash from `user` meets `body` behind it, so its end is drawn under the body: + * - A body standing nearer the viewer than the wielder (a row down the screen) is met on its far side, whatever way it + * faces: the line runs down from the hand to its outline and on behind it, its head, back and other leg, to the part + * it cuts. A crossing cut's two wires cross behind it too. + * - Side on, an arm or leg on the far side of a standing body (wire_limb_far()), behind the near limbs and the torso. + * In a crossing cut, the wire from the wielder's far hand side on (`hand_behind`) runs through behind the near + * hand's, under both bodies. + * - A body further off than the wielder is met on the side facing the viewer: over it. So is one lying on the floor. + */ +/proc/wire_lash_behind(mob/living/user, mob/living/body, zone, hand_behind, cross) + var/turf/body_turf = get_turf(body) + var/turf/user_turf = get_turf(user) + if(body.body_position != LYING_DOWN && body_turf && user_turf && body_turf.y < user_turf.y) + return TRUE + if(cross) + return hand_behind && (user.dir & (EAST | WEST)) + return body.body_position != LYING_DOWN && wire_limb_far(zone, body.dir) + +/** + * While its lash shows, the wire hanging in the hand isn't drawn, whichever way `user` faces: the line out of the grip + * is the wire, out to the target. It is back as the line fades, never both at once and never neither. Its spool stays + * in the hand: the line comes out of it. Every lash goes through here (wire_lash_at()): an ordinary swing, the aimed + * sever, the Arc's, and both halves of a crossing cut, each wire for its own hand. A longer hide already running (the + * swing out of the spool, the garrote) is left as it is. + */ +/obj/item/melee/cyberware_monowire/proc/wire_lash_hide(mob/living/user) + if(inhand_hidden_until >= world.time + WIRE_LASH_HIDE) + return + hide_inhand_for(WIRE_LASH_HIDE, spool = TRUE) + +/// The middle of a body facing the viewer, in pixels from the middle of its tile as a lash's line is placed: tg draws +/// bodies a pixel left of the tile's middle. +#define WIRE_BODY_MIDDLE -1 +/// A lash's line keeps at least this far off that middle down the trouser legs (rows 6 to 13 below the tile's middle)... +#define WIRE_CLEAR_TROUSERS 5.75 +/// ...and this far down the shoes (rows 14 to 16), which stand wider. Either way its soft edge stays off them. +#define WIRE_CLEAR_SHOES 6.7 +/// A lash's end moves no further than this to clear the legs: it still lands on the shoulder or hip it cuts. +#define WIRE_CLEAR_REACH 3 + +/** + * Where across a lash from a hand at (`hand_x`, `hand_y`) to a body a row down lands, given that it would land at + * (`end_x`, `end_y`) (all in pixels off the middle of the wielder's tile), so that it runs down beside the legs of a + * wielder facing the viewer, not across them: moved out to the hand's side as far as it has to go and no further. One + * that can't clear them without landing more than WIRE_CLEAR_REACH off the limb's joint, a limb across the body from + * the hand, is left where it was: the line goes to the limb that comes off. + */ +/proc/wire_lash_clear_legs(mob/living/user, hand_x, hand_y, end_x, end_y) + var/span_y = end_y - hand_y + if(span_y >= 0) + return end_x + var/middle = user.pixel_x + WIRE_BODY_MIDDLE + var/side = hand_x < middle ? -1 : 1 + var/span_x = end_x - hand_x + // Each band's top and bottom rows (a straight line is furthest in at one of them), and how far off the middle it keeps. + var/static/list/bands = list(list(-6, -13, WIRE_CLEAR_TROUSERS), list(-14, -16, WIRE_CLEAR_SHOES)) + for(var/list/band as anything in bands) + for(var/row in list(band[1], band[2])) + // How far along the line that row's middle is. + var/along = (user.pixel_y + row + 0.5 - hand_y) / span_y + if(along <= 0 || along > 1) + continue + var/most = (middle + side * band[3] - hand_x) / along + span_x = side < 0 ? min(span_x, most) : max(span_x, most) + var/cleared = hand_x + span_x + if(abs(cleared - end_x) > WIRE_CLEAR_REACH) + return end_x + return cleared + +#undef WIRE_BODY_MIDDLE +#undef WIRE_CLEAR_TROUSERS +#undef WIRE_CLEAR_SHOES +#undef WIRE_CLEAR_REACH + +/** + * One straight piece of a lash on `where`: placed on the pixel (`base_x`, `base_y`) off the middle of that tile (its + * lower left corner), drawn as `shape` (wire_lash_shape()) in `state`, at world `line_layer`; it fades out over `fade`. + * Over the usual WIRE_LASH_FADE it is down to a trace as the wire comes back into the hand (wire_lash_hide()) and + * holds that until it goes: both are the server's timers, so a server running behind keeps the line in the hand until + * the wire is drawn. It is placed with pixel_w and pixel_z, which only move the picture; `row` (pixel_y) is where it + * sorts among the things on its tile's row, which the map orders front to back before it looks at layers + * (wire_lash_at()). + */ +/obj/item/melee/cyberware_monowire/proc/wire_line_piece(turf/where, base_x, base_y, matrix/shape, state, line_layer, row = 0, fade = WIRE_LASH_FADE) + if(!where || !shape) + return + var/obj/effect/abstract/wire_reach/lash = new(where) + lash.icon_state = state + lash.layer = line_layer + lash.add_overlay(emissive_appearance(lash.icon, lash.icon_state, lash)) + lash.pixel_y = row + lash.pixel_w = base_x + lash.pixel_z = base_y - row + lash.transform = shape + if(fade == WIRE_LASH_FADE) + animate(lash, alpha = WIRE_LASH_TRACE, time = WIRE_LASH_HIDE, easing = QUAD_EASING | EASE_IN) + else + animate(lash, alpha = 0, time = fade, easing = QUAD_EASING | EASE_IN) + QDEL_IN(lash, fade) + +/// The line of a lash that ends on what it hit: the wire's bright end at its far end. +/obj/item/melee/cyberware_monowire/proc/lash_state() + return "wire_lash" + +/obj/item/melee/cyberware_monowire/live/lash_state() + return "wire_lash_live" + +/// The line of a lash that runs on into another piece: no bright end. +/obj/item/melee/cyberware_monowire/proc/lash_run_state() + return "wire_lash_run" + +/obj/item/melee/cyberware_monowire/live/lash_run_state() + return "wire_lash_run_live" + +/// The light at the spool while the wire runs out or snaps back: the wire's own colour. +/obj/item/melee/cyberware_monowire/proc/spool_light_color() + return "#f86cfa" + +/obj/item/melee/cyberware_monowire/live/spool_light_color() + return "#7fe0ff" + +/// The wire swings out of the spool into the hand. +/obj/item/melee/cyberware_monowire/proc/play_deploy(mob/living/user) + var/side = held_side(user) + if(!side) + return + cyberware_anim_play(user, WIRE_HELD_ANIM_ICON, "[icon_state]_deploy_[side]", wire_swing_layer(user, side), WIRE_SWING_TIME) + hide_inhand_for(WIRE_SWING_TIME) + user.mob_light(1.5, 0.6, spool_light_color(), 0.3 SECONDS) + +/// The wire reels back into the spool from the `side` hand. A wet wire cracks its blood off first. +/obj/item/melee/cyberware_monowire/proc/play_retract(mob/living/user, side, stage) + if(QDELETED(user) || !side) + return + var/swing_layer = wire_swing_layer(user, side) + cyberware_anim_play(user, WIRE_HELD_ANIM_ICON, "[icon_state]_retract_[side]", swing_layer, WIRE_SWING_TIME) + user.mob_light(1.5, 0.6, spool_light_color(), 0.3 SECONDS) + if(stage) + var/obj/effect/abstract/cyberware_anim/blood = cyberware_anim_play(user, WIRE_HELD_ANIM_ICON, "monowire_retract_blood[stage]_[side]", swing_layer + 0.05, WIRE_SWING_TIME) + if(blood) + blood.appearance_flags |= RESET_COLOR + blood.color = get_blood_dna_color() || BLOOD_COLOR_RED + if(stage >= 2) + flick_blood(user, side) + clear_blood_look() + +/** + * The fan a wet wire throws as it cracks back into the spool: WIRE_FLICK_DROPS drops leave its tip, fly an arc + * and land spread over the floor ahead and to the sides, each as a drip. Drawn on temporary visuals; only the + * drips stay. + */ +/obj/item/melee/cyberware_monowire/proc/flick_blood(mob/living/user, side) + var/list/blood_dna = GET_ATOM_BLOOD_DNA(src) + var/turf/feet = get_turf(user) + if(!length(blood_dna) || !feet || !feet.has_gravity()) + return + var/blood_color = get_blood_dna_color() || BLOOD_COLOR_RED + for(var/list/drop as anything in wire_fan_plan(user.dir, side)) + new /obj/effect/temp_visual/wire_blood_drop(feet, drop, blood_color, blood_dna) + +/** + * Where each drop of the fan starts and lands, in pixels from the middle of the wielder's tile: + * list(start x, start y, land x, land y, arc height, flight time). It leaves the wire's tip, which hangs by the + * `side` hand ("left" or "right"), and lands up to a tile and a bit ahead of `facing`, spread to both sides. + */ +/proc/wire_fan_plan(facing, side) + . = list() + var/forward_x = (facing & EAST) ? 1 : ((facing & WEST) ? -1 : 0) + var/forward_y = (facing & NORTH) ? 1 : ((facing & SOUTH) ? -1 : 0) + if(!forward_x && !forward_y) + forward_y = -1 + // The tip hangs by the hand: screen left or right of the body facing north or south, in front of it in profile. + var/start_x = forward_x * 3 + if(!forward_x) + var/screen_left = (side == "right") == (facing != NORTH) + start_x = screen_left ? -6 : 6 + var/start_y = -13 + var/bearing = forward_x ? (forward_x > 0 ? 90 : 270) : (forward_y > 0 ? 0 : 180) + // Spread evenly over a cone ahead and over the reach, each with some give, and dealt out at random so that no two + // neighbours in the cone are also neighbours in reach: the drops land as a scatter, never a row or a line. + var/list/reaches = list() + for(var/i in 1 to WIRE_FLICK_DROPS) + reaches += 12 + round(24 * i / WIRE_FLICK_DROPS) + shuffle_inplace(reaches) + var/slice = 90 / WIRE_FLICK_DROPS + for(var/i in 1 to WIRE_FLICK_DROPS) + var/angle = bearing - 45 + slice * (i - 0.5) + rand(-slice, slice) / 2 + var/reach = reaches[i] + rand(-3, 3) + var/land_x = start_x + round(sin(angle) * reach) + rand(-3, 3) + var/land_y = start_y + round(cos(angle) * reach) + rand(-3, 3) + // Facing away, every drop lands past the head, ahead of him: on the floor beside it, it reads as blood by his ear. + if(forward_y > 0) + land_y = max(land_y, (abs(land_x) < 10 ? 26 : 22) + rand(0, 6)) + var/height = 5 + rand(0, 6) + var/flight = round(2 + reach / 12, 0.5) + . += list(list(start_x, start_y, land_x, land_y, height, flight)) + +/// One drop of the fan in flight. It lands as a drip, unless where it lands has no floor to hold it. +/obj/effect/temp_visual/wire_blood_drop + name = "blood" + icon = WIRE_GORE_ICON + icon_state = "wire_drop" + layer = ABOVE_MOB_LAYER + randomdir = FALSE + duration = 0.6 SECONDS + +/obj/effect/temp_visual/wire_blood_drop/Initialize(mapload, list/drop, blood_color, list/blood_dna, list/viruses) + var/start_x = drop[1] + var/start_y = drop[2] + var/land_x = drop[3] + var/land_y = drop[4] + var/height = drop[5] + var/flight = drop[6] + // Held back a beat (a 7th entry, else the flick's): the flick's drops leave on the crack, the retract's second frame. + var/crack = length(drop) >= 7 ? drop[7] : 0.5 + duration = crack + flight + . = ..() + // Thrown away from the viewer, it flies behind whoever it leaves, not over their head. An 8th entry says so outright, + // for drops that leave from above the floor; else it is read from where it lands. + if(length(drop) >= 8 ? drop[8] : (land_y > start_y + 2)) + layer = BELOW_MOB_LAYER + color = blood_color + pixel_x = start_x + pixel_y = start_y + alpha = 0 + if(crack) + animate(src, alpha = 0, time = crack) + animate(alpha = 255, pixel_x = (start_x + land_x) / 2, pixel_y = max(start_y, land_y) + height, time = flight / 2, easing = SINE_EASING | EASE_OUT) + else + alpha = 255 + animate(src, pixel_x = (start_x + land_x) / 2, pixel_y = max(start_y, land_y) + height, time = flight / 2, easing = SINE_EASING | EASE_OUT) + animate(pixel_x = land_x, pixel_y = land_y, time = flight / 2, easing = SINE_EASING | EASE_IN) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_drop_land), get_turf(src), land_x, land_y, blood_dna, viruses), duration - 0.1) + +/// A drop of the fan comes down at (`land_x`, `land_y`) pixels from the middle of `origin`. +/proc/wire_drop_land(turf/origin, land_x, land_y, list/blood_dna, list/viruses) + if(!origin) + return + var/tile_x = floor((land_x + 16) / 32) + var/tile_y = floor((land_y + 16) / 32) + var/turf/landing = locate(origin.x + tile_x, origin.y + tile_y, origin.z) + if(!landing || isgroundlessturf(landing) || !landing.has_gravity() || (landing != origin && hv_blood_spray_blocked(landing))) + return + var/obj/effect/decal/cleanable/blood/drip/wire_flick/drop = new(landing, viruses, blood_dna) + if(QDELETED(drop)) + return + drop.wire_place(land_x - tile_x * 32, land_y - tile_y * 32) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/Extend(obj/item/augment) + . = ..() + var/obj/item/melee/cyberware_monowire/wire = active_item + if(istype(wire) && owner?.is_holding(wire)) + wire.play_deploy(owner) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/Retract() + var/mob/living/carbon/stowing_owner = owner + var/obj/item/melee/cyberware_monowire/wire = active_item + var/side + var/stage = 0 + if(istype(wire) && stowing_owner?.is_holding(wire)) + side = wire.held_side(stowing_owner) + stage = wire.blood_stage() + . = ..() + if(. && side && !QDELETED(wire)) + wire.play_retract(stowing_owner, side, stage) + +/// A drop of the fan. Each stays where it fell instead of pooling with the others on its tile; a fan is a handful. +/obj/effect/decal/cleanable/blood/drip/wire_flick + mergeable_decal = FALSE + +/// Puts the drop's blood, not its picture, at (`x`, `y`) pixels off the middle of its tile: each of tg's drop +/// pictures sits off the middle its own way, by up to eight pixels. +/obj/effect/decal/cleanable/blood/drip/wire_flick/proc/wire_place(x, y) + var/static/list/offsets = list("drip1" = list(-2, 0), "drip2" = list(4, -1), "drip3" = list(6, -5), "drip4" = list(1, -8), "drip5" = list(-6, -6)) + var/list/offset = offsets[icon_state] || list(0, 0) + pixel_x = x - offset[1] + pixel_y = y - offset[2] + // tg's five drops are all one size of blob. These land smaller or larger, turned and flipped, about their own middle. + var/size = pick(0.5, 0.75, 1, 1, 1.25) + var/matrix/shape = matrix() + shape.Translate(-offset[1], -offset[2]) + shape.Scale(size * pick(-1, 1), size) + shape.Turn(pick(0, 90, 180, 270)) + shape.Translate(offset[1], offset[2]) + transform = shape + appearance_flags |= PIXEL_SCALE diff --git a/voidcrew/modules/hyperviolence/wire/wire_seams.dm b/voidcrew/modules/hyperviolence/wire/wire_seams.dm new file mode 100644 index 00000000000..0e7e6f3f3d2 --- /dev/null +++ b/voidcrew/modules/hyperviolence/wire/wire_seams.dm @@ -0,0 +1,275 @@ +// Widowline x hyperviolence: the hooks the wire needs in the gore parts, chained here rather than edited +// into them. Everything a wire sever changes about blood and stumps is in this file: +// - A clean cut (TRAIT_HV_CLEAN_CUT, held only while a wire's damage is being applied) throws no flying +// hitsplatter, no heavy-hit or crit spray and no puff off a wound it reopens, puts no blood on the floor or on +// the wielder at the hit. The wounds and the blood lost are tg's as ever. A limb it takes +// off bleeds when it slides off (wire_sever_fx.dm); otherwise the wound bleeds as any does. +// - tg's own wound roll never tears a limb off mid wire cut; the wire takes that limb off clean after. +// - A limb taken by the wire sprays nothing when it leaves (hv_sever_spray); the wire lays its own streak. +// - Nor does its body reel, flash or lurch as the animation pass has a lost limb do (hv_vis_on_limb_lost()). +// - A wire stump can be held back for the beat the severed arm is still drawn on, and can be seared shut. +// - A neck the wire took the head off shows its own stump: a clean flat cut, not #509's ragged one. +// - hv_wire_take_part(): tg's dismemberment without the throw and the fan of blood. + +/mob/living + /// While not null, a limb coming off throws no spray of its own (blood/blood_spray.dm). Set around a wire sever. + var/hv_sever_spray + /// A limb tg's wound roll would have torn off during a wire cut. The wire takes it off clean once the hit is done. + var/obj/item/bodypart/hv_wire_owed_sever + +/mob/living/carbon + /// Body zone -> world.time its stump may be drawn. A wire cut holds the stump back while the limb still shows. Lazy. + var/list/hv_stump_reveal_at + /// Body zones whose stump a hot wire seared shut. Lazy. + var/list/hv_stump_burnt + /// Body zones a wire cut through, whose stump is drawn with the wire's own art (GLOB.hv_wire_stump_zones). Lazy. + var/list/hv_stump_wire_cut + +/// The stumps the wire has its own art for: "stump__wire_blood" and "stump__wire_bone" in WIRE_GORE_ICON. +/// Only the neck the garrote cuts; every other stump, and a head taken any other way, keeps #509's. +GLOBAL_LIST_INIT(hv_wire_stump_zones, list(BODY_ZONE_HEAD)) + +// ---- Clean cuts ---- + +/mob/living/carbon/spray_blood(splatter_direction, splatter_strength = 3) + if(HAS_TRAIT(src, TRAIT_HV_CLEAN_CUT)) + return + return ..() + +/mob/living/hv_blood_on_damaged(datum/source, damage_dealt, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item, wound_clothing) + SIGNAL_HANDLER + if(HAS_TRAIT(src, TRAIT_HV_CLEAN_CUT)) + return + return ..() + +/mob/living/add_splatter_floor(turf/splatter_turf, small_drip = FALSE) + if(HAS_TRAIT(src, TRAIT_HV_CLEAN_CUT)) + return null + return ..() + +// tg's puff of blood off a wound that is hit again (an open puncture), and the heavy spray of a crit landing. +/mob/living/create_splatter(splatter_dir = pick(GLOB.cardinals)) + if(HAS_TRAIT(src, TRAIT_HV_CLEAN_CUT)) + return + return ..() + +/mob/living/hv_blood_throw(spray_dir, strength = 3) + if(HAS_TRAIT(src, TRAIT_HV_CLEAN_CUT)) + return FALSE + return ..() + +// tg's hit puts blood on the floor and on whoever stands next to the body at the moment of the blow. The wire is a +// pace away and cuts clean: the blood comes after (wire_sever_fx.dm), and the wire carries its own (wire_held.dm). +/mob/living/attack_effects(damage_done, hit_zone, armor_block, obj/item/attacking_item, mob/living/attacker) + if(HAS_TRAIT(src, TRAIT_HV_CLEAN_CUT) && istype(attacking_item, /obj/item/melee/cyberware_monowire)) + // The hit's message still reads before what follows it (hit_lines.dm). + hv_flush_hit() + return FALSE + return ..() + +/mob/living/carbon/hv_blood_on_limb_removed(datum/source, obj/item/bodypart/removed_limb, special, dismembered) + SIGNAL_HANDLER + if(!isnull(hv_sever_spray)) + return + return ..() + +// tg tears an arm or leg off when its wound roll says so, flinging it with a fan of blood. Mid wire cut it +// stays on for now and the wire takes it off clean once the hit is resolved (hv_wire_settle_owed_sever()). +/datum/wound/loss/apply_dismember(obj/item/bodypart/dismembered_part, wounding_type = WOUND_SLASH, outright = FALSE, attack_direction) + var/mob/living/carbon/cut = dismembered_part?.owner + if(cut && HAS_TRAIT(cut, TRAIT_HV_CLEAN_CUT) && (dismembered_part.body_zone in GLOB.hv_wire_sever_zones) && dismembered_part.can_dismember()) + cut.hv_wire_owed_sever = dismembered_part + qdel(src) + return FALSE + return ..() + +// The gore's animation pass (visuals/hit_reactions.dm) reels a body that loses a limb: a stagger along the blow, held +// for a hit-stop with a pale flash while whoever landed it holds a lean in, and a lurch toward the missing side. All at +// the moment the limb is lost, which for a wire is the hit: its limb stays drawn on for a beat after, and the lash still +// runs to it. None of that plays for a limb the wire takes (hv_wire_take_part()): the cut is clean and the body stands +// as it stood; the garrote, taking a head, lets its own body go in its own one move (let_go_at_kill()). A leg gone +// still limps from then on, and puts someone on their feet down once it has dropped (wire_leg_fall()). +/mob/living/carbon/hv_vis_on_limb_lost(obj/item/bodypart/lost_limb, special, dismembered) + if(isnull(hv_sever_spray)) + return ..() + if(special || QDELETED(src) || stat == DEAD) + return + var/zone = lost_limb.body_zone + if((zone == BODY_ZONE_L_LEG || zone == BODY_ZONE_R_LEG) && default_num_legs >= 2) + AddComponent(/datum/component/hv_limp) + +/// The limbs a wire takes off. The head is the garrote's; the chest never comes off. +GLOBAL_LIST_INIT(hv_wire_sever_zones, list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)) + +/** + * The short spray of a clean cut: a few drops thrown from src toward spray_dir, landing within a tile or so in a + * narrow fan. No streak along the floor; the shared spray (hv_blood_throw()) lays a straight line, a wire's never + * does. `tiles` sets how far the furthest drops reach. From the stump of `zone` if given, shorter, and never straight + * away from the viewer: drops thrown that way would read as leaving the head. With no `zone`, from the pixel `from` + * (x, y of its lower left corner, off the middle of src's tile), where a line of wire cut the body, or from the middle + * of the body if that isn't given either. Returns TRUE if anything was sprayed. + */ +/mob/living/proc/hv_wire_spray(spray_dir, tiles = 2, zone, list/from) + if(QDELETED(src) || !isturf(loc) || can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return FALSE + tiles = clamp(round(tiles), 1, 2) + if(!spray_dir) + spray_dir = pick(GLOB.alldirs) + hv_blood_spray_until = world.time + 0.4 SECONDS + hv_blood_spray_strength = max(hv_blood_spray_strength, tiles) + if(!zone) + var/list/reach = tiles > 1 ? list(10, 16, 22, 30, 38) : list(8, 12, 16, 20) + // A drop's picture is the pixel under the one it is placed on. + var/from_x = from ? from[1] : pixel_x + var/from_y = from ? from[2] + 1 : pixel_y - 2 + wire_blood_burst(loc, from_x, from_y, wire_blood_color(src), get_blood_dna_list(), 6, dir2angle(spray_dir), 45, reach) + return TRUE + // From the stump: drops only, no splat; a clean cut. Short, so they land by the body, on the floor round the feet + // of a body standing. + var/list/stump = wire_zone_point(src, zone) + var/lying = body_position == LYING_DOWN + var/floor_y = lying ? stump[2] : -10 + // A limb on the far side of a body side on: its stump is behind the body, and so are the drops leaving it. + var/behind = !lying && wire_limb_far(zone, dir) + if(!(spray_dir & NORTH)) + hv_wire_drops(stump, floor_y, 6, dir2angle(spray_dir), 50, tiles > 1 ? 22 : 14, behind) + return TRUE + // Away from the viewer: out to the sides instead, short, landing on the floor beside the feet. + if(!lying) + floor_y = -13 + if(spray_dir & (EAST | WEST)) + hv_wire_drops(stump, floor_y, 6, (spray_dir & EAST) ? 90 : 270, 20, 16, behind) + return TRUE + hv_wire_drops(stump, floor_y, 3, 95, 15, 16, behind) + hv_wire_drops(stump, floor_y, 3, 265, 15, 16, behind) + return TRUE + +/// How far from the middle of a body side on drops leaving a stump behind it first show: past its back or chest. +#define WIRE_DROPS_CLEAR_X 10 + +/** + * `count` drops thrown from `from` (x, y pixels off the middle of src's tile) on `bearing` (degrees from north), give + * or take `spread`, each landing as a drop on the floor up to `reach` pixels from (from x, `floor_y`). Spread evenly + * over the cone and over the reach, each with a little give, and dealt out at random so that no two neighbours in + * the cone are also neighbours in reach: they land as a scatter, not a line. They leave a beat apart. `behind` draws + * them all behind the bodies they pass. + */ +/mob/living/proc/hv_wire_drops(list/from, floor_y, count, bearing, spread, reach, behind = FALSE) + // From a stump behind a body side on, they come out past its back or front, not over its outline: a drop crossing + // the edge of the body, half hidden, reads as a speck on it. + if(behind && round(sin(bearing), 0.01)) + from = list(pixel_x + SIGN(sin(bearing)) * WIRE_DROPS_CLEAR_X, from[2]) + var/blood_color = wire_blood_color(src) + var/list/blood_dna = get_blood_dna_list() + var/list/reaches = list() + for(var/i in 1 to count) + reaches += round(reach * (0.3 + 0.7 * i / count)) + shuffle_inplace(reaches) + var/slice = count > 1 ? 2 * spread / count : 0 + for(var/i in 1 to count) + var/angle = bearing - spread + slice * (i - 0.5) + rand(-slice, slice) / 2 + var/distance = reaches[i] + rand(-3, 3) + var/land_x = from[1] + round(sin(angle) * distance) + rand(-3, 3) + var/land_y = floor_y + round(cos(angle) * distance) + rand(-3, 3) + var/flight = round(1.5 + distance / 14, 0.5) + // Never all at once: a burst of drops leaving one point at once reads as a red star on the stump. + var/delay = pick(0.05, 0.1, 0.15, 0.2) SECONDS + new /obj/effect/temp_visual/wire_blood_drop(loc, list(from[1], from[2], land_x, land_y, 2 + rand(0, 4), flight, delay, behind || cos(angle) > 0.3), blood_color, blood_dna) + +#undef WIRE_DROPS_CLEAR_X + +// ---- Stumps: held back, and seared ---- + +/mob/living/carbon/hv_update_gore_overlays() + // A limb back on forgets how its stump was cut: that is done as it goes on (try_attach_limb(), wire_sever_fx.dm), + // not here. A redraw while a limb is still coming off (tg's limb-removal signals go out before it leaves the + // body) would forget the cut that is taking it. + // A held-back stump whose time has come shows now, whatever else changed. + for(var/zone in hv_stump_reveal_at?.Copy()) + if(get_bodypart(zone) || world.time >= hv_stump_reveal_at[zone]) + LAZYREMOVE(hv_stump_reveal_at, zone) + hv_gore_key = null + return ..() + +/mob/living/carbon/hv_build_gore_images(list/stumps, skull, blood_color) + var/list/shown = stumps + if(LAZYLEN(hv_stump_reveal_at) && length(stumps)) + shown = stumps.Copy() + for(var/zone in hv_stump_reveal_at) + if(world.time < hv_stump_reveal_at[zone]) + shown -= zone + . = ..(shown, skull, blood_color) + if(!LAZYLEN(hv_stump_burnt) && !LAZYLEN(hv_stump_wire_cut)) + return + for(var/zone in shown) + var/wire_cut = LAZYACCESS(hv_stump_wire_cut, zone) && (zone in GLOB.hv_wire_stump_zones) + var/burnt = LAZYACCESS(hv_stump_burnt, zone) + if(!wire_cut && !burnt) + continue + for(var/image/gore_image as anything in .) + var/layer_part + if(gore_image.icon_state == "stump_[zone]_blood") + layer_part = "blood" + else if(gore_image.icon_state == "stump_[zone]_bone") + layer_part = "bone" + else + continue + // Same layer, alpha, colour and height filters as #509's stump; the wire's own picture. + if(wire_cut) + gore_image.icon = WIRE_GORE_ICON + gore_image.icon_state = "stump_[zone]_wire_[layer_part]" + if(!burnt) + continue + if(layer_part == "blood") + gore_image.color = WIRE_BURNT_STUMP_COLOR + gore_image.alpha = 255 + else + gore_image.color = WIRE_BURNT_BONE_COLOR + +/// Draws a stump a wire cut held back, now that the limb has left the body. +/mob/living/carbon/proc/hv_reveal_stump(zone) + LAZYREMOVE(hv_stump_reveal_at, zone) + hv_gore_key = null + hv_update_gore_overlays() + +// ---- Taking a limb off ---- + +/** + * Takes `part` off its owner as tg's dismember() does (the chest takes a share of the limb's damage, a scream, + * the mood and memory, blood lost) but drops it where the body stands instead of flinging it, and throws no + * spray: a wire's cut is clean. `bleed_mult` scales the blood lost; `splatter` leaves a drip under the body. + * Returns the part, or null if it can't come off. + */ +/proc/hv_wire_take_part(obj/item/bodypart/part, wounding_type = WOUND_SLASH, bleed_mult = 1, splatter = TRUE) + var/mob/living/carbon/victim = part?.owner + if(!victim || !part.can_dismember() || HAS_TRAIT(victim, TRAIT_GODMODE)) + return null + var/obj/item/bodypart/chest = victim.get_bodypart(BODY_ZONE_CHEST) + if(chest && chest != part) + chest.receive_damage(clamp(part.brute_dam / 2 * chest.body_damage_coeff, 15, 50), clamp(part.burn_dam / 2 * chest.body_damage_coeff, 0, 50), wound_bonus = CANT_WOUND) + if(victim.stat != DEAD) + INVOKE_ASYNC(victim, TYPE_PROC_REF(/mob, emote), "scream") + playsound(get_turf(victim), 'sound/effects/dismember.ogg', 80, TRUE) + victim.add_mood_event("dismembered_[part.body_zone]", /datum/mood_event/dismembered, part) + victim.add_mob_memory(/datum/memory/was_dismembered, lost_limb = part) + LAZYSET(victim.body_zone_dismembered_by, part.body_zone, wounding_type) + var/bleeds = part.can_bleed() + var/turf/spot = get_turf(victim) + var/old_value = victim.hv_sever_spray + victim.hv_sever_spray = 0 + // Before the drop, which draws the stump: the wire's own clean cut where it has one (the garrote's neck). + var/zone = part.body_zone + if(zone in GLOB.hv_wire_stump_zones) + LAZYSET(victim.hv_stump_wire_cut, zone, TRUE) + part.drop_limb(FALSE, TRUE) + if(victim.get_bodypart(zone) == part) + LAZYREMOVE(victim.hv_stump_wire_cut, zone) + victim.hv_sever_spray = old_value + victim.update_equipment_speed_mods() + if(bleeds && !QDELETED(victim)) + // tg bleeds a limb loss twice, once each side of the drop + victim.bleed(round(rand(20, 40) * bleed_mult)) + victim.bleed(round(rand(20, 40) * bleed_mult)) + if(splatter && isturf(spot) && victim.can_bleed(BLOOD_COVER_TURFS) == BLEED_SPLATTER) + new /obj/effect/decal/cleanable/blood/drip(spot, victim.get_static_viruses(), victim.get_blood_dna_list()) + return part diff --git a/voidcrew/modules/hyperviolence/wire/wire_sever_fx.dm b/voidcrew/modules/hyperviolence/wire/wire_sever_fx.dm new file mode 100644 index 00000000000..72eb7fb8ee9 --- /dev/null +++ b/voidcrew/modules/hyperviolence/wire/wire_sever_fx.dm @@ -0,0 +1,559 @@ +/** + * # The Widowline's cut, drawn + * + * Visual only: the sever, the sear and the through-cut have already happened (wire_cut.dm) when these run. + * + * - The delayed cut. The limb is off at the hit, but for WIRE_CUT_DELAY it is still drawn on its body: + * a held copy (the limb's own sprite, plus the jumpsuit, suit, glove or shoe cut to its shape) rides the + * body in its vis_contents, over the stump the gore overlays hold back. Then it slides along the cut, + * turns, falls and fades while the severed limb on the floor fades in, and the stump shows. The held copy + * deletes itself on a hard timer, and with its body; if the limb is back on, or the body was carried off + * meanwhile, it just fades. + * - The seam: a white flash across the limb that cools to the wire's colour and beads with blood, or on a + * seared cut glows white to orange to embers, with a little light and smoke. + * - The through-cut: a fan of drops from each of the two bodies. Its line is the lash's own (wire_lash_through()). + */ + +/// The colour a body's blood is drawn in, as the gore overlays draw it. +/proc/wire_blood_color(mob/living/bleeder) + return bleeder.get_bloodtype()?.get_damage_color(bleeder) || BLOOD_COLOR_RED + +/// Which way a limb in `zone` falls away from a body facing `facing`, cut by a swing going `swing_dir`: +/// -1 to screen left, 1 to screen right. Seen from the front or back it falls out on its own side; in profile +/// it falls the way the swing carries it, away from the wielder. +/proc/wire_limb_side(zone, facing, swing_dir) + if(facing == EAST || facing == WEST) + if(swing_dir & EAST) + return 1 + if(swing_dir & WEST) + return -1 + return facing == EAST ? 1 : -1 + if(facing == NORTH) + return (zone == BODY_ZONE_R_ARM || zone == BODY_ZONE_R_LEG) ? 1 : -1 + return (zone == BODY_ZONE_R_ARM || zone == BODY_ZONE_R_LEG) ? -1 : 1 + +/// The middle of a human limb in `zone` as a body facing `facing` draws it, in pixels from the middle of the +/// tile. An arm on the far side of a body in profile is hidden, so it is placed as the near one. list(x, y) +/proc/wire_limb_centre(zone, facing) + var/arm = (zone == BODY_ZONE_L_ARM || zone == BODY_ZONE_R_ARM) + var/right = (zone == BODY_ZONE_R_ARM || zone == BODY_ZONE_R_LEG) + var/y = arm ? 0 : -11 + switch(facing) + if(EAST) + return list(arm ? -2 : 0, y) + if(WEST) + return list(arm ? 2 : 0, y) + if(NORTH) + return list(arm ? (right ? 6 : -7) : (right ? 3 : -4), y) + return list(arm ? (right ? -7 : 6) : (right ? -4 : 3), y) + +/** + * Where a cut limb comes to rest, as a transform for something drawing it with its middle at `centre`. Upright, it + * has toppled over `side` and lies on the floor beside the feet; off a body already lying down it only slides out a + * little, since it is on the floor already. For something drawn apart from the body, `body` places and turns it as + * that body is drawn. A dropped limb shifts its own picture by (`shift_x`, `shift_y`) after any transform, so that + * is taken back off at the end. + */ +/proc/wire_limb_rest(list/centre, side, lying, mob/living/body, shift_x = 0, shift_y = 0) + var/list/target = lying ? list(centre[1] + side * 7, centre[2] - 2) : list(side * 10, -13) + return wire_part_pose(centre, lying ? side * 10 : side * 90, target, body, shift_x, shift_y) + +/** + * A transform that draws a part whose middle is at `centre` turned `turn` degrees about that middle, with the middle + * at `target` (both in its body's own frame), then placed and turned as `body` is drawn, if given; less a shift + * the picture applies after its transform. + */ +/proc/wire_part_pose(list/centre, turn, list/target, mob/living/body, shift_x = 0, shift_y = 0) + var/list/spot = target + if(body) + turn += body.body_position == LYING_DOWN ? body.lying_angle : 0 + var/matrix/shape = body.transform + spot = list(shape.a * target[1] + shape.b * target[2] + shape.c, shape.d * target[1] + shape.e * target[2] + shape.f) + var/matrix/pose = matrix() + pose.Translate(-centre[1], -centre[2]) + pose.Turn(turn) + pose.Translate(spot[1] - shift_x, spot[2] - shift_y) + return pose + +// ---- The held limb ---- + +/// A severed limb, still drawn on its body for the beat before it slides off. +/obj/effect/abstract/cyberware_anim/wire_ghost + name = "severed limb" + appearance_flags = KEEP_TOGETHER | TILE_BOUND | PIXEL_SCALE + /// The body zone it was cut from + var/zone + /// Cut by a hot wire: no blood when it goes + var/seared = FALSE + /// Which way the blood goes when it slides off: along the swing + var/spray_dir + /// Where the body stood when it was cut. Moved since, and there's no slide. + var/turf/cut_at + /// The severed limb lying on the floor + var/datum/weakref/severed_ref + /// Timer of the slide + var/slide_timer + /// Which way the body faced when it was cut + var/facing = SOUTH + /// Which way the limb falls: -1 to screen left, 1 to screen right + var/side = 1 + /// The body was lying down when it was cut + var/lying = FALSE + /// A far arm in profile: drawn as the near arm of a body facing the other way, flipped back + var/mirrored = FALSE + /// Copies of what the body wore over the limb (uniform, suit, gloves or shoes) when it was cut, uncut + var/list/worn + /// The other foot's shoe, still drawn on while the leg is held: tg takes both shoes off with a leg + var/obj/effect/abstract/cyberware_anim/kept_shoe + +/obj/effect/abstract/cyberware_anim/wire_ghost/Destroy() + if(slide_timer) + deltimer(slide_timer) + slide_timer = null + cut_at = null + severed_ref = null + worn = null + QDEL_NULL(kept_shoe) + return ..() + +/** + * Draws `limb` held on `victim` until it slides off. Called while the limb is still attached, since what it + * draws (the limb and the clothes over it) is read off the body. Returns the held copy, or null. + */ +/proc/wire_ghost_limb(mob/living/carbon/victim, obj/item/bodypart/limb, seared, spray_dir) + if(QDELETED(victim) || !isturf(victim.loc) || limb?.owner != victim) + return null + var/obj/effect/abstract/cyberware_anim/wire_ghost/ghost = new(null) + ghost.zone = limb.body_zone + ghost.seared = seared + ghost.spray_dir = spray_dir + ghost.cut_at = get_turf(victim) + ghost.facing = victim.dir + ghost.side = wire_limb_side(ghost.zone, victim.dir, spray_dir) + ghost.lying = victim.body_position == LYING_DOWN + ghost.dress(victim, limb) + ghost.bearer = victim + ghost.RegisterSignal(victim, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + victim.vis_contents += ghost + ghost.keep_other_shoe(victim) + ghost.slide_timer = addtimer(CALLBACK(ghost, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim/wire_ghost, slide)), WIRE_CUT_DELAY, TIMER_STOPPABLE) + // Whatever happens to the body meanwhile, it never outlives its beat. + QDEL_IN(ghost, WIRE_CUT_DELAY + WIRE_SLIDE_TIME + WIRE_FALL_TIME + 0.3 SECONDS) + return ghost + +/// Whether a limb in `zone` is on the far side of a body facing `facing`, drawn behind its chest: the left arm and +/// leg of a body facing east, the right of one facing west. +/proc/wire_limb_far(zone, facing) + if(facing == EAST) + return zone == BODY_ZONE_L_ARM || zone == BODY_ZONE_L_LEG + if(facing == WEST) + return zone == BODY_ZONE_R_ARM || zone == BODY_ZONE_R_LEG + return FALSE + +/// Builds the picture: the limb as the body drew it, with the clothes over it cut to its shape. +/obj/effect/abstract/cyberware_anim/wire_ghost/proc/dress(mob/living/carbon/victim, obj/item/bodypart/limb) + icon = null + var/arm = (zone == BODY_ZONE_L_ARM || zone == BODY_ZONE_R_ARM) + if(wire_limb_far(zone, victim.dir)) + // A far limb is behind the body, so it goes under all of it until it falls clear. Visual contents don't sort + // among their body's own overlays; as an underlay it is under every one of them. + layer = FLOAT_LAYER + vis_flags |= VIS_UNDERLAY + // Side on, the body hides a far arm all but a sliver. It is drawn as the near arm of a body facing the other + // way, flipped back, as the severed arm on the floor is (hold_severed()), so the arm that falls is the one + // that lands. + if(arm) + mirrored = TRUE + vis_flags &= ~VIS_INHERIT_DIR + dir = REVERSE_DIR(victim.dir) + transform = matrix(-1, 0, 0, 0, 1, 0) + else + layer = WIRE_GHOST_LAYER + var/mob/living/carbon/human/dressed = ishuman(victim) ? victim : null + var/reshaped = dressed && dressed.mob_height != HUMAN_HEIGHT_MEDIUM + // A clean cut: no bruising (tg draws it as a dither the clothes normally hide). A seared limb shows burns. + var/list/parts = limb.get_limb_icon(TRUE, victim) + for(var/image/part_image in parts) + if(part_image.layer == -DAMAGE_LAYER) + parts -= part_image + if(seared) + parts += image('icons/mob/effects/dam_mob.dmi', "[limb.dmg_overlay_type]_[zone]_0[max(limb.burnstate, 2)]", -DAMAGE_LAYER) + for(var/image/part_image in parts) + if(PLANE_TO_TRUE(part_image.plane) == EMISSIVE_PLANE) + continue + if(reshaped) + dressed.apply_height_filters(part_image) + overlays += part_image + if(!dressed || (dressed.bodyshape & (BODYSHAPE_MONKEY | BODYSHAPE_DIGITIGRADE))) + return + worn = wire_worn_over(dressed, arm ? list(UNIFORM_LAYER, SUIT_LAYER, GLOVES_LAYER) : list(UNIFORM_LAYER, SUIT_LAYER, SHOES_LAYER)) + for(var/mutable_appearance/clothes as anything in wire_dress_limb(worn, "limb_[zone]", "ghost [REF(src)]")) + overlays += clothes + +/// Copies of the overlays `body` wears at `layers` (UNIFORM_LAYER and so on), as they are now. list(layer = copy) +/proc/wire_worn_over(mob/living/carbon/human/body, list/layers) + . = list() + for(var/index in layers) + var/mutable_appearance/worn_overlay = body.overlays_standing[index] + if(istype(worn_overlay)) + .["[index]"] = new /mutable_appearance(worn_overlay) + +/** + * One picture of the `worn` overlays (from wire_worn_over()) cut to the shape of a limb: `mask_state` in the sleeve + * masks. `key` names its mask; no two pictures on screen at once may share one. Null if nothing is worn. + */ +/proc/wire_cut_clothes(list/worn, mask_state, key) + if(!length(worn)) + return null + var/mutable_appearance/clothes = mutable_appearance(appearance_flags = KEEP_TOGETHER) + for(var/index in worn) + clothes.overlays += worn[index] + // Built as tg builds the missing-hand glove mask (update_worn_gloves()), and the sleeve mask: an atom's appearance + // carries the render target. A mutable_appearance carrying one draws nothing through the filter. A new atom for + // each picture: one shared atom given a second picture's target for the same limb took the first one's mask away, + // and that picture drew nothing (a cut leg's trouser, made just before its shoe's picture). + var/atom/movable/cutout = new(null) + cutout.icon = HV_SLEEVE_MASK_ICON + cutout.icon_state = mask_state + cutout.render_target = "*wire_cut [key] [mask_state]" + clothes.overlays += cutout + clothes.add_filter("wire_cut_clothes", 0, alpha_mask_filter(render_source = cutout.render_target)) + qdel(cutout) + return clothes + +/** + * The `worn` overlays cut to a limb's shape (wire_cut_clothes()), layered as tg layers them on a body: the jumpsuit + * under the hand, the suit, gloves and shoes over it. Side on, a jumpsuit has cloth behind the hand that would + * otherwise cover it. list() if nothing is worn. + */ +/proc/wire_dress_limb(list/worn, mask_state, key) + . = list() + var/uniform_key = "[UNIFORM_LAYER]" + var/list/over = worn.Copy() + if(worn[uniform_key]) + over -= uniform_key + var/mutable_appearance/under = wire_cut_clothes(list("[UNIFORM_LAYER]" = worn[uniform_key]), mask_state, "[key] under") + under.layer = -UNIFORM_LAYER + . += under + var/mutable_appearance/rest = wire_cut_clothes(over, mask_state, "[key] over") + if(rest) + . += rest + +/// The leg's own shoe goes with the leg, but tg takes the other one off too. It stays drawn on its foot until the leg +/// slides off. +/obj/effect/abstract/cyberware_anim/wire_ghost/proc/keep_other_shoe(mob/living/carbon/victim) + if(!worn || !worn["[SHOES_LAYER]"] || (zone != BODY_ZONE_L_LEG && zone != BODY_ZONE_R_LEG)) + return + var/other = zone == BODY_ZONE_L_LEG ? BODY_ZONE_R_LEG : BODY_ZONE_L_LEG + if(!victim.get_bodypart(other)) + return + var/mutable_appearance/shoe = wire_cut_clothes(list("[SHOES_LAYER]" = worn["[SHOES_LAYER]"]), "limb_[other]", "shoe [REF(src)]") + if(!shoe) + return + kept_shoe = new(null) + kept_shoe.icon = null + // Over the body, and under the held leg if that is the near one. + kept_shoe.layer = WIRE_GHOST_LAYER - 0.05 + kept_shoe.overlays += shoe + kept_shoe.bearer = victim + kept_shoe.RegisterSignal(victim, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + victim.vis_contents += kept_shoe + +/** + * The severed limb on the floor stays unseen until this lands, then shows where this came to rest: facing the way + * it hung on the body, lying on the floor beside the feet, turned as far as this fell. + */ +/obj/effect/abstract/cyberware_anim/wire_ghost/proc/hold_severed(obj/item/bodypart/severed) + if(QDELETED(severed) || !isturf(severed.loc)) + return + severed_ref = WEAKREF(severed) + var/mob/living/body = bearer + // A dropped limb is drawn facing south otherwise. An arm on the far side of a body in profile is not drawn at + // all from that side, so that one lies as the near arm would: the other way round, flipped. + var/far_arm = (facing == EAST && zone == BODY_ZONE_L_ARM) || (facing == WEST && zone == BODY_ZONE_R_ARM) + severed.setDir(far_arm ? REVERSE_DIR(facing) : facing) + var/list/centre = wire_limb_centre(zone, facing) + // The dropped limb's picture is shifted by (px_x, px_y) to sit mid-tile, after its transform. + var/matrix/rest = wire_limb_rest(centre, side, lying, body, severed.px_x, severed.px_y) + if(far_arm) + var/matrix/flipped = matrix(-1, 0, 0, 0, 1, 0) + flipped.Multiply(rest) + rest = flipped + severed.transform = rest + // It keeps the sleeve, trouser leg or shoe it was cut with. tg took both shoes off; the pair lies beside it + // (hold_shoes()), as the other foot's. + if(worn) + severed.hv_wire_dressing = wire_dress_limb(worn, "limb_[zone]", "limb [REF(severed)]") + severed.update_icon_dropped() + severed.pixel_x = body ? body.pixel_x : 0 + severed.pixel_y = body ? body.pixel_y : 0 + severed.pixel_w = body ? body.pixel_w : 0 + severed.pixel_z = body ? body.pixel_z : 0 + // Picked up, kicked or put back on, it is an ordinary limb again. + severed.RegisterSignal(severed, COMSIG_MOVABLE_MOVED, TYPE_PROC_REF(/obj/item/bodypart, wire_stand_up), override = TRUE) + // The server value is 255 at once; only the picture waits for the landing. + severed.alpha = 0 + animate(severed, alpha = 0, time = WIRE_CUT_DELAY + WIRE_SLIDE_TIME + WIRE_FALL_TIME) + animate(alpha = 255, time = 0.5) + +/// Shoes lying by a cut leg are drawn at this scale: tg's shoe on the floor is as big as a leg. +#define WIRE_SHOE_SCALE 0.6 + +/** + * The shoe tg pulls off a leg that comes away goes with the leg: unseen until the leg lands, then lying on the floor + * just past it, not hanging in the air at the hip where tg drops it. + */ +/obj/effect/abstract/cyberware_anim/wire_ghost/proc/hold_shoes(obj/item/shoes) + if(QDELETED(shoes) || !isturf(shoes.loc)) + return + var/mob/living/body = bearer + // By the foot end of the leg as it lies (wire_limb_rest()), not the hip end. + var/list/spot = lying ? list(side * 12, -9) : list(side * 6, -13) + if(body) + var/matrix/shape = body.transform + spot = list(shape.a * spot[1] + shape.b * spot[2] + shape.c + body.pixel_x, shape.d * spot[1] + shape.e * spot[2] + shape.f + body.pixel_y) + shoes.pixel_x = round(spot[1]) + shoes.pixel_y = round(spot[2]) + // tg draws a shoe on the floor as big as a leg. These lie by a cut leg at the leg's scale. + shoes.transform = matrix(WIRE_SHOE_SCALE, 0, 0, 0, WIRE_SHOE_SCALE, 0) + shoes.RegisterSignal(shoes, COMSIG_MOVABLE_MOVED, TYPE_PROC_REF(/obj/item, wire_show_shoes), override = TRUE) + shoes.alpha = 0 + animate(shoes, alpha = 0, time = WIRE_CUT_DELAY + WIRE_SLIDE_TIME + WIRE_FALL_TIME) + animate(alpha = 255, time = 0.5) + +/// Shoes that came off with a cut leg, once moved: drawn as any item. +/obj/item/proc/wire_show_shoes() + SIGNAL_HANDLER + UnregisterSignal(src, COMSIG_MOVABLE_MOVED) + animate(src, alpha = 255, time = 0) + transform = matrix() + pixel_x = base_pixel_x + pixel_y = base_pixel_y + +/// A limb the wire cut, once it is moved: drawn as any dropped limb. +/obj/item/bodypart/proc/wire_stand_up() + SIGNAL_HANDLER + UnregisterSignal(src, COMSIG_MOVABLE_MOVED) + animate(src, alpha = 255, time = 0) + transform = matrix() + setDir(SOUTH) + pixel_x = base_pixel_x + pixel_y = base_pixel_y + pixel_w = base_pixel_w + pixel_z = base_pixel_z + +/obj/item/bodypart + /// The sleeve or trouser leg a wire cut this limb off with, drawn on it while it lies severed (wire_dress_limb()) + var/list/hv_wire_dressing + +/obj/item/bodypart/update_icon_dropped() + . = ..() + if(!length(hv_wire_dressing) || owner) + return + // Shifted as get_limb_icon()'s pieces are, to sit on the limb. + for(var/mutable_appearance/piece as anything in hv_wire_dressing) + var/mutable_appearance/dressing = new(piece) + dressing.pixel_w += px_x + dressing.pixel_z += px_y + add_overlay(dressing) + +// Back on a body, it wears that body's clothes again. +/obj/item/bodypart/try_attach_limb(mob/living/carbon/new_limb_owner, special, lazy) + . = ..() + if(.) + hv_wire_dressing = null + // A limb back on forgets how its stump was cut (wire_seams.dm) + if(iscarbon(new_limb_owner)) + LAZYREMOVE(new_limb_owner.hv_stump_burnt, body_zone) + LAZYREMOVE(new_limb_owner.hv_stump_wire_cut, body_zone) + +/// A limb cut clean by a wire: no bruising on the picture of it. Only the picture; its damage is as it was. +/obj/item/bodypart/proc/wire_clean_look() + brutestate = 0 + update_icon_dropped() + +/// A limb cut by a hot wire: burnt, not bloody. Only the picture; its damage is as it was. +/obj/item/bodypart/proc/wire_char() + brutestate = 0 + burnstate = max(burnstate, 2) + // The blood it caught coming off is burnt away too. A later wash brings the body's own back, as for any limb. + var/list/kept = blood_dna_info + blood_dna_info = null + wash(CLEAN_TYPE_BLOOD) + blood_dna_info = kept + update_icon_dropped() + +/// The limb leaves: it slides along the cut, topples and falls to the floor. The stump shows, and the blood goes. +/obj/effect/abstract/cyberware_anim/wire_ghost/proc/slide() + slide_timer = null + var/mob/living/carbon/victim = bearer + if(QDELETED(victim)) + qdel(src) + return + victim.hv_reveal_stump(zone) + // The other shoe is off now, as it has been since the cut. + QDEL_NULL(kept_shoe) + if(victim.get_bodypart(zone) || get_turf(victim) != cut_at) + // Put back on, or carried off: nothing slides, the picture just goes. + animate(src, alpha = 0, time = 0.1 SECONDS) + QDEL_IN(src, 0.1 SECONDS) + return + // Drawn in its body's own frame, which turns it with a lying body: so no body_shape here. + var/list/centre = wire_limb_centre(zone, facing) + var/matrix/slid = matrix() + slid.Translate(-centre[1], -centre[2]) + slid.Turn(side * (lying ? 4 : 15)) + slid.Translate(centre[1] + side * 2, centre[2] - 1) + var/matrix/rest = wire_limb_rest(centre, side, lying) + // Halfway over: the turn is split so it turns rather than squashes on the way. + var/matrix/tipping = matrix() + tipping.Translate(-centre[1], -centre[2]) + tipping.Turn(side * (lying ? 7 : 50)) + if(lying) + tipping.Translate(centre[1] + side * 5, centre[2] - 1) + else + tipping.Translate((centre[1] + side * 12) / 2, (centre[2] - 13) / 2) + if(mirrored) + // Flipped first, then moved, as the arm on the floor is. + var/list/poses = list(slid, tipping, rest) + for(var/i in 1 to length(poses)) + var/matrix/flipped = matrix(-1, 0, 0, 0, 1, 0) + flipped.Multiply(poses[i]) + poses[i] = flipped + slid = poses[1] + tipping = poses[2] + rest = poses[3] + animate(src, transform = slid, time = WIRE_SLIDE_TIME, easing = SINE_EASING | EASE_IN) + animate(transform = tipping, time = WIRE_FALL_TIME / 2, easing = QUAD_EASING | EASE_IN) + animate(transform = rest, time = WIRE_FALL_TIME / 2, easing = QUAD_EASING | EASE_IN) + // Down: the limb on the floor takes over. + animate(alpha = 0, time = 0.5) + // The blood starts now, as the limb leaves: a short spray from the stump and a drop falling under it. + if(!seared) + victim.hv_wire_spray(spray_dir, 2, zone) + wire_stump_drip(victim, zone, side) + QDEL_IN(src, WIRE_SLIDE_TIME + WIRE_FALL_TIME + 0.1 SECONDS) + +/// The drop under a fresh stump leaves it this long after the limb starts to slide, as the stump shows... +#define WIRE_STUMP_DRIP_WAIT 1 +/// ...and falls for this long (both in deciseconds, as the drop's flight is given). +#define WIRE_STUMP_DRIP_FALL 2 + +/// A drop of blood falls from a fresh stump and lands on the floor under it: where the feet stand on a body standing +/// (not at the foot of the tile, where it would sit on the head of anyone standing below), at the stump of one lying. +/// Side on, it lands clear of the feet, away from the limb that fell to `side`: under them, it shows past the legs as a +/// red bar. From a limb on the far side it falls behind the body. +/proc/wire_stump_drip(mob/living/carbon/victim, zone, side = 1) + var/turf/floor = get_turf(victim) + if(!floor || isgroundlessturf(floor) || !floor.has_gravity() || victim.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return + var/list/spot = wire_zone_point(victim, zone) + var/start_x = spot[1] + var/start_y = spot[2] + var/land_x + var/land_y + var/behind = FALSE + if(victim.body_position == LYING_DOWN) + // Down already: it only runs off the stump onto the floor. + land_x = clamp(spot[1], -12, 12) + land_y = clamp(spot[2], -12, 12) + start_x = land_x + start_y = land_y + 3 + else + // On the floor at the feet: higher, it shows through the gap a leg leaves as a blot at the hip. + land_x = (victim.dir & (EAST | WEST)) ? victim.pixel_x - side * 9 : clamp(spot[1], -12, 12) + land_y = -13 + behind = wire_limb_far(zone, victim.dir) + new /obj/effect/temp_visual/wire_blood_drop(floor, list(start_x, start_y, land_x, land_y, 1, WIRE_STUMP_DRIP_FALL, WIRE_STUMP_DRIP_WAIT, behind), wire_blood_color(victim), victim.get_blood_dna_list(), victim.get_static_viruses()) + +#undef WIRE_STUMP_DRIP_WAIT +#undef WIRE_STUMP_DRIP_FALL + +// ---- The seam ---- + +/// The cut across `zone`: a flash that cools and beads with blood, or a seared seam that glows down to embers. +/proc/wire_seam_fx(mob/living/carbon/victim, zone, seared) + if(QDELETED(victim)) + return + if(seared) + cyberware_anim_play(victim, WIRE_GORE_ICON, "wire_cut_hot_[zone]", WIRE_FX_LAYER, 1.1 SECONDS, glow = TRUE) + victim.mob_light(1.5, 0.8, "#ff9a3c", 0.6 SECONDS) + playsound(victim, 'sound/effects/wounds/sizzle1.ogg', 60, TRUE) + wire_stump_smoke(victim, zone) + return + // Gone as the limb slides: its last frame left behind would hang in the air where the limb was. + cyberware_anim_play(victim, WIRE_GORE_ICON, "wire_cut_[zone]", WIRE_FX_LAYER, WIRE_CUT_DELAY, glow = TRUE) + // No blood until the limb comes away. + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(wire_seam_beads), victim, zone), WIRE_CUT_DELAY) + +/// The seam beads with blood as the limb slides off it. The beads keep to the body's side of the cut (the stump): +/// past it there is only air now. +/proc/wire_seam_beads(mob/living/carbon/victim, zone) + if(QDELETED(victim) || victim.get_bodypart(zone) || victim.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return + var/obj/effect/abstract/cyberware_anim/beads = cyberware_anim_play(victim, WIRE_GORE_ICON, "wire_cut_blood_[zone]", WIRE_FX_LAYER - 0.1, 0.9 SECONDS) + if(beads) + beads.appearance_flags |= RESET_COLOR + beads.color = wire_blood_color(victim) + +/// A seared stump smokes for a few seconds. +/obj/effect/abstract/cyberware_anim/wire_smoke + name = "smoke" + icon = null + +/obj/effect/abstract/cyberware_anim/wire_smoke/proc/stop_smoking() + particles?.spawning = 0 + +/proc/wire_stump_smoke(mob/living/carbon/victim, zone) + var/obj/effect/abstract/cyberware_anim/wire_smoke/smoke = new(null) + // On the body, over the stump, not over everything on the tile. + smoke.layer = WIRE_GHOST_LAYER + var/particles/smoke/steam/mild/wire_stump/puff = new + puff.position = wire_stump_joint(zone, victim.dir) + // Side on, the face is just above a shoulder: the smoke leans back over the shoulders, away from it. + if(victim.dir & (EAST | WEST)) + var/back = victim.dir == EAST ? -1 : 1 + puff.velocity = list(back * 0.3, 0.15, 0) + puff.gravity = list(back * 0.12, 0.18) + smoke.particles = puff + smoke.bearer = victim + smoke.RegisterSignal(victim, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + victim.vis_contents += smoke + addtimer(CALLBACK(smoke, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim/wire_smoke, stop_smoking)), WIRE_ARC_SMOKE_TIME - 1 SECONDS) + QDEL_IN(smoke, WIRE_ARC_SMOKE_TIME) + +/// Where a limb in `zone` joins a body facing `facing` (the shoulder, the hip, the neck), in pixels from the middle +/// of the tile, as the body draws it standing. list(x, y, 0) +/proc/wire_stump_joint(zone, facing) + if(zone == BODY_ZONE_HEAD) + return list(0, 6, 0) + var/list/centre = wire_limb_centre(zone, facing) + var/arm = (zone == BODY_ZONE_L_ARM || zone == BODY_ZONE_R_ARM) + return list(centre[1], arm ? 4 : -6, 0) + +/// Thin wisps off a seared stump: small, rising slowly from the joint. +/particles/smoke/steam/mild/wire_stump + scale = 0.4 + grow = 0.02 + spawning = 0.6 + lifespan = 1.2 SECONDS + fade = 0.8 SECONDS + velocity = list(0, 0.2, 0) + gravity = list(0, 0.25) + drift = generator(GEN_SPHERE, 0, 0.6, NORMAL_RAND) + +// ---- Through two bodies ---- + +/** + * The wire of `user` went through `target` and on into `behind`: each throws a short fan of drops the way it went, from + * where it was cut: the pixel the swing's lash passes on `target` and the one it ends on in `behind`'s chest + * (wire_through_cuts()). No line of light and no line of blood: that lash runs on to `behind` (wire_lash_through()). + * `clean`: `target` throws none here, its own cut showing another way (a limb coming off, a crossing cut). + */ +/obj/item/melee/cyberware_monowire/proc/wire_through_fx(mob/living/user, mob/living/target, mob/living/behind, direction, clean = FALSE) + var/list/cuts = wire_through_cuts(user, target, behind) + if(!clean) + target.hv_wire_spray(direction, 2, from = cuts ? cuts[1] : null) + behind.hv_wire_spray(direction, 2, from = cuts ? cuts[2] : wire_zone_point(behind, BODY_ZONE_CHEST)) + +#undef WIRE_SHOE_SCALE diff --git a/voidcrew/modules/hyperviolence/wire/wire_users.dm b/voidcrew/modules/hyperviolence/wire/wire_users.dm new file mode 100644 index 00000000000..a78220a8615 --- /dev/null +++ b/voidcrew/modules/hyperviolence/wire/wire_users.dm @@ -0,0 +1,55 @@ +/** + * Who may use the Widowline's own moves: the aimed sever, the crossing cut and the garrote. + * + * Players can. Human NPCs can't yet: the owner wants bounty criminals to use them later, and this is the one + * place that opens them, for example `return wielder.client || wielder.npc_rank >= HUMAN_NPC_RANK_BOSS` + * for bosses only. Everything else a wire does (its damage, the through-cut, clean cuts, blood on + * the wire, tg's own dismemberment drawn clean) belongs to the weapon and works for any wielder, as it did + * before these moves existed. + * + * Each move also has an entry point that needs no mouse and no target doll, for an AI to call once this + * lets it: wire_aimed_swing() (the aimed sever), wire_crossing_swing() (the crossing cut) and + * wire_start_garrote() (the garrote, wire_garrote.dm). Each still asks this proc first. + */ +/proc/hv_wire_moves_allowed(mob/living/wielder) + if(!isliving(wielder)) + return FALSE + if(istype(wielder, /mob/living/carbon/human/npc)) + return !!wielder.client + return TRUE + +/** + * An aimed swing at `victim`'s `zone`, as a player's click with that zone on the target doll: the wire's cut, + * and the sever if that arm or leg is hurt enough. Where it lands is tg's aim roll, as for anyone. Never starts + * a garrote. Returns TRUE if it swung. + */ +/obj/item/melee/cyberware_monowire/proc/wire_aimed_swing(mob/living/user, mob/living/victim, zone) + if(!isliving(user) || !isliving(victim) || !user.is_holding(src) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED)) + return FALSE + if(!user.CanReach(victim, src)) + return FALSE + if(user.get_active_held_item() != src) + user.swap_hand(user.get_held_index_of_item(src), silent = TRUE) + var/old_zone = user.zone_selected + var/old_combat_mode = user.combat_mode + user.zone_selected = zone + user.set_combat_mode(TRUE) + garrote_blow = TRUE + melee_attack_chain(user, victim) + if(!QDELETED(src)) + garrote_blow = FALSE + if(!QDELETED(user)) + user.zone_selected = old_zone + user.set_combat_mode(old_combat_mode) + user.changeNext_move(CLICK_CD_MELEE) + return TRUE + +/// The crossing cut on demand: with a wire out in each hand, this aimed swing crosses both through `victim` if it +/// lands, whatever the count. Returns TRUE if it swung as a crossing cut. +/obj/item/melee/cyberware_monowire/proc/wire_crossing_swing(mob/living/user, mob/living/victim, zone = BODY_ZONE_CHEST) + if(!hv_wire_moves_allowed(user) || wire_count_held(user) < 2) + return FALSE + force_cross = TRUE + . = wire_aimed_swing(user, victim, zone) + if(!QDELETED(src)) + force_cross = FALSE diff --git a/voidcrew/modules/hyperviolence_gorilla/chrome_puppet_rig.dm b/voidcrew/modules/hyperviolence_gorilla/chrome_puppet_rig.dm new file mode 100644 index 00000000000..eb9372465b9 --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/chrome_puppet_rig.dm @@ -0,0 +1,803 @@ +/** + * # The puppet rig ("arm rig") + * + * tg bodies have no poses, so a chrome finisher that needs a real arm swing, a body held up by the + * collar or folded over a knee draws one: the real body is hidden for a few seconds and stand-ins + * ("puppets") cut from one flat picture of it are posed in its place. + * + * - One getFlatIcon() of the body, facing the way the finisher needs, at the start. Whatever tg draws on the + * hidden body after that (blood on its clothes, a stump) is hidden with it, so a move that bloodies or + * wounds a rigged body takes the picture again at that moment (snapshot(), redraw_arms()). + * - The picture is cut with masks drawn from tg's human base sprite (gorilla_gore.dmi, rig_*): the arms + * (with their sleeves, gloves and chrome, whatever is worn), the body without one or both arms, and + * the upper and lower halves at the belt. In a side view the near arm covers the torso, so the torso + * under it is filled from the torso just beside it. + * - Each puppet is a plain object on the body's tile, posed with its own transform and offsets, so + * nothing ever touches the real body's transform, offsets or layer; tg's lying turn, grab offsets and + * height filters stay right. A puppet turns about a pivot (a shoulder, the belt) with chrome_rig_turn(). + * - The real body is hidden with a colour filter, and made clickable over its whole tile while hidden, + * so the crew can still click the body to stop it. Puppets never take clicks. + * - The pictures are made at runtime, and each client has to fetch them before it can draw a puppet. Until + * they land a puppet is drawn as nothing: a body hidden at once was simply gone for that moment, and a + * bearer whose body had landed stood there with no arms. So a copy of the body's own look, which needs + * no new picture, stands where it was drawn (the stand-in), cut out by a solid box kept in the same + * file as the puppets' pictures. Every rig that goes up in one tick shares one file (the sheet), so on + * each client the stand-ins go and all the puppets show in the same frame, the frame the file lands. + * - Off: the filter and the click area come back and every puppet is deleted. That happens when the rig + * is deleted, which its owner does on every way a finisher ends, and which the rig does itself if the + * body is deleted. + * + * A body whose flat picture isn't 32x32 (something huge worn or held) gets no rig: the move still + * happens, just without the poses. + */ + +/// Mask states and pivots below are for tg's human base body, medium height. +#define CHROME_RIG_HIDE_FILTER "chrome_rig_hide" +/// The filter that cuts a body's stand-in out once the puppets' pictures have reached a client. +#define CHROME_RIG_SWAP_FILTER "chrome_rig_swap" +/// The solid box's name in a sheet. +#define CHROME_RIG_BOX_STATE "box" + +/** + * Shoulder pivots (pixels from the icon's centre, x right, y up) per facing, from the human base + * sprite. list(dir = list(left_x, left_y, right_x, right_y)). + */ +GLOBAL_LIST_INIT(chrome_rig_shoulders, list( + "[SOUTH]" = list(4, 4, -6, 4), + "[NORTH]" = list(-6, 4, 4, 4), + "[EAST]" = list(-4, 2, -4, 2), + "[WEST]" = list(4, 2, 4, 2), +)) + +/// Pixels from a shoulder pivot to the fist on a hanging arm, per facing. +GLOBAL_LIST_INIT(chrome_rig_arm_length, list( + "[SOUTH]" = 10, + "[NORTH]" = 10, + "[EAST]" = 7, + "[WEST]" = 7, +)) + +/** + * Pixels from a shoulder pivot to the middle of the hand on a hanging arm, per facing, from the rig masks. + * list(dir = list(left_x, left_y, right_x, right_y)). In a side view the far arm is drawn as the near one a + * pixel further back (arm_picture()), so its hand is a pixel further back too. + */ +GLOBAL_LIST_INIT(chrome_rig_hands, list( + "[SOUTH]" = list(2, -9, -1, -9), + "[NORTH]" = list(-1, -9, 2, -9), + "[EAST]" = list(0.5, -6, 1.5, -6), + "[WEST]" = list(-1.5, -6, -0.5, -6), +)) + +/// The soles of a standing human, from the icon's centre: a body bends forward about them. +#define CHROME_RIG_FEET_Y -15 +/// The lowest pixel row (from the bottom, 1-based) of a human head; the neck is under it. +#define CHROME_RIG_NECK_Y 23 +/// The neck line, from the icon's centre: the bottom edge of the head's lowest row. A head squashed or +/// turned about it stays on the shoulders. +#define CHROME_RIG_NECK_PIVOT_Y (CHROME_RIG_NECK_Y - 1 - ICON_SIZE_Y / 2) + +/// Most degrees an arm turns in one animation step. +#define CHROME_RIG_SWING_STEP 12 +/// How long a body takes to go once its puppets are certain to be drawn (conceal_after()). +#define CHROME_RIG_SWAP (0.01 SECONDS) +/// The shortest an arm is drawn, as a share of its length. +#define CHROME_RIG_MIN_ARM_LENGTH 0.4 + +/// Where the torso under a side view's near arm is filled from: a pixel takes the one this far behind +/// it along x (negative: from in front). list(dir = shift). +GLOBAL_LIST_INIT(chrome_rig_fill_shift, list( + "[EAST]" = -4, + "[WEST]" = 4, +)) + +/** + * A matrix turning a puppet by [angle] (clockwise) about [pivot_x], [pivot_y] (pixels from the centre), + * then moving it by [shift_x], [shift_y]. + */ +/proc/chrome_rig_turn(angle, pivot_x = 0, pivot_y = 0, shift_x = 0, shift_y = 0, scale_x = 1, scale_y = 1) + var/matrix/turned = matrix() + turned.Translate(-pivot_x, -pivot_y) + if(scale_x != 1 || scale_y != 1) + turned.Scale(scale_x, scale_y) + turned.Turn(angle) + turned.Translate(pivot_x + shift_x, pivot_y + shift_y) + return turned + +/// A hidden body's own look, standing where it was drawn until its puppets' pictures reach a client (conceal()). +/obj/effect/abstract/chrome_rig_stand_in + name = "body" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + animate_movement = NO_STEPS + +/// The solid box a stand-in is cut out by, riding on it and never drawn itself. It comes from the puppets' file. +/obj/effect/abstract/chrome_rig_cutout + name = "" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + // Upright whatever the stand-in's own turn: a filter cuts it before it is turned + appearance_flags = RESET_TRANSFORM | RESET_COLOR | RESET_ALPHA + vis_flags = VIS_INHERIT_PLANE | VIS_INHERIT_LAYER + +/** + * The one picture file every puppet of the rigs that go up in the same tick is drawn from: a solid box (what + * the stand-ins are cut out by) and each puppet's picture, every one under a name of its own. One file lands + * on a client at one moment, so nothing of those rigs is drawn before the rest. + */ +/datum/chrome_rig_sheet + /// The world.time it was started in + var/made_at + /// The rigs drawn from it + var/list/datum/chrome_rig/rigs = list() + /// The file + var/icon/pictures + +/// The sheet for rigs going up in this tick. +/proc/chrome_rig_sheet_now() + var/static/datum/chrome_rig_sheet/current + if(isnull(current) || current.made_at != world.time) + current = new + current.made_at = world.time + return current + +/// Builds the file again from every puppet its rigs have now, and points them and the stand-ins' cut-outs at it. +/datum/chrome_rig_sheet/proc/redraw() + var/static/icon/box + if(isnull(box)) + box = icon('icons/blanks/32x32.dmi', "nothing") + box.DrawBox("#ffffff", 1, 1, ICON_SIZE_X, ICON_SIZE_Y) + var/icon/file = icon(box) + file.Insert(box, CHROME_RIG_BOX_STATE) + var/list/states = list() + for(var/datum/chrome_rig/rig as anything in rigs) + for(var/key in rig.puppets) + var/obj/effect/abstract/chrome_puppet/puppet = rig.puppets[key] + if(QDELETED(puppet) || (isnull(puppet.picture) && isnull(puppet.icon))) + continue + // One stood up by its owner, not add_puppet(): its picture is whatever it shows + if(isnull(puppet.picture)) + puppet.picture = icon(puppet.icon, puppet.icon_state) + var/state = "puppet_[length(states) + 1]" + file.Insert(puppet.picture, state) + // BYOND drops an Insert whose picture is pixel for pixel one already in the file while the file's inserts + // are still pending (a back view's arm is often the front view's), and the puppet would show the file's + // first state, the white box. Reading the file's states after each Insert makes every one land. One that + // still didn't keeps the picture it has. + if(!(state in icon_states(file))) + continue + states[puppet] = state + pictures = file + for(var/obj/effect/abstract/chrome_puppet/puppet as anything in states) + puppet.icon = file + puppet.icon_state = states[puppet] + for(var/datum/chrome_rig/rig as anything in rigs) + if(rig.cutout) + rig.cutout.icon = file + rig.cutout.icon_state = CHROME_RIG_BOX_STATE + +/// One stand-in picture on a hidden body's tile. +/obj/effect/abstract/chrome_puppet + name = "body" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + appearance_flags = PIXEL_SCALE | TILE_BOUND | LONG_GLIDE + // A puppet moved to the next tile is re-offset by a tile at once; a glide would draw it a tile out and slide it back + animate_movement = NO_STEPS + plane = GAME_PLANE + layer = MOB_LAYER + vis_flags = NONE + /// The picture it was given, as it was before it went into a sheet + var/icon/picture + +/// Hides a body and stands puppets in its place. +/datum/chrome_rig + /// The hidden body + var/mob/living/body + /// The flat picture puppets are cut from + var/icon/flat + /// The facing the picture was taken in + var/facing + /// Key -> /obj/effect/abstract/chrome_puppet + var/list/puppets = list() + /// The body's click area before it was hidden + var/old_mouse_opacity + /// TRUE while the body is hidden + var/hidden = FALSE + /// The body's own look, standing in for it until the puppets' pictures reach a client + var/obj/effect/abstract/chrome_rig_stand_in/stand_in + /// What the stand-in is cut out by + var/obj/effect/abstract/chrome_rig_cutout/cutout + /// The file this rig's puppets are drawn from + var/datum/chrome_rig_sheet/sheet + /// Side -> list(turn, length) the arm was last sent to + var/list/arm_poses = list() + /// The body's own transform (a lying body's turn) under every pose of its arms, or null for none + var/matrix/base_transform + /// Degrees the body is bent forward from the feet (negative: leaning back), seen from the side + var/bend_angle = 0 + /// Called when the hidden body moves or changes posture, for an owner that asked (watch_body()) + var/datum/callback/on_disturbed + +/datum/chrome_rig/New(mob/living/body, facing) + . = ..() + src.body = body + src.facing = facing || body.dir + if(!(src.facing in GLOB.cardinals)) + src.facing = (src.facing & (EAST|WEST)) || SOUTH + RegisterSignal(body, COMSIG_QDELETING, PROC_REF(on_body_deleted)) + +/datum/chrome_rig/Destroy() + reveal() + QDEL_NULL(stand_in) + QDEL_NULL(cutout) + if(sheet) + sheet.rigs -= src + sheet = null + for(var/key in puppets) + qdel(puppets[key]) + puppets = null + if(body) + UnregisterSignal(body, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BODY_POSITION, COMSIG_ATOM_POST_DIR_CHANGE)) + body = null + flat = null + on_disturbed = null + return ..() + +/datum/chrome_rig/proc/on_body_deleted(datum/source) + SIGNAL_HANDLER + qdel(src) + +/** + * Calls [disturbed] when the hidden body moves or is knocked down, so its owner can take the rig down. The rig + * listens itself: an owner that already listens to the body for its own reasons (an action does) keeps its handlers. + */ +/datum/chrome_rig/proc/watch_body(datum/callback/disturbed, turns = FALSE) + if(QDELETED(body)) + return + on_disturbed = disturbed + RegisterSignals(body, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BODY_POSITION), PROC_REF(on_body_disturbed)) + // With [turns], a body that turns to face another way too: its puppets are pictures of the old facing + if(turns) + RegisterSignal(body, COMSIG_ATOM_POST_DIR_CHANGE, PROC_REF(on_body_turned)) + +/datum/chrome_rig/proc/on_body_disturbed(datum/source) + SIGNAL_HANDLER + on_disturbed?.InvokeAsync() + +/datum/chrome_rig/proc/on_body_turned(datum/source, old_dir, new_dir) + SIGNAL_HANDLER + if(old_dir != new_dir) + on_disturbed?.InvokeAsync() + +/// Takes the flat picture. Returns FALSE if the body can't be rigged (gone, or not a 32x32 picture). +/datum/chrome_rig/proc/snapshot() + if(QDELETED(body) || !isturf(body.loc)) + return FALSE + var/icon/picture = getFlatIcon(body, facing, no_anim = TRUE) + if(!picture || picture.Width() != ICON_SIZE_X || picture.Height() != ICON_SIZE_Y) + return FALSE + flat = picture + return TRUE + +/// A copy of the flat picture cut by [mask_state] (white keeps, clear cuts) from the rig masks. +/datum/chrome_rig/proc/cut(mask_state) + var/icon/piece = icon(flat) + piece.Blend(icon(GORILLA_GORE_ICON, mask_state, facing), ICON_MULTIPLY) + return piece + +/// The flat picture with the arm on [side] ("l", "r" or "both") cut out, the torso under it filled. +/datum/chrome_rig/proc/cut_without_arms(side = "both") + var/icon/piece = cut(side == "both" ? "rig_keep" : "rig_keep_[side]") + var/shift = GLOB.chrome_rig_fill_shift["[facing]"] + if(!shift) + return piece + for(var/fill_side in (side == "both" ? list("l", "r") : list(side))) + var/icon/fill = icon(flat) + fill.Shift(shift > 0 ? EAST : WEST, abs(shift)) + fill.Blend(icon(GORILLA_GORE_ICON, "rig_fill_[fill_side]", facing), ICON_MULTIPLY) + piece.Blend(fill, ICON_OVERLAY) + return piece + +/** + * The flat picture above the neck (the head, with its hair and hat) if [head], else below it. The head keeps + * the body's top row too, so the two overlap at the neck and no seam opens while the head is squashed. + */ +/datum/chrome_rig/proc/cut_at_neck(head = TRUE) + var/icon/piece = icon(flat) + if(head) + piece.DrawBox(null, 1, 1, ICON_SIZE_X, CHROME_RIG_NECK_Y - 2) + else + piece.DrawBox(null, 1, CHROME_RIG_NECK_Y, ICON_SIZE_X, ICON_SIZE_Y) + return piece + +/** + * Hides the real body. Its whole tile still takes clicks. Call it once the rig's puppets are up: they go into + * the tick's sheet here. Until that file reaches a client the body's stand-in shows, [shift_x], [shift_y] + * pixels from where the body is drawn: where its puppets start, if not on the body. + */ +/datum/chrome_rig/proc/conceal(shift_x = 0, shift_y = 0) + if(hidden || QDELETED(body)) + return + hidden = TRUE + var/turf/spot = get_turf(body) + if(spot) + // Taken before the body is hidden, or it would be a copy of nothing + stand_in = new(spot) + stand_in.appearance = body.appearance + // A look carries no facing: without the body's own it would stand facing the viewer + stand_in.dir = body.dir + stand_in.mouse_opacity = MOUSE_OPACITY_TRANSPARENT + stand_in.pixel_x = body.pixel_x + shift_x + stand_in.pixel_y = body.pixel_y + shift_y + stand_in.pixel_w = body.pixel_w + stand_in.pixel_z = body.pixel_z + // The body's own filters stay on its copy when the cut-out goes on + stand_in.filter_data = body.filter_data?.Copy() + cutout = new(null) + cutout.render_target = "*chrome_rig_[REF(src)]" + stand_in.vis_contents += cutout + stand_in.add_filter(CHROME_RIG_SWAP_FILTER, 1, alpha_mask_filter(render_source = cutout.render_target, flags = MASK_INVERSE)) + old_mouse_opacity = body.mouse_opacity + body.mouse_opacity = MOUSE_OPACITY_OPAQUE + body.add_filter(CHROME_RIG_HIDE_FILTER, 1, color_matrix_filter(list(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0))) + pack() + +/** + * Puts this rig's puppets in the sheet of the tick it goes up in (conceal() does). A rig that is never + * concealed, because another rig of the same body is, calls this itself. + */ +/datum/chrome_rig/proc/pack() + if(sheet && sheet.made_at != world.time) + // Its file has gone out: a puppet added now is a picture of its own + return + sheet = chrome_rig_sheet_now() + sheet.rigs |= src + sheet.redraw() + +/** + * Hides the real body [hold] from now by the client's own clock, in step with its puppets. Until then the puppets must + * stand exactly over the body, so nothing changes on screen while their pictures are still on their way to a client, + * and a late picture never shows a missing body. + */ +/datum/chrome_rig/proc/conceal_after(hold) + conceal() + if(hold <= 0 || QDELETED(body)) + return + var/hide = body.get_filter(CHROME_RIG_HIDE_FILTER) + if(!hide) + return + var/static/list/hidden = list(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0) + animate(hide, color = COLOR_MATRIX_IDENTITY, time = 0) + animate(color = COLOR_MATRIX_IDENTITY, time = hold) + animate(color = hidden, time = CHROME_RIG_SWAP) + +/// Shows the real body again. +/datum/chrome_rig/proc/reveal() + if(!hidden) + return + hidden = FALSE + QDEL_NULL(stand_in) + QDEL_NULL(cutout) + if(QDELETED(body)) + return + body.mouse_opacity = old_mouse_opacity + body.remove_filter(CHROME_RIG_HIDE_FILTER) + +/** + * Stands a puppet showing [picture] on the body's tile under [key], replacing any under that key. + * It starts where the body is drawn now: the body's offsets and, with [copy_transform], its transform. + */ +/datum/chrome_rig/proc/add_puppet(key, icon/picture, copy_transform = FALSE, puppet_layer) + var/turf/spot = get_turf(body) + if(isnull(spot)) + return null + qdel(puppets[key]) + var/obj/effect/abstract/chrome_puppet/puppet = new(spot) + puppet.name = body.name + puppet.icon = picture + puppet.picture = picture + puppet.dir = SOUTH + puppet.pixel_x = body.pixel_x + puppet.pixel_y = body.pixel_y + puppet.pixel_w = body.pixel_w + puppet.pixel_z = body.pixel_z + // The body's own plane: a level drawn on offset planes has its bodies on one of those + puppet.plane = body.plane + puppet.layer = puppet_layer || body.layer + if(copy_transform) + puppet.transform = body.transform + puppets[key] = puppet + // Stood up after the rig was packed, in the same tick: into the same file + if(sheet?.made_at == world.time) + sheet.redraw() + return puppet + +/// The puppet under [key], or null. +/datum/chrome_rig/proc/puppet(key) + return puppets?[key] + +/// Deletes the puppet under [key]. +/datum/chrome_rig/proc/drop_puppet(key) + var/obj/effect/abstract/chrome_puppet/puppet = puppets?[key] + if(puppet) + puppets -= key + qdel(puppet) + +/// The pose (list(turn, length)) of the arm on [side] raised [angle] degrees from hanging with [reach] pixels of piston, as swing_arm() takes them. +/datum/chrome_rig/proc/pose_of(side, angle, reach = 0) + return list(angle * raise_sign(side), max(CHROME_RIG_MIN_ARM_LENGTH, 1 + reach / (GLOB.chrome_rig_arm_length["[facing]"] || 10))) + +/// The pivot of the shoulder on [side] ("l" or "r") in this rig's facing. +/datum/chrome_rig/proc/shoulder(side) + var/list/pivots = GLOB.chrome_rig_shoulders["[facing]"] + return side == "l" ? list(pivots[1], pivots[2]) : list(pivots[3], pivots[4]) + +/** + * Which way the arm on [side] turns to come up and out from the body: clockwise (1) or anticlockwise + * (-1). In a side view both arms come up toward the facing. + */ +/datum/chrome_rig/proc/raise_sign(side) + switch(facing) + if(SOUTH) + return side == "r" ? 1 : -1 + if(NORTH) + return side == "l" ? 1 : -1 + if(EAST) + return -1 + if(WEST) + return 1 + return 1 + +/** + * Builds the standard bearer rig: the body without arms and both arms on their own puppets. Hides the + * real body. Returns TRUE if it is up. + */ +/datum/chrome_rig/proc/rig_arms(hold = 0) + if(!snapshot()) + return FALSE + add_puppet("body", cut_without_arms("both")) + for(var/side in list("l", "r")) + var/obj/effect/abstract/chrome_puppet/arm = add_puppet("arm_[side]", arm_picture(side)) + arm.layer = body.layer + (behind_body(side) ? -0.01 : 0.01) + // With a [hold], the body stays on show that long under its puppets (conceal_after()) + conceal_after(hold) + return TRUE + +/** + * Takes the flat picture again and gives the standard bearer puppets their new cuts, where they stand and as + * they are posed. Blood that lands on the hidden body mid-move shows on its stand-ins at once, not only when + * the rig comes down. Returns FALSE if the picture can't be taken; the old one stays. + */ +/datum/chrome_rig/proc/redraw_arms() + if(!snapshot()) + return FALSE + repaint("body", cut_without_arms("both")) + for(var/side in list("l", "r")) + repaint("arm_[side]", arm_picture(side)) + return TRUE + +/** + * Draws [picture] over the puppet under [key], in place of anything drawn over it before. Not a swap of its icon: + * a picture made at runtime takes a moment to reach each client, and a puppet whose only picture is still on its + * way is drawn as nothing, so it would blink out. The old picture stays under the new one until that lands. + */ +/datum/chrome_rig/proc/repaint(key, icon/picture) + var/obj/effect/abstract/chrome_puppet/puppet = puppets?[key] + if(!puppet || !picture) + return + puppet.cut_overlays() + puppet.add_overlay(mutable_appearance(picture)) + +/// Whether the arm on [side] is the far one in a side view, under the body. Seen from the front or back both arms are over it. +/datum/chrome_rig/proc/behind_body(side) + return (facing in list(EAST, WEST)) && side != near_side() + +/** + * The picture of the arm on [side]. The far arm is hidden behind the body in a side view, so its cut is + * empty: it is drawn as the near arm, a pixel further back and in shadow, so a raised pair reads as two arms. + */ +/datum/chrome_rig/proc/arm_picture(side) + if(!behind_body(side)) + return cut("rig_arm_[side]") + var/icon/picture = cut("rig_arm_[near_side()]") + picture.Shift(facing == EAST ? WEST : EAST, 1) + picture.Blend(rgb(170, 170, 178), ICON_MULTIPLY) + return picture + +/** + * The torso that shows where the arm on [side] hangs once that arm is gone: filled from the torso just beside it, as + * cut_without_arms() fills it. Null when nothing is under the arm (seen from the front or back, or the far arm). + */ +/datum/chrome_rig/proc/fill_picture(side) + var/shift = GLOB.chrome_rig_fill_shift["[facing]"] + if(!shift || behind_body(side)) + return null + var/icon/fill = icon(flat) + fill.Shift(shift > 0 ? EAST : WEST, abs(shift)) + fill.Blend(icon(GORILLA_GORE_ICON, "rig_fill_[side]", facing), ICON_MULTIPLY) + return fill + +/** + * Every puppet takes the offsets the hidden body has now: eased as tg eases a tracked offset (add_offsets()) with + * [eased], else at once. For a body that leans or trembles under its puppets, so it is where they are when they go. + */ +/datum/chrome_rig/proc/follow_offsets(eased = TRUE) + if(QDELETED(body)) + return + for(var/key in puppets) + var/obj/effect/abstract/chrome_puppet/puppet = puppets[key] + if(puppet.pixel_w == body.pixel_w && puppet.pixel_x == body.pixel_x && puppet.pixel_y == body.pixel_y && puppet.pixel_z == body.pixel_z) + continue + if(eased) + animate(puppet, pixel_w = body.pixel_w, pixel_x = body.pixel_x, pixel_y = body.pixel_y, pixel_z = body.pixel_z, easing = (EASE_IN|EASE_OUT), flags = ANIMATION_PARALLEL, time = UPDATE_TRANSFORM_ANIMATION_TIME) + else + puppet.pixel_w = body.pixel_w + puppet.pixel_x = body.pixel_x + puppet.pixel_y = body.pixel_y + puppet.pixel_z = body.pixel_z + +/// Pixels from the shoulder pivot on [side] to the middle of its hand, on a hanging arm. +/datum/chrome_rig/proc/hand_offset(side) + var/list/hands = GLOB.chrome_rig_hands["[facing]"] + return side == "l" ? list(hands[1], hands[2]) : list(hands[3], hands[4]) + +/// The length of the arm on [side]: shoulder pivot to the middle of the hand. +/datum/chrome_rig/proc/arm_reach(side) + var/list/hand = hand_offset(side) + return sqrt(hand[1] * hand[1] + hand[2] * hand[2]) + +/** + * The matrix posing the arm on [side]: turned [turn] degrees about its shoulder, [length] times as long, then + * turned with the body ([base], else the rig's base_transform). + */ +/datum/chrome_rig/proc/arm_matrix(side, turn, length, matrix/base) + var/list/pivot = shoulder(side) + var/matrix/pose = chrome_rig_turn(turn, pivot[1], pivot[2], 0, 0, 1, length) + var/matrix/under = base || base_transform + if(under) + pose.Multiply(under) + return pose + +/// The body bent forward [angle] degrees from the feet, seen from the side; null when it doesn't turn (no angle, or seen from the front or back). +/datum/chrome_rig/proc/bend_matrix(angle) + if(!angle || !(facing in list(EAST, WEST))) + return null + return chrome_rig_turn(facing == WEST ? -angle : angle, 0, CHROME_RIG_FEET_Y) + +/** + * Bends the body to [to_bend] degrees from the feet (see bend_matrix()) while both arms swing to [angle], as + * swing_arm() does, step for step so the arms stay on the shoulders, over [time]. + */ +/datum/chrome_rig/proc/bend_and_swing(to_bend, angle, time, reach = 0) + var/steps = swing_steps(bend_angle, to_bend) + var/list/targets = list() + for(var/side in list("l", "r")) + var/list/from = arm_poses[side] || list(0, 1) + var/to_turn = angle * raise_sign(side) + targets[side] = list(to_turn, max(CHROME_RIG_MIN_ARM_LENGTH, 1 + reach / (GLOB.chrome_rig_arm_length["[facing]"] || 10))) + steps = max(steps, swing_steps(from[1], to_turn)) + var/list/bases = list() + for(var/i in 1 to steps) + bases += list(bend_matrix(bend_angle + (to_bend - bend_angle) * (1 - cos(180 * i / steps)) / 2)) + for(var/side in list("l", "r")) + var/list/from = arm_poses[side] || list(0, 1) + var/list/to_pose = targets[side] + var/list/poses = list() + for(var/i in 1 to steps) + var/progress = (1 - cos(180 * i / steps)) / 2 + poses += list(list(from[1] + (to_pose[1] - from[1]) * progress, from[2] + (to_pose[2] - from[2]) * progress, bases[i])) + pose_arm_through(side, poses, time / steps) + body_through(bases, time / steps) + bend_angle = to_bend + base_transform = bend_matrix(to_bend) + +/// Sends the body puppet through [bases] (matrices, null for upright), one straight step of [step_time] each (or of step_time[i], given a list), as its arms go through theirs. +/datum/chrome_rig/proc/body_through(list/bases, step_time) + var/obj/effect/abstract/chrome_puppet/body_puppet = puppet("body") + if(!body_puppet) + return + for(var/i in 1 to length(bases)) + var/matrix/base = bases[i] || matrix() + var/this_step = islist(step_time) ? step_time[i] : step_time + if(i == 1) + animate(body_puppet, transform = base, time = this_step) + else + animate(transform = base, time = this_step) + +/// [x], [y] (pixels from the middle of the picture) put through [transform]. +/proc/chrome_rig_apply(matrix/transform, x, y) + return list(transform.a * x + transform.b * y + transform.c, transform.d * x + transform.e * y + transform.f) + +/// [flat] (a body's own turn, a lying one's) turned on by [angle] degrees (clockwise) about the body's feet as drawn under it. +/proc/chrome_rig_turn_about_feet(matrix/flat, angle) + var/matrix/turned = matrix(flat) + if(!angle) + return turned + var/list/feet = chrome_rig_apply(turned, 0, CHROME_RIG_FEET_Y) + turned.Multiply(chrome_rig_turn(angle, feet[1], feet[2])) + return turned + +/// Where the shoulder on [side] is drawn under [base] (else base_transform): pixels from the middle of the puppet, before its offsets. +/datum/chrome_rig/proc/shoulder_point(side, matrix/base) + var/list/pivot = shoulder(side) + var/matrix/under = base || base_transform + return under ? chrome_rig_apply(under, pivot[1], pivot[2]) : pivot + +/// Where the hand on [side] is drawn in the arm's last pose: pixels from the middle of the puppet, before its offsets. +/datum/chrome_rig/proc/hand_point(side) + return hand_at(side, arm_poses[side] || list(0, 1)) + +/// Where the hand on [side] is drawn in [pose] (list(turn, length), or list(turn, length, base)): pixels from the middle of the puppet, before its offsets. +/datum/chrome_rig/proc/hand_at(side, list/pose) + var/list/pivot = shoulder(side) + var/list/hand = hand_offset(side) + return chrome_rig_apply(arm_matrix(side, pose[1], pose[2], length(pose) > 2 ? pose[3] : null), pivot[1] + hand[1], pivot[2] + hand[2]) + +/** + * The pose (list(turn, length)) that puts the hand on [side] at [x], [y] (pixels from the middle of the + * puppet, as drawn, before its offsets) with the body turned by [base] (else base_transform): the arm turned + * about its shoulder and stretched or shortened along its length. Turned the short way round from [from_turn]. + */ +/datum/chrome_rig/proc/pose_reaching(side, x, y, from_turn = 0, matrix/base) + // Back through the body's turn into the flat picture's own pixels + var/matrix/body_turn = base || base_transform + if(body_turn) + var/det = body_turn.a * body_turn.e - body_turn.b * body_turn.d + if(det) + var/rel_x = x - body_turn.c + var/rel_y = y - body_turn.f + x = (body_turn.e * rel_x - body_turn.b * rel_y) / det + y = (body_turn.a * rel_y - body_turn.d * rel_x) / det + var/list/pivot = shoulder(side) + var/list/hand = hand_offset(side) + var/to_x = x - pivot[1] + var/to_y = y - pivot[2] + var/reach = sqrt(to_x * to_x + to_y * to_y) + if(reach < 1) + return list(from_turn, CHROME_RIG_MIN_ARM_LENGTH) + // Only the length stretches, so the hand keeps its sideways offset from the shoulder + var/length = max(CHROME_RIG_MIN_ARM_LENGTH, sqrt(max(0, reach * reach - hand[1] * hand[1])) / abs(hand[2])) + var/turn = arctan(hand[1], hand[2] * length) - arctan(to_x, to_y) + while(turn - from_turn > 180) + turn -= 360 + while(turn - from_turn < -180) + turn += 360 + return list(turn, length) + +/// How many straight steps a swing from [from_turn] to [to_turn] takes, so the shoulder stays on its pivot. +/datum/chrome_rig/proc/swing_steps(from_turn, to_turn) + return max(1, CEILING(abs(to_turn - from_turn) / CHROME_RIG_SWING_STEP, 1)) + +/** + * Sends the arm on [side] through [poses] (each list(turn, length), or list(turn, length, base) with the + * body's turn at that step), one straight step of [step_time] to each (or of step_time[i] to the i-th, given a + * list). Arms sent through matching poses in the same steps move together, hand on hand. + */ +/datum/chrome_rig/proc/pose_arm_through(side, list/poses, step_time) + var/obj/effect/abstract/chrome_puppet/arm = puppet("arm_[side]") + if(!arm || !length(poses)) + return + for(var/i in 1 to length(poses)) + var/list/pose = poses[i] + var/matrix/posed = arm_matrix(side, pose[1], pose[2], length(pose) > 2 ? pose[3] : null) + var/this_step = islist(step_time) ? step_time[i] : step_time + if(i == 1) + animate(arm, transform = posed, time = this_step) + else + animate(transform = posed, time = this_step) + var/list/last = poses[length(poses)] + arm_poses[side] = list(last[1], last[2]) + +/** + * Sends the hand on [side] to each of [points] in turn (list(x, y), pixels from the middle of the puppet, as + * pose_reaching() takes them), times[i] to the i-th, each leg cut into short steps so the shoulder stays put. The + * arm is never stretched past [max_length] times its length: the hand stops short instead. + */ +/datum/chrome_rig/proc/reach_through(side, list/points, list/times, max_length = 2) + var/list/from = arm_poses[side] || list(0, 1) + var/list/poses = list() + var/list/step_times = list() + for(var/i in 1 to length(points)) + var/list/point = points[i] + var/list/to_pose = pose_reaching(side, point[1], point[2], from[1]) + to_pose[2] = min(to_pose[2], max_length) + var/steps = swing_steps(from[1], to_pose[1]) + for(var/j in 1 to steps) + var/progress = (1 - cos(180 * j / steps)) / 2 + poses += list(list(from[1] + (to_pose[1] - from[1]) * progress, from[2] + (to_pose[2] - from[2]) * progress)) + step_times += times[i] / steps + from = to_pose + pose_arm_through(side, poses, step_times) + +/** + * Counts each arm's turn the short way round from hanging, without moving it (a full turn more or less is the same + * pose). An arm swung on past straight up then comes down the way it points, not back up over the head. + */ +/datum/chrome_rig/proc/unwind_arms() + for(var/side in arm_poses) + var/list/pose = arm_poses[side] + while(pose[1] > 180) + pose[1] -= 360 + while(pose[1] <= -180) + pose[1] += 360 + +/// The arm nearer the viewer in a side view ("l" or "r"); the right arm in other views. +/datum/chrome_rig/proc/near_side() + return facing == WEST ? "l" : "r" + +/** + * Turns the arm on [side] to [angle] degrees up from hanging (0) over [time]. [reach] pixels of piston + * push the fist out along the arm (negative pulls it in, as an arm reaching toward the viewer looks + * shorter). The arm stretches or shortens from the shoulder, so its top never leaves the shoulder. + * + * BYOND blends the move part of a turned matrix in a straight line, which would carry the shoulder off + * its pivot halfway through a big swing, so a swing is cut into steps of a few degrees. + */ +/datum/chrome_rig/proc/swing_arm(side, angle, time, reach = 0, easing = SINE_EASING) + var/obj/effect/abstract/chrome_puppet/arm = puppet("arm_[side]") + if(!arm) + return + var/list/from = arm_poses[side] || list(0, 1) + var/to_turn = angle * raise_sign(side) + var/to_length = max(CHROME_RIG_MIN_ARM_LENGTH, 1 + reach / (GLOB.chrome_rig_arm_length["[facing]"] || 10)) + arm_poses[side] = list(to_turn, to_length) + var/steps = max(1, CEILING(abs(to_turn - from[1]) / CHROME_RIG_SWING_STEP, 1)) + var/step_time = time / steps + for(var/i in 1 to steps) + // Sine in and out across the whole swing; each step itself is straight + var/progress = (easing & SINE_EASING) ? (1 - cos(180 * i / steps)) / 2 : i / steps + var/matrix/pose = arm_matrix(side, from[1] + (to_turn - from[1]) * progress, from[2] + (to_length - from[2]) * progress) + if(i == 1) + animate(arm, transform = pose, time = step_time) + else + animate(transform = pose, time = step_time) + +/** + * The body crouches over [time]: squashed to [squash] of its height and dropped [drop] pixels, the arms + * coming down with their shoulders. 1 and 0 stand it back up. + */ +/datum/chrome_rig/proc/crouch(squash, drop, time, easing = SINE_EASING) + var/obj/effect/abstract/chrome_puppet/body_puppet = puppet("body") + if(body_puppet) + animate(body_puppet, transform = matrix(1, 0, 0, 0, squash, -drop), time = time, easing = easing) + for(var/side in list("l", "r")) + var/obj/effect/abstract/chrome_puppet/arm = puppet("arm_[side]") + if(!arm) + continue + // Where the squashed body puts this shoulder + var/list/pivot = shoulder(side) + animate(arm, pixel_z = round(pivot[2] * squash - drop - pivot[2]), time = time, easing = easing, flags = ANIMATION_PARALLEL) + +/// Every puppet (but those under the keys in [skip]: one drawn on another moves with it) trembles a pixel for [time], and ends where it began. +/datum/chrome_rig/proc/tremble(time = 0.4 SECONDS, list/skip) + for(var/key in puppets) + if(key in skip) + continue + var/obj/effect/abstract/chrome_puppet/puppet = puppets[key] + var/moved = 0 + for(var/i in 1 to max(1, round(time / (0.1 SECONDS)))) + var/step = (i % 2) ? 1 : -1 + if(i == 1) + animate(puppet, pixel_w = step, time = 0.05 SECONDS, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + moved += step + else + animate(pixel_w = step * 2, time = 0.05 SECONDS, flags = ANIMATION_RELATIVE) + moved += step * 2 + animate(pixel_w = -step, time = 0.05 SECONDS, flags = ANIMATION_RELATIVE) + moved -= step + // An even count leaves it a pixel off, which would jump back when the rig comes down + if(moved) + animate(pixel_w = -moved, time = 0.05 SECONDS, flags = ANIMATION_RELATIVE) + +/// Every puppet flashes white and fades back. +/datum/chrome_rig/proc/flash() + for(var/key in puppets) + cyberware_flash_fx(puppets[key], 0.2 SECONDS) + +#undef CHROME_RIG_HIDE_FILTER +#undef CHROME_RIG_SWAP_FILTER +#undef CHROME_RIG_BOX_STATE +#undef CHROME_RIG_SWING_STEP +#undef CHROME_RIG_SWAP +#undef CHROME_RIG_MIN_ARM_LENGTH diff --git a/voidcrew/modules/hyperviolence_gorilla/chrome_use_release.dm b/voidcrew/modules/hyperviolence_gorilla/chrome_use_release.dm new file mode 100644 index 00000000000..4b24244c20a --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/chrome_use_release.dm @@ -0,0 +1,25 @@ +/** + * # Use chrome, let go + * + * A hook for charged chrome on the chrome wheel (cyberware/chrome_wheel*.dm): when the Use chrome key comes + * back up, the picked ability hears it through chrome_use_released(). The Gorilla haymaker throws its + * charge there. Kept in its own file so other charged chrome can share it. + */ + +/** + * The bearer let go of the Use chrome key with this ability picked. A charged ability can throw what + * it built up. Returns TRUE if it did something. Every other ability ignores it. + */ +/datum/action/proc/chrome_use_released(mob/living/carbon/bearer) + return FALSE + +/datum/keybinding/living/chrome/use/up(client/user, turf/target) + . = ..() + if(.) + return + var/mob/living/carbon/bearer = user.mob + if(!iscarbon(bearer)) + return + var/datum/component/chrome_wheel/wheel = bearer.GetComponent(/datum/component/chrome_wheel) + var/datum/action/picked = wheel?.get_selected_ability() + picked?.chrome_use_released(bearer) diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_finisher.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_finisher.dm new file mode 100644 index 00000000000..cb85f71c3c4 --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_finisher.dm @@ -0,0 +1,2128 @@ +/** + * # Gorilla finishers (owner D39) + * + * A piston punch from a synced real pair, with both hands empty, on someone in crit or stunned, finishes + * them instead. The aimed zone picks which: + * - Head: the head clap. Hauled off the floor by the collar, a beat of kicking, then both fists meet on + * the head and it bursts (#509's burst; the brain is thrown out whole, so revival works). A helmet or + * plating crumples instead and the skull caves in. Needs gravity, or the brain would drift off. + * - Arm (the aimed one, else the other): the limb rip. A boot on the body, both fists on the arm, it tears + * off at the shoulder with the spray running back over the bearer, and one blow to the head with it. + * Armour on the arm wrenches the shoulder out instead. + * - Chest: the backbreaker. Pressed overhead, brought down across a knee, the back breaks and the body + * is shoved off it, still bent, onto the tile he faces (at his feet if that tile is blocked). Armour on + * the chest cracks the ribs instead. + * The Atlas frame beats all three: nothing bursts, tears or breaks. + * A synced pair of Brawler myomers has the limb rip only, the same rip on the same terms. + * + * The wind-up is the two bodies (owner D34: no mark): the puppet rig (chrome_puppet_rig.dm) poses the + * bearer's arms and the victim. It can be stopped like any #509 finisher: enough damage on the bearer, + * the bearer moving, stunned or cuffed, the victim pulled away or out of their stun, the arms falling + * out of sync. The haymaker and the finishers share the pistons' cooldown: longer after a kill than + * after being stopped. Starting one counts as aggression at a trader outpost. + */ + +/** + * Starts the Gorilla finisher [zone] picks (the bearer's aim when null), if one can start on [victim]. + * Returns TRUE if it did. The punch calls it with the aim; an AI can call it with a zone. + */ +/proc/gorilla_try_finisher(mob/living/carbon/human/source, mob/living/victim, zone) + if(!iscarbon(victim) || !ishuman(source) || !gorilla_may_use_heavy_moves(source)) + return FALSE + var/gorilla_pair = gorilla_synced(source) + if(!gorilla_pair && !brawler_synced(source)) + return FALSE + if(!TIMER_COOLDOWN_FINISHED(source, COOLDOWN_GORILLA_PISTONS) || source.chrome_finisher) + return FALSE + if(!chrome_finisher_valid_victim(source, victim)) + return FALSE + zone = check_zone(zone || source.zone_selected) + var/datum/hv_finisher/chrome/gorilla/finisher_type + switch(zone) + if(BODY_ZONE_HEAD) + finisher_type = /datum/hv_finisher/chrome/gorilla/clap + if(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM) + finisher_type = /datum/hv_finisher/chrome/gorilla/rip + if(BODY_ZONE_CHEST) + finisher_type = /datum/hv_finisher/chrome/gorilla/backbreaker + if(!finisher_type) + return FALSE + // Brawler myomers have the rip and nothing else + if(!gorilla_pair && !initial(finisher_type.brawler_ok)) + return FALSE + var/datum/hv_finisher/chrome/gorilla/finisher = new finisher_type(source, victim) + finisher.aimed_zone = zone + if(!finisher.start()) + qdel(finisher) + return FALSE + gorilla_register_aggression(victim, source) + return TRUE + +/datum/hv_finisher/chrome/gorilla + name = "gorilla finisher" + /// The zone the bearer aimed when it started + var/aimed_zone + /// The bearer's facing toward the victim, fixed at the start + var/facing + /// The bearer's puppets + var/datum/chrome_rig/bearer_rig + /// The victim's puppets + var/datum/chrome_rig/victim_rig + /// Whether a synced pair of Brawler myomers can do this one too, not only Gorilla Arms + var/brawler_ok = FALSE + /// Where the victim was drawn before the finisher's grab, list(x, y) of their pixel offsets: tg draws a grabbed body + /// pulled in at once, and the puppets ease that in instead + var/list/lying_offsets + +/datum/hv_finisher/chrome/gorilla/take_grip() + if(!gripped && isnull(lying_offsets) && !QDELETED(victim)) + lying_offsets = list(victim.pixel_x + victim.pixel_w, victim.pixel_y + victim.pixel_z) + return ..() + +/// Pixels from where the victim is drawn now back to where they lay before the grab: list(x, y). +/datum/hv_finisher/chrome/gorilla/proc/grab_pull_back() + if(isnull(lying_offsets) || QDELETED(victim)) + return list(0, 0) + return list(lying_offsets[1] - (victim.pixel_x + victim.pixel_w), lying_offsets[2] - (victim.pixel_y + victim.pixel_z)) + +/datum/hv_finisher/chrome/gorilla/can_start() + if(!..()) + return FALSE + if(!ishuman(user) || !pair_synced() || !TIMER_COOLDOWN_FINISHED(user, COOLDOWN_GORILLA_PISTONS)) + return FALSE + var/mob/living/carbon/human/bearer = user + for(var/obj/item/held in bearer.held_items) + return FALSE + var/list/arms = gorilla_synced_pair(bearer) + if(length(arms) < 2) + return FALSE + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in arms) + if(!arm.gorilla_running()) + return FALSE + // Square on only: from a corner the punch is just a punch + if(!finisher_square_on(user, victim)) + return FALSE + return can_start_on(victim) + +/// Whether the bearer's arms are synced for this finisher: a Gorilla pair, or a Brawler pair where it allows one. +/datum/hv_finisher/chrome/gorilla/proc/pair_synced() + return gorilla_synced(user) || (brawler_ok && brawler_synced(user)) + +/// What this finisher needs of the victim besides being down. +/datum/hv_finisher/chrome/gorilla/proc/can_start_on(mob/living/carbon/target) + return TRUE + +/datum/hv_finisher/chrome/gorilla/safety_check() + . = ..() + if(!. && !completed && !pair_synced()) + return HV_FINISHER_ATTACKER_DOWN + if(!. && !completed && finisher_on_corner(user, victim)) + return HV_FINISHER_LOST_GRIP + +/datum/hv_finisher/chrome/gorilla/stop(reason) + if(!running) + return + var/finished = completed + // The parent deletes the finisher, which clears these + var/mob/living/bearer = user + var/mob/living/body = victim + . = ..() + cleanup_rigs() + if(!QDELETED(bearer)) + gorilla_spend_pistons(bearer, finished ? GORILLA_PISTONS_COOLDOWN : GORILLA_PISTONS_INTERRUPTED) + if(finished && !QDELETED(body)) + hv_execution_witnesses(bearer, body) + +/datum/hv_finisher/chrome/gorilla/Destroy() + cleanup_rigs() + return ..() + +/// Takes every puppet down and shows both bodies. +/datum/hv_finisher/chrome/gorilla/proc/cleanup_rigs() + QDEL_NULL(bearer_rig) + QDEL_NULL(victim_rig) + +/// The bearer's rig, made on first use: the body without arms and both arms on their own puppets. +/datum/hv_finisher/chrome/gorilla/proc/rig_bearer() + if(bearer_rig || QDELETED(user)) + return bearer_rig + user.face_atom(victim) + facing = user.dir + bearer_rig = new(user, facing) + if(!bearer_rig.rig_arms()) + QDEL_NULL(bearer_rig) + return bearer_rig + +/// Whether the bearer is seen from the side (facing east or west). +/datum/hv_finisher/chrome/gorilla/proc/side_view() + return facing == EAST || facing == WEST + +// The one gate on who may use the Gorilla's heavy moves (gorilla_punch.dm). +/datum/hv_finisher/chrome/gorilla/user_may_finish() + return gorilla_may_use_heavy_moves(user) + +/// Pixels from the victim's tile to the bearer's. +/datum/hv_finisher/chrome/gorilla/proc/to_bearer() + return list((user.x - victim.x) * ICON_SIZE_X, (user.y - victim.y) * ICON_SIZE_Y) + +/// Both of the bearer's arms to [angle], with [reach] pixels of piston. +/datum/hv_finisher/chrome/gorilla/proc/arms_to(angle, time, reach = 0) + bearer_rig?.swing_arm("l", angle, time, reach) + bearer_rig?.swing_arm("r", angle, time, reach) + +/// The bearer's punching hand, the attacking item for #509's hooks. +/datum/hv_finisher/chrome/gorilla/proc/fist() + var/mob/living/carbon/bearer = user + return bearer.get_active_hand() || bearer.get_bodypart(BODY_ZONE_R_ARM) + +/// The bearer's arm on [which] ("near" or "far" to the viewer in a side view) to [angle], with [reach]. +/datum/hv_finisher/chrome/gorilla/proc/arm_to(which, angle, time, reach = 0) + if(!bearer_rig) + return + var/near = bearer_rig.near_side() + var/side = which == "near" ? near : (near == "l" ? "r" : "l") + bearer_rig.swing_arm(side, angle, time, reach) + +/// The bearer's arm puppet on [which] ("near" or "far"), or null. +/datum/hv_finisher/chrome/gorilla/proc/arm_puppet(which) + if(!bearer_rig) + return null + var/near = bearer_rig.near_side() + return bearer_rig.puppet("arm_[which == "near" ? near : (near == "l" ? "r" : "l")]") + +/// The beat a stage begins with: poses and sounds. Lines come from enter_line(). +/datum/hv_finisher/chrome/gorilla/proc/pose(key) + return + +/// A stage's beat: damage, gore, poses. +/datum/hv_finisher/chrome/gorilla/proc/beat(key) + return + +/// The line the room sees as a stage begins, or null. +/datum/hv_finisher/chrome/gorilla/proc/enter_line(key) + return null + +/// The line the victim sees as a stage begins, or null for the room's. +/datum/hv_finisher/chrome/gorilla/proc/enter_self_line(key) + return null + +/// The flash, sparks, ring and shake of a killing blow on [where], the sparks [spark_w], [spark_z] pixels from its middle. Only the victim flashes; the arms keep their look. +/datum/hv_finisher/chrome/gorilla/proc/hit_stop(atom/movable/where, heavy = TRUE, spark_z = 0, spark_w = 0) + victim_rig?.flash() + var/obj/effect/abstract/cyberware_anim/sparks = gorilla_play_impact(user, where, "impact_gorilla") + if(sparks) + sparks.pixel_z += spark_z + sparks.pixel_w += spark_w + var/turf/spot = get_turf(where) + if(spot) + // On the floor: on the game plane the ring was drawn over bodies standing further up the screen + new /obj/effect/temp_visual/circle_wave/cyberware_slam/floor(spot, heavy ? 1 : 0.6) + for(var/mob/living/viewer in range(4, spot)) + if(viewer.client) + shake_camera(viewer, heavy ? 3 : 2, heavy ? 2 : 1) + +// ---- The stages: each one hands its key to the finisher ---- + +/datum/hv_finisher_stage/hold/gorilla + lunge = 0 + effect_severity = 0 + /// What the finisher does in this stage + var/key + +/datum/hv_finisher_stage/hold/gorilla/enter() + . = ..() + var/datum/hv_finisher/chrome/gorilla/finisher = host + finisher.pose(key) + +/datum/hv_finisher_stage/hold/gorilla/effect() + var/datum/hv_finisher/chrome/gorilla/finisher = host + finisher.beat(key) + +/datum/hv_finisher_stage/hold/gorilla/enter_message() + var/datum/hv_finisher/chrome/gorilla/finisher = host + return finisher.enter_line(key) + +/datum/hv_finisher_stage/hold/gorilla/enter_self_message() + var/datum/hv_finisher/chrome/gorilla/finisher = host + return finisher.enter_self_line(key) + +/datum/hv_finisher_stage/kill/gorilla + lunge = 0 + effect_delay = 0 + duration = 1 SECONDS + var/key + +/datum/hv_finisher_stage/kill/gorilla/enter() + . = ..() + var/datum/hv_finisher/chrome/gorilla/finisher = host + finisher.pose(key) + +/datum/hv_finisher_stage/kill/gorilla/effect() + var/datum/hv_finisher/chrome/gorilla/finisher = host + finisher.beat(key) + +/datum/hv_finisher_stage/kill/gorilla/enter_message() + var/datum/hv_finisher/chrome/gorilla/finisher = host + return finisher.enter_line(key) + +/datum/hv_finisher_stage/recover/gorilla + duration = 0.8 SECONDS + var/key + +/datum/hv_finisher_stage/recover/gorilla/enter() + . = ..() + var/datum/hv_finisher/chrome/gorilla/finisher = host + finisher.pose(key) + +/datum/hv_finisher_stage/recover/gorilla/effect() + var/datum/hv_finisher/chrome/gorilla/finisher = host + finisher.beat(key) + +/datum/hv_finisher_stage/recover/gorilla/enter_message() + var/datum/hv_finisher/chrome/gorilla/finisher = host + return finisher.enter_line(key) + +/** + * Keeps #509's heavy-hit spray and its lost-limb spray off [victim] for the blow being dealt now. A + * finisher lays its own blood; #509's full fan from a held body reads as blood out of nowhere. + */ +/proc/gorilla_hold_spray(mob/living/victim) + victim.hv_blood_spray_until = max(victim.hv_blood_spray_until, world.time + 1) + victim.hv_blood_spray_strength = INFINITY + +/// One short line of [victim]'s blood toward [direction], [tiles] long, and nothing more from #509 for this blow. +/proc/gorilla_short_spray(mob/living/victim, direction, tiles = 2) + victim.hv_blood_throw(direction, tiles) + gorilla_hold_spray(victim) + +// ========================================================================= +// (A) THE HEAD CLAP +// ========================================================================= + +/datum/hv_finisher/chrome/gorilla/clap + name = "gorilla head clap" + zone_preference = list(BODY_ZONE_HEAD) + stages = list( + /datum/hv_finisher_stage/hold/gorilla/clap_hoist, + /datum/hv_finisher_stage/hold/gorilla/clap_squeeze, + /datum/hv_finisher_stage/hold/gorilla/clap_toss, + /datum/hv_finisher_stage/kill/gorilla/clap, + /datum/hv_finisher_stage/recover/gorilla/clap, + ) + /// The held body's offsets at rest in the hold, list(pixel_x, pixel_y, pixel_z): the fists move it about from there + var/list/held_at + /// Where the held head is as the fists meet on it, list(x, y) in pixels from the middle of its tile: what comes out of it starts there + var/list/burst_at + +/datum/hv_finisher_stage/hold/gorilla/clap_hoist + key = "hoist" + duration = 0.65 SECONDS + +/datum/hv_finisher_stage/hold/gorilla/clap_squeeze + key = "squeeze" + duration = 1 SECONDS + +/datum/hv_finisher_stage/hold/gorilla/clap_toss + key = "toss" + duration = 0.3 SECONDS + +/datum/hv_finisher_stage/kill/gorilla/clap + key = "clap" + // The fists meet, a beat of hit-stop, then the head goes + effect_delay = 0.15 SECONDS + +/datum/hv_finisher_stage/recover/gorilla/clap + key = "recover" + +// With nothing to hold the brain down it would drift off for good. +/datum/hv_finisher/chrome/gorilla/clap/can_start_on(mob/living/carbon/target) + var/turf/spot = get_turf(target) + return !isnull(target.get_bodypart(BODY_ZONE_HEAD)) && spot?.has_gravity() + +/datum/hv_finisher/chrome/gorilla/clap/pick_zone() + target_zone = BODY_ZONE_HEAD + return target_zone + +/datum/hv_finisher/chrome/gorilla/clap/enter_line(key) + switch(key) + if("hoist") + return "[user] hauls [victim] off the floor by the collar!" + if("squeeze") + return "[victim] chokes and kicks in [user]'s grip." + +/datum/hv_finisher/chrome/gorilla/clap/enter_self_line(key) + switch(key) + if("hoist") + return "[user] hauls you off the floor by the collar!" + if("squeeze") + return "You choke and kick in [user]'s grip." + +/// The middle of a human head above the neck line, half its width, and half a fist's width, in pixels (tg's human base sprite). +#define CLAP_HEAD_RISE 3.5 +#define CLAP_HEAD_HALF_WIDTH 4.5 +#define CLAP_FIST_HALF_WIDTH 1.5 +/// A chrome fist on an arm pointing up is drawn a couple of pixels short of its hand's middle: aim it that much higher. +#define CLAP_FIST_RAISE 2 + +/// The puppets of the body held in the clap that move it about. The head rides on the body (see the hoist), so it is not one. +/datum/hv_finisher/chrome/gorilla/clap/proc/held_parts() + . = list() + for(var/key_name in victim_rig?.puppets) + if(key_name != "head") + . += victim_rig.puppets[key_name] + +/** + * Where the bearer's fists go on the held head: side ("l" or "r") -> list(x, y), pixels from the middle of his + * puppets, as pose_reaching() takes them. Seen from the side both go on the temple, the near one over the head and the + * far one behind it; from the front or back, one on each side of it. [apart] pixels back off it (negative: pressed + * in), the head squashed to [width] and [height] about its neck, the held body moved [shift_x], [shift_y] pixels from + * where it rests in the hold. Null without both rigs. + */ +/datum/hv_finisher/chrome/gorilla/clap/proc/fists_on_head(apart = 0, width = 1, height = 1, shift_x = 0, shift_y = 0) + var/obj/effect/abstract/chrome_puppet/body_puppet = victim_rig?.puppet("body") + if(!bearer_rig || !body_puppet || !isturf(body_puppet.loc) || !held_at) + return null + // The held body's middle as drawn, from the middle of the bearer's puppets + var/held_x = (body_puppet.x - user.x) * ICON_SIZE_X + held_at[1] + shift_x - (user.pixel_x + user.pixel_w) + var/held_y = (body_puppet.y - user.y) * ICON_SIZE_Y + held_at[2] + held_at[3] + shift_y - (user.pixel_y + user.pixel_z) + // The picture faces the bearer, which puts the head's middle half a pixel off the picture's + var/head_x = held_x + (facing == WEST ? 0.5 : -0.5) * width + var/head_y = held_y + CHROME_RIG_NECK_PIVOT_Y + CLAP_HEAD_RISE * height + . = list() + if(side_view()) + var/back = facing == EAST ? -1 : 1 + for(var/side in list("l", "r")) + .[side] = list(head_x + back * apart, head_y - 1) + return + var/out_by = CLAP_HEAD_HALF_WIDTH * width + CLAP_FIST_HALF_WIDTH + apart + for(var/side in list("l", "r")) + var/list/pivot = bearer_rig.shoulder(side) + .[side] = list(head_x + (pivot[1] < 0 ? -out_by : out_by), head_y + CLAP_FIST_RAISE) + +/// Both fists to [fists] (fists_on_head()) over [time], in short steps. +/datum/hv_finisher/chrome/gorilla/clap/proc/fists_to(list/fists, time) + for(var/side in fists) + bearer_rig.reach_through(side, list(fists[side]), list(time), GORILLA_CLAP_MAX_REACH) + +/// The most either arm must stretch to put its fist on [fists] (fists_on_head()), as a share of its length. +/datum/hv_finisher/chrome/gorilla/clap/proc/fists_stretch(list/fists) + . = 0 + for(var/side in fists) + var/list/point = fists[side] + var/list/pose = bearer_rig.pose_reaching(side, point[1], point[2]) + . = max(., pose[2]) + +/** + * [shift_x], [shift_y] (pixels the fists would move the held head from where it rests in the hold), cut back as far as it + * takes for both fists to stay on the head there ([apart], [width] and [height] as fists_on_head() takes them): never further + * than his arms reach, or than they already stretch to hold it still. list(x, y), whole pixels. + */ +/datum/hv_finisher/chrome/gorilla/clap/proc/within_reach(shift_x, shift_y, apart = 0, width = 1, height = 1) + var/list/still = fists_on_head(apart, width, height) + if(!still) + return list(0, 0) + var/most = max(GORILLA_CLAP_MAX_REACH, fists_stretch(still)) + for(var/scale in list(1, 0.75, 0.5, 0.25)) + var/list/shift = list(round(shift_x * scale, 1), round(shift_y * scale, 1)) + if(fists_stretch(fists_on_head(apart, width, height, shift[1], shift[2])) <= most) + return shift + return list(0, 0) + +/** + * The held body hangs from its head: to each of [shifts] (list(x, y) pixels from where it rests in the hold) in turn, + * step_times[i] to the i-th, swinging about its neck behind the head as it is shaken aside. Returns the swing at each step, + * which the head takes back off its own turn so only its strain shows. + */ +/datum/hv_finisher/chrome/gorilla/clap/proc/move_held(list/shifts, list/step_times, easing = SINE_EASING) + . = list() + var/obj/effect/abstract/chrome_puppet/body_puppet = victim_rig?.puppet("body") + for(var/i in 1 to length(shifts)) + var/list/shift = shifts[i] + var/sway = clamp(shift[1] * GORILLA_CLAP_SWAY, -GORILLA_CLAP_MAX_SWAY, GORILLA_CLAP_MAX_SWAY) + . += sway + if(!body_puppet || !held_at) + continue + var/matrix/hung = chrome_rig_turn(sway, 0, CHROME_RIG_NECK_PIVOT_Y) + if(i == 1) + animate(body_puppet, transform = hung, pixel_x = held_at[1] + shift[1], pixel_y = held_at[2], pixel_z = held_at[3] + shift[2], time = step_times[i], easing = easing) + else + animate(transform = hung, pixel_x = held_at[1] + shift[1], pixel_y = held_at[2], pixel_z = held_at[3] + shift[2], time = step_times[i], easing = easing) + +/datum/hv_finisher/chrome/gorilla/clap/pose(key) + switch(key) + if("hoist") + rig_bearer() + victim_rig = new(victim, REVERSE_DIR(facing || user.dir)) + if(victim_rig.snapshot()) + // The head on its own puppet, so it can strain and crush while the body hangs + victim_rig.add_puppet("body", victim_rig.cut_at_neck(FALSE), TRUE) + var/obj/effect/abstract/chrome_puppet/head = victim_rig.add_puppet("head", victim_rig.cut_at_neck(TRUE)) + // The head rides on the body, drawn wherever the body is and turned with it, so it can never come + // off the neck: only its own squash and strain are its own + head.pixel_x = 0 + head.pixel_y = 0 + head.pixel_w = 0 + head.pixel_z = 0 + head.moveToNullspace() + var/obj/effect/abstract/chrome_puppet/body_puppet = victim_rig.puppet("body") + body_puppet.vis_contents += head + // Its puppets start where it lay before the grab (below): so does what stands in for them + var/list/lay_at = grab_pull_back() + victim_rig.conceal(lay_at[1], lay_at[2]) + var/list/toward = to_bearer() + // Held up in close, and kept there until the burst: seen from the side chest to chest, from the front + // up to his face, from the back just past his head, so its head is where his fists can close on it + var/share = side_view() ? GORILLA_CLAP_HOLD_SIDE : (facing == NORTH ? GORILLA_CLAP_HOLD_BACK : GORILLA_CLAP_HOLD_FRONT) + var/lift = side_view() ? GORILLA_CLAP_LIFT_SIDE : (facing == NORTH ? GORILLA_CLAP_LIFT_BACK : GORILLA_CLAP_LIFT_FRONT) + held_at = list(round(toward[1] * share), round(toward[2] * share), lift) + // It comes up from where it lay, not from where tg's grab draws it pulled in + var/list/pull_back = grab_pull_back() + for(var/obj/effect/abstract/chrome_puppet/held as anything in held_parts()) + held.pixel_x += pull_back[1] + held.pixel_y += pull_back[2] + // The held body is in front of the bearer, unless he faces away from the viewer + held.layer = facing == NORTH ? user.layer - 0.02 : user.layer + 0.02 + animate(held, transform = matrix(), pixel_x = held_at[1], pixel_y = held_at[2], pixel_w = 0, pixel_z = held_at[3], time = 0.4 SECONDS, easing = SINE_EASING | EASE_OUT) + // The head's bottom row overlaps the body's top one: the head draws over it + head.layer = body_puppet.layer + 0.001 + else + QDEL_NULL(victim_rig) + if(side_view()) + // The near fist holds the shirt front, over the held body; the far one is behind the bearer. + var/obj/effect/abstract/chrome_puppet/near_arm = arm_puppet("near") + if(near_arm) + near_arm.layer = user.layer + 0.03 + arm_to("near", 125, 0.4 SECONDS, 2) + arm_to("far", 60, 0.4 SECONDS) + else + // Seen from the front or back: both hands on the shoulders of the body held in front. The arms + // are over the bearer's body and under the held one (which is behind him when he faces away). + for(var/side in list("l", "r")) + var/obj/effect/abstract/chrome_puppet/arm = bearer_rig?.puppet("arm_[side]") + if(arm) + arm.layer = user.layer + 0.01 + arms_to(-25, 0.4 SECONDS) + if("squeeze") + // The fists close on the head and press, then wrench it side to side and lift it as they squeeze. The body + // hangs from the head and goes with them, swinging behind it; the head strains and gives between the fists in + // steps, about the neck so it stays on the shoulders, and the fists follow it in. + var/obj/effect/abstract/chrome_puppet/head = victim_rig?.puppet("head") + var/list/jerks = list(-5, 4, -4, 5, -3, 0) + // Shares of GORILLA_CLAP_SHAKE (aside) and GORILLA_CLAP_HEAVE (up), never lowered + var/list/shakes = list(0, 1, -1, 1, -0.5, 0) + var/list/heaves = list(0, 0.5, 0.5, 1, 1, 1) + var/list/step_times = list() + var/list/squashes = list() + var/list/shifts = list() + var/list/fist_points = list("l" = list(), "r" = list()) + for(var/i in 1 to length(jerks)) + var/give = 1 - 0.05 * i + var/width = side_view() ? 1 + (1 - give) * 0.5 : give + var/height = side_view() ? give : 1 + (1 - give) * 0.3 + step_times += i == 1 ? 0.2 SECONDS : 0.15 SECONDS + squashes += list(list(width, height)) + var/list/shift = within_reach(shakes[i] * GORILLA_CLAP_SHAKE, heaves[i] * GORILLA_CLAP_HEAVE, 0, width, height) + shifts += list(shift) + var/list/fists = fists_on_head(0, width, height, shift[1], shift[2]) + for(var/side in fists) + fist_points[side] += list(fists[side]) + // Each puppet's steps in one run, as animate() chains onto the last thing it was given + var/list/sways = move_held(shifts, step_times) + if(head) + for(var/i in 1 to length(jerks)) + var/list/squash = squashes[i] + // Its own strain and squash about the neck, on top of the body's swing + var/matrix/pressed = chrome_rig_turn(jerks[i] - sways[i], 0, CHROME_RIG_NECK_PIVOT_Y, 0, 0, squash[1], squash[2]) + if(i == 1) + animate(head, transform = pressed, time = step_times[i], easing = SINE_EASING) + else + animate(transform = pressed, time = step_times[i], easing = SINE_EASING) + for(var/side in fist_points) + if(length(fist_points[side])) + bearer_rig.reach_through(side, fist_points[side], step_times, GORILLA_CLAP_MAX_REACH) + // After the swings: the tremble runs alongside them, his fists and the body he holds shaking together + bearer_rig?.tremble(1 SECONDS) + victim_rig?.tremble(1 SECONDS, list("head")) + playsound(victim, 'sound/mobs/humanoids/human/gasp/gasp_male1.ogg', 30, TRUE) + if("toss") + // The fists heave the head up and come off it a little, for the clap; the body goes up with it + var/width = side_view() ? 1.15 : 0.7 + var/height = side_view() ? 0.7 : 1.09 + var/list/shift = within_reach(0, GORILLA_CLAP_HEAVE + GORILLA_CLAP_TOSS_LIFT, GORILLA_CLAP_WIND, width, height) + fists_to(fists_on_head(GORILLA_CLAP_WIND, width, height, shift[1], shift[2]), 0.15 SECONDS) + move_held(list(shift), list(0.15 SECONDS), SINE_EASING | EASE_OUT) + if("clap") + // It bursts and falls where it is held, on the bearer's tile. First, as it moves every puppet to his tile. + bring_in() + // ...and the fists slam back in and down, pressed into the head as it gives between them, still on the neck, + // and drive it down with them + var/width = side_view() ? 1.2 : 0.55 + var/height = side_view() ? 0.6 : 1.15 + var/list/shift = within_reach(0, GORILLA_CLAP_HEAVE + GORILLA_CLAP_TOSS_LIFT - GORILLA_CLAP_SLAM, -1, width, height) + fists_to(fists_on_head(-1, width, height, shift[1], shift[2]), 0.08 SECONDS) + move_held(list(shift), list(0.08 SECONDS), SINE_EASING | EASE_IN) + if(held_at) + burst_at = list(held_at[1] + shift[1], held_at[2] + held_at[3] + shift[2] + CHROME_RIG_NECK_PIVOT_Y + CLAP_HEAD_RISE * height) + var/obj/effect/abstract/chrome_puppet/head = victim_rig?.puppet("head") + if(head) + animate(head, transform = chrome_rig_turn(0, 0, CHROME_RIG_NECK_PIVOT_Y, 0, 0, width, height), time = 0.08 SECONDS, easing = SINE_EASING | EASE_IN) + // The sparks go where the fists meet, on the head + hit_stop(victim_rig?.puppet("body") || victim, TRUE, 9) + if("recover") + arms_to(0, 0.5 SECONDS) + +/datum/hv_finisher/chrome/gorilla/clap/beat(key) + if(key != "clap" || QDELETED(victim)) + return + playsound(victim, 'sound/effects/wounds/crack2.ogg', 80, TRUE) + // Blood and pieces go on out ahead of him + var/outcome = gorilla_head_clap(victim, user, fist(), facing, burst_at) + drop_held_body(outcome == "burst") + +/** + * Brings the held body onto the bearer's tile, drawn where it is held, so it bursts there and falls at his feet + * (a body on the floor shares his tile). + */ +/datum/hv_finisher/chrome/gorilla/clap/proc/bring_in() + var/turf/here = get_turf(user) + var/turf/from = get_turf(victim) + if(!isturf(here) || !isturf(from) || here == from) + return + // Off the grab first: tg turns a pulled body to face whoever pulls it, and on one tile there is no way to face + release_grip() + if(!victim.Move(here, get_dir(from, here))) + victim.forceMove(here) + if(get_turf(victim) != here) + return + for(var/obj/effect/abstract/chrome_puppet/part as anything in held_parts()) + part.forceMove(here) + part.pixel_x -= (here.x - from.x) * ICON_SIZE_X + part.pixel_y -= (here.y - from.y) * ICON_SIZE_Y + if(held_at) + held_at[1] -= (here.x - from.x) * ICON_SIZE_X + held_at[2] -= (here.y - from.y) * ICON_SIZE_Y + +/// The held body falls from where it is held, headless after a burst, to lie as the real one does; that one shows when it lands. +/datum/hv_finisher/chrome/gorilla/clap/proc/drop_held_body(burst) + var/obj/effect/abstract/chrome_puppet/body_puppet = victim_rig?.puppet("body") + if(!body_puppet || QDELETED(victim) || get_turf(body_puppet) != get_turf(victim)) + land() + return + if(burst) + var/obj/effect/abstract/chrome_puppet/head = victim_rig.puppet("head") + if(head) + body_puppet.vis_contents -= head + victim_rig.drop_puppet("head") + // The real body's turn and offsets are already its own, though it may still be drawn on its way to them + animate(body_puppet, transform = victim.transform, pixel_x = victim.pixel_x, pixel_y = victim.pixel_y, pixel_w = victim.pixel_w, pixel_z = victim.pixel_z, time = GORILLA_CLAP_DROP_TIME, easing = SINE_EASING | EASE_IN) + addtimer(CALLBACK(src, PROC_REF(land)), GORILLA_CLAP_DROP_TIME, TIMER_DELETE_ME) + +/// The held body is down: the real one shows in its place. +/datum/hv_finisher/chrome/gorilla/clap/proc/land() + QDEL_NULL(victim_rig) + if(!QDELETED(victim) && victim.stat == DEAD) + victim.hv_death_throes() + +#undef CLAP_HEAD_RISE +#undef CLAP_HEAD_HALF_WIDTH +#undef CLAP_FIST_HALF_WIDTH +#undef CLAP_FIST_RAISE + +/** + * Both fists meet on [victim]'s head. Bursts it (#509), or on a helmet or plating crumples the helmet and + * caves the skull in, or on the Atlas frame does heavy damage and nothing breaks. [head_at] is where a held + * head is drawn (list(x, y), pixels from the middle of its tile), for gorilla_clap_burst(). Returns what + * happened: "burst", "helmet", "frame" or "crit". + */ +/proc/gorilla_head_clap(mob/living/carbon/victim, mob/living/user, obj/item/fist, direction, list/head_at) + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + if(isnull(head)) + return null + victim.hv_hold_attack_message("[user] claps both fists together on [victim]'s head!", "[user] claps both fists together on your head!", "You clap both fists together on [victim]'s head!", user, vision_range = DEFAULT_MESSAGE_RANGE) + . = "burst" + if(HAS_TRAIT(victim, TRAIT_NODISMEMBER) && HAS_TRAIT(victim, TRAIT_CYBERWARE_UNBREAKABLE_BONES)) + // The Atlas frame: nothing bursts and nothing breaks + victim.apply_damage(35, BRUTE, head, victim.run_armor_check(head, MELEE), wound_bonus = CANT_WOUND) + victim.adjustOrganLoss(ORGAN_SLOT_BRAIN, 20) + victim.hv_add_hit_line("[victim]'s frame holds!", HV_LINE_BOLD, "Your frame holds!") + . = "frame" + else if(HAS_TRAIT(victim, TRAIT_HEAD_INJURY_BLOCKED) || hv_crit_cover_rating(victim, head, MELEE) >= GORILLA_CLAP_HELMET_ARMOUR) + // A helmet or plating: no burst. It crumples and the skull caves in under it. + // No attack direction: a sealed helmet throws no blood + victim.apply_damage(35, BRUTE, head, wound_bonus = CANT_WOUND) + var/obj/item/clothing/helmet + if(ishuman(victim)) + var/mob/living/carbon/human/human_victim = victim + helmet = human_victim.head + if(istype(helmet)) + helmet.take_damage(40, BRUTE, MELEE, FALSE) + if(!QDELETED(helmet)) + gorilla_helmet_dent(victim) + victim.hv_add_hit_line("[victim]'s helmet crumples!", HV_LINE_BOLD, "Your helmet crumples!", DEFAULT_MESSAGE_RANGE) + if(hv_crit_apply_wound(head, /datum/wound/blunt/bone/critical/hv_skull, direction, fist)) + victim.hv_add_hit_line("[victim]'s skull caves in!", HV_LINE_HUGE, "Your skull caves in!", DEFAULT_MESSAGE_RANGE) + . = "helmet" + else + // No attack direction: the burst lays its own blood (gorilla_clap_burst()) + victim.apply_damage(30, BRUTE, head, victim.run_armor_check(head, MELEE), wound_bonus = CANT_WOUND) + if(QDELETED(victim) || isnull(victim.get_bodypart(BODY_ZONE_HEAD))) + . = "burst" + else if(!gorilla_clap_burst(victim, direction, head_at)) + // A head that can't come off: the skull caves in instead + if(hv_crit_apply_wound(head, /datum/wound/blunt/bone/critical/hv_skull, direction, fist)) + victim.hv_add_hit_line("[victim]'s skull caves in!", HV_LINE_HUGE, "Your skull caves in!", DEFAULT_MESSAGE_RANGE) + . = "crit" + if(!QDELETED(victim)) + victim.hv_flush_hit() + playsound(victim, 'sound/effects/wounds/splatter.ogg', 60, TRUE) + log_combat(user, victim, "head-clapped", "gorilla arms", "([.])") + +/** + * #509's head burst (hv_burst_head_apart()) sized for two fists at arm's length: the gibs and splatter + * stay round the head, one short line of blood goes out along [burst_dir], the eyes, ears and tongue + * drop on the spot or a tile out and the brain lands a tile or two away, whole, for revival. They leave + * from [head_at] (list(x, y), pixels from the middle of the tile), where the head is held, or from where + * the body's own head is drawn if that isn't given. Returns TRUE if the head burst. + */ +/proc/gorilla_clap_burst(mob/living/carbon/victim, burst_dir, list/head_at) + if(HAS_TRAIT(victim, TRAIT_GODMODE)) + return FALSE + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + if(!head || !head.can_dismember()) + return FALSE + if(!burst_dir) + burst_dir = pick(GLOB.alldirs) + var/turf/here = get_turf(victim) + var/organic = IS_ORGANIC_LIMB(head) + var/bleeds = head.can_bleed() + var/list/blood_dna = bleeds ? victim.get_blood_dna_list() : null + var/blood_color = bleeds ? victim.get_bloodtype()?.get_color() : null + // Read before the head comes off + if(!head_at) + head_at = victim.hv_vis_part_offset(BODY_ZONE_HEAD) + var/list/obj/item/organ/loose = list() + for(var/obj/item/organ/organ in head) + if(!(organ.organ_flags & ORGAN_UNREMOVABLE)) + loose += organ + // One short line; the lost-limb spray the dismember would add is held off + gorilla_short_spray(victim, burst_dir, GORILLA_CLAP_SPRAY_TILES) + // Not dismember(): it throws the head a tile or two, and a head is heavy enough to knock whoever it hits + // a tile back. Thrown into the bearer it shoved him off the body and ended the finisher at the burst. + head = gorilla_tear_limb(victim, head, burst_dir, FALSE) + if(isnull(head)) + return FALSE + // A burst head comes apart where it was + if(isturf(here) && head.loc != here) + head.forceMove(here) + // No violent removal: the brain has to stay good for revival + head.drop_organs() + qdel(head) + if(isturf(here)) + if(!organic) + new /obj/effect/gibspawner/robot(here, victim) + else if(bleeds) + gorilla_clap_gibs(here, burst_dir, blood_dna) + hv_head_burst_splatter(here, burst_dir, blood_color) + playsound(here, 'sound/effects/wounds/splatter.ogg', 80, TRUE) + for(var/obj/item/organ/organ as anything in loose) + if(QDELETED(organ) || !isturf(organ.loc)) + continue + // Flown, not thrown (hv_fling()): nobody is hit by it, the bearer least of all. It starts at the head. + if(istype(organ, /obj/item/organ/brain)) + var/datum/callback/landed = blood_dna ? CALLBACK(organ, TYPE_PROC_REF(/obj/item/organ, hv_landed), blood_dna) : null + organ.hv_vis_fling_from = head_at + hv_fling_organ(organ, burst_dir, GORILLA_CLAP_BRAIN_MIN, GORILLA_CLAP_BRAIN_MAX, landed) + else if(prob(50)) + organ.hv_vis_fling_from = head_at + hv_fling_organ(organ, turn(burst_dir, pick(-45, 0, 45)), 1, 1) + organ.hv_vis_forget_fling() + victim.hv_add_hit_line(pick("[victim]'s head bursts apart!", "[victim]'s skull bursts open!"), HV_LINE_HUGE, range = DEFAULT_MESSAGE_RANGE) + return TRUE + +/** + * The clap's gibs: piled round the head, one a tile out along [burst_dir]. #509's burst gibs streak up to + * three tiles across a cone, which from two fists at arm's length reads as a blast. + */ +/proc/gorilla_clap_gibs(turf/where, burst_dir, list/blood_dna) + for(var/i in 1 to 3) + var/obj/effect/decal/cleanable/blood/gibs/gib = new(where, null, blood_dna) + if(!QDELETED(gib)) + gib.pixel_x = rand(-8, 8) + gib.pixel_y = rand(-8, 8) + var/turf/ahead = get_step(where, burst_dir) + if(ahead && !isgroundlessturf(ahead) && !hv_blood_spray_blocked(ahead)) + new /obj/effect/decal/cleanable/blood/gibs(ahead, null, blood_dna) + new /obj/effect/decal/cleanable/blood/gibs/core(where, null, blood_dna) + +/// A crumpled dent drawn over the helmet for a while. +/proc/gorilla_helmet_dent(mob/living/carbon/victim) + var/mutable_appearance/dent = mutable_appearance(GORILLA_GORE_ICON, "helmet_dent", -(HEAD_LAYER - 0.1)) + victim.add_overlay(dent) + addtimer(CALLBACK(victim, TYPE_PROC_REF(/atom, cut_overlay), dent), 10 SECONDS) + +// ========================================================================= +// (B) THE LIMB RIP +// ========================================================================= + +/datum/hv_finisher/chrome/gorilla/rip + name = "gorilla limb rip" + brawler_ok = TRUE + stages = list( + /datum/hv_finisher_stage/hold/gorilla/rip_plant, + /datum/hv_finisher_stage/hold/gorilla/rip_strain, + /datum/hv_finisher_stage/kill/gorilla/rip, + /datum/hv_finisher_stage/recover/gorilla/rip_club, + /datum/hv_finisher_stage/recover/gorilla/rip, + ) + /// The torn-off arm, held until it is dropped on the victim's tile + var/obj/item/bodypart/held_limb + /// "l" or "r": the side of the victim's body the arm is on + var/side + /// The bearer's arm whose fist takes the wrist first ("l" or "r"); the other fist joins it + var/grip_side + /// Pixels the bearer's puppets lean onto the body now: further in as he takes the arm, back to lean_out as he hauls + var/list/lean = list(0, 0) + /// The lean he hauls back to and holds through the blow + var/list/lean_out = list(0, 0) + /// Pixels the body's puppets are drawn from the real body: where it lay before the grab, until he drags it in by the arm + var/list/body_shift = list(0, 0) + /// Degrees (clockwise) the body is turned up about its feet toward his fists by the haul + var/raised = 0 + /// The hauled arm's length when the fists take it, as a share of its own + var/grip_stretch = 1 + /// Where the fists hold the wrist: pixels from the middle of the bearer's tile + var/list/grip + /// The torn arm's hand and shoulder in its own picture, list(hand_x, hand_y, shoulder_x, shoulder_y): the bearer + /// holds it by the hand and swings the shoulder end + var/list/club_ends + +/datum/hv_finisher_stage/hold/gorilla/rip_plant + key = "plant" + duration = 0.5 SECONDS + enter_sound = 'sound/effects/gravhit.ogg' + enter_volume = 40 + +/datum/hv_finisher_stage/hold/gorilla/rip_strain + key = "strain" + duration = 1.35 SECONDS + +/datum/hv_finisher_stage/kill/gorilla/rip + key = "tear" + duration = 0.8 SECONDS + +/datum/hv_finisher_stage/recover/gorilla/rip_club + key = "club" + duration = 0.45 SECONDS + // Still held through the blow, so the body doesn't slide back off the grab under it. The hit is timed with the + // swing (swing_club()), not this stage's beat, which only fires on the finisher's next tick. + pins = TRUE + +/datum/hv_finisher_stage/recover/gorilla/rip + key = "recover" + +/datum/hv_finisher/chrome/gorilla/rip/Destroy() + drop_held_limb() + return ..() + +/datum/hv_finisher/chrome/gorilla/rip/stop(reason) + if(!running) + return + . = ..() + drop_held_limb() + +/// The aimed arm, else the other one. +/datum/hv_finisher/chrome/gorilla/rip/pick_zone() + var/other = aimed_zone == BODY_ZONE_L_ARM ? BODY_ZONE_R_ARM : BODY_ZONE_L_ARM + target_zone = victim.get_bodypart(aimed_zone) ? aimed_zone : (victim.get_bodypart(other) ? other : null) + side = target_zone == BODY_ZONE_L_ARM ? "l" : "r" + return target_zone + +/datum/hv_finisher/chrome/gorilla/rip/can_start_on(mob/living/carbon/target) + return !isnull(target.get_bodypart(BODY_ZONE_L_ARM)) || !isnull(target.get_bodypart(BODY_ZONE_R_ARM)) + +/datum/hv_finisher/chrome/gorilla/rip/enter_line(key) + switch(key) + if("plant") + return "[user] plants a boot on [victim] and grabs [victim.p_their()] arm!" + if("strain") + return "[user] hauls back on [victim]'s arm!" + +/datum/hv_finisher/chrome/gorilla/rip/enter_self_line(key) + switch(key) + if("plant") + return "[user] plants a boot on you and grabs your arm!" + if("strain") + return "[user] hauls back on your arm!" + +/datum/hv_finisher/chrome/gorilla/rip/pose(key) + var/list/toward = to_bearer() + switch(key) + if("plant") + rig_bearer() + if(bearer_rig && facing == NORTH) + // Seen from behind, everything he does here is on his far side: his arms reach out past his own + // back and head, which hide them where they cross + for(var/arm_side in list("l", "r")) + var/obj/effect/abstract/chrome_puppet/own_arm = bearer_rig.puppet("arm_[arm_side]") + own_arm?.layer = user.layer - 0.01 + lean_out = list(-round(toward[1] / ICON_SIZE_X * GORILLA_RIP_LEAN), -round(toward[2] / ICON_SIZE_Y * GORILLA_RIP_LEAN)) + lean = lean_out.Copy() + victim_rig = new(victim, victim.dir) + if(bearer_rig && victim_rig.snapshot()) + // The arm turns with the lying body, about its own shoulder + victim_rig.base_transform = matrix(victim.transform) + var/obj/effect/abstract/chrome_puppet/laid_body = victim_rig.add_puppet("body", victim_rig.cut_without_arms(side), TRUE) + // Draw order, back to front, the same from the plant to the let-go: + // - Facing the viewer the body lies nearer than he stands: his body, the body on the floor, its + // hauled arm, his arms (they reach toward the viewer), the torn arm. + // - From the side: his far arm, a far hauled arm, the body, his body (a boot on it), a near hauled + // arm, his near arm, the torn arm. + // - Facing away the body is beyond him, and so is all he does to it: the body, its hauled arm, his + // arms, the torn arm in his fists, and over them all his own back and head. + if(laid_body && facing == SOUTH) + laid_body.layer = user.layer + 0.004 + var/obj/effect/abstract/chrome_puppet/hauled = victim_rig.add_puppet("arm_[side]", victim_rig.arm_picture(side), TRUE) + // The far arm seen from the side comes out from behind the body. Any other arm is hauled up in front of the + // bearer, over his body and under his near fist, unless he faces away and it is beyond him. + if(victim_rig.behind_body(side)) + hauled.layer = victim.layer - 0.01 + else + hauled.layer = facing == NORTH ? victim.layer + 0.01 : user.layer + 0.005 + // The body stays where it lay (tg's grab draws it pulled in at once): he steps in to it as far, and drags it + // in by the arm as he hauls + body_shift = grab_pull_back() + lean = list(lean_out[1] + body_shift[1], lean_out[2] + body_shift[2]) + for(var/key_name in victim_rig.puppets) + var/obj/effect/abstract/chrome_puppet/part = victim_rig.puppets[key_name] + part.pixel_x += body_shift[1] + part.pixel_y += body_shift[2] + // What stands in for it until its puppets can be drawn stands where they do + victim_rig.conceal(body_shift[1], body_shift[2]) + take_wrist(0.3 SECONDS, GORILLA_RIP_START_HOLD) + else + QDEL_NULL(victim_rig) + arms_to(side_view() ? 45 : 30, 0.3 SECONDS, 3) + // A boot on the body: the bearer leans over them, arms and all (after the swings, which would cut + // the lean short on the arms). Nothing moves through the hold, while the puppets' pictures reach the + // client: they come on as the bodies stood, and then he steps in. + for(var/key_name in bearer_rig?.puppets) + var/obj/effect/abstract/chrome_puppet/part = bearer_rig.puppets[key_name] + if(victim_rig) + animate(part, pixel_x = part.pixel_x, time = GORILLA_RIP_START_HOLD, flags = ANIMATION_PARALLEL) + animate(pixel_x = part.pixel_x + lean[1], pixel_y = part.pixel_y + lean[2], time = 0.3 SECONDS, easing = SINE_EASING | EASE_OUT) + else + animate(part, pixel_x = part.pixel_x + lean[1], pixel_y = part.pixel_y + lean[2], time = 0.3 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + if("strain") + if(victim_rig && grip) + haul(1.3 SECONDS) + else + arms_to(side_view() ? 25 : 15, 1.3 SECONDS, 1) + bearer_rig?.tremble(1.3 SECONDS) + if("tear") + // The arm gives: he yanks it back and comes upright + bearer_rig?.bend_and_swing(0, side_view() ? -20 : 0, 0.1 SECONDS) + if("club") + if(held_limb) + // Up over his head, then down on theirs, the hit landing as it comes down + swing_club(GORILLA_CLUB_RAISE, GORILLA_CLUB_STRIKE) + // A shade before the arm is all the way down: the server's timer runs a tick or two behind the client's swing + addtimer(CALLBACK(src, PROC_REF(club_hit)), GORILLA_CLUB_RAISE + GORILLA_CLUB_STRIKE - GORILLA_CLUB_HIT_LEAD, TIMER_DELETE_ME) + else + arms_to(0, 0.4 SECONDS) + if("recover") + bearer_rig?.drop_puppet("club") + // The arm goes down with the body as he lets it go + drop_held_limb() + // Down the way they point: not back up over his head the way they came + bearer_rig?.unwind_arms() + arms_to(0, 0.5 SECONDS) + // Let go, the body slides back to where tg lays it; its stand-ins go with it, and the real one shows there + if(victim_rig && !QDELETED(victim)) + for(var/key_name in victim_rig.puppets) + var/obj/effect/abstract/chrome_puppet/part = victim_rig.puppets[key_name] + animate(part, pixel_x = victim.pixel_x, pixel_y = victim.pixel_y, pixel_w = victim.pixel_w, pixel_z = victim.pixel_z, time = GORILLA_RIP_LET_GO, easing = EASE_IN | EASE_OUT, flags = ANIMATION_PARALLEL) + addtimer(CALLBACK(src, PROC_REF(fallen)), GORILLA_RIP_LET_GO + 0.05 SECONDS, TIMER_DELETE_ME) + // Straightens up off the body, so the real one shows where he stands (after the swing, as the lean was) + for(var/key_name in bearer_rig?.puppets) + var/obj/effect/abstract/chrome_puppet/part = bearer_rig.puppets[key_name] + animate(part, pixel_x = user.pixel_x, pixel_y = user.pixel_y, time = 0.4 SECONDS, easing = SINE_EASING, flags = ANIMATION_PARALLEL) + +/// The middle of the bearer's puppets as drawn: pixels from the middle of his tile. +/datum/hv_finisher/chrome/gorilla/rip/proc/bearer_origin() + return list(user.pixel_x + user.pixel_w + lean[1], user.pixel_y + user.pixel_z + lean[2]) + +/// The middle of the body's puppets as drawn (body_shift from the real body): pixels from the middle of the bearer's tile. +/datum/hv_finisher/chrome/gorilla/rip/proc/body_origin() + return list((victim.x - user.x) * ICON_SIZE_X + victim.pixel_x + victim.pixel_w + body_shift[1], (victim.y - user.y) * ICON_SIZE_Y + victim.pixel_y + victim.pixel_z + body_shift[2]) + +/** + * The hauled arm's shoulder as drawn, the body turned as the victim rig's base_transform turns it (pixels from the middle + * of the bearer's tile), and the angle the arm comes up at: toward the bearer's shoulders (bent by [bearer_base]), and + * seen from the side turned [tilt] degrees up off the floor. list(x, y, angle). + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/haul_line(tilt, matrix/bearer_base) + var/list/shoulder_at = body_shoulder_at() + var/list/left = bearer_shoulder_at("l", bearer_base) + var/list/right = bearer_shoulder_at("r", bearer_base) + var/angle = arctan((left[1] + right[1]) / 2 - shoulder_at[1], (left[2] + right[2]) / 2 - shoulder_at[2]) + if(side_view()) + // Up toward the top of the screen, never past it + var/to_up = 90 - angle + while(to_up > 180) + to_up -= 360 + while(to_up < -180) + to_up += 360 + angle += clamp(to_up, -tilt, tilt) + return list(shoulder_at[1], shoulder_at[2], angle) + +/// Where the bearer's shoulder on [arm_side] is drawn with his body bent by [bearer_base]: pixels from the middle of his tile. +/datum/hv_finisher/chrome/gorilla/rip/proc/bearer_shoulder_at(arm_side, matrix/bearer_base) + var/list/origin = bearer_origin() + var/list/at = bearer_rig.shoulder_point(arm_side, bearer_base) + return list(origin[1] + at[1], origin[2] + at[2]) + +/// Where the hauled arm's shoulder is drawn, the body turned as the victim rig's base_transform turns it: pixels from the middle of the bearer's tile. +/datum/hv_finisher/chrome/gorilla/rip/proc/body_shoulder_at() + var/list/body_at = body_origin() + var/list/at = victim_rig.shoulder_point(side) + return list(body_at[1] + at[1], body_at[2] + at[2]) + +/// Where the wrist is when the arm is [stretch] times its length: pixels from the middle of the bearer's tile. +/datum/hv_finisher/chrome/gorilla/rip/proc/wrist_at(stretch, tilt, matrix/bearer_base) + var/list/line = haul_line(tilt, bearer_base) + var/length = stretch * victim_rig.arm_reach(side) + return list(line[1] + length * cos(line[3]), line[2] + length * sin(line[3])) + +/** + * The poses that put both of the bearer's fists (his body bent by [bearer_base]) and the hauled hand (the body + * turned as the victim rig's base_transform turns it) on [wrist], each turned the short way from [from] (key -> turn). + * Keys "bearer_l", "bearer_r" and "body"; every pose carries its body's turn. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/poses_on(list/wrist, list/from, matrix/bearer_base) + . = list() + var/list/origin = bearer_origin() + for(var/arm_side in list("l", "r")) + var/list/pose = bearer_rig.pose_reaching(arm_side, wrist[1] - origin[1], wrist[2] - origin[2], from["bearer_[arm_side]"], bearer_base) + .["bearer_[arm_side]"] = list(pose[1], pose[2], bearer_base) + var/list/body_at = body_origin() + var/list/body_pose = victim_rig.pose_reaching(side, wrist[1] - body_at[1], wrist[2] - body_at[2], from["body"]) + .["body"] = list(body_pose[1], body_pose[2], victim_rig.base_transform) + +/// Sends the bearer's arms and body and the hauled arm through [all_poses] (a list of poses_on() lists), [step_time] a step (or step_time[i] for the i-th, given a list). +/datum/hv_finisher/chrome/gorilla/rip/proc/pose_through(list/all_poses, step_time) + var/list/bends = list() + for(var/key_name in list("bearer_l", "bearer_r", "body")) + var/list/steps = list() + for(var/list/poses as anything in all_poses) + var/list/pose = poses[key_name] + steps += list(pose) + if(key_name == "bearer_l") + bends += list(pose[3]) + if(key_name == "body") + victim_rig.pose_arm_through(side, steps, step_time) + else + bearer_rig.pose_arm_through(key_name == "bearer_l" ? "l" : "r", steps, step_time) + // His body bends with his arms, step for step, so they stay on his shoulders + bearer_rig.body_through(bends, step_time) + +/// The turns each arm is in now, keyed as poses_on() keys them. +/datum/hv_finisher/chrome/gorilla/rip/proc/turns_now() + . = list() + for(var/arm_side in list("l", "r")) + var/list/pose = bearer_rig.arm_poses[arm_side] || list(0, 1) + .["bearer_[arm_side]"] = pose[1] + var/list/pose = victim_rig.arm_poses[side] || list(0, 1) + .["body"] = pose[1] + +/** + * The plant, over [time]: the bearer's piston arms push out, both fists close on the wrist and the arm comes + * up off the floor into them. Every part stays as it is for [hold] first. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/take_wrist(time, hold = 0) + var/bend = 0 + var/matrix/bent = null + var/list/line = haul_line(GORILLA_RIP_TILT, bent) + // The fist on the near side (seen from the side) or nearer the arm takes it; the other one joins it + var/best_distance + for(var/arm_side in list("l", "r")) + var/list/at = bearer_shoulder_at(arm_side, bent) + var/distance = sqrt((at[1] - line[1]) ** 2 + (at[2] - line[2]) ** 2) + if(isnull(best_distance) || distance < best_distance) + best_distance = distance + grip_side = arm_side + if(side_view()) + grip_side = bearer_rig.near_side() + // The arm comes up as far as it takes to meet that fist pushed out to its reach + var/list/from = bearer_shoulder_at(grip_side, bent) + var/along = gorilla_ray_meets(line[1], line[2], line[3], from[1], from[2], GORILLA_RIP_REACH * bearer_rig.arm_reach(grip_side)) + grip_stretch = clamp(isnull(along) ? GORILLA_RIP_MAX_STRETCH : along / victim_rig.arm_reach(side), 1, GORILLA_RIP_MAX_STRETCH) + grip = wrist_at(grip_stretch, GORILLA_RIP_TILT, bent) + // Every arm swings the same number of short steps, so they arrive together + var/list/now = turns_now() + var/list/there = poses_on(grip, now, bent) + var/list/start = list( + "bearer_l" = bearer_rig.arm_poses["l"] || list(0, 1), + "bearer_r" = bearer_rig.arm_poses["r"] || list(0, 1), + "body" = victim_rig.arm_poses[side] || list(0, 1), + ) + var/steps = bearer_rig.swing_steps(0, bend) + for(var/key_name in there) + var/list/pose = there[key_name] + steps = max(steps, bearer_rig.swing_steps(now[key_name], pose[1])) + var/list/all_poses = list() + var/list/step_times = list() + if(hold) + var/list/still = list() + for(var/key_name in start) + var/list/was = start[key_name] + still[key_name] = list(was[1], was[2], null) + all_poses += list(still) + step_times += hold + for(var/i in 1 to steps) + var/progress = (1 - cos(180 * i / steps)) / 2 + var/matrix/bent_now = bearer_rig.bend_matrix(bend * progress) + var/list/poses = list() + for(var/key_name in there) + var/list/pose = there[key_name] + var/list/was = start[key_name] + poses[key_name] = list(was[1] + (pose[1] - was[1]) * progress, was[2] + (pose[2] - was[2]) * progress, key_name == "body" ? null : bent_now) + all_poses += list(poses) + step_times += time / steps + pose_through(all_poses, step_times) + +/** + * The strain, over [time]: the bearer leans back from his feet (seen from the side) with his arms out and steps back to + * lean_out, hauling the arm up and out of its socket. The body is dragged in by it to where tg's grab draws it, and turns + * up about its feet toward his fists, the feet staying on the floor; both fists on the wrist the whole way. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/haul(time) + var/lean_back = side_view() ? -GORILLA_RIP_LEAN_BACK : 0 + var/list/start_fist = bearer_shoulder_at(grip_side) + var/grip_reach = sqrt((grip[1] - start_fist[1]) ** 2 + (grip[2] - start_fist[2]) ** 2) + var/body_length = victim_rig.arm_reach(side) + var/matrix/flat = matrix(victim.transform) + raised = raise_toward(flat, grip) + var/list/lean_from = lean.Copy() + var/list/shift_from = body_shift.Copy() + var/step_time = time / GORILLA_RIP_HAUL_STEPS + var/list/all_poses = list() + var/list/body_turns = list() + var/list/leans = list() + var/list/shifts = list() + var/list/from = turns_now() + for(var/i in 1 to GORILLA_RIP_HAUL_STEPS) + // Sine in and out, the same for every part + var/progress = (1 - cos(180 * i / GORILLA_RIP_HAUL_STEPS)) / 2 + lean = list(round(lean_from[1] + (lean_out[1] - lean_from[1]) * progress, 1), round(lean_from[2] + (lean_out[2] - lean_from[2]) * progress, 1)) + body_shift = list(round(shift_from[1] * (1 - progress), 1), round(shift_from[2] * (1 - progress), 1)) + victim_rig.base_transform = chrome_rig_turn_about_feet(flat, raised * progress) + leans += list(lean) + shifts += list(body_shift) + body_turns += list(victim_rig.base_transform) + var/matrix/bent = bearer_rig.bend_matrix(lean_back * progress) + var/list/fist_from = bearer_shoulder_at(grip_side, bent) + var/list/arm_from = body_shoulder_at() + var/apart = sqrt((arm_from[1] - fist_from[1]) ** 2 + (arm_from[2] - fist_from[2]) ** 2) + var/fist_reach = grip_reach + // The arm gives as far as it must to stay in his fists + var/arm_reach = clamp(max((grip_stretch + GORILLA_RIP_HAUL * progress) * body_length, apart - fist_reach + 1), body_length, GORILLA_RIP_MAX_HAUL * body_length) + fist_reach = max(fist_reach, apart - arm_reach + 1) + grip = gorilla_circles_meet(fist_from[1], fist_from[2], fist_reach, arm_from[1], arm_from[2], arm_reach, grip[1], grip[2]) + var/list/poses = poses_on(grip, from, bent) + for(var/key_name in poses) + var/list/pose = poses[key_name] + from[key_name] = pose[1] + all_poses += list(poses) + pose_through(all_poses, step_time) + victim_rig.body_through(body_turns, step_time) + // He stays leaning back until the arm comes away + bearer_rig.bend_angle = lean_back + bearer_rig.base_transform = bearer_rig.bend_matrix(lean_back) + // After the swings and turns, which would cut these short: he steps back and the body comes with him + gorilla_offsets_through(bearer_rig.puppets, leans, user.pixel_x, user.pixel_y, step_time) + gorilla_offsets_through(victim_rig.puppets, shifts, victim.pixel_x, victim.pixel_y, step_time) + // Both bodies shake together, so the fists stay on the wrist + bearer_rig.tremble(time) + victim_rig.tremble(time) + +/** + * Degrees (clockwise) to turn the body lying as [flat] turns it about its feet as the arm is hauled toward [point] (pixels + * from the middle of the bearer's tile). Seen from the side the upper body comes up off the floor, GORILLA_RIP_RAISE; from + * the front or back it turns toward the fists, at most that. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/raise_toward(matrix/flat, list/point) + var/list/feet = chrome_rig_apply(flat, 0, CHROME_RIG_FEET_Y) + var/list/shoulder_at = victim_rig.shoulder_point(side, flat) + if(side_view()) + // Clockwise lifts a shoulder that lies to the left of the feet + return shoulder_at[1] < feet[1] ? GORILLA_RIP_RAISE : -GORILLA_RIP_RAISE + var/list/body_at = body_origin() + var/turned = arctan(point[1] - body_at[1] - feet[1], point[2] - body_at[2] - feet[2]) - arctan(shoulder_at[1] - feet[1], shoulder_at[2] - feet[2]) + while(turned > 180) + turned -= 360 + while(turned <= -180) + turned += 360 + // Angles run anticlockwise, turns clockwise + return -clamp(turned, -GORILLA_RIP_RAISE, GORILLA_RIP_RAISE) + +/** + * The arm gives: the body drops back flat from its turn about the feet, faster and faster, the arm falling back to its + * side with it if it held. It stays on its stand-ins, in their draw order, until he lets go (the recover). + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/fall_back() + var/obj/effect/abstract/chrome_puppet/body_puppet = victim_rig?.puppet("body") + if(!body_puppet || QDELETED(victim)) + QDEL_NULL(victim_rig) + return + if(!raised) + return + var/matrix/flat = matrix(victim.transform) + var/list/arm_from = victim_rig.puppet("arm_[side]") ? (victim_rig.arm_poses[side] || list(0, 1)) : null + var/steps = 3 + if(arm_from) + steps = max(steps, victim_rig.swing_steps(arm_from[1], 0)) + var/list/body_turns = list() + var/list/arm_steps = list() + for(var/i in 1 to steps) + // Gravity: slow off the top, fast onto the floor + var/progress = 1 - cos(90 * i / steps) + var/matrix/turned = chrome_rig_turn_about_feet(flat, raised * (1 - progress)) + body_turns += list(turned) + if(arm_from) + arm_steps += list(list(arm_from[1] * (1 - progress), arm_from[2] + (1 - arm_from[2]) * progress, turned)) + victim_rig.body_through(body_turns, GORILLA_RIP_FALL_TIME / steps) + if(arm_from) + victim_rig.pose_arm_through(side, arm_steps, GORILLA_RIP_FALL_TIME / steps) + raised = 0 + victim_rig.base_transform = flat + +/// He has let the body go and it lies where tg lays it: the real one shows in its place. +/datum/hv_finisher/chrome/gorilla/rip/proc/fallen() + QDEL_NULL(victim_rig) + +/** + * The stand-ins take on how both bodies look now. With the arm [torn] off, the victim's whole picture is the body, + * stump and all; else the arm is still its own piece. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/redraw_bodies(torn) + bearer_rig?.redraw_arms() + if(QDELETED(victim) || !victim_rig?.snapshot()) + return + victim_rig.repaint("body", torn ? victim_rig.flat : victim_rig.cut_without_arms(side)) + if(!torn) + victim_rig.repaint("arm_[side]", victim_rig.arm_picture(side)) + +/// Blood bursts every way from the socket the arm just left, where the shoulder is drawn at that moment. +/datum/hv_finisher/chrome/gorilla/rip/proc/shoulder_burst() + var/turf/spot = get_turf(victim) + if(!isturf(spot)) + return + var/list/joint + if(victim_rig?.puppet("body")) + // The stand-in's shoulder, hauled up off the floor: from the middle of the bearer's tile, so back onto the victim's + var/list/at = body_shoulder_at() + var/list/toward = to_bearer() + joint = list(at[1] + toward[1], at[2] + toward[2]) + else + joint = gorilla_shoulder_at(victim, side) + gorilla_blood_burst(spot, round(joint[1]), round(joint[2]), victim, GORILLA_RIP_BURST_DROPS) + +/** + * Where the pool under the torn shoulder goes: pixels from the middle of the victim's tile. Half-way between where the + * shoulder lies as the arm comes off, pulled in by the grab, and where it lies once he lets go, so the stump is over it + * both times. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/pool_spot() + if(QDELETED(victim)) + return null + var/list/joint = gorilla_shoulder_at(victim, side, victim_rig?.facing) + // Off a body still on its feet it lands at them + if(victim.body_position != LYING_DOWN) + joint[2] = CHROME_RIG_FEET_Y + victim.pixel_y + victim.pixel_z + var/list/back = grab_pull_back() + return list(clamp(round(joint[1] + back[1] / 2), -GORILLA_RIP_POOL_REACH, GORILLA_RIP_POOL_REACH), clamp(round(joint[2] + back[2] / 2), -GORILLA_RIP_POOL_REACH, GORILLA_RIP_POOL_REACH)) + +/** + * Where the shoulder on [side] ("l" or "r") of [body] is drawn, lying or standing as it is now: pixels from the middle of + * its tile. [facing] is the way its picture faces, else its own. + */ +/proc/gorilla_shoulder_at(mob/living/body, side, facing) + var/list/pivots = GLOB.chrome_rig_shoulders["[facing || body.dir]"] || GLOB.chrome_rig_shoulders["[SOUTH]"] + var/list/at = chrome_rig_apply(body.transform, side == "l" ? pivots[1] : pivots[3], side == "l" ? pivots[2] : pivots[4]) + return list(at[1] + body.pixel_x + body.pixel_w, at[2] + body.pixel_y + body.pixel_z) + +/** + * Blood bursts from a wound at [from_x], [from_y] (pixels from the middle of [origin]) every way at once: [count] drops + * of [bleeder]'s blood thrown in a broken ring, no two in a row alike, each landing as a drip one of [reach] pixels out, + * give or take. Drops only: no line along the floor, as #509's sprays lay, and no heavy splats. + */ +/proc/gorilla_blood_burst(turf/origin, from_x, from_y, mob/living/bleeder, count = 10, list/reach = list(6, 9, 12, 15, 19)) + if(!isturf(origin) || QDELETED(bleeder) || bleeder.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return + var/blood_color = bleeder.get_bloodtype()?.get_damage_color(bleeder) || BLOOD_COLOR_RED + var/list/blood_dna = bleeder.get_blood_dna_list() + var/list/viruses = bleeder.get_static_viruses() + var/start = rand(0, 359) + for(var/i in 1 to count) + var/angle = start + i * (360 / count) + rand(-14, 14) + var/distance = pick(reach) + rand(-2, 2) + var/land_x = from_x + round(sin(angle) * distance) + var/land_y = from_y + round(cos(angle) * distance) + // list(start x, start y, land x, land y, arc height, flight time, wait): the monowire's drop, which lands as a drip + new /obj/effect/temp_visual/wire_blood_drop(origin, list(from_x, from_y, land_x, land_y, 3 + rand(0, 5), round(1.5 + distance / 14, 0.5), 0), blood_color, blood_dna, viruses) + +/** + * Moves [pool] (blood just laid on the floor) so its middle is [x], [y] pixels from the middle of its tile, and keeps it + * there as it grows into a pool. + */ +/proc/gorilla_place_blood(obj/effect/decal/cleanable/blood/pool, x, y) + pool.pixel_x += x - pool.base_pixel_x + pool.pixel_y += y - pool.base_pixel_y + pool.base_pixel_x = x + pool.base_pixel_y = y + +/** + * [body] shudders up to [shift_x], [shift_y] pixels for [time] and ends where it began. Drawn only (pixel_w and pixel_z, + * each step relative), so whatever offsets tg has on the body stay as they are. + */ +/proc/gorilla_shudder(atom/movable/body, shift_x = 2, shift_y = 1, time = 0.2 SECONDS) + var/steps = max(2, round(time / (0.04 SECONDS))) + var/moved_w = 0 + var/moved_z = 0 + for(var/i in 1 to steps) + // The last step takes it back + var/to_w = i == steps ? 0 : rand(-shift_x, shift_x) + var/to_z = i == steps ? 0 : rand(-shift_y, shift_y) + if(i == 1) + animate(body, pixel_w = to_w - moved_w, pixel_z = to_z - moved_z, time = time / steps, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + else + animate(pixel_w = to_w - moved_w, pixel_z = to_z - moved_z, time = time / steps, flags = ANIMATION_RELATIVE) + moved_w = to_w + moved_z = to_z + +/// Sends every puppet in [parts] (key -> puppet) through [points] (list(x, y) pixels on from [base_x], [base_y]), [step_time] a step, alongside its turns. +/proc/gorilla_offsets_through(list/parts, list/points, base_x, base_y, step_time) + for(var/key_name in parts) + var/obj/effect/abstract/chrome_puppet/part = parts[key_name] + for(var/i in 1 to length(points)) + var/list/point = points[i] + if(i == 1) + animate(part, pixel_x = base_x + point[1], pixel_y = base_y + point[2], time = step_time, flags = ANIMATION_PARALLEL) + else + animate(pixel_x = base_x + point[1], pixel_y = base_y + point[2], time = step_time) + +/** + * The point [first_radius] from [first_x], [first_y] and [second_radius] from [second_x], [second_y] nearest + * [near_x], [near_y]. If the two never meet, the point [first_radius] along the line between them. + */ +/proc/gorilla_circles_meet(first_x, first_y, first_radius, second_x, second_y, second_radius, near_x, near_y) + var/apart_x = second_x - first_x + var/apart_y = second_y - first_y + var/apart = sqrt(apart_x * apart_x + apart_y * apart_y) + if(!apart) + return list(first_x, first_y) + apart_x /= apart + apart_y /= apart + if(first_radius + second_radius <= apart || abs(first_radius - second_radius) >= apart) + return list(first_x + apart_x * first_radius, first_y + apart_y * first_radius) + var/along = (apart * apart + first_radius * first_radius - second_radius * second_radius) / (2 * apart) + var/aside = sqrt(max(0, first_radius * first_radius - along * along)) + var/list/one = list(first_x + apart_x * along - apart_y * aside, first_y + apart_y * along + apart_x * aside) + var/list/two = list(first_x + apart_x * along + apart_y * aside, first_y + apart_y * along - apart_x * aside) + if((one[1] - near_x) ** 2 + (one[2] - near_y) ** 2 <= (two[1] - near_x) ** 2 + (two[2] - near_y) ** 2) + return one + return two + +/// How far along the line from [from_x], [from_y] heading [angle] degrees it first meets the circle of [radius] round [round_x], [round_y], or null. +/proc/gorilla_ray_meets(from_x, from_y, angle, round_x, round_y, radius) + var/off_x = from_x - round_x + var/off_y = from_y - round_y + var/half_b = off_x * cos(angle) + off_y * sin(angle) + var/c = off_x * off_x + off_y * off_y - radius * radius + var/disc = half_b * half_b - c + if(disc < 0) + return null + var/root = sqrt(disc) + if(-half_b - root >= 0) + return -half_b - root + if(-half_b + root >= 0) + return -half_b + root + return null + +/datum/hv_finisher/chrome/gorilla/rip/beat(key) + if(QDELETED(victim)) + return + switch(key) + if("tear") + // The sparks at the shoulder the arm leaves, on the body: on the arm they would go off with it in his fists + var/obj/effect/abstract/chrome_puppet/torn_from = victim_rig?.puppet("body") + if(torn_from) + var/list/socket = victim_rig.shoulder_point(side) + hit_stop(torn_from, TRUE, round(socket[2]), round(socket[1])) + else + hit_stop(victim) + var/outcome = gorilla_limb_rip(victim, target_zone, user, fist(), pool_spot()) + // Both bodies are hidden behind their stand-ins, and so is what this just did to them (the stump, the blood + // that ran back over him): the stand-ins take it on now, or it would only show when they come down + redraw_bodies(outcome == "torn") + if(outcome == "torn") + held_limb = gorilla_last_torn_limb(victim, target_zone) + if(held_limb?.can_bleed()) + shoulder_burst() + // The arm goes with the bearer's fists; the body drops back to the floor + var/obj/effect/abstract/chrome_puppet/arm = victim_rig?.puppet("arm_[side]") + if(arm && bearer_rig) + var/list/arm_shoulder = victim_rig.shoulder(side) + var/list/arm_hand = victim_rig.hand_offset(side) + club_ends = list(arm_shoulder[1] + arm_hand[1], arm_shoulder[2] + arm_hand[2], arm_shoulder[1], arm_shoulder[2]) + victim_rig.puppets -= "arm_[side]" + bearer_rig.puppets["club"] = arm + // Drawn where it was, from the bearer's tile + var/list/toward = to_bearer() + arm.pixel_x -= toward[1] + arm.pixel_y -= toward[2] + arm.forceMove(get_turf(user)) + // In his fists, over them. Seen from behind he holds it on his far side, so his body hides it + arm.layer = facing == NORTH ? user.layer - 0.005 : user.layer + 0.03 + if(grip && facing == NORTH) + // Yanked back lying as it was hauled, it would cross the back of his legs and reach past his feet. + // It comes down in his fist, back to its own length, and hangs from it beside him + var/list/origin = bearer_origin() + hang_club(arm, list(grip[1] - origin[1], grip[2] - origin[2]), bearer_rig.hand_point(grip_side)) + else if(grip) + // ...and yanked back with the fist that held it + var/list/fist_at = bearer_rig.hand_point(grip_side) + var/list/origin = bearer_origin() + animate(arm, pixel_x = arm.pixel_x + round(origin[1] + fist_at[1] - grip[1]), pixel_y = arm.pixel_y + round(origin[2] + fist_at[2] - grip[2]), time = 0.1 SECONDS, easing = SINE_EASING) + else + arm.pixel_x = 0 + arm.pixel_y = 0 + arm.pixel_z = 6 + arm.transform = matrix().Turn(100) + for(var/key_name in bearer_rig?.puppets) + var/obj/effect/abstract/chrome_puppet/part = bearer_rig.puppets[key_name] + animate(part, pixel_w = -2, time = 0.1 SECONDS, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + animate(pixel_w = 2, time = 0.3 SECONDS, flags = ANIMATION_RELATIVE) + // It drops back to the floor as the arm gives + fall_back() + +/** + * The torn arm ([club]) goes with the fist that holds its hand, from [from_fist] to [fist_at] (pixels from the middle of + * his puppets), swinging about it in short steps to hang straight down. The fist is at his side, and the arm back at + * its own length, by half way. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/hang_club(obj/effect/abstract/chrome_puppet/club, list/from_fist, list/fist_at) + var/held_length = club_length() + if(!held_length) + return + var/matrix/drawn = club.transform + var/list/hand_now = chrome_rig_apply(drawn, club_ends[1], club_ends[2]) + var/list/stump_now = chrome_rig_apply(drawn, club_ends[3], club_ends[4]) + var/angle_now = arctan(stump_now[1] - hand_now[1], stump_now[2] - hand_now[2]) + var/stretch_now = sqrt((stump_now[1] - hand_now[1]) ** 2 + (stump_now[2] - hand_now[2]) ** 2) / held_length + var/turn = -90 - angle_now + while(turn > 180) + turn -= 360 + while(turn <= -180) + turn += 360 + var/steps = max(4, bearer_rig.swing_steps(0, turn)) + var/obj/effect/abstract/chrome_puppet/own_arm = bearer_rig.puppet("arm_[grip_side]") + for(var/i in 1 to steps) + var/progress = i / steps + var/yanked = min(1, progress * 2) + var/matrix/hung = club_matrix(from_fist[1] + (fist_at[1] - from_fist[1]) * yanked, from_fist[2] + (fist_at[2] - from_fist[2]) * yanked, angle_now + turn * progress, stretch_now + (1 - stretch_now) * yanked) + if(i == 1) + // From here on its transform alone puts it in his fist, from where his own arm stands + animate(club, transform = hung, pixel_x = own_arm?.pixel_x || 0, pixel_y = own_arm?.pixel_y || 0, pixel_z = own_arm?.pixel_z || 0, time = GORILLA_RIP_HANG_TIME / steps) + else + animate(transform = hung, time = GORILLA_RIP_HANG_TIME / steps) + +/// The middle of the victim's head as drawn, lying or not: pixels from the middle of the bearer's tile. +/datum/hv_finisher/chrome/gorilla/rip/proc/victim_head_at() + var/list/head = chrome_rig_apply(victim.transform, 0, CHROME_RIG_NECK_PIVOT_Y + 3.5) + return list((victim.x - user.x) * ICON_SIZE_X + victim.pixel_x + victim.pixel_w + head[1], (victim.y - user.y) * ICON_SIZE_Y + victim.pixel_y + victim.pixel_z + head[2]) + +/// The torn arm's length in its own picture, hand to shoulder. +/datum/hv_finisher/chrome/gorilla/rip/proc/club_length() + return sqrt((club_ends[3] - club_ends[1]) ** 2 + (club_ends[4] - club_ends[2]) ** 2) + +/** + * The torn arm held by its hand at [fist_x], [fist_y] (pixels from the middle of the bearer's puppets), its shoulder + * end pointing [angle] degrees round from the right (anticlockwise), [stretch] times its length. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/club_matrix(fist_x, fist_y, angle, stretch = 1) + var/along = arctan(club_ends[3] - club_ends[1], club_ends[4] - club_ends[2]) + return chrome_rig_turn(along - angle, club_ends[1], club_ends[2], fist_x - club_ends[1], fist_y - club_ends[2], 1, stretch) + +/// The degrees from [from_angle] to [to_angle], turning the way [arm_turned] went (anticlockwise positive) when they are far apart. +/proc/gorilla_turn_with(from_angle, to_angle, arm_turned) + var/turned = to_angle - from_angle + while(turned > 180) + turned -= 360 + while(turned <= -180) + turned += 360 + if(abs(arm_turned) > 90 && turned * arm_turned < 0) + turned += arm_turned > 0 ? 360 : -360 + return turned + +/** + * The blow with the torn arm: both fists swing it up over his head in [raise], then bring it down on the victim's + * head in [strike], so it lands as the arms come down. The arm in his fists goes through the same short steps as + * his arms, held by its hand in the fist that tore it off. + */ +/datum/hv_finisher/chrome/gorilla/rip/proc/swing_club(raise, strike) + if(!bearer_rig) + return + var/obj/effect/abstract/chrome_puppet/club = club_ends ? bearer_rig.puppet("club") : null + var/holding = grip_side || bearer_rig.near_side() + var/list/origin = bearer_origin() + // The blow comes down from his shoulders onto the head; the fists go out as far along it as the arm in them doesn't + var/list/head = victim_head_at() + var/list/left = bearer_rig.shoulder("l") + var/list/right = bearer_rig.shoulder("r") + var/from_x = (left[1] + right[1]) / 2 + var/from_y = (left[2] + right[2]) / 2 + var/to_x = head[1] - origin[1] - from_x + var/to_y = head[2] - origin[2] - from_y + var/apart = sqrt(to_x * to_x + to_y * to_y) + var/blow_angle = arctan(to_x, to_y) + var/held_length = club ? club_length() : 0 + var/fist_along = clamp(apart - held_length, 0, GORILLA_CLUB_REACH * bearer_rig.arm_reach(holding)) + var/blow_stretch = held_length ? clamp((apart - fist_along) / held_length, 1, GORILLA_CLUB_MAX_STRETCH) : 1 + var/fist_x = from_x + fist_along * cos(blow_angle) + var/fist_y = from_y + fist_along * sin(blow_angle) + // Overhead: seen from the side up and back, the arm hanging back over his head; from the front or from behind + // straight up, where both his arms and the arm in them show over his head + var/club_up + var/list/poses_now = list() + var/list/poses_up = list() + var/list/poses_down = list() + for(var/arm_side in list("l", "r")) + poses_now[arm_side] = bearer_rig.arm_poses[arm_side] || list(0, 1) + var/list/up + if(side_view()) + up = list(200 * bearer_rig.raise_sign(arm_side), 1.2) + club_up = facing == EAST ? 145 : 35 + else + up = list(170 * bearer_rig.raise_sign(arm_side), 1.1) + club_up = 90 + poses_up[arm_side] = up + var/list/down = bearer_rig.pose_reaching(arm_side, fist_x, fist_y, up[1]) + down[2] = min(down[2], GORILLA_CLUB_REACH) + poses_down[arm_side] = down + // Every arm goes through the same steps: sine up, then faster and faster down + var/up_steps = 1 + var/down_steps = 1 + for(var/arm_side in list("l", "r")) + var/list/now = poses_now[arm_side] + var/list/up = poses_up[arm_side] + var/list/down = poses_down[arm_side] + up_steps = max(up_steps, bearer_rig.swing_steps(now[1], up[1])) + down_steps = max(down_steps, bearer_rig.swing_steps(up[1], down[1])) + var/list/progress = list() + var/list/step_times = list() + for(var/i in 1 to up_steps) + progress += (1 - cos(180 * i / up_steps)) / 2 + step_times += raise / up_steps + for(var/i in 1 to down_steps) + progress += 1 - cos(90 * i / down_steps) + step_times += strike / down_steps + var/list/arm_steps = list("l" = list(), "r" = list()) + for(var/i in 1 to length(progress)) + var/rising = i <= up_steps + for(var/arm_side in list("l", "r")) + var/list/was = rising ? poses_now[arm_side] : poses_up[arm_side] + var/list/will = rising ? poses_up[arm_side] : poses_down[arm_side] + arm_steps[arm_side] += list(list(was[1] + (will[1] - was[1]) * progress[i], was[2] + (will[2] - was[2]) * progress[i])) + for(var/arm_side in arm_steps) + bearer_rig.pose_arm_through(arm_side, arm_steps[arm_side], step_times) + if(!club) + return + // The torn arm turns the way the arm holding it does, from where it hangs in the fist now + var/matrix/drawn = club.transform + var/list/hand_now = chrome_rig_apply(drawn, club_ends[1], club_ends[2]) + var/list/stump_now = chrome_rig_apply(drawn, club_ends[3], club_ends[4]) + var/club_now = arctan(stump_now[1] - hand_now[1], stump_now[2] - hand_now[2]) + var/stretch_now = held_length ? sqrt((stump_now[1] - hand_now[1]) ** 2 + (stump_now[2] - hand_now[2]) ** 2) / held_length : 1 + var/list/hold_now = poses_now[holding] + var/list/hold_up = poses_up[holding] + var/list/hold_down = poses_down[holding] + // Arm turns are clockwise, the arm's angles anticlockwise + var/turn_up = gorilla_turn_with(club_now, club_up, hold_now[1] - hold_up[1]) + var/turn_down = gorilla_turn_with(club_now + turn_up, blow_angle, hold_up[1] - hold_down[1]) + var/obj/effect/abstract/chrome_puppet/holding_arm = bearer_rig.puppet("arm_[holding]") + var/list/held_steps = arm_steps[holding] + for(var/i in 1 to length(held_steps)) + var/rising = i <= up_steps + var/list/fist = bearer_rig.hand_at(holding, held_steps[i]) + var/angle = rising ? club_now + turn_up * progress[i] : club_now + turn_up + turn_down * progress[i] + var/stretch = rising ? stretch_now + (1 - stretch_now) * progress[i] : 1 + (blow_stretch - 1) * progress[i] + var/matrix/held = club_matrix(fist[1], fist[2], angle, stretch) + if(i == 1) + animate(club, transform = held, pixel_x = holding_arm?.pixel_x || 0, pixel_y = holding_arm?.pixel_y || 0, pixel_w = 0, pixel_z = holding_arm?.pixel_z || 0, time = step_times[i]) + else + animate(transform = held, time = step_times[i]) + +/// The torn arm lands on the victim's head. +/datum/hv_finisher/chrome/gorilla/rip/proc/club_hit() + if(!running || QDELETED(victim) || !held_limb) + return + var/obj/item/bodypart/head = victim.get_bodypart(BODY_ZONE_HEAD) + victim.hv_hold_attack_message("[user] beats [victim] with [victim.p_their()] own arm!", "[user] beats you with your own arm!", "You beat [victim] with [victim.p_their()] own arm!", user, vision_range = DEFAULT_MESSAGE_RANGE) + // None of #509's heavy-hit spray for this blow: its fan lands a tile out past the body, nowhere near the head + gorilla_hold_spray(victim) + victim.apply_damage(15, BRUTE, head || BODY_ZONE_CHEST, victim.run_armor_check(head, MELEE), wound_bonus = CANT_WOUND, attack_direction = get_dir(user, victim), attacking_item = fist()) + victim.hv_flush_hit() + playsound(victim, 'sound/effects/wounds/splatter.ogg', 60, TRUE) + // The blow's wound is drawn on the hidden body: its stand-in takes it on, and takes the hit + var/obj/effect/abstract/chrome_puppet/body_puppet = victim_rig?.puppet("body") + if(body_puppet && victim_rig.snapshot()) + victim_rig.repaint("body", victim_rig.puppet("arm_[side]") ? victim_rig.cut_without_arms(side) : victim_rig.flat) + var/obj/effect/abstract/cyberware_anim/impact = gorilla_play_impact(user, body_puppet || victim, "impact_gorilla") + if(impact && body_puppet) + // On the head, where the arm lands. On a puppet it keeps the puppet's place but not its turn: the head as it lies + var/list/head_at = chrome_rig_apply(victim.transform, 0, CHROME_RIG_NECK_PIVOT_Y + 3.5) + impact.pixel_w += round(head_at[1]) + impact.pixel_z += round(head_at[2]) + else if(impact) + // It rides on the body, so its offset turns with a lying one: up is the head + impact.pixel_y += round(CHROME_RIG_NECK_PIVOT_Y + 3.5) + // Not tg's Shake(): its first step takes pixel_y from pixel_x, which throws a body pulled in by a grab a third of a + // tile aside for a frame + if(body_puppet) + for(var/key_name in victim_rig.puppets) + gorilla_shudder(victim_rig.puppets[key_name], 2, 1, 0.2 SECONDS) + else + gorilla_shudder(victim, 2, 1, 0.2 SECONDS) + if(held_limb.can_bleed()) + victim.add_splatter_floor(get_turf(victim), small_drip = TRUE) + +/// Puts the torn arm down on the victim's tile, wherever the finisher stopped. +/datum/hv_finisher/chrome/gorilla/rip/proc/drop_held_limb() + if(isnull(held_limb)) + return + var/obj/item/bodypart/limb = held_limb + held_limb = null + if(QDELETED(limb)) + return + var/turf/spot = get_turf(victim) || get_turf(user) + if(spot) + limb.forceMove(spot) + // What still runs out of it as it lands: a drip, into the pool from the tear where there is one. Not a fresh + // splash on the body's tile a second after the wound + if(limb.can_bleed()) + if(!QDELETED(victim) && get_turf(victim) == spot) + victim.add_splatter_floor(spot, TRUE) + else + new /obj/effect/decal/cleanable/blood/drip(spot, null, limb.blood_dna_info) + +/// The arm just torn from [victim] at [zone], waiting in nullspace, or null. +/proc/gorilla_last_torn_limb(mob/living/carbon/victim, zone) + var/obj/item/bodypart/limb = victim.gorilla_torn_limb?.resolve() + victim.gorilla_torn_limb = null + if(QDELETED(limb) || limb.body_zone != zone) + return null + return limb + +/mob/living/carbon + /// The last arm a Gorilla tore off this body, until the finisher takes it. + var/datum/weakref/gorilla_torn_limb + +/** + * Tears [victim]'s arm at [zone] off, or wrenches the shoulder out of its socket when it's armoured, or + * does nothing but hurt on the Atlas frame or a limb that can't come off. Returns "torn", + * "dislocated" or "held". [blood_at] (list(x, y) pixels from the middle of the victim's tile) is where + * the blood the torn shoulder puts on the floor goes; the middle of the tile without it. + */ +/proc/gorilla_limb_rip(mob/living/carbon/victim, zone, mob/living/user, obj/item/fist, list/blood_at) + var/obj/item/bodypart/limb = victim.get_bodypart(zone) + if(isnull(limb)) + return null + var/toward_bearer = get_dir(victim, user) + if(!limb.can_dismember() || HAS_TRAIT(victim, TRAIT_CYBERWARE_UNBREAKABLE_BONES)) + victim.hv_hold_attack_message("[user] wrenches at [victim]'s [limb.plaintext_zone]!", "[user] wrenches at your [limb.plaintext_zone]!", null, user) + victim.apply_damage(25, BRUTE, limb, victim.run_armor_check(limb, MELEE), wound_bonus = CANT_WOUND, attack_direction = toward_bearer) + victim.hv_add_hit_line("[victim]'s arm holds!", HV_LINE_BOLD, "Your arm holds!") + victim.hv_flush_hit() + log_combat(user, victim, "failed to tear off the arm of", "gorilla arms") + return "held" + if(hv_crit_cover_rating(victim, limb, MELEE) >= GORILLA_RIP_ARMOUR) + victim.hv_hold_attack_message("[user] wrenches at [victim]'s [limb.plaintext_zone]!", "[user] wrenches at your [limb.plaintext_zone]!", null, user) + victim.apply_damage(25, BRUTE, limb, victim.run_armor_check(limb, MELEE), wound_bonus = CANT_WOUND, attack_direction = toward_bearer) + if(hv_crit_apply_wound(limb, /datum/wound/blunt/bone/moderate, toward_bearer, fist)) + victim.hv_add_hit_line("[victim]'s shoulder wrenches out of its socket!", HV_LINE_BOLD, "Your shoulder wrenches out of its socket!") + victim.hv_flush_hit() + do_sparks(2, TRUE, victim) + log_combat(user, victim, "dislocated the arm of", "gorilla arms") + return "dislocated" + // The spray runs back at the bearer: the last hit on the body came from them. + victim.hv_hold_attack_message("[user] tears [victim]'s [limb.plaintext_zone] off at the shoulder!", "[user] tears your [limb.plaintext_zone] off at the shoulder!", "You tear [victim]'s [limb.plaintext_zone] off at the shoulder!", user, vision_range = DEFAULT_MESSAGE_RANGE) + victim.apply_damage(10, BRUTE, limb, wound_bonus = CANT_WOUND, attack_direction = toward_bearer) + // One straight line back at the bearer, who takes it; no fan past him + if(limb.can_bleed()) + gorilla_short_spray(victim, toward_bearer, 2) + var/obj/item/bodypart/torn = gorilla_tear_limb(victim, limb, toward_bearer, TRUE, blood_at) + victim.hv_flush_hit() + if(isnull(torn)) + return "held" + if(!torn.can_bleed()) + do_sparks(3, TRUE, victim) + playsound(victim, 'sound/effects/wounds/crackandbleed.ogg', 80, TRUE) + victim.gorilla_torn_limb = WEAKREF(torn) + log_combat(user, victim, "tore off the [torn.plaintext_zone] of", "gorilla arms") + return "torn" + +/** + * Takes [limb] off as tg's dismember() does (chest damage, scream, sound, mood, memory, bleeding, the + * floor splatter, the wet stump and the spray along the last blow), but never flings it: with [keep_out] + * it is kept out of the world for the finisher to hold, else it is left on the victim's tile. Fresh blood + * it puts on the floor goes [blood_at] (list(x, y) pixels from the middle of the tile), under the wound, if + * given; blood already on the tile stays where it is. Returns the limb or null. + */ +/proc/gorilla_tear_limb(mob/living/carbon/victim, obj/item/bodypart/limb, direction, keep_out = TRUE, list/blood_at) + if(isnull(limb) || limb.owner != victim || !limb.can_dismember() || HAS_TRAIT(victim, TRAIT_GODMODE)) + return null + var/obj/item/bodypart/chest = victim.get_bodypart(BODY_ZONE_CHEST) + chest?.receive_damage(clamp(limb.brute_dam / 2 * chest.body_damage_coeff, 15, 50), wound_bonus = CANT_WOUND) + INVOKE_ASYNC(victim, TYPE_PROC_REF(/mob, emote), "scream") + playsound(get_turf(victim), 'sound/effects/dismember.ogg', 80, TRUE) + victim.add_mood_event("dismembered_[limb.body_zone]", /datum/mood_event/dismembered, limb) + victim.add_mob_memory(/datum/memory/was_dismembered, lost_limb = limb) + LAZYSET(victim.body_zone_dismembered_by, limb.body_zone, WOUND_BLUNT) + var/bleeds = limb.can_bleed() + var/turf/spot = get_turf(victim) + var/list/old_blood = list() + if(blood_at && isturf(spot)) + for(var/obj/effect/decal/cleanable/blood/there in spot) + old_blood += there + if(bleeds) + victim.bleed(rand(20, 40)) + limb.drop_limb(FALSE, TRUE) + victim.update_equipment_speed_mods() + if(bleeds && isturf(spot)) + victim.add_splatter_floor(spot) + if(blood_at) + // tg lays it on the middle of the tile, which a body held in a grab is drawn well off + for(var/obj/effect/decal/cleanable/blood/pool in spot) + if(pool.type == /obj/effect/decal/cleanable/blood && !(pool in old_blood) && !QDELETED(pool)) + gorilla_place_blood(pool, blood_at[1], blood_at[2]) + if(QDELETED(limb)) + return null + if(keep_out) + limb.moveToNullspace() + return limb + +// ========================================================================= +// (C) THE BACKBREAKER +// ========================================================================= + +/datum/hv_finisher/chrome/gorilla/backbreaker + name = "gorilla backbreaker" + zone_preference = list(BODY_ZONE_CHEST) + stages = list( + /datum/hv_finisher_stage/hold/gorilla/back_hoist, + /datum/hv_finisher_stage/hold/gorilla/back_press, + /datum/hv_finisher_stage/kill/gorilla/backbreaker, + /datum/hv_finisher_stage/recover/gorilla/backbreaker, + ) + /// TRUE once the back broke: the body is rolled off still bent + var/broke = FALSE + /// Which way the body lies in his hands and on the floor after: 1 head east, -1 head west. Away from a bearer + /// facing east or west, so it goes off his knee head first; tg lays no body head north or south. + var/lay = 1 + +/datum/hv_finisher_stage/hold/gorilla/back_hoist + key = "hoist" + duration = 0.85 SECONDS + +/datum/hv_finisher_stage/hold/gorilla/back_press + key = "press" + duration = 1 SECONDS + +/datum/hv_finisher_stage/kill/gorilla/backbreaker + key = "slam" + effect_delay = 0.18 SECONDS + duration = 0.6 SECONDS + +/datum/hv_finisher_stage/recover/gorilla/backbreaker + key = "roll" + duration = 0.8 SECONDS + +/datum/hv_finisher/chrome/gorilla/backbreaker/pick_zone() + target_zone = BODY_ZONE_CHEST + return target_zone + +/datum/hv_finisher/chrome/gorilla/backbreaker/can_start_on(mob/living/carbon/target) + return !isnull(target.get_bodypart(BODY_ZONE_CHEST)) + +/datum/hv_finisher/chrome/gorilla/backbreaker/enter_line(key) + switch(key) + if("hoist") + return "[user] hoists [victim] over [user.p_their()] head!" + if("press") + return "[victim] thrashes in [user]'s grip." + if("roll") + return "[user] drops [victim] off [user.p_their()] knee." + +/datum/hv_finisher/chrome/gorilla/backbreaker/enter_self_line(key) + switch(key) + if("hoist") + return "[user] hoists you over [user.p_their()] head!" + if("press") + return "You thrash in [user]'s grip." + +/// Where the belt sits, from the icon's centre: halves turn about it. +#define BACK_WAIST_PIVOT_Y -7 + +/datum/hv_finisher/chrome/gorilla/backbreaker/pose(key) + var/list/toward = to_bearer() + switch(key) + if("hoist") + rig_bearer() + lay = (facing || user.dir) == WEST ? -1 : 1 + victim_rig = new(victim, SOUTH) + if(victim_rig.snapshot()) + // A body lying with its head the other way from how he will hold it comes up head first: turned to that in one + // straight step it would shrink away to nothing half way and grow back + var/lying_turn = arctan(victim.transform.a, victim.transform.b) + var/turn_over = abs(lay * 90 - lying_turn) > 90 ? lay * 90 - lying_turn : 0 + // Draw order, the same from the floor to the floor, so nothing changes places mid-move: + // - Facing away he lifts the body on his far side, holds it there and breaks it over a knee that is + // beyond him too: the body, then his own back, head and arms over it wherever they cross. + // - Any other way it comes up on the viewer's side of him and stays there: he is under it. + var/halves_layer = user.layer + ((facing || user.dir) == NORTH ? -0.05 : 0.05) + for(var/half in list("upper", "lower")) + var/obj/effect/abstract/chrome_puppet/part = victim_rig.add_puppet(half, victim_rig.cut("rig_[half]"), TRUE, halves_layer) + // Overhead on his back, flat, held clear above the bearer's head + if(turn_over) + var/steps = bearer_rig?.swing_steps(0, turn_over) || 15 + for(var/i in 1 to steps) + // Fast off the floor, slow into his hands + var/progress = sin(90 * i / steps) + var/matrix/turned = chrome_rig_turn(lying_turn + turn_over * progress, 0, BACK_WAIST_PIVOT_Y * progress) + if(i == 1) + animate(part, transform = turned, time = 0.55 SECONDS / steps) + else + animate(transform = turned, time = 0.55 SECONDS / steps) + animate(part, pixel_x = toward[1], pixel_y = toward[2], pixel_w = 0, pixel_z = 29, time = 0.55 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + else + animate(part, pixel_x = toward[1], pixel_y = toward[2], pixel_w = 0, pixel_z = 29, transform = laid(), time = 0.55 SECONDS, easing = SINE_EASING | EASE_OUT) + victim_rig.conceal() + else + QDEL_NULL(victim_rig) + // Fists up under the body + if(side_view()) + arm_to("near", 166, 0.5 SECONDS, 6) + arm_to("far", 174, 0.5 SECONDS, 6) + else + arms_to(170, 0.5 SECONDS, 3) + if("press") + bearer_rig?.tremble(1 SECONDS) + var/obj/effect/abstract/chrome_puppet/upper = victim_rig?.puppet("upper") + var/obj/effect/abstract/chrome_puppet/lower = victim_rig?.puppet("lower") + for(var/i in 1 to 4) + var/kick = (i % 2) ? 1 : -1 + if(upper) + if(i == 1) + animate(upper, transform = laid(6 * kick), time = 0.12 SECONDS) + else + animate(transform = laid(6 * kick), time = 0.24 SECONDS) + if(lower) + if(i == 1) + animate(lower, transform = laid(-(12 * kick)), time = 0.12 SECONDS) + else + animate(transform = laid(-(12 * kick)), time = 0.24 SECONDS) + if(upper) + animate(transform = laid(), time = 0.1 SECONDS) + if(lower) + animate(transform = laid(), time = 0.1 SECONDS) + if("slam") + // Down to one knee, and the body comes down across it + arms_to(120, 0.15 SECONDS, 2) + bearer_rig?.crouch(0.8, 3, 0.15 SECONDS, SINE_EASING | EASE_IN) + for(var/half in list("upper", "lower")) + var/obj/effect/abstract/chrome_puppet/part = victim_rig?.puppet(half) + if(part) + animate(part, pixel_z = 2, time = 0.16 SECONDS, easing = SINE_EASING | EASE_IN, flags = ANIMATION_PARALLEL) + if("roll") + // Off the knee and forward, onto the tile he faces (owner). If something is in the way there, it comes + // down at his feet instead, on his own tile (a body on the floor shares it). + var/turf/knee = get_turf(user) + var/turf/from = get_turf(victim) + var/turf/ahead = get_step(user, facing || user.dir) + var/shoved = can_lay_on(ahead) + var/turf/lands = shoved ? ahead : knee + if(lands && from && lands != from && victim.body_position == LYING_DOWN) + // The real body is hidden under its halves, which stay drawn where they are as it moves under them + if(shoved) + victim.forceMove(lands) + else + victim.Move(lands, get_dir(from, lands)) + lands = get_turf(victim) + for(var/key_name in victim_rig?.puppets) + var/obj/effect/abstract/chrome_puppet/part = victim_rig.puppets[key_name] + part.forceMove(lands) + part.pixel_x -= (lands.x - from.x) * ICON_SIZE_X + part.pixel_y -= (lands.y - from.y) * ICON_SIZE_Y + // At his feet it lies in front of him, toward the viewer, where he doesn't hide it: the real body too, for + // when the halves come down. Shoved clear of him it lies as tg lays any body. + var/at_feet = get_turf(victim) == knee + if(at_feet) + victim.AddComponent(/datum/component/gorilla_laid_in_front, lay) + // tg turns a lying body to the way it last crawled: lay it as the halves are, or it flips over when + // they come down. + if(victim.body_position == LYING_DOWN) + victim.set_lying_angle(lay > 0 ? LYING_ANGLE_EAST : LYING_ANGLE_WEST) + // Where the halves come to rest, from the middle of the tile they are on. They turn about the belt, seven + // pixels under the middle of the picture, so they sit that far back along the body and a pixel up to lie + // exactly where tg draws the lying body; at his feet the body is drawn out to them instead (the component). + var/rest_x = at_feet ? 0 : lay * BACK_WAIST_PIVOT_Y + var/rest_y = at_feet ? 1 - GORILLA_BACK_IN_FRONT : 1 + // Still bent if the back broke. A broken back hangs folded over the knee for a moment first. + var/bend = broke ? 33 : 0 + var/hold = broke ? GORILLA_BACK_FOLD_HOLD : 0 + if(at_feet) + // He lets it down and stands + arms_to(0, 0.5 SECONDS) + bearer_rig?.crouch(1, 0, 0.4 SECONDS, SINE_EASING | EASE_OUT) + else if(hold) + // He stays down on the knee under it until he shoves it off + addtimer(CALLBACK(src, PROC_REF(shove_off)), hold, TIMER_DELETE_ME) + else + shove_off() + for(var/half in list("upper", "lower")) + var/obj/effect/abstract/chrome_puppet/part = victim_rig?.puppet(half) + if(!part) + continue + var/way = half == "upper" ? 1 : -1 + animate(part, transform = laid(way * (broke ? 38 : 0)), time = hold) + if(at_feet) + animate(pixel_x = rest_x, pixel_y = rest_y, pixel_z = 0, transform = laid(way * bend), time = 0.45 SECONDS, easing = SINE_EASING | EASE_IN | EASE_OUT) + else + // Shoved: up off the knee and over, then down onto the floor ahead + animate(pixel_x = (part.pixel_x + rest_x) / 2, pixel_y = (part.pixel_y + rest_y) / 2, pixel_z = GORILLA_BACK_SHOVE_RISE, transform = laid(way * bend), time = GORILLA_BACK_SHOVE_TIME * 0.45, easing = SINE_EASING | EASE_OUT) + animate(pixel_x = rest_x, pixel_y = rest_y, pixel_z = 0, time = GORILLA_BACK_SHOVE_TIME * 0.55, easing = SINE_EASING | EASE_IN) + // No blood of the move's own where he lands (owner): a broken back doesn't bleed, and a pool on the middle + // of the tile never lined up with the body. What the body really bleeds is tg's. + // At his feet the halves stay drawn as they were hoisted while they lie there: over him, or under him seen + // from behind, where tg draws the lying body too + +/// The bearer shoves the body off his knee: both arms push out after it, then he lets them down and stands. +/datum/hv_finisher/chrome/gorilla/backbreaker/proc/shove_off() + if(!running || !bearer_rig) + return + // Away from the viewer the body goes on past him, behind him as it has been since the hoist + arms_to(side_view() ? 70 : 60, GORILLA_BACK_SHOVE_PUSH, 4) + addtimer(CALLBACK(src, PROC_REF(stand_up)), GORILLA_BACK_SHOVE_PUSH + 0.05 SECONDS, TIMER_DELETE_ME) + +/// He lets his arms down and stands off the knee. +/datum/hv_finisher/chrome/gorilla/backbreaker/proc/stand_up() + if(!running || !bearer_rig) + return + arms_to(0, 0.3 SECONDS) + bearer_rig.crouch(1, 0, 0.3 SECONDS, SINE_EASING | EASE_OUT) + +/// A half of the body as it is held and laid: flat on its back, head the way [var/lay] says, bent [bend] degrees at the belt. +/datum/hv_finisher/chrome/gorilla/backbreaker/proc/laid(bend = 0) + return chrome_rig_turn(lay * (90 + bend), 0, BACK_WAIST_PIVOT_Y) + +/** + * Whether the body can be shoved off the knee onto [ahead], the tile the bearer faces: open floor he can reach, with + * nothing solid on it and nobody else on their feet there. The body's own tile is fine: it was lifted off it. + */ +/datum/hv_finisher/chrome/gorilla/backbreaker/proc/can_lay_on(turf/ahead) + var/turf/here = get_turf(user) + if(QDELETED(victim) || !isopenturf(ahead) || !here || !here.Adjacent(ahead)) + return FALSE + // Nowhere to lie, unless it lay there already + if(get_turf(victim) != ahead && (isgroundlessturf(ahead) || ischasm(ahead) || islava(ahead))) + return FALSE + // No source atom: a body lying on a crate or table tile may pass what it sits on, but it is not put back down on one + if(ahead.is_blocked_turf(exclude_mobs = TRUE)) + return FALSE + for(var/mob/living/other in ahead) + if(other != victim && other != user && other.density && other.body_position == STANDING_UP) + return FALSE + return TRUE + +/datum/hv_finisher/chrome/gorilla/backbreaker/beat(key) + if(key != "slam" || QDELETED(victim)) + return + hit_stop(victim_rig?.puppet("upper") || victim, TRUE) + gorilla_backbreaker_sound(victim) + playsound(victim, 'sound/effects/meteorimpact.ogg', 50, TRUE) + var/turf/knee = get_turf(user) + if(knee) + new /obj/effect/temp_visual/cyberware_impact_cracks(knee, "damaged1", 255) + cyberware_grey_dust(knee) + var/outcome = gorilla_backbreak(victim, user, fist()) + broke = outcome == "broken" + // What the blow did to the body (the snapped bone, tg's wounds) is drawn on the hidden one: the halves take it on + // now, or it would only show when they come down + if(!QDELETED(victim) && victim_rig?.snapshot()) + for(var/half in list("upper", "lower")) + victim_rig.repaint(half, victim_rig.cut("rig_[half]")) + if(broke) + // The body folds over the knee + var/obj/effect/abstract/chrome_puppet/upper = victim_rig?.puppet("upper") + var/obj/effect/abstract/chrome_puppet/lower = victim_rig?.puppet("lower") + if(upper) + animate(upper, transform = laid(38), time = 0.06 SECONDS) + if(lower) + animate(lower, transform = laid(-(38)), time = 0.06 SECONDS) + else + // Nothing gives: the body bounces off the knee + for(var/half in list("upper", "lower")) + var/obj/effect/abstract/chrome_puppet/part = victim_rig?.puppet(half) + if(part) + animate(part, pixel_z = 6, time = 0.12 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + animate(pixel_z = 2, time = 0.12 SECONDS, easing = SINE_EASING | EASE_IN) + +/datum/hv_finisher/chrome/gorilla/backbreaker/cleanup_rigs() + // A broken back stays drawn bent for a while after + if(broke && victim_rig && !QDELETED(victim) && victim.get_bodypart(BODY_ZONE_CHEST)) + victim.AddComponent(/datum/component/gorilla_fold, victim_rig, lay) + victim_rig = null + return ..() + +/** + * Brings [victim] down across a knee: heavy brute to the chest, then a broken back, or cracked ribs under + * chest armour, or nothing on the Atlas frame. Returns "broken", "ribs", "frame" or "bruised". + */ +/proc/gorilla_backbreak(mob/living/carbon/victim, mob/living/user, obj/item/fist) + var/obj/item/bodypart/chest = victim.get_bodypart(BODY_ZONE_CHEST) + if(isnull(chest)) + return null + var/direction = get_dir(user, victim) + victim.hv_hold_attack_message("[user] drops to one knee and brings [victim] down across it!", "[user] drops to one knee and brings you down across it!", "You drop to one knee and bring [victim] down across it!", user, vision_range = DEFAULT_MESSAGE_RANGE) + // No attack direction: a body bent over a knee throws no blood across the room (#509's heavy-hit spray) + victim.apply_damage(45, BRUTE, chest, victim.run_armor_check(chest, MELEE), wound_bonus = CANT_WOUND) + . = "bruised" + if(HAS_TRAIT(victim, TRAIT_CYBERWARE_UNBREAKABLE_BONES)) + victim.hv_add_hit_line("[victim]'s frame holds!", HV_LINE_BOLD, "Your frame holds!") + . = "frame" + else if(hv_crit_cover_rating(victim, chest, MELEE) >= GORILLA_BACK_ARMOUR) + if(hv_crit_apply_wound(chest, /datum/wound/blunt/bone/severe, direction, fist)) + victim.hv_add_hit_line("[victim]'s ribs crack!", HV_LINE_BOLD, "Your ribs crack!") + . = "ribs" + else if(hv_crit_apply_wound(chest, /datum/wound/blunt/bone/critical/gorilla_spine, direction, fist)) + victim.hv_add_hit_line("[victim]'s back breaks!", HV_LINE_HUGE, "Your back breaks!", DEFAULT_MESSAGE_RANGE) + . = "broken" + if(!QDELETED(victim)) + victim.hv_flush_hit() + log_combat(user, victim, "backbroke", "gorilla arms", "([.])") + +/** + * # Broken back + * + * tg's compound fracture on the chest, with the spine gone: while it lasts the body can crawl but not + * stand. Treated like any compound fracture (surgery, or bone gel and tape). + */ +/datum/wound/blunt/bone/critical/gorilla_spine + name = "Broken Back" + undiagnosed_name = "Broken Back" + desc = "Patient's spine has been snapped across, leaving the legs useless." + treat_text = "Repair surgically. Bone gel and surgical tape will hold it in an emergency." + treat_text_short = "Repair surgically, or apply bone gel and surgical tape." + simple_desc = "Patient's back is broken. They cannot stand." + simple_treat_text = "Surgery, or bone gel and surgical tape." + homemade_treat_text = "Don't move them." + examine_desc = "is bent at an angle no back should bend" + occur_text = "folds the wrong way with a crack" + +/datum/wound/blunt/bone/critical/gorilla_spine/wound_injury(datum/wound/old_wound = null, attack_direction = null) + . = ..() + if(victim) + ADD_TRAIT(victim, TRAIT_FLOORED, REF(src)) + +/datum/wound/blunt/bone/critical/gorilla_spine/remove_wound(ignore_limb, replaced = FALSE) + if(victim) + REMOVE_TRAIT(victim, TRAIT_FLOORED, REF(src)) + return ..() + +/datum/wound/blunt/bone/critical/gorilla_spine/set_victim(new_victim) + if(victim) + REMOVE_TRAIT(victim, TRAIT_FLOORED, REF(src)) + return ..() + +/datum/wound_pregen_data/bone/gorilla_spine + abstract = FALSE + wound_path_to_generate = /datum/wound/blunt/bone/critical/gorilla_spine + viable_zones = list(BODY_ZONE_CHEST) + can_be_randomly_generated = FALSE + threshold_minimum = 115 + +/** + * The fold a broken back leaves: the victim's puppets stay bent for a while after the backbreaker, until + * the body is moved, buckled or the back is set. Left alone, it eases out flat when its time is up, to lie as + * the real body does, which then shows in its place. + */ +/datum/component/gorilla_fold + /// The victim's rig, handed over by the finisher + var/datum/chrome_rig/rig + /// 1 if the body lies head east, -1 head west + var/lay = 1 + var/fold_timer + +/datum/component/gorilla_fold/Initialize(datum/chrome_rig/rig, lay = 1) + if(!iscarbon(parent) || !istype(rig)) + return COMPONENT_INCOMPATIBLE + src.rig = rig + src.lay = lay + fold_timer = addtimer(CALLBACK(src, PROC_REF(settle)), GORILLA_FOLD_TIME, TIMER_STOPPABLE) + +/// The fold's time is up: the halves ease out flat, where the real body lies, and it shows once they are. +/datum/component/gorilla_fold/proc/settle() + for(var/half in list("upper", "lower")) + var/obj/effect/abstract/chrome_puppet/part = rig?.puppet(half) + if(part) + animate(part, transform = chrome_rig_turn(lay * 90, 0, BACK_WAIST_PIVOT_Y), time = GORILLA_FOLD_SETTLE, easing = SINE_EASING) + fold_timer = QDEL_IN_STOPPABLE(src, GORILLA_FOLD_SETTLE) + +/datum/component/gorilla_fold/RegisterWithParent() + RegisterSignals(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BUCKLED, COMSIG_CARBON_LOSE_WOUND, COMSIG_LIVING_REVIVE, COMSIG_LIVING_SET_BODY_POSITION), PROC_REF(unfold)) + +/datum/component/gorilla_fold/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BUCKLED, COMSIG_CARBON_LOSE_WOUND, COMSIG_LIVING_REVIVE, COMSIG_LIVING_SET_BODY_POSITION)) + +/datum/component/gorilla_fold/Destroy() + if(fold_timer) + deltimer(fold_timer) + fold_timer = null + QDEL_NULL(rig) + return ..() + +/datum/component/gorilla_fold/proc/unfold(datum/source) + SIGNAL_HANDLER + qdel(src) + +/** + * A body the backbreaker dropped on the bearer's own tile (the tile he faced was blocked), drawn [GORILLA_BACK_IN_FRONT] + * pixels toward the viewer so the one standing over it doesn't hide it. Comes off when it is moved, strapped in or gets up. + * + * It lies where its halves were laid. They turn about the belt, which is under the middle of the picture, so they lie + * that many pixels along toward the head from where tg draws a lying body (turned about its middle): the real body is + * drawn as far along, or it would jump back when the halves come down. + */ +/datum/component/gorilla_laid_in_front + +/// [lay] is 1 for a body lying head east, -1 head west. +/datum/component/gorilla_laid_in_front/Initialize(lay = 1) + if(!isliving(parent)) + return COMPONENT_INCOMPATIBLE + var/mob/living/body = parent + body.add_offsets(GORILLA_LAID_IN_FRONT_OFFSET, x_add = lay * -BACK_WAIST_PIVOT_Y, y_add = -GORILLA_BACK_IN_FRONT, animate = FALSE) + +/datum/component/gorilla_laid_in_front/RegisterWithParent() + RegisterSignals(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BUCKLED, COMSIG_LIVING_SET_BODY_POSITION), PROC_REF(moved_off)) + +/datum/component/gorilla_laid_in_front/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BUCKLED, COMSIG_LIVING_SET_BODY_POSITION)) + var/mob/living/body = parent + body.remove_offsets(GORILLA_LAID_IN_FRONT_OFFSET) + +/datum/component/gorilla_laid_in_front/proc/moved_off(datum/source) + SIGNAL_HANDLER + qdel(src) + +#undef BACK_WAIST_PIVOT_Y diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_haymaker.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_haymaker.dm new file mode 100644 index 00000000000..6ddd071aa9f --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_haymaker.dm @@ -0,0 +1,623 @@ +/** + * # The charged haymaker + * + * A chrome wheel chip on each real Gorilla arm. Hold Use chrome to wind up and let go to throw it at + * whoever is in the tile you face; or tap Use chrome (or pick the chip) and click someone next to you. + * The wind-up slows the bearer, lets go of any grab and leans back, so the target has a + * beat to step out of line. The hit sends the body flying along the safe path, further for a full + * charge; into a wall it hits harder and cracks the chest. A swing at nobody staggers the bearer. + * Held too long, or called off, the charge is lost. + * + * The arm shows it. A bearer who stands their ground is drawn on the puppet rig (chrome_puppet_rig.dm, with the swing + * of gorilla_swing.dm): the punching arm draws back as the charge builds and is held there, the other comes up as a + * guard, and on the release the fist is thrown onto the part it hits with a step in behind it, stays there a beat, + * follows through and comes back to rest. The blow lands with the fist on it, a tick after the release. A bearer who + * walks or turns while winding up keeps the lean alone, and their blow is tg's lunge; so does one whose punching hand + * holds something. A guard hand that holds something stays down. + * + * The haymaker and every Gorilla finisher share one cooldown, kept on the bearer, so they never chain. + */ + +/datum/action/cooldown/cyberware/gorilla_haymaker + name = "Haymaker" + desc = "Wind up one fist and put everything behind it." + button_icon = GORILLA_GORE_ICON + button_icon_state = "chip_haymaker" + check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED | AB_CHECK_HANDS_BLOCKED + cooldown_time = GORILLA_PISTONS_COOLDOWN + click_to_activate = TRUE + unset_after_click = TRUE + /// world.time the wind-up began, 0 when not winding up + var/charge_started = 0 + /// world.time Use chrome went down for this charge, so a short press reads as a tap + var/pressed_at = 0 + /// Set while a release unsets the click ability, so that doesn't read as calling it off + var/releasing = FALSE + /// Timer that vents a charge held too long + var/vent_timer + /// Timer for a release made before the minimum wind-up: it lands when the wind-up is done + var/release_timer + /// The bearer's arm rig while the wind-up and the swing are drawn + var/datum/chrome_rig/rig + /// Timer that takes the rig down when the arms are back at rest + var/rig_timer + /// The guard hand held something when the rig came up, so that arm stays down + var/guard_still = FALSE + /// Timer that lands a thrown blow + var/land_timer + /// The part the blow must land on, for an AI that picks one. Else it is rolled from the part the bearer aims at + var/aimed_zone + +/datum/action/cooldown/cyberware/gorilla_haymaker/Destroy() + stop_charge() + if(land_timer) + deltimer(land_timer) + land_timer = null + return ..() + +/datum/action/cooldown/cyberware/gorilla_haymaker/Remove(mob/remove_from) + if(charge_started) + stop_charge() + return ..() + +/datum/action/cooldown/cyberware/gorilla_haymaker/IsAvailable(feedback = FALSE) + . = ..() + if(!.) + return + if(!TIMER_COOLDOWN_FINISHED(owner, COOLDOWN_GORILLA_PISTONS)) + if(feedback) + owner.balloon_alert(owner, "pistons still hot!") + return FALSE + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = organ + if(!istype(arm) || !arm.heavy_moves || !gorilla_may_use_heavy_moves(owner) || HAS_TRAIT(owner, TRAIT_PACIFISM)) + return FALSE + return TRUE + +/// Whether a wind-up is running. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/charging() + return charge_started > 0 + +// A second press while winding up throws it at the tile you face. +/datum/action/cooldown/cyberware/gorilla_haymaker/Trigger(mob/clicker, trigger_flags, atom/target) + if(charging() && !target && owner) + if(!IsAvailable(feedback = TRUE)) + return FALSE + release(get_step(owner, owner.dir)) + return TRUE + return ..() + +/datum/action/cooldown/cyberware/gorilla_haymaker/set_click_ability(mob/on_who) + . = ..() + start_charge() + +/datum/action/cooldown/cyberware/gorilla_haymaker/unset_click_ability(mob/on_who, refund_cooldown = TRUE) + . = ..() + // Called off by hand (the chip again, a stun, the arm going dark): the pistons vent. + if(charging() && !releasing && !release_timer) + vent() + +/datum/action/cooldown/cyberware/gorilla_haymaker/Activate(atom/target) + return release(target) + +/// Use chrome came back up: a held press throws it at the tile you face, a tap waits for a click. +/datum/action/cooldown/cyberware/gorilla_haymaker/chrome_use_released(mob/living/carbon/bearer) + if(!charging() || bearer != owner || release_timer) + return FALSE + if(world.time - pressed_at < GORILLA_HAYMAKER_TAP || !IsAvailable(feedback = TRUE)) + return FALSE + release(get_step(owner, owner.dir)) + return TRUE + +/** + * Winds up and lands the blow on [target] after [hold_time], with no click or key: the same wind-up anyone can see + * and dodge. On [zone], if one is given. For an AI. Returns TRUE if the wind-up began. + */ +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/wind_up_at(atom/target, hold_time = GORILLA_HAYMAKER_FULL_CHARGE, zone) + if(charging() || !IsAvailable()) + return FALSE + start_charge() + if(!charging()) + return FALSE + aimed_zone = zone + // Thrown a throw's length early, so the blow lands when the hold is up + release_timer = addtimer(CALLBACK(src, PROC_REF(queued_release), WEAKREF(target)), max(hold_time, GORILLA_HAYMAKER_MIN_CHARGE) - GORILLA_HAYMAKER_THROW, TIMER_STOPPABLE|TIMER_DELETE_ME) + return TRUE + +/// Begins the wind-up. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/start_charge() + var/mob/living/carbon/bearer = owner + if(!iscarbon(bearer) || charging()) + return + charge_started = world.time + pressed_at = world.time + aimed_zone = null + // Before the lean: the puppets come up where the body rests, and lean with it from there + raise_rig(bearer) + bearer.apply_status_effect(/datum/status_effect/gorilla_windup, src) + if(!bearer.has_status_effect(/datum/status_effect/gorilla_windup)) + drop_rig() + vent_timer = addtimer(CALLBACK(src, PROC_REF(vent)), GORILLA_HAYMAKER_VENT_AFTER, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/// Ends the wind-up without throwing anything. Clears every timer and the look; with [keep_rig] the arms stay up, for a swing or to come down. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/stop_charge(keep_rig = FALSE) + if(!keep_rig) + drop_rig() + charge_started = 0 + pressed_at = 0 + if(vent_timer) + deltimer(vent_timer) + vent_timer = null + if(release_timer) + deltimer(release_timer) + release_timer = null + var/mob/living/bearer = owner + if(!QDELETED(bearer)) + var/datum/status_effect/gorilla_windup/windup = bearer.has_status_effect(/datum/status_effect/gorilla_windup) + if(windup?.action == src) + qdel(windup) + +/// Held too long, or called off: a short cooldown, nothing thrown. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/vent() + vent_timer = null + if(!charging()) + return + var/mob/living/bearer = owner + stop_charge(keep_rig = TRUE) + lower_rig() + if(QDELETED(bearer)) + return + gorilla_spend_pistons(bearer, GORILLA_PISTONS_VENTED) + if(bearer.click_intercept == src) + releasing = TRUE + unset_click_ability(bearer, refund_cooldown = FALSE) + releasing = FALSE + +/// The wind-up's status effect went away under it (a stun, death): end quietly, no vent. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/windup_lost() + if(!charging()) + return + drop_rig() + charge_started = 0 + pressed_at = 0 + if(vent_timer) + deltimer(vent_timer) + vent_timer = null + if(release_timer) + deltimer(release_timer) + release_timer = null + if(owner?.click_intercept == src) + releasing = TRUE + unset_click_ability(owner, refund_cooldown = FALSE) + releasing = FALSE + +/** + * Lets it go at [target] (a mob, or a tile to swing into). Before the minimum wind-up the blow waits + * and lands when it is done. Returns TRUE if anything was thrown or queued. + */ +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/release(atom/target) + if(!charging() || release_timer) + return FALSE + var/held = world.time - charge_started + // Thrown a throw's length before the minimum, so the blow lands on it + if(held < GORILLA_HAYMAKER_MIN_CHARGE - GORILLA_HAYMAKER_THROW) + var/datum/weakref/target_ref = WEAKREF(target) + release_timer = addtimer(CALLBACK(src, PROC_REF(queued_release), target_ref), GORILLA_HAYMAKER_MIN_CHARGE - GORILLA_HAYMAKER_THROW - held, TIMER_STOPPABLE|TIMER_DELETE_ME) + return TRUE + throw_haymaker(target, max(held, GORILLA_HAYMAKER_MIN_CHARGE)) + return TRUE + +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/queued_release(datum/weakref/target_ref) + release_timer = null + if(!charging() || !IsAvailable()) + stop_charge() + return + // The charge it has when the blow lands + throw_haymaker(target_ref?.resolve(), world.time - charge_started + GORILLA_HAYMAKER_THROW) + +/** + * The swing itself, for a charge of [held] deciseconds. The fist is thrown now and the blow lands as it arrives + * (land()). Who it hits and where is settled here. + */ +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/throw_haymaker(atom/target, held) + var/mob/living/carbon/human/bearer = owner + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = organ + var/zone = aimed_zone + stop_charge(keep_rig = TRUE) + if(bearer?.click_intercept == src) + releasing = TRUE + unset_click_ability(bearer, refund_cooldown = FALSE) + releasing = FALSE + if(!ishuman(bearer) || !istype(arm) || arm.owner != bearer) + drop_rig() + return + gorilla_spend_pistons(bearer, GORILLA_PISTONS_COOLDOWN) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/both as anything in gorilla_heavy_arms(bearer)) + COOLDOWN_START(both, slam_cooldown, both.punch_cooldown_time) + bearer.changeNext_move(CLICK_CD_MELEE) + // Swinging from inside a camo field drops it, as any blow does + cyberware_camo_drop(bearer, "haymaker") + var/mob/living/victim = gorilla_haymaker_victim(bearer, target) + if(isnull(victim)) + var/turf/swing_at = isturf(target) ? target : get_step(bearer, bearer.dir) + if(swing_at) + // A turn takes the rig down (it is a picture of the old facing), and the swing is tg's lunge + bearer.face_atom(swing_at) + // The arm and the step in, or the lunge only: a fist that met nothing leaves no mark on the floor + if(!swing()) + bearer.do_attack_animation(swing_at) + else + drop_rig() + playsound(bearer, 'sound/items/weapons/punchmiss.ogg', 50, TRUE) + bearer.visible_message(span_danger("[bearer]'s fist hits nothing but air!"), span_userdanger("Your fist hits nothing but air!")) + bearer.adjust_staggered_up_to(1 SECONDS, 1 SECONDS) + return + var/charge = clamp((held - GORILLA_HAYMAKER_MIN_CHARGE) / (GORILLA_HAYMAKER_FULL_CHARGE - GORILLA_HAYMAKER_MIN_CHARGE), 0, 1) + zone ||= victim.get_random_valid_zone(bearer.zone_selected) + bearer.face_atom(victim) + // The lunge only, as with the piston punch, when the arm can't be drawn: the sparks are the blow's mark + if(!swing(victim, zone)) + bearer.do_attack_animation(victim) + if(land_timer) + deltimer(land_timer) + land_timer = addtimer(CALLBACK(src, PROC_REF(land), WEAKREF(victim), charge, zone), GORILLA_HAYMAKER_THROW, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/// The thrown fist arrives on [zone] of the victim: the blow, as it was settled at the release. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/land(datum/weakref/victim_ref, charge, zone) + land_timer = null + var/mob/living/victim = victim_ref?.resolve() + var/mob/living/carbon/human/bearer = owner + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = organ + if(QDELETED(victim) || !ishuman(bearer) || !istype(arm) || arm.owner != bearer) + return + gorilla_haymaker_hit(bearer, victim, arm, charge, zone) + +// ========================================================================= +// THE ARM +// ========================================================================= + +/// The punching arm's side on the rig: the arm that carries this chip. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/punching_side() + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = organ + return (istype(arm) && arm.zone == BODY_ZONE_L_ARM) ? "l" : "r" + +/** + * The wind-up's poses for the way the rig faces: list(punching arm half drawn, punching arm drawn, guard arm half + * up, guard arm up, punching arm thrown at nobody, guard arm at the throw, degrees the punching arm carries on by, + * its piston then), each list(degrees up from hanging, pixels of piston) but the seventh. + */ +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/swing_poses() + var/static/list/side_on = list(list(-60, -1), list(-115, 0), list(45, -1), list(70, -1), list(92, 7), list(20, 0), 43, 2) + var/static/list/away = list(list(70, -3), list(115, -2), list(8, 0), list(12, 0), list(174, 6), list(5, 0), -14, 1) + var/static/list/toward = list(list(70, -3), list(120, -2), list(8, 0), list(12, 0), list(14, 6), list(5, 0), -22, 2) + if(rig.facing & (EAST|WEST)) + return side_on + return rig.facing == NORTH ? away : toward + +/** + * Draws the bearer on the rig and starts the wind-up: after a beat with the real body still on show, the punching + * arm draws back, half way by GORILLA_HAYMAKER_DRAW and all the way by GORILLA_HAYMAKER_DRAWN, and the other arm + * comes up as a guard if its hand is empty. Returns TRUE if the rig is up. + */ +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/raise_rig(mob/living/carbon/human/bearer) + drop_rig() + if(!ishuman(bearer) || bearer.body_position == LYING_DOWN || !isturf(bearer.loc) || !(bearer.dir in GLOB.cardinals)) + return FALSE + // Faded (a camo field, a cloak): puppets would stand there in plain sight. Taller or shorter than the rig's cuts: + // the picture is of a body of the usual height + if(bearer.alpha < 255 || bearer.invisibility || bearer.mob_height != HUMAN_HEIGHT_MEDIUM) + return FALSE + // An arm is cut from the picture at its own outline, so one that swings would take the thing in its hand apart and + // leave the rest of it behind. A punching hand that holds something gets no drawing, and a full guard hand stays down + var/side = punching_side() + var/guard = side == "l" ? "r" : "l" + if(bearer.get_item_for_held_index(side == "l" ? 1 : 2)) + return FALSE + guard_still = !!bearer.get_item_for_held_index(guard == "l" ? 1 : 2) + rig = new(bearer, bearer.dir) + if(!rig.rig_arms(GORILLA_HAYMAKER_RIG_HOLD)) + QDEL_NULL(rig) + return FALSE + // A step, a turn or a fall: the drawing comes down at once and the lean carries the rest of the wind-up + rig.watch_body(CALLBACK(src, PROC_REF(drop_rig)), turns = TRUE) + var/list/poses = swing_poses() + // Facing the viewer the arm is drawn back behind its own shoulder + var/back_layer = rig.facing == SOUTH ? bearer.layer - 0.01 : null + var/datum/chrome_swing_beat/hold = new(GORILLA_HAYMAKER_RIG_HOLD) + var/datum/chrome_swing_beat/half = new(GORILLA_HAYMAKER_DRAW - GORILLA_HAYMAKER_RIG_HOLD, CHROME_SWING_EASE_OUT) + half.arm(side, rig.pose_of(side, poses[1][1], poses[1][2]), back_layer) + var/datum/chrome_swing_beat/drawn = new(GORILLA_HAYMAKER_DRAWN - GORILLA_HAYMAKER_DRAW, CHROME_SWING_EASE_OUT) + drawn.arm(side, rig.pose_of(side, poses[2][1], poses[2][2])) + if(!guard_still) + half.arm(guard, rig.pose_of(guard, poses[3][1], poses[3][2])) + drawn.arm(guard, rig.pose_of(guard, poses[4][1], poses[4][2])) + play_rig(list(hold, half, drawn)) + return TRUE + +/// Plays [beats] on the rig from where its arms are, the body starting [shift_x], [shift_y] pixels from its rest. With [settle], every puppet eases onto the body's own offsets over the first frame. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/play_rig(list/beats, shift_x = 0, shift_y = 0, settle = FALSE) + var/list/arms_from = list() + var/list/arms = list() + for(var/arm_side in list("l", "r")) + arms_from[arm_side] = rig.arm_poses[arm_side] || list(0, 1) + arms[arm_side] = rig.puppet("arm_[arm_side]") + var/list/frames = chrome_swing_frames(beats, arms_from, shift_x, shift_y) + var/list/rest + if(settle) + rest = list() + var/list/offsets = list(rig.body.pixel_w, rig.body.pixel_x, rig.body.pixel_y, rig.body.pixel_z) + for(var/key in rig.puppets) + rest[rig.puppets[key]] = offsets + chrome_swing_play(rig, frames, list(rig.puppet("body")), arms, null, rest) + // Where the arms end up + for(var/datum/chrome_swing_beat/beat as anything in beats) + for(var/arm_side in beat.arms) + var/list/pose = beat.arms[arm_side] + rig.arm_poses[arm_side] = list(pose[1], pose[2]) + +/// How far the rig's puppets stand from where the hidden body is now: list(across, up). The lean and the tremble they still carry once the wind-up has let the body go. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/rig_leant() + var/obj/effect/abstract/chrome_puppet/puppet = rig.puppet("body") + var/mob/living/body = rig.body + if(isnull(puppet)) + return list(0, 0) + return list(puppet.pixel_x + puppet.pixel_w - body.pixel_x - body.pixel_w, puppet.pixel_y + puppet.pixel_z - body.pixel_y - body.pixel_z) + +/// The wind-up's lean or tremble moved the hidden body: its puppets go with it ([eased] as tg eases an offset, or at once). +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/rig_follow(eased = TRUE) + rig?.follow_offsets(eased) + +/** + * The swing on the rig, from where the wind-up left the arms: the fist thrown onto [zone] of [victim] (or through the + * empty tile ahead) with a step in behind it, the follow-through, and back to rest; then the rig comes down. Called + * once the wind-up has ended. Returns FALSE, with the rig down, if it can't be drawn: no rig, a bearer who has + * turned away from the way it faces, or a victim who isn't straight ahead. + */ +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/swing(mob/living/victim, zone) + var/mob/living/carbon/human/bearer = owner + if(isnull(rig) || rig.body != bearer || rig.facing != bearer.dir || !isturf(bearer.loc)) + drop_rig() + return FALSE + // The arm is thrown the way the rig faces. A body a corner away, or on the bearer's own tile, isn't there + if(victim && get_turf(victim) != get_step(bearer.loc, rig.facing)) + drop_rig() + return FALSE + var/list/leant = rig_leant() + var/side = punching_side() + var/guard = side == "l" ? "r" : "l" + var/list/poses = swing_poses() + var/list/way = chrome_swing_way(rig.facing) + // The throw: onto the part, the body stepping in as far as it takes + var/list/thrown = rig.pose_of(side, poses[5][1], poses[5][2]) + var/step = rig.facing & (EAST|WEST) ? GORILLA_HAYMAKER_STEP_MAX - 2 : GORILLA_HAYMAKER_STEP_MIN + var/list/point = victim && gorilla_fist_target(bearer, victim, zone) + if(point) + var/list/reach = chrome_swing_reach(rig, side, point[1], point[2], way, GORILLA_HAYMAKER_STEP_MIN, (rig.facing & (EAST|WEST)) ? GORILLA_HAYMAKER_STEP_MAX : GORILLA_SWING_STEP_UPRIGHT, 0, GORILLA_SWING_EASY_LENGTH, GORILLA_SWING_MAX_LENGTH, thrown[1]) + step = reach[1] + thrown = list(reach[2], reach[3]) + // The layers. Seen from the side the near arm is over everything and the far one under its own body; facing away + // the thrown arm passes behind its own head; facing the viewer it comes out from behind its own shoulder + var/over = bearer.layer + 0.01 + var/under = bearer.layer - 0.01 + var/throw_layer + switch(rig.facing) + if(NORTH) + throw_layer = under + if(SOUTH) + throw_layer = over + else + throw_layer = rig.behind_body(side) ? under : max(bearer.layer, victim?.layer) + 0.01 + var/datum/chrome_swing_beat/throw_beat = new(GORILLA_HAYMAKER_OUT, CHROME_SWING_LINEAR, way[1] * step, way[2] * step) + throw_beat.arm(side, thrown, throw_layer) + if(!guard_still) + throw_beat.arm(guard, rig.pose_of(guard, poses[6][1], poses[6][2])) + // The fist is there a moment before the blow is due, and stays as it lands + var/datum/chrome_swing_beat/dwell_beat = new(GORILLA_HAYMAKER_DWELL, CHROME_SWING_LINEAR, way[1] * step, way[2] * step) + // The follow-through carries the fist on the way it was going, and the body half way back + var/follow_step = round(step * 0.4) + var/datum/chrome_swing_beat/follow_beat = new(GORILLA_HAYMAKER_FOLLOW, CHROME_SWING_EASE_OUT, way[1] * follow_step, way[2] * follow_step) + follow_beat.arm(side, list(thrown[1] + poses[7] * rig.raise_sign(side), max(1, 1 + poses[8] / (GLOB.chrome_rig_arm_length["[rig.facing]"] || 10)))) + follow_beat.arm(guard, list(0, 1)) + var/datum/chrome_swing_beat/return_beat = new(GORILLA_HAYMAKER_RETURN, CHROME_SWING_EASE_IN_OUT) + return_beat.arm(side, list(0, 1)) + return_beat.arm(guard, list(0, 1)) + if(rig.facing == NORTH) + // Out from behind the head once it is clear of it + return_beat.layer_once_under = list() + return_beat.layer_once_under[side] = list(120, over) + play_rig(list(throw_beat, dwell_beat, follow_beat, return_beat), leant[1], leant[2], settle = TRUE) + if(rig_timer) + deltimer(rig_timer) + rig_timer = addtimer(CALLBACK(src, PROC_REF(drop_rig)), GORILLA_HAYMAKER_OUT + GORILLA_HAYMAKER_DWELL + GORILLA_HAYMAKER_FOLLOW + GORILLA_HAYMAKER_RETURN, TIMER_STOPPABLE|TIMER_DELETE_ME) + return TRUE + +/// A wind-up that ended with nothing thrown: the arms come down, then the rig does. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/lower_rig() + if(isnull(rig) || QDELETED(rig.body)) + drop_rig() + return + var/list/leant = rig_leant() + var/datum/chrome_swing_beat/lower = new(GORILLA_HAYMAKER_LOWER, CHROME_SWING_EASE_IN_OUT) + for(var/arm_side in list("l", "r")) + lower.arm(arm_side, list(0, 1), rig.body.layer + (rig.behind_body(arm_side) ? -0.01 : 0.01)) + play_rig(list(lower), leant[1], leant[2], settle = TRUE) + if(rig_timer) + deltimer(rig_timer) + rig_timer = addtimer(CALLBACK(src, PROC_REF(drop_rig)), GORILLA_HAYMAKER_LOWER, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/// Takes the rig down and shows the real body. +/datum/action/cooldown/cyberware/gorilla_haymaker/proc/drop_rig() + if(rig_timer) + deltimer(rig_timer) + rig_timer = null + QDEL_NULL(rig) + +/// Who a haymaker at [target] hits: the clicked body if it is next to the bearer, else whoever stands in that tile. +/proc/gorilla_haymaker_victim(mob/living/bearer, atom/target) + if(isliving(target) && target != bearer && bearer.Adjacent(target)) + return target + var/turf/swing_at = isturf(target) ? target : get_turf(target) + if(isnull(swing_at) || get_dist(bearer, swing_at) != 1) + swing_at = get_step(bearer, get_dir(bearer, target) || bearer.dir) + if(isnull(swing_at) || !bearer.Adjacent(swing_at)) + return null + var/mob/living/lying + for(var/mob/living/body in swing_at) + if(body == bearer || body.stat == DEAD) + continue + if(body.body_position != LYING_DOWN) + return body + lying ||= body + return lying + +/// A haymaker lands on [victim]: [charge] 0 to 1 sets the damage and the reach. On [zone], else a part rolled from the one the bearer aims at. Only the blow: the swing is the caller's. +/proc/gorilla_haymaker_hit(mob/living/carbon/human/bearer, mob/living/victim, obj/item/organ/cyberimp/cyberware/gorilla_arms/arm, charge, zone) + var/obj/item/bodypart/hand = bearer.get_bodypart(arm.zone) + var/damage = round(GORILLA_HAYMAKER_MIN_DAMAGE + (GORILLA_HAYMAKER_MAX_DAMAGE - GORILLA_HAYMAKER_MIN_DAMAGE) * charge) + var/reach = charge >= 1 ? GORILLA_HAYMAKER_MAX_RANGE : GORILLA_HAYMAKER_MIN_RANGE + var/direction = get_dir(bearer, victim) || bearer.dir + if(ishuman(victim)) + var/mob/living/carbon/human/human_victim = victim + if(human_victim.check_block(bearer, damage, "[bearer]'s haymaker")) + playsound(victim, 'sound/items/weapons/punchmiss.ogg', 40, TRUE) + log_combat(bearer, victim, "attempted a haymaker on", "gorilla arms") + return FALSE + var/list/plan = gorilla_plan_knockback(victim, direction, reach) + var/flies = plan[2] > 0 && victim.body_position != LYING_DOWN && !victim.buckled && !victim.anchored + if(flies) + victim.hv_hold_attack_message("[bearer] drives a fist into [victim] and sends [victim.p_them()] flying!", "[bearer] drives a fist into you and sends you flying!", "You drive a fist into [victim] and send [victim.p_them()] flying!", bearer, vision_range = DEFAULT_MESSAGE_RANGE) + else + victim.hv_hold_attack_message("[bearer] drives a fist into [victim]!", "[bearer] drives a fist into you!", "You drive a fist into [victim]!", bearer, vision_range = DEFAULT_MESSAGE_RANGE) + zone ||= victim.get_random_valid_zone(bearer.zone_selected) + var/armour = victim.run_armor_check(zone, MELEE, armour_penetration = hand?.unarmed_effectiveness) + var/list/wounds_before + if(iscarbon(victim)) + var/mob/living/carbon/carbon_victim = victim + wounds_before = carbon_victim.gorilla_wound_snapshot() + if(flies) + // The flight leaves its own trail and the wall its own marks; no #509 fan on top of them + gorilla_hold_spray(victim) + var/dealt = victim.apply_damage(damage, BRUTE, zone, armour, wound_bonus = GORILLA_PUNCH_WOUND_BONUS + 5, attack_direction = direction, attacking_item = hand) + var/wounded = FALSE + if(iscarbon(victim) && !QDELETED(victim)) + var/mob/living/carbon/carbon_victim = victim + if(dealt >= GORILLA_STRAIN_MIN_DAMAGE) + gorilla_add_strain(carbon_victim, check_zone(zone), bearer, arm.snap_strain, hand, direction) + wounded = gorilla_new_wound(carbon_victim, wounds_before) + victim.hv_flush_hit() + gorilla_register_aggression(victim, bearer) + gorilla_haymaker_impact_sound(victim) + arm.gorilla_punch_fx(bearer, victim, TRUE, zone) + cyberware_flash_fx(victim, 0.2 SECONDS) + shake_camera(victim, 3, 2) + if(flies && !QDELETED(victim)) + gorilla_launch(victim, bearer, direction, reach, GORILLA_HAYMAKER_SPEED, FALSE, TRUE, wounded) + log_combat(bearer, victim, "landed a haymaker on", "gorilla arms", "(charge [round(charge * 100)]%)") + return TRUE + +/// A haymaker from [bearer] at [target] with whichever arm is ready, wound up for [hold_time], onto [zone] if one is given. For an AI. Returns TRUE if it began. +/proc/gorilla_try_haymaker(mob/living/carbon/human/bearer, atom/target, hold_time = GORILLA_HAYMAKER_FULL_CHARGE, zone) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in gorilla_heavy_arms(bearer)) + for(var/datum/action/cooldown/cyberware/gorilla_haymaker/haymaker in arm.actions) + if(haymaker.owner == bearer && haymaker.wind_up_at(target, hold_time, zone)) + return TRUE + return FALSE + +/// Starts the pistons' shared cooldown on [bearer] and shows it on every haymaker chip. +/proc/gorilla_spend_pistons(mob/living/bearer, time) + gorilla_cooldown(bearer, COOLDOWN_GORILLA_PISTONS, time) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in gorilla_heavy_arms(bearer)) + for(var/datum/action/cooldown/cyberware/gorilla_haymaker/haymaker in arm.actions) + haymaker.StartCooldownSelf(time) + +// ========================================================================= +// THE WIND-UP +// ========================================================================= + +/// The bearer winding up a haymaker: slowed, empty-handed of grabs, leaning back, trembling at full charge. +/datum/status_effect/gorilla_windup + id = "gorilla_windup" + alert_type = null + duration = GORILLA_HAYMAKER_VENT_AFTER + 1 SECONDS + tick_interval = 0.2 SECONDS + status_type = STATUS_EFFECT_UNIQUE + /// The haymaker winding up + var/datum/action/cooldown/cyberware/gorilla_haymaker/action + /// Trembling at full charge + var/trembling = FALSE + /// Which way the tremble's next pixel goes + var/tremble_side = 1 + +/datum/status_effect/gorilla_windup/on_creation(mob/living/new_owner, datum/action/cooldown/cyberware/gorilla_haymaker/action) + src.action = action + return ..() + +/datum/status_effect/gorilla_windup/on_apply() + if(owner.stat != CONSCIOUS) + return FALSE + owner.add_movespeed_modifier(/datum/movespeed_modifier/gorilla_windup) + if(owner.pulling) + owner.stop_pulling() + RegisterSignal(owner, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_change)) + RegisterSignal(owner, COMSIG_ATOM_POST_DIR_CHANGE, PROC_REF(on_turned)) + lean() + return TRUE + +/** + * Leans back from the way they face now, further as the charge builds, so the whole wind-up moves: away from the + * target seen from the side (a pixel at once, GORILLA_HAYMAKER_LEAN at full charge), half as far up the screen when + * they face the viewer and down it when they face away. A tracked offset tg eases to and removes cleanly. + */ +/datum/status_effect/gorilla_windup/proc/lean() + var/charged = action?.charging() ? clamp((world.time - action.charge_started) / GORILLA_HAYMAKER_FULL_CHARGE, 0, 1) : 0 + var/back_by = 1 + round(charged * (GORILLA_HAYMAKER_LEAN - 1)) + var/up_by = CEILING(back_by / 2, 1) + var/back = REVERSE_DIR(owner.dir) + var/dx = (back & EAST) ? back_by : ((back & WEST) ? -back_by : 0) + var/dz = (back & NORTH) ? up_by : ((back & SOUTH) ? -up_by : 0) + owner.add_offsets(id, x_add = dx, z_add = dz) + // Drawn on the rig, the puppets lean as the hidden body does + action?.rig_follow(TRUE) + +/// Turned mid wind-up: the lean turns with them. +/datum/status_effect/gorilla_windup/proc/on_turned(datum/source, old_dir, new_dir) + SIGNAL_HANDLER + if(old_dir != new_dir) + lean() + +/datum/status_effect/gorilla_windup/on_remove() + UnregisterSignal(owner, list(COMSIG_MOB_STATCHANGE, COMSIG_ATOM_POST_DIR_CHANGE)) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/gorilla_windup) + owner.remove_offsets("[id]_tremble", animate = FALSE) + owner.remove_offsets(id) + var/datum/action/cooldown/cyberware/gorilla_haymaker/haymaker = action + action = null + haymaker?.windup_lost() + +/datum/status_effect/gorilla_windup/Destroy() + action = null + return ..() + +/datum/status_effect/gorilla_windup/tick(seconds_between_ticks) + // Stunned, cuffed or knocked down mid wind-up: the swing is lost + if(HAS_TRAIT(owner, TRAIT_INCAPACITATED) || HAS_TRAIT(owner, TRAIT_HANDS_BLOCKED) || owner.body_position == LYING_DOWN) + qdel(src) + return + if(!action?.charging()) + return + lean() + if(world.time - action.charge_started < GORILLA_HAYMAKER_FULL_CHARGE) + return + // Full: a tremble for as long as it is held, a pixel either way. A tracked offset, so it can't leave them + // off their tile, and never the pixel of nothing tg's random jitter can roll + trembling = TRUE + tremble_side = -tremble_side + owner.add_offsets("[id]_tremble", w_add = tremble_side, animate = FALSE) + action.rig_follow(FALSE) + +/datum/status_effect/gorilla_windup/proc/on_stat_change(datum/source, new_stat, old_stat) + SIGNAL_HANDLER + if(new_stat != CONSCIOUS) + qdel(src) + +/datum/movespeed_modifier/gorilla_windup + multiplicative_slowdown = 1.5 diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_looks.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_looks.dm new file mode 100644 index 00000000000..af865681fbe --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_looks.dm @@ -0,0 +1,173 @@ +/** + * # Gorilla Arms looks + * + * Pictures on top of moves that already happened; nothing here changes a number. + * The arms always look like their worn sprite: no tint, glow or steam over them (owner). + * - The deploy flex: as the pair syncs, after an EMP reboot, or on the Arm chrome key when the Gorilla + * has nothing to deploy. A squat, the knuckles flash in turn, and it settles. + * - Snapped bones: a compound fracture on an arm, a leg or the chest shows bone through the skin and + * blood, whatever broke it. Drawn like #509's stumps (bone plus greyscale blood tinted to the body's + * blood), on its own overlay list beside them. + */ + +/// Whether this arm's worn plate is on show (no suit over the arms). +/obj/item/organ/cyberimp/cyberware/gorilla_arms/proc/plate_shows() + var/mob/living/carbon/human/bearer = owner + if(!ishuman(bearer)) + return FALSE + return !(bearer.wear_suit?.body_parts_covered & ARMS) + +// ========================================================================= +// THE DEPLOY FLEX +// ========================================================================= + +/// The flex, at most once per GORILLA_FLEX_COOLDOWN. Every step is relative and ends where it began. +/proc/gorilla_flex(mob/living/carbon/human/bearer) + if(!ishuman(bearer) || bearer.stat != CONSCIOUS || bearer.body_position == LYING_DOWN || !isturf(bearer.loc)) + return FALSE + var/list/arms = gorilla_heavy_arms(bearer) + if(!length(arms) || !TIMER_COOLDOWN_FINISHED(bearer, COOLDOWN_GORILLA_FLEX)) + return FALSE + gorilla_cooldown(bearer, COOLDOWN_GORILLA_FLEX, GORILLA_FLEX_COOLDOWN) + // The squat, about the feet, and back up + var/matrix/squat = matrix(1.05, 0, 0, 0, 0.93, -1) + var/matrix/rise = matrix(squat) + rise.Invert() + animate(bearer, transform = squat, time = 0.15 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + animate(transform = matrix(), time = 0.5 SECONDS, flags = ANIMATION_RELATIVE) + animate(transform = rise, time = 0.25 SECONDS, easing = SINE_EASING | EASE_IN | EASE_OUT, flags = ANIMATION_RELATIVE) + var/delay = 0.15 SECONDS + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in arms) + addtimer(CALLBACK(arm, TYPE_PROC_REF(/obj/item/organ/cyberimp/cyberware/gorilla_arms, flex_beat)), delay) + delay += 0.15 SECONDS + return TRUE + +/** + * Where each hand hangs on tg's human sprite, in pixels from the middle of the icon (x right, y up), by facing: + * arm zone -> list("[dir]" = list(x, y)). Measured on icons/mob/human/bodyparts_greyscale.dmi. Seen from the side + * the near hand hangs behind the middle and the far one shows in front of the belly. + */ +GLOBAL_LIST_INIT(gorilla_hand_points, list( + BODY_ZONE_L_ARM = list("[SOUTH]" = list(6, -4), "[NORTH]" = list(-7, -4), "[EAST]" = list(4, -4), "[WEST]" = list(2, -4)), + BODY_ZONE_R_ARM = list("[SOUTH]" = list(-7, -4), "[NORTH]" = list(6, -4), "[EAST]" = list(-2, -4), "[WEST]" = list(-4, -4)), +)) + +/// Where the hand of [bearer]'s arm on [arm_zone] is drawn for the way they face now: list(x, y) from the middle of the icon. +/proc/gorilla_hand_point(mob/living/bearer, arm_zone) + var/facing = bearer.dir + if(ISDIAGONALDIR(facing)) + facing = (facing & EAST) ? EAST : WEST + var/list/point = GLOB.gorilla_hand_points[arm_zone]?["[facing]"] + return point ? list(point[1], point[2]) : list(0, -4) + +/// One arm's part of the flex: the knuckles flashing. +/obj/item/organ/cyberimp/cyberware/gorilla_arms/proc/flex_beat() + if(!owner) + return + var/obj/effect/abstract/cyberware_anim/spark = cyberware_anim_play(owner, GORILLA_GORE_ICON, "impact_brawler", GORILLA_ANIM_TOP_LAYER, 0.4 SECONDS) + if(spark) + spark.appearance_flags |= RESET_TRANSFORM + // On this arm's own hand, wherever the facing puts it + var/list/hand = gorilla_hand_point(owner, zone) + spark.pixel_w = hand[1] + spark.pixel_z = hand[2] + spark.transform = matrix().Scale(0.5) + +// The pair comes back from an EMP: once it is back in sync, the arms flex. +/datum/component/cyberware/finish_emp_reboot() + var/was_down = emp_down + . = ..() + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = parent + if(!was_down || emp_down || !istype(arm) || !arm.heavy_moves || !arm.owner) + return + if(gorilla_synced(arm.owner)) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(gorilla_flex), arm.owner), 0.6 SECONDS) + +// The Arm chrome key with nothing to deploy but a synced pair of Gorilla Arms: they flex. +/datum/component/chrome_wheel/use_arms() + var/mob/living/carbon/bearer = parent + if((!arm_action || arm_action.owner != bearer) && gorilla_synced(bearer)) + gorilla_flex(bearer) + return TRUE + return ..() + +// ========================================================================= +// SNAPPED BONES +// ========================================================================= + +/mob/living/carbon + /// Snapped-bone images drawn on us now (hyperviolence_gorilla). + var/list/gorilla_snap_overlays + /// What gorilla_snap_overlays was built from. + var/gorilla_snap_key + +/mob/living/carbon/update_damage_overlays() + . = ..() + gorilla_update_snap_overlays() + +/mob/living/carbon/regenerate_icons() + gorilla_snap_key = null + return ..() + +/// The zones showing a snapped bone: an arm, a leg or the chest with a compound fracture (not the skull). +/mob/living/carbon/proc/gorilla_snapped_zones() + var/static/list/snap_zones = list(BODY_ZONE_CHEST, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) + . = list() + if(!ishuman(src)) + return + for(var/zone in snap_zones) + var/obj/item/bodypart/part = get_bodypart(zone) + if(isnull(part) || !part.hv_shows_gore()) + continue + for(var/datum/wound/blunt/bone/critical/fracture in part.wounds) + . += zone + break + +/// Rebuilds the snapped-bone overlays if what they show changed. +/mob/living/carbon/proc/gorilla_update_snap_overlays() + var/list/zones = gorilla_snapped_zones() + var/new_key + var/blood_color + if(length(zones)) + if(can_bleed()) + blood_color = get_bloodtype()?.get_damage_color(src) || BLOOD_COLOR_RED + var/height = HUMAN_HEIGHT_MEDIUM + if(ishuman(src)) + var/mob/living/carbon/human/as_human = src + height = as_human.mob_height + new_key = "[jointext(zones, ",")]|[islist(blood_color) ? jointext(blood_color, ",") : blood_color]|[height]" + if(new_key == gorilla_snap_key && (new_key || !gorilla_snap_overlays)) + return + gorilla_snap_key = new_key + if(gorilla_snap_overlays) + cut_overlay(gorilla_snap_overlays) + gorilla_snap_overlays = null + if(isnull(new_key)) + return + var/list/images = list() + for(var/zone in zones) + if(blood_color) + var/image/blood = image(GORILLA_GORE_ICON, "snap_[zone]_blood", -HV_STUMP_FRESH_LAYER) + blood.appearance_flags = RESET_COLOR + blood.color = blood_color + images += blood + images += image(GORILLA_GORE_ICON, "snap_[zone]_bone", -HV_STUMP_FRESH_LAYER) + if(ishuman(src)) + var/mob/living/carbon/human/as_human = src + if(as_human.mob_height != HUMAN_HEIGHT_MEDIUM) + for(var/image/snap_image as anything in images) + as_human.apply_height_filters(snap_image) + gorilla_snap_overlays = images + add_overlay(gorilla_snap_overlays) + +// A compound fracture comes and goes: the snapped bone with it. +/datum/wound/blunt/bone/critical/apply_wound(obj/item/bodypart/L, silent = FALSE, datum/wound/old_wound = null, smited = FALSE, attack_direction = null, wound_source = "Unknown", replacing = FALSE) + . = ..() + if(. && iscarbon(victim)) + victim.gorilla_update_snap_overlays() + +/datum/wound/blunt/bone/critical/remove_wound(ignore_limb, replaced) + var/mob/living/carbon/was_on = victim + . = ..() + if(iscarbon(was_on) && !QDELETED(was_on)) + was_on.gorilla_update_snap_overlays() diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_pound.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_pound.dm new file mode 100644 index 00000000000..be2e7cfe0c4 --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_pound.dm @@ -0,0 +1,245 @@ +/** + * # Ground pound + * + * A chrome wheel chip the synced pair grants. The bearer crouches for a beat, then drives both fists into + * the floor: a ring and cracks, dust, a shake for anyone close. Everyone on the tiles around the bearer, + * bar the bearer's own crew, staggers, is dazed (the next shove knocks them down) and loses some wind; it + * does no brute. Loose things on the floor nearby hop a tile outward. They are moved, never thrown, so a + * ring of knives never becomes a ring of thrown knives, and they never hop into a hazard or through glass. + * + * Brawler myomers' synced pair gets a lighter one (the /brawler chip): a shorter stagger, less wind, no daze, + * nothing hops, a smaller ring and one crack, on a longer clock. Same crouch, so it reads the same. + */ + +/datum/action/cooldown/cyberware/gorilla_pound + name = "Ground pound" + desc = "Drive both fists into the floor." + button_icon = GORILLA_GORE_ICON + button_icon_state = "chip_pound" + check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED | AB_CHECK_HANDS_BLOCKED | AB_CHECK_IMMOBILE | AB_CHECK_LYING + cooldown_time = GORILLA_POUND_COOLDOWN + /// The crouch before the slam + var/crouch_timer + /// The bearer's arm rig while the pound is drawn (chrome_puppet_rig.dm) + var/datum/chrome_rig/rig + /// The longest stagger it leaves + var/stagger = GORILLA_POUND_STAGGER + /// Daze on everyone it hits; 0 for none + var/daze = GORILLA_POUND_DAZE + /// Stamina it takes from everyone it hits + var/stamina = GORILLA_POUND_STAMINA + /// Whether loose things nearby hop outward, and the full crash, ring and cracks + var/full_pound = TRUE + +/// Brawler myomers' pound: a shove-off, no daze, nothing hops. +/datum/action/cooldown/cyberware/gorilla_pound/brawler + cooldown_time = BRAWLER_POUND_COOLDOWN + stagger = BRAWLER_POUND_STAGGER + daze = 0 + stamina = BRAWLER_POUND_STAMINA + full_pound = FALSE + +/// Whether the pair this chip belongs to is synced. +/datum/action/cooldown/cyberware/gorilla_pound/proc/pair_synced() + return gorilla_synced(owner) + +/datum/action/cooldown/cyberware/gorilla_pound/brawler/pair_synced() + return brawler_synced(owner) + +/datum/action/cooldown/cyberware/gorilla_pound/Destroy() + if(crouch_timer) + deltimer(crouch_timer) + crouch_timer = null + drop_rig() + return ..() + +/// Draws the bearer crouching with both arms up. Returns TRUE if the rig is up. +/datum/action/cooldown/cyberware/gorilla_pound/proc/raise_rig(mob/living/carbon/human/bearer) + drop_rig() + rig = new(bearer, bearer.dir) + if(!rig.rig_arms()) + QDEL_NULL(rig) + return FALSE + // Moved or knocked down: the drawing comes down at once (a deleted body takes its rig with it). The rig does the + // listening: this chip already hears the bearer lie down and be deleted, and a second listener here would + // replace those and then remove them with the rig. + rig.watch_body(CALLBACK(src, PROC_REF(drop_rig))) + // Arms first: a crouch runs alongside, and a swing started after it would cut it short + for(var/side in list("l", "r")) + rig.swing_arm(side, 150, GORILLA_POUND_CROUCH, 0, SINE_EASING) + rig.crouch(0.88, 2, GORILLA_POUND_CROUCH, SINE_EASING | EASE_OUT) + return TRUE + +/// Takes the rig down and shows the real body. +/datum/action/cooldown/cyberware/gorilla_pound/proc/drop_rig() + QDEL_NULL(rig) + +/datum/action/cooldown/cyberware/gorilla_pound/IsAvailable(feedback = FALSE) + . = ..() + if(!.) + return + if(!pair_synced() || !gorilla_may_use_heavy_moves(owner)) + if(feedback) + owner.balloon_alert(owner, "arms out of sync!") + return FALSE + if(HAS_TRAIT(owner, TRAIT_PACIFISM)) + return FALSE + if(!TIMER_COOLDOWN_FINISHED(owner, COOLDOWN_GORILLA_POUND)) + return FALSE + var/turf/floor = get_turf(owner) + if(!isfloorturf(floor) || !floor.has_gravity()) + if(feedback) + owner.balloon_alert(owner, "nothing to hit!") + return FALSE + return TRUE + +/datum/action/cooldown/cyberware/gorilla_pound/Activate(atom/target) + var/mob/living/carbon/human/bearer = owner + if(!ishuman(bearer) || crouch_timer) + return FALSE + StartCooldown() + gorilla_cooldown(bearer, COOLDOWN_GORILLA_POUND, cooldown_time) + // The crouch: down, both fists up. Without a rig (something huge worn) the body only dips. + if(!raise_rig(bearer)) + animate(bearer, pixel_z = -2, time = GORILLA_POUND_CROUCH, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + animate(pixel_z = 2, time = 0.1 SECONDS, flags = ANIMATION_RELATIVE) + crouch_timer = addtimer(CALLBACK(src, PROC_REF(slam), get_turf(bearer)), GORILLA_POUND_CROUCH, TIMER_STOPPABLE|TIMER_DELETE_ME) + return TRUE + +/// A ground pound from [bearer], as the chip would. For an AI. Returns TRUE if it began. +/proc/gorilla_try_pound(mob/living/carbon/human/bearer) + if(!iscarbon(bearer)) + return FALSE + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in bearer.organs) + for(var/datum/action/cooldown/cyberware/gorilla_pound/pound in arm.actions) + if(pound.owner == bearer) + return !!pound.Trigger() + return FALSE + +/// The fists hit the floor, if the bearer is still crouched where they began. +/datum/action/cooldown/cyberware/gorilla_pound/proc/slam(turf/where) + crouch_timer = null + var/mob/living/carbon/human/bearer = owner + if(!ishuman(bearer) || bearer.loc != where || bearer.stat != CONSCIOUS || HAS_TRAIT(bearer, TRAIT_INCAPACITATED) || HAS_TRAIT(bearer, TRAIT_HANDS_BLOCKED)) + drop_rig() + return + if(rig) + // Down hard, fists on the floor, then back up + for(var/side in list("l", "r")) + rig.swing_arm(side, 0, GORILLA_POUND_DRIVE, 3, NONE) + rig.crouch(0.72, 6, GORILLA_POUND_DRIVE, SINE_EASING | EASE_IN) + addtimer(CALLBACK(src, PROC_REF(rise)), GORILLA_POUND_DRIVE + 0.1 SECONDS, TIMER_DELETE_ME) + gorilla_ground_pound(bearer, where, stagger, daze, stamina, full_pound) + +/// The bearer stands back up after the pound. +/datum/action/cooldown/cyberware/gorilla_pound/proc/rise() + if(!rig) + return + for(var/side in list("l", "r")) + rig.swing_arm(side, 0, GORILLA_POUND_RISE, 0) + rig.crouch(1, 0, GORILLA_POUND_RISE, SINE_EASING | EASE_OUT) + addtimer(CALLBACK(src, PROC_REF(drop_rig)), GORILLA_POUND_RISE, TIMER_DELETE_ME) + +/** + * Both fists into the floor at [where]: the shock, the stagger and the hop. Returns the mobs it hit. + * [full] is the Gorilla's: the big crash and ring, the cracks round it, and loose things hopping. Without it + * (Brawler myomers) a smaller ring, one crack and nothing moved. + */ +/proc/gorilla_ground_pound(mob/living/carbon/human/bearer, turf/where, stagger = GORILLA_POUND_STAGGER, daze = GORILLA_POUND_DAZE, stamina = GORILLA_POUND_STAMINA, full = TRUE) + . = list() + cyberware_camo_drop(bearer, "ground pound") + // No attack ring from tg: it is drawn over everything on the tile, the bearer's head included, and the pound has + // its own ring, cracks and dust on the floor under him + bearer.do_attack_animation(where) + bearer.visible_message(span_danger("[bearer] drives both fists into the floor!"), span_danger("You drive both fists into the floor!"), vision_distance = DEFAULT_MESSAGE_RANGE) + playsound(where, 'sound/effects/meteorimpact.ogg', full ? 80 : 50, TRUE, full ? 8 : 2) + gorilla_pound_impact_fx(where, full ? 1.5 : 1, full) + cyberware_grey_dust(where) + for(var/mob/living/shaken in range(full ? 3 : 2, where)) + if(shaken.client && shaken != bearer) + shake_camera(shaken, 3, get_dist(shaken, where) <= 1 ? 2 : 1) + shake_camera(bearer, 2, 1) + for(var/mob/living/hit in orange(1, where)) + // Not through glass or a door edge, and never the bearer's own crew + if(hit == bearer || hit.stat == DEAD || !hit.Adjacent(bearer) || cyberware_is_ally(bearer, hit)) + continue + hit.adjust_staggered_up_to(STAGGERED_SLOWDOWN_LENGTH, stagger) + if(daze > 0) + hit.apply_status_effect(/datum/status_effect/dazed, daze) + hit.apply_damage(stamina, STAMINA) + gorilla_register_aggression(hit, bearer) + log_combat(bearer, hit, "ground-pounded", "gorilla arms") + . += hit + if(full) + gorilla_pound_scatter(where) + +/// The ring and the cracks under a ground pound: the Piledriver's cross, gone sooner. Without [cross], the centre crack only. +/proc/gorilla_pound_impact_fx(turf/where, reach, cross = TRUE) + if(isnull(where)) + return + // On the floor: a ring on the game plane is drawn over anyone standing further up the screen than the bearer + new /obj/effect/temp_visual/circle_wave/cyberware_slam/floor(where, reach) + new /obj/effect/temp_visual/cyberware_impact_cracks/gorilla_pound(where, "damaged1", cross ? 255 : 180) + if(!cross) + return + for(var/direction in GLOB.cardinals) + var/turf/next = get_step(where, direction) + if(next) + new /obj/effect/temp_visual/cyberware_impact_cracks/gorilla_pound(next, "damaged5", 140) + +/obj/effect/temp_visual/cyberware_impact_cracks/gorilla_pound + duration = 4 SECONDS + +/// Loose things on the floor near [where] hop a tile outward, never into a hazard, glass or a door. +/proc/gorilla_pound_scatter(turf/where) + var/moved = 0 + for(var/obj/item/loose in range(GORILLA_POUND_ITEM_REACH, where)) + if(moved >= 30) + return + if(loose.anchored || !isturf(loose.loc) || (loose.item_flags & ABSTRACT) || loose.invisibility) + continue + var/turf/here = loose.loc + if(locate(/obj/structure/table) in here) + continue + var/out = get_dir(where, here) || pick(GLOB.cardinals) + var/turf/next = get_step(here, out) + if(isnull(next) || isclosedturf(next) || !isfloorturf(next) || gorilla_throw_stops_short(here, next, out)) + continue + if(!loose.Move(next, out)) + continue + moved++ + animate(loose, pixel_z = 5, time = 0.08 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + animate(pixel_z = -5, time = 0.1 SECONDS, easing = SINE_EASING | EASE_IN, flags = ANIMATION_RELATIVE) + +// The set bonus grants the chip to the right arm of its pair, or whichever arm there is. + +/datum/status_effect/organ_set_bonus/cyberware_gorilla + /// The ground pound chip, while the pair is synced + var/datum/action/cooldown/cyberware/gorilla_pound/pound + +/datum/status_effect/organ_set_bonus/cyberware_gorilla/proc/grant_pound() + if(pound && !QDELETED(pound)) + return + var/list/arms = gorilla_pair_arms(owner, type) + if(!length(arms)) + return + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/carrier = arms[1] + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in arms) + if(arm.zone == BODY_ZONE_R_ARM) + carrier = arm + pound = carrier.add_item_action(pound_type) + if(carrier.owner) + pound.Grant(carrier.owner) + +/datum/status_effect/organ_set_bonus/cyberware_gorilla/proc/take_pound() + if(!pound) + return + var/datum/action/cooldown/cyberware/gorilla_pound/old = pound + pound = null + if(QDELETED(old)) + return + var/obj/item/organ/carrier = old.organ + if(istype(carrier)) + carrier.remove_item_action(old) + else + qdel(old) diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_pry.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_pry.dm new file mode 100644 index 00000000000..024f6f0ce23 --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_pry.dm @@ -0,0 +1,173 @@ +/** + * # Gorilla door pry + * + * The synced pair's bare-handed pry (Gorilla Arms, and slower from Brawler myomers) is tg's door_pryer (instant on an unpowered door, a slow pry on a + * powered one, refused through bolts, welds and seals), with two changes: + * - Trader outpost doors never give: the sanctuary airlocks and any door on an outpost's protected + * ground. Trying counts as aggression against the outpost. A combat-mode punch at one is refused the + * same way (ware_military_arms.dm on_punch()). + * - A powered pry strains: every half second the bearer trembles, the door shakes, the seam opens a + * little wider and throws sparks. The sparks are for show (gorilla_pry_sparks()): they heat nothing and set + * nothing alight. + */ +/datum/element/door_pryer/gorilla + +/datum/element/door_pryer/gorilla/on_attack(mob/living/attacker, atom/target, proximity_flag) + SIGNAL_HANDLER + if(proximity_flag && istype(target, /obj/machinery/door/airlock) && !attacker.combat_mode) + var/obj/machinery/door/airlock/airlock_target = target + if(airlock_target.density && gorilla_pry_refused(airlock_target)) + airlock_target.balloon_alert(attacker, "it won't budge!") + gorilla_pry_aggression(airlock_target, attacker) + attacker.log_message("tried to pry open [airlock_target] at a trader outpost, located at [loc_name(airlock_target)].", LOG_GAME) + return COMPONENT_CANCEL_ATTACK_CHAIN + // Browned out or EMP'd, the arms are only arms: an ordinary click on the door + if(airlock_target.density && iscarbon(attacker)) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in gorilla_synced_pair(attacker)) + if(!arm.gorilla_running()) + return NONE + return ..() + +/// Whether a trader outpost keeps this door shut against Gorilla Arms or Brawler myomers, pried or punched. +/proc/gorilla_pry_refused(obj/machinery/door/door) + return istype(door, /obj/machinery/door/airlock/outpost) || is_trader_outpost_protected(door) + +/// Trying to force a trader outpost's door counts against the one who tried. +/proc/gorilla_pry_aggression(obj/machinery/door/door, mob/living/offender) + var/obj/machinery/door/airlock/outpost/outpost_door = door + if(istype(outpost_door) && outpost_door.outpost) + outpost_door.outpost.register_aggression(offender) + return + var/obj/structure/overmap/trader_outpost/guarding = get_trader_outpost_for_turf(get_turf(door)) + guarding?.register_aggression(offender) + +/datum/element/door_pryer/gorilla/open_door(mob/living/attacker, obj/machinery/door/airlock/airlock_target) + // Unpowered or opened for them: nothing to strain against. + if(!airlock_target.hasPower() || airlock_target.allowed(attacker)) + return ..() + var/datum/gorilla_pry_strain/strain = new(attacker, airlock_target, pry_time) + . = ..() + qdel(strain) + +/// The strain of a powered pry, beat by beat, while the do_after runs. +/datum/gorilla_pry_strain + var/mob/living/carbon/bearer + var/obj/machinery/door/airlock/door + /// The seam opening over the door + var/obj/effect/abstract/gorilla_pry_seam/seam + /// Beats so far + var/beats = 0 + var/beat_timer + /// world.time the pry began + var/started + /// How long the pry takes + var/pry_time + +/datum/gorilla_pry_strain/New(mob/living/carbon/bearer, obj/machinery/door/airlock/door, pry_time = GORILLA_PRY_TIME) + . = ..() + src.bearer = bearer + src.door = door + src.pry_time = pry_time + started = world.time + seam = new(null) + seam.stepped = gorilla_door_seam_stepped(door) + seam.set_width(0) + door.vis_contents += seam + RegisterSignal(door, COMSIG_QDELETING, PROC_REF(on_deleted)) + RegisterSignal(door, COMSIG_AIRLOCK_OPEN, PROC_REF(on_opening)) + RegisterSignal(bearer, COMSIG_QDELETING, PROC_REF(on_deleted)) + // The first beat waits a tick. Every beat asks whether the pry is still going, and the pry's do_after only + // starts once this strain is made: asked here the answer was always no, and no beat ever ran. + beat_timer = addtimer(CALLBACK(src, PROC_REF(beat)), 1, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/datum/gorilla_pry_strain/Destroy() + if(beat_timer) + deltimer(beat_timer) + beat_timer = null + if(door) + UnregisterSignal(door, list(COMSIG_QDELETING, COMSIG_AIRLOCK_OPEN)) + door.vis_contents -= seam + if(bearer) + UnregisterSignal(bearer, COMSIG_QDELETING) + QDEL_NULL(seam) + bearer = null + door = null + return ..() + +/datum/gorilla_pry_strain/proc/on_deleted(datum/source) + SIGNAL_HANDLER + qdel(src) + +/// The door gives: from here the gap is the door's own, sliding open. The seam goes before the leaves move. +/datum/gorilla_pry_strain/proc/on_opening(datum/source) + SIGNAL_HANDLER + if(door && seam) + door.vis_contents -= seam + +/datum/gorilla_pry_strain/proc/beat() + beat_timer = null + if(QDELETED(bearer) || QDELETED(door) || !DOING_INTERACTION_WITH_TARGET(bearer, door)) + return + beats++ + // A tremble that is over before the next beat: a pixel each way, twice. tg's jitter runs on for more than two + // seconds, so the bearer would still be shaking long after the door had opened, and it can roll no movement at all. + var/side = pick(-1, 1) + animate(bearer, pixel_w = side, time = 0.1 SECONDS, loop = 2, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL) + animate(pixel_w = -side, time = 0.1 SECONDS, flags = ANIMATION_RELATIVE) + door.Shake(1, 0, 0.3 SECONDS) + seam.set_width((world.time - started) / max(pry_time, 1)) + gorilla_pry_sparks(2, TRUE, door) + beat_timer = addtimer(CALLBACK(src, PROC_REF(beat)), 0.5 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/** + * Sparks off a door being forced, thrown and spread as do_sparks() throws tg's. They look and sound like tg's sparks + * and do nothing else: tg's are hot (they light fuel gas, fuel pools and plasma floors, and heat what they touch), + * and a pry is not meant to set a room alight. + */ +/proc/gorilla_pry_sparks(number, cardinal_only, datum/source) + var/datum/effect_system/gorilla_pry_sparks/sparks = new + sparks.set_up(number, cardinal_only, source) + sparks.autocleanup = TRUE + sparks.start() + +/datum/effect_system/gorilla_pry_sparks + effect_type = /obj/effect/particle_effect/gorilla_pry_sparks + +/// A cold spark. Not a subtype of tg's sparks on purpose: a fuel pool lights when anything of that type enters it. +/obj/effect/particle_effect/gorilla_pry_sparks + name = "sparks" + icon_state = "sparks" + // The glow of tg's sparks. It is this effect's own and goes with it. + light_system = OVERLAY_LIGHT + light_range = 1.5 + light_power = 0.8 + light_color = LIGHT_COLOR_FIRE + +/obj/effect/particle_effect/gorilla_pry_sparks/Initialize(mapload) + . = ..() + flick(icon_state, src) + playsound(src, SFX_SPARKS, 100, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) + QDEL_IN(src, 2 SECONDS) + +/// The crack forced open down an airlock's middle seam: a dark gap with lit edges. +/obj/effect/abstract/gorilla_pry_seam + name = "seam" + icon = GORILLA_GORE_ICON + icon_state = "pry_seam_1" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + vis_flags = VIS_INHERIT_PLANE | VIS_INHERIT_ID + layer = ABOVE_OBJ_LAYER + /// The door's leaves meet on the stepped seam of tg's station airlocks, not a straight one + var/stepped = FALSE + +/// Widens the seam as the pry goes on: three steps, a third of the pry each. [progress] runs 0 to 1. +/obj/effect/abstract/gorilla_pry_seam/proc/set_width(progress) + icon_state = "pry_seam_[stepped ? "step_" : ""][clamp(1 + round(progress * 3), 1, 3)]" + +/** + * Whether [door]'s two leaves meet on the stepped seam tg's station airlock sprites share (public, command, + * maintenance and the rest of icons/obj/doors/airlocks/station), so the gap is drawn along it. Any other door + * gets the straight gap. + */ +/proc/gorilla_door_seam_stepped(obj/machinery/door/airlock/door) + return !!findtext("[door.icon]", "/airlocks/station/") diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_punch.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_punch.dm new file mode 100644 index 00000000000..4d7c1673a2e --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_punch.dm @@ -0,0 +1,501 @@ +/** + * # The Gorilla punch, through #509 + * + * The piston punch of Gorilla Arms and Brawler myomers (ware_military_arms.dm on_punch()) lands here: + * - The arm throws it: the fist draws back and drives out onto the part it hits (gorilla_thrust.dm), and the blow + * lands when the fist gets there, a tenth of a second after the click. What it hits was settled at the click. + * - The blow goes through #509 like any weapon: the punching hand is the attacking item and the blow + * has a direction, so aimed crits roll, blood sprays the way it went, and every wound line joins + * the attack line in one message. + * - Bone breakers: piston hits on one limb strain it. The third Gorilla hit inside the window (the + * fourth from Brawler myomers) snaps an arm or a leg, or caves in the ribs. Heavy armour on the limb, + * robotic limbs and the Atlas frame stop the snap, and the head never snaps. + * - The knockback rides the safe path (gorilla_throw.dm). A grabbed body is hurled, once per grab-move + * cooldown shared with the slam, so a held body can't be thrown into a wall over and over. + * - Grab and slam: with someone in an aggressive grab, a click on the floor under them, an open floor + * beside you or a table lifts them and brings them down (gorilla_slam.dm). Brawler myomers slam lighter, + * with a lower lift and a body-fall thud. A table click while grabbing slams instead of caving the table in. + * - Every Gorilla blow on a person counts as PvP aggression at a trader outpost: the punch cancels the + * attack chain before the outpost's own unarmed-attack listener ever hears it. + */ + +/obj/item/organ/cyberimp/cyberware/gorilla_arms + /// The hurl, the haymaker, the flex, and the Gorilla pair's pound and three finishers. The Brawler has none + /// of these; its pair has its own pound and the limb rip (cyberware_brawler, ware_line_models_a.dm). + var/heavy_moves = TRUE + /// Whether a grabbed body can be slammed onto the floor or a table. + var/grab_slam = TRUE + /// Brute a floor slam deals. + var/slam_floor_damage = GORILLA_SLAM_FLOOR_DAMAGE + /// Stamina a floor slam takes. + var/slam_floor_stamina = GORILLA_SLAM_FLOOR_STAMINA + /// Brute a table slam deals. + var/slam_table_damage = GORILLA_SLAM_TABLE_DAMAGE + /// Stamina a table slam takes. + var/slam_table_stamina = GORILLA_SLAM_TABLE_STAMINA + /// How long a slam floors them. + var/slam_knockdown = GORILLA_SLAM_KNOCKDOWN + /// Damage a table slam does to the table. + var/slam_table_break = GORILLA_SLAM_TABLE_BREAK + /// The bearer-wide wait after a slam or a hurl before the next one. + var/grab_move_cooldown = GORILLA_GRAB_MOVE_COOLDOWN + /// Whether a slammed body is pressed overhead first. Off: brought to the shoulder. + var/slam_overhead = TRUE + /// The Gorilla's floor slam: the meteor crash, the big ring and the cracks. Off: a body-fall thud, a small ring. + var/slam_full_fx = TRUE + /// What drives the fist, in the attack line. + var/fist_word = "piston-driven" + /// Strain on one limb that snaps it. + var/snap_strain = 3 + /// Wound bonus on the punch. + var/punch_wound_bonus = GORILLA_PUNCH_WOUND_BONUS + /// The sparks a landed punch throws (gorilla_gore.dmi). + var/impact_state = "impact_gorilla" + +/// Starts (or restarts) a bearer-wide cooldown, replacing any one already running under [index]. +/proc/gorilla_cooldown(mob/living/bearer, index, time) + var/old_timer = TIMER_COOLDOWN_RUNNING(bearer, index) + if(old_timer) + deltimer(old_timer) + TIMER_COOLDOWN_END(bearer, index) + S_TIMER_COOLDOWN_START(bearer, index, time) + +/// Counts a Gorilla blow on [victim] as PvP aggression at a trader outpost. +/proc/gorilla_register_aggression(mob/living/victim, mob/living/offender) + if(!isliving(victim) || !isliving(offender) || victim == offender) + return + GLOB.outpost_pvp_enforcement?.register_pvp_aggression(victim, offender) + +/// The bearer's installed Gorilla Arms of the real (heavy) kind, both sides. +/proc/gorilla_heavy_arms(mob/living/carbon/bearer) + RETURN_TYPE(/list) + . = list() + if(!iscarbon(bearer)) + return + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in bearer.organs) + if(arm.heavy_moves && arm.owner == bearer) + . += arm + +/// Whether [bearer] has both real Gorilla arms synced (the set bonus): the finishers and the ground pound. +/proc/gorilla_synced(mob/living/carbon/bearer) + var/datum/status_effect/organ_set_bonus/cyberware_gorilla/bonus = bearer?.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_gorilla) + return !!bonus?.bonus_active + +/// Whether [bearer] has both Brawler myomers synced: the Brawler pound, the forced door and the limb rip. +/proc/brawler_synced(mob/living/carbon/bearer) + var/datum/status_effect/organ_set_bonus/cyberware_gorilla/bonus = bearer?.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_brawler) + return !!bonus?.bonus_active + +/// [bearer]'s installed arms that sync into [bonus_type] (an arm's pair_bonus). +/proc/gorilla_pair_arms(mob/living/carbon/bearer, bonus_type) + RETURN_TYPE(/list) + . = list() + if(!iscarbon(bearer) || !bonus_type) + return + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in bearer.organs) + if(arm.pair_bonus == bonus_type && arm.owner == bearer) + . += arm + +/// The arms of [bearer]'s synced pair, Gorilla or Brawler; empty when neither is synced. +/proc/gorilla_synced_pair(mob/living/carbon/bearer) + RETURN_TYPE(/list) + if(gorilla_synced(bearer)) + return gorilla_pair_arms(bearer, /datum/status_effect/organ_set_bonus/cyberware_gorilla) + if(brawler_synced(bearer)) + return gorilla_pair_arms(bearer, /datum/status_effect/organ_set_bonus/cyberware_brawler) + return list() + +/** + * Who may use the Gorilla's heavy moves: the slam, the haymaker, the ground pound and the finishers. + * Players, and NPCs of boss rank, as with gun executions (hv_can_execute()). This is the one gate for all + * of them, so letting other NPCs use the moves later is a change here and nowhere else. + */ +/proc/gorilla_may_use_heavy_moves(mob/living/bearer) + return isliving(bearer) && bearer.hv_can_execute() + +/// Whether this arm's chrome is running (not EMP'd, browned out or failing). +/obj/item/organ/cyberimp/cyberware/gorilla_arms/proc/gorilla_running() + if(organ_flags & ORGAN_FAILING) + return FALSE + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + return !chrome || chrome.is_running() + +// ========================================================================= +// THE PISTON PUNCH +// ========================================================================= + +/** + * A piston punch on [living_target] that can no longer miss: the arm throws it (gorilla_thrust()), and it lands when + * the fist gets there (piston_land()). It lands on [aimed_zone] if one is given, else on a part rolled from the one + * [source] aims at, settled now so the fist goes to it. Returns TRUE. + */ +/obj/item/organ/cyberimp/cyberware/gorilla_arms/proc/piston_hit(mob/living/carbon/human/source, mob/living/living_target, obj/item/bodypart/active_hand, aimed_zone) + var/target_zone = aimed_zone || living_target.get_random_valid_zone(source.zone_selected) + // The arm and the lunge. No attack ring from tg: it is drawn over the middle of the target and rides it wherever + // it is knocked; the knuckle sparks (gorilla_punch_fx()) are this blow's mark, on the part it landed on + var/lands_in = gorilla_thrust(source, living_target, zone, target_zone) + addtimer(CALLBACK(src, PROC_REF(piston_land), source, living_target, active_hand, target_zone), lands_in) + return TRUE + +/** + * The fist of a piston punch arrives on [target_zone] of [living_target]: the damage through #509 as one line, strain, + * the knockback or the hurl, aggression, and the look. Returns the brute it dealt. + */ +/obj/item/organ/cyberimp/cyberware/gorilla_arms/proc/piston_land(mob/living/carbon/human/source, mob/living/living_target, obj/item/bodypart/active_hand, target_zone) + if(QDELETED(source) || QDELETED(living_target) || QDELETED(active_hand)) + return 0 + var/grabbed = living_target.pulledby == source && source.grab_state >= GRAB_AGGRESSIVE + var/standing = source.body_position != LYING_DOWN + var/hurl = heavy_moves && hurl_range > 0 && grabbed && standing && TIMER_COOLDOWN_FINISHED(source, COOLDOWN_GORILLA_GRAB_MOVE) + var/direction = get_dir(source, living_target) || source.dir + gorilla_punch_impact_sound(living_target) + var/armor_block = living_target.run_armor_check(target_zone, MELEE, armour_penetration = active_hand.unarmed_effectiveness) + if(hurl) + living_target.hv_hold_attack_message("[source] hurls [living_target] across the room!", "[source] hurls you across the room!", "You hurl [living_target] across the room!", source) + else + living_target.hv_hold_attack_message("[source] slams [living_target] with a [fist_word] fist!", "[source] slams you with a [fist_word] fist!", "You slam [living_target]!", source) + var/list/wounds_before + if(iscarbon(living_target)) + var/mob/living/carbon/carbon_before = living_target + wounds_before = carbon_before.gorilla_wound_snapshot() + var/dealt = living_target.apply_damage(punch_damage, BRUTE, target_zone, armor_block, wound_bonus = punch_wound_bonus, attack_direction = direction, attacking_item = active_hand) + var/wounded = FALSE + if(iscarbon(living_target) && !QDELETED(living_target)) + var/mob/living/carbon/carbon_target = living_target + if(dealt >= GORILLA_STRAIN_MIN_DAMAGE) + gorilla_add_strain(carbon_target, check_zone(target_zone), source, snap_strain, active_hand, direction) + wounded = gorilla_new_wound(carbon_target, wounds_before) + living_target.hv_flush_hit() + gorilla_register_aggression(living_target, source) + // Before the launch: a throw's first step is taken at once, and the sparks belong where the blow fell + gorilla_punch_fx(source, living_target, wounded, target_zone) + if(standing && !QDELETED(living_target)) + if(hurl) + gorilla_cooldown(source, COOLDOWN_GORILLA_GRAB_MOVE, grab_move_cooldown) + gorilla_launch(living_target, source, direction, hurl_range, 2, FALSE, FALSE, wounded) + else if(!grabbed) + gorilla_launch(living_target, source, direction, 1, rand(1, 4), TRUE, FALSE, wounded) + log_combat(source, living_target, hurl ? "piston-hurled" : "piston-punched", "gorilla arms") + return dealt + +/// Whether [victim] picked up a wound (or a worse one) since [before] (gorilla_wound_snapshot()). +/proc/gorilla_new_wound(mob/living/carbon/victim, list/before) + for(var/datum/wound/wound as anything in victim.all_wounds) + if(!(wound in before) || before[wound] < wound.severity) + return TRUE + return FALSE + +/** + * What a piston punch looks like: knuckle sparks on the part of the target it landed on ([zone]), and on a heavy + * hit a small ring. + */ +/obj/item/organ/cyberimp/cyberware/gorilla_arms/proc/gorilla_punch_fx(mob/living/carbon/human/source, mob/living/target, heavy = FALSE, zone) + gorilla_punch_sparks(source, target, impact_state, zone, gorilla_far_fist(source, src.zone)) + if(heavy) + gorilla_floor_ring(target, 0.4) + +/** + * A shockwave ring on the floor under [target], out to [reach]. On the floor plane, so it passes under whoever stands + * in it or beyond it up the screen. Laid where the body is drawn: one hit mid-stride is short of its turf, as the + * sparks are (gorilla_glide_lag()). + */ +/proc/gorilla_floor_ring(atom/movable/target, reach) + var/turf/spot = get_turf(target) + if(isnull(spot)) + return null + var/obj/effect/temp_visual/circle_wave/cyberware_slam/floor/ring = new(spot, reach) + var/list/lag = gorilla_glide_lag(target) + ring.pixel_w += round(lag[1]) + ring.pixel_z += round(lag[2]) + return ring + +/// The sound of a landed piston punch on [target]. The one place to swap it. +/proc/gorilla_punch_impact_sound(atom/target) + playsound(get_turf(target), GORILLA_PUNCH_SOUND, 55, TRUE, -1) + +/// The landed piston punch: one of three at random. +/datum/sound_effect/gorilla_piston_punch + key = GORILLA_PUNCH_SOUND + file_paths = list( + 'voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch.ogg', + 'voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch2.ogg', + 'voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch3.ogg', + ) + +/// The sound of a landed haymaker on [target]. The one place to swap it. +/proc/gorilla_haymaker_impact_sound(atom/target) + playsound(target, GORILLA_HAYMAKER_SOUND, 70, TRUE) + +/// The sound of a back breaking across a Gorilla's knee on [target]. The one place to swap it. +/proc/gorilla_backbreaker_sound(atom/target) + playsound(target, GORILLA_BACKBREAKER_SOUND, 70, TRUE) + +/** + * Knuckle sparks over [target]: a short one-shot drawn upright and turned to come from the + * attacker's side, like cyberware_play_impact() but from this module's sheet. + */ +/proc/gorilla_play_impact(atom/movable/attacker, atom/movable/target, impact_state) + if(!impact_state || !ismovable(target)) + return null + var/obj/effect/abstract/cyberware_anim/impact = cyberware_anim_play(target, GORILLA_GORE_ICON, impact_state, GORILLA_ANIM_TOP_LAYER, 0.4 SECONDS, glow = impact_state == "impact_gorilla") + if(!impact) + return null + impact.appearance_flags |= RESET_TRANSFORM + var/direction = get_dir(attacker, target) + if((direction & WEST) || (!(direction & EAST) && prob(50))) + impact.transform = matrix(-1, 0, 0, 0, 1, 0) + return impact + +/** + * Where each body zone sits on tg's human sprite, in pixels from the middle of the icon (x right, y up), by the way + * the body faces: zone -> list("[dir]" = list(x, y)). Measured on icons/mob/human/bodyparts_greyscale.dmi. Left and + * right swap sides on screen as the body turns, and the far arm of a body seen from the side is behind its chest. + */ +GLOBAL_LIST_INIT(gorilla_zone_points, list( + BODY_ZONE_HEAD = list("[SOUTH]" = list(0, 9), "[NORTH]" = list(0, 9), "[EAST]" = list(1, 9), "[WEST]" = list(-1, 9)), + BODY_ZONE_CHEST = list("[SOUTH]" = list(0, 2), "[NORTH]" = list(0, 2), "[EAST]" = list(0, 2), "[WEST]" = list(0, 2)), + BODY_ZONE_L_ARM = list("[SOUTH]" = list(6, 0), "[NORTH]" = list(-7, 0), "[EAST]" = list(0, 0), "[WEST]" = list(3, 0)), + BODY_ZONE_R_ARM = list("[SOUTH]" = list(-7, 0), "[NORTH]" = list(6, 0), "[EAST]" = list(-3, 0), "[WEST]" = list(0, 0)), + BODY_ZONE_L_LEG = list("[SOUTH]" = list(3, -10), "[NORTH]" = list(-4, -10), "[EAST]" = list(1, -10), "[WEST]" = list(0, -10)), + BODY_ZONE_R_LEG = list("[SOUTH]" = list(-4, -10), "[NORTH]" = list(3, -10), "[EAST]" = list(0, -10), "[WEST]" = list(-1, -10)), +)) + +/** + * Where [zone] of [target] is drawn right now, in pixels from the middle of its icon: list(x, y). The part's place for + * the way the body faces, turned with the body when it lies. The middle of the icon for anything that isn't a human. + */ +/proc/gorilla_zone_point(atom/movable/target, zone) + var/mob/living/carbon/human/body = target + if(!ishuman(body) || !zone) + return list(0, 0) + var/facing = body.dir + if(ISDIAGONALDIR(facing)) + facing = (facing & EAST) ? EAST : WEST + var/list/point = GLOB.gorilla_zone_points[check_zone(zone)]?["[facing]"] + if(!point) + return list(0, 0) + return chrome_rig_apply(body.transform, point[1], point[2]) + +/** + * How far short of its tile [target] is still drawn while its last step glides: list(x, y), pixels from the middle + * of its turf. A client eases each step over the time the step takes, so a body hit mid-stride is drawn behind the + * turf it already stands on, and a mark left on the turf would miss it. Worked out from when its next step is due: + * a player's move delay, or an AI's move loop. Nothing when neither says (a body standing still, or dragged). + */ +/proc/gorilla_glide_lag(atom/movable/target) + . = list(0, 0) + if(!ismovable(target) || !target.last_move || !isturf(target.loc)) + return + var/due_in = 0 + var/mob/as_mob = target + if(ismob(as_mob) && as_mob.client) + due_in = as_mob.client.move_delay - world.time + else if(target.move_packet?.running_loop) + due_in = target.move_packet.running_loop.timer - world.time + if(due_in <= 0) + return + var/short_by = target.glide_size * due_in / world.tick_lag + // Longer than a step's glide: something else is holding its next move, and it has long since arrived + if(short_by > ICON_SIZE_ALL) + return + var/came_from = REVERSE_DIR(target.last_move) + .[1] = (came_from & EAST) ? short_by : ((came_from & WEST) ? -short_by : 0) + .[2] = (came_from & NORTH) ? short_by : ((came_from & SOUTH) ? -short_by : 0) + +/// Knuckle sparks where a piston punch landed (gorilla_gore.dmi). They stay where the blow fell. +/obj/effect/temp_visual/gorilla_punch_sparks + name = "sparks" + icon = GORILLA_GORE_ICON + icon_state = "impact_gorilla" + plane = GAME_PLANE + layer = ABOVE_MOB_LAYER + appearance_flags = PIXEL_SCALE | TILE_BOUND | LONG_GLIDE + randomdir = FALSE + duration = 0.4 SECONDS + +/obj/effect/temp_visual/gorilla_punch_sparks/Initialize(mapload, state, glow = FALSE) + if(state) + icon_state = state + . = ..() + if(glow) + add_overlay(emissive_appearance(icon, icon_state, src)) + +/// Whether the fist of [bearer]'s arm on [arm_zone] is the far one for the way they face: seen from the side, the arm behind their own body. +/proc/gorilla_far_fist(mob/living/bearer, arm_zone) + return ((bearer.dir & EAST) && arm_zone == BODY_ZONE_L_ARM) || ((bearer.dir & WEST) && arm_zone == BODY_ZONE_R_ARM) + +/** + * Knuckle sparks where a piston punch from [attacker] lands on [target]: on the part that was hit ([zone], else the + * middle of the body), for the way the body faces and lies, where the body is drawn (mid-stride it is short of its + * turf). They are left where the blow fell, so a body knocked away doesn't carry them off. They are drawn where the + * fist is: over the body, but + * - thrown from beyond a standing body (the attacker further from the viewer), or by the far fist of an attacker beside + * it ([behind]), they are behind that body and show round it; + * - thrown from nearer the viewer, they are in front of the body with the fist, and so under the attacker's own body, + * which that fist passes behind. + */ +/proc/gorilla_punch_sparks(atom/movable/attacker, atom/movable/target, impact_state, zone, behind = FALSE) + var/turf/spot = get_turf(target) + if(!impact_state || isnull(spot) || !ismovable(target)) + return null + var/list/point = gorilla_zone_point(target, zone) + var/direction = get_dir(attacker, target) + // From nearer the viewer: on the attacker's own screen row (rows sort before layers), reaching a tile up it + var/turf/from = get_turf(attacker) + var/from_below = (direction & NORTH) && ismob(attacker) && from && from.z == spot.z + var/turf/row = from_below ? from : spot + var/obj/effect/temp_visual/gorilla_punch_sparks/sparks = new(row, impact_state, impact_state == "impact_gorilla") + // On the side of the part the fist came in on + var/near_side = (direction & EAST) ? -2 : ((direction & WEST) ? 2 : 0) + // On the body's own screen row (pixel_y sorts before layer), then moved over the part without leaving it + sparks.pixel_x = target.pixel_x + sparks.pixel_y = from_below ? attacker.pixel_y : target.pixel_y + // ...and back along its last step if it was hit mid-stride, to where it is drawn + var/list/lag = gorilla_glide_lag(target) + sparks.pixel_w = target.pixel_w + round(point[1] + lag[1]) + near_side + (spot.x - row.x) * ICON_SIZE_X + sparks.pixel_z = target.pixel_z + round(point[2] + lag[2]) + (spot.y - row.y) * ICON_SIZE_Y + (target.pixel_y - sparks.pixel_y) + var/mob/living/struck = target + var/standing = !isliving(struck) || struck.body_position != LYING_DOWN + if(from_below) + sparks.plane = attacker.plane + sparks.layer = attacker.layer - 0.005 + else + sparks.plane = target.plane + sparks.layer = target.layer + 0.02 + if(standing && (direction & SOUTH)) + sparks.layer = target.layer - 0.02 + else if(standing && behind && (direction & (EAST|WEST))) + // Behind the body, and still in front of the far arm that threw it (a hair under its own body) + sparks.layer = target.layer - 0.005 + if((direction & WEST) || (!(direction & EAST) && prob(50))) + sparks.transform = matrix(-1, 0, 0, 0, 1, 0) + return sparks + +// ========================================================================= +// BONE BREAKERS +// ========================================================================= + +/** + * Strain on a body from piston hits: how many hard hits each limb has taken, and when the last one + * landed. A limb that goes [GORILLA_STRAIN_MEMORY] without a hit forgets its count. Expires on its own. + */ +/datum/status_effect/gorilla_strain + id = "gorilla_strain" + alert_type = null + duration = GORILLA_STRAIN_MEMORY + tick_interval = STATUS_EFFECT_NO_TICK + status_type = STATUS_EFFECT_REFRESH + /// Body zone -> hard hits counted + var/list/counts = list() + /// Body zone -> world.time of its last hard hit + var/list/last_hit = list() + +/// Counts one more hard hit on [zone]. Returns the count. +/datum/status_effect/gorilla_strain/proc/add(zone) + if(world.time - (last_hit[zone] || -INFINITY) > GORILLA_STRAIN_MEMORY) + counts[zone] = 0 + counts[zone] = (counts[zone] || 0) + 1 + last_hit[zone] = world.time + return counts[zone] + +/// Forgets [zone]'s count after it snapped. +/datum/status_effect/gorilla_strain/proc/clear(zone) + counts -= zone + last_hit -= zone + +/// A hard piston hit on [zone]: strains it, and snaps it when it has taken [snap_at] in the window. +/proc/gorilla_add_strain(mob/living/carbon/victim, zone, mob/living/attacker, snap_at, obj/item/source_item, direction) + if(zone == BODY_ZONE_HEAD) + return FALSE + var/datum/status_effect/gorilla_strain/strain = victim.has_status_effect(/datum/status_effect/gorilla_strain) + if(strain) + strain.refresh() + else + strain = victim.apply_status_effect(/datum/status_effect/gorilla_strain) + if(!strain) + return FALSE + if(strain.add(zone) < snap_at) + return FALSE + strain.clear(zone) + return gorilla_snap_limb(victim, victim.get_bodypart(zone), attacker, direction, source_item) + +/** + * Snaps [limb]: tg's compound fracture forced on an arm or a leg, or the ribs caved in on the chest. + * Heavy armour on the limb, a limb without bone (robotic) and the Atlas frame stop it. Returns TRUE + * if it snapped. + */ +/proc/gorilla_snap_limb(mob/living/carbon/victim, obj/item/bodypart/limb, mob/living/attacker, direction, obj/item/source_item) + if(isnull(limb) || limb.owner != victim || limb.body_zone == BODY_ZONE_HEAD) + return FALSE + if(hv_crit_cover_rating(victim, limb, MELEE) >= GORILLA_SNAP_ARMOUR) + return FALSE + if(!hv_crit_apply_wound(limb, /datum/wound/blunt/bone/critical, direction, source_item)) + return FALSE + if(limb.body_zone == BODY_ZONE_CHEST) + victim.hv_add_hit_line("[victim]'s ribs cave in!", HV_LINE_HUGE, "Your ribs cave in!", DEFAULT_MESSAGE_RANGE) + else + victim.hv_add_hit_line("The bone in [victim]'s [limb.plaintext_zone] snaps!", HV_LINE_HUGE, "The bone in your [limb.plaintext_zone] snaps!", DEFAULT_MESSAGE_RANGE) + playsound(victim, 'sound/effects/wounds/crack2.ogg', 80, TRUE, falloff_exponent = SOUND_FALLOFF_EXPONENT + 2, ignore_walls = FALSE, falloff_distance = 0) + cyberware_flash_fx(victim, 0.2 SECONDS) + gorilla_floor_ring(victim, 0.5) + log_combat(attacker, victim, "snapped the [limb.plaintext_zone] of", source_item, "(gorilla arms)") + return TRUE + +// ========================================================================= +// GRAB AND SLAM +// ========================================================================= + +/** + * With someone in an aggressive grab, a click on the floor under them, an open floor beside the bearer + * or a table starts the slam that brings them down onto it (gorilla_slam.dm). Returns GORILLA_SLAM_*. + */ +/obj/item/organ/cyberimp/cyberware/gorilla_arms/proc/try_slam(mob/living/carbon/human/source, atom/target, obj/item/bodypart/active_hand) + var/mob/living/victim = source.pulling + if(!isliving(victim) || source.grab_state < GRAB_AGGRESSIVE || victim == source) + return GORILLA_SLAM_NO + var/obj/structure/table/table = istype(target, /obj/structure/table) ? target : null + if(!table && !isturf(target)) + return GORILLA_SLAM_NO + if(!grab_slam || !gorilla_running() || !gorilla_may_use_heavy_moves(source) || HAS_TRAIT(source, TRAIT_PACIFISM) || victim.buckled || source.body_position == LYING_DOWN) + return table ? GORILLA_SLAM_PASS : GORILLA_SLAM_NO + if(!TIMER_COOLDOWN_FINISHED(source, COOLDOWN_GORILLA_GRAB_MOVE)) + return table ? GORILLA_SLAM_PASS : GORILLA_SLAM_NO + var/turf/spot = table ? get_turf(table) : target + if(!source.Adjacent(spot)) + return GORILLA_SLAM_NO + if(!table && !gorilla_slam_floor_ok(spot)) + return GORILLA_SLAM_NO + var/datum/gorilla_slam/slam = new(source, victim, spot, table, src, active_hand) + if(!slam.start()) + qdel(slam) + return table ? GORILLA_SLAM_PASS : GORILLA_SLAM_NO + gorilla_cooldown(source, COOLDOWN_GORILLA_GRAB_MOVE, grab_move_cooldown) + source.changeNext_move(CLICK_CD_MELEE) + return GORILLA_SLAM_DONE + +/** + * Slams whoever [bearer] holds in an aggressive grab onto [onto] (their own tile, an open floor beside the + * bearer, or a table) with the active arm, as a click there would. Returns TRUE if it slammed. For an AI. + * Brawler arms slam too; gorilla_may_use_heavy_moves() still keeps it to players and boss-rank NPCs. + */ +/proc/gorilla_try_slam(mob/living/carbon/human/bearer, atom/onto) + var/obj/item/bodypart/hand = bearer?.get_active_hand() + if(!iscarbon(bearer)) + return FALSE + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in bearer.organs) + if(arm.owner != bearer || !arm.grab_slam || arm.zone != hand?.body_zone || !arm.gorilla_running() || !COOLDOWN_FINISHED(arm, slam_cooldown)) + continue + if(arm.try_slam(bearer, onto, hand) != GORILLA_SLAM_DONE) + return FALSE + COOLDOWN_START(arm, slam_cooldown, arm.punch_cooldown_time) + return TRUE + return FALSE + +/// Whether a body can be slammed down on [spot]: solid floor with gravity and nothing standing in the way. +/proc/gorilla_slam_floor_ok(turf/spot) + if(!isfloorturf(spot) || isgroundlessturf(spot) || !spot.has_gravity()) + return FALSE + for(var/obj/thing in spot) + if(thing.density && !(thing.flags_1 & ON_BORDER_1)) + return FALSE + return TRUE diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_slam.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_slam.dm new file mode 100644 index 00000000000..6abe224fd6d --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_slam.dm @@ -0,0 +1,1054 @@ +/** + * # The grab-slam + * + * With someone in an aggressive grab, a click on the floor under them, an open floor beside the bearer or a table + * presses them up and drives them down onto it (gorilla_arms/proc/try_slam(), gorilla_punch.dm). The lift is drawn + * with the puppet rig (chrome_puppet_rig.dm), so neither real body is moved or turned by it. + * + * - Grip: he leans in and both fists take the body, by belt and collar seen from the side. + * - Hoist: up and over, turning flat. Gorilla Arms press it overhead; Brawler myomers bring it to the shoulder. + * - Top: one held beat. A body taken from behind or beside him is turned to the table or tile here. + * - Slam: driven down with his fists still on it. Seen from the side he bends at the belt; from the front or back he + * drops and lunges. + * - Impact: the damage, the knockdown and the grab letting go all land here, and the real body is put on the tile. + * A ring, and on a floor cracks (and dust and the heavy crash, for Gorilla Arms); both cameras shake and the body + * flashes white. Blood only if the blow made them bleed (a wound through the skin, or tg's cracked ribs bleeding + * inside), as a few drops thrown out round the body. + * - Rebound: the body bounces once and he comes up, hands off. The puppets go once both are still, with the real body + * lying in the same pixels. + * + * Until the impact nothing has happened to anyone. The bearer can't step, the grab is held, and the slam is called off + * if he is stunned or knocked down, loses the grab, or either of them is moved: the body comes down on its feet, unhurt. + * + * The poses are keys (the grip, the top, the impact, the rebound) played as short straight steps. While his fists are on + * the body they are solved onto it at every step, so they never leave it. Every puppet stands on the bearer's tile and is + * moved by its transform alone, which keeps its place in the draw order: the client sorts by row before layer, so a puppet + * that must draw over a table or a ring on the row nearer the viewer is put on that row. + */ + +/mob/living + /// The grab-slam this mob is doing or is held in, if any (gorilla_slam.dm). Cleared when it ends. + var/datum/gorilla_slam/gorilla_slam + +// What an arm does in a key pose. +/// On the body: list(kind, x, y) in the body's own pixels, from the middle of its picture. +#define SLAM_ARM_GRIP 1 +/// On the body, at a point of the scene: list(kind, x, y) pixels from where the bearer stands. +#define SLAM_ARM_POINT 2 +/// On the body, wherever a swing puts the hand: list(kind, angle, reach) as swing_arm() takes them. +#define SLAM_ARM_HELD 3 +/// Off the body: list(kind, angle, reach). +#define SLAM_ARM_SWING 4 + +// How a key pose is eased into. +#define SLAM_EASE_LINEAR 0 +#define SLAM_EASE_OUT 1 +#define SLAM_EASE_IN 2 +#define SLAM_EASE_SINE 3 + +/// Where the belt sits, from the middle of the picture: seen from the side the bearer bends about it. +#define SLAM_WAIST_Y -7 + +/// [progress] (0 to 1) eased as [kind] (SLAM_EASE_*). +/proc/gorilla_slam_ease(kind, progress) + progress = clamp(progress, 0, 1) + switch(kind) + if(SLAM_EASE_OUT) + return 1 - (1 - progress) ** 2 + if(SLAM_EASE_IN) + return progress ** 2 + if(SLAM_EASE_SINE) + return (1 - cos(180 * progress)) / 2 + return progress + +/// One key pose of the bearer. +/datum/gorilla_slam_pose + /// Deciseconds from the click + var/time = 0 + /// The facing of the rig that shows it + var/facing + /// How the move eases into it from the pose before (SLAM_EASE_*) + var/ease = SLAM_EASE_LINEAR + /// Pixels the whole bearer is moved + var/shift_x = 0 + var/shift_y = 0 + /// Degrees he leans forward from the feet, seen from the side + var/lean = 0 + /// Degrees he bends forward at the belt, seen from the side + var/waist = 0 + /// The crouch seen from the front or back: his height as a share, and pixels dropped + var/squash = 1 + var/drop = 0 + /// Side -> list(SLAM_ARM_*, a, b) + var/list/arms + /// Side -> list(x, y): where the fist is on the body, in the body's own pixels. No entry for an arm that is off it. + var/list/grips = list() + /// Side -> list(turn, length): the arm as it is in this pose + var/list/reached = list() + +/datum/gorilla_slam_pose/New(time, facing, ease = SLAM_EASE_LINEAR) + src.time = time + src.facing = facing + src.ease = ease + +/// One grab-slam, from the click to the puppets coming down. +/datum/gorilla_slam + /// Who slams + var/mob/living/carbon/human/bearer + /// Who is slammed + var/mob/living/victim + /// The arm that does it, and its hand: the attacking item + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm + var/obj/item/bodypart/fist + /// The tile the body is brought down on, and the table there if it is slammed onto one + var/turf/spot + var/datum/weakref/table_ref + /// Where the two stood at the click + var/turf/bearer_spot + var/turf/victim_spot + /// The way the bearer faces to take the body, and the way he faces to bring it down + var/taking + var/facing + /// The zone he aimed at the click + var/aimed_zone + /// TRUE for a head-aimed table slam: the body lands face down + var/face_down = FALSE + /// world.time at the click + var/started_at = 0 + /// TRUE once the impact has landed + var/landed = FALSE + /// TRUE once it is over, or called off + var/ended = FALSE + /// TRUE while the slam itself lets go of the grab and moves the body + var/placing = FALSE + /// FALSE when a body couldn't be rigged: the slam happens without the poses + var/posed = FALSE + // The beats, in deciseconds from the click + var/t_grip = GORILLA_SLAM_GRIP_TIME + var/t_top + var/t_drive + var/t_hit + var/t_mid + var/t_up + var/t_end + // The body's middle, in pixels from where the bearer is drawn, and its turn (degrees clockwise): held at the click, + // at the top, and where it lands + var/held_x = 0 + var/held_y = 0 + var/held_angle = 0 + var/top_x = 0 + var/top_y = 0 + var/top_angle = 0 + var/land_x = 0 + var/land_y = 0 + var/land_angle = 0 + /// The middle of the tile it lands on + var/tile_x = 0 + var/tile_y = 0 + /// Where the bearer is drawn on his own tile: every puppet stands there + var/origin_x = 0 + var/origin_y = 0 + /// Where the real body lies after the impact: the puppet settles there + var/final_x = 0 + var/final_y = 0 + var/final_angle = 0 + /// Facing ("[dir]") -> the bearer's rig in that facing + var/list/rigs + /// The body's puppets, one for each of the bearer's rigs ("body_[dir]") + var/datum/chrome_rig/victim_rig + /// The key poses, in order (/datum/gorilla_slam_pose) + var/list/keys + var/hit_timer + var/end_timer + +/datum/gorilla_slam/New(mob/living/carbon/human/bearer, mob/living/victim, turf/spot, obj/structure/table/table, obj/item/organ/cyberimp/cyberware/gorilla_arms/arm, obj/item/bodypart/fist) + . = ..() + src.bearer = bearer + src.victim = victim + src.spot = spot + src.arm = arm + src.fist = fist + if(table) + table_ref = WEAKREF(table) + +/datum/gorilla_slam/Destroy() + ended = TRUE + if(hit_timer) + deltimer(hit_timer) + hit_timer = null + if(end_timer) + deltimer(end_timer) + end_timer = null + take_down() + if(bearer) + stop_listening() + REMOVE_TRAIT(bearer, TRAIT_IMMOBILIZED, GORILLA_SLAM_TRAIT) + if(bearer.gorilla_slam == src) + bearer.gorilla_slam = null + if(victim?.gorilla_slam == src) + victim.gorilla_slam = null + bearer = null + victim = null + arm = null + fist = null + spot = null + bearer_spot = null + victim_spot = null + keys = null + return ..() + +/// Takes every puppet down and shows both bodies. +/datum/gorilla_slam/proc/take_down() + QDEL_NULL(victim_rig) + if(rigs) + QDEL_LIST_ASSOC_VAL(rigs) + rigs = null + +/// The facing toward [target] from where the bearer stands, as face_atom() picks it. Null for his own tile. +/datum/gorilla_slam/proc/toward(turf/target) + var/dx = target.x - bearer_spot.x + var/dy = target.y - bearer_spot.y + if(!dx && !dy) + return null + if(abs(dx) < abs(dy)) + return dy > 0 ? NORTH : SOUTH + return dx > 0 ? EAST : WEST + +/** + * Starts the slam: the rigs go up, the bearer is held where he stands and the impact is set for t_hit. Returns FALSE if + * it can't start; nothing has changed then. + */ +/datum/gorilla_slam/proc/start() + if(QDELETED(bearer) || QDELETED(victim) || QDELETED(arm) || bearer.gorilla_slam || victim.gorilla_slam) + return FALSE + bearer_spot = bearer.loc + victim_spot = victim.loc + if(!isturf(bearer_spot) || !isturf(victim_spot) || !isturf(spot)) + return FALSE + // A body on its feet can't be put down where he stands himself + if(spot == bearer_spot && victim.density) + return FALSE + for(var/mob/living/in_the_way in spot) + if(in_the_way != victim && in_the_way != bearer && in_the_way.density) + return FALSE + bearer.gorilla_slam = src + victim.gorilla_slam = src + started_at = world.time + aimed_zone = check_zone(bearer.zone_selected) + face_down = !isnull(table_ref) && aimed_zone == BODY_ZONE_HEAD + var/now_facing = (bearer.dir in GLOB.cardinals) ? bearer.dir : ((bearer.dir & (EAST|WEST)) || SOUTH) + taking = toward(victim_spot) || now_facing + facing = toward(spot) || taking + bearer.setDir(taking) + t_top = t_grip + (arm.slam_overhead ? GORILLA_SLAM_HOIST_TIME : BRAWLER_SLAM_HOIST_TIME) + t_drive = t_top + GORILLA_SLAM_TOP_TIME + t_hit = t_drive + GORILLA_SLAM_DRIVE_TIME + t_mid = t_hit + GORILLA_SLAM_REBOUND_TIME / 2 + t_up = t_hit + GORILLA_SLAM_RISE_TIME + t_end = t_hit + GORILLA_SLAM_SETTLE_TIME + measure() + posed = build_rigs() + if(posed) + build_keys() + set_stage() + play(0, t_hit) + else + take_down() + ADD_TRAIT(bearer, TRAIT_IMMOBILIZED, GORILLA_SLAM_TRAIT) + listen() + hit_timer = addtimer(CALLBACK(src, PROC_REF(hit)), t_hit, TIMER_STOPPABLE | TIMER_DELETE_ME) + return TRUE + +/// Where [body] is drawn: list(x, y) pixels from where the bearer was drawn at the click. +/datum/gorilla_slam/proc/drawn_at(mob/living/body) + var/turf/here = get_turf(body) + return list((here.x - bearer_spot.x) * ICON_SIZE_X + body.pixel_x + body.pixel_w - origin_x, (here.y - bearer_spot.y) * ICON_SIZE_Y + body.pixel_y + body.pixel_z - origin_y) + +/// [body]'s lying turn in degrees clockwise, the short way round: 0 on its feet, 90 or -90 lying. +/datum/gorilla_slam/proc/turn_of(mob/living/body) + return body.lying_angle > 180 ? body.lying_angle - 360 : body.lying_angle + +/// Works out where the body is held, where the top of the lift is and where it lands, all from where the bearer is drawn. +/datum/gorilla_slam/proc/measure() + origin_x = bearer.pixel_x + bearer.pixel_w + origin_y = bearer.pixel_y + bearer.pixel_z + var/list/victim_at = drawn_at(victim) + held_x = victim_at[1] + held_y = victim_at[2] + held_angle = turn_of(victim) + tile_x = (spot.x - bearer_spot.x) * ICON_SIZE_X + tile_y = (spot.y - bearer_spot.y) * ICON_SIZE_Y + var/side_on = facing & (EAST|WEST) + var/ahead = facing == WEST ? -1 : 1 + // Seen from the side the head ends at his feet, under his fists; from the front or back the body lies head east + var/turned = facing == EAST ? -1 : 1 + if(arm.slam_overhead) + top_x = side_on ? GORILLA_SLAM_TOP_SIDE_X * ahead : GORILLA_SLAM_TOP_FRONT_X + top_y = side_on ? GORILLA_SLAM_TOP_SIDE_Y : (facing == NORTH ? GORILLA_SLAM_TOP_BACK_Y : GORILLA_SLAM_TOP_FRONT_Y) + top_angle = 90 * turned + else + top_x = side_on ? BRAWLER_SLAM_TOP_SIDE_X * ahead : BRAWLER_SLAM_TOP_FRONT_X + top_y = side_on ? BRAWLER_SLAM_TOP_SIDE_Y : BRAWLER_SLAM_TOP_FRONT_Y + top_angle = BRAWLER_SLAM_TOP_TURN * turned + land_angle = 90 * turned + land_x = tile_x + // Where tg draws a body lying there: a little down the tile, and up on a table top + land_y = tile_y + PIXEL_Y_OFFSET_LYING + (table_ref ? GORILLA_SLAM_TABLE_TOP : 0) + final_x = land_x + final_y = land_y + final_angle = land_angle + +// ========================================================================= +// THE RIGS +// ========================================================================= + +/// A flat picture of [body] facing [way], into [rig]. getFlatIcon() draws a body in its own facing unless it faces south, so it is turned for the picture. +/datum/gorilla_slam/proc/picture(datum/chrome_rig/rig, mob/living/body, way) + var/real_dir = body.dir + body.dir = way + . = rig.snapshot() + body.dir = real_dir + +/** + * Stands a puppet of [rig] under [key] where the bearer stands, [row] tiles up the map from him (-1: the row nearer the + * viewer), on [puppet_layer]. It is moved by its transform from there. + */ +/datum/gorilla_slam/proc/stand(datum/chrome_rig/rig, key, icon/picture, row, puppet_layer) + var/obj/effect/abstract/chrome_puppet/puppet = new(bearer_spot) + puppet.name = rig.body.name + puppet.icon = picture + puppet.dir = SOUTH + puppet.plane = bearer.plane + puppet.layer = puppet_layer + puppet.pixel_x = bearer.pixel_x + puppet.pixel_w = bearer.pixel_w + puppet.pixel_y = bearer.pixel_y + row * ICON_SIZE_Y + puppet.pixel_z = bearer.pixel_z - row * ICON_SIZE_Y + rig.puppets[key] = puppet + return puppet + +/// The two arms of [rig] in the order key poses name them: the near one then the far one seen from the side, else the one on the viewer's left then the other. +/datum/gorilla_slam/proc/arm_pair(datum/chrome_rig/rig) + if(rig.facing & (EAST|WEST)) + var/near = rig.near_side() + return list(near, near == "l" ? "r" : "l") + return rig.facing == NORTH ? list("l", "r") : list("r", "l") + +/** + * Builds the bearer's rig for each way he faces in the move, and a puppet of the body for each. Back to front: + * seen from the side, far arm, legs and torso, the body, near arm; from behind, the body, torso, arms; from the front, + * torso, the body, arms. Returns FALSE if either couldn't be rigged. + */ +/datum/gorilla_slam/proc/build_rigs() + rigs = list() + var/list/ways = taking == facing ? list(taking) : list(taking, facing) + for(var/way in ways) + var/datum/chrome_rig/rig = new(bearer, way) + rigs["[way]"] = rig + if(!picture(rig, bearer, way)) + return FALSE + victim_rig = new(victim, face_down ? NORTH : SOUTH) + if(!picture(victim_rig, victim, victim_rig.facing)) + return FALSE + var/base = bearer.layer + for(var/way in ways) + var/datum/chrome_rig/rig = rigs["[way]"] + // The row of the tile the body is on while this rig shows: the one it is taken from, then the one it lands on + var/turf/from = way == taking ? victim_spot : spot + var/turf/onto = way == facing ? spot : victim_spot + var/body_row = min(from.y, onto.y) < bearer_spot.y ? -1 : 0 + var/icon/whole = rig.cut_without_arms("both") + if(way & (EAST|WEST)) + // Split at the belt, the halves sharing three rows so no gap opens behind the bend + var/icon/legs = icon(whole) + legs.DrawBox(null, 1, 13, ICON_SIZE_X, ICON_SIZE_Y) + var/icon/torso = icon(whole) + torso.DrawBox(null, 1, 1, ICON_SIZE_X, 9) + stand(rig, "legs", legs, 0, base) + stand(rig, "body", torso, 0, base + 0.001) + var/near = rig.near_side() + stand(rig, "arm_[near]", rig.arm_picture(near), body_row, base + 0.03) + var/far = near == "l" ? "r" : "l" + stand(rig, "arm_[far]", rig.arm_picture(far), 0, base - 0.02) + stand(victim_rig, "body_[way]", victim_rig.flat, body_row, base + 0.02) + else if(way == NORTH) + stand(rig, "body", whole, 0, base) + for(var/side in list("l", "r")) + stand(rig, "arm_[side]", rig.arm_picture(side), 0, base + 0.02) + stand(victim_rig, "body_[way]", victim_rig.flat, 0, base - 0.02) + else + stand(rig, "body", whole, 0, base) + for(var/side in list("l", "r")) + stand(rig, "arm_[side]", rig.arm_picture(side), body_row, base + 0.03) + stand(victim_rig, "body_[way]", victim_rig.flat, body_row, base + 0.02) + var/datum/chrome_rig/first = rigs["[taking]"] + first.conceal() + victim_rig.conceal() + // The rig he turns into hides no body of its own: its puppets still go in the same file as the rest + if(taking != facing) + var/datum/chrome_rig/turned = rigs["[facing]"] + turned.pack() + return TRUE + +// ========================================================================= +// THE POSES +// ========================================================================= + +/// The body at [time]: list(x, y, turn), its middle in pixels from where the bearer is drawn and its turn in degrees clockwise. +/datum/gorilla_slam/proc/body_at(time) + if(time <= t_grip) + return list(held_x, held_y, held_angle) + if(time <= t_top) + // Fast out of the floor, easing into the top + var/up = gorilla_slam_ease(SLAM_EASE_OUT, (time - t_grip) / (t_top - t_grip)) + return list(held_x + (top_x - held_x) * up, held_y + (top_y - held_y) * up, held_angle + (top_angle - held_angle) * up) + if(time <= t_drive) + return list(top_x, top_y, top_angle) + if(time <= t_hit) + // Straight down, faster all the way + var/down = gorilla_slam_ease(SLAM_EASE_IN, (time - t_drive) / (t_hit - t_drive)) + return list(top_x + (land_x - top_x) * down, top_y + (land_y - top_y) * down, top_angle + (land_angle - top_angle) * down) + // It bounces once, tipping, and drops back onto where the real body lies + var/settled = clamp((time - t_hit) / GORILLA_SLAM_REBOUND_TIME, 0, 1) + var/hop = sin(180 * settled) + var/tip = (land_angle < 0 ? GORILLA_SLAM_BOUNCE_TIP : -GORILLA_SLAM_BOUNCE_TIP) * hop + return list( + land_x + (final_x - land_x) * settled, + land_y + (final_y - land_y) * settled + (arm?.slam_overhead ? GORILLA_SLAM_BOUNCE : BRAWLER_SLAM_BOUNCE) * hop, + land_angle + (final_angle - land_angle) * settled + tip, + ) + +/// The body puppet's transform at [time]. +/datum/gorilla_slam/proc/body_matrix(time) + var/list/at = body_at(time) + var/matrix/placed + if(landed && time >= t_hit + GORILLA_SLAM_REBOUND_TIME && !QDELETED(victim)) + // The real body's own turn, so the puppet ends in its pixels + placed = matrix(victim.transform) + else + placed = matrix() + placed.Turn(at[3]) + placed.Translate(at[1], at[2]) + return placed + +/// The point [x], [y] of the scene (pixels from where the bearer is drawn) in the body's own pixels at [time]. +/datum/gorilla_slam/proc/on_body(time, x, y) + var/list/at = body_at(time) + var/dx = x - at[1] + var/dy = y - at[2] + return list(dx * cos(at[3]) - dy * sin(at[3]), dx * sin(at[3]) + dy * cos(at[3])) + +/** + * The bearer's transforms in a pose of the rig facing [way]: list(legs, torso, arms' base). Seen from the side the legs lean + * from the feet and the torso bends on at the belt; from the front or back the whole body is squashed and the legs are null. + */ +/datum/gorilla_slam/proc/bases(way, shift_x, shift_y, lean, waist, squash, drop) + if(way & (EAST|WEST)) + var/forward = way == EAST ? 1 : -1 + var/matrix/legs = chrome_rig_turn(forward * lean, 0, CHROME_RIG_FEET_Y) + var/matrix/torso = chrome_rig_turn(forward * waist, 0, SLAM_WAIST_Y) + torso.Multiply(legs) + torso.Translate(shift_x, shift_y) + legs.Translate(shift_x, shift_y) + return list(legs, torso, torso) + var/datum/chrome_rig/rig = rigs["[way]"] + var/shoulder_y = rig.shoulder("l")[2] + // The arms come down with the squashed shoulders + return list(null, matrix(1, 0, shift_x, 0, squash, shift_y - drop), matrix(1, 0, shift_x, 0, 1, shift_y + shoulder_y * squash - drop - shoulder_y)) + +/// The bases of key pose [pose]. +/datum/gorilla_slam/proc/bases_of(datum/gorilla_slam_pose/pose) + return bases(pose.facing, pose.shift_x, pose.shift_y, pose.lean, pose.waist, pose.squash, pose.drop) + +/// The arm of [rig] on [side] as swing_arm() would leave it: list(turn, length). +/datum/gorilla_slam/proc/swung(datum/chrome_rig/rig, side, angle, reach) + return list(angle * rig.raise_sign(side), max(GORILLA_SLAM_MIN_REACH, 1 + reach / (GLOB.chrome_rig_arm_length["[rig.facing]"] || 10))) + +/// The arm of [rig] on [side] with its hand at [x], [y] of the scene, the body under it turned by [base]: list(turn, length). It stops short past its longest. +/datum/gorilla_slam/proc/reaching(datum/chrome_rig/rig, side, x, y, matrix/base) + var/list/pose = rig.pose_reaching(side, x, y, 0, base) + pose[2] = min(pose[2], GORILLA_SLAM_MAX_REACH) + return pose + +/** + * Poses [pose] with both fists on a body lying on the tile at [at_x], [at_y] (pixels from where the bearer stands), its + * middle [rise] pixels above the tile's: bent at the belt and leaning in, seen from the side; dropped and lunging, from the + * front or back. [on_table] is the shallower reach onto a table top. + */ +/datum/gorilla_slam/proc/press(datum/gorilla_slam_pose/pose, at_x, at_y, rise, on_table) + var/datum/chrome_rig/rig = rigs["[pose.facing]"] + var/way_x = (pose.facing == EAST) - (pose.facing == WEST) + var/way_y = (pose.facing == NORTH) - (pose.facing == SOUTH) + // How far in front of him the tile is: a whole tile, or none for his own + var/ahead = at_x * way_x + at_y * way_y + var/body_y = at_y + rise + pose.arms = list() + if(way_x) + pose.waist = on_table ? 30 : 50 + pose.shift_x = way_x * ((on_table ? 10 : 12) + (ahead - ICON_SIZE_X) * 18 / ICON_SIZE_X) + // A tile up or down the map as well: he goes most of the way with it + pose.shift_y = at_y * 22 / ICON_SIZE_Y + var/list/pair = arm_pair(rig) + pose.arms[pair[1]] = list(SLAM_ARM_POINT, pose.shift_x + way_x * (on_table ? 11 : 15), body_y + (on_table ? 2 : 3)) + pose.arms[pair[2]] = list(SLAM_ARM_POINT, pose.shift_x + way_x * (on_table ? 9 : 12), body_y + (on_table ? 2 : 3)) + return + var/share = ahead / ICON_SIZE_Y + var/edge + if(way_y > 0) + pose.squash = 0.8 + pose.drop = 3 + pose.shift_y = (on_table ? 13 : 10) * share + edge = body_y - (on_table ? 7 : 4) + else + pose.squash = on_table ? 0.85 : 0.8 + pose.drop = on_table ? 2.25 : 3 + pose.shift_y = (on_table ? -4 : -14) * share + edge = body_y + (on_table ? 6 : 7) * share + 2 * (1 - share) + for(var/side in list("l", "r")) + pose.arms[side] = list(SLAM_ARM_POINT, rig.shoulder(side)[1], edge) + +/// Works out [pose]'s arms: where each fist is on the body (grips) and the arm's own turn and length there (reached). +/datum/gorilla_slam/proc/settle_arms(datum/gorilla_slam_pose/pose) + var/datum/chrome_rig/rig = rigs["[pose.facing]"] + var/matrix/base = bases_of(pose)[3] + for(var/side in list("l", "r")) + var/list/does = pose.arms[side] + switch(does[1]) + if(SLAM_ARM_SWING) + pose.reached[side] = swung(rig, side, does[2], does[3]) + continue + if(SLAM_ARM_GRIP) + pose.grips[side] = list(does[2], does[3]) + if(SLAM_ARM_POINT) + pose.grips[side] = on_body(pose.time, does[2], does[3]) + if(SLAM_ARM_HELD) + var/list/swing = swung(rig, side, does[2], does[3]) + var/list/hand = rig.hand_at(side, list(swing[1], swing[2], base)) + pose.grips[side] = on_body(pose.time, hand[1], hand[2]) + var/list/grip = pose.grips[side] + var/list/point = chrome_rig_apply(body_matrix(pose.time), grip[1], grip[2]) + pose.reached[side] = reaching(rig, side, point[1], point[2], base) + +/// Both arms hanging. +/datum/gorilla_slam/proc/arms_down() + return list("l" = list(SLAM_ARM_SWING, 0, 0), "r" = list(SLAM_ARM_SWING, 0, 0)) + +/// Builds the key poses: standing, the grip, the top (the end of the hoist in the rig that takes the body, then held in the rig that brings it down), the impact, half way up, and upright. +/datum/gorilla_slam/proc/build_keys() + var/datum/chrome_rig/take_rig = rigs["[taking]"] + var/datum/chrome_rig/slam_rig = rigs["[facing]"] + var/take_x = (taking == EAST) - (taking == WEST) + var/slam_x = (facing == EAST) - (facing == WEST) + + var/datum/gorilla_slam_pose/stood = new(0, taking) + stood.arms = arms_down() + + // The grip. A body on its feet: he leans in and takes its near side by belt and collar, or its sides seen from the + // front or back. A body on the floor: he goes down to it as he will at the impact. + var/datum/gorilla_slam_pose/grip = new(t_grip, taking, SLAM_EASE_SINE) + var/list/pair = arm_pair(take_rig) + if(held_angle) + press(grip, held_x, held_y - PIXEL_Y_OFFSET_LYING, PIXEL_Y_OFFSET_LYING, FALSE) + else if(take_x) + grip.waist = 18 + grip.shift_x = 4 * take_x + grip.shift_y = held_y * 22 / ICON_SIZE_Y + grip.arms = list() + grip.arms[pair[1]] = list(SLAM_ARM_GRIP, -5 * take_x, -6) + grip.arms[pair[2]] = list(SLAM_ARM_GRIP, -4 * take_x, 3) + else if(taking == NORTH) + grip.arms = list() + grip.arms[pair[1]] = list(SLAM_ARM_GRIP, -5, -3) + grip.arms[pair[2]] = list(SLAM_ARM_GRIP, 5, -3) + else + grip.squash = 0.9 + grip.drop = 1.5 + grip.shift_y = -4 + grip.arms = list() + grip.arms[pair[1]] = list(SLAM_ARM_GRIP, -6, 2) + grip.arms[pair[2]] = list(SLAM_ARM_GRIP, 6, 2) + + // The top. Gorilla Arms: pressed overhead at full reach, leaning back under it. Brawler myomers: at the shoulder. + var/datum/gorilla_slam_pose/top = new(t_top, facing) + pair = arm_pair(slam_rig) + top.arms = list() + if(slam_x) + if(arm.slam_overhead) + top.lean = -6 + top.arms[pair[1]] = list(SLAM_ARM_HELD, 166, 6) + top.arms[pair[2]] = list(SLAM_ARM_HELD, 174, 6) + else + top.arms[pair[1]] = list(SLAM_ARM_GRIP, -7 * slam_x, 0) + top.arms[pair[2]] = list(SLAM_ARM_GRIP, -5 * slam_x, 4.5) + else + if(arm.slam_overhead && facing == NORTH) + top.shift_y = GORILLA_SLAM_TOP_BACK_RISE + for(var/side in list("l", "r")) + top.arms[side] = list(SLAM_ARM_POINT, slam_rig.shoulder(side)[1], top_y - (arm.slam_overhead ? 8 : 7)) + settle_arms(top) + var/datum/gorilla_slam_pose/top_held = new(t_drive, facing) + top_held.lean = top.lean + top_held.shift_y = top.shift_y + top_held.arms = list() + // The hoist ends with the fists where the top has them, in the rig that took the body + var/datum/gorilla_slam_pose/hoisted = new(t_top, taking, SLAM_EASE_OUT) + hoisted.arms = list() + if(taking == facing) + hoisted.lean = top.lean + hoisted.shift_y = top.shift_y + for(var/side in list("l", "r")) + var/list/grip_at = top.grips[side] + top_held.arms[side] = list(SLAM_ARM_GRIP, grip_at[1], grip_at[2]) + hoisted.arms[side] = list(SLAM_ARM_GRIP, grip_at[1], grip_at[2]) + + // The impact, and half way back up with his hands off it + var/datum/gorilla_slam_pose/impact = new(t_hit, facing, SLAM_EASE_IN) + press(impact, tile_x, tile_y, land_y - tile_y, !isnull(table_ref)) + var/datum/gorilla_slam_pose/rising = new(t_mid, facing, SLAM_EASE_OUT) + rising.shift_x = impact.shift_x / 2 + rising.shift_y = impact.shift_y / 2 + rising.arms = list() + if(slam_x) + rising.waist = 24 + rising.arms[pair[1]] = list(SLAM_ARM_SWING, 38, 2) + rising.arms[pair[2]] = list(SLAM_ARM_SWING, 46, 2) + else + rising.squash = 0.9 + rising.drop = 1.5 + for(var/side in list("l", "r")) + rising.arms[side] = list(SLAM_ARM_SWING, 24, 0) + var/datum/gorilla_slam_pose/upright = new(t_up, facing, SLAM_EASE_SINE) + upright.arms = arms_down() + var/datum/gorilla_slam_pose/still = new(t_end, facing) + still.arms = arms_down() + + keys = list(stood, grip, hoisted, top, top_held, impact, rising, upright, still) + for(var/datum/gorilla_slam_pose/pose as anything in keys) + if(pose != top) + settle_arms(pose) + +/** + * The bearer's puppets in the rig facing [way] at [time]: key ("legs", "body", "arm_l", "arm_r") -> transform. The body + * pose is eased between the keys either side; an arm on the body is solved onto its grip, which slides between the keys' + * grips, and the hand of an arm coming off it or going onto it is carried straight between where the two keys have it. + */ +/datum/gorilla_slam/proc/pose_at(time, way) + var/datum/gorilla_slam_pose/from_key + var/datum/gorilla_slam_pose/to_key + for(var/i in 1 to length(keys) - 1) + var/datum/gorilla_slam_pose/first = keys[i] + var/datum/gorilla_slam_pose/second = keys[i + 1] + if(first.facing != way || second.facing != way || second.time <= first.time) + continue + from_key = first + to_key = second + if(time <= second.time) + break + if(!from_key) + return null + var/datum/chrome_rig/rig = rigs["[way]"] + var/progress = gorilla_slam_ease(to_key.ease, (time - from_key.time) / (to_key.time - from_key.time)) + var/list/base = bases(way, + from_key.shift_x + (to_key.shift_x - from_key.shift_x) * progress, + from_key.shift_y + (to_key.shift_y - from_key.shift_y) * progress, + from_key.lean + (to_key.lean - from_key.lean) * progress, + from_key.waist + (to_key.waist - from_key.waist) * progress, + from_key.squash + (to_key.squash - from_key.squash) * progress, + from_key.drop + (to_key.drop - from_key.drop) * progress) + . = list("body" = base[2]) + if(base[1]) + .["legs"] = base[1] + var/matrix/held + for(var/side in list("l", "r")) + var/list/grip_from = from_key.grips[side] + var/list/grip_to = to_key.grips[side] + var/list/arm_pose + if(grip_from && grip_to) + held ||= body_matrix(time) + var/list/point = chrome_rig_apply(held, grip_from[1] + (grip_to[1] - grip_from[1]) * progress, grip_from[2] + (grip_to[2] - grip_from[2]) * progress) + arm_pose = reaching(rig, side, point[1], point[2], base[3]) + else + // Coming off the body or going onto it: the hand goes straight from where one key has it to where the other + // does, in his own pixels, so the arm folds in past the shoulder and never swings out wide + var/list/hand_from = rig.hand_at(side, from_key.reached[side]) + var/list/hand_to = rig.hand_at(side, to_key.reached[side]) + arm_pose = rig.pose_reaching(side, hand_from[1] + (hand_to[1] - hand_from[1]) * progress, hand_from[2] + (hand_to[2] - hand_from[2]) * progress) + arm_pose[2] = min(arm_pose[2], GORILLA_SLAM_MAX_REACH) + .["arm_[side]"] = rig.arm_matrix(side, arm_pose[1], arm_pose[2], base[3]) + +/// Every puppet takes its first pose: the rig that takes the body as he stands, the rig that brings it down at the top and unseen until then. +/datum/gorilla_slam/proc/set_stage() + for(var/way_text in rigs) + var/datum/chrome_rig/rig = rigs[way_text] + var/way = rig.facing + var/first_time = way == taking ? 0 : t_top + var/list/poses = pose_at(first_time, way) + var/obj/effect/abstract/chrome_puppet/held = victim_rig.puppet("body_[way]") + if(way == taking) + // Exactly as the real body is drawn, whatever its size + var/matrix/as_held = matrix(victim.transform) + as_held.Translate(held_x, held_y) + held.transform = as_held + else + held.transform = body_matrix(first_time) + held.alpha = 0 + for(var/key in poses) + var/obj/effect/abstract/chrome_puppet/puppet = rig.puppet(key) + puppet.transform = poses[key] + if(way != taking) + puppet.alpha = 0 + +/** + * Plays the move from [from_time] to [to_time] (deciseconds from the click, now being [from_time]): every puppet goes + * through its poses in straight steps of GORILLA_SLAM_STEP. The rig that takes the body shows until the top and the rig + * that brings it down from then on. + */ +/datum/gorilla_slam/proc/play(from_time, to_time) + for(var/way_text in rigs) + var/datum/chrome_rig/rig = rigs[way_text] + var/way = rig.facing + var/on_from = max(from_time, way == taking ? 0 : t_top) + var/on_to = min(to_time, way == facing ? t_end : t_top) + if(on_to <= on_from) + continue + var/steps = max(1, round((on_to - on_from) / GORILLA_SLAM_STEP)) + var/step_time = (on_to - on_from) / steps + var/list/chains = list() + for(var/i in 1 to steps) + var/time = on_from + step_time * i + var/list/poses = pose_at(time, way) + poses["body_[way]"] = body_matrix(time) + for(var/key in poses) + if(!chains[key]) + chains[key] = list() + chains[key] += poses[key] + for(var/key in chains) + var/obj/effect/abstract/chrome_puppet/puppet = key == "body_[way]" ? victim_rig.puppet(key) : rig.puppet(key) + if(puppet) + send_through(puppet, chains[key], step_time, on_from - from_time, on_to < to_time) + +/** + * Sends [puppet] through [poses] (transforms), [step_time] each. With a [wait] it stays unseen that long first; with + * [leave] it goes unseen at the end. The swap takes a hundredth of a second, so two rigs never show at once. + */ +/datum/gorilla_slam/proc/send_through(obj/effect/abstract/chrome_puppet/puppet, list/poses, step_time, wait = 0, leave = FALSE) + var/begun = FALSE + var/first_step = step_time + if(wait > 0) + animate(puppet, alpha = 0, time = wait) + animate(alpha = 255, time = GORILLA_SLAM_SWAP) + first_step = max(0, step_time - GORILLA_SLAM_SWAP) + begun = TRUE + for(var/i in 1 to length(poses)) + if(begun) + animate(transform = poses[i], time = i == 1 ? first_step : step_time) + else + animate(puppet, transform = poses[i], time = step_time) + begun = TRUE + if(leave) + animate(alpha = 0, time = GORILLA_SLAM_SWAP) + +// ========================================================================= +// CALLING IT OFF +// ========================================================================= + +/datum/gorilla_slam/proc/listen() + RegisterSignals(bearer, list( + COMSIG_MOVABLE_MOVED, + COMSIG_ATOM_NO_LONGER_PULLING, + COMSIG_LIVING_SET_BODY_POSITION, + COMSIG_MOB_STATCHANGE, + SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), + ), PROC_REF(on_change)) + RegisterSignal(victim, COMSIG_MOVABLE_MOVED, PROC_REF(on_change)) + RegisterSignal(bearer, COMSIG_QDELETING, PROC_REF(on_deleted)) + RegisterSignal(victim, COMSIG_QDELETING, PROC_REF(on_deleted)) + +/datum/gorilla_slam/proc/stop_listening() + if(bearer) + UnregisterSignal(bearer, list( + COMSIG_MOVABLE_MOVED, + COMSIG_ATOM_NO_LONGER_PULLING, + COMSIG_LIVING_SET_BODY_POSITION, + COMSIG_MOB_STATCHANGE, + SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), + COMSIG_QDELETING, + )) + if(victim) + UnregisterSignal(victim, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING)) + +/// Whether the slam can still land: the bearer up and able, the grab on, both where they stood, the arm running. +/datum/gorilla_slam/proc/still_held() + if(QDELETED(bearer) || QDELETED(victim) || QDELETED(arm) || arm.owner != bearer || !arm.gorilla_running()) + return FALSE + if(bearer.stat != CONSCIOUS || HAS_TRAIT(bearer, TRAIT_INCAPACITATED) || bearer.body_position == LYING_DOWN) + return FALSE + if(bearer.pulling != victim || bearer.grab_state < GRAB_AGGRESSIVE || victim.buckled) + return FALSE + return bearer.loc == bearer_spot && victim.loc == victim_spot + +/// Something changed for one of them: before the impact the slam is called off if it can't land any more; after it, a body that is moved shows as it is. +/datum/gorilla_slam/proc/on_change(datum/source) + SIGNAL_HANDLER + if(ended || placing) + return + if(!landed) + if(!still_held()) + call_off() + return + if(bearer.loc != bearer_spot || victim.loc != spot) + finish() + +/datum/gorilla_slam/proc/on_deleted(datum/source) + SIGNAL_HANDLER + finish() + +/** + * Calls the slam off before the impact. The bearer shows as he is now, free to move, and the body comes down on its feet + * where it stands, unhurt. + */ +/datum/gorilla_slam/proc/call_off() + if(landed || ended) + return + ended = TRUE + if(hit_timer) + deltimer(hit_timer) + hit_timer = null + stop_listening() + if(QDELETED(bearer) || QDELETED(victim)) + finish() + return + REMOVE_TRAIT(bearer, TRAIT_IMMOBILIZED, GORILLA_SLAM_TRAIT) + victim.visible_message(span_danger("[bearer] loses [bearer.p_their()] hold on [victim]!"), span_userdanger("[bearer] loses [bearer.p_their()] hold on you!"), ignored_mobs = bearer) + to_chat(bearer, span_danger("You lose your hold on [victim]!")) + var/showing = world.time - started_at < t_top ? taking : facing + var/obj/effect/abstract/chrome_puppet/held = posed ? victim_rig?.puppet("body_[showing]") : null + // A body taken off its tile shows where it is at once: its puppet would set down on the tile it left. + if(!held || !isturf(victim.loc) || victim.loc != victim_spot) + finish() + return + // His own puppets go at once; the body's puppet comes down onto the real body, and the one not on yet never shows + QDEL_LIST_ASSOC_VAL(rigs) + rigs = null + for(var/key in victim_rig.puppets) + if(victim_rig.puppets[key] != held) + victim_rig.drop_puppet(key) + var/list/victim_at = drawn_at(victim) + var/matrix/down = matrix(victim.transform) + down.Translate(victim_at[1], victim_at[2]) + animate(held, transform = down, alpha = 255, time = GORILLA_SLAM_SET_DOWN_TIME, easing = SINE_EASING | EASE_IN) + end_timer = addtimer(CALLBACK(src, PROC_REF(finish)), GORILLA_SLAM_SET_DOWN_TIME, TIMER_STOPPABLE | TIMER_DELETE_ME) + // Lost grip first, then the body taken off its tile (a pull breaks before the body moves): it shows where it is at + // once, not hidden under a puppet setting down on the tile it left. Destroy()'s stop_listening() lets go of this. + RegisterSignal(victim, COMSIG_MOVABLE_MOVED, PROC_REF(on_deleted)) + +/// The slam is over: the puppets go and both bodies show. +/datum/gorilla_slam/proc/finish() + end_timer = null + if(!QDELETED(src)) + qdel(src) + +// ========================================================================= +// THE IMPACT +// ========================================================================= + +/// The body comes down, if the slam can still land: the grab lets go, the body is put on the tile, and the blow lands. +/datum/gorilla_slam/proc/hit() + hit_timer = null + if(landed || ended) + return + if(!still_held()) + call_off() + return + var/obj/structure/table/table = table_ref?.resolve() + if(table && (QDELETED(table) || table.loc != spot)) + table = null + if(!table && !gorilla_slam_floor_ok(spot)) + call_off() + return + placing = TRUE + bearer.stop_pulling() + var/turf/stood = victim.loc + if(victim.loc != spot) + var/passtable_key = REF(src) + if(table) + passtable_on(victim, passtable_key) + victim.Move(spot, get_dir(victim, spot)) + if(table) + passtable_off(victim, passtable_key) + if(victim.loc != spot && victim.loc != stood && isturf(stood)) + // A diagonal move goes a step at a time: one that got half way was never there, it never left the hoist + victim.forceMove(stood) + placing = FALSE + if(victim.loc != spot) + // Something stopped them getting there + call_off() + return + landed = TRUE + bearer.setDir(facing) + // On its back, or face down for a head-aimed table slam: tg's fall keeps a body facing north or south as it is + if(victim.rotate_on_lying) + victim.setDir(face_down ? NORTH : SOUTH) + var/on_table = !isnull(table) + var/bled = strike(table) + if(!QDELETED(src) && !QDELETED(victim) && !QDELETED(bearer)) + impact_fx(on_table, bled) + if(QDELETED(src) || QDELETED(victim) || QDELETED(bearer)) + if(!QDELETED(src)) + finish() + return + if(victim.rotate_on_lying && victim.body_position == LYING_DOWN) + victim.set_lying_angle(facing == EAST ? LYING_ANGLE_WEST : LYING_ANGLE_EAST) + if(!posed) + finish() + return + // The real body is under the puppets: whatever tg is still easing on it (the fall, the grab's pull, a table's lift) ends now + animate(victim, transform = victim.transform, pixel_x = victim.pixel_x, pixel_y = victim.pixel_y, pixel_w = victim.pixel_w, pixel_z = victim.pixel_z, time = 0, flags = ANIMATION_END_NOW) + var/list/victim_at = drawn_at(victim) + final_x = victim_at[1] + final_y = victim_at[2] + final_angle = turn_of(victim) + play(t_hit, t_end) + end_timer = addtimer(CALLBACK(src, PROC_REF(finish)), t_end - t_hit, TIMER_STOPPABLE | TIMER_DELETE_ME) + +/** + * The blow itself on the body, now on the tile: the damage through #509 as one line, the stamina, the knockdown, and what + * the table takes. Returns TRUE if it opened a wound that bleeds. + */ +/datum/gorilla_slam/proc/strike(obj/structure/table/table) + var/obj/item/bodypart/limb = victim.get_bodypart(aimed_zone) || victim.get_bodypart(BODY_ZONE_CHEST) + var/others + var/self + if(table) + others = face_down ? "[bearer] slams [victim] face first into [table]!" : "[bearer] slams [victim] onto [table]!" + self = face_down ? "[bearer] slams you face first into [table]!" : "[bearer] slams you onto [table]!" + else + others = "[bearer] slams [victim] into the floor!" + self = "[bearer] slams you into the floor!" + victim.hv_hold_attack_message(others, self, null, bearer, vision_range = DEFAULT_MESSAGE_RANGE) + var/armour = victim.run_armor_check(limb, MELEE) + // No attack direction: a body driven into the floor throws no blood across the room (#509's heavy-hit spray) + gorilla_hold_spray(victim) + var/mob/living/carbon/carbon_victim = iscarbon(victim) ? victim : null + var/list/wounds_before = carbon_victim?.gorilla_wound_snapshot() + // What tg lays itself for a chest that bleeds inside from the blow (below): where, and what is there already + var/list/coughed_on = list(spot) + var/turf/faced = get_step(spot, victim.dir) + if(faced) + coughed_on += faced + var/list/blood_before = list() + for(var/turf/where as anything in coughed_on) + for(var/obj/effect/blood in where) + if(istype(blood, /obj/effect/decal/cleanable/blood) || istype(blood, /obj/effect/temp_visual/dir_setting/bloodsplatter)) + blood_before += blood + victim.apply_damage(table ? arm.slam_table_damage : arm.slam_floor_damage, BRUTE, limb || BODY_ZONE_CHEST, armour, wound_bonus = arm.punch_wound_bonus, attacking_item = fist) + victim.hv_flush_hit() + if(QDELETED(victim)) + return FALSE + . = !isnull(carbon_victim) && gorilla_slam_opened_wound(carbon_victim, wounds_before) + // A chest that bleeds inside from the blow coughs it up (tg's cracked ribs): real blood, which tg bursts one way over + // the top of the body and splashes on the tile it faces. A body on its back throws the slam's drops instead, so what + // tg has just laid is taken up and the drops (the same blood) go down in its place. + for(var/turf/where as anything in coughed_on) + for(var/obj/effect/blood in where) + if(blood in blood_before) + continue + if(istype(blood, /obj/effect/decal/cleanable/blood) || istype(blood, /obj/effect/temp_visual/dir_setting/bloodsplatter)) + qdel(blood) + . = TRUE + victim.apply_damage(table ? arm.slam_table_stamina : arm.slam_floor_stamina, STAMINA) + victim.Knockdown(arm.slam_knockdown) + gorilla_register_aggression(victim, bearer) + if(table) + var/datum/component/table_smash/smash = table.GetComponent(/datum/component/table_smash) + table.take_damage(arm.slam_table_break) + // Glass tables break as they do under any slammed body + if(!QDELETED(table)) + smash?.after_smash?.Invoke(victim) + log_combat(bearer, victim, table ? "piston-slammed onto a table" : "piston-slammed into the floor", "gorilla arms") + +/** + * What the impact looks and sounds like. Both cameras shake and the body flashes white. A ring spreads from under it: on + * the table top for a table slam, with the table's own crash; on a floor with cracks, and for Gorilla Arms dust and the + * heavy crash. With [bled], a few drops of blood are thrown out round it. + */ +/datum/gorilla_slam/proc/impact_fx(on_table, bled) + var/heavy = arm.slam_full_fx + for(var/mob/living/shaken in list(bearer, victim)) + shake_camera(shaken, heavy ? 3 : 2, heavy ? 2 : 1) + cyberware_flash_fx((posed && victim_rig?.puppet("body_[facing]")) || victim, 0.2 SECONDS) + // Level with the middle of the body: a table top is half way up to where tg draws a body lying on it + new /obj/effect/temp_visual/circle_wave/cyberware_slam/under_body(spot, heavy ? 0.8 : 0.5, on_table ? GORILLA_SLAM_TABLE_TOP / 2 : 0) + if(on_table) + playsound(victim, 'sound/effects/tableslam.ogg', 90, TRUE) + else if(heavy) + playsound(spot, 'sound/effects/meteorimpact.ogg', 40, TRUE) + new /obj/effect/temp_visual/cyberware_impact_cracks(spot, "damaged1", 220) + var/obj/effect/temp_visual/mook_dust/dust = cyberware_grey_dust(spot) + if(dust) + // On the tile's own row, as the ring is, so the body lying there draws over it + dust.pixel_x = 0 + dust.pixel_y = 0 + dust.pixel_w = -ICON_SIZE_X / 2 + dust.pixel_z = -ICON_SIZE_Y / 2 + else + playsound(spot, SFX_BODYFALL, 70, TRUE) + new /obj/effect/temp_visual/cyberware_impact_cracks(spot, "damaged1", 70) + if(bled && iscarbon(victim)) + gorilla_slam_blood(victim, spot) + +/** + * The slam's ring. tg's ring is drawn from half a tile toward the viewer, which puts it on the row in front of its own + * tile and over anybody lying there; this one stays on its tile's row and is centred by eye only, so the body draws over it. + */ +/obj/effect/temp_visual/circle_wave/cyberware_slam/under_body + pixel_x = 0 + pixel_y = 0 + pixel_w = -16 + pixel_z = -16 + +/obj/effect/temp_visual/circle_wave/cyberware_slam/under_body/Initialize(mapload, reach = 2, rise = 0) + pixel_z += rise + return ..() + +/// Whether [victim] has a wound that bleeds which it didn't have, or had milder, at [before] (gorilla_wound_snapshot()): a cut, a stab, or bone through the skin. +/proc/gorilla_slam_opened_wound(mob/living/carbon/victim, list/before) + for(var/datum/wound/wound as anything in victim.all_wounds) + if((wound in before) && before[wound] >= wound.severity) + continue + if(wound.blood_flow > 0 || (istype(wound, /datum/wound/blunt/bone) && wound.severity >= WOUND_SEVERITY_CRITICAL)) + return TRUE + return FALSE + +/// A few drops of [victim]'s blood thrown out round where it lies on [floor], in a ragged ring: no two the same size or the same way up. +/proc/gorilla_slam_blood(mob/living/carbon/victim, turf/floor) + if(!isturf(floor) || isgroundlessturf(floor) || victim.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return + var/list/blood_dna = victim.get_blood_dna_list() + var/list/viruses = victim.get_static_viruses() + var/drops = rand(GORILLA_SLAM_DROPS_MIN, GORILLA_SLAM_DROPS_MAX) + var/first = rand(0, 359) + for(var/i in 1 to drops) + var/obj/effect/decal/cleanable/blood/splatter/gorilla_skid/drop = new(floor, viruses, blood_dna) + if(QDELETED(drop)) + continue + var/way = first + i * 360 / drops + rand(-18, 18) + var/far = rand(GORILLA_SLAM_DROPS_NEAR, GORILLA_SLAM_DROPS_FAR) + var/matrix/shape = matrix() + shape.Scale(pick(0.45, 0.55, 0.7)) + shape.Turn(pick(0, 90, 180, 270)) + drop.transform = shape + // From under the body outward. The floor is seen from above and a little from the front, so the ring is flattened. + drop.pixel_x = 0 + drop.pixel_y = PIXEL_Y_OFFSET_LYING + animate(drop, pixel_x = round(cos(way) * far), pixel_y = round(sin(way) * far * 0.75) + PIXEL_Y_OFFSET_LYING, time = 0.12 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + +#undef SLAM_ARM_GRIP +#undef SLAM_ARM_POINT +#undef SLAM_ARM_HELD +#undef SLAM_ARM_SWING +#undef SLAM_EASE_LINEAR +#undef SLAM_EASE_OUT +#undef SLAM_EASE_IN +#undef SLAM_EASE_SINE +#undef SLAM_WAIST_Y diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_swing.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_swing.dm new file mode 100644 index 00000000000..3473f7dcffe --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_swing.dm @@ -0,0 +1,251 @@ +/** + * # Arm swings + * + * A Gorilla fist is thrown by an arm that moves: the piston punch draws its fist back and drives it out + * (gorilla_thrust.dm), and the haymaker winds its arm up, throws it and follows through (gorilla_haymaker.dm). Both + * are drawn with the puppet rig's pictures and maths (chrome_puppet_rig.dm), and both land their blow when the fist + * arrives, not at the click. What they share is here: + * + * - A swing is a list of beats (where the body and each arm are when the beat ends), cut into frames of a few degrees + * so a shoulder never leaves its body, and played on every piece at once. + * - The fist is sent to the part of the body the blow lands on, where that part is drawn. The body steps in behind it + * as far as it takes; an arm is only drawn so long. + */ + +/// Most degrees an arm or a body turns in one frame of a swing. +#define SWING_FRAME_TURN 12 +/// The longest one frame of an eased beat lasts. +#define SWING_FRAME_TIME (0.03 SECONDS) + +// A frame of a swing: list(time, the body's matrix, side -> list(turn, length), side -> a layer the arm takes) +#define SWING_FRAME_TIME_INDEX 1 +#define SWING_FRAME_BASE 2 +#define SWING_FRAME_ARMS 3 +#define SWING_FRAME_LAYERS 4 + +// ========================================================================= +// BEATS AND FRAMES +// ========================================================================= + +/// One beat of a swing: where the body and its arms are when it ends. +/datum/chrome_swing_beat + /// How long the beat lasts + var/time = 0 + /// Its pace (CHROME_SWING_*) + var/easing = CHROME_SWING_LINEAR + /// Pixels the body has moved from its rest, across and up the screen + var/shift_x = 0 + var/shift_y = 0 + /// Degrees the body is tipped, clockwise + var/tip = 0 + /// Side -> list(turn, length): the arms that move in this beat. One left out stays as it is + var/list/arms + /// Side -> the layer that arm takes as the beat starts + var/list/layers + /// Side -> list(degrees, layer): the layer that arm takes once it is turned less than that from hanging + var/list/layer_once_under + +/datum/chrome_swing_beat/New(time = 0, easing = CHROME_SWING_LINEAR, shift_x = 0, shift_y = 0, tip = 0) + src.time = time + src.easing = easing + src.shift_x = shift_x + src.shift_y = shift_y + src.tip = tip + +/// Sends the arm on [side] to [pose] (list(turn, length)) in this beat, on [layer] from its start if one is given. +/datum/chrome_swing_beat/proc/arm(side, list/pose, layer) + LAZYSET(arms, side, pose) + if(!isnull(layer)) + LAZYSET(layers, side, layer) + return src + +/// The body's matrix [tip] degrees over and moved by [shift_x], [shift_y]: tipped about its middle, then moved. +/proc/chrome_swing_base(shift_x = 0, shift_y = 0, tip = 0) + var/matrix/base = matrix() + if(tip) + base.Turn(tip) + if(shift_x || shift_y) + base.Translate(shift_x, shift_y) + return base + +/** + * Cuts [beats] into frames. [arms_from] (side -> list(turn, length)) is where each arm starts, and [shift_x], [shift_y] + * and [tip] where the body does. Every arm in [arms_from] is in every frame, moving or not. + */ +/proc/chrome_swing_frames(list/beats, list/arms_from, shift_x = 0, shift_y = 0, tip = 0) + var/list/frames = list() + var/list/arms_now = list() + for(var/side in arms_from) + var/list/pose = arms_from[side] + arms_now[side] = list(pose[1], pose[2]) + for(var/datum/chrome_swing_beat/beat as anything in beats) + var/steps = 1 + if(beat.time > 0) + for(var/side in beat.arms) + var/list/from_pose = arms_now[side] + var/list/to_pose = beat.arms[side] + if(from_pose) + steps = max(steps, CEILING(abs(to_pose[1] - from_pose[1]) / SWING_FRAME_TURN, 1)) + steps = max(steps, CEILING(abs(beat.tip - tip) / SWING_FRAME_TURN, 1)) + if(beat.easing != CHROME_SWING_LINEAR) + steps = max(steps, min(CEILING(beat.time / SWING_FRAME_TIME, 1), 12)) + var/list/switched = list() + for(var/i in 1 to steps) + var/progress = i / steps + switch(beat.easing) + if(CHROME_SWING_EASE_OUT) + progress = sin(90 * progress) + if(CHROME_SWING_EASE_IN_OUT) + progress = (1 - cos(180 * progress)) / 2 + var/matrix/base = chrome_swing_base(shift_x + (beat.shift_x - shift_x) * progress, shift_y + (beat.shift_y - shift_y) * progress, tip + (beat.tip - tip) * progress) + var/list/frame_arms = list() + var/list/frame_layers + for(var/side in arms_now) + var/list/from_pose = arms_now[side] + var/list/to_pose = beat.arms?[side] + var/list/pose = to_pose ? list(from_pose[1] + (to_pose[1] - from_pose[1]) * progress, from_pose[2] + (to_pose[2] - from_pose[2]) * progress) : from_pose + frame_arms[side] = pose + if(i == 1 && !isnull(beat.layers?[side])) + LAZYSET(frame_layers, side, beat.layers[side]) + var/list/under = beat.layer_once_under?[side] + if(under && !switched[side] && abs(pose[1]) < under[1]) + switched[side] = TRUE + LAZYSET(frame_layers, side, under[2]) + frames += list(list(beat.time / steps, base, frame_arms, frame_layers)) + for(var/side in beat.arms) + if(arms_now[side]) + var/list/to_pose = beat.arms[side] + arms_now[side] = list(to_pose[1], to_pose[2]) + shift_x = beat.shift_x + shift_y = beat.shift_y + tip = beat.tip + return frames + +/** + * Plays [frames] on the pieces of one body, with [rig]'s maths. Everything in [bodies] (a puppet standing for the body, + * anything that rides on it) takes each frame's matrix; each arm in [arms] (side -> its puppet) takes its pose on that + * matrix, and any layer the frame gives it. [real_body] is the body itself when it is the one on show: it takes the + * matrices alongside whatever else is moving it, as tg's own lunge does. [settle] (piece -> list(pixel_w, pixel_x, + * pixel_y, pixel_z)) are offsets a piece eases to over its first frame. + */ +/proc/chrome_swing_play(datum/chrome_rig/rig, list/frames, list/bodies, list/arms, atom/movable/real_body, list/settle) + if(!length(frames)) + return + for(var/atom/movable/piece as anything in bodies) + var/list/rest = settle?[piece] + var/first = TRUE + for(var/list/frame as anything in frames) + if(!first) + animate(transform = frame[SWING_FRAME_BASE], time = frame[SWING_FRAME_TIME_INDEX]) + continue + first = FALSE + if(rest) + animate(piece, transform = frame[SWING_FRAME_BASE], pixel_w = rest[1], pixel_x = rest[2], pixel_y = rest[3], pixel_z = rest[4], time = frame[SWING_FRAME_TIME_INDEX]) + else + animate(piece, transform = frame[SWING_FRAME_BASE], time = frame[SWING_FRAME_TIME_INDEX]) + if(real_body) + var/first = TRUE + for(var/list/frame as anything in frames) + if(first) + animate(real_body, transform = frame[SWING_FRAME_BASE], time = frame[SWING_FRAME_TIME_INDEX], flags = ANIMATION_PARALLEL) + first = FALSE + else + animate(transform = frame[SWING_FRAME_BASE], time = frame[SWING_FRAME_TIME_INDEX]) + for(var/side in arms) + var/atom/movable/arm = arms[side] + if(isnull(arm)) + continue + var/list/rest = settle?[arm] + var/first = TRUE + for(var/list/frame as anything in frames) + var/list/pose = frame[SWING_FRAME_ARMS][side] + if(isnull(pose)) + continue + var/matrix/posed = rig.arm_matrix(side, pose[1], pose[2], frame[SWING_FRAME_BASE]) + var/new_layer = frame[SWING_FRAME_LAYERS]?[side] + if(!first) + if(!isnull(new_layer)) + animate(layer = new_layer, time = 0) + animate(transform = posed, time = frame[SWING_FRAME_TIME_INDEX]) + continue + first = FALSE + if(!isnull(new_layer)) + arm.layer = new_layer + if(rest) + animate(arm, transform = posed, pixel_w = rest[1], pixel_x = rest[2], pixel_y = rest[3], pixel_z = rest[4], time = frame[SWING_FRAME_TIME_INDEX]) + else + animate(arm, transform = posed, time = frame[SWING_FRAME_TIME_INDEX]) + +// ========================================================================= +// WHERE A FIST LANDS +// ========================================================================= + +/// Which way [facing] steps: list(across, up). +/proc/chrome_swing_way(facing) + switch(facing) + if(EAST) + return list(1, 0) + if(WEST) + return list(-1, 0) + if(NORTH) + return list(0, 1) + return list(0, -1) + +/** + * Where the middle of a fist from [bearer] stops for a blow on [zone] of [target]: list(x, y), pixels from where the + * middle of [bearer] is drawn. The body is taken where it is drawn now: for the way it faces and lies, its offsets, and + * short of its tile when it is hit mid-stride. A standing body beside the bearer is met at its edge, at the height of + * the part, the knuckles just on it; anything else, on the part itself. Null when they aren't on one level. + */ +/proc/gorilla_fist_target(mob/living/bearer, atom/movable/target, zone) + var/turf/from = get_turf(bearer) + var/turf/onto = get_turf(target) + if(isnull(from) || isnull(onto) || from.z != onto.z) + return null + var/list/part = gorilla_zone_point(target, zone) + var/list/lag = gorilla_glide_lag(target) + var/body_x = (onto.x - from.x) * ICON_SIZE_X + target.pixel_x + target.pixel_w + lag[1] - bearer.pixel_x - bearer.pixel_w + var/body_y = (onto.y - from.y) * ICON_SIZE_Y + target.pixel_y + target.pixel_z + lag[2] - bearer.pixel_y - bearer.pixel_z + var/mob/living/struck = target + if(ishuman(target) && struck.body_position != LYING_DOWN && body_x && abs(body_x) >= abs(body_y)) + // Beside the bearer: half the width of tg's human sprite at that height, seen side on or from the front or back + var/side_on = struck.dir & (EAST|WEST) + var/half = 4 + switch(check_zone(zone)) + if(BODY_ZONE_CHEST) + half = side_on ? 4 : 7 + if(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM) + half = side_on ? 4 : 8 + if(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) + half = side_on ? 2 : 5 + return list(body_x + (body_x > 0 ? -1 : 1) * (half + GORILLA_FIST_KNUCKLES), body_y + part[2]) + // Up or down the screen, or lying: the fist is drawn on the part, a little to the bearer's side of it + var/to_x = body_x + part[1] + var/to_y = body_y + part[2] + var/far = sqrt(to_x * to_x + to_y * to_y) + if(far < 3) + return list(to_x, to_y) + return list(to_x - to_x / far * 2, to_y - to_y / far * 2) + +/** + * The swing that lands the fist of [rig]'s arm on [side] at [x], [y] (gorilla_fist_target()): list(step, turn, length). + * The body steps [way] (chrome_swing_way()) by at least [least] pixels and at most [most], tipped [tip] degrees: as few + * as bring the fist there with the arm no longer than [easy] times its length. The arm is never longer than [cap]: the + * fist stops short instead. [near_turn] picks which way round the arm comes. + */ +/proc/chrome_swing_reach(datum/chrome_rig/rig, side, x, y, list/way, least, most, tip, easy, cap, near_turn) + var/list/found + for(var/step in least to most) + var/list/pose = rig.pose_reaching(side, x, y, near_turn, chrome_swing_base(way[1] * step, way[2] * step, tip)) + found = list(step, pose[1], pose[2]) + if(pose[2] <= easy) + break + found[3] = min(found[3], cap) + return found + +#undef SWING_FRAME_TURN +#undef SWING_FRAME_TIME +#undef SWING_FRAME_TIME_INDEX +#undef SWING_FRAME_BASE +#undef SWING_FRAME_ARMS +#undef SWING_FRAME_LAYERS diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_throw.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_throw.dm new file mode 100644 index 00000000000..d2b4a5d58a9 --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_throw.dm @@ -0,0 +1,513 @@ +/** + * # Gorilla throws and wall impacts + * + * Every body the Gorilla Arms send flying (the one-tile shove, the hurl, the haymaker) takes one + * safe path: gorilla_plan_knockback() walks the tiles first and stops the body on the last good one + * before space, open air, a chasm, lava, a tile with no gravity, a window, a door, a railing or a + * grille. It never launches at all from a tile with no gravity. A wall or a standing body in the way + * is hit, as tg would. + * + * Bodies fly flat, without spinning, and skid. Along the way the body leaves a scuff and a little dust + * on each tile, or a ragged smear of blood drops if it bleeds, on at most GORILLA_TRAIL_MAX tiles. + * + * A Gorilla throw that meets a wall hurts through tg's damage and wound rolls (owner D48): a blunt hit + * on the part that meets it and split skin on the wall's edge, harder for a haymaker than a hurl, and + * likelier to wound a part that is already beaten. It replaces tg's own random-limb wall crash for that + * throw. A shove only dents the wall. Any hard throw into a wall (a Gorilla's or anyone else's) then + * leaves a mark chosen by the injuries the body carries after the hit (owner D38): no broken skin dents + * the wall and knocks chips off it; a bleeding cut or a compound fracture splashes a half-moon on the + * floor and smears the wall's edge; heavy bleeding or a torn artery sprays up the wall and runs. The + * body drops at the foot of the wall with tg's knockdown, no slide (D44). A haymaker always dents too. + */ + +/mob/living + /// The Gorilla throw this mob is flying in, if any (hyperviolence_gorilla). Cleared when it lands. + var/datum/gorilla_flight/gorilla_flight + +/// One Gorilla throw in flight: who threw it, what kind, and what it has left on the floor. +/datum/gorilla_flight + /// The body in the air + var/mob/living/victim + /// Who threw it + var/mob/living/thrower + /// TRUE for a haymaker: it always dents a wall + var/haymaker = FALSE + /// GORILLA_IMPACT_*: how hard it meets a wall + var/impact = GORILLA_IMPACT_HURL + /// Decals left so far + var/trail_left = 0 + /// The punch that launched it broke the skin: the trail is blood even if nothing bled before + var/wounded = FALSE + /// Safety timer that ends the flight if the landing signal never comes + var/expiry_timer + +/datum/gorilla_flight/New(mob/living/victim, mob/living/thrower, haymaker = FALSE, wounded = FALSE, impact = GORILLA_IMPACT_HURL) + . = ..() + src.victim = victim + src.thrower = thrower + src.haymaker = haymaker + src.wounded = wounded + src.impact = haymaker ? GORILLA_IMPACT_HAYMAKER : impact + victim.gorilla_flight = src + RegisterSignal(victim, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) + RegisterSignal(victim, COMSIG_MOVABLE_THROW_LANDED, PROC_REF(on_landed)) + RegisterSignal(victim, COMSIG_QDELETING, PROC_REF(on_victim_deleted)) + expiry_timer = addtimer(CALLBACK(src, PROC_REF(end)), 3 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/datum/gorilla_flight/Destroy() + if(expiry_timer) + deltimer(expiry_timer) + expiry_timer = null + if(victim) + UnregisterSignal(victim, list(COMSIG_MOVABLE_MOVED, COMSIG_MOVABLE_THROW_LANDED, COMSIG_QDELETING)) + if(victim.gorilla_flight == src) + victim.gorilla_flight = null + victim = null + thrower = null + return ..() + +/// Ends the flight. Safe to call more than once. +/datum/gorilla_flight/proc/end() + expiry_timer = null + if(!QDELETED(src)) + qdel(src) + +/datum/gorilla_flight/proc/on_victim_deleted(datum/source) + SIGNAL_HANDLER + end() + +/// Whether the body leaves blood rather than a scuff. +/datum/gorilla_flight/proc/bleeds() + if(victim.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return FALSE + if(wounded) + return TRUE + if(!iscarbon(victim)) + return FALSE + var/mob/living/carbon/body = victim + return body.get_bleed_rate() > 0 + +/// Each tile left behind gets a scuff and dust, or a streak of blood. +/datum/gorilla_flight/proc/on_moved(atom/movable/source, atom/old_loc, dir, forced, list/old_locs) + SIGNAL_HANDLER + if(trail_left >= GORILLA_TRAIL_MAX || !isturf(old_loc) || !victim.throwing) + return + var/turf/left = old_loc + if(!isfloorturf(left) || !left.has_gravity()) + return + trail_left++ + var/travel = get_dir(old_loc, victim) || dir + if(bleeds()) + gorilla_lay_skid_blood(left, travel, victim.get_blood_dna_list(), victim.get_static_viruses()) + return + new /obj/effect/temp_visual/gorilla_scuff(left, travel) + var/obj/effect/temp_visual/mook_dust/dust = cyberware_grey_dust(left) + if(dust) + dust.transform = matrix().Scale(0.5) + +/// Where it skids to a stop: a splash if it bleeds. +/datum/gorilla_flight/proc/on_landed(datum/source, datum/thrownthing/throwing_datum) + SIGNAL_HANDLER + var/turf/stop = get_turf(victim) + if(isfloorturf(stop) && stop.has_gravity() && bleeds() && trail_left < GORILLA_TRAIL_MAX) + hv_blood_lay_spray(stop, /obj/effect/decal/cleanable/blood/hv_spray, throwing_datum?.init_dir || victim.dir, victim.get_blood_dna_list(), victim.get_static_viruses()) + end() + +/** + * A bleeding body's skid over [floor] along [travel]: two to GORILLA_SKID_SPLATS drops and small splats + * of tg's blood, each a different shape, size and place along the line, so tiles don't repeat. + */ +/proc/gorilla_lay_skid_blood(turf/floor, travel, list/blood_dna, list/viruses) + var/along_x = (travel & EAST) ? 1 : ((travel & WEST) ? -1 : 0) + var/along_y = (travel & NORTH) ? 1 : ((travel & SOUTH) ? -1 : 0) + for(var/i in 1 to rand(2, GORILLA_SKID_SPLATS)) + var/obj/effect/decal/cleanable/blood/splatter/gorilla_skid/splat = new(floor, viruses, blood_dna) + if(QDELETED(splat)) + continue + // Spread along the line of travel, a little either side of it + var/along = rand(-13, 13) + var/across = rand(-3, 3) + splat.pixel_x = along * along_x + across * along_y + splat.pixel_y = along * along_y + across * along_x + var/matrix/shape = matrix() + var/size = pick(0.6, 0.75, 0.9, 1.1) + shape.Scale(size * pick(1, -1), size) + shape.Turn(pick(0, 90, 180, 270)) + splat.transform = shape + +/// One drop or splat of a bleeding body's skid. Several share a tile. +/obj/effect/decal/cleanable/blood/splatter/gorilla_skid + random_icon_states = list("gibbl1", "gibbl2", "gibbl3", "gibbl4", "gibbl5", "drip2", "drip4") + mergeable_decal = FALSE + // Thin enough that walking through it does not leave footprints + bloodiness = 5 + +/// The grey drag mark a launched body leaves on the floor. It fades on its own. +/obj/effect/temp_visual/gorilla_scuff + icon = GORILLA_GORE_ICON + icon_state = "scuff" + plane = FLOOR_PLANE + layer = ABOVE_OPEN_TURF_LAYER + randomdir = FALSE + duration = 8 SECONDS + +/obj/effect/temp_visual/gorilla_scuff/Initialize(mapload, travel_dir) + . = ..() + setDir(travel_dir || SOUTH) + animate(src, alpha = 255, time = duration - 3 SECONDS) + animate(alpha = 0, time = 3 SECONDS) + +// ========================================================================= +// THE SAFE PATH +// ========================================================================= + +/** + * Whether a body flying from [here] into [next] must stop short on [here] without hitting anything: + * the edge of the map, a hole, lava, open air, space, no gravity, or glass, a door, a railing or a + * grille in the way (the body would break the glass or the door would take the hit). + */ +/proc/gorilla_throw_stops_short(turf/here, turf/next, direction) + if(isnull(next)) + return TRUE + if(isspaceturf(next) || isopenspaceturf(next) || ischasm(next) || islava(next) || isgroundlessturf(next)) + return TRUE + if(!isclosedturf(next) && !next.has_gravity()) + return TRUE + // Something on the edge of our own tile, facing the way we fly + for(var/obj/border in here) + if(!border.density || !(border.flags_1 & ON_BORDER_1) || !(border.dir & direction)) + continue + if(gorilla_throw_is_barrier(border)) + return TRUE + for(var/obj/thing in next) + if(!thing.density) + continue + if((thing.flags_1 & ON_BORDER_1) && !(thing.dir & REVERSE_DIR(direction))) + continue + if(gorilla_throw_is_barrier(thing)) + return TRUE + return FALSE + +/// Glass, doors, railings and grilles: a flying body stops before them rather than going through or breaking them. +/proc/gorilla_throw_is_barrier(obj/thing) + return istype(thing, /obj/structure/window) || istype(thing, /obj/machinery/door) || istype(thing, /obj/structure/railing) || istype(thing, /obj/structure/grille) || istype(thing, /obj/structure/falsewall) + +/** + * Plans a knockback of [victim] up to [range] tiles along [direction]. Returns a list: + * (the turf to throw at, how many tiles it travels, GORILLA_THROW_* why it stops, what it hits or null). + * A distance of 0 means no throw at all. + */ +/proc/gorilla_plan_knockback(mob/living/victim, direction, range) + var/turf/here = get_turf(victim) + if(isnull(here) || !direction || range <= 0) + return list(here, 0, GORILLA_THROW_SHORT, null) + if(!here.has_gravity()) + return list(here, 0, GORILLA_THROW_SHORT, null) + var/turf/current = here + for(var/step in 1 to range) + var/turf/next = get_step(current, direction) + if(isnull(next)) + return list(current, step - 1, GORILLA_THROW_SHORT, null) + if(isclosedturf(next)) + // The wall is hit: throw at it and the body stops against it + return list(next, step, GORILLA_THROW_WALL, next) + if(gorilla_throw_stops_short(current, next, direction)) + return list(current, step - 1, GORILLA_THROW_SHORT, null) + for(var/mob/living/standing in next) + if(standing.density && standing != victim) + return list(next, step, GORILLA_THROW_MOB, standing) + current = next + return list(current, range, GORILLA_THROW_CLEAR, null) + +/** + * Throws [victim] along [direction] on the safe path. [haymaker] marks a haymaker's flight; [wounded] + * makes the trail blood. Returns the distance it will travel, 0 if it doesn't move. + */ +/proc/gorilla_launch(mob/living/victim, mob/living/thrower, direction, range, speed = 2, gentle = FALSE, haymaker = FALSE, wounded = FALSE) + if(QDELETED(victim) || victim.anchored || victim.buckled || victim.move_resist == INFINITY) + return 0 + var/list/plan = gorilla_plan_knockback(victim, direction, range) + var/turf/target = plan[1] + var/distance = plan[2] + if(distance <= 0 || isnull(target)) + return 0 + // Megafauna and anything bolted down shrug it off, as safe_throw_at() decides + if(MOVE_FORCE_STRONG < victim.move_resist * MOVE_FORCE_THROW_RATIO) + return 0 + if(victim.gorilla_flight) + qdel(victim.gorilla_flight) + var/datum/gorilla_flight/flight = new(victim, thrower, haymaker, wounded, gentle ? GORILLA_IMPACT_SHOVE : GORILLA_IMPACT_HURL) + // Flat, no spin: the body skids to a stop + if(!victim.throw_at(target, distance, speed, thrower, spin = FALSE, gentle = gentle)) + flight.end() + return 0 + return distance + +// ========================================================================= +// WALL IMPACTS (owner D38) +// ========================================================================= + +/// The wounds on a body right now, with their severities, to tell what a hit added. +/mob/living/carbon/proc/gorilla_wound_snapshot() + . = list() + for(var/datum/wound/wound as anything in all_wounds) + .[wound] = wound.severity + +/** + * Which picture a wall impact leaves, from the injuries the body carries after the hit (owner D38, D48): + * GORILLA_SPLAT_SPRAY for a heavy cut or stab or a torn artery, GORILLA_SPLAT_EDGE for a bleeding + * cut or stab or a compound fracture, else GORILLA_SPLAT_DENT. A body that can't bleed only dents. + */ +/mob/living/carbon/proc/gorilla_splat_kind() + if(can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return GORILLA_SPLAT_DENT + var/kind = GORILLA_SPLAT_DENT + for(var/datum/wound/wound as anything in all_wounds) + var/series = wound.get_pregen_data()?.wound_series + // A torn aorta or throat (#509), or a limb artery torn by a blade + if(series == WOUND_SERIES_HV_AORTA || series == WOUND_SERIES_HV_CAROTID || series == "wound_series_hv_limb_artery") + return GORILLA_SPLAT_SPRAY + if(istype(wound, /datum/wound/slash) || istype(wound, /datum/wound/pierce)) + if(wound.severity >= WOUND_SEVERITY_SEVERE) + return GORILLA_SPLAT_SPRAY + if(wound.severity >= WOUND_SEVERITY_MODERATE) + kind = GORILLA_SPLAT_EDGE + else if(istype(wound, /datum/wound/blunt/bone) && wound.severity >= WOUND_SEVERITY_CRITICAL) + // A compound fracture breaks the skin + kind = GORILLA_SPLAT_EDGE + return kind + +/mob/living/carbon/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) + var/datum/gorilla_flight/flight = gorilla_flight + if(!isclosedturf(hit_atom) || !hit_atom.density || !istype(throwingdatum)) + return ..() + var/was_gentle = throwingdatum.gentle + // A Gorilla throw's crash is its own (gorilla_wall_crash()): tg's random-limb crash is held off by + // passing the throw to the parent as gentle, then put back. + var/own_crash = !isnull(flight) && flight.victim == src + if(own_crash) + throwingdatum.gentle = TRUE + . = ..() + throwingdatum.gentle = was_gentle + if(QDELETED(src) || (was_gentle && !own_crash)) + return + gorilla_wall_impact(hit_atom, own_crash ? flight : null) + +/** + * A landing against [wall]: the Gorilla throw's crash, if it was one, then the marks by the wounds after it. + */ +/mob/living/carbon/proc/gorilla_wall_impact(turf/wall, datum/gorilla_flight/flight) + var/turf/floor = get_turf(src) + var/toward = get_dir(floor, wall) + if(!toward) + return + if(flight) + gorilla_wall_crash(wall, flight, toward) + if(QDELETED(src)) + return + // A shove only bumps the wall, whatever the body carries + var/kind = flight?.impact == GORILLA_IMPACT_SHOVE ? GORILLA_SPLAT_DENT : gorilla_splat_kind() + // Only a straight hit on a wall face gets the pictures; a glancing corner hit gets the dent. + if(!(toward in GLOB.cardinals)) + gorilla_wall_dent(wall, toward) + return + switch(kind) + if(GORILLA_SPLAT_SPRAY) + gorilla_lay_wall_decal(floor, /obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray, toward) + gorilla_lay_wall_decal(floor, /obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/runs, toward) + if(GORILLA_SPLAT_EDGE) + gorilla_lay_wall_decal(floor, /obj/effect/decal/cleanable/blood/hv_spray/gorilla_splash, toward) + gorilla_lay_wall_decal(floor, /obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/edge, toward) + else + gorilla_wall_chips(floor, toward) + if(kind == GORILLA_SPLAT_DENT || flight?.haymaker) + gorilla_wall_dent(wall, toward) + +/** + * A Gorilla throw meets [wall] going [toward] (owner D48). A shove does nothing more than tg's gentle + * throw. A hurl or a haymaker knocks the body down as tg's crash does and lands two real hits on the + * part that meets the wall: a blunt one (tg's bone wounds) and the skin split on the wall's edge (tg's + * cuts), each through armour and tg's wound roll. A part that is already beaten gets a higher wound + * bonus, so a hurt body is likelier to break open. + */ +/mob/living/carbon/proc/gorilla_wall_crash(turf/wall, datum/gorilla_flight/flight, toward) + var/blunt + var/blunt_wound + var/edge + var/edge_wound + switch(flight.impact) + if(GORILLA_IMPACT_HAYMAKER) + blunt = GORILLA_WALL_HAYMAKER_BLUNT + blunt_wound = GORILLA_WALL_HAYMAKER_BLUNT_WOUND + edge = GORILLA_WALL_HAYMAKER_EDGE + edge_wound = GORILLA_WALL_HAYMAKER_EDGE_WOUND + if(GORILLA_IMPACT_HURL) + blunt = GORILLA_WALL_HURL_BLUNT + blunt_wound = GORILLA_WALL_HURL_BLUNT_WOUND + edge = GORILLA_WALL_HURL_EDGE + edge_wound = GORILLA_WALL_HURL_EDGE_WOUND + else + return + Paralyze(GORILLA_WALL_KNOCKDOWN) + visible_message(span_danger("[src] slams into [wall]!"), span_userdanger("You slam into [wall]!")) + playsound(src, 'sound/items/weapons/punch1.ogg', 50, TRUE) + log_combat(flight.thrower || wall, src, "slammed into a wall", null, "(gorilla throw, impact [flight.impact])") + var/obj/item/bodypart/part = get_bodypart(gorilla_wall_zone(toward)) || get_bodypart(BODY_ZONE_CHEST) + if(isnull(part)) + return + var/hurt_bonus = min(GORILLA_WALL_HURT_MAX, round(part.brute_dam / GORILLA_WALL_HURT_PER_POINT)) + var/armour = run_armor_check(part, MELEE, silent = TRUE) + // The wall's marks are the picture; no #509 blood fan on top of them + gorilla_hold_spray(src) + apply_damage(blunt, BRUTE, part, armour, wound_bonus = blunt_wound + hurt_bonus, attack_direction = toward) + if(QDELETED(src) || part.owner != src) + return + apply_damage(edge, BRUTE, part, armour, wound_bonus = edge_wound + hurt_bonus, sharpness = SHARP_EDGED, attack_direction = toward) + +/** + * The part that meets a wall at [toward]: a body side-on to it takes it on the shoulder half the time, + * otherwise the chest, sometimes the head. + */ +/mob/living/carbon/proc/gorilla_wall_zone(toward) + if(turn(dir, -90) == toward && prob(50)) + return BODY_ZONE_R_ARM + if(turn(dir, 90) == toward && prob(50)) + return BODY_ZONE_L_ARM + return prob(75) ? BODY_ZONE_CHEST : BODY_ZONE_HEAD + +/// Lays (or refreshes) one wall-impact decal on the floor tile in front of the wall. +/mob/living/carbon/proc/gorilla_lay_wall_decal(turf/floor, decal_type, toward) + if(!isturf(floor) || isclosedturf(floor) || isgroundlessturf(floor)) + return null + var/list/blood_dna = get_blood_dna_list() + var/list/viruses = get_static_viruses() + for(var/obj/effect/decal/cleanable/blood/hv_spray/existing in floor) + if(existing.type != decal_type || existing.dir != toward || existing.dried || QDELETED(existing)) + continue + existing.add_blood_DNA(blood_dna, viruses) + return existing + var/obj/effect/decal/cleanable/blood/hv_spray/fresh = new decal_type(floor, viruses, blood_dna) + if(QDELETED(fresh)) + return null + fresh.hv_aim(toward) + return fresh + +/// Chips knocked off the wall where the body hit it. +/mob/living/carbon/proc/gorilla_wall_chips(turf/floor, toward) + var/obj/effect/abstract/gorilla_chips/chips = new(floor) + chips.aim(toward) + +/// A body-sized dent in a wall, kept with the wall's bullet holes and dents so a welder repairs it. +/proc/gorilla_wall_dent(turf/closed/wall/wall, toward) + if(!istype(wall) || LAZYLEN(wall.dent_decals) >= MAX_DENT_DECALS) + return FALSE + if(!(toward in GLOB.cardinals)) + toward = (toward & (EAST|WEST)) || (toward & (NORTH|SOUTH)) + var/mutable_appearance/dent = mutable_appearance(GORILLA_GORE_ICON, "wall_dent_[dir2text(toward)]", BULLET_HOLE_LAYER) + if(LAZYLEN(wall.dent_decals)) + wall.cut_overlay(wall.dent_decals) + wall.dent_decals += dent + else + wall.dent_decals = list(dent) + wall.add_overlay(wall.dent_decals) + return TRUE + +/// A short burst of grey chips off the contact point. +/obj/effect/abstract/gorilla_chips + name = "chips" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + layer = ABOVE_MOB_LAYER + +/obj/effect/abstract/gorilla_chips/Initialize(mapload) + . = ..() + particles = new /particles/gorilla_chips + addtimer(CALLBACK(src, PROC_REF(stop)), 0.2 SECONDS) + QDEL_IN(src, 1 SECONDS) + +/// Throws the chips back off the wall at [toward]. +/obj/effect/abstract/gorilla_chips/proc/aim(toward) + var/dx = (toward & EAST) ? 1 : ((toward & WEST) ? -1 : 0) + var/dy = (toward & NORTH) ? 1 : ((toward & SOUTH) ? -1 : 0) + pixel_x = dx * 14 + pixel_y = dy * 14 + var/particles/gorilla_chips/burst = particles + burst.velocity = generator(GEN_BOX, list(-dx * 3 - 1.5, -dy * 3 - 1.5, 0), list(-dx * 1 + 1.5, -dy * 1 + 1.5, 0), UNIFORM_RAND) + +/obj/effect/abstract/gorilla_chips/proc/stop() + if(particles) + particles.spawning = 0 + +/particles/gorilla_chips + icon = 'icons/effects/particles/generic.dmi' + icon_state = list("dot" = 3, "cross" = 1) + color = "#8a8e96" + count = 12 + spawning = 6 + lifespan = 0.5 SECONDS + fade = 0.25 SECONDS + position = generator(GEN_BOX, list(-4, -4, 0), list(4, 4, 0), UNIFORM_RAND) + velocity = generator(GEN_BOX, list(-2, -2, 0), list(2, 2, 0), UNIFORM_RAND) + gravity = list(0, -0.4) + friction = 0.1 + scale = 0.5 + +// ---- The decals. Greyscale art tinted to the victim's blood, on the floor tile in front of the wall. ---- + +/// Option C: a half-moon splash on the floor at the foot of the wall. Mops like floor blood. +/obj/effect/decal/cleanable/blood/hv_spray/gorilla_splash + name = "blood splatter" + icon = GORILLA_GORE_LARGE_ICON + icon_state = "impact_splash" + random_icon_states = null + bloodiness = 20 + +/obj/effect/decal/cleanable/blood/hv_spray/gorilla_splash/hv_aim(spray_dir) + setDir(spray_dir) + // Centred, the half-moon's flat side lies on this tile's edge toward the wall in every facing, so the + // splash meets the wall's foot. Its ragged 2 px fringe past that sits under the wall, which draws over + // floor decals. Pulled back any further, floor shows between the blood and the wall. + pixel_x = -16 + pixel_y = -16 + +/// Wall pictures: 64x64 on the floor tile at -16,-16, drawn up onto the wall's near edge. +/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray + name = "blood spray" + icon = GORILLA_GORE_LARGE_ICON + icon_state = "impact_spray" + random_icon_states = null + alpha = 230 + +/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/hv_aim(spray_dir) + setDir(spray_dir) + pixel_x = -16 + pixel_y = -16 + +/// Option A's runs down the wall face. They crawl down as they appear. +/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/runs + name = "blood runs" + icon_state = "impact_runs" + alpha = 220 + +/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/runs/hv_aim(spray_dir) + . = ..() + // The runs grow downward from their top on the wall face, so they never show past it. Parallel: tg's + // drying animation keeps running. + var/top = 0 + switch(spray_dir) + if(SOUTH) + top = -17 + if(NORTH) + top = 25 + else + top = -1 + var/matrix/start = matrix() + start.Scale(1, 0.25) + start.Translate(0, round(top * 0.75)) + transform = start + animate(src, transform = matrix(), time = 3 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + +/// Option C's thin band on the wall's edge where the body slid down it. +/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/edge + name = "blood smear" + icon_state = "impact_edge" + alpha = 220 diff --git a/voidcrew/modules/hyperviolence_gorilla/gorilla_thrust.dm b/voidcrew/modules/hyperviolence_gorilla/gorilla_thrust.dm new file mode 100644 index 00000000000..567afa6aae9 --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/gorilla_thrust.dm @@ -0,0 +1,306 @@ +/** + * # The piston punch's arm + * + * A piston punch is thrown by its arm: the fist draws back, drives out onto the part it hits with the body lunging + * behind it, stays there as the blow lands, and comes back to rest, in three tenths of a second (the swing is + * gorilla_swing.dm's). + * + * The punch comes about once a second, so it does not take the whole body's picture each time and stand puppets for + * all of it, as a finisher does. The punching arm alone is cut from one picture of the bearer, kept until their look + * changes, and drawn by a puppet over the real body, whose own arm is masked out for as long as the punch lasts. The + * real body does its own lunging. A bearer who can't be drawn that way lunges as tg has them lunge. + */ + +/// The mask on a body whose punching arm is drawn by a puppet. +#define GORILLA_THRUST_FILTER "gorilla_thrust" + +/mob/living/carbon/human + /// The pictures a piston punch's arm is drawn from, by facing: "[dir]" -> /datum/gorilla_arm_look (gorilla_swing.dm) + var/list/gorilla_arm_looks + /// The piston punch being drawn on us now + var/datum/gorilla_thrust/gorilla_thrust + +/// One picture of a bearer in one facing, and the arms cut from it. Good until their look changes. +/datum/gorilla_arm_look + /// What the bearer looked like when it was taken (gorilla_look_key()) + var/key + /// Holds the picture and does the maths. Never hides anyone and stands no puppets + var/datum/chrome_rig/rig + /// Cuts made from the picture so far, by name + var/list/pictures = list() + /// Side -> TRUE once that arm's picture has been shown + var/list/shown = list() + +/datum/gorilla_arm_look/Destroy() + QDEL_NULL(rig) + pictures = null + return ..() + +/// The picture of the arm on [side]. +/datum/gorilla_arm_look/proc/arm_picture(side) + . = pictures["arm_[side]"] + if(isnull(.)) + . = (rig.behind_body(side) && far_arm_picture(side)) || rig.arm_picture(side) + pictures["arm_[side]"] = . + +/** + * The picture of the arm on [side] when it is the far one, hidden behind the body in this facing: that arm as it shows + * from the bearer's other side, turned round, a pixel further back and in shadow. The rig's own far arm is a copy of + * the near one, which would bring along whatever the near hand holds; the far hand is the one punching, and empty. + * Null if the other side can't be pictured. + */ +/datum/gorilla_arm_look/proc/far_arm_picture(side) + var/mob/living/body = rig.body + if(QDELETED(body)) + return null + var/datum/chrome_rig/other_side = new(body, REVERSE_DIR(rig.facing)) + // getFlatIcon() draws a body in its own facing, so it is turned for the picture + var/real_dir = body.dir + body.dir = other_side.facing + var/taken = other_side.snapshot() + body.dir = real_dir + var/icon/picture = taken ? other_side.cut("rig_arm_[side]") : null + qdel(other_side) + if(isnull(picture)) + return null + picture.Flip(EAST) + picture.Shift(rig.facing == EAST ? WEST : EAST, 1) + picture.Blend(rgb(170, 170, 178), ICON_MULTIPLY) + return picture + +/// The torso under the arm on [side], or null where there is none. +/datum/gorilla_arm_look/proc/fill_picture(side) + if("fill_[side]" in pictures) + return pictures["fill_[side]"] + . = rig.fill_picture(side) + pictures["fill_[side]"] = . + +/// What [bearer] looks like, as text: everything drawn on them and the way they face. Not where or how they stand. +/proc/gorilla_look_key(mob/living/carbon/human/bearer) + var/list/parts = list("[bearer.dir]", "[bearer.icon]", "[bearer.icon_state]") + for(var/overlay in bearer.overlays) + parts += ref(overlay) + for(var/underlay in bearer.underlays) + parts += ref(underlay) + return parts.Join("|") + +/// The picture a piston punch's arm is cut from for the way [bearer] faces and looks now, taken if there is none. Null if they can't be drawn. +/proc/gorilla_arm_look(mob/living/carbon/human/bearer) + var/key = gorilla_look_key(bearer) + var/datum/gorilla_arm_look/look = bearer.gorilla_arm_looks?["[bearer.dir]"] + if(look?.key == key && !QDELETED(look.rig)) + return look + if(look) + qdel(look) + LAZYREMOVE(bearer.gorilla_arm_looks, "[bearer.dir]") + var/datum/chrome_rig/rig = new(bearer, bearer.dir) + if(!rig.snapshot()) + qdel(rig) + return null + look = new + look.key = key + look.rig = rig + LAZYSET(bearer.gorilla_arm_looks, "[bearer.dir]", look) + return look + +/// The mask that cuts the hanging arm on [side] out of a body facing [facing]. Each is made once. +/proc/gorilla_arm_mask(facing, side) + var/static/list/masks = list() + var/key = "[facing]-[side]" + . = masks[key] + if(isnull(.)) + . = icon(GORILLA_GORE_ICON, "rig_arm_[side]", facing, 1) + masks[key] = . + +/// One piston punch's arm on its bearer: the puppets, and the mask on the real body. Deleting it puts the real arm back. +/datum/gorilla_thrust + /// Who is punching + var/mob/living/carbon/human/bearer + /// The puppets: the arm, and the torso under it where there is any + var/list/pieces = list() + /// Takes it down when the arm is back at rest + var/end_timer + +/datum/gorilla_thrust/New(mob/living/carbon/human/bearer) + src.bearer = bearer + bearer.gorilla_thrust = src + RegisterSignal(bearer, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) + RegisterSignal(bearer, COMSIG_ATOM_POST_DIR_CHANGE, PROC_REF(on_turned)) + RegisterSignals(bearer, list(COMSIG_LIVING_SET_BODY_POSITION, COMSIG_QDELETING), PROC_REF(on_lost)) + +/datum/gorilla_thrust/Destroy() + if(end_timer) + deltimer(end_timer) + end_timer = null + QDEL_LIST(pieces) + if(bearer) + UnregisterSignal(bearer, list(COMSIG_MOVABLE_MOVED, COMSIG_ATOM_POST_DIR_CHANGE, COMSIG_LIVING_SET_BODY_POSITION, COMSIG_QDELETING)) + if(!QDELETED(bearer)) + bearer.remove_filter(GORILLA_THRUST_FILTER) + if(bearer.gorilla_thrust == src) + bearer.gorilla_thrust = null + bearer = null + return ..() + +/// Stands a puppet showing [picture] where the bearer is drawn, on [puppet_layer]. +/datum/gorilla_thrust/proc/stand(icon/picture, puppet_layer) + var/obj/effect/abstract/chrome_puppet/puppet = new(bearer.loc) + puppet.name = bearer.name + puppet.icon = picture + puppet.dir = SOUTH + puppet.pixel_x = bearer.pixel_x + puppet.pixel_y = bearer.pixel_y + puppet.pixel_w = bearer.pixel_w + puppet.pixel_z = bearer.pixel_z + puppet.plane = bearer.plane + puppet.layer = puppet_layer + // It walks with the bearer (on_moved()), gliding as they glide + puppet.animate_movement = SLIDE_STEPS + pieces += puppet + return puppet + +/// The bearer stepped mid-punch: the arm steps with them, at their pace. +/datum/gorilla_thrust/proc/on_moved(atom/movable/source, atom/old_loc) + SIGNAL_HANDLER + var/turf/now = source.loc + if(!isturf(now) || !isturf(old_loc) || get_dist(old_loc, now) > 1) + qdel(src) + return + for(var/obj/effect/abstract/chrome_puppet/puppet as anything in pieces) + puppet.set_glide_size(source.glide_size) + puppet.forceMove(now) + +/// The bearer turned to face another way: the arm is a picture of the old facing. +/datum/gorilla_thrust/proc/on_turned(datum/source, old_dir, new_dir) + SIGNAL_HANDLER + if(old_dir != new_dir) + qdel(src) + +/// Knocked down, or gone. +/datum/gorilla_thrust/proc/on_lost(datum/source) + SIGNAL_HANDLER + qdel(src) + +/datum/gorilla_thrust/proc/finish() + end_timer = null + qdel(src) + +/** + * [bearer] throws a piston punch at [zone] of [target] with the arm on [arm_zone]: the fist draws back and drives out + * onto the part, the body lunging behind it, and comes back to rest. Only the picture. Returns how long the fist takes + * to land, for the blow to wait on: the same for every punch. A bearer who can't be drawn that way (lying, turned or + * resized, something huge worn, a target that isn't straight ahead) lunges as tg has them lunge. + */ +/proc/gorilla_thrust(mob/living/carbon/human/bearer, atom/movable/target, arm_zone, zone) + if(!gorilla_thrust_arm(bearer, target, arm_zone, zone)) + bearer.do_attack_animation(target) + return GORILLA_THRUST_LANDS + +/// Draws gorilla_thrust()'s arm and lunge. Returns TRUE, or FALSE if it can't be drawn. +/proc/gorilla_thrust_arm(mob/living/carbon/human/bearer, atom/movable/target, arm_zone, zone) + if(!ishuman(bearer) || !ismovable(target) || QDELETED(target) || !isturf(bearer.loc)) + return FALSE + if(bearer.body_position == LYING_DOWN || !(bearer.dir in GLOB.cardinals) || bearer.mob_height != HUMAN_HEIGHT_MEDIUM) + return FALSE + // The arm is thrown the way the bearer faces. A target a corner away, or on the bearer's own tile, isn't there + if(get_turf(target) != get_step(bearer.loc, bearer.dir)) + return FALSE + // Faded (a camo field, a cloak): a puppet would be an arm in plain sight + if(bearer.alpha < 255 || bearer.invisibility) + return FALSE + var/matrix/own = bearer.transform + if(own && (own.a != 1 || own.b || own.c || own.d || own.e != 1 || own.f)) + return FALSE + // One punch drawn at a time + if(bearer.gorilla_thrust) + qdel(bearer.gorilla_thrust) + var/list/point = gorilla_fist_target(bearer, target, zone) + var/datum/gorilla_arm_look/look = point && gorilla_arm_look(bearer) + var/datum/chrome_rig/rig = look?.rig + if(isnull(rig)) + return FALSE + var/facing = rig.facing + var/side = arm_zone == BODY_ZONE_L_ARM ? "l" : "r" + // A picture no client has drawn yet may reach one late. The real arm stays on show under its puppet for the beat the + // fist would have drawn back in, and the fist is driven straight out in what is left: it lands when it always does + var/hold = look.shown[side] ? 0 : GORILLA_THRUST_HOLD + look.shown[side] = TRUE + + // The poses: drawn back, then out onto the part + var/list/way = chrome_swing_way(facing) + var/list/back + var/out_angle + var/tip = GORILLA_THRUST_TIP + switch(facing) + if(EAST, WEST) + back = rig.pose_of(side, -45, -2) + out_angle = 90 + // Into the punch, as tg's lunge tips them + tip *= facing == EAST ? 1 : -1 + if(NORTH) + back = rig.pose_of(side, 60, -3) + out_angle = 174 + // The punching shoulder goes forward + tip *= side == "r" ? -1 : 1 + else + back = rig.pose_of(side, 60, -3) + out_angle = 12 + tip *= side == "r" ? -1 : 1 + var/list/reach = chrome_swing_reach(rig, side, point[1], point[2], way, GORILLA_THRUST_LUNGE_MIN, (facing & (EAST|WEST)) ? GORILLA_THRUST_LUNGE_MAX : GORILLA_SWING_STEP_UPRIGHT, tip, GORILLA_SWING_EASY_LENGTH, GORILLA_SWING_MAX_LENGTH, out_angle * rig.raise_sign(side)) + var/lunge = reach[1] + var/list/out = list(reach[2], reach[3]) + + // The layers. Seen from the side the near arm is over everything and the far one under its own body. Facing away + // the thrown arm passes behind its own head; facing the viewer it is drawn back behind its own shoulder + var/over = bearer.layer + 0.01 + var/under = bearer.layer - 0.01 + var/datum/gorilla_thrust/thrust = new(bearer) + var/obj/effect/abstract/chrome_puppet/arm + // The body leans back a pixel as the fist draws back (or waits, the first time). The fist is out a moment before the + // blow is due and stays there a moment after it + var/datum/chrome_swing_beat/back_beat = new(hold || GORILLA_THRUST_BACK, CHROME_SWING_LINEAR, -way[1], -way[2]) + var/datum/chrome_swing_beat/out_beat = new(GORILLA_THRUST_BACK + GORILLA_THRUST_OUT - back_beat.time, CHROME_SWING_LINEAR, way[1] * lunge, way[2] * lunge, tip) + var/datum/chrome_swing_beat/dwell_beat = new(GORILLA_THRUST_DWELL, CHROME_SWING_LINEAR, way[1] * lunge, way[2] * lunge, tip) + var/datum/chrome_swing_beat/rest_beat = new(GORILLA_THRUST_REST, CHROME_SWING_EASE_IN_OUT) + if(!hold) + back_beat.arm(side, back) + switch(facing) + if(EAST, WEST) + arm = thrust.stand(look.arm_picture(side), rig.behind_body(side) ? under : max(bearer.layer, target.layer) + 0.01) + out_beat.arm(side, out) + rest_beat.arm(side, list(0, 1)) + if(NORTH) + arm = thrust.stand(look.arm_picture(side), over) + out_beat.arm(side, out, under) + rest_beat.arm(side, list(0, 1)) + rest_beat.layer_once_under = list() + rest_beat.layer_once_under[side] = list(120, over) + else + arm = thrust.stand(look.arm_picture(side), under) + out_beat.arm(side, out, over) + rest_beat.arm(side, list(0, 1)) + var/icon/fill_picture = look.fill_picture(side) + var/obj/effect/abstract/chrome_puppet/fill = fill_picture ? thrust.stand(fill_picture, bearer.layer - 0.005) : null + + var/list/beats = list(back_beat, out_beat, dwell_beat, rest_beat) + // The real arm goes: at once, or when the hold is over by the client's own clock, in step with the puppet. The + // mask starts off to one side of the body, where it cuts nothing. Before the lunge, and alongside whatever else is + // moving the bearer: an animation of a filter is one of its owner's, and a new one would end the rest + bearer.add_filter(GORILLA_THRUST_FILTER, 1, alpha_mask_filter(x = hold ? ICON_SIZE_X * 2 : 0, icon = gorilla_arm_mask(facing, side), flags = MASK_INVERSE)) + if(hold) + var/mask = bearer.get_filter(GORILLA_THRUST_FILTER) + if(mask) + animate(mask, x = ICON_SIZE_X * 2, time = hold, flags = ANIMATION_PARALLEL) + animate(x = 0, time = 0) + // A rebuild of the bearer's filters lands on the cut, not the wait + bearer.filter_data[GORILLA_THRUST_FILTER]["x"] = 0 + var/list/arms_from = list() + arms_from[side] = list(0, 1) + var/list/arms = list() + arms[side] = arm + chrome_swing_play(rig, chrome_swing_frames(beats, arms_from), fill ? list(fill) : null, arms, bearer) + play_fov_effect(target, 5, "attack") + thrust.end_timer = addtimer(CALLBACK(thrust, TYPE_PROC_REF(/datum/gorilla_thrust, finish)), GORILLA_THRUST_BACK + GORILLA_THRUST_OUT + GORILLA_THRUST_DWELL + GORILLA_THRUST_REST, TIMER_STOPPABLE | TIMER_DELETE_ME) + return TRUE + +#undef GORILLA_THRUST_FILTER diff --git a/voidcrew/modules/hyperviolence_gorilla/hv_finisher_chrome.dm b/voidcrew/modules/hyperviolence_gorilla/hv_finisher_chrome.dm new file mode 100644 index 00000000000..3783cdc7fdd --- /dev/null +++ b/voidcrew/modules/hyperviolence_gorilla/hv_finisher_chrome.dm @@ -0,0 +1,142 @@ +/** + * # Chrome finishers: #509's finisher engine for a player's bare hands + * + * #509's /datum/hv_finisher was built for bosses with a weapon in hand and NPC factions. A chrome + * finisher (a player's or a boss's own arms) changes four things, and nothing else: + * - No weapon needed: the start and the safety check never ask for one. + * - Anyone can be finished, as with a gun execution: two players share a faction, so the faction test + * only stops an NPC finishing its own side. Players and boss-rank NPCs only (hv_can_execute()). + * - Down means in crit or stunned, never just lying there. A victim whose stun wears off before the + * kill twists free. + * - No red mark over the victim (owner D34): the wind-up is the two bodies. + * - The one doing it can't walk away mid-way: any step lets go. + * + * Kept in its own file so the other chrome finishers (Mantis, monowire) can share it. + */ + +/mob/living + /// The chrome finisher this mob is doing now, if any. + var/datum/hv_finisher/chrome/chrome_finisher + +/datum/hv_finisher/chrome + name = "chrome finisher" + interrupt_damage = GORILLA_FINISHER_INTERRUPT + /// Set when the victim came out of their stun before the kill + var/twisted_free = FALSE + +/datum/hv_finisher/chrome/Destroy() + if(user?.chrome_finisher == src) + user.chrome_finisher = null + return ..() + +/datum/hv_finisher/chrome/start() + . = ..() + if(. && user) + user.chrome_finisher = src + +/datum/hv_finisher/chrome/can_start() + if(QDELETED(user) || user.stat != CONSCIOUS || HAS_TRAIT(user, TRAIT_INCAPACITATED) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED)) + return FALSE + if(HAS_TRAIT(user, TRAIT_PACIFISM) || !user_may_finish()) + return FALSE + if(user.chrome_finisher && user.chrome_finisher != src) + return FALSE + if(!chrome_finisher_valid_victim(user, victim)) + return FALSE + return get_dist(user, victim) <= 1 && user.Adjacent(victim) + +/// Who may do this finisher at all. Players and boss-rank NPCs, as with gun executions; a chrome line can route +/// this through its own gate. +/datum/hv_finisher/chrome/proc/user_may_finish() + return user.hv_can_execute() + +/datum/hv_finisher/chrome/safety_check() + if(QDELETED(user) || user.stat != CONSCIOUS || HAS_TRAIT(user, TRAIT_INCAPACITATED)) + return HV_FINISHER_ATTACKER_DOWN + if(QDELETED(victim)) + return HV_FINISHER_VICTIM_GONE + if(!completed && victim.stat == DEAD) + return HV_FINISHER_VICTIM_GONE + if(!isturf(user.loc) || !isturf(victim.loc) || user.z != victim.z || get_dist(user, victim) > 1) + return HV_FINISHER_LOST_GRIP + if(!victim.has_status_effect(/datum/status_effect/hv_finisher_hold)) + return HV_FINISHER_LOST_GRIP + if(completed) + return 0 + if(HAS_TRAIT(user, TRAIT_HANDS_BLOCKED)) + return HV_FINISHER_ATTACKER_DOWN + if(gripped && (user.pulling != victim || user.grab_state < GRAB_AGGRESSIVE)) + return HV_FINISHER_LOST_GRIP + if(!chrome_finisher_is_down(victim)) + twisted_free = TRUE + return HV_FINISHER_LOST_GRIP + return 0 + +// The one doing it takes a step, is shoved or is thrown: it lets go. The victim moving is #509's rule. +/datum/hv_finisher/chrome/on_moved(datum/source) + SIGNAL_HANDLER + if(source == user && running) + end_early(HV_FINISHER_LOST_GRIP) + return + return ..() + +/datum/hv_finisher/chrome/interrupt(reason) + if(running && !completed && reason == HV_FINISHER_LOST_GRIP && twisted_free && !QDELETED(victim) && !QDELETED(user)) + for(var/datum/hv_finisher_stage/stage as anything in stages) + if(stage.entered) + stage.on_interrupt() + victim.visible_message(span_danger("[victim] twists free of [user]'s grip!"), span_userdanger("You twist free of [user]'s grip!")) + stop(reason) + return + return ..() + +/datum/hv_finisher/chrome/stop(reason) + if(!running) + return + . = ..() + if(user?.chrome_finisher == src) + user.chrome_finisher = null + // Nothing owns a chrome finisher but its own timers, and its stages point back at it: it has to delete + // itself once it is over, or the pair would hold both bodies forever. + if(!QDELETED(src)) + qdel(src) + +/** + * Whether [user] may start a chrome finisher on [victim]: a humanoid body that is alive, in crit or + * stunned, on the floor beside them, not strapped to anything and not already being finished. A player + * can finish anyone, as with a gun execution; an NPC never finishes its own side. + */ +/proc/chrome_finisher_valid_victim(mob/living/user, mob/living/carbon/victim) + if(!iscarbon(victim) || !isliving(user) || QDELETED(victim) || QDELETED(user) || victim == user) + return FALSE + if(!ishuman(victim) && !(victim.mob_biotypes & MOB_HUMANOID)) + return FALSE + if(victim.stat == DEAD || HAS_TRAIT(victim, TRAIT_GODMODE)) + return FALSE + if(!chrome_finisher_is_down(victim)) + return FALSE + if(victim.has_status_effect(/datum/status_effect/hv_finisher_hold)) + return FALSE + if(victim.buckled || !isturf(victim.loc) || !isturf(user.loc) || victim.z != user.z) + return FALSE + // An NPC (anything run by an AI) never finishes its own side + if(user.ai_controller && user.faction_check_atom(victim)) + return FALSE + return TRUE + +/// Down, for a chrome finisher: in crit, or stunned. Lying there isn't enough. +/proc/chrome_finisher_is_down(mob/living/victim) + return victim.stat >= SOFT_CRIT || HAS_TRAIT(victim, TRAIT_INCAPACITATED) + +/** + * Whether [victim] is square on to [user]: straight north, south, east or west, never on a corner. The + * Gorilla finishers and the Mantis scissor draw both bodies along one straight line, so they only start + * square on; from a corner the click is an ordinary blow and the bearer steps round to finish. + */ +/proc/finisher_square_on(atom/user, atom/victim) + return (get_dir(user, victim) in GLOB.cardinals) + +/// Whether [victim] has ended up on a corner from [user] mid-move: dragged there or the like. The rigs above +/// can't draw that, so it lets go. The same tile is fine (the clap brings the body in). +/proc/finisher_on_corner(atom/user, atom/victim) + return (get_dir(user, victim) in GLOB.diagonals) diff --git a/voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore.dmi b/voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore.dmi new file mode 100644 index 00000000000..e1886ca097d Binary files /dev/null and b/voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore.dmi differ diff --git a/voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore_large.dmi b/voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore_large.dmi new file mode 100644 index 00000000000..9da1856f484 Binary files /dev/null and b/voidcrew/modules/hyperviolence_gorilla/icons/gorilla_gore_large.dmi differ diff --git a/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_backbreaker.ogg b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_backbreaker.ogg new file mode 100644 index 00000000000..cb6e3ddfb17 Binary files /dev/null and b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_backbreaker.ogg differ diff --git a/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_haymaker.ogg b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_haymaker.ogg new file mode 100644 index 00000000000..cae44544ff7 Binary files /dev/null and b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_haymaker.ogg differ diff --git a/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch.ogg b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch.ogg new file mode 100644 index 00000000000..7bd87514966 Binary files /dev/null and b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch.ogg differ diff --git a/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch2.ogg b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch2.ogg new file mode 100644 index 00000000000..8f721e72461 Binary files /dev/null and b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch2.ogg differ diff --git a/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch3.ogg b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch3.ogg new file mode 100644 index 00000000000..ba7bd00f79d Binary files /dev/null and b/voidcrew/modules/hyperviolence_gorilla/sound/gorilla_piston_punch3.ogg differ diff --git a/voidcrew/modules/lich/lich_thrall.dm b/voidcrew/modules/lich/lich_thrall.dm index 00d8117386b..ba1e9aec77e 100644 --- a/voidcrew/modules/lich/lich_thrall.dm +++ b/voidcrew/modules/lich/lich_thrall.dm @@ -370,6 +370,8 @@ continue // Ilthuun and his garrison if(candidate.has_status_effect(/datum/status_effect/lich_thrall)) continue + if(cyberware_camo_hides(candidate, owner)) // optical camo (cyberware_stealth.dm) + continue var/score = get_dist(owner, candidate) if(candidate.client) diff --git a/voidcrew/modules/loot/themes/armory.dm b/voidcrew/modules/loot/themes/armory.dm index 0e2b164afe7..4e76fe20567 100644 --- a/voidcrew/modules/loot/themes/armory.dm +++ b/voidcrew/modules/loot/themes/armory.dm @@ -8,6 +8,8 @@ // Cyberware: chrome a garrison would have issued rather than bought, light // weave and knuckle plate on the line, and in the back room the ceramic // plating, the targeting optics and the frame that stops a limb coming off. +// The governor and rage-core lines ride here too: the taped-over street +// models on the line, the surplus service models in the back room. // TODO: review/balance-pass all four tiers: first-draft weights and // contents, never playtested. Tune against the outfitter armor/gun prices // in theme_skus. @@ -140,6 +142,15 @@ /datum/shop_sku/ripperdoc/slabskin, /datum/shop_sku/ripperdoc/deadeye, /datum/shop_sku/ripperdoc/atlas, + /datum/shop_sku/ripperdoc/governor_street, + /datum/shop_sku/ripperdoc/governor_milspec, + /datum/shop_sku/ripperdoc/redline_street, + /datum/shop_sku/ripperdoc/redline_milspec, + /datum/shop_sku/ripperdoc/cuffer_wrists, + /datum/shop_sku/ripperdoc/muffler_ear, + /datum/shop_sku/ripperdoc/hardweave, + /datum/shop_sku/ripperdoc/deadeye_milspec, + /datum/shop_sku/ripperdoc/lookout, ) loot_common = list( /obj/item/clothing/suit/armor/vest = 10, @@ -152,6 +163,10 @@ /obj/item/clothing/mask/balaclava = 4, // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/strength = 3, + // guard-post chrome: faster hands with the cuffs, and an ear that + // shuts out a flashbang + /obj/item/organ/cyberimp/cyberware/cuffer_wrists = 4, + /obj/item/organ/cyberimp/cyberware/muffler_ear = 4, ) loot_uncommon = list( /obj/item/clothing/suit/armor/bulletproof = 10, @@ -163,6 +178,11 @@ /obj/item/ship_parts/combat = 7, // Issue chrome: subdermal impact weave. /obj/item/organ/cyberimp/cyberware/dermal_mesh = 4, + // a patched limiter and a cheap rage core, both off a deserter + /obj/item/organ/cyberimp/cyberware/governor_delete/street = 2, + /obj/item/organ/cyberimp/cyberware/redline/street = 2, + // the heavier issue weave + /obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave = 3, ) loot_prime = list( /obj/item/clothing/suit/armor/vest/marine = 9, @@ -178,6 +198,12 @@ /obj/item/organ/cyberimp/cyberware/atlas = 2, // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/quick_recovery = 1, + // surplus service chrome with the unit numbers still on it + /obj/item/organ/cyberimp/cyberware/governor_delete/milspec = 2, + /obj/item/organ/cyberimp/cyberware/redline/milspec = 2, + // the service optics + /obj/item/organ/eyes/robotic/cyberware/deadeye/milspec = 2, + /obj/item/organ/eyes/robotic/cyberware/lookout = 2, ) // One-of-a-kind authored prizes, drawn as the fourth tier from any // band (weight = how shallow the item used to sit: 3 was reachable diff --git a/voidcrew/modules/loot/themes/expedition.dm b/voidcrew/modules/loot/themes/expedition.dm index 998f18b4288..24b2223ffa5 100644 --- a/voidcrew/modules/loot/themes/expedition.dm +++ b/voidcrew/modules/loot/themes/expedition.dm @@ -42,6 +42,13 @@ /datum/shop_sku/ripperdoc/angler, /datum/shop_sku/ripperdoc/prospector, /datum/shop_sku/ripperdoc/hopper, + /datum/shop_sku/ripperdoc/frostline, + /datum/shop_sku/ripperdoc/spyglass, + /datum/shop_sku/ripperdoc/assay_optics, + /datum/shop_sku/ripperdoc/hopper_street, + /datum/shop_sku/ripperdoc/rockjaw_deepcore, + /datum/shop_sku/ripperdoc/longsight, + /datum/shop_sku/ripperdoc/hopper_milspec, ) loot_common = list( /obj/item/clothing/suit/hooded/explorer = 10, @@ -57,6 +64,10 @@ /obj/item/organ/cyberimp/cyberware/shock_coils = 4, // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/geladikinesis = 3, + // a cold lining for the ice worlds, and cheap eyes that see a long way + /obj/item/organ/cyberimp/cyberware/frostline = 3, + /obj/item/organ/eyes/robotic/cyberware/spyglass = 3, + /obj/item/organ/eyes/robotic/cyberware/prospector/street = 3, ) loot_uncommon = list( /obj/item/gun/energy/recharge/kinetic_accelerator = 10, @@ -76,6 +87,11 @@ /obj/item/dnainjector/loot/olfaction = 3, /obj/item/dnainjector/loot/farsight = 2, /obj/item/dnainjector/loot/cold_adaptation = 2, + // claim chrome a step up: calf springs, the heavy drill fist and long + // optics + /obj/item/organ/cyberimp/cyberware/hopper/street = 3, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore = 3, + /obj/item/organ/eyes/robotic/cyberware/longsight = 2, ) loot_prime = list( /obj/item/borg/upgrade/modkit/range = 9, @@ -91,6 +107,8 @@ /obj/item/organ/cyberimp/cyberware/hopper = 2, // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/pressure_adaptation = 1, + // the survey team's jump pistons + /obj/item/organ/cyberimp/cyberware/hopper/milspec = 2, ) // One-of-a-kind authored prizes, drawn as the fourth tier from any // band (weight = how shallow the item used to sit: 3 was reachable diff --git a/voidcrew/modules/loot/themes/industrial.dm b/voidcrew/modules/loot/themes/industrial.dm index 6fae89d3e02..d860708cfad 100644 --- a/voidcrew/modules/loot/themes/industrial.dm +++ b/voidcrew/modules/loot/themes/industrial.dm @@ -8,7 +8,8 @@ // (see cave_entrance.dm): industrial plant equipment, uncommon-tier. // - cyberware: shop-floor chrome, the kind a plant fits to keep a line // running, omnitool fingers, then the coolant lattice for hot work and -// the myomer arms that pull a dead airlock open. +// the myomer arms that pull a dead airlock open. The cheap myomer pair +// is a yellow melee extra, the real Gorilla Arms a red one. // TODO: review/balance-pass all four tiers: first-draft weights and // contents, never playtested. Tune against outpost shop material prices and // the Boffin stall parts SKUs in theme_skus. @@ -26,6 +27,9 @@ ), ) melee_extras = list( + LOOT_WEAPON_YELLOW = list( + /obj/item/cyberware_pair_case/gorilla_arms/street = 1, + ), LOOT_WEAPON_RED = list( /obj/item/cyberware_pair_case/gorilla_arms = 1, ), @@ -41,6 +45,10 @@ /datum/shop_sku/ripperdoc/fixers, /datum/shop_sku/ripperdoc/coolant, /datum/shop_sku/ripperdoc/gorilla, + /datum/shop_sku/ripperdoc/coolant_street, + /datum/shop_sku/ripperdoc/fixers_street, + /datum/shop_sku/ripperdoc/atlas_street, + /datum/shop_sku/ripperdoc/gorilla_street, ) loot_common = list( /obj/item/stack/sheet/iron/fifty = 10, @@ -57,6 +65,9 @@ /obj/item/stack/sheet/plasteel/twenty = 4, // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/rock_eater = 3, + // line-worker chrome: a heat-sink lining and loose fingertip tools + /obj/item/organ/cyberimp/cyberware/coolant/street = 3, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street = 4, ) loot_uncommon = list( /obj/item/stack/sheet/mineral/titanium/fifty = 8, @@ -79,6 +90,8 @@ // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/heat_adaptation = 2, /obj/item/dnainjector/loot/insulated = 3, + // a loader's strut frame + /obj/item/organ/cyberimp/cyberware/atlas/street = 3, ) loot_prime = list( /obj/item/stack/sheet/plasteel/fifty = 9, diff --git a/voidcrew/modules/loot/themes/medical.dm b/voidcrew/modules/loot/themes/medical.dm index 3d152ec9ea7..7b9bd79fd7e 100644 --- a/voidcrew/modules/loot/themes/medical.dm +++ b/voidcrew/modules/loot/themes/medical.dm @@ -34,6 +34,9 @@ /datum/shop_sku/ripperdoc/hemoglass, /datum/shop_sku/ripperdoc/dead_channel, /datum/shop_sku/ripperdoc/lazarus, + /datum/shop_sku/ripperdoc/clotter_node, + /datum/shop_sku/ripperdoc/medic_palms, + /datum/shop_sku/ripperdoc/second_wind_deep, ) loot_common = list( /obj/item/storage/medkit/regular = 10, @@ -53,6 +56,9 @@ /obj/item/organ/cyberimp/cyberware/gastro = 4, // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/stimmed = 3, + // clinic chrome: a clotting node and a medic's sensor palms + /obj/item/organ/cyberimp/cyberware/clotter_node = 4, + /obj/item/organ/cyberimp/cyberware/medic_palms = 3, ) loot_uncommon = list( /obj/item/storage/medkit/advanced = 10, @@ -79,6 +85,8 @@ // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/hypermetabolic = 3, /obj/item/dnainjector/loot/plasmocile = 2, + // the long-shift air bladder + /obj/item/organ/cyberimp/cyberware/second_wind/deep = 3, ) loot_prime = list( /obj/item/reagent_containers/hypospray/medipen/atropine = 7, diff --git a/voidcrew/modules/loot/themes/plunder.dm b/voidcrew/modules/loot/themes/plunder.dm index d0cc0e26036..313898b55d4 100644 --- a/voidcrew/modules/loot/themes/plunder.dm +++ b/voidcrew/modules/loot/themes/plunder.dm @@ -6,7 +6,9 @@ // crews. // Cyberware: boarding chrome, and it reads as taken off somebody rather than // bought, grip pads at uncommon, and in the treasure the blade pair, the -// folding machine-pistol and the rocket pod. +// folding machine-pistol and the rocket pod. The cheap shiv pair is a yellow +// melee extra, the heat-sunk blade pair a red one beside the Mantis, and the +// holdout revolver arm a yellow gun extra. // TODO: review/balance-pass all four tiers: first-draft weights and // contents, never playtested. // ========================================================================= @@ -22,6 +24,7 @@ /obj/item/gun/ballistic/revolver/mateba = 1, /obj/item/gun/ballistic/shotgun/musket/no_quarter = 1, /obj/item/gun/magic/hook/marlinspike = 1, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout = 1, ), LOOT_WEAPON_RED = list( /obj/item/gun/ballistic/shotgun/automatic/combat = 1, @@ -30,9 +33,13 @@ ), ) melee_extras = list( + LOOT_WEAPON_YELLOW = list( + /obj/item/cyberware_pair_case/mantis_street = 1, + ), LOOT_WEAPON_RED = list( /obj/item/claymore/cutlass/parley = 1, /obj/item/cyberware_pair_case/mantis_blades = 1, + /obj/item/cyberware_pair_case/mantis_scorch = 1, /obj/item/heave_ho = 1, ), ) @@ -41,8 +48,11 @@ /datum/shop_sku/black_market/rotating/mateba, /datum/shop_sku/ripperdoc/gecko, /datum/shop_sku/ripperdoc/mantis, + /datum/shop_sku/ripperdoc/mantis_street, + /datum/shop_sku/ripperdoc/mantis_scorch, /datum/shop_sku/ripperdoc/ronin, /datum/shop_sku/ripperdoc/bunker_buster, + /datum/shop_sku/ripperdoc/ronin_holdout, ) loot_common = list( /obj/item/stack/spacecash/c100 = 10, diff --git a/voidcrew/modules/loot/themes/research.dm b/voidcrew/modules/loot/themes/research.dm index 5ab110ccda4..ad8cc8e3a2b 100644 --- a/voidcrew/modules/loot/themes/research.dm +++ b/voidcrew/modules/loot/themes/research.dm @@ -36,6 +36,9 @@ theme_skus = list( /datum/shop_sku/ripperdoc/doppler, /datum/shop_sku/ripperdoc/rigger, + /datum/shop_sku/ripperdoc/doppler_street, + /datum/shop_sku/ripperdoc/longsight, + /datum/shop_sku/ripperdoc/lookout, ) loot_common = list( /obj/item/storage/box/beakers = 10, @@ -64,6 +67,9 @@ // lab hardware worn instead of carried: a sonar transceiver socketed // into the bone behind the ear, reading movement through walls /obj/item/organ/cyberimp/cyberware/doppler = 3, + // a cheaper sonar ear, and survey optics off the long-range bench + /obj/item/organ/cyberimp/cyberware/doppler/street = 3, + /obj/item/organ/eyes/robotic/cyberware/longsight = 2, ) loot_prime = list( /obj/item/stack/ore/bluespace_crystal/refined = 10, @@ -87,6 +93,8 @@ // the annex's own interface work: a skull jack that flies a ship from // anywhere aboard it, as long as the hull still has a helm console /obj/item/organ/cyberimp/cyberware/rigger = 2, + // the observation post's eyes + /obj/item/organ/eyes/robotic/cyberware/lookout = 2, // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/thermal_vision = 3, /obj/item/dnainjector/loot/cryokinesis = 2, diff --git a/voidcrew/modules/loot/themes/syndicate.dm b/voidcrew/modules/loot/themes/syndicate.dm index fb0fe4ef730..f271f7b6cc5 100644 --- a/voidcrew/modules/loot/themes/syndicate.dm +++ b/voidcrew/modules/loot/themes/syndicate.dm @@ -9,6 +9,11 @@ // Cyberware rides the same two channels: the parlor's smuggling cavity and // door spike sit at uncommon, and the three voucher-only pieces an operative // would carry (cloak weave, wire, reflex shunt) sit at the bottom of prime. +// The camo and reflex lines follow the same split: the street weave and the +// taped reflex rig at uncommon, the service lattice in prime, and the live +// wire beside the plain one in the red melee extras. The chrome added with the +// cyberware lines sits at about half the weight of the older entries, so the +// syndicate tables stay mostly guns, gear and contraband. // ========================================================================= /datum/loot_theme/syndicate @@ -32,6 +37,7 @@ LOOT_WEAPON_RED = list( /obj/item/knife/understudy = 1, /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire = 1, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live = 1, ), ) guard_themes = list(/obj/effect/zone_mobs/syndicate, /obj/effect/zone_mobs/syndicate/boss) @@ -47,6 +53,14 @@ /datum/shop_sku/ripperdoc/slipwire, /datum/shop_sku/ripperdoc/monowire, /datum/shop_sku/ripperdoc/ghostskin, + /datum/shop_sku/ripperdoc/ghostskin_street, + /datum/shop_sku/ripperdoc/cascade_street, + /datum/shop_sku/ripperdoc/cascade_milspec, + /datum/shop_sku/ripperdoc/monowire_live, + /datum/shop_sku/ripperdoc/subvocal_mic, + /datum/shop_sku/ripperdoc/slipwire_street, + /datum/shop_sku/ripperdoc/adrenal_pump, + /datum/shop_sku/ripperdoc/slipwire_milspec, ) loot_common = list( /obj/item/soap/syndie = 10, @@ -56,6 +70,8 @@ /obj/item/encryptionkey/syndicate = 6, /obj/item/grenade/empgrenade = 5, /obj/item/storage/medkit/tactical = 4, + // a throat mic nobody nearby hears + /obj/item/organ/cyberimp/cyberware/subvocal_mic = 2, ) loot_uncommon = list( /obj/item/grenade/c4 = 6, @@ -71,6 +87,12 @@ // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/mind_reader = 2, /obj/item/dnainjector/loot/anti_glow = 2, + // knockoff operative chrome: a patchy camo weave and a taped reflex rig + /obj/item/organ/cyberimp/cyberware/ghostskin/street = 2, + /obj/item/organ/cyberimp/cyberware/cascade/street = 1, + // street operative chrome: a twitchy reflex shunt and an adrenal pump + /obj/item/organ/cyberimp/cyberware/slipwire/street = 2, + /obj/item/organ/cyberimp/cyberware/adrenal_pump = 2, ) loot_prime = list( /obj/item/pen/sleepy = 4, @@ -79,6 +101,9 @@ // Operative chrome: the reflex shunt and refraction weave. /obj/item/organ/cyberimp/cyberware/slipwire = 3, /obj/item/organ/cyberimp/cyberware/ghostskin = 2, + /obj/item/organ/cyberimp/cyberware/cascade/milspec = 1, + // the boarding team's shunt + /obj/item/organ/cyberimp/cyberware/slipwire/milspec = 1, ) // One-of-a-kind authored prizes, drawn as the fourth tier from any // band (weight = how shallow the item used to sit: 3 was reachable @@ -105,28 +130,28 @@ name = "zone mob spawner (syndicate)" wave_pod_style = /datum/pod_style/syndicate mobs_green = list( - /mob/living/basic/trooper/syndicate/melee = 14, + /mob/living/carbon/human/npc/ruin/trooper/syndicate = 14, ) mobs_yellow = list( - /mob/living/basic/trooper/syndicate/melee/sword = 8, - /mob/living/basic/trooper/syndicate/ranged = 12, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/sword = 8, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner = 12, ) mobs_red = list( - /mob/living/basic/trooper/syndicate/ranged/smg = 8, - /mob/living/basic/trooper/syndicate/ranged/shotgun = 6, - /mob/living/basic/trooper/syndicate/melee/sword = 5, - /mob/living/basic/trooper/syndicate/ranged/smg/space/stormtrooper = 2, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg = 8, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/shotgun = 6, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/sword = 5, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper = 2, ) /obj/effect/zone_mobs/syndicate/boss name = "zone mob spawner (syndicate boss)" mobs_green = list( - /mob/living/basic/trooper/syndicate/melee = 1, + /mob/living/carbon/human/npc/ruin/trooper/syndicate = 1, ) mobs_yellow = list( - /mob/living/basic/trooper/syndicate/ranged = 2, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner = 2, ) mobs_red = list( - /mob/living/basic/trooper/syndicate/ranged/smg/space/stormtrooper = 1, - /mob/living/basic/trooper/syndicate/ranged/shotgun/space/stormtrooper = 1, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper = 1, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper/shotgun = 1, ) diff --git a/voidcrew/modules/loot/themes/wardrobe.dm b/voidcrew/modules/loot/themes/wardrobe.dm index 35dc5bede0e..abdec557e70 100644 --- a/voidcrew/modules/loot/themes/wardrobe.dm +++ b/voidcrew/modules/loot/themes/wardrobe.dm @@ -32,6 +32,7 @@ theme_skus = list( /datum/shop_sku/ripperdoc/chromatic_dermis, /datum/shop_sku/ripperdoc/nightshade, + /datum/shop_sku/ripperdoc/spyglass, ) loot_common = list( /obj/item/clothing/suit/jacket/leather = 10, @@ -51,6 +52,8 @@ // gene injector loot (gene_injectors.dm) /obj/item/dnainjector/loot/glowy = 3, /obj/item/dnainjector/loot/gigantism = 2, + // cheap zoom eyes, bought for the look as much as the view + /obj/item/organ/eyes/robotic/cyberware/spyglass = 3, ) loot_uncommon = list( /obj/item/clothing/suit/jacket/leather/biker = 10, diff --git a/voidcrew/modules/loot/zone_mobs.dm b/voidcrew/modules/loot/zone_mobs.dm index bc2b62e4edc..2be63404698 100644 --- a/voidcrew/modules/loot/zone_mobs.dm +++ b/voidcrew/modules/loot/zone_mobs.dm @@ -134,5 +134,8 @@ // A wave never lands a pod or digs up under someone's feet if(tile.is_blocked_turf(exclude_mobs = !wave)) continue + // Nor drops one into lava, water or a pit + if(wave && (islava(tile) || ischasm(tile) || istype(tile, /turf/open/water))) + continue result += tile return result diff --git a/voidcrew/modules/mantis_gore/icons/mantis_artery.dmi b/voidcrew/modules/mantis_gore/icons/mantis_artery.dmi new file mode 100644 index 00000000000..8732265b3a0 Binary files /dev/null and b/voidcrew/modules/mantis_gore/icons/mantis_artery.dmi differ diff --git a/voidcrew/modules/mantis_gore/icons/mantis_gore.dmi b/voidcrew/modules/mantis_gore/icons/mantis_gore.dmi new file mode 100644 index 00000000000..abb47b51618 Binary files /dev/null and b/voidcrew/modules/mantis_gore/icons/mantis_gore.dmi differ diff --git a/voidcrew/modules/mantis_gore/icons/mantis_gore_large.dmi b/voidcrew/modules/mantis_gore/icons/mantis_gore_large.dmi new file mode 100644 index 00000000000..39c504a9b18 Binary files /dev/null and b/voidcrew/modules/mantis_gore/icons/mantis_gore_large.dmi differ diff --git a/voidcrew/modules/mantis_gore/icons/mantis_gore_reach.dmi b/voidcrew/modules/mantis_gore/icons/mantis_gore_reach.dmi new file mode 100644 index 00000000000..2b66dba06d8 Binary files /dev/null and b/voidcrew/modules/mantis_gore/icons/mantis_gore_reach.dmi differ diff --git a/voidcrew/modules/mantis_gore/icons/mantis_lefthand.dmi b/voidcrew/modules/mantis_gore/icons/mantis_lefthand.dmi new file mode 100644 index 00000000000..263155493f3 Binary files /dev/null and b/voidcrew/modules/mantis_gore/icons/mantis_lefthand.dmi differ diff --git a/voidcrew/modules/mantis_gore/icons/mantis_righthand.dmi b/voidcrew/modules/mantis_gore/icons/mantis_righthand.dmi new file mode 100644 index 00000000000..6d528bd0a56 Binary files /dev/null and b/voidcrew/modules/mantis_gore/icons/mantis_righthand.dmi differ diff --git a/voidcrew/modules/mantis_gore/icons/mantis_swing.dmi b/voidcrew/modules/mantis_gore/icons/mantis_swing.dmi new file mode 100644 index 00000000000..6ea7bf69677 Binary files /dev/null and b/voidcrew/modules/mantis_gore/icons/mantis_swing.dmi differ diff --git a/voidcrew/modules/mantis_gore/mantis_blade.dm b/voidcrew/modules/mantis_gore/mantis_blade.dm new file mode 100644 index 00000000000..d625a5a3fbf --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_blade.dm @@ -0,0 +1,382 @@ +// The blade side of the Mantis line's gore: what a landed cut does to the body (arterial gashes, the +// X-slash), the held poses, the glint, and blood on the blade. See mantis_core.dm for the overview. + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis + // tg's energy weapons refuse blood. This one takes it, and shows it in the hand. + item_flags = NONE + /// What this blade can do beyond cutting: MANTIS_MOVE_* flags. + var/gore_moves = MANTIS_MOVES_ALL + /// The wound a torn arm or leg artery is. + var/artery_wound_type = /datum/wound/slash/flesh/critical/hv_carotid/limb + /// The held pose: MANTIS_POSE_*. The held sprite is "[base_icon_state]_[mantis_pose]". + var/mantis_pose = MANTIS_POSE_GUARD + /// The housing that made this blade. + var/datum/weakref/housing_ref + /// The wielder of the swing being resolved, while it resolves. + var/datum/weakref/cut_wielder + /// Until this world.time the blade drips. + var/drenched_until = 0 + /// Until this world.time the blade is drawn soaked, not just bloodied. + var/soaked_until = 0 + /// Drops it can still leave from this drench. + var/drips_left = 0 + /// Timer of the next drop. + var/drip_timer + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/Destroy() + if(drip_timer) + deltimer(drip_timer) + drip_timer = null + housing_ref = null + cut_wielder = null + return ..() + +// ---- The models ---------------------------------------------------------- + +// The Shiv only bleeds people: no torn arteries, no X-slash, no scissor (owner D34). It still takes +// blood and holds the guard. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street + gore_moves = NONE + +// The Scorch's cuts burn and half-seal what they open, and the heat keeps the blade clean. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch + item_flags = NO_BLOOD_ON_ITEM + artery_wound_type = /datum/wound/slash/flesh/critical/hv_carotid/limb/seared + +// ========================================================================= +// THE CUT +// ========================================================================= + +/// Whether this swing is not a cut at all: the bearer is busy finishing someone, or it starts the scissor. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_swing_taken(mob/living/target, mob/living/user) + if(!isliving(user) || !isliving(target)) + return FALSE + // The blades are already at someone's neck. + if(user.has_status_effect(/datum/status_effect/hv_finishing)) + return TRUE + return mantis_try_scissor(target, user) + +/// Listens to [target] while this blade's swing resolves on them. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_watch_cut(mob/living/target, mob/living/user) + if(!isliving(target) || !isliving(user) || target == user) + return + cut_wielder = WEAKREF(user) + RegisterSignal(target, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(on_cut_damage_pre), override = TRUE) + RegisterSignal(target, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_cut_damage), override = TRUE) + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_unwatch_cut(mob/living/target) + cut_wielder = null + if(isliving(target)) + UnregisterSignal(target, list(COMSIG_MOB_APPLY_DAMAGE, COMSIG_MOB_AFTER_APPLY_DAMAGE)) + +/// Before the cut lands: a death from it counts as the wielder's kill, and only this blade runs red for it. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/on_cut_damage_pre(mob/living/source, damage_amount, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item, wound_clothing) + SIGNAL_HANDLER + if(attacking_item != src) + return + var/mob/living/user = cut_wielder?.resolve() + if(user) + mantis_note_hit(source, user, list(src)) + +/// The cut has landed, while its attack line is still held: what it does goes into the same message. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/on_cut_damage(mob/living/source, damage_dealt, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item, wound_clothing) + SIGNAL_HANDLER + // The X-slash's follow-through comes from the other blade, so it never counts here. + if(attacking_item != src || damage_dealt <= 0 || damagetype != BRUTE) + return + var/mob/living/user = cut_wielder?.resolve() + if(isnull(user) || QDELETED(source)) + return + mantis_cut_landed(source, user, isbodypart(def_zone) ? def_zone : null, damage_dealt, attack_direction || get_dir(user, source)) + +/// A cut that did damage: the artery count, the scorch seam and the X-slash count. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_cut_landed(mob/living/victim, mob/living/user, obj/item/bodypart/limb, damage, attack_direction) + if(limb && iscarbon(victim)) + // The swing's slash goes on the part it cut (mantis_swing.dm). + mantis_swing_impact_onto(victim, limb.body_zone) + cut_fx(victim, limb) + if(gore_moves & MANTIS_MOVE_ARTERY) + mantis_gash(victim, user, limb, damage, attack_direction) + if(gore_moves & MANTIS_MOVE_XSLASH) + mantis_xslash_count(victim, user, limb, attack_direction) + +/// What a landed cut looks like on the limb, beyond the impact. Nothing for a plain blade. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/cut_fx(mob/living/carbon/victim, obj/item/bodypart/limb) + return + +// The cut sears: a glowing seam across the limb that cools to char, and a hiss. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch/cut_fx(mob/living/carbon/victim, obj/item/bodypart/limb) + mantis_scorch_seam_fx(victim, limb) + playsound(victim, pick('sound/effects/wounds/sizzle1.ogg', 'sound/effects/wounds/sizzle2.ogg'), 40, TRUE) + +// ---- Arterial gashes ---------------------------------------------------- + +/// How many cuts tear the artery of [limb], or 0 if the cover on it never lets them. +/proc/mantis_cuts_to_tear(mob/living/carbon/victim, obj/item/bodypart/limb, armour_penetration) + var/cover = hv_crit_cover_rating(victim, limb, MELEE, armour_penetration) + if(cover >= MANTIS_COVER_STOP) + return 0 + if(cover >= MANTIS_COVER_LIGHT) + return MANTIS_TEAR_CUTS_COVERED + return MANTIS_TEAR_CUTS_BARE + +/// Counts a cut on [limb], and tears its artery when enough have landed. Returns TRUE if it tore. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_gash(mob/living/carbon/victim, mob/living/user, obj/item/bodypart/limb, damage, attack_direction) + if(damage < MANTIS_CUT_MIN_DAMAGE || victim.stat == DEAD || limb.owner != victim || !limb.can_bleed()) + return FALSE + if(!user.hv_can_land_aimed_crits()) + return FALSE + var/needed = mantis_cuts_to_tear(victim, limb, armour_penetration) + if(!needed) + return FALSE + var/datum/status_effect/mantis_cuts/cuts = victim.has_status_effect(/datum/status_effect/mantis_cuts) + if(isnull(cuts) || cuts.add_cut(limb.body_zone) < needed) + return FALSE + cuts.clear_cuts(limb.body_zone) + return mantis_tear_artery(victim, user, limb, attack_direction) + +/// What the torn artery of [limb] is: the throat and the aorta are #509's own wounds. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/artery_wound_for(obj/item/bodypart/limb) + switch(limb.body_zone) + if(BODY_ZONE_HEAD) + return /datum/wound/slash/flesh/critical/hv_carotid + if(BODY_ZONE_CHEST) + return /datum/wound/pierce/bleed/critical/hv_aorta + return artery_wound_type + +/// Where the artery of [limb] is, as the line names it. +/proc/mantis_artery_place(obj/item/bodypart/limb) + return limb.body_zone == BODY_ZONE_HEAD ? "neck" : limb.plaintext_zone + +/// Tears the artery of [limb]. Returns TRUE if it tore. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_tear_artery(mob/living/carbon/victim, mob/living/user, obj/item/bodypart/limb, attack_direction) + // A sealed helmet or an armoured collar still saves the throat, as it does from #509's slit throat. + if(limb.body_zone == BODY_ZONE_HEAD) + var/datum/hv_crit/throat/throat = locate() in GLOB.hv_crits + if(throat?.blocked_on_carbon(victim, limb, src)) + return FALSE + var/datum/wound/wound_type = artery_wound_for(limb) + var/datum/wound_pregen_data/pregen = GLOB.all_wound_pregen_data[wound_type] + if(!pregen?.can_be_applied_to(limb, list(WOUND_SLASH))) + return FALSE + // The throat's and the aorta's wounds are #509's and tg's: given the cut's direction they throw tg's wound + // spray along it, a line of blood three tiles long. The tear throws its own drops instead, so they get none. + var/own_wound = ispath(wound_type, /datum/wound/slash/flesh/critical/hv_carotid/limb) + var/datum/wound/torn = hv_crit_apply_wound(limb, wound_type, own_wound ? attack_direction : null, src) + if(!torn) + return FALSE + var/seared = ispath(artery_wound_type, /datum/wound/slash/flesh/critical/hv_carotid/limb/seared) + var/place = mantis_artery_place(limb) + if(seared) + // The throat and aorta wounds are #509's; the heat closes part of them. + if(!istype(torn, /datum/wound/slash/flesh/critical/hv_carotid/limb)) + torn.adjust_blood_flow(-torn.blood_flow * 0.4) + victim.hv_add_hit_line("[victim]'s [place] is seared open to the artery!", HV_LINE_BOLD, "Your [place] is seared open to the artery!", DEFAULT_MESSAGE_RANGE) + else + victim.hv_add_hit_line("The artery in [victim]'s [place] is cut!", HV_LINE_BOLD, "The artery in your [place] is cut!", DEFAULT_MESSAGE_RANGE) + drench(victim) + // What it looks like: one spurt of drops the way the cut went, then the blood runs down the body. + mantis_spurt_fx(victim, limb.body_zone, attack_direction, seared) + mantis_artery_run_fx(victim, limb.body_zone, torn) + log_combat(user, victim, "tore an artery in", src, "([limb.plaintext_zone])") + return TRUE + +// ---- X-slash ----------------------------------------------------------- + +/// Counts a landed cut toward the X-slash. Every third on one target, with both blades out, is one. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_xslash_count(mob/living/victim, mob/living/user, obj/item/bodypart/limb, attack_direction) + var/datum/mantis_bearer/state = user.get_mantis_state() + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/off_blade + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/held as anything in mantis_held_blades(user, MANTIS_MOVE_XSLASH)) + if(held != src) + off_blade = held + break + if(isnull(off_blade) || !user.hv_can_land_aimed_crits() || victim.stat == DEAD) + state.xslash_count = 0 + return FALSE + if(state.xslash_target?.resolve() != victim || world.time - state.xslash_last > MANTIS_XSLASH_WINDOW) + state.xslash_count = 0 + state.xslash_target = WEAKREF(victim) + state.xslash_last = world.time + state.xslash_count++ + if(state.xslash_count < MANTIS_XSLASH_EVERY) + return FALSE + state.xslash_count = 0 + mantis_xslash(victim, user, off_blade, limb, attack_direction) + return TRUE + +/// The off blade follows through across the first cut, and the target reels. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_xslash(mob/living/victim, mob/living/user, obj/item/melee/energy/blade/hardlight/cyberware_mantis/off_blade, obj/item/bodypart/limb, attack_direction) + var/zone = limb ? limb.body_zone : BODY_ZONE_CHEST + var/place = limb ? limb.plaintext_zone : "body" + // The attack line being held for this hit becomes the crossed slash. + var/datum/hv_hit/hit = victim.hv_hit + if(hit?.others_text && hit.attacker == user) + hit.others_text = "[user] crosses both blades through [victim]'s [place]!" + hit.victim_text = "[user] crosses both blades through your [place]!" + if(hit.attacker_text) + hit.attacker_text = "You cross both blades through [victim]'s [place]!" + victim.hv_add_hit_line("[victim] reels!", HV_LINE_BOLD, "You reel!") + var/armour = victim.run_armor_check(zone, MELEE, armour_penetration = off_blade.armour_penetration, silent = TRUE) + victim.apply_damage( + off_blade.force * 0.5, + BRUTE, + limb || zone, + armour, + wound_bonus = 10, + sharpness = SHARP_EDGED, + attack_direction = attack_direction, + attacking_item = off_blade, + ) + if(!QDELETED(victim)) + victim.set_staggered_if_lower(MANTIS_XSLASH_STAGGER) + mantis_xslash_cross(user, victim, off_blade, zone) + log_combat(user, victim, "x-slashed", src) + +// ========================================================================= +// POSES AND THE GLINT +// ========================================================================= + +/// Puts the held blade in [pose] (MANTIS_POSE_*), or back in the guard if this model has no such pose. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/set_mantis_pose(pose = MANTIS_POSE_GUARD) + var/state = "[base_icon_state]_[pose]" + if(pose != MANTIS_POSE_GUARD && !icon_exists(righthand_file, state)) + pose = MANTIS_POSE_GUARD + state = "[base_icon_state]_[pose]" + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = housing_ref?.resolve() + housing?.set_stance_raise(mantis_stance_raise(pose)) + if(mantis_pose == pose && inhand_icon_state == state) + return + housing?.unfold_overtaken(src) + mantis_pose = pose + inhand_icon_state = state + var/mob/holder = loc + if(ismob(holder)) + holder.update_held_items() + +/// How far the fists ride up in [pose], in pixels. Matches the held sprites. +/proc/mantis_stance_raise(pose) + switch(pose) + if(MANTIS_POSE_RAISE) + return 3 + if(MANTIS_POSE_COIL) + return 1 + return 2 + +/// Puts every blade of [housings] in [pose]. +/proc/mantis_pose_blades(list/housings, pose) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_housing_blades(housings)) + blade.set_mantis_pose(pose) + +/// The hand this blade sits in, as the art names it. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/hand_side() + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = housing_ref?.resolve() + return housing?.zone == BODY_ZONE_L_ARM ? "left" : "right" + +/// A light runs along the edge, if this model has an edge that catches the light in [pose]. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/play_glint(pose = mantis_pose) + var/mob/living/holder = loc + if(!isliving(holder) || !holder.is_holding(src)) + return null + var/state = "[base_icon_state]_[pose]_glint_[hand_side()]" + if(!icon_exists(MANTIS_GORE_ICON, state)) + return null + var/obj/effect/abstract/cyberware_anim/glint = cyberware_anim_play(holder, MANTIS_GORE_ICON, state, MANTIS_ANIM_BLADE_LAYER, 0.3 SECONDS, glow = TRUE) + // Side on, the far blade's light stays behind the near blade. + glint?.sort_as_arm(hand_side()) + return glint + +// ========================================================================= +// BLOOD +// ========================================================================= + +/// Whether there is blood on the blade to show. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/is_bloody() + return !(item_flags & NO_BLOOD_ON_ITEM) && GET_ATOM_BLOOD_DECAL_LENGTH(src) + +/// A kill, a torn artery, a rip, the scissor or the X-slash: the blade runs red with [source]'s blood and drips +/// for a while. Only the blade that did it: the other keeps whatever it had. +/// [light]: the steel that went through is bloodied (the lighter coat), not soaked: the impale and the scissor, +/// so the held blade matches the one the finisher drew. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/drench(mob/living/source, light = FALSE) + if(item_flags & NO_BLOOD_ON_ITEM) + return FALSE + if(isliving(source) && source.can_bleed(BLOOD_COVER_ITEMS) == BLEED_SPLATTER) + add_mob_blood(source) + if(!is_bloody()) + return FALSE + drenched_until = world.time + MANTIS_DRENCH_TIME + if(!light) + soaked_until = drenched_until + drips_left = MANTIS_DRIP_MAX + if(!drip_timer) + drip_timer = addtimer(CALLBACK(src, PROC_REF(drip)), MANTIS_DRIP_INTERVAL, TIMER_STOPPABLE|TIMER_DELETE_ME) + refresh_held() + return TRUE + +/// One drop off the blade onto the floor under its wielder, while it is still drenched. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/drip() + drip_timer = null + if(world.time >= drenched_until || drips_left <= 0 || !is_bloody()) + stop_dripping() + return + var/mob/living/holder = loc + if(isliving(holder) && holder.is_holding(src) && isturf(holder.loc)) + var/turf/floor = holder.loc + if(!isgroundlessturf(floor) && floor.has_gravity()) + var/list/blood_dna = blood_dna_copy() + var/obj/effect/decal/cleanable/blood/drip/drop = locate() in floor + if(drop) + drop.add_blood_DNA(blood_dna) + else + new /obj/effect/decal/cleanable/blood/drip(floor, null, blood_dna) + drips_left-- + drip_timer = addtimer(CALLBACK(src, PROC_REF(drip)), MANTIS_DRIP_INTERVAL, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/// The blade stops dripping. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/stop_dripping() + if(drip_timer) + deltimer(drip_timer) + drip_timer = null + var/was_drenched = drenched_until + drenched_until = 0 + soaked_until = 0 + drips_left = 0 + if(was_drenched) + refresh_held() + +/// The blood on the blade, as a list of its own (a decal keeps the list it is given). +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/blood_dna_copy() + var/list/blood_dna = GET_ATOM_BLOOD_DNA(src) + return blood_dna ? blood_dna.Copy() : list() + +/// The held sprite redraws. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/refresh_held() + var/mob/holder = loc + if(ismob(holder)) + holder.update_held_items() + +/// The blade is back in its housing: the guard, and no more drops. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_stowed() + stop_dripping() + mantis_pose = MANTIS_POSE_GUARD + inhand_icon_state = "[base_icon_state]_[MANTIS_POSE_GUARD]" + +// tg's item blood is drawn on the item only. In the hand, a coat of blood drawn for the pose, heavier and +// dripping while drenched. Drawn as its own state: an inset overlay inside a whole body masks against the +// body, not the blade. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/worn_overlays(mutable_appearance/standing, isinhands = FALSE, icon_file) + . = ..() + if(!isinhands || !is_bloody()) + return + var/blood_color = get_blood_dna_color() + var/drenched = world.time < drenched_until + var/coat_state = "[standing.icon_state]_[world.time < soaked_until ? "soak" : "blood"]" + if(icon_exists(icon_file, coat_state)) + var/mutable_appearance/coat = mutable_appearance(icon_file, coat_state, appearance_flags = RESET_COLOR) + coat.color = blood_color + . += coat + if(drenched && icon_exists(icon_file, "[standing.icon_state]_drip")) + var/mutable_appearance/drops = mutable_appearance(icon_file, "[standing.icon_state]_drip", appearance_flags = RESET_COLOR) + drops.color = blood_color + . += drops diff --git a/voidcrew/modules/mantis_gore/mantis_charge.dm b/voidcrew/modules/mantis_gore/mantis_charge.dm new file mode 100644 index 00000000000..548799fb2a3 --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_charge.dm @@ -0,0 +1,274 @@ +// The charged leap. With the lunge armed, press and hold on a target: past a short tap the bearer sinks +// into a crouch, rooted, blades swept back and glowing brighter the longer they hold. Release to pounce, +// further for a longer hold. A tap is still the ordinary lunge. One solid hit or a stun knocks them out +// of the crouch and costs the whole cooldown; holding too long they straighten up on their own. +// +// The input is tg's hold pattern (full-auto, the Justice mech): the armed button listens to its +// bearer's client for the press and the release. AI bearers, with no client, only ever tap. + +/datum/action/cooldown/cyberware/mantis_lunge + /// The client the armed button listens to. + var/client/charge_client + /// world.time the press began, or 0. + var/charge_started = 0 + /// Who the press was on. + var/datum/weakref/charge_target + /// TRUE once the crouch shows. + var/crouched = FALSE + /// The body crouched, so it is stood up again even if the button has moved on. + var/datum/weakref/crouch_body + /// The glow on each blade while crouched. + var/list/datum/weakref/crouch_glows + /// Timer of the crouch showing. + var/charge_timer + /// Timer of the next crouch check. + var/crouch_tick_timer + +/datum/action/cooldown/cyberware/mantis_lunge/set_click_ability(mob/on_who) + . = ..() + listen_for_charge(on_who) + +/datum/action/cooldown/cyberware/mantis_lunge/unset_click_ability(mob/on_who, refund_cooldown = TRUE) + stop_listening_for_charge() + cancel_charge() + return ..() + +/datum/action/cooldown/cyberware/mantis_lunge/Remove(mob/removed_from) + stop_listening_for_charge() + cancel_charge() + impale?.finish() + return ..() + +/datum/action/cooldown/cyberware/mantis_lunge/Destroy() + stop_listening_for_charge() + cancel_charge() + impale?.finish() + impale = null + return ..() + +/datum/action/cooldown/cyberware/mantis_lunge/proc/listen_for_charge(mob/on_who) + stop_listening_for_charge() + if(isnull(on_who?.client)) + return + charge_client = on_who.client + RegisterSignal(charge_client, COMSIG_CLIENT_MOUSEDOWN, PROC_REF(on_mouse_down)) + +/datum/action/cooldown/cyberware/mantis_lunge/proc/stop_listening_for_charge() + if(isnull(charge_client)) + return + UnregisterSignal(charge_client, list(COMSIG_CLIENT_MOUSEDOWN, COMSIG_CLIENT_MOUSEUP)) + charge_client = null + +/datum/action/cooldown/cyberware/mantis_lunge/proc/on_mouse_down(client/source, atom/object, turf/location, control, params) + SIGNAL_HANDLER + var/list/modifiers = params2list(params) + if(!LAZYACCESS(modifiers, LEFT_CLICK) || LAZYACCESS(modifiers, SHIFT_CLICK) || LAZYACCESS(modifiers, CTRL_CLICK) || LAZYACCESS(modifiers, ALT_CLICK)) + return + if(owner?.click_intercept != src || !isliving(object)) + return + INVOKE_ASYNC(src, PROC_REF(begin_charge), object) + +/datum/action/cooldown/cyberware/mantis_lunge/proc/on_mouse_up(client/source, atom/object, turf/location, control, params) + SIGNAL_HANDLER + UnregisterSignal(source, COMSIG_CLIENT_MOUSEUP) + if(!charge_started) + return + if(!crouched) + // A tap: the click that follows is the ordinary lunge. + cancel_charge(rearm = FALSE) + return + INVOKE_ASYNC(src, PROC_REF(release_charge)) + // The crouch was the press: the click that follows it is spent. + return COMPONENT_CLIENT_MOUSEUP_INTERCEPT + +/// How far a leap held for [held] reaches, from a lunge of [base_range]. +/proc/mantis_charge_range(held, base_range) + var/progress = clamp((held - MANTIS_CHARGE_TAP) / (MANTIS_CHARGE_FULL - MANTIS_CHARGE_TAP), 0, 1) + return base_range + round(MANTIS_CHARGE_EXTRA_RANGE * progress, 1) + +/// The press on [target]. Returns TRUE if a charge began. +/datum/action/cooldown/cyberware/mantis_lunge/proc/begin_charge(mob/living/target) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = organ + var/mob/living/carbon/bearer = owner + if(charge_started || !istype(housing) || !iscarbon(bearer) || !isliving(target)) + return FALSE + if(!IsAvailable() || !housing.blade_extended() || HAS_TRAIT(bearer, TRAIT_PACIFISM)) + return FALSE + if(target == bearer || target.stat == DEAD || bearer.buckled || !isturf(bearer.loc)) + return FALSE + var/datum/mantis_bearer/state = bearer.get_mantis_state() + if(world.time < state.next_charge) + return FALSE + var/reach = housing.lunge_range + MANTIS_CHARGE_EXTRA_RANGE + if(get_dist(bearer, target) > reach || !can_see(bearer, target, reach)) + return FALSE + charge_started = world.time + charge_target = WEAKREF(target) + // The field drops the moment they set themselves, not when they leave the floor. + cyberware_camo_drop(bearer) + charge_timer = addtimer(CALLBACK(src, PROC_REF(enter_crouch)), MANTIS_CHARGE_TAP, TIMER_STOPPABLE|TIMER_DELETE_ME) + if(charge_client) + RegisterSignal(charge_client, COMSIG_CLIENT_MOUSEUP, PROC_REF(on_mouse_up), override = TRUE) + return TRUE + +/// Past the tap: the crouch shows. +/datum/action/cooldown/cyberware/mantis_lunge/proc/enter_crouch() + if(charge_timer) + deltimer(charge_timer) + charge_timer = null + var/mob/living/carbon/bearer = owner + if(!charge_started || !iscarbon(bearer) || crouched) + return + if(!can_hold_crouch()) + cancel_charge() + return + crouched = TRUE + crouch_body = WEAKREF(bearer) + ADD_TRAIT(bearer, TRAIT_IMMOBILIZED, MANTIS_CHARGE_TRAIT) + bearer.add_offsets(MANTIS_CHARGE_TRAIT, z_add = -MANTIS_CHARGE_CROUCH_DROP) + var/list/housings = get_extended_housings() + mantis_pose_blades(housings, MANTIS_POSE_COIL) + crouch_glows = list() + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_housing_blades(housings)) + var/obj/effect/abstract/cyberware_anim/glow = mantis_coil_glow_fx(bearer, blade) + if(glow) + crouch_glows += WEAKREF(glow) + var/mob/living/target = charge_target?.resolve() + if(target) + bearer.face_atom(target) + bearer.visible_message( + span_boldwarning("[bearer] sinks into a crouch, blades drawn back!"), + span_warning("You coil to spring."), + ) + playsound(bearer, 'sound/items/weapons/sear.ogg', 35, TRUE) + RegisterSignal(bearer, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_crouch_damaged)) + crouch_tick_timer = addtimer(CALLBACK(src, PROC_REF(crouch_tick)), 0.2 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/// Whether the bearer can keep crouching: on their feet, unhurt enough, blade out, still meaning harm. +/datum/action/cooldown/cyberware/mantis_lunge/proc/can_hold_crouch() + var/mob/living/carbon/bearer = owner + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = organ + if(!iscarbon(bearer) || !istype(housing) || !housing.blade_extended()) + return FALSE + if(bearer.stat != CONSCIOUS || bearer.buckled || !isturf(bearer.loc) || HAS_TRAIT(bearer, TRAIT_PACIFISM)) + return FALSE + return TRUE + +/// Whether something has put the crouched bearer down: a stun, a knockdown, a fall. +/datum/action/cooldown/cyberware/mantis_lunge/proc/crouch_knocked_out() + var/mob/living/carbon/bearer = owner + return HAS_TRAIT(bearer, TRAIT_INCAPACITATED) || HAS_TRAIT(bearer, TRAIT_FLOORED) || bearer.body_position == LYING_DOWN || HAS_TRAIT(bearer, TRAIT_HANDS_BLOCKED) + +/datum/action/cooldown/cyberware/mantis_lunge/proc/crouch_tick() + crouch_tick_timer = null + if(!crouched) + return + if(!iscarbon(owner) || owner.stat != CONSCIOUS) + cancel_charge() + return + if(crouch_knocked_out()) + break_crouch() + return + if(!can_hold_crouch()) + cancel_charge() + return + if(world.time - charge_started >= MANTIS_CHARGE_MAX_HOLD) + // Held too long: they straighten up. No cooldown, a moment before they can set again. + var/mob/living/bearer = owner + cancel_charge() + bearer.balloon_alert(bearer, "straightened up") + return + crouch_tick_timer = addtimer(CALLBACK(src, PROC_REF(crouch_tick)), 0.2 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/datum/action/cooldown/cyberware/mantis_lunge/proc/on_crouch_damaged(datum/source, damage_dealt, damagetype) + SIGNAL_HANDLER + if(!crouched || damage_dealt < MANTIS_CHARGE_BREAK_DAMAGE) + return + if(!(damagetype in list(BRUTE, BURN, STAMINA))) + return + INVOKE_ASYNC(src, PROC_REF(break_crouch)) + +/// Knocked out of the crouch: no pounce, and the whole cooldown. +/datum/action/cooldown/cyberware/mantis_lunge/proc/break_crouch() + if(!crouched) + return + var/mob/living/carbon/bearer = owner + cancel_charge() + if(!iscarbon(bearer)) + return + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge as anything in mantis_lunge_actions(bearer)) + lunge.StartCooldown() + bearer.do_stagger_animation() + bearer.visible_message( + span_danger("[bearer] is knocked out of [bearer.p_their()] crouch!"), + span_userdanger("You're knocked out of your crouch!"), + ) + if(bearer.click_intercept == src) + unset_click_ability(bearer, refund_cooldown = FALSE) + +/// Let go after the crouch: the leap. Returns TRUE if they sprang. +/datum/action/cooldown/cyberware/mantis_lunge/proc/release_charge() + var/held = world.time - charge_started + var/mob/living/target = charge_target?.resolve() + var/mob/living/carbon/bearer = owner + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = organ + cancel_charge(rearm = FALSE) + if(!iscarbon(bearer) || !istype(housing)) + return FALSE + if(QDELETED(target) || target.stat == DEAD) + bearer.balloon_alert(bearer, "no target!") + return FALSE + if(!IsAvailable(feedback = TRUE) || !housing.blade_extended() || HAS_TRAIT(bearer, TRAIT_PACIFISM)) + return FALSE + var/range = mantis_charge_range(held, housing.lunge_range) + if(get_dist(bearer, target) > range || !can_see(bearer, target, range)) + bearer.balloon_alert(bearer, "out of reach!") + return FALSE + cyberware_camo_drop(bearer) + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge as anything in mantis_lunge_actions(bearer)) + lunge.StartCooldown() + if(bearer.click_intercept == src) + unset_click_ability(bearer, refund_cooldown = FALSE) + bearer.face_atom(target) + mantis_pose_blades(get_extended_housings(), MANTIS_POSE_LUNGE) + playsound(bearer, 'sound/items/weapons/sear.ogg', 50, TRUE) + // The crouch was the telegraph: no second wind-up. + do_lunge(WEAKREF(target), range, TRUE) + return TRUE + +/** + * Ends any charge: stands the bearer back up, takes the glow off and puts the blades back in the guard. + * [rearm] keeps them from setting again for a moment, when the crouch had shown. + */ +/datum/action/cooldown/cyberware/mantis_lunge/proc/cancel_charge(rearm = TRUE) + if(charge_timer) + deltimer(charge_timer) + charge_timer = null + if(crouch_tick_timer) + deltimer(crouch_tick_timer) + crouch_tick_timer = null + if(charge_client) + UnregisterSignal(charge_client, COMSIG_CLIENT_MOUSEUP) + charge_started = 0 + charge_target = null + if(!crouched) + return + crouched = FALSE + for(var/datum/weakref/glow_ref as anything in crouch_glows) + var/obj/effect/abstract/cyberware_anim/glow = glow_ref.resolve() + if(glow) + qdel(glow) + crouch_glows = null + var/mob/living/carbon/bearer = crouch_body?.resolve() + crouch_body = null + if(isnull(bearer)) + return + UnregisterSignal(bearer, COMSIG_MOB_AFTER_APPLY_DAMAGE) + REMOVE_TRAIT(bearer, TRAIT_IMMOBILIZED, MANTIS_CHARGE_TRAIT) + bearer.remove_offsets(MANTIS_CHARGE_TRAIT, animate = FALSE) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + if(blade.mantis_pose == MANTIS_POSE_COIL) + blade.set_mantis_pose(MANTIS_POSE_GUARD) + if(rearm) + var/datum/mantis_bearer/state = bearer.get_mantis_state() + state.next_charge = world.time + MANTIS_CHARGE_REARM diff --git a/voidcrew/modules/mantis_gore/mantis_core.dm b/voidcrew/modules/mantis_gore/mantis_core.dm new file mode 100644 index 00000000000..0f13f8c6dcb --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_core.dm @@ -0,0 +1,253 @@ +/** + * # Mantis Blades x hyperviolence + * + * The Mantis line (voidcrew/modules/cyberware/ware_military_arms.dm, ware_line_mantis.dm) on top of the + * gore layer (voidcrew/modules/hyperviolence/). The Mantis is the predator: it wins by bleed-out, + * pinning and mobility. It never cuts a limb clean off mid-fight; its one dismemberment is the scissor, + * on someone already dying. + * + * - Arterial gashes: cuts on one limb add up and tear its artery (mantis_blade.dm, mantis_wounds.dm). + * - Impaling lunge: both blades into someone hurt hold them up, or pin them to a wall (mantis_impale.dm). + * - Scissor: a head swing at someone dying, a #509 finisher (mantis_scissor.dm). + * - Blood on the blades, dripping after a kill, flicked off on the way in (mantis_blade.dm, mantis_housing.dm). + * - Lunge trail, afterimages and the arrival (mantis_lunge_fx.dm). + * - X-slash: every third cut with both blades out (mantis_blade.dm). + * - Combat stance: the guard pose and the raised fists while the blades are out (mantis_poses.dm). + * - Charged leap and the kill reset (mantis_charge.dm, and the kill credit below). + * - Scorch burns and half-seals; the Shiv only bleeds (the model tuning in mantis_blade.dm). + * + * Human NPCs only get the gore moves at #509's ranks: aimed crits (hv_can_land_aimed_crits()) for the + * arteries, the impale, the X-slash and the reset; executions (hv_can_execute()) for the scissor. An + * ordinary NPC with Mantis blades cuts like a knife. + * + * Every number is in voidcrew/_DEFINES/mantis_gore.dm. + */ + +// ========================================================================= +// PER-BEARER BOOKKEEPING +// ========================================================================= + +/// What one bearer of the line is in the middle of: the X-slash count and the clocks of the +/// scissor, the kill reset and the crouch. Holds no hard references. +/datum/mantis_bearer + /// Who the X-slash count is on + var/datum/weakref/xslash_target + /// Landed cuts on them so far + var/xslash_count = 0 + /// world.time of the last of those cuts + var/xslash_last = 0 + /// world.time the scissor can be tried again + var/next_scissor = 0 + /// world.time a kill can reset the lunge again + var/next_kill_reset = 0 + /// world.time the bearer can crouch to charge again + var/next_charge = 0 + /// The scissor running now, if any + var/datum/hv_finisher/mantis_scissor/scissor + /// The blade rig drawing this bearer now, if any (mantis_rig.dm) + var/datum/mantis_rig/rig + +/datum/mantis_bearer/Destroy() + xslash_target = null + scissor = null + rig = null + return ..() + +/mob/living + /// The Mantis line's bookkeeping for this mob as a bearer (voidcrew/modules/mantis_gore/). Made on first use. + var/datum/mantis_bearer/mantis_state + /// world.time this mob, killed, last reset someone's lunge. Outlives death on purpose (revive loops). + var/mantis_reset_given_at = 0 + +/mob/living/proc/get_mantis_state() + RETURN_TYPE(/datum/mantis_bearer) + if(!mantis_state) + mantis_state = new + return mantis_state + +// ========================================================================= +// HELPERS +// ========================================================================= + +/// The Mantis-line blades [bearer] has out in a hand, optionally only those that can do [moves] (MANTIS_MOVE_*). +/proc/mantis_held_blades(mob/living/bearer, moves = NONE) + RETURN_TYPE(/list) + . = list() + if(!isliving(bearer)) + return + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade in bearer.held_items) + if(moves && (blade.gore_moves & moves) != moves) + continue + . += blade + +/// Every Mantis lunge button [bearer] has. Chrome abilities never join mob.actions (chrome_hud.dm). +/proc/mantis_lunge_actions(mob/living/bearer) + RETURN_TYPE(/list) + . = list() + if(!iscarbon(bearer)) + return + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge in get_chrome_wheel_actions(bearer)) + . += lunge + +/// The held blade of each of [housings], skipping any that isn't out. +/proc/mantis_housing_blades(list/housings) + RETURN_TYPE(/list) + . = list() + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in housings) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = housing.active_item + if(istype(blade) && housing.blade_extended()) + . += blade + +/// Whether [victim] is dying: in crit, or out cold at crit health. Lying down or stunned is not enough. +/proc/mantis_in_crit(mob/living/victim) + if(!isliving(victim) || victim.stat == DEAD) + return FALSE + if(victim.stat == SOFT_CRIT || victim.stat == HARD_CRIT) + return TRUE + return victim.stat == UNCONSCIOUS && victim.health <= victim.crit_threshold + +// ========================================================================= +// KILL CREDIT +// ========================================================================= + +/** + * [bearer] has just cut [victim] with the line: a death in the next few seconds is their kill. + * Called before the damage lands, so the cut that kills counts. [blades] are the blades that cut, the ones + * a kill drenches; null when every blade out struck (the lunge, the impale, the scissor). + */ +/proc/mantis_note_hit(mob/living/victim, mob/living/bearer, list/blades) + if(!isliving(victim) || !isliving(bearer) || victim == bearer || QDELETED(victim) || victim.stat == DEAD) + return null + var/datum/status_effect/mantis_cuts/cuts = victim.has_status_effect(/datum/status_effect/mantis_cuts) + if(cuts) + cuts.refresh() + else + cuts = victim.apply_status_effect(/datum/status_effect/mantis_cuts) + if(!cuts) + return null + cuts.last_bearer = WEAKREF(bearer) + cuts.last_hit = world.time + cuts.last_blades = null + for(var/obj/item/blade as anything in blades) + LAZYADD(cuts.last_blades, WEAKREF(blade)) + return cuts + +/** + * On someone the line has cut lately. Counts the cuts on each limb (the arterial gashes) and remembers + * who cut them last, so their death can be credited. Runs out on its own a while after the last cut. + */ +/datum/status_effect/mantis_cuts + id = "mantis_cuts" + alert_type = null + duration = MANTIS_CUT_WINDOW + tick_interval = STATUS_EFFECT_NO_TICK + status_type = STATUS_EFFECT_UNIQUE + /// Body zone -> cuts on it that still add up + var/list/limb_cuts + /// Body zone -> world.time of its last cut + var/list/limb_cut_times + /// Who cut them last + var/datum/weakref/last_bearer + /// world.time of that cut + var/last_hit = 0 + /// Weakrefs to the blades of that cut, or null if every blade out struck + var/list/last_blades + +/datum/status_effect/mantis_cuts/on_apply() + RegisterSignal(owner, COMSIG_LIVING_DEATH, PROC_REF(on_owner_death)) + return TRUE + +/datum/status_effect/mantis_cuts/on_remove() + UnregisterSignal(owner, COMSIG_LIVING_DEATH) + +/datum/status_effect/mantis_cuts/Destroy() + last_bearer = null + last_blades = null + return ..() + +/// One more cut on [zone]. Returns how many now add up there. +/datum/status_effect/mantis_cuts/proc/add_cut(zone) + LAZYINITLIST(limb_cuts) + LAZYINITLIST(limb_cut_times) + if(world.time - (limb_cut_times[zone] || 0) > MANTIS_CUT_WINDOW) + limb_cuts[zone] = 0 + limb_cuts[zone] = (limb_cuts[zone] || 0) + 1 + limb_cut_times[zone] = world.time + return limb_cuts[zone] + +/// The count on [zone] starts over. +/datum/status_effect/mantis_cuts/proc/clear_cuts(zone) + LAZYREMOVE(limb_cuts, zone) + LAZYREMOVE(limb_cut_times, zone) + +/datum/status_effect/mantis_cuts/proc/on_owner_death(datum/source, gibbed) + SIGNAL_HANDLER + var/mob/living/bearer = last_bearer?.resolve() + if(isnull(bearer) || world.time - last_hit > MANTIS_KILL_CREDIT_WINDOW) + return + var/list/killing_blades + for(var/datum/weakref/blade_ref as anything in last_blades) + var/obj/item/blade = blade_ref.resolve() + if(blade) + LAZYADD(killing_blades, blade) + mantis_kill_credit(bearer, owner, last_blades ? (killing_blades || list()) : null) + +/** + * [bearer] killed [victim]: the blades that did it are drenched, and the lunge may come back early. + * [blades] are those blades; null means every blade [bearer] has out. A kill in the impale or the scissor + * only stains them: the blade rig draws the blood they leave on the steel, and the held art keeps that coat + * after. + */ +/proc/mantis_kill_credit(mob/living/bearer, mob/living/victim, list/blades) + if(QDELETED(bearer) || bearer.stat == DEAD) + return FALSE + var/light = !isnull(bearer.mantis_state?.rig) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + if(isnull(blades) || (blade in blades)) + blade.drench(victim, light) + return mantis_try_kill_reset(bearer, victim) + +/// Whether killing [victim] can reset a lunge at all: a person (not a monkey), or something big. +/proc/mantis_kill_reset_counts(mob/living/victim) + if(ishuman(victim)) + return !ismonkey(victim) + return victim.maxHealth >= MANTIS_KILL_RESET_MIN_HEALTH + +/** + * The kill reset. [bearer]'s lunge cooldown comes down to MANTIS_KILL_RESET_FLOOR, never lower, at most + * once per MANTIS_KILL_RESET_COOLDOWN per bearer, and a body that gave one gives no other for + * MANTIS_KILL_RESET_VICTIM_LOCKOUT. Prisoners (cuffed or strapped down at death) and small animals never + * count. Returns TRUE if it reset. + */ +/proc/mantis_try_kill_reset(mob/living/bearer, mob/living/victim) + if(!isliving(victim) || !iscarbon(bearer) || !bearer.hv_can_land_aimed_crits()) + return FALSE + if(!mantis_kill_reset_counts(victim)) + return FALSE + if(HAS_TRAIT(victim, TRAIT_RESTRAINED) || victim.buckled) + return FALSE + if(victim.mantis_reset_given_at && world.time < victim.mantis_reset_given_at + MANTIS_KILL_RESET_VICTIM_LOCKOUT) + return FALSE + var/datum/mantis_bearer/state = bearer.get_mantis_state() + if(world.time < state.next_kill_reset) + return FALSE + var/reset = FALSE + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge as anything in mantis_lunge_actions(bearer)) + if(lunge.next_use_time > world.time + MANTIS_KILL_RESET_FLOOR) + lunge.StartCooldown(MANTIS_KILL_RESET_FLOOR) + reset = TRUE + if(!reset) + return FALSE + state.next_kill_reset = world.time + MANTIS_KILL_RESET_COOLDOWN + victim.mantis_reset_given_at = world.time + mantis_reset_tell(bearer) + log_combat(bearer, victim, "had the mantis lunge come back early from killing") + return TRUE + +/// The only sign of a reset: both blades flare once, with a soft ring of steel. +/proc/mantis_reset_tell(mob/living/bearer) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + blade.play_glint(MANTIS_POSE_GUARD) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = blade.housing_ref?.resolve() + housing?.blade_flash(1, 0.3 SECONDS) + playsound(bearer, 'sound/items/unsheath.ogg', 25, TRUE, SILENCED_SOUND_EXTRARANGE) diff --git a/voidcrew/modules/mantis_gore/mantis_housing.dm b/voidcrew/modules/mantis_gore/mantis_housing.dm new file mode 100644 index 00000000000..2d682512cd6 --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_housing.dm @@ -0,0 +1,236 @@ +// The housing side of the Mantis line's gore: the combat stance while a blade is out (the guard pose, +// the fists raised, a glint now and then), the flick of blood on the way back in, and the stain the +// housing keeps until it is washed. See mantis_core.dm for the overview. + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis + /// Raises the fist on the arm while the blade is out. + var/datum/bodypart_overlay/mantis_stance/stance_overlay + /// The arm it is on. + var/datum/weakref/stance_limb + /// Timer of the next glint. + var/glint_timer + /// Blood flicked off the blade has left the housing stained. + var/stained = FALSE + /// Colour of that stain. + var/stain_color + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/Destroy() + stance_off() + stop_glint() + return ..() + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/on_mob_insert(mob/living/carbon/arm_owner, special = FALSE, movement_flags) + . = ..() + RegisterSignal(arm_owner, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(on_bearer_washed)) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/on_mob_remove(mob/living/carbon/arm_owner, special = FALSE, movement_flags) + . = ..() + UnregisterSignal(arm_owner, COMSIG_COMPONENT_CLEAN_ACT) + stance_off() + stop_glint() + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/Extend(obj/item/augment) + . = ..() + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = active_item + if(!istype(blade) || (blade in src) || !owner?.is_holding(blade)) + return + blade.housing_ref = WEAKREF(src) + stance_on() + blade.set_mantis_pose(MANTIS_POSE_GUARD) + schedule_glint() + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/Retract() + var/mob/living/carbon/stowing_owner = owner + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/stowing = active_item + var/flick = istype(stowing) && stowing_owner?.is_holding(stowing) && stowing.is_bloody() + . = ..() + if(!.) + return + stance_off() + stop_glint() + if(!istype(stowing)) + return + stowing.mantis_stowed() + if(flick && !QDELETED(stowing_owner)) + flick_blood(stowing_owner, stowing) + +// A blade forced out of the hand some other way (a cut-off hand, a forced drop) ends the stance too. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/on_deployed_item_dropped(obj/item/source, mob/user) + SIGNAL_HANDLER + stance_off() + stop_glint() + return ..() + +// ---- The stance ---------------------------------------------------------- + +/// Raises this arm's fist to the guard. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/stance_on() + stance_off() + var/obj/item/bodypart/arm = owner?.get_bodypart(zone) + if(isnull(arm)) + return + stance_overlay = new + stance_limb = WEAKREF(arm) + arm.add_bodypart_overlay(stance_overlay) + +/// Lowers it again. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/stance_off() + if(isnull(stance_overlay)) + return + var/obj/item/bodypart/arm = stance_limb?.resolve() + if(arm && (stance_overlay in arm.bodypart_overlays)) + arm.remove_bodypart_overlay(stance_overlay) + QDEL_NULL(stance_overlay) + stance_limb = null + +/// How high the fist rides, for the blade's pose. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/set_stance_raise(raise) + if(isnull(stance_overlay) || stance_overlay.raise == raise) + return + stance_overlay.raise = raise + owner?.update_body_parts() + +/** + * The fist on an arm whose Mantis blade is out, raised to the guard. Draws nothing of its own: it moves + * the arm's hand up a few pixels, and is part of the arm's render key so it redraws when it changes. + */ +/datum/bodypart_overlay/mantis_stance + layers = NONE + blocks_emissive = EMISSIVE_BLOCK_NONE + /// Pixels the hand rides up. + var/raise = 2 + +/datum/bodypart_overlay/mantis_stance/generate_icon_cache() + return list("mantis_stance_[raise]") + +/datum/bodypart_overlay/mantis_stance/modify_bodypart_appearance(datum/appearance) + // Images and mutable appearances both: the hand and its emissive blocker move together. + var/image/part = appearance + if(isnull(part) || !findtext("[part.icon_state]", "_hand")) + return + part.pixel_y += raise + +// ---- The glint ----------------------------------------------------------- + +/// The next glint along the edge, 8 to 12 seconds out. One-shot timers only. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/schedule_glint() + stop_glint() + glint_timer = addtimer(CALLBACK(src, PROC_REF(stance_glint)), rand(8 SECONDS, 12 SECONDS), TIMER_STOPPABLE|TIMER_DELETE_ME) + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/stop_glint() + if(glint_timer) + deltimer(glint_timer) + glint_timer = null + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/stance_glint() + glint_timer = null + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = active_item + if(!istype(blade) || !owner?.is_holding(blade)) + return + if(blade.mantis_pose == MANTIS_POSE_GUARD) + blade.play_glint() + schedule_glint() + +// ---- Blood ----------------------------------------------------------------- + +/// How long flicked blood is in the air: the flick's three frames. +#define MANTIS_FLICK_FLIGHT (0.3 SECONDS) + +/** + * What a flicked blade leaves on the tile ahead: a thin line of spatter from where the blade pointed, bending a + * little and breaking into drops toward its far end ("flick_spatter_[hand]", drawn for the tile ahead in each + * facing). One per hand, so two blades lay a line each. Its own kind of blood, not one of the sprays: a tile's + * spray is neither turned by a flick nor kept off the tile by one. + */ +/obj/effect/decal/cleanable/blood/mantis_flick + name = "blood spatter" + icon = MANTIS_GORE_ICON + icon_state = "flick_spatter_right" + random_icon_states = null + mergeable_decal = FALSE + // Thin enough that walking through it does not leave footprints. + bloodiness = 15 + drying_time = 3 MINUTES + beauty = -20 + base_name = null + base_suffix = "spatter" + /// The hand that flicked it: "left" or "right". + var/hand = "right" + +// Too thin to dive into. +/obj/effect/decal/cleanable/blood/mantis_flick/can_bloodcrawl_in() + return FALSE + +/// The [hand] blade's flicked blood lands on [ahead], thrown the way [flick_dir]. Wet spatter that hand already +/// left there is only freshened. Returns the spatter. +/proc/mantis_flick_land(turf/ahead, flick_dir, hand, list/blood_dna) + if(!isturf(ahead) || !length(blood_dna)) + return null + for(var/obj/effect/decal/cleanable/blood/mantis_flick/wet in ahead) + if(wet.hand != hand || wet.dir != flick_dir || wet.dried || QDELETED(wet)) + continue + wet.add_blood_DNA(blood_dna) + return wet + var/obj/effect/decal/cleanable/blood/mantis_flick/spatter = new(ahead, null, blood_dna) + if(QDELETED(spatter)) + return null + spatter.hand = hand + spatter.icon_state = "flick_spatter_[hand]" + spatter.setDir(flick_dir) + var/full_alpha = spatter.alpha + spatter.alpha = 0 + animate(spatter, alpha = full_alpha, time = 0.1 SECONDS) + return spatter + +/// The blade snaps back in bloody: the blood flies off ahead and lands as a line of spatter, and some stays on +/// the housing. +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/flick_blood(mob/living/carbon/bearer, obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade) + var/blood_color = blade.get_blood_dna_color() + var/list/blood_dna = blade.blood_dna_copy() + var/obj/effect/abstract/cyberware_anim/fling = cyberware_anim_play(bearer, MANTIS_GORE_LARGE_ICON, "mantis_flick_[zone == BODY_ZONE_L_ARM ? "left" : "right"]", MANTIS_ANIM_BLADE_LAYER, 0.3 SECONDS) + if(fling) + fling.pixel_x = -16 + fling.pixel_y = -16 + fling.color = blood_color + var/turf/ahead = get_step(bearer, bearer.dir) + if(isturf(bearer.loc) && ahead && length(blood_dna) && !hv_blood_spray_blocked(ahead) && !isgroundlessturf(ahead) && ahead.has_gravity()) + // It lands once the flick has crossed to it, not as the blade starts back in. + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_flick_land), ahead, bearer.dir, zone == BODY_ZONE_L_ARM ? "left" : "right", blood_dna), MANTIS_FLICK_FLIGHT) + blade.wash(CLEAN_TYPE_BLOOD) + stained = TRUE + stain_color = blood_color + bearer.update_body_parts() + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/proc/on_bearer_washed(datum/source, clean_types) + SIGNAL_HANDLER + if(!(clean_types & CLEAN_TYPE_BLOOD)) + return + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = active_item + if(istype(blade) && blade.is_bloody()) + blade.wash(CLEAN_TYPE_BLOOD) + blade.stop_dripping() + blade.refresh_held() + if(!stained) + return + stained = FALSE + stain_color = null + owner?.update_body_parts() + +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/cyberware_worn_key() + return "[..()][stained ? "-blood[stain_color]" : ""]" + +// The stain is drawn over the housing's own pixels, only in its plain look (an EMP's dark, a brownout or the +// fold hide it with the rest of the housing). +/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/cyberware_dress_worn(list/imageset, image_layer, obj/item/bodypart/limb) + . = ..() + if(!stained || cyberware_worn_look()) + return + var/stain_state = "[aug_overlay]_[zone == BODY_ZONE_L_ARM ? "left" : "right"]_stain" + if(!icon_exists(MANTIS_GORE_ICON, stain_state)) + return + var/image/stain = image(icon = MANTIS_GORE_ICON, icon_state = stain_state, layer = image_layer) + stain.appearance_flags |= RESET_COLOR + stain.color = stain_color + . += stain + +#undef MANTIS_FLICK_FLIGHT diff --git a/voidcrew/modules/mantis_gore/mantis_impale.dm b/voidcrew/modules/mantis_gore/mantis_impale.dm new file mode 100644 index 00000000000..de703e5538e --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_impale.dm @@ -0,0 +1,602 @@ +// The impaling lunge. A lunge that arrives with both blades on someone already hurt or down skewers them: +// held up on the blades for a beat (pinned to the wall for longer, if one is right behind them), then the +// blades rip out with a spray and they drop. The bearer is rooted with full hands the whole time, and +// the victim's hands stay free, so they can still shoot. + +/// Whether a lunge arriving with [housings] skewers [victim]: both blades out and able, a person no bigger +/// than a person, and already hurt or down. +/proc/mantis_can_impale(mob/living/lunger, mob/living/victim, list/housings) + if(!iscarbon(victim) || victim.stat == DEAD || victim.mob_size > MOB_SIZE_HUMAN) + return FALSE + if(!lunger.hv_can_land_aimed_crits()) + return FALSE + var/list/blades = mantis_housing_blades(housings) + if(length(blades) < 2) + return FALSE + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in blades) + if(!(blade.gore_moves & MANTIS_MOVE_IMPALE)) + return FALSE + if(HAS_TRAIT_FROM(victim, TRAIT_IMMOBILIZED, MANTIS_IMPALE_TRAIT) || victim.has_status_effect(/datum/status_effect/hv_finisher_hold)) + return FALSE + if(victim.buckled || !isturf(victim.loc)) + return FALSE + if(victim.health <= victim.maxHealth * MANTIS_IMPALE_HEALTH_FRACTION) + return TRUE + return victim.body_position == LYING_DOWN || victim.stat >= SOFT_CRIT || HAS_TRAIT(victim, TRAIT_INCAPACITATED) + +/// Skewers [victim] on the blades of [housings]. Returns TRUE if it took hold. [from] is where the lunge set +/// out, for the [glide] the lunging body takes to reach them (mantis_lunge_dash_fx()). +/proc/mantis_start_impale(datum/action/cooldown/cyberware/mantis_lunge/lunge, mob/living/carbon/lunger, mob/living/carbon/victim, list/housings, knockdown, turf/from, glide = MANTIS_LUNGE_GLIDE) + var/datum/mantis_impale/skewer = new(lunger, victim, housings, knockdown) + var/turf/landed = get_turf(lunger) + if(from && landed && from != landed) + skewer.glide_w = (from.x - landed.x) * ICON_SIZE_X + skewer.glide_z = (from.y - landed.y) * ICON_SIZE_Y + skewer.glide_time = glide + if(!skewer.start()) + qdel(skewer) + return FALSE + lunge?.impale = skewer + return TRUE + +/datum/action/cooldown/cyberware/mantis_lunge + /// The skewer this lunge is holding, while it holds. + var/datum/mantis_impale/impale + +/** + * # The skewer + * + * The beats, from the approved storyboard: the lunging body glides in, blades out; the points reach them + * and go in, and the two are drawn together; the victim is held up on the blades; the bearer pulls back, rips + * the blades out and the victim drops. From the glide to the drop the bearer is drawn by the blade rig + * (mantis_rig.dm): the far blade, the far arm and the bearer's body under the victim, the near arm and the + * near blade over them, the steel inside them cut out. + */ +/datum/mantis_impale + var/mob/living/carbon/bearer + var/mob/living/carbon/victim + /// The housings whose blades went in. + var/list/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housings + /// The way the lunge travelled. The tips come out on that side. + var/lunge_dir + /// The way it is drawn (mantis_rig_facing()). + var/facing + /// TRUE when a wall right behind them takes the points. + var/wall_pin = FALSE + /// How long they are held. + var/hold_time = MANTIS_IMPALE_HOLD + /// How long they go down for when the blades come out. + var/knockdown = 2 SECONDS + var/started_at = 0 + /// Damage the bearer has taken since it began. + var/taken = 0 + var/tick_timer + /// The bearer drawn around the victim, from the start of the glide in. + var/datum/mantis_rig/rig + /// The landing, when the points reach them. + var/rig_timer + /// Where the lunging body glides in from, in pixels off the bearer's tile, and how long it takes. + var/glide_w = 0 + var/glide_z = 0 + var/glide_time = 0 + /// The beat drawn now. + var/beat + /// How far tg had them turned to lie down when they came up on the blades, or 0. + var/hoist_angle = 0 + /// Degrees they are tipped back about their feet at the rip, to take back out. + var/tilt_angle = 0 + /// The way they faced before they were turned onto the blades. + var/prior_dir + var/running = FALSE + /// TRUE from the pull-back until the blades are out. + var/ripping = FALSE + /// Pixels they hang up from where the hold has them: -1 while they sag on the blades (set_sag()). + var/sag = 0 + /// The bar over the bearer that everyone sees fill until the rip (finisher_bar.dm) + var/obj/effect/abstract/hv_exec_bar/exec_bar + +/datum/mantis_impale/New(mob/living/carbon/bearer, mob/living/carbon/victim, list/housings, knockdown) + . = ..() + src.bearer = bearer + src.victim = victim + src.housings = housings.Copy() + if(isnum(knockdown)) + src.knockdown = knockdown + +/datum/mantis_impale/Destroy() + if(running) + finish() + QDEL_NULL(rig) + bearer = null + victim = null + housings = null + return ..() + +/datum/mantis_impale/proc/start() + if(running || QDELETED(bearer) || QDELETED(victim)) + return FALSE + lunge_dir = get_dir(bearer, victim) || bearer.dir + facing = mantis_rig_facing(bearer, victim) + var/turf/behind = get_step(victim, lunge_dir) + wall_pin = !isnull(behind) && hv_blood_spray_blocked(behind) + hold_time = wall_pin ? MANTIS_IMPALE_PIN_HOLD : MANTIS_IMPALE_HOLD + running = TRUE + started_at = world.time + // Everyone in view sees the hold count down to the rip (finisher_bar.dm) + exec_bar = hv_exec_bar_start(bearer, hold_time) + bearer.add_traits(list(TRAIT_IMMOBILIZED, TRAIT_HANDS_BLOCKED), MANTIS_IMPALE_TRAIT) + ADD_TRAIT(victim, TRAIT_IMMOBILIZED, MANTIS_IMPALE_TRAIT) + // Turned onto the blades and brought up off the floor if they were on it. The rig draws the lunging body + // gliding in, blades out and short of them (the bearer's own lunge pose would lie over them); the points + // reach them as it lands (begin_rig()). + prior_dir = victim.dir + victim.setDir(mantis_face_dir(victim, bearer)) + hoist() + place_victim(0, 0) + mantis_pose_blades(housings, MANTIS_POSE_LUNGE) + put_up_rig() + if(rig) + show_beat("arrive", glide_time, glide_w, glide_z) + rig_timer = addtimer(CALLBACK(src, PROC_REF(begin_rig)), max(glide_time, world.tick_lag), TIMER_STOPPABLE|TIMER_DELETE_ME) + // The lunge's own slash, drawn as it landed, would float over the blades. + for(var/obj/effect/abstract/cyberware_anim/picture in victim.vis_contents) + if(findtext(picture.icon_state, "impact_") == 1) + qdel(picture) + RegisterSignal(bearer, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_bearer_damaged)) + RegisterSignals(bearer, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING, COMSIG_MOVABLE_MOVED), PROC_REF(on_lost)) + RegisterSignals(victim, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING, COMSIG_MOVABLE_MOVED), PROC_REF(on_lost)) + RegisterSignal(victim, COMSIG_LIVING_POST_UPDATE_TRANSFORM, PROC_REF(on_victim_turned)) + if(wall_pin) + victim.visible_message( + span_danger("[bearer] drives both blades through [victim] and pins [victim.p_them()] to the wall!"), + span_userdanger("Two blades punch through you and into the wall!"), + ) + else + victim.visible_message( + span_danger("[bearer] drives both blades through [victim] and lifts [victim.p_them()] off [victim.p_their()] feet!"), + span_userdanger("Two blades punch through you!"), + ) + schedule_tick() + return TRUE + +/// The bearer is drawn by the rig from here to the drop. +/datum/mantis_impale/proc/put_up_rig() + if(rig) + return + rig = new(bearer, victim, facing, model(), "impale") + if(!rig.start()) + QDEL_NULL(rig) + +/// The lunging body has landed: the two are drawn together, and the victim slides onto the blades. +/datum/mantis_impale/proc/begin_rig() + rig_timer = null + if(!running || ripping) + return + put_up_rig() + // Whole blades, the victim over the steel they have slid onto: they cover it as they come. + show_beat("contact", MANTIS_IMPALE_CONTACT_BEAT) + addtimer(CALLBACK(src, PROC_REF(stab)), MANTIS_IMPALE_CONTACT_BEAT, TIMER_DELETE_ME) + +/// The blades are in: the points come out of the back wet, with a burst of blood and a crackle of their light. +/datum/mantis_impale/proc/stab() + if(!running || ripping) + return + if(rig) + rig.wet = TRUE + show_beat("enter", 0) + // The crackle is at the points, so it lasts only while they are still: it is gone as the hoist begins. + switch(facing) + if(NORTH) + rig?.burst("enter_puff", 0.25 SECONDS, "T", under = TRUE) + rig?.burst("enter_spark", MANTIS_IMPALE_ENTER_BEAT, "tips", blood = FALSE) + if(SOUTH) + rig?.burst("enter_puff", 0.25 SECONDS, "tips") + rig?.burst("enter_spark", MANTIS_IMPALE_ENTER_BEAT, "tips", blood = FALSE) + else + rig?.burst("enter_puff", 0.25 SECONDS, "T") + rig?.burst("enter_spark", MANTIS_IMPALE_ENTER_BEAT, "near", blood = FALSE) + addtimer(CALLBACK(src, PROC_REF(lift), 1), MANTIS_IMPALE_ENTER_BEAT, TIMER_DELETE_ME) + +/** + * The hoist from the stab to the hold, a frame at a time: the victim and the blades in them rise together, + * in the same frame, so the steel stays where it went in. + */ +/datum/mantis_impale/proc/lift(step) + if(!running || ripping) + return + if(!mantis_rig_beat("impale", "lift[step]", facing)) + hang() + return + show_beat("lift[step]", 0) + addtimer(CALLBACK(src, PROC_REF(lift), step + 1), MANTIS_IMPALE_STEP, TIMER_DELETE_ME) + +/** + * Held up: the victim hangs on the blades until the pull-back. Twice they sag a pixel and are heaved back up, + * and the blades and the arms holding them dip with them in the same frame (set_sag()). + */ +/datum/mantis_impale/proc/hang() + show_beat("hold", 0) + if(!running || ripping || QDELETED(victim)) + return + for(var/again in 0 to 1) + var/at = MANTIS_IMPALE_SAG_AFTER + again * MANTIS_IMPALE_SAG_EVERY + addtimer(CALLBACK(src, PROC_REF(set_sag), -1), at, TIMER_DELETE_ME) + addtimer(CALLBACK(src, PROC_REF(set_sag), 0), at + MANTIS_IMPALE_SAG_FOR, TIMER_DELETE_ME) + +/// In the hold they hang [new_sag] pixels up from where the hold has them (a sag is negative). +/datum/mantis_impale/proc/set_sag(new_sag) + if(!running || ripping || beat != "hold" || sag == new_sag) + return + sag = new_sag + show_beat("hold", 0) + +/** + * Draws [new_beat] (mantis_rig_beat()): the bearer's arms and lean, and the victim drawn onto the blades. + * Up against a wall the victim stays where they are and the bearer comes the whole way; from a diagonal the + * two meet halfway up or down the screen. Pictures only. + */ +/datum/mantis_impale/proc/show_beat(new_beat, time = 0.1 SECONDS, from_w = 0, from_z = 0) + if(!running || (ripping && (new_beat == "hold" || findtext(new_beat, "lift") == 1))) + return + var/list/spec = mantis_rig_beat("impale", new_beat, facing) + if(!spec) + return + beat = new_beat + var/target_w = spec[MANTIS_RIG_TARGET_W] + var/target_z = spec[MANTIS_RIG_TARGET_Z] + var/extra_w = 0 + var/extra_z = 0 + if((facing & (EAST|WEST)) && (lunge_dir & (NORTH|SOUTH))) + var/half = (lunge_dir & NORTH) ? ICON_SIZE_Y / 2 : -ICON_SIZE_Y / 2 + extra_z = half + target_z -= half + if(wall_pin) + extra_w -= target_w + extra_z -= target_z + target_w = 0 + target_z = 0 + // Sagging in the hold (set_sag()): the steel in them and the arms holding them go with them. Not against a + // wall: the points are in it. + var/dip = (new_beat == "hold" && !wall_pin) ? sag : 0 + // Facing south the victim is held up in front of the bearer, back to the camera, high enough to hide them + // whole. The bearer draws up tall behind them as they heave, head and shoulders over the victim's head, the + // fists with them; the points out of the victim's back stay where they are. + var/rise = (facing == SOUTH) ? max(0, spec[MANTIS_RIG_TARGET_Z] - MANTIS_IMPALE_SOUTH_RISE_FROM) : 0 + rig?.show(new_beat, extra_w, extra_z, time, from_w, from_z, ride_z = dip, body_z = rise) + // The bar over the bearer goes up with them, so it sits over their head rather than across their face. + if(!QDELETED(exec_bar) && !exec_bar.ending) + animate(exec_bar, pixel_z = exec_bar.rest_z + rise, time = time, easing = SINE_EASING, flags = ANIMATION_PARALLEL) + place_victim(target_w, target_z + dip, time) + set_tilt(spec[MANTIS_RIG_TILT]) + +/// Draws the victim [w], [z] pixels off their tile (and upright, if brought up off the floor), over [time]. +/datum/mantis_impale/proc/place_victim(w, z, time = 0.1 SECONDS) + // Brought upright off the floor: tg draws someone lying down a little low. + var/upright = hoist_angle ? -PIXEL_Y_OFFSET_LYING : 0 + // Drawn onto the blades as fast as the rig leans in (tg's own glide takes twice as long), so the points + // are at their front as they arrive, not after. + var/from_w = victim.pixel_w + var/from_z = victim.pixel_z + victim.add_offsets(MANTIS_IMPALE_TRAIT, w_add = w, z_add = z + upright, animate = FALSE) + var/to_w = victim.pixel_w + var/to_z = victim.pixel_z + if((to_w == from_w && to_z == from_z) || !time) + return + victim.pixel_w = from_w + victim.pixel_z = from_z + animate(victim, pixel_w = to_w, pixel_z = to_z, time = time, easing = SINE_EASING, flags = ANIMATION_PARALLEL) + +/// The matrix tipping a body [angle] degrees about its feet (clockwise), after [base]. +/proc/mantis_tip_matrix(matrix/base, angle) + var/matrix/turned = matrix(base) + turned.Translate(0, MANTIS_TIP_FEET) + turned.Turn(angle) + turned.Translate(0, -MANTIS_TIP_FEET) + return turned + +/// Where the point [x], [y] (pixels from a sprite's middle, y up) is drawn once the sprite is turned [angle] +/// degrees clockwise about [about_x], [about_y]. +/proc/mantis_turn_point(x, y, angle, about_x, about_y) + var/dx = x - about_x + var/dy = y - about_y + return list(about_x + dx * cos(angle) + dy * sin(angle), about_y - dx * sin(angle) + dy * cos(angle)) + +/** + * [body] falls in one motion from how it was drawn on the blades (offsets [from_w], [from_z], [from_y], upright + * and tipped back [from_angle] degrees about its feet) to how tg has it now, lying or standing, turning about + * the point [pivot] pixels under its middle (its feet for a fall backwards, 0 for a drop in place). It is the + * real body the whole way and ends on tg's own turn and offsets, so nothing takes over at the end. Gravity: + * slow off the blades, fast at the floor. A picture only: tg's lying state is set before this. + */ +/proc/mantis_drop_body(mob/living/body, from_w, from_z, from_y, from_angle, pivot, time) + if(QDELETED(body)) + return + var/matrix/to_transform = matrix(body.transform) + var/to_w = body.pixel_w + var/to_z = body.pixel_z + var/to_y = body.pixel_y + var/to_angle = (body.body_position == LYING_DOWN && body.rotate_on_lying) ? body.lying_angle : 0 + if(to_angle > 180) + to_angle -= 360 + // The turning point at the start (the picture tipped about the feet) and at the end (tg turns about the middle). + var/list/start = mantis_turn_point(0, -pivot, from_angle, 0, -MANTIS_TIP_FEET) + var/start_x = start[1] + from_w + var/start_y = start[2] + from_z + from_y + var/list/end = mantis_turn_point(0, -pivot, to_angle, 0, 0) + var/end_x = end[1] + to_w + var/end_y = end[2] + to_z + to_y + var/steps = 4 + for(var/step in 0 to steps) + var/fallen = (step / steps) ** 2 + var/matrix/turned = to_transform + var/step_w = to_w + var/step_z = to_z + if(step < steps) + turned = matrix() + turned.Translate(0, pivot) + turned.Turn(from_angle + (to_angle - from_angle) * fallen) + turned.Translate(0, -pivot) + step_w = round(start_x + (end_x - start_x) * fallen, 1) + step_z = round(start_y + (end_y - start_y) * fallen + pivot - to_y, 1) + // The first step puts the picture back where it was drawn at once: it replaces tg's own turn, and + // whatever else this tick started on the body. + if(step == 0) + animate(body, transform = turned, pixel_w = step_w, pixel_z = step_z, pixel_y = to_y, time = 0) + else + animate(transform = turned, pixel_w = step_w, pixel_z = step_z, time = time / steps) + +/// Tips the victim back to [angle] degrees about their feet. +/datum/mantis_impale/proc/set_tilt(angle) + if(angle == tilt_angle || QDELETED(victim)) + return + var/matrix/turned = mantis_tip_matrix(victim.transform, angle - tilt_angle) + tilt_angle = angle + animate(victim, transform = turned, time = 0.1 SECONDS, flags = ANIMATION_PARALLEL) + +/// Takes the tip back out at once, before anything else turns them. +/datum/mantis_impale/proc/untilt() + if(tilt_angle && !QDELETED(victim)) + victim.transform = mantis_tip_matrix(victim.transform, -tilt_angle) + tilt_angle = 0 + +/** + * Someone skewered off the floor comes up with the blades and is drawn upright for the hold. Only the + * picture turns: tg still has them lying down, with everything that goes with it. Skipped for a resized + * body, whose lying turn carries a shift that wouldn't come back out cleanly. + */ +/datum/mantis_impale/proc/hoist() + if(hoist_angle || victim.body_position != LYING_DOWN || !victim.rotate_on_lying || !victim.lying_angle) + return + if(victim.current_size != RESIZE_DEFAULT_SIZE) + return + hoist_angle = victim.lying_angle + var/matrix/upright = matrix(victim.transform) + upright.Turn(-hoist_angle) + victim.transform = upright + +/// Gives back tg's lying turn. [fall] drops them into it instead of snapping. +/datum/mantis_impale/proc/unhoist(fall = FALSE) + if(!hoist_angle) + return + var/matrix/lying = matrix(victim.transform) + lying.Turn(hoist_angle) + hoist_angle = 0 + if(fall) + animate(victim, transform = lying, time = 0.2 SECONDS, easing = EASE_IN, flags = ANIMATION_PARALLEL) + else + victim.transform = lying + +/// tg turned them while they hang on the blades (got up, or went down): its turn stands, the picture stays upright. +/datum/mantis_impale/proc/on_victim_turned(datum/source, resize, new_lying_angle, is_opposite_angle) + SIGNAL_HANDLER + if(!running) + return + // tg turned the upright picture by the change, and turns add up: undoing the hoist leaves tg's own. + untilt() + unhoist() + hoist() + if(beat) + show_beat(beat) + else + place_victim(0, 0) + +/// The model of the blades in them, for the pictures. +/datum/mantis_impale/proc/model() + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_housing_blades(housings)) + return blade.base_icon_state + return "mantis" + +/// Ends the bar over the bearer: full when the rip comes on time, failed otherwise +/datum/mantis_impale/proc/end_exec_bar(success) + if(!QDELETED(exec_bar)) + exec_bar.finish(success) + exec_bar = null + +/datum/mantis_impale/proc/schedule_tick() + tick_timer = addtimer(CALLBACK(src, PROC_REF(tick)), 0.2 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/datum/mantis_impale/proc/tick() + tick_timer = null + if(!running) + return + if(!holds()) + finish() + return + if(world.time - started_at >= hold_time) + rip() + return + schedule_tick() + +/// Whether the hold still holds: both alive and side by side, the blades still out, the bearer on their feet. +/datum/mantis_impale/proc/holds() + if(QDELETED(bearer) || QDELETED(victim) || bearer.stat != CONSCIOUS || victim.stat == DEAD) + return FALSE + if(HAS_TRAIT(bearer, TRAIT_INCAPACITATED) || HAS_TRAIT(bearer, TRAIT_FLOORED)) + return FALSE + if(!isturf(bearer.loc) || !isturf(victim.loc) || bearer.z != victim.z || get_dist(bearer, victim) > 1) + return FALSE + return length(mantis_housing_blades(housings)) >= 1 + +/** + * The blades rip out. [half] when the bearer lost their grip: it tears less on the way out, with no + * pull-back. Otherwise first the pull-back: the bearer draws back while they still hang there, then tears + * the blades out, and a beat later they come free and the body drops (tear_out()). + */ +/datum/mantis_impale/proc/rip(half = FALSE) + if(!running || ripping) + return + end_exec_bar(!half) + // A lost grip is a jolt, not a pull: they come straight off. + if(half) + tear_out(TRUE) + return + ripping = TRUE + if(tick_timer) + deltimer(tick_timer) + tick_timer = null + // The pull-back in steps, the steel coming out a little at a time. + for(var/step in 1 to 3) + addtimer(CALLBACK(src, PROC_REF(show_beat), "pull[step]", 0), (step - 1) * MANTIS_IMPALE_PULL_STEP, TIMER_DELETE_ME) + addtimer(CALLBACK(src, PROC_REF(show_rip)), 3 * MANTIS_IMPALE_PULL_STEP, TIMER_DELETE_ME) + addtimer(CALLBACK(src, PROC_REF(tear_out), half), 3 * MANTIS_IMPALE_PULL_STEP + MANTIS_IMPALE_PULL_BEAT - MANTIS_IMPALE_RIP_BEAT, TIMER_DELETE_ME) + +/// The blades tear up and down out of them: blood sprays out of the back as they come free. +/datum/mantis_impale/proc/show_rip() + if(!running) + return + show_beat("rip") + rig?.burst("rip_spray", 0.4 SECONDS, "T", under = (facing == NORTH)) + +/// The blades come out after the pull-back: the damage, the spray and the fall. The bearer holds the +/// last pose for the drop, then is drawn as usual again. +/datum/mantis_impale/proc/tear_out(half = FALSE) + if(!running) + return + var/list/blades = mantis_housing_blades(housings) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/first_blade = length(blades) ? blades[1] : null + var/damage = half ? MANTIS_IMPALE_RIP_DAMAGE * 0.5 : MANTIS_IMPALE_RIP_DAMAGE + var/mob/living/carbon/held = victim + var/mob/living/carbon/holder = bearer + var/rip_dir = lunge_dir + // The rig stays up for the drop; finish() would take it down. + var/datum/mantis_rig/dropping = rig + rig = null + // They fall from where they are drawn now: tipped back about their feet, up on the blades. + var/fall_w = held?.pixel_w + var/fall_z = held?.pixel_z + var/fall_y = held?.pixel_y + var/fall_tilt = tilt_angle + // Only a body drawn upright on the blades (brought up off the floor, or standing) at its usual size. + var/can_fall = held && held.current_size == RESIZE_DEFAULT_SIZE && (hoist_angle || held.body_position != LYING_DOWN || !held.rotate_on_lying || !held.lying_angle) + var/side = facing & (EAST|WEST) + var/face = held?.dir + finish(settle = !can_fall) + if(!QDELETED(held) && held.stat != DEAD) + mantis_note_hit(held, holder) + if(half) + held.hv_hold_attack_message("[holder] loses [holder.p_their()] grip on [held]!", "[holder] loses [holder.p_their()] grip on you!", null, null, null, COMBAT_MESSAGE_RANGE) + else + held.hv_hold_attack_message("[holder] rips both blades out of [held]!", "[holder] rips both blades out of you!", null, null, null, COMBAT_MESSAGE_RANGE) + var/armour = held.run_armor_check(BODY_ZONE_CHEST, MELEE, armour_penetration = first_blade?.armour_penetration, silent = TRUE) + for(var/i in 1 to max(1, length(blades))) + held.apply_damage( + damage, + BRUTE, + BODY_ZONE_CHEST, + armour, + wound_bonus = MANTIS_IMPALE_RIP_WOUND_BONUS, + sharpness = SHARP_EDGED, + attack_direction = rip_dir, + attacking_item = first_blade, + ) + if(QDELETED(held)) + break + if(!QDELETED(held)) + held.hv_flush_hit() + if(!QDELETED(held)) + held.hv_blood_spray(rip_dir, half ? 2 : 3) + if(wall_pin) + held.hv_blood_lay_wall_spray(get_turf(held), rip_dir, held.get_blood_dna_list(), held.get_static_viruses()) + // Someone held up standing goes down now. tg would slide them the 6 px down into its lying offset + // on its own clock while the fall draws them; give them the offset first, so the fall draws it. + var/was_standing = can_fall && held.body_position != LYING_DOWN && held.rotate_on_lying + if(was_standing) + held.add_offsets(LYING_DOWN_TRAIT, y_add = PIXEL_Y_OFFSET_LYING, animate = FALSE) + held.Knockdown(knockdown) + if(was_standing && held.body_position != LYING_DOWN) + held.remove_offsets(LYING_DOWN_TRAIT, animate = FALSE) + playsound(held, 'sound/items/weapons/bladeslice.ogg', 70, TRUE) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in blades) + blade.drench(held, light = TRUE) + if(half && !QDELETED(holder)) + holder.set_staggered_if_lower(1.5 SECONDS) + log_combat(holder, held, half ? "lost the grip on" : "ripped the mantis blades out of") + // The fall: one motion from the blades to the floor, ending where tg lays them. Seen from the side they + // were tipped back, so they land on their back, head away from the bearer, still facing them. + if(can_fall && !QDELETED(held)) + if(side && held.body_position == LYING_DOWN && held.rotate_on_lying) + held.set_lying_angle(side == EAST ? LYING_ANGLE_EAST : LYING_ANGLE_WEST) + if(face) + held.setDir(face) + mantis_drop_body(held, fall_w, fall_z, fall_y, fall_tilt, side ? MANTIS_TIP_FEET : 0, MANTIS_IMPALE_DROP_BEAT) + // The drop, drawn once they are down (their layer is the floor's now), then the real bearer fades back in. + if(dropping && !QDELETED(dropping)) + dropping.show("drop", time = MANTIS_IMPALE_DROP_BEAT) + addtimer(CALLBACK(dropping, TYPE_PROC_REF(/datum/mantis_rig, hand_back)), MANTIS_IMPALE_DROP_BEAT, TIMER_DELETE_ME) + +/// The bearer is hit while holding them up. Enough of it and they lose the grip. +/datum/mantis_impale/proc/on_bearer_damaged(datum/source, damage_dealt, damagetype) + SIGNAL_HANDLER + if(!running || damage_dealt <= 0) + return + taken += damage_dealt + if(taken >= MANTIS_IMPALE_BREAK_DAMAGE) + INVOKE_ASYNC(src, PROC_REF(rip), TRUE) + +/// Either of them died, was deleted or was moved off the other. +/datum/mantis_impale/proc/on_lost(datum/source) + SIGNAL_HANDLER + if(!running) + return + // Moving within the hold (a nudge onto the same spot) is fine; apart is not. + if(!holds()) + finish() + +/** + * Lets go of both, puts everything back, and ends. Without [settle] the victim's picture is put back at once + * for the drop to draw the fall from (tear_out()); with it they ease back the way tg would. + */ +/datum/mantis_impale/proc/finish(settle = TRUE) + if(!running) + return + running = FALSE + end_exec_bar(FALSE) + if(tick_timer) + deltimer(tick_timer) + tick_timer = null + if(rig_timer) + deltimer(rig_timer) + rig_timer = null + QDEL_NULL(rig) + if(bearer) + UnregisterSignal(bearer, list(COMSIG_MOB_AFTER_APPLY_DAMAGE, COMSIG_LIVING_DEATH, COMSIG_QDELETING, COMSIG_MOVABLE_MOVED)) + bearer.remove_traits(list(TRAIT_IMMOBILIZED, TRAIT_HANDS_BLOCKED), MANTIS_IMPALE_TRAIT) + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge as anything in mantis_lunge_actions(bearer)) + if(lunge.impale == src) + lunge.impale = null + if(victim) + UnregisterSignal(victim, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIVING_POST_UPDATE_TRANSFORM)) + REMOVE_TRAIT(victim, TRAIT_IMMOBILIZED, MANTIS_IMPALE_TRAIT) + victim.remove_offsets(MANTIS_IMPALE_TRAIT, animate = settle) + if(!QDELETED(victim)) + untilt() + unhoist(fall = settle) + // Still on the floor: back to the way tg laid them. + if(settle && victim.body_position == LYING_DOWN && prior_dir) + victim.setDir(prior_dir) + if(housings) + mantis_pose_blades(housings, MANTIS_POSE_GUARD) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_housing_blades(housings)) + blade.show_inhand() + if(!QDELETED(src)) + qdel(src) diff --git a/voidcrew/modules/mantis_gore/mantis_lunge_fx.dm b/voidcrew/modules/mantis_gore/mantis_lunge_fx.dm new file mode 100644 index 00000000000..72f1f089403 --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_lunge_fx.dm @@ -0,0 +1,509 @@ +// Pictures for the Mantis line's gore. Nothing here changes who gets hit, when or how hard: the +// mechanics call in after they have happened. One-shot holders and temp visuals only; every animate() +// on a mob here is relative and parallel and ends where it began, so tg's offsets, lying turn and #509's +// death throes stay right. (The impale's hoist, which turns a body upright for the hold, is in +// mantis_impale.dm and gives tg's turn back. The blades going into a body are drawn by the blade rig, +// mantis_rig.dm.) + +// ========================================================================= +// THE LUNGE +// ========================================================================= + +/// How long a charged leap's body takes to arc in: longer than the lunge's glide (MANTIS_LUNGE_GLIDE). +#define MANTIS_LEAP_GLIDE 2 + +/// Whether a dash must stop before [step]: a drop, lava or open space. Never crossed, whatever the reach. +/proc/mantis_lunge_unsafe_turf(turf/step) + if(isnull(step)) + return TRUE + return istype(step, /turf/open/chasm) || islava(step) || isspaceturf(step) || istype(step, /turf/open/openspace) + +/// A hardlight afterimage left along the dash. +/obj/effect/temp_visual/decoy/fading/mantis_afterimage + duration = 4 + +/obj/effect/temp_visual/decoy/fading/mantis_afterimage/Initialize(mapload, atom/mimiced_atom, model, fade = 1) + . = ..() + // Washed out to the blade's light, fainter the further back down the line. + color = model == "mantis_scorch" ? list(0.5, 0.3, 0.15, 0.5, 0.3, 0.15, 0.5, 0.3, 0.15, 0.45, 0.25, 0.1) : list(0.25, 0.35, 0.5, 0.25, 0.35, 0.5, 0.25, 0.35, 0.5, 0.15, 0.3, 0.45) + alpha = round(200 * fade) + animate(src, alpha = 0, time = duration) + +/// The streak a lunge leaves at blade height across a tile it passed. +/obj/effect/temp_visual/mantis_trail + icon = MANTIS_GORE_ICON + icon_state = "mantis_trail" + layer = ABOVE_MOB_LAYER + randomdir = FALSE + duration = 5 + +/obj/effect/temp_visual/mantis_trail/Initialize(mapload, trail_dir, model) + . = ..() + if(model == "mantis_scorch") + icon_state = "mantis_scorch_trail" + // The art runs east-west and north-south; a diagonal dash uses the nearer of the two. + setDir((trail_dir & (EAST|WEST)) ? ((trail_dir & EAST) ? EAST : WEST) : ((trail_dir & NORTH) ? NORTH : SOUTH)) + add_overlay(emissive_appearance(icon, icon_state, src)) + +/** + * The dash, drawn after the lunger has already arrived: the body glides in from where it started, and + * each afterimage and streak shows as the body passes it, so the line trails behind. Returns how long the + * body takes to glide in, 0 if it went nowhere: what the dash does to its target waits that long, to land + * as the body does. + */ +/proc/mantis_lunge_dash_fx(mob/living/lunger, turf/start, list/passed, charged, model) + var/turf/finish = get_turf(lunger) + if(isnull(finish) || isnull(start) || !length(passed)) + return 0 + var/dash_dir = get_dir(start, finish) + var/count = length(passed) + var/glide = charged ? MANTIS_LEAP_GLIDE : MANTIS_LUNGE_GLIDE + // The body is already there: draw it back where it started and let it slide in. + var/back_w = (start.x - finish.x) * ICON_SIZE_X + var/back_z = (start.y - finish.y) * ICON_SIZE_Y + // The client glides a move of one tile by itself. Drawn back a tile on top of that, the body would start a + // tile behind where it stood, so here it is not drawn back: its own glide is only made to take as long. + if(get_dist(start, finish) <= 1) + lunger.set_glide_size(DELAY_TO_GLIDE_SIZE(glide)) + back_w = 0 + back_z = 0 + animate(lunger, pixel_w = back_w, pixel_z = back_z, time = 0, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL) + if(charged) + // A pounce arcs, higher the further it goes. + var/arc = min(2 * get_dist(start, finish) + 4, 16) + animate(pixel_w = -back_w * 0.5, pixel_z = -back_z * 0.5 + arc, time = glide * 0.5, easing = SINE_EASING|EASE_OUT, flags = ANIMATION_RELATIVE) + animate(pixel_w = -back_w * 0.5, pixel_z = -back_z * 0.5 - arc, time = glide * 0.5, easing = SINE_EASING|EASE_IN, flags = ANIMATION_RELATIVE) + cyberware_grey_dust(start) + else + animate(pixel_w = -back_w, pixel_z = -back_z, time = glide, easing = SINE_EASING|EASE_OUT, flags = ANIMATION_RELATIVE) + var/list/spots = list() + for(var/turf/spot as anything in passed) + spots += WEAKREF(spot) + for(var/i in 1 to count) + var/delay = round(glide * (i - 1) / count, world.tick_lag) + // Dashing away from the viewer, the last half-step afterimage would stand in front of the body it trails, + // over its legs: that one is left out. + var/half_step = !(i == count && (dash_dir & NORTH)) + if(delay <= 0) + mantis_dash_ghost(WEAKREF(lunger), spots[i], dash_dir, i / (count + 1), model, half_step) + else + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_dash_ghost), WEAKREF(lunger), spots[i], dash_dir, i / (count + 1), model, half_step), delay) + return glide + +/** + * The blades of [housings], laid flat for the dash, come back to the guard once the body has glided in, [delay] + * from now. A blade that has taken another pose since (a crouch, a raise) keeps it. + */ +/proc/mantis_lunge_settle(list/housings, delay = 0) + if(delay > 0) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_lunge_settle), housings), delay) + return + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_housing_blades(housings)) + if(blade.mantis_pose == MANTIS_POSE_LUNGE) + blade.set_mantis_pose(MANTIS_POSE_GUARD) + +/// One step of the dash's wake: two afterimages half a tile apart (one without [half_step]) and the streak, on +/// the tile the body just crossed. +/proc/mantis_dash_ghost(datum/weakref/lunger_ref, datum/weakref/spot_ref, dash_dir, fade, model, half_step = TRUE) + var/mob/living/lunger = lunger_ref?.resolve() + var/turf/spot = spot_ref?.resolve() + if(QDELETED(lunger) || isnull(spot)) + return + new /obj/effect/temp_visual/decoy/fading/mantis_afterimage(spot, lunger, model, fade * 0.7) + if(half_step) + var/obj/effect/temp_visual/decoy/fading/mantis_afterimage/half = new(spot, lunger, model, fade) + half.pixel_x += (dash_dir & EAST) ? 16 : ((dash_dir & WEST) ? -16 : 0) + half.pixel_y += (dash_dir & NORTH) ? 16 : ((dash_dir & SOUTH) ? -16 : 0) + new /obj/effect/temp_visual/mantis_trail(spot, dash_dir, model) + +/// The lunge lands: one impact and a puff of dust, as the gliding body reaches them, [delay] from now (the +/// glide mantis_lunge_dash_fx() gave; none for a body already there). A [pounce] lands with both blades, the +/// second mirrored a beat later. The flash comes with the knockdown (mantis_lunge_knockdown()). +/proc/mantis_lunge_arrival_fx(mob/living/lunger, mob/living/victim, impact_state, pounce = FALSE, delay = MANTIS_LUNGE_GLIDE) + if(QDELETED(victim)) + return + if(delay <= 0) + mantis_lunge_land_fx(WEAKREF(lunger), WEAKREF(victim), impact_state, pounce) + return + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_lunge_land_fx), WEAKREF(lunger), WEAKREF(victim), impact_state, pounce), delay) + +/// Knocks [victim] down when the lunging body lands on them, with the impact, rather than as the lunge +/// starts its glide in: [delay] from now, as for the impact. They flash as they go: after the fall has begun, +/// because tg's fall is a plain animate() and would end a flash already running. +/proc/mantis_lunge_knockdown(mob/living/victim, amount, delay = MANTIS_LUNGE_GLIDE) + if(QDELETED(victim)) + return + if(delay <= 0) + mantis_lunge_knockdown_now(WEAKREF(victim), amount) + return + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_lunge_knockdown_now), WEAKREF(victim), amount), delay) + +/proc/mantis_lunge_knockdown_now(datum/weakref/victim_ref, amount) + var/mob/living/victim = victim_ref?.resolve() + if(QDELETED(victim)) + return + victim.Knockdown(amount) + cyberware_flash_fx(victim, 0.2 SECONDS) + +/proc/mantis_lunge_land_fx(datum/weakref/lunger_ref, datum/weakref/victim_ref, impact_state, pounce) + var/mob/living/lunger = lunger_ref?.resolve() + var/mob/living/victim = victim_ref?.resolve() + if(QDELETED(lunger) || QDELETED(victim)) + return + // Skewered: the blades in them are the picture of this hit. + if(HAS_TRAIT_FROM(victim, TRAIT_IMMOBILIZED, MANTIS_IMPALE_TRAIT)) + return + cyberware_play_impact(lunger, victim, impact_state) + if(pounce) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_mirrored_impact), lunger_ref, victim_ref, impact_state), 0.4) + var/obj/effect/temp_visual/mook_dust/dust = cyberware_grey_dust(get_turf(victim)) + if(dust) + dust.transform = matrix(0.5, 0, 0, 0, 0.5, 0) + +/// The second blade's impact, from the other side. +/proc/mantis_mirrored_impact(datum/weakref/lunger_ref, datum/weakref/victim_ref, impact_state) + var/mob/living/lunger = lunger_ref?.resolve() + var/mob/living/victim = victim_ref?.resolve() + if(QDELETED(lunger) || QDELETED(victim)) + return + // Skewered: the blades in them are the picture of this hit. + if(HAS_TRAIT_FROM(victim, TRAIT_IMMOBILIZED, MANTIS_IMPALE_TRAIT)) + return + var/obj/effect/abstract/cyberware_anim/impact = cyberware_play_impact(lunger, victim, impact_state) + if(impact) + var/matrix/flipped = matrix(impact.transform) + flipped.a = -flipped.a + impact.transform = flipped + +// ========================================================================= +// THE CUTS +// ========================================================================= + +/// How far over the floor the artery of [zone] opens on [victim], as the spurt's art comes: "low" (a leg, or +/// anyone lying down), "mid" (an arm, the chest) or "high" (the neck). +/proc/mantis_artery_height(mob/living/victim, zone) + if(victim.body_position == LYING_DOWN) + return "low" + switch(zone) + if(BODY_ZONE_HEAD) + return "high" + if(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) + return "low" + return "mid" + +/// Where the artery of [zone] opens on [body], as it stands, faces and lies now, from the middle of its tile: +/// list(x, y) in pixels. The part as it is drawn (mantis_part_point()); the neck for the head. +/proc/mantis_artery_point(mob/living/body, zone) + if(zone != BODY_ZONE_HEAD) + return mantis_part_point(body, zone) + var/across = (body.dir == EAST) ? 2 : ((body.dir == WEST) ? -3 : 0) + var/matrix/shape = body.transform + return list(round(shape.a * across + shape.b * 5 + shape.c, 1), round(shape.d * across + shape.e * 5 + shape.f, 1)) + +/// How long a spurt's picture shows nothing before its drops leave the wound: the half beat a swinging blade cocks +/// back before it cuts (the slash over the target waits for it the same way, mantis_swing.dm). A tear comes with +/// the click, so without the wait its drops were in the air a frame ahead of the cut. It is the art's own first +/// frame, empty: the client plays it from the same moment as the swing, where a timer on the server could not +/// be held to it. +#define MANTIS_SPURT_WAIT (0.5 DECISECONDS) + +/// The spurt's art, by [height] and whether it is a [weak] one: list(how far out its drops come down, how far +/// below the wound, how long they are in the air). Pixels and deciseconds, as the art is drawn. +/proc/mantis_spurt_shape(height, weak) + switch(height) + if("low") + return list(weak ? 6.7 : 16.16, 6, 3) + if("high") + return list(weak ? 11.63 : 28.18, 24, 4.5) + return list(weak ? 9.8 : 23.74, 16, 4) + +/** + * One spurt out of a torn artery: a handful of drops thrown from the wound the way the cut went ([spurt_dir]), + * big and small in turn, that arc down and land as spots about a tile off ("spurt_[height]" in + * MANTIS_ARTERY_ICON, drawn for each of the eight ways). A [weak] one is fewer drops that fall close by: a + * seared artery, or a wall where the drops would have come down. Upright in the world (it does not lie down + * with the body), in the blood's own colour. Thrown away from the viewer, or out of a limb on the body's far + * side, the drops leave from behind the body; otherwise in front of it. Thrown straight up or down the screen + * they lean out to the wound's side of the body (mantis_spurt_lean()). The drops leave half a beat after the + * call (MANTIS_SPURT_WAIT), with the cut that tore the artery and never ahead of it. Returns the picture. + */ +/proc/mantis_spurt_fx(mob/living/victim, zone, spurt_dir, weak = FALSE) + if(QDELETED(victim) || !isturf(victim.loc) || victim.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return null + if(!spurt_dir) + spurt_dir = pick(GLOB.alldirs) + var/height = mantis_artery_height(victim, zone) + var/list/point = mantis_artery_point(victim, zone) + // Which side of the body's middle line, as it is drawn, the wound is on. One on the line counts as the right. + var/side = point[1] < 0 ? -1 : 1 + // The wound on the floor's own grid: the body may be drawn off the middle of its tile (lying down, shoved). + var/list/from = list(point[1] + victim.pixel_x + victim.pixel_w, point[2] + victim.pixel_y + victim.pixel_z) + var/turf/land = weak ? null : mantis_spurt_turf(victim, from, height, FALSE, spurt_dir, side) + if(!weak && (isnull(land) || hv_blood_spray_blocked(land))) + weak = TRUE + if(weak) + land = mantis_spurt_turf(victim, from, height, TRUE, spurt_dir, side) + var/list/shape = mantis_spurt_shape(height, weak) + var/state = "[height][weak ? "_weak" : ""]" + // The wait, the flight, and one beat past the landing on its last frame: the spots it shows there are the ones + // laid on the floor. + var/obj/effect/abstract/cyberware_anim/jet = cyberware_anim_play(victim, MANTIS_ARTERY_ICON, "spurt_[state]", MANTIS_ANIM_TOP_LAYER, MANTIS_SPURT_WAIT + shape[3] + world.tick_lag) + if(!jet) + return null + jet.vis_flags &= ~VIS_INHERIT_DIR + jet.setDir(spurt_dir) + // Blood in the air is no part of the body: drawn apart from it, so its layer sorts it against the whole body. + jet.appearance_flags |= RESET_TRANSFORM|RESET_COLOR|KEEP_APART + // 96x96, the wound above its middle so the drops that fall furthest (the neck's, thrown down the screen) stay + // in the picture until they land. Drawn elsewhere, not moved: it stays on the body's own row. + jet.pixel_w = -32 + point[1] + jet.pixel_z = -32 - MANTIS_ARTERY_WOUND_RISE + point[2] + jet.color = victim.get_blood_dna_color() || BLOOD_COLOR_RED + jet.layer = ((spurt_dir & NORTH) || wire_limb_far(zone, victim.dir)) ? BELOW_MOB_LAYER : MANTIS_OVER_VICTIM_LAYER + var/lean = mantis_spurt_lean(weak, spurt_dir, side) + if(lean) + // They lean from when they leave the wound, not while the picture waits. + var/wound_w = jet.pixel_w + animate(jet, pixel_w = wound_w, time = MANTIS_SPURT_WAIT) + animate(pixel_w = wound_w + lean, time = shape[3], easing = SINE_EASING|EASE_OUT) + if(land) + var/list/spot = mantis_spurt_spot(from, height, weak, spurt_dir, side) + var/offset_x = spot[1] - (land.x - victim.x) * ICON_SIZE_X + var/offset_y = spot[2] - (land.y - victim.y) * ICON_SIZE_Y + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_spurt_land), land, "artery_drops_[state]", spurt_dir, offset_x, offset_y, victim.get_blood_dna_list(), victim.get_static_viruses()), MANTIS_SPURT_WAIT + shape[3]) + return jet + +/// How far a spurt's drops lean sideways by the time they come down, in pixels. Thrown straight up or down the +/// screen out of a wound on one [side] of the body's middle line (-1 left as drawn, 1 right, 0 for no lean) they +/// would fly along the body, behind it or over it: they lean out to the wound's side and land clear of it. +/proc/mantis_spurt_lean(weak, spurt_dir, side) + if(spurt_dir != NORTH && spurt_dir != SOUTH) + return 0 + return side * (weak ? 4 : 9) + +/// Where the middle of a spurt's drops comes down, from the middle of the tile the wound is on: list(x, y). +/// [point] is the wound (mantis_artery_point()), on the [side] of the body mantis_spurt_lean() takes. +/proc/mantis_spurt_spot(list/point, height, weak, spurt_dir, side = 0) + var/list/shape = mantis_spurt_shape(height, weak) + var/out_x = (spurt_dir & EAST) ? 1 : ((spurt_dir & WEST) ? -1 : 0) + var/out_y = (spurt_dir & NORTH) ? 1 : ((spurt_dir & SOUTH) ? -1 : 0) + var/reach = shape[1] * ((out_x && out_y) ? 0.7071 : 1) + return list(point[1] + round(out_x * reach, 1) + mantis_spurt_lean(weak, spurt_dir, side), point[2] - shape[2] + round(out_y * reach, 1)) + +/// The tile a spurt's drops come down on, or null if there is none. +/proc/mantis_spurt_turf(mob/living/victim, list/point, height, weak, spurt_dir, side = 0) + var/list/spot = mantis_spurt_spot(point, height, weak, spurt_dir, side) + return locate(victim.x + round(spot[1] / ICON_SIZE_X, 1), victim.y + round(spot[2] / ICON_SIZE_Y, 1), victim.z) + +/** + * The spots a spurt of arterial blood leaves where its drops come down ("artery_drops_[...]", the last frame + * of the spurt's own art, eight ways), and the drips at the feet off the run down the body ("artery_feet_[...]"). + * Its own kind of blood, not one of the sprays: thin, and a tile keeps only a few. + * + * It is one of tg's drops of blood on purpose, with tg's own list of drop pictures. tg's bleeding feeds its + * drips to the first wet blood it finds on a tile unless that blood is drops, so someone bleeding over spots + * that were plain blood would never stand in a pool. Onto drops it lets its own drips fall as ever, and turns + * the lot into its pool in the end. + */ +/obj/effect/decal/cleanable/blood/drip/mantis_drops + name = "blood drops" + icon = MANTIS_GORE_ICON + icon_state = "artery_drops_mid" + mergeable_decal = FALSE + // Thin enough that walking through it does not leave footprints. + bloodiness = 10 + drying_time = 3 MINUTES + beauty = -15 + base_name = null + base_suffix = "drops" + /// How many drips off a run have landed here, if this is the pool at someone's feet. + var/feet_drips = 0 + +// Too thin to dive into. +/obj/effect/decal/cleanable/blood/drip/mantis_drops/can_bloodcrawl_in() + return FALSE + +/// A spurt's drops come down on [land]: its spots are laid, [offset_x] and [offset_y] pixels from the tile's +/// middle. Wet spots already there from the same beat of the same wound are only freshened, and a tile holds +/// no more than a few. Returns the spots. +/proc/mantis_spurt_land(turf/land, state, spurt_dir, offset_x, offset_y, list/blood_dna, list/viruses) + if(!isturf(land) || !length(blood_dna) || hv_blood_spray_blocked(land) || isgroundlessturf(land) || !land.has_gravity()) + return null + var/laid = 0 + for(var/obj/effect/decal/cleanable/blood/drip/mantis_drops/wet in land) + if(wet.dried || wet.feet_drips || QDELETED(wet)) + continue + laid++ + if(laid >= 4 || (wet.icon_state == state && wet.dir == spurt_dir && wet.pixel_x == offset_x && wet.pixel_y == offset_y)) + wet.add_blood_DNA(blood_dna, viruses) + return wet + var/obj/effect/decal/cleanable/blood/drip/mantis_drops/drops = new(land, viruses, blood_dna) + if(QDELETED(drops)) + return null + drops.icon_state = state + drops.setDir(spurt_dir) + drops.pixel_x = offset_x + drops.pixel_y = offset_y + return drops + +/// The blood run down a body from a torn artery (mantis_artery_run_fx()). +/obj/effect/abstract/cyberware_anim/mantis_run + icon = MANTIS_GORE_ICON + layer = MANTIS_ANIM_TOP_LAYER + /// The part it runs from. + var/zone + +/// Run its length: a still picture from here on, whichever way the body turns. +/obj/effect/abstract/cyberware_anim/mantis_run/proc/ran() + icon_state = "artery_ran_[zone]" + +/// A drip falls off the run's lower end and lands at the feet. +/obj/effect/abstract/cyberware_anim/mantis_run/proc/drip() + var/mob/living/body = bearer + if(QDELETED(src) || !istype(body) || QDELETED(body) || body.body_position == LYING_DOWN) + return + mantis_feet_drip(body, zone) + +/// Where the run down a body from [zone] comes to the sole of a body facing [facing], in pixels across from the +/// middle of its tile: the lower end of the art's own run ("artery_ran_[zone]"). Where the part is on the body's +/// far side and the run can't be seen, the sole the blood comes down to all the same. +/proc/mantis_artery_run_foot(zone, facing) + var/static/list/feet = list( + BODY_ZONE_HEAD = list("[SOUTH]" = 0, "[NORTH]" = 0, "[EAST]" = 3, "[WEST]" = -2), + BODY_ZONE_CHEST = list("[SOUTH]" = 1, "[NORTH]" = 0, "[EAST]" = 3, "[WEST]" = -2), + BODY_ZONE_L_ARM = list("[SOUTH]" = 5, "[NORTH]" = -7, "[EAST]" = -1, "[WEST]" = 2), + BODY_ZONE_R_ARM = list("[SOUTH]" = -6, "[NORTH]" = 5, "[EAST]" = -1, "[WEST]" = 2), + BODY_ZONE_L_LEG = list("[SOUTH]" = 4, "[NORTH]" = -2, "[EAST]" = 0, "[WEST]" = 2), + BODY_ZONE_R_LEG = list("[SOUTH]" = -3, "[NORTH]" = 2, "[EAST]" = 0, "[WEST]" = 2), + ) + var/list/by_facing = feet[zone] + return by_facing?["[facing]"] + +/** + * A drip off the blood run down [victim] from [zone] lands at the feet, two pixels under the sole the run comes + * down to: a spot there ("artery_feet_1"), wider with the next, a small pool with the third. Nothing where no + * blood would lie. Returns the spot. + */ +/proc/mantis_feet_drip(mob/living/victim, zone) + if(QDELETED(victim) || !isturf(victim.loc) || victim.can_bleed(BLOOD_COVER_TURFS) != BLEED_SPLATTER) + return null + var/foot = mantis_artery_run_foot(zone, victim.dir) + if(isnull(foot)) + return null + // The sole is the body picture's lowest row, 15 pixels under the middle of the tile, wherever the body is drawn. + var/matrix/shape = victim.transform + var/drip_x = round(shape.a * foot + shape.b * -15 + shape.c, 1) + victim.pixel_x + victim.pixel_w + var/drip_y = round(shape.d * foot + shape.e * -15 + shape.f, 1) + victim.pixel_y + victim.pixel_z - 2 + var/turf/land = locate(victim.x + round(drip_x / ICON_SIZE_X, 1), victim.y + round(drip_y / ICON_SIZE_Y, 1), victim.z) + if(!isturf(land) || isgroundlessturf(land) || !land.has_gravity() || (land != victim.loc && hv_blood_spray_blocked(land))) + return null + var/offset_x = drip_x - (land.x - victim.x) * ICON_SIZE_X + var/offset_y = drip_y - (land.y - victim.y) * ICON_SIZE_Y + for(var/obj/effect/decal/cleanable/blood/drip/mantis_drops/wet in land) + if(!wet.feet_drips || wet.dried || QDELETED(wet) || wet.pixel_x != offset_x || wet.pixel_y != offset_y) + continue + wet.feet_drips = min(wet.feet_drips + 1, 3) + wet.icon_state = "artery_feet_[wet.feet_drips]" + wet.add_blood_DNA(victim.get_blood_dna_list(), victim.get_static_viruses()) + return wet + var/obj/effect/decal/cleanable/blood/drip/mantis_drops/pool = new(land, victim.get_static_viruses(), victim.get_blood_dna_list()) + if(QDELETED(pool)) + return null + pool.feet_drips = 1 + pool.icon_state = "artery_feet_1" + pool.pixel_x = offset_x + pool.pixel_y = offset_y + return pool + +/** + * The blood of a torn artery runs down [victim]'s body from the wound on [zone] to the feet: a thin broken + * line that grows over half a second and stays ("artery_run_[zone]", then "artery_ran_[zone]", drawn for the + * body's four facings; nothing where the part is on the body's far side). Part of the body: it turns and lies + * down with it. It lasts as long as [torn], the wound. Only on someone upright: lying down, the blood goes + * straight to the floor. Returns the picture. + */ +/proc/mantis_artery_run_fx(mob/living/victim, zone, datum/wound/torn) + if(QDELETED(victim) || QDELETED(torn) || victim.body_position == LYING_DOWN) + return null + if(!icon_exists(MANTIS_GORE_ICON, "artery_run_[zone]")) + return null + var/obj/effect/abstract/cyberware_anim/mantis_run/run = new(null) + run.bearer = victim + run.zone = zone + run.icon_state = "artery_run_[zone]" + run.appearance_flags |= RESET_COLOR + run.color = victim.get_blood_dna_color() || BLOOD_COLOR_RED + run.RegisterSignal(victim, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + // The wound closing, or going with its limb, takes the run with it. + run.RegisterSignal(torn, COMSIG_QDELETING, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim, on_bearer_deleted)) + victim.vis_contents += run + addtimer(CALLBACK(run, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim/mantis_run, ran)), 0.8 SECONDS) + // It comes to the feet, and three drips fall off it there. + for(var/wait in list(0.6 SECONDS, 0.95 SECONDS, 1.25 SECONDS)) + addtimer(CALLBACK(run, TYPE_PROC_REF(/obj/effect/abstract/cyberware_anim/mantis_run, drip)), wait) + return run + +/// A Scorch cut: a white-hot seam across the limb that cools to char. +/proc/mantis_scorch_seam_fx(mob/living/carbon/victim, obj/item/bodypart/limb) + var/state = "scorch_gash_[limb.body_zone]" + if(!icon_exists(MANTIS_GORE_ICON, state)) + return null + return cyberware_anim_play(victim, MANTIS_GORE_ICON, state, MANTIS_ANIM_BLADE_LAYER, 1.5 SECONDS, glow = TRUE) + +/// The X-slash lands: a flash of light off the blades. The two crossed strokes are drawn with the blades' own +/// swings (mantis_xslash_cross(), mantis_swing.dm). +/proc/mantis_xslash_fx(mob/living/user, mob/living/victim, impact_state) + if(QDELETED(victim)) + return + cyberware_flash_fx(victim, 0.15 SECONDS) + victim.mob_light(2, 1.5, impact_state == "impact_scorch" ? LIGHT_COLOR_FIRE : "#bfe6ff", 0.2 SECONDS) + +// ========================================================================= +// IMPALE, SCISSOR, CROUCH +// ========================================================================= + +/// The way [looker] turns to look at [seen], as face_atom() picks it, whatever state [looker] is in. +/proc/mantis_face_dir(atom/looker, atom/seen) + var/dx = seen.x - looker.x + var/dy = seen.y - looker.y + if(abs(dx) < abs(dy)) + return dy > 0 ? NORTH : SOUTH + return dx > 0 ? EAST : WEST + +/// How [victim] lies, for the scissor's art: "stand", or "lie90"/"lie270" by the way tg has turned them. +/proc/mantis_scissor_posture(mob/living/victim) + if(victim.body_position != LYING_DOWN || !victim.rotate_on_lying) + return "stand" + return victim.lying_angle == 270 ? "lie270" : "lie90" + +/// Someone under the raised blades shudders: small sideways jolts, relative, ending where they began. +/proc/mantis_struggle_fx(mob/living/victim, duration) + if(QDELETED(victim)) + return + var/static/list/jolts = list(1, -1, 1, 0, -1, 1, -1, 0) + var/step_time = duration / length(jolts) + var/offset = 0 + for(var/i in 1 to length(jolts)) + var/shift = jolts[i] - offset + offset = jolts[i] + if(i == 1) + animate(victim, pixel_w = shift, time = step_time, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL) + else + animate(pixel_w = shift, time = step_time, flags = ANIMATION_RELATIVE) + +/// The crouched blade's glow, brightening over the charge. Gone with the crouch. +/proc/mantis_coil_glow_fx(mob/living/bearer, obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade) + var/state = "[blade.base_icon_state]_coil_glow_[blade.hand_side()]" + if(!icon_exists(MANTIS_GORE_ICON, state)) + return null + var/obj/effect/abstract/cyberware_anim/glow = cyberware_anim_play(bearer, MANTIS_GORE_ICON, state, MANTIS_ANIM_BLADE_LAYER, MANTIS_CHARGE_MAX_HOLD + 1 SECONDS, glow = TRUE) + if(!glow) + return null + // Side on, the far blade's glow stays behind the near blade. + glow.sort_as_arm(blade.hand_side()) + glow.alpha = 0 + animate(glow, alpha = 255, time = MANTIS_CHARGE_FULL - MANTIS_CHARGE_TAP) + return glow + +#undef MANTIS_LEAP_GLIDE +#undef MANTIS_SPURT_WAIT diff --git a/voidcrew/modules/mantis_gore/mantis_rig.dm b/voidcrew/modules/mantis_gore/mantis_rig.dm new file mode 100644 index 00000000000..ce74f3981f6 --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_rig.dm @@ -0,0 +1,568 @@ +/** + * # The blade rig: the impale and the scissor, drawn around the victim + * + * Both moves need parts of the bearer under the victim and parts over it: in the side view the far blade + * and the bearer's body go under the person skewered and the near arm and blade over them, and the far + * blade passes under a neck on the floor while the bearer stands over it. Pictures attached to a mob + * (overlays, underlays, vis_contents) are drawn with the mob, so they can't sit between two mobs. So for + * these moves the bearer is drawn as separate pictures ("puppets") standing on their tile, each with its + * own layer next to the victim's, the way the Gorilla Arms finishers draw their arm rig + * (voidcrew/modules/hyperviolence_gorilla/chrome_puppet_rig.dm): + * + * - "body": a copy of the bearer's appearance without the held blades, and without the hands seen from the + * front or back, where the blades' forearms take their place. + * - The arms and blades of each beat, from mantis_gore_reach.dmi: "___", 96x96 with + * the bearer's tile in the middle. Steel inside the victim on the camera's side of them is cut out of its + * piece; steel on their far side is drawn under them and left to their outline. Blood on the blades is a coat over + * each piece ("_blood" or "_soak", the held art's two coats) tinted by the blood, read off the held + * blades, so a blade already wet stays wet and one drenched in the move turns red as it happens. The impale + * also has wet points from the moment they come out of the back, in the victim's blood. + * - Pieces of the victim's blood: "wound" (where the steel goes in and out) and "drip" (drops off the points), + * and "glint", the light on the near blade before the scissor. Sprays, and the crackle of the blades' light + * at the points as they punch out, are loose pictures (burst()) that stay where they started and outlive the beat. + * - The map is SIDE_MAP: rows sort before layers, so every picture is centred with pixel_w/pixel_z and stands on + * the row of what it must sort against (sort_y()). + * + * mantis_rig_beat() has each beat's stack, back to front, with "T" where the victim goes, and the lean. + * Puppets are plain objects on the bearer's tile, so nothing touches the real bearer's own picture, + * offsets or layer; the real bearer is hidden with a colour filter (still clickable over its whole tile) + * and comes back when the rig is deleted. Its owner deletes it on every way the move ends. + */ + +#define MANTIS_RIG_HIDE_FILTER "mantis_rig_hide" +/// The gap between two neighbours in the stack around the victim. +#define MANTIS_RIG_LAYER_STEP 0.001 + +/** + * One beat of [move] seen facing [facing], from the approved storyboards (S/mantis-storyboard): list(order, + * bearer_w, bearer_z, target_w, target_z, tilt, raise). Order is the stack back to front: "T" is the victim, + * "body" the bearer's flat picture without the held blades, "whole" that picture as the bearer is held (blades + * and all), anything else a piece. Bearer and target are pixel offsets from their own tiles; tilt turns the + * victim about the feet (degrees, clockwise); raise is how high the fists ride in the body picture (0 leaves + * it). West is east mirrored. + */ +/proc/mantis_rig_beat(move, beat, facing) + var/view = (facing & (EAST|WEST)) ? "E" : (facing == NORTH ? "N" : "S") + var/list/spec + switch("[move]_[beat]_[view]") + // ---- The impale. "arrive" glides in with the lunging body. "contact" is the slide onto the blades: whole + // blades, and everything on the far side of the target (the near blade past the fist, "nrest", in the side + // view) drawn under them, so the target itself covers the steel it has slid onto. Then they are in: "enter". + if("impale_arrive_E") + spec = list(list("T", "far", "body", "near"), 2, 0, 0, 0, 0, 2) + if("impale_contact_E") + spec = list(list("far", "body", "nrest", "T", "narm", "near"), 7, 0, -17, 0, 0, 1) + // From the stab to the hold the blades go through the same place on the target: "enter", "lift1" and "lift2" + // are the hold's blades 4, 2 and 1 px lower, with the target. The steel inside them is cut out of the near + // blade; the far blade is under them. + if("impale_enter_E") + spec = list(list("far", "body", "T", "wound", "narm", "near"), 7, 0, -17, 0, 0, 1) + if("impale_lift1_E") + spec = list(list("far", "body", "T", "wound", "narm", "near"), 7, 0, -17, 2, 0, 2) + if("impale_lift2_E") + spec = list(list("far", "body", "T", "wound", "narm", "near"), 7, 0, -17, 3, 0, 2) + if("impale_hold_E") + spec = list(list("far", "body", "T", "wound", "drip", "narm", "near"), 7, 0, -17, 4, 0, 2) + // The pull-back in three steps: the bearer leans back, the arms draw back and the target slides off, + // 3 px of steel out a step. Only what has come out of the front shows. + if("impale_pull1_E") + spec = list(list("far", "body", "T", "wound", "narm", "near"), 6, 0, -16, 3, 0, 2) + if("impale_pull2_E") + spec = list(list("far", "body", "T", "wound", "narm", "near"), 5, 0, -15, 2, 0, 2) + if("impale_pull3_E") + spec = list(list("far", "body", "T", "wound", "narm", "near"), 4, 0, -14, 1, 0, 2) + if("impale_rip_E") + spec = list(list("far", "body", "T", "near"), 6, 0, -12, 2, 14, 1) + if("impale_drop_E") + spec = list(list("T", "far", "body", "near"), 0, 0, 0, 0, 0, 2) + // Seen from behind the target is on the row beyond the bearer, facing the camera. The blades go into the + // chest a torso's width apart: "arms" is the forearms and the fists, which the bearer's back hides; "tips" + // is the blades, drawn behind the target: what shows of them is the points past the shoulders by the neck. + if("impale_arrive_N") + spec = list(list("T", "arms", "body"), 0, 2, 0, 0, 0, 0) + if("impale_contact_N", "impale_enter_N") + spec = list(list("tips", "T", "arms", "body"), 0, 24, 0, 0, 0, 0) + if("impale_lift1_N") + spec = list(list("tips", "T", "arms", "body"), 0, 24, 0, 2, 0, 0) + if("impale_lift2_N") + spec = list(list("tips", "T", "arms", "body"), 0, 24, 0, 3, 0, 0) + if("impale_hold_N") + spec = list(list("tips", "T", "arms", "body"), 0, 24, 0, 4, 0, 0) + if("impale_pull1_N") + spec = list(list("tips", "T", "arms", "body"), 0, 23, 0, 3, 0, 0) + if("impale_pull2_N") + spec = list(list("tips", "T", "arms", "body"), 0, 22, 0, 2, 0, 0) + if("impale_pull3_N") + spec = list(list("tips", "T", "arms", "body"), 0, 21, 0, 1, 0, 0) + if("impale_rip_N") + spec = list(list("T", "arms", "body"), 0, 15, 0, 0, 0, 0) + // The drop from the front and the back is the bearer as they are held again ("whole": the guard, blood and + // all), so nothing changes when the real bearer comes back. + if("impale_drop_N") + spec = list(list("T", "whole"), 0, 0, 0, 0, 0, 0) + // Seen from the front the target is on the row before the bearer, their back to the camera, and covers the + // bearer's arms and the steel going in. "tips" is the two points out of their back, over them. + if("impale_arrive_S") + spec = list(list("body", "arms", "T"), 0, -2, 0, 0, 0, 0) + if("impale_contact_S") + spec = list(list("body", "arms", "T"), 0, 0, 0, 24, 0, 0) + if("impale_enter_S") + spec = list(list("body", "arms", "T", "wound", "tips"), 0, 0, 0, 24, 0, 0) + if("impale_lift1_S") + spec = list(list("body", "arms", "T", "wound", "tips"), 0, 0, 0, 26, 0, 0) + if("impale_lift2_S") + spec = list(list("body", "arms", "T", "wound", "tips"), 0, 0, 0, 27, 0, 0) + if("impale_hold_S") + spec = list(list("body", "arms", "T", "wound", "tips", "drip"), 0, 0, 0, 28, 0, 0) + if("impale_pull1_S") + spec = list(list("body", "arms", "T", "wound", "tips"), 0, 0, 0, 27, 0, 0) + if("impale_pull2_S") + spec = list(list("body", "arms", "T", "wound", "tips"), 0, 0, 0, 25, 0, 0) + if("impale_pull3_S") + spec = list(list("body", "arms", "T", "wound", "tips"), 0, 0, 0, 23, 0, 0) + if("impale_rip_S") + spec = list(list("body", "arms", "T"), 0, -2, 0, 13, 0, 0) + // They fall in front of the bearer, and are drawn over them all the way down. + if("impale_drop_S") + spec = list(list("whole", "T"), 0, 0, 0, 0, 0, 0) + // ---- The scissor. + if("scissor_raise_E") + spec = list(list("T", "far", "body", "near"), 0, 0, 0, 0, 0, 3) + if("scissor_glint_E") + spec = list(list("T", "far", "body", "near", "glint"), 0, 0, 0, 0, 0, 3) + // Half way down from the raise to the close: the swing. + if("scissor_swing_E") + spec = list(list("T", "far", "body", "near"), 5, 0, 0, 0, 0, 2) + if("scissor_close_E", "scissor_cut_E") + spec = list(list("fblade", "T", "farm", "body", "near"), 10, 0, 0, 0, 0, 1) + if("scissor_recover_E") + spec = list(list("T", "far", "body", "near"), 0, 0, 0, 0, 0, 2) + if("scissor_raise_N", "scissor_recover_N") + spec = list(list("T", "arms", "body"), 0, 0, 0, 0, 0, 0) + if("scissor_glint_N") + spec = list(list("T", "arms", "glint", "body"), 0, 0, 0, 0, 0, 0) + if("scissor_close_N", "scissor_cut_N") + spec = list(list("T", "arms", "body"), 0, 10, 0, 0, 0, 0) + if("scissor_raise_S", "scissor_recover_S") + spec = list(list("T", "body", "arms"), 0, 0, 0, 0, 0, 0) + if("scissor_glint_S") + spec = list(list("T", "body", "arms", "glint"), 0, 0, 0, 0, 0, 0) + if("scissor_swing_S") + spec = list(list("T", "body", "arms"), 0, -8, 0, 0, 0, 0) + if("scissor_close_S", "scissor_cut_S") + spec = list(list("T", "body", "arms"), 0, -16, 0, 0, 0, 0) + if(isnull(spec)) + return null + if(facing & WEST) + spec[MANTIS_RIG_BEARER_W] = -spec[MANTIS_RIG_BEARER_W] + spec[MANTIS_RIG_TARGET_W] = -spec[MANTIS_RIG_TARGET_W] + spec[MANTIS_RIG_TILT] = -spec[MANTIS_RIG_TILT] + return spec + +/// The way the rig draws a move from [user] to [victim]: the side view for anything off to the side. +/proc/mantis_rig_facing(atom/user, atom/victim) + var/toward = get_dir(user, victim) || user.dir + if(toward & EAST) + return EAST + if(toward & WEST) + return WEST + return toward & NORTH ? NORTH : SOUTH + +/// One picture of the rig on the bearer's tile. +/obj/effect/abstract/mantis_puppet + name = "body" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + appearance_flags = PIXEL_SCALE | TILE_BOUND | LONG_GLIDE + animate_movement = NO_STEPS + plane = GAME_PLANE + layer = MOB_LAYER + vis_flags = NONE + /// Pixels it is drawn off the bearer's lean (pixel_w, pixel_z): a 96x96 piece is centred on the tile, and + /// one standing on another row (mantis_rig/proc/set_row()) is drawn back where it belongs. + var/shift_w = 0 + var/shift_z = 0 + +/// A spray of the victim's blood drawn by the rig: it stays where it started and goes on its own. +/obj/effect/abstract/mantis_rig_fx + name = "blood" + icon = MANTIS_GORE_REACH_ICON + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + appearance_flags = PIXEL_SCALE | TILE_BOUND | LONG_GLIDE + animate_movement = NO_STEPS + plane = GAME_PLANE + layer = MOB_LAYER + vis_flags = NONE + +/datum/mantis_rig + /// Who is drawn + var/mob/living/carbon/bearer + /// Whom the stack is built around + var/mob/living/victim + /// The way the pictures face + var/facing + /// The blades' model, for the pieces + var/model + /// "impale" or "scissor" + var/move + /// Key -> /obj/effect/abstract/mantis_puppet + var/list/puppets = list() + /// The beat drawn now + var/beat + /// How high the fists ride in the body picture now + var/raise = 0 + /// The bearer's own offsets when the rig went up, under every lean + var/base_w = 0 + var/base_z = 0 + /// The lean drawn now, from base_w and base_z + var/lean_w = 0 + var/lean_z = 0 + /// TRUE while the real bearer is hidden + var/hidden = FALSE + var/old_mouse_opacity + /// The victim's layer when the beat drawn now went up + var/victim_layer = MOB_LAYER + /// The colour of the victim's blood, or null if they don't bleed + var/victim_color + /// TRUE once the points have been through the victim: wet with their blood even before a drench + var/wet = FALSE + /// The blood on the blades drawn now: null, "blood" or "soak" (the held art's coats), and its colour + var/coat + var/coat_color + /// TRUE while the pictures fade out and the real bearer fades back in (hand_back()) + var/handing_back = FALSE + /// TRUE while the body picture is the bearer as they are held, blades and all ("whole") + var/whole = FALSE + +/datum/mantis_rig/New(mob/living/carbon/bearer, mob/living/victim, facing, model, move) + . = ..() + src.bearer = bearer + src.victim = victim + src.facing = facing + src.model = model + src.move = move + RegisterSignal(bearer, COMSIG_QDELETING, PROC_REF(on_bearer_deleted)) + // A kill while the rig draws the blades only stains them: the rig draws the blood it leaves (mantis_kill_credit()). + bearer.get_mantis_state().rig = src + if(victim) + RegisterSignal(victim, COMSIG_QDELETING, PROC_REF(on_victim_deleted)) + if(victim.can_bleed(BLOOD_COVER_TURFS) == BLEED_SPLATTER) + var/datum/blood_type/blood = victim.get_bloodtype() + victim_color = blood?.get_color() + +/datum/mantis_rig/Destroy() + reveal() + for(var/key in puppets) + qdel(puppets[key]) + puppets = null + if(bearer) + UnregisterSignal(bearer, COMSIG_QDELETING) + if(bearer.mantis_state?.rig == src) + bearer.mantis_state.rig = null + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + blade.show_inhand() + if(victim) + UnregisterSignal(victim, COMSIG_QDELETING) + bearer = null + victim = null + return ..() + +/datum/mantis_rig/proc/on_bearer_deleted(datum/source) + SIGNAL_HANDLER + qdel(src) + +/datum/mantis_rig/proc/on_victim_deleted(datum/source) + SIGNAL_HANDLER + UnregisterSignal(victim, COMSIG_QDELETING) + victim = null + +/** + * Puts the rig up: hides the held blades and the real bearer and stands the body picture in its place. + * FALSE if the bearer can't be drawn this way (not on a turf); the move goes on without the poses. + */ +/datum/mantis_rig/proc/start() + if(QDELETED(bearer) || !isturf(bearer.loc)) + return FALSE + base_w = bearer.pixel_w - bearer.has_offset(HV_FINISHER_OFFSET, PIXEL_W_OFFSET) + base_z = bearer.pixel_z - bearer.has_offset(HV_FINISHER_OFFSET, PIXEL_Z_OFFSET) + snapshot() + conceal() + return TRUE + +/** + * Draws the body puppet as the bearer looks now, without the held blades: a copy of the bearer's own + * appearance, so the client already has every icon in it and it never blinks while one downloads. Seen from + * the front or back the hands and gloves are left off: the forearms of the blades start at the elbows. + * [as_held]: the bearer exactly as they are held, blades, hands and all, for a beat that ends on the held art. + */ +/datum/mantis_rig/proc/snapshot(as_held = FALSE) + whole = as_held + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + if(as_held) + blade.show_inhand() + else + blade.hide_inhand_for(10 SECONDS) + var/mutable_appearance/look = new(bearer.appearance) + look.filters = null + if(!as_held && (facing & (NORTH|SOUTH))) + for(var/image/part as anything in look.overlays.Copy()) + if(part.layer == -GLOVES_LAYER || findtext("[part.icon_state]", "_hand")) + look.overlays -= part + var/obj/effect/abstract/mantis_puppet/body = puppet("body") + var/body_layer = body.layer + var/body_row = body.pixel_y + body.appearance = look + body.dir = facing + body.layer = body_layer + body.mouse_opacity = MOUSE_OPACITY_TRANSPARENT + body.pixel_x = own_x() + body.pixel_y = body_row + body.pixel_w = base_w + lean_w + body.shift_w + body.pixel_z = base_z + lean_z + body.shift_z + +/** + * The bearer's pixel_x and pixel_y under the rig's own lean: without a #509 finisher's lean (pose_user()), which + * the rig draws itself. pixel_y is also the row the pictures sort on. + */ +/datum/mantis_rig/proc/own_x() + return bearer.pixel_x - bearer.has_offset(HV_FINISHER_OFFSET, PIXEL_X_OFFSET) + +/datum/mantis_rig/proc/own_y() + return bearer.pixel_y - bearer.has_offset(HV_FINISHER_OFFSET, PIXEL_Y_OFFSET) + +/// The fists ride [new_raise] pixels high in the body picture (mantis_stance_raise()). +/datum/mantis_rig/proc/set_raise(new_raise) + if(!new_raise || new_raise == raise || QDELETED(bearer)) + return + raise = new_raise + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = blade.housing_ref?.resolve() + housing?.set_stance_raise(new_raise) + if(puppets["body"]) + snapshot(whole) + +/// The puppet under [key], made on the bearer's tile at the lean drawn now if there isn't one. +/datum/mantis_rig/proc/puppet(key) + var/obj/effect/abstract/mantis_puppet/picture = puppets[key] + if(picture) + return picture + picture = new(get_turf(bearer)) + picture.name = bearer.name + picture.pixel_x = own_x() + picture.pixel_y = own_y() + // Centred with pixel_w and pixel_z only: pixel_y picks the row it sorts on (set_row()). + if(key != "body") + picture.icon = MANTIS_GORE_REACH_ICON + picture.shift_w = -ICON_SIZE_X + picture.shift_z = -ICON_SIZE_Y + picture.pixel_w = base_w + lean_w + picture.shift_w + picture.pixel_z = base_z + lean_z + picture.shift_z + puppets[key] = picture + return picture + +/** + * The pixel_y, from the bearer's tile, of the row a picture drawn [behind] the victim (or in front of them) + * sorts on. The map is SIDE_MAP: BYOND sorts by row (a tile's y plus pixel_y) before layer, so a picture + * only sorts against the victim by its layer on the victim's own row. One the bearer's row already puts on + * the right side of the victim stays on the bearer's row, under or over everything else there as before. + */ +/datum/mantis_rig/proc/sort_y(behind) + var/own = own_y() + if(!victim || QDELETED(victim) || victim.z != bearer.z || !isturf(victim.loc)) + return own + var/theirs = (victim.y - bearer.y) * ICON_SIZE_Y + victim.pixel_y + if(behind ? own > theirs : own < theirs) + return own + return theirs + +/// Stands [picture] on the row [row_y], still drawn where it was. +/datum/mantis_rig/proc/set_row(obj/effect/abstract/mantis_puppet/picture, row_y) + var/change = row_y - picture.pixel_y + if(!change) + return + picture.pixel_y = row_y + picture.shift_z -= change + picture.pixel_z -= change + +/** + * Draws [new_beat]: each piece of its stack is swapped in at its layer next to the victim's, pieces it + * doesn't use go, and the whole bearer leans to the beat's lean, plus [extra_w] and [extra_z], over [time]. + * With [from_w] or [from_z] every picture starts that far off and glides into place over [time] instead, the + * way the lunging body glides in (mantis_lunge_dash_fx()): one animation, so the client sees the start. + * [ride_z] lifts everything but the bearer's body that far: the arms and the blades riding with someone who + * sags on them, so the steel in them stays where it is in them. [body_z] lifts the bearer's body and the arms + * on it ("arms": the forearms and fists) that far: the hands stay on the wrists while the blades' points stay put. + */ +/datum/mantis_rig/proc/show(new_beat, extra_w = 0, extra_z = 0, time = 0.1 SECONDS, from_w = 0, from_z = 0, easing = SINE_EASING, ride_z = 0, body_z = 0) + if(QDELETED(bearer)) + return + var/list/spec = mantis_rig_beat(move, new_beat, facing) + if(!spec) + return + beat = new_beat + set_raise(spec[MANTIS_RIG_RAISE]) + var/list/order = spec[MANTIS_RIG_ORDER] + var/victim_at = order.Find("T") + victim_layer = (victim && !QDELETED(victim)) ? victim.layer : bearer.layer + var/list/used = list() + for(var/i in 1 to length(order)) + var/key = order[i] + if(key == "T") + continue + // The victim's own blood: nothing to draw on someone who doesn't bleed. + var/bloody = (key == "wound" || key == "drip") + if(bloody && !victim_color) + continue + // The body picture, with or without the held blades. + if(key == "whole" || key == "body") + if((key == "whole") != whole) + snapshot(key == "whole") + key = "body" + var/obj/effect/abstract/mantis_puppet/picture = puppet(key) + if(key != "body") + var/state = "[model]_[move]_[beat]_[key]" + // A looping picture (the drops) would start over if it were set again. + if(picture.icon_state != state) + picture.icon_state = state + picture.dir = facing + if(bloody) + picture.color = victim_color + picture.layer = victim_layer + (i - victim_at) * MANTIS_RIG_LAYER_STEP + set_row(picture, sort_y(i < victim_at)) + used[key] = TRUE + for(var/key in puppets.Copy()) + if(!used[key]) + qdel(puppets[key]) + puppets -= key + dress() + lean_w = spec[MANTIS_RIG_BEARER_W] + extra_w + lean_z = spec[MANTIS_RIG_BEARER_Z] + extra_z + for(var/key in puppets) + var/obj/effect/abstract/mantis_puppet/picture = puppets[key] + var/to_w = base_w + lean_w + picture.shift_w + var/to_z = base_z + lean_z + picture.shift_z + (key == "body" ? body_z : ride_z) + (key == "arms" ? body_z : 0) + if(from_w || from_z) + picture.pixel_w = to_w + from_w + picture.pixel_z = to_z + from_z + // At once, ending whatever was still moving it. + if(!time) + animate(picture, pixel_w = to_w, pixel_z = to_z, time = 0) + continue + animate(picture, pixel_w = to_w, pixel_z = to_z, time = time, easing = easing) + +/** + * Blood on the blades as the held blades have it now: the heavier coat while one is drenched, the light one + * while one is only stained, and at least the light one in the victim's blood once the points have been + * through them. A blade that keeps itself clean (the Scorch) shows none. + */ +/datum/mantis_rig/proc/read_coat() + coat = null + coat_color = null + if(QDELETED(bearer)) + return + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + if(blade.item_flags & NO_BLOOD_ON_ITEM) + coat = null + return + if(!blade.is_bloody() || coat == "soak") + continue + coat = world.time < blade.soaked_until ? "soak" : "blood" + coat_color = blade.get_blood_dna_color() + if(!coat && wet && victim_color) + coat = "blood" + coat_color = victim_color + +/// Puts the blood on every blade piece drawn now (read_coat()). +/datum/mantis_rig/proc/dress() + read_coat() + for(var/key in puppets) + if(key == "body" || key == "wound" || key == "drip" || key == "glint") + continue + var/obj/effect/abstract/mantis_puppet/picture = puppets[key] + picture.cut_overlays() + if(!coat) + continue + var/state = "[picture.icon_state]_[coat]" + if(!icon_exists(MANTIS_GORE_REACH_ICON, state)) + continue + var/mutable_appearance/blood = mutable_appearance(MANTIS_GORE_REACH_ICON, state) + blood.color = coat_color + picture.add_overlay(blood) + +/** + * A spray of the victim's blood, "__", drawn where the beat drawn now puts it and left + * there for [lifetime]: just over (or, with [under], just under) the piece [key], or the victim for "T". + * Not [blood]: a flash of the blades' own light, drawn in its own colours. + */ +/datum/mantis_rig/proc/burst(name, lifetime, key = "T", under = FALSE, blood = TRUE) + if(QDELETED(bearer) || (blood && !victim_color)) + return null + var/state = "[model]_[move]_[name]" + if(!icon_exists(MANTIS_GORE_REACH_ICON, state)) + return null + var/obj/effect/abstract/mantis_rig_fx/spray = new(get_turf(bearer)) + spray.icon_state = state + spray.dir = facing + if(blood) + spray.color = victim_color + else + spray.name = "light" + var/obj/effect/abstract/mantis_puppet/beside = puppets[key] + var/beside_layer = beside ? beside.layer : victim_layer + spray.layer = beside_layer + (under ? -0.5 : 0.5) * MANTIS_RIG_LAYER_STEP + // On the row of what it sorts against, centred with pixel_w and pixel_z (set_row()). + spray.pixel_x = own_x() + spray.pixel_y = beside ? beside.pixel_y : sort_y(under) + spray.pixel_w = base_w + lean_w - ICON_SIZE_X + spray.pixel_z = base_z + lean_z - ICON_SIZE_Y + own_y() - spray.pixel_y + QDEL_IN(spray, lifetime) + return spray + +/** + * The move is over: the real bearer, held blades and all, is drawn again at once, and the pictures, lifted + * over it in the same order, fade out over [time]. A pose that differs from the held art eases into it + * instead of jumping, and nothing is ever see-through: the real bearer underneath is whole. Then the rig goes. + */ +/datum/mantis_rig/proc/hand_back(time = MANTIS_RIG_HANDBACK) + if(handing_back || QDELETED(src)) + return + handing_back = TRUE + if(QDELETED(bearer) || !time) + qdel(src) + return + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + blade.show_inhand() + reveal() + var/lowest + for(var/key in puppets) + var/obj/effect/abstract/mantis_puppet/picture = puppets[key] + lowest = isnull(lowest) ? picture.layer : min(lowest, picture.layer) + var/lift = isnull(lowest) ? 0 : max(0, bearer.layer - lowest + MANTIS_RIG_LAYER_STEP) + for(var/key in puppets) + var/obj/effect/abstract/mantis_puppet/picture = puppets[key] + picture.layer += lift + animate(picture, alpha = 0, time = time, flags = ANIMATION_PARALLEL) + QDEL_IN(src, time) + +/// Hides the real bearer. Its whole tile still takes clicks. +/datum/mantis_rig/proc/conceal() + if(hidden || QDELETED(bearer)) + return + hidden = TRUE + old_mouse_opacity = bearer.mouse_opacity + bearer.mouse_opacity = MOUSE_OPACITY_OPAQUE + bearer.add_filter(MANTIS_RIG_HIDE_FILTER, 1, color_matrix_filter(list(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0))) + +/// Shows the real bearer again. +/datum/mantis_rig/proc/reveal() + if(!hidden) + return + hidden = FALSE + if(QDELETED(bearer)) + return + bearer.mouse_opacity = old_mouse_opacity + bearer.remove_filter(MANTIS_RIG_HIDE_FILTER) + +#undef MANTIS_RIG_HIDE_FILTER +#undef MANTIS_RIG_LAYER_STEP diff --git a/voidcrew/modules/mantis_gore/mantis_scissor.dm b/voidcrew/modules/mantis_gore/mantis_scissor.dm new file mode 100644 index 00000000000..0972323df06 --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_scissor.dm @@ -0,0 +1,348 @@ +// The scissor: both blades out, head aimed, a swing at someone adjacent who is dying. The blades rise, +// catch the light, then come down and close on the neck, one blade behind it and one in front, and #509's +// decapitation takes the head. The bearer is drawn by the blade rig (mantis_rig.dm) from the raise to the +// recovery, so the far blade can pass under the neck while the bearer stands over the body. A #509 finisher +// (voidcrew/modules/hyperviolence/finishers/), drawn the way the bosses' are rather than as real blows, +// so the bearer stands rooted and exposed through the wind-up and a hit makes them reel. No mark over the +// victim (owner D34): the wind-up reads only from the bodies. An Atlas frame stops the cut. + +/// Starts the scissor on [target] if this swing is one. Returns TRUE if it started. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_try_scissor(mob/living/target, mob/living/user) + if(!(gore_moves & MANTIS_MOVE_SCISSOR) || !iscarbon(target) || target == user) + return FALSE + if(!user.combat_mode || user.zone_selected != BODY_ZONE_HEAD || HAS_TRAIT(user, TRAIT_PACIFISM)) + return FALSE + // The cheap checks first: most head swings are at someone on their feet. + if(!mantis_in_crit(target) || length(mantis_held_blades(user, MANTIS_MOVE_SCISSOR)) < 2) + return FALSE + var/datum/mantis_bearer/state = user.get_mantis_state() + if(world.time < state.next_scissor || state.scissor) + return FALSE + var/datum/hv_finisher/mantis_scissor/scissor = new(user, target, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_scissor_ended))) + scissor.model = base_icon_state + if(!scissor.start()) + scissor.on_end = null + qdel(scissor) + return FALSE + state.scissor = scissor + state.next_scissor = world.time + MANTIS_SCISSOR_COOLDOWN + // The swing never reaches the attack chain, so it counts at a trader outpost here, as the Gorilla finishers do. + gorilla_register_aggression(target, user) + return TRUE + +/// The scissor ended, however it ended: the blades go back to the guard, and the rig fades into the real bearer. +/proc/mantis_scissor_ended(datum/hv_finisher/mantis_scissor/scissor, result) + var/mob/living/bearer = scissor.user + var/datum/mantis_rig/rig = scissor.rig + scissor.rig = null + if(!QDELETED(bearer)) + if(bearer.mantis_state?.scissor == scissor) + bearer.mantis_state.scissor = null + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + blade.set_mantis_pose(MANTIS_POSE_GUARD) + rig?.hand_back() + qdel(scissor) + +/datum/hv_finisher/mantis_scissor + name = "mantis scissor" + interrupt_damage = 15 + vulnerability = 1.25 + stagger_time = 1 SECONDS + zone_preference = list(BODY_ZONE_HEAD) + stages = list( + /datum/hv_finisher_stage/windup/mantis, + /datum/hv_finisher_stage/kill/decapitate/mantis, + /datum/hv_finisher_stage/recover/mantis, + ) + /// The model of the blades doing it, for the pictures. + var/model = "mantis" + /// The bearer drawn around the victim, while it runs. + var/datum/mantis_rig/rig + +/datum/hv_finisher/mantis_scissor/Destroy() + QDEL_NULL(rig) + return ..() + +/// Draws [beat] of the scissor, if the bearer is drawn by the rig, leaning into it over [time]. +/datum/hv_finisher/mantis_scissor/proc/show_beat(beat, time = 0.1 SECONDS) + rig?.show(beat, time = time) + +// Drawn, not real blows: a bearer with two blades fused to the arms makes no aggressive grab, and the +// head comes off by the finisher's own hand. That also roots them and makes them take more damage. +/datum/hv_finisher/mantis_scissor/New(mob/living/user, mob/living/carbon/victim, datum/callback/on_end) + . = ..() + real_hits = FALSE + +/** + * #509's check, made for people: it refuses anyone of the attacker's faction, and every player shares + * one. The scissor goes for anyone dying, as a gun execution does (owner D34). Dying means crit, not + * just lying down: a lunge knockdown alone is not enough. A human NPC only scissors at execution rank. + */ +/datum/hv_finisher/mantis_scissor/can_start() + if(QDELETED(user) || user.stat != CONSCIOUS || HAS_TRAIT(user, TRAIT_INCAPACITATED) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || HAS_TRAIT(user, TRAIT_PACIFISM)) + return FALSE + if(!iscarbon(victim) || QDELETED(victim) || victim == user || HAS_TRAIT(victim, TRAIT_GODMODE)) + return FALSE + if(!mantis_in_crit(victim)) + return FALSE + if(victim.has_status_effect(/datum/status_effect/hv_finisher_hold) || HAS_TRAIT_FROM(victim, TRAIT_IMMOBILIZED, MANTIS_IMPALE_TRAIT)) + return FALSE + if(victim.buckled || !isturf(victim.loc) || !isturf(user.loc) || victim.z != user.z) + return FALSE + if(isnull(victim.get_bodypart(BODY_ZONE_HEAD))) + return FALSE + if(!user.hv_can_execute()) + return FALSE + if(length(mantis_held_blades(user, MANTIS_MOVE_SCISSOR)) < 2) + return FALSE + // Square on only: from a corner the swing is just a swing + return get_dist(user, victim) <= 1 && user.Adjacent(victim) && finisher_square_on(user, victim) + +// A blade stowed (an EMP, a retract) or the hands bound: it can't close. +/datum/hv_finisher/mantis_scissor/safety_check() + . = ..() + if(. || completed) + return + if(length(mantis_held_blades(user, MANTIS_MOVE_SCISSOR)) < 2 || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED)) + return HV_FINISHER_ATTACKER_DOWN + if(finisher_on_corner(user, victim)) + return HV_FINISHER_LOST_GRIP + +// #509's wording, but the bearer reels back rather than letting go of a grip they never took. +/datum/hv_finisher/mantis_scissor/interrupt(reason) + if(!running || completed) + return + for(var/datum/hv_finisher_stage/stage as anything in stages) + if(stage.entered) + stage.on_interrupt() + if(reason == HV_FINISHER_DAMAGED) + user.visible_message(span_danger("[user] reels back from [victim]!")) + user.apply_status_effect(/datum/status_effect/hv_finisher_reeling, stagger_time) + stop(reason) + +/// Puts the bearer's blades in [pose]. +/datum/hv_finisher/mantis_scissor/proc/pose_blades(pose) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(user)) + blade.set_mantis_pose(pose) + +// ---- The wind-up ----------------------------------------------------------- + +/// Someone on the floor is turned so their head lies toward [bearer], the way tg turns someone dragged. +/// Straight above or below them, the head goes to the left, where the blades are drawn to close on it. +/proc/mantis_turn_head_toward(mob/living/victim, mob/living/bearer) + if(victim.body_position != LYING_DOWN || !victim.rotate_on_lying || !victim.lying_angle) + return + if(bearer.x == victim.x) + victim.set_lying_angle(LYING_ANGLE_WEST) + return + victim.set_lying_angle(bearer.x > victim.x ? LYING_ANGLE_EAST : LYING_ANGLE_WEST) + +/// Both blades rise. A glint runs along them, and the victim shudders. +/datum/hv_finisher_stage/windup/mantis + duration = MANTIS_SCISSOR_WINDUP + rise = 1 + enter_sound = 'sound/items/unsheath.ogg' + enter_volume = 50 + /// Timer of the glint halfway through. + var/glint_timer + +/datum/hv_finisher_stage/windup/mantis/enter() + . = ..() + var/datum/hv_finisher/mantis_scissor/scissor = host + scissor.pose_blades(MANTIS_POSE_RAISE) + mantis_turn_head_toward(host.victim, host.user) + QDEL_NULL(scissor.rig) + scissor.rig = new(host.user, host.victim, mantis_rig_facing(host.user, host.victim), scissor.model, "scissor") + if(!scissor.rig.start()) + QDEL_NULL(scissor.rig) + scissor.show_beat("raise") + glint_timer = addtimer(CALLBACK(src, PROC_REF(glint)), duration * 0.5, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/// Halfway through the wind-up the light runs along the near blade (the rig draws it) and the victim shudders. +/datum/hv_finisher_stage/windup/mantis/proc/glint() + glint_timer = null + if(!host?.running) + return + var/datum/hv_finisher/mantis_scissor/scissor = host + scissor.show_beat("glint") + mantis_struggle_fx(host.victim, duration * 0.5) + // Not drawn by the rig: the light runs along one held blade instead. + if(!scissor.rig) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = locate() in host.user.held_items + blade?.play_glint(MANTIS_POSE_RAISE) + +/datum/hv_finisher_stage/windup/mantis/on_stop() + if(glint_timer) + deltimer(glint_timer) + glint_timer = null + +/datum/hv_finisher_stage/windup/mantis/Destroy() + if(glint_timer) + deltimer(glint_timer) + glint_timer = null + return ..() + +/datum/hv_finisher_stage/windup/mantis/enter_message() + return "[host.user] raises both blades over [host.victim]!" + +// ---- The cut --------------------------------------------------------------- + +/datum/hv_finisher_stage/kill/decapitate/mantis + duration = 0.6 SECONDS + // The swing shuts the blades itself, on its own clock (strike()); this only catches a swing that never got there. + effect_delay = 0.4 SECONDS + // The blade rig draws the bearer's lean; without it, enter() leans the real bearer. + lunge = 0 + effect_sound = 'sound/items/weapons/bladeslice.ogg' + spray_strength = 4 + /// The swing's next frame and the blades shutting, to come. + var/close_timer + var/strike_timer + /// The bearer straightening up out of the cut, to come. + var/recover_timer + +/datum/hv_finisher_stage/kill/decapitate/mantis/Destroy() + stop_timers() + return ..() + +/datum/hv_finisher_stage/kill/decapitate/mantis/proc/stop_timers() + for(var/timer in list(close_timer, strike_timer, recover_timer)) + if(timer) + deltimer(timer) + close_timer = null + strike_timer = null + recover_timer = null + +/** + * The swing: the blades come down out of the raise, close on the neck (the far one passes under it, the near + * one over it; the blade rig draws both) and shut through it, a frame apart, and the head comes off as they + * shut. The bearer leans in as they come down. + */ +/datum/hv_finisher_stage/kill/decapitate/mantis/enter() + . = ..() + var/datum/hv_finisher/mantis_scissor/scissor = host + scissor.pose_blades(MANTIS_POSE_GUARD) + if(!scissor.rig) + // Drawn as the bearer: a lean, further if the head lies on the far side of the body. + var/posture = mantis_scissor_posture(host.victim) + var/toward = get_dir(host.user, host.victim) + var/far = (posture == "lie90" && (toward & EAST)) || (posture == "lie270" && (toward & WEST)) + host.pose_user(far ? MANTIS_SCISSOR_FAR_LEAN : MANTIS_SCISSOR_LEAN, rise) + scissor.show_beat("swing", MANTIS_SCISSOR_SWING_STEP) + close_timer = addtimer(CALLBACK(src, PROC_REF(close)), MANTIS_SCISSOR_SWING_STEP, TIMER_STOPPABLE|TIMER_DELETE_ME) + strike_timer = addtimer(CALLBACK(src, PROC_REF(strike)), 1.5 * MANTIS_SCISSOR_SWING_STEP, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/// The blades meet at the neck. +/datum/hv_finisher_stage/kill/decapitate/mantis/proc/close() + close_timer = null + if(!host?.running) + return + var/datum/hv_finisher/mantis_scissor/scissor = host + scissor.show_beat("close", MANTIS_SCISSOR_SWING_STEP) + +/// The blades shut through the neck: the stage's beat (effect()), checked the way #509's tick checks it. +/datum/hv_finisher_stage/kill/decapitate/mantis/proc/strike() + strike_timer = null + if(!host?.running || host.current_stage != src || effect_done) + return + var/reason = host.safety_check() + if(reason) + host.end_early(reason) + return + host.fire_effect() + +/// The blades are through: the bearer straightens back to the guard. +/datum/hv_finisher_stage/kill/decapitate/mantis/proc/recover() + recover_timer = null + if(!host?.running) + return + var/datum/hv_finisher/mantis_scissor/scissor = host + scissor.show_beat("recover", MANTIS_SCISSOR_STRAIGHTEN) + +/datum/hv_finisher_stage/kill/decapitate/mantis/on_stop() + . = ..() + stop_timers() + +/** + * The blades come together at the neck: one line for the cut, a huge one if the head comes off. An + * Atlas frame (or anything else that won't let the head go) takes a deep cut instead. + */ +/datum/hv_finisher_stage/kill/decapitate/mantis/effect() + var/mob/living/carbon/victim = host.victim + var/mob/living/bearer = host.user + var/datum/hv_finisher/mantis_scissor/scissor = host + scissor.show_beat("cut", MANTIS_SCISSOR_SWING_STEP) + // The cut holds, then the bearer straightens. + if(!recover_timer) + recover_timer = addtimer(CALLBACK(src, PROC_REF(recover)), MANTIS_SCISSOR_RECOVER_BEAT, TIMER_STOPPABLE|TIMER_DELETE_ME) + if(effect_sound) + playsound(victim, effect_sound, effect_volume, TRUE) + var/spray_dir = away_dir() + mantis_note_hit(victim, bearer) + victim.hv_hold_attack_message( + "[bearer] brings both blades together at [victim]'s neck!", + "[bearer] brings both blades together at your neck!", + null, + null, + null, + DEFAULT_MESSAGE_RANGE, + ) + var/beheads = can_gore() + if(beheads) + victim.hv_add_hit_line("[victim]'s head comes off!", HV_LINE_HUGE, "Your head comes off!", DEFAULT_MESSAGE_RANGE) + gore(spray_dir) + else + fallback(spray_dir) + if(!QDELETED(victim)) + victim.hv_flush_hit() + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade as anything in mantis_held_blades(bearer)) + blade.drench(victim, light = TRUE) + // The blades come out of the neck red, and it sprays. + if(scissor.rig) + scissor.rig.dress() + switch(scissor.rig.facing) + if(NORTH) + scissor.rig.burst("cut_spray", 0.4 SECONDS, "T") + if(SOUTH) + scissor.rig.burst("cut_spray", 0.4 SECONDS, "arms") + else + scissor.rig.burst("cut_spray", 0.4 SECONDS, "near", under = TRUE) + log_combat(bearer, victim, "scissored", addition = "([beheads ? "beheaded" : "cut"])") + +// The head stays on: a deep cut across the neck. Atlas plating stops the blades on metal. +/datum/hv_finisher_stage/kill/decapitate/mantis/fallback(spray_dir) + var/mob/living/carbon/victim = host.victim + var/mob/living/bearer = host.user + if(HAS_TRAIT(victim, TRAIT_NODISMEMBER)) + victim.hv_add_hit_line("The blades grind to a stop on metal!", HV_LINE_BOLD, null, DEFAULT_MESSAGE_RANGE) + playsound(victim, 'sound/items/weapons/block_blade.ogg', 70, TRUE) + else + victim.hv_add_hit_line("[bearer]'s blades bite deep into [victim]'s neck!", HV_LINE_BOLD, "[bearer]'s blades bite deep into your neck!", DEFAULT_MESSAGE_RANGE) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = locate() in bearer.held_items + victim.apply_damage(MANTIS_SCISSOR_FALLBACK_DAMAGE, BRUTE, BODY_ZONE_HEAD, wound_bonus = 20, sharpness = SHARP_EDGED, attack_direction = spray_dir, attacking_item = blade) + if(!QDELETED(victim)) + victim.hv_blood_spray(spray_dir, 2) + +// #509's: the spray, and the head comes off. Then it comes away from the neck on the floor. +/datum/hv_finisher_stage/kill/decapitate/mantis/gore(spray_dir) + var/mob/living/carbon/victim = host.victim + var/angle = victim.lying_angle + victim.hv_blood_spray(spray_dir, spray_strength) + var/obj/item/bodypart/head/head = hv_finisher_take_head(victim, WOUND_SLASH) + mantis_roll_head(head, angle) + +/// [head], just cut off a body lying at [angle], comes away from the neck on the floor: from where the neck +/// was to a hand's width off it. Only where it is drawn on its tile. +/proc/mantis_roll_head(obj/item/bodypart/head/head, angle) + if(QDELETED(head) || !isturf(head.loc) || !angle) + return + var/side = angle == LYING_ANGLE_EAST ? 1 : -1 + head.pixel_w = side * MANTIS_HEAD_ROLL_FROM + head.pixel_z = -MANTIS_HEAD_ROLL_DROP + animate(head, pixel_w = side * MANTIS_HEAD_ROLL_TO, pixel_z = -MANTIS_HEAD_ROLL_DROP - 2, time = 0.3 SECONDS, easing = SINE_EASING|EASE_OUT) + +// ---- After ------------------------------------------------------------------- + +/// The bearer straightens up out of the cut. +/datum/hv_finisher_stage/recover/mantis + duration = 0.5 SECONDS diff --git a/voidcrew/modules/mantis_gore/mantis_swing.dm b/voidcrew/modules/mantis_gore/mantis_swing.dm new file mode 100644 index 00000000000..86f02e9f38b --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_swing.dm @@ -0,0 +1,304 @@ +// The ordinary hit with a Mantis blade: the hand that hit swings its blade. The held blade cocks back, cuts +// through and follows down, then is back in the guard. Only the picture: the damage and tg's attack step land +// at the click as before. See mantis_core.dm for the overview. +// +// The swing is a fresh picture on the bearer (a fresh object always plays its frames from the first, an +// overlay does not), the held blade hidden under it while it plays. Its last frame is the guard itself, so the +// held blade comes back under an exact copy of itself whichever reaches the client first. +// +// Side on, the arm on the far side of the body swings under the near arm's swing, and whatever the near hand +// holds is cut out of it (sort_as_arm(), voidcrew/modules/cyberware/cyberware_anim.dm). The blood coat goes on +// after its swing, so it draws over it. + +/// 64x64 frames on the bearer's tile: "[model]_swing_[side]" and its "_blood" and "_soak" coats. And the slash +/// over the target, by the blade's impact_state: the impact art after half a beat of nothing, the swing's cock. +/// And one stroke of the X-slash, "xslash_[model]": a straight cut from the upper left to the lower right after +/// the same half beat, drawn so that it and its mirror image cross in the exact middle of the picture. +#define MANTIS_SWING_ICON 'voidcrew/modules/mantis_gore/icons/mantis_swing.dmi' +/// How long the held blade is hidden: the cock, the strike and the follow-through. +#define MANTIS_SWING_TIME (2.5 DECISECONDS) +/// How long the swing picture stays: one beat of the guard frame past the hide. +#define MANTIS_SWING_LIFETIME (3 DECISECONDS) +/// The impact over the target waits for the strike frame. +#define MANTIS_SWING_IMPACT_DELAY (0.5 DECISECONDS) +/// How long the slash over the target stays: that half beat, then its four frames. +#define MANTIS_SWING_IMPACT_LIFETIME (4.5 DECISECONDS) +/// The X-slash's other blade swings one beat behind the first, so its stroke crosses one already through. +#define MANTIS_XSLASH_SWING_DELAY (1 DECISECONDS) +/// Where an X-slash on a leg is centred, in pixels up from the middle of the tile: half way down the leg, whichever +/// way the body faces (a human leg runs from 7.5 to 15.5 pixels below the middle, and the strokes cross half a pixel +/// above the middle of their art). +#define MANTIS_XSLASH_LEG_Y -12 + +/obj/item/melee/energy/blade/hardlight/cyberware_mantis + /// The swing playing for this blade right now, if any. Weak: it deletes itself. + var/datum/weakref/swing_ref + /// The slash over the target of that swing, if any. Weak: it deletes itself. + var/datum/weakref/swing_impact_ref + +/// The swing playing for this blade right now, if any. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_swing() + return swing_ref?.resolve() + +/** + * The hand holding this blade swings it at [attacked_atom]. Called with tg's attack step, so it plays for + * every swing that steps, landed or blocked. Only from the guard, and never over a blade already drawn + * elsewhere (the unfold, the impale, the scissor). Returns the swing, or null if none plays. + */ +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_play_swing(mob/living/attacker, atom/attacked_atom) + if(!isliving(attacker) || QDELETED(attacker) || attacked_atom == attacker) + return null + var/held_index = attacker.get_held_index_of_item(src) + if(!held_index || mantis_pose != MANTIS_POSE_GUARD || world.time < inhand_hidden_until) + return null + var/side = IS_LEFT_INDEX(held_index) ? "left" : "right" + var/state = "[base_icon_state]_swing_[side]" + if(!icon_exists(MANTIS_SWING_ICON, state)) + return null + qdel(mantis_swing()) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = housing_ref?.resolve() + housing?.unfold_overtaken(src) + var/obj/effect/abstract/cyberware_anim/mantis_swing/swing = new(null) + swing.start(attacker, src, state, side) + if(is_bloody()) + var/coat_state = "[state]_[world.time < soaked_until ? "soak" : "blood"]" + if(icon_exists(MANTIS_SWING_ICON, coat_state)) + swing.add_coat(coat_state, get_blood_dna_color()) + swing_ref = WEAKREF(swing) + // This blade leaves its guard, so a far swing behind it is no longer cut around it: its own swing is in + // front now. The hands redraw, and every arm's picture on the bearer sorts itself again. + hide_inhand_for(MANTIS_SWING_TIME) + return swing + +/** + * The slash over [attacked_atom] for this blade's swing, cut the way the blade crosses the target in the strike + * frame for the way [attacker] faces now, or [mirrored] if given. It goes up with the swing and shows nothing + * for the half beat the blade cocks back: the client plays both pictures from the same moment, so the slash + * comes up with the strike frame and never ahead of it (a timer on the server could). Returns it, or null. + */ +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_swing_impact(atom/movable/attacker, atom/attacked_atom, mirrored = null) + if(!impact_state || !ismovable(attacked_atom)) + return null + if(!icon_exists(MANTIS_SWING_ICON, impact_state)) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cyberware_play_impact), attacker, attacked_atom, impact_state, mirrored), MANTIS_SWING_IMPACT_DELAY) + return null + if(isnull(mirrored)) + var/obj/effect/abstract/cyberware_anim/mantis_swing/swing = mantis_swing() + if(swing && !QDELETED(attacker)) + mirrored = mantis_swing_impact_mirrored(attacker.dir, swing.side) + else + // Turned as any chrome hit's is (cyberware_play_impact()). + var/direction = get_dir(attacker, attacked_atom) + mirrored = (direction & WEST) || (!(direction & EAST) && prob(50)) + var/obj/effect/abstract/cyberware_anim/impact = cyberware_anim_play(attacked_atom, MANTIS_SWING_ICON, impact_state, MANTIS_ANIM_TOP_LAYER, MANTIS_SWING_IMPACT_LIFETIME, glow = impact_state != "impact_shiv") + if(isnull(impact)) + return null + // 64x64 around the target's tile, upright even on someone lying down. + impact.pixel_w = -16 + impact.pixel_z = -16 + impact.appearance_flags |= RESET_TRANSFORM + if(mirrored) + impact.transform = matrix(-1, 0, 0, 0, 1, 0) + swing_impact_ref = WEAKREF(impact) + return impact + +/** + * How far the [zone] part of [body] is drawn from the middle of its chest, as it stands, faces and lies now + * (wire_part_offset(), hyperviolence/wire/wire_held.dm): list(x, y) in pixels. The body's left and right swap + * on screen as it turns. + */ +/proc/mantis_part_shift(mob/living/body, zone) + var/list/part = wire_part_offset(zone, body.dir) + var/list/chest = wire_part_offset(BODY_ZONE_CHEST, body.dir) + var/across = part[1] - chest[1] + var/up = part[2] - chest[2] + var/matrix/shape = body.transform + return list(round(shape.a * across + shape.b * up), round(shape.d * across + shape.e * up)) + +/** + * Where the [zone] part of [body] is drawn, as it stands, faces and lies now, from the middle of its tile + * (wire_part_offset()): list(x, y) in pixels. Facing west it is the mirror of facing east. + */ +/proc/mantis_part_point(mob/living/body, zone) + var/list/part = wire_part_offset(zone, body.dir) + var/matrix/shape = body.transform + return list(round(shape.a * part[1] + shape.b * part[2] + shape.c), round(shape.d * part[1] + shape.e * part[2] + shape.f)) + +/// The slash of the swing playing now is set on the part of [victim] it cut ([zone]). +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_swing_impact_onto(mob/living/victim, zone) + var/obj/effect/abstract/cyberware_anim/impact = swing_impact_ref?.resolve() + if(isnull(impact) || impact.bearer != victim || !zone) + return + var/list/shift = mantis_part_shift(victim, zone) + impact.pixel_w = -16 + shift[1] + impact.pixel_z = -16 + shift[2] + +/** + * Whether the [side] hand's swing, its bearer facing [facing], shows the impact art mirrored. The art cuts + * clockwise: in along the top from the left, then down on the right. In mantis_swing.dmi, from the cock frame + * to the strike frame, facing south or north each hand cuts across the body toward the other: facing south the + * right hand cuts clockwise and the left anticlockwise, facing north the other way round. Side on both hands + * chop down in front, clockwise facing east and anticlockwise facing west. + */ +/proc/mantis_swing_impact_mirrored(facing, side) + if(facing & WEST) + return TRUE + if(facing & EAST) + return FALSE + return (facing == NORTH) == (side == "right") + +/** + * The X-slash as it looks: two straight strokes that cross on the part cut ([zone]). This blade's stroke comes + * up with its strike in place of its ordinary slash; the other blade swings a beat behind and its stroke, turned + * the other way, comes up with its own strike and crosses the first; the flash lands then. Without a swing + * playing (a blade out of its guard) the whole cross lands at once. + */ +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_xslash_cross(mob/living/user, mob/living/victim, obj/item/melee/energy/blade/hardlight/cyberware_mantis/off_blade, zone) + var/obj/effect/abstract/cyberware_anim/first = swing_impact_ref?.resolve() + if(first?.bearer != victim) + first = null + // This blade's stroke runs the way its own slash does. + var/flipped + if(first) + var/matrix/turned = first.transform + flipped = turned.a < 0 + else + flipped = mantis_swing_impact_mirrored(user.dir, hand_side()) + if(!mantis_swing() || isnull(first)) + mantis_xslash_stroke_fx(victim, impact_state, zone, flipped) + mantis_xslash_stroke_fx(victim, impact_state, zone, !flipped) + mantis_xslash_land(user, victim, off_blade) + return + // Made in the same instant as the slash it replaces, so only the stroke is ever seen. + var/obj/effect/abstract/cyberware_anim/stroke = mantis_xslash_stroke_fx(victim, impact_state, zone, flipped) + if(stroke) + qdel(first) + swing_impact_ref = WEAKREF(stroke) + addtimer(CALLBACK(src, PROC_REF(mantis_xslash_second), user, victim, off_blade, zone, !flipped), MANTIS_XSLASH_SWING_DELAY) + addtimer(CALLBACK(src, PROC_REF(mantis_xslash_land), user, victim, off_blade), MANTIS_XSLASH_SWING_DELAY + MANTIS_SWING_IMPACT_DELAY) + +/** + * One stroke of the X-slash over [victim], by [impact_state]'s model: a straight cut through the [zone] part from + * the upper left to the lower right, or the other way if [flipped]. A stroke and its mirror image cross in the + * middle of the art, and the art is centred on the part as it is drawn now, so the cross sits at the same place + * on the part whichever way the target faces. Returns the picture, or null if that model has no stroke art. + */ +/proc/mantis_xslash_stroke_fx(mob/living/victim, impact_state, zone, flipped) + if(QDELETED(victim) || !impact_state) + return null + var/state = replacetext(impact_state, "impact_", "xslash_") + if(!icon_exists(MANTIS_SWING_ICON, state)) + return null + var/obj/effect/abstract/cyberware_anim/stroke = cyberware_anim_play(victim, MANTIS_SWING_ICON, state, MANTIS_ANIM_TOP_LAYER, MANTIS_SWING_IMPACT_LIFETIME, glow = TRUE) + if(isnull(stroke)) + return null + // A body on fire draws its flames apart from the rest of it and over all of its own pictures, and tg throws + // its embers over those (a particle holder at ABOVE_ALL_MOB_LAYER): a cross on it lost its middle to them. + // There the stroke is drawn apart as well, just over the embers. It stays on the body's own row, so whoever + // stands in front of the body still covers it. + if(victim.on_fire) + stroke.appearance_flags |= KEEP_APART + stroke.layer = ABOVE_ALL_MOB_LAYER + 0.01 + var/list/point = mantis_xslash_point(victim, zone || BODY_ZONE_CHEST) + // 64x64 around the part, upright even on someone lying down. + stroke.pixel_w = -16 + point[1] + stroke.pixel_z = -16 + point[2] + stroke.appearance_flags |= RESET_TRANSFORM + if(flipped) + stroke.transform = matrix(-1, 0, 0, 0, 1, 0) + return stroke + +/** + * Where the X-slash's strokes cross on the [zone] part of [body], as mantis_part_point() gives it, but on a leg half + * way down it rather than at the hip a wire's lash ends on. + */ +/proc/mantis_xslash_point(mob/living/body, zone) + if(zone != BODY_ZONE_L_LEG && zone != BODY_ZONE_R_LEG) + return mantis_part_point(body, zone) + var/list/part = wire_part_offset(zone, body.dir) + var/matrix/shape = body.transform + return list(round(shape.a * part[1] + shape.b * MANTIS_XSLASH_LEG_Y + shape.c), round(shape.d * part[1] + shape.e * MANTIS_XSLASH_LEG_Y + shape.f)) + +/// The second stroke of the X-slash: [off_blade] swings, and its stroke goes up [flipped] to cross the first. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_xslash_second(mob/living/user, mob/living/victim, obj/item/melee/energy/blade/hardlight/cyberware_mantis/off_blade, zone, flipped) + if(QDELETED(victim) || QDELETED(user) || QDELETED(off_blade) || !user.is_holding(off_blade)) + return + off_blade.mantis_play_swing(user, victim) + // A model with no stroke art crosses with its ordinary slash. + if(!mantis_xslash_stroke_fx(victim, impact_state, zone, flipped)) + off_blade.mantis_swing_impact(user, victim, flipped) + +/// The crossed slash lands on [victim]: the flash, and both blades cut, so both run red. +/obj/item/melee/energy/blade/hardlight/cyberware_mantis/proc/mantis_xslash_land(mob/living/user, mob/living/victim, obj/item/melee/energy/blade/hardlight/cyberware_mantis/off_blade) + if(QDELETED(victim)) + return + mantis_xslash_fx(user, victim, impact_state) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/crossed as anything in list(src, off_blade)) + if(!QDELETED(crossed) && user?.is_holding(crossed)) + crossed.drench(victim) + +// ========================================================================= +// THE PICTURE +// ========================================================================= + +/// One swing of one blade on its bearer, and the blood on it. Ends early if the blade leaves the hand. +/obj/effect/abstract/cyberware_anim/mantis_swing + icon = MANTIS_SWING_ICON + // The frames are 64x64 around the bearer's tile. Centred with pixel_w/pixel_z, which only draw elsewhere: + // the picture stays on the bearer's row, so it sorts against other mobs as the bearer does. + pixel_w = -16 + pixel_z = -16 + layer = MANTIS_ANIM_BLADE_LAYER + /// The blade swinging. + var/obj/item/blade + /// The hand it swings in: "left" or "right". + var/side + /// The blood on it, a picture of its own so its frames start with the swing's. + var/obj/effect/abstract/cyberware_anim/mantis_swing/coat + +/obj/effect/abstract/cyberware_anim/mantis_swing/Destroy() + if(blade) + UnregisterSignal(blade, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING)) + blade = null + QDEL_NULL(coat) + return ..() + +/// Starts playing [state] for [swung], held in [bearer]'s [hand_side] hand. +/obj/effect/abstract/cyberware_anim/mantis_swing/proc/start(mob/living/bearer, obj/item/swung, state, hand_side) + icon_state = state + side = hand_side + blade = swung + RegisterSignals(blade, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING), PROC_REF(on_blade_gone)) + attach(bearer) + sort_as_arm(side) + +/// Lays the blood coat [coat_state] in [blood_color] over the swing. +/obj/effect/abstract/cyberware_anim/mantis_swing/proc/add_coat(coat_state, blood_color) + coat = new(null) + coat.icon = MANTIS_SWING_ICON + coat.icon_state = coat_state + coat.pixel_w = pixel_w + coat.pixel_z = pixel_z + coat.color = blood_color + coat.appearance_flags |= RESET_COLOR + coat.attach(bearer) + coat.sort_as_arm(side) + +/obj/effect/abstract/cyberware_anim/mantis_swing/proc/on_blade_gone(datum/source) + SIGNAL_HANDLER + qdel(src) + +/// Puts this picture on [target] for the swing's lifetime. +/obj/effect/abstract/cyberware_anim/mantis_swing/proc/attach(atom/movable/target) + bearer = target + RegisterSignal(bearer, COMSIG_QDELETING, PROC_REF(on_bearer_deleted)) + bearer.vis_contents += src + QDEL_IN(src, MANTIS_SWING_LIFETIME) + +#undef MANTIS_SWING_ICON +#undef MANTIS_SWING_TIME +#undef MANTIS_SWING_LIFETIME +#undef MANTIS_SWING_IMPACT_DELAY +#undef MANTIS_SWING_IMPACT_LIFETIME +#undef MANTIS_XSLASH_SWING_DELAY +#undef MANTIS_XSLASH_LEG_Y diff --git a/voidcrew/modules/mantis_gore/mantis_wounds.dm b/voidcrew/modules/mantis_gore/mantis_wounds.dm new file mode 100644 index 00000000000..f93d959178e --- /dev/null +++ b/voidcrew/modules/mantis_gore/mantis_wounds.dm @@ -0,0 +1,90 @@ +// The torn limb artery the Mantis line leaves. A sibling of #509's slit throat +// (voidcrew/modules/hyperviolence/crits/crit_wounds.dm): the same clamp, then sutures or cautery, the same +// heavy bleed that never clots, but on an arm or a leg, with no gargle, and it pumps the way the cut went. +// Like the crit wounds, nothing in tg's random wound roll makes it; only the Mantis cut count does. + +/datum/wound/slash/flesh/critical/hv_carotid/limb + name = "Torn Artery" + undiagnosed_name = "Torn Artery" + desc = "Patient's limb is cut open through a major artery. Blood loss will kill within minutes." + treat_text = "Clamp the artery with a hemostat, then suture or cauterize the wound. Transfuse blood." + treat_text_short = "Clamp with a hemostat, then suture or cauterize." + simple_desc = "Patient's limb is cut open and pumping blood." + simple_treat_text = "Clamp the artery with a hemostat, then suture or cauterize it." + homemade_treat_text = "Tie it off tight above the cut and keep them still." + examine_desc = "is cut open to the artery, pumping out blood" + occur_text = "is cut open to the artery" + initial_flow = 3.5 + /// The way the cut travelled. The artery pumps along it. + var/spurt_dir + /// How far each pulse throws blood, in tiles. + var/spurt_strength = 2 + /// world.time of the next pulse. + var/next_pulse = 0 + +/datum/wound/slash/flesh/critical/hv_carotid/limb/wound_injury(datum/wound/old_wound = null, attack_direction = null) + // tg's own wound is told no direction. With one it throws its spray along it, a line of blood three tiles + // long, and this artery throws its own drops instead (mantis_spurt_fx()). + . = ..(old_wound, null) + spurt_dir = attack_direction || pick(GLOB.alldirs) + next_pulse = world.time + rand(2 SECONDS, 3 SECONDS) + // The throat's own pulse throws blood every which way. This one has its own, along the cut. + next_spurt = INFINITY + +// An arm or a leg doesn't drown the voice. +/datum/wound/slash/flesh/critical/hv_carotid/limb/gargle_speech(datum/source, list/message_args) + return + +/datum/wound/slash/flesh/critical/hv_carotid/limb/handle_process(seconds_per_tick, times_fired) + . = ..() + if(QDELETED(src) || !victim || !limb || victim.stat == DEAD || HAS_TRAIT(victim, TRAIT_STASIS)) + return + if(clamped || blood_flow < MANTIS_ARTERY_OPEN_FLOW || world.time < next_pulse || !limb.can_bleed()) + return + next_pulse = world.time + rand(2 SECONDS, 3 SECONDS) + pulse() + +/// One heartbeat out of the open artery. +/datum/wound/slash/flesh/critical/hv_carotid/limb/proc/pulse() + mantis_spurt_fx(victim, limb.body_zone, spurt_dir, spurt_strength < 2) + +/datum/wound/slash/flesh/critical/hv_carotid/limb/clamp_artery(obj/item/tool, mob/user) + if(clamped) + to_chat(user, span_warning("The artery is already clamped.")) + return TRUE + var/whose = (user == victim) ? "your" : "[victim]'s" + user.visible_message(span_danger("[user] reaches into the cut on [victim]'s [limb.plaintext_zone] with [tool]..."), span_warning("You reach into the cut on [whose] [limb.plaintext_zone] with [tool]...")) + if(!do_after(user, base_treat_time * (user == victim ? 2 : 1.5), target = victim, extra_checks = CALLBACK(src, PROC_REF(still_exists)))) + return TRUE + clamped = TRUE + user.visible_message(span_green("[user] clamps the artery in [victim]'s [limb.plaintext_zone]."), span_green("You clamp the artery in [whose] [limb.plaintext_zone].")) + adjust_blood_flow(-2.5) + return TRUE + +/datum/wound_pregen_data/flesh_slash/hv_limb_artery + abstract = FALSE + wound_path_to_generate = /datum/wound/slash/flesh/critical/hv_carotid/limb + wound_series = WOUND_SERIES_HV_LIMB_ARTERY + required_limb_biostate = (BIO_FLESH|BIO_BLOODED) + ignore_cannot_bleed = FALSE + viable_zones = list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) + can_be_randomly_generated = FALSE + threshold_minimum = 80 + +/** + * The Scorch's tear: the heat closes part of it as it cuts. It bleeds less, pumps weaker, and clots + * shut on its own in under a minute instead of killing. + */ +/datum/wound/slash/flesh/critical/hv_carotid/limb/seared + name = "Seared Artery" + undiagnosed_name = "Seared Artery" + desc = "Patient's limb is burned open to a major artery. The heat has partly closed it." + simple_desc = "Patient's limb is burned open and bleeding." + examine_desc = "is burned open to the artery, oozing blood" + occur_text = "is seared open to the artery" + initial_flow = 2 + clot_rate = 0.04 + spurt_strength = 1 + +/datum/wound_pregen_data/flesh_slash/hv_limb_artery/seared + wound_path_to_generate = /datum/wound/slash/flesh/critical/hv_carotid/limb/seared diff --git a/voidcrew/modules/missions/_missions.dm b/voidcrew/modules/missions/_missions.dm index 039a2e53bb8..3d8e8093258 100644 --- a/voidcrew/modules/missions/_missions.dm +++ b/voidcrew/modules/missions/_missions.dm @@ -952,6 +952,8 @@ GLOBAL_VAR_INIT(mission_work_serial, 0) var/result = objective.accept_item(turned_in_item, reward_anchor) if(result == MISSION_ITEM_REFUSED) return FALSE + // The pad took something: every hand-over gets the effect, counted ones included + flash_reward_anchor(reward_anchor) if(result == MISSION_ITEM_PROGRESS) return TRUE // partial hand-over; mission continues if(!all_objectives_satisfied()) @@ -1223,6 +1225,8 @@ GLOBAL_VAR_INIT(mission_work_serial, 0) if(completed && !failed && guarded_prize_family && !guarded_prize_rolled) guarded_prize_rolled = TRUE guarded_prize = servant.award_guarded_prize(guarded_prize_family, quote_zone, reward_anchor, type) + if(guarded_prize) + flash_reward_anchor(reward_anchor) /** * Turn-in visual: pads get their teleport effect, other anchors stay quiet diff --git a/voidcrew/modules/missions/mission_pad.dm b/voidcrew/modules/missions/mission_pad.dm index f52ef602e19..d2ef0583733 100644 --- a/voidcrew/modules/missions/mission_pad.dm +++ b/voidcrew/modules/missions/mission_pad.dm @@ -23,6 +23,8 @@ var/datum/pirate_negotiation/tribute_negotiation /// The ship this pad is installed on var/obj/structure/overmap/ship/linked_ship + /// world.time of the last teleport effect, so several things moving through in one tick make one flash + var/last_teleport_effect = -1 /obj/machinery/mission_pad/Initialize(mapload) . = ..() @@ -160,6 +162,11 @@ * Called when items are teleported in (rewards) or out (turn-ins). */ /obj/machinery/mission_pad/proc/do_teleport_effect() + // A turn-in and its payout land in the same tick: one flash, one sound + if(last_teleport_effect == world.time) + return + last_teleport_effect = world.time + // Visual effect flick("lpad-idle", src) @@ -171,6 +178,14 @@ // Sound effect playsound(src, 'sound/effects/magic/teleport_diss.ogg', 50, TRUE) +/** + * Plays the pad effect for something a mission has just put on a pad's tile + * (kits, chips, finished batches). Does nothing where no pad stands there. + */ +/proc/mission_pad_delivery_effect(turf/where) + var/obj/machinery/mission_pad/pad = locate() in where + pad?.do_teleport_effect() + /** * Handle items entering the pad's turf (via signal from connect_loc element). * If we're linked to a tribute negotiation, check if the item is valid tribute. diff --git a/voidcrew/modules/missions/mission_target.dm b/voidcrew/modules/missions/mission_target.dm index 00f7d84bc2c..7fb44cf6f05 100644 --- a/voidcrew/modules/missions/mission_target.dm +++ b/voidcrew/modules/missions/mission_target.dm @@ -62,7 +62,8 @@ /datum/mission_target/proc/notify_when_loaded() return -/// A random open turf inside the loaded interior for objective spawns +/// A random open turf inside the loaded interior for objective spawns, out of +/// every living player's sight when there is one (see spawn_cover.dm) /datum/mission_target/proc/get_spawn_turf() return null @@ -222,7 +223,7 @@ mission?.on_target_interior_loaded() /datum/mission_target/space_ruin/get_spawn_turf() - return ruin?.get_random_interior_turf() || ruin?.ruin_bottom_left + return ruin?.get_random_interior_turf(unwatched = TRUE) || ruin?.ruin_bottom_left /datum/mission_target/space_ruin/contains_turf(turf/T) if(!ruin || !T) @@ -405,16 +406,23 @@ min_y = max(min_y, above_docks) if(min_x > max_x || min_y > max_y) return null + // A crew already on the surface must not watch the objective appear. Every + // sample that passes is kept as a fallback, farthest from them wins. + var/datum/spawn_cover/cover = new(site_z) for(var/_ in 1 to 40) var/turf/candidate = locate(rand(min_x, max_x), rand(min_y, max_y), site_z) if(!candidate || !isopenturf(candidate) || isspaceturf(candidate)) continue + // Lava burns the objective and a chasm swallows it before anyone arrives + if(islava(candidate) || ischasm(candidate)) + continue if(istype(get_area(candidate), /area/shuttle)) continue if(candidate.is_blocked_turf(exclude_mobs = TRUE)) continue - return candidate - return null + if(cover.is_hidden(candidate)) + return candidate + return cover.fallback /** * "Is the player at the site" - the primitive the pylon scatter and the hunting diff --git a/voidcrew/modules/missions/missions/big_game_hunt.dm b/voidcrew/modules/missions/missions/big_game_hunt.dm index ce3d5d7a760..18892459239 100644 --- a/voidcrew/modules/missions/missions/big_game_hunt.dm +++ b/voidcrew/modules/missions/missions/big_game_hunt.dm @@ -16,10 +16,32 @@ * the trophy after that. Losing any of them voids the contract (FAIL policy, * with exactly one planet of each type per round, a filtered retarget has * nowhere to go, and set_lure's one kit can't re-arm a fresh site anyway). + * + * The staked lure stays behind as an anchored rig that thumps and stinks of + * chum. It is scenery, not a quest atom. The beast does not appear beside it: + * a roar rolls in from one side, then after a short wait the beast and its + * entourage come into being out of every player's sight, a good way off, and + * walk in on the stake (AI planning subtree at the bottom of this file). The + * rig is trampled when the beast reaches it, or goes quiet when it dies. */ /// How long staking the hunting lure takes #define LURE_STAKE_TIME (8 SECONDS) +/// Wait between the lure going in and its quarry setting out (the walk in comes on top) +#define LURE_ARRIVAL_MIN (9 SECONDS) +#define LURE_ARRIVAL_MAX (16 SECONDS) +/// How far from the stake the quarry starts out, in tiles. An AI drops a movement +/// goal more than 14 tiles away, so the far edge stays under that. +#define LURE_APPROACH_MIN 10 +#define LURE_APPROACH_MAX 13 +/// Nearest a player may stand to a starting tile. A screen reaches 7 tiles each way. +#define LURE_UNSEEN_RANGE 9 +/// How long an animal keeps heading for the lure before it goes back to its own business +#define LURE_CHARGE_TIME (45 SECONDS) +/// The rumble before a beast climbs out of the ground (matches zone_mobs_arrival.dm) +#define LURE_EMERGE_TIME (2.5 SECONDS) +/// Blackboard key: world.time after which a lured animal stops heading for the lure +#define BB_LURE_CHARGE_EXPIRES "BB_lure_charge_expires" /datum/mission/big_game_hunt name = "Big Game Hunt" @@ -208,8 +230,8 @@ * A lure kit is dispensed at the servant's mission pad on accept (the * prospect-stake kit pattern) and tracked as the quest atom, burn the lure, * void the hunt. Staking it in open ground on the target planet records the - * stake position for the kill step and completes; the beast's spawn devours - * the kit. Assumes the FAIL loss policy: the one kit can't re-arm after a + * stake position for the kill step, stands the rig on that spot and + * completes. Assumes the FAIL loss policy: the one kit can't re-arm after a * retarget reset. */ /datum/mission_objective/set_lure @@ -217,12 +239,21 @@ var/obj/item/hunting_lure/kit /// The kill step this lure feeds its stake position to var/datum/mission_objective/field/kill_named/big_game/hunt_objective + /// The kit went into the ground; a rewind (the site unloaded) needs a fresh one + var/kit_spent = FALSE /datum/mission_objective/set_lure/Destroy() kit = null // the item survives; it self-reports expiry on use hunt_objective = null return ..() +/// Back on this step after the site unloaded with the beast in it: send a new lure +/datum/mission_objective/set_lure/activate() + . = ..() + if(kit_spent && QDELETED(kit)) + kit_spent = FALSE + dispense_kit() + /// Called by the mission at start: hand the lure over at the ship's pad /datum/mission_objective/set_lure/proc/dispense_kit() var/obj/structure/overmap/ship/ship = get_servant() @@ -235,6 +266,7 @@ mission.fail("No mission pad to dispense the hunting lure to.") return FALSE kit = new(kit_turf) + mission_pad_delivery_effect(kit_turf) kit.objective_ref = WEAKREF(src) // Losing the lure voids the hunt (and points the GPS chain at it meanwhile) mission.register_quest_atom(kit) @@ -245,13 +277,14 @@ /datum/mission_objective/set_lure/proc/on_planted(mob/living/user, turf/where) if(completed || !active || !where || !mission || mission.failed || mission.completed) return - if(hunt_objective) - hunt_objective.lure_turf = where + // The rig goes into the ground here and the kill step takes it from there + hunt_objective?.plant_lure(where) // The staked lure stops being the tracked objective; the beast that - // answers takes over the slot as soon as complete() advances the chain + // answers takes over the slot once it has been called in mission.forget_quest_atom(kit) QDEL_NULL(kit) - notify_crew("Lure staked. Something big is moving toward it - stand ready.", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') + kit_spent = TRUE + notify_crew("Lure staked.", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') complete() /datum/mission_objective/set_lure/get_progress_string() @@ -266,36 +299,231 @@ /** * kill_named pointed at the lure instead of a random stretch of surface: the - * beast (a trophy-grade specimen of the planet's apex fauna) breaks cover - * next to the stake the moment the lure objective completes, with its - * entourage of lesser fauna. Death drops the mission-bound trophy. + * beast (a trophy-grade specimen of the planet's apex fauna) answers the + * stake with its entourage of lesser fauna. It is called in after a roar and a + * short wait, starts well out of sight and heads for the stake; a site too + * cramped to hide an approach gets the beast climbing out of the ground next + * to it instead. Death drops the mission-bound trophy. */ /datum/mission_objective/field/kill_named/big_game proof_type = /obj/item/mission_recovery/trophy - /// Where the lure was staked; the beast breaks cover next to it + /// Where the lure was staked; the beast comes for it var/turf/lure_turf + /// The rig standing on lure_turf (weak: it goes with the site) + var/datum/weakref/lure_stake_ref + /// Pending arrival timer: the wait before the quarry sets out, or the rumble before it digs out + var/arrival_timer + /// Whether the beast has been called but is not out yet + var/arrival_pending = FALSE + /// Where the first roar came from; the quarry comes in from the same side + var/turf/approach_hint /// The trophy the beast drops ("tendril-crowned skull"), set by the mission var/trophy_part = "trophy" /// Trophy-grade specimen: raise maxHealth/health to this on spawn (0 = leave alone). /// A plain var-level scale-up, no new buff system. var/health_override = 0 +/datum/mission_objective/field/kill_named/big_game/Destroy() + cancel_arrival() + // Never leave the rig behind for a contract that no longer exists + var/obj/structure/hunting_lure_stake/stake = lure_stake_ref?.resolve() + stake?.topple() + lure_stake_ref = null + approach_hint = null + lure_turf = null + return ..() + +/datum/mission_objective/field/kill_named/big_game/deactivate() + // Completed, failed or rewound: nothing is on its way and the rig goes quiet + cancel_arrival() + var/obj/structure/hunting_lure_stake/stake = lure_stake_ref?.resolve() + stake?.topple() + lure_stake_ref = null + return ..() + /datum/mission_objective/field/kill_named/big_game/reset() . = ..() lure_turf = null - -/// The beast answers the lure, not a random spawn point + approach_hint = null + +/// Stops a call that is still waiting to be answered +/datum/mission_objective/field/kill_named/big_game/proc/cancel_arrival() + if(arrival_timer) + deltimer(arrival_timer) + arrival_timer = null + arrival_pending = FALSE + +/// The kit went into the ground: remember the spot and stand the rig on it +/datum/mission_objective/field/kill_named/big_game/proc/plant_lure(turf/where) + lure_turf = where + var/obj/structure/hunting_lure_stake/stake = new(where) + lure_stake_ref = WEAKREF(stake) + +/// The beast answers the lure, not a random spawn point, and not at once /datum/mission_objective/field/kill_named/big_game/do_field_spawn() if(spawned) return if(!lure_turf) return ..() spawned = TRUE - spawn_field_objects(get_nearby_open_turf(lure_turf, 4)) + arrival_pending = TRUE + // First sign of it: a roar from the side it will come in on (or from the + // ground itself where there is no hiding place) + var/list/approaches = approach_turfs() + approach_hint = length(approaches) ? pick(approaches) : null + var/turf/roar_from = approach_hint || lure_turf + playsound(roar_from, 'sound/mobs/non-humanoids/space_dragon/space_dragon_roar.ogg', 40, TRUE, extrarange = 20) + for(var/mob/living/hearer in GLOB.player_list) + if(hearer.z == lure_turf.z && get_dist(hearer, lure_turf) <= 14 && hearer.can_hear()) + to_chat(hearer, span_boldwarning("Something huge bellows in the distance.")) + arrival_timer = addtimer(CALLBACK(src, PROC_REF(answer_lure)), rand(LURE_ARRIVAL_MIN, LURE_ARRIVAL_MAX), TIMER_STOPPABLE | TIMER_DELETE_ME) + +/// The wait is over: the beast and its entourage set out for the stake +/datum/mission_objective/field/kill_named/big_game/proc/answer_lure() + arrival_timer = null + if(!arrival_still_wanted()) + return + var/datum/mission_target/site = mission.target + if(!lure_turf || !site?.is_valid() || !site.is_interior_loaded() || !site.contains_turf(lure_turf)) + // The hunting ground went away during the wait; arm again the ordinary way + cancel_arrival() + spawned = FALSE + lure_turf = null + arm() + return + var/list/approaches = approach_turfs() + if(!length(approaches)) + dig_out() + return + arrival_pending = FALSE + // Start on the side the roar came from where there is room, and where a + // straight run at the stake looks open + var/list/same_side = list() + for(var/turf/candidate as anything in approaches) + if(approach_hint && get_dist(candidate, approach_hint) <= 6) + same_side += candidate + var/list/pool = length(same_side) ? same_side : approaches + var/turf/lead = pick(pool) + for(var/_ in 1 to 12) + var/turf/candidate = pick(pool) + if(approach_is_clear(candidate)) + lead = candidate + break + // The entourage trails in beside it, on tiles that are also out of sight + var/list/guard_spots = list() + for(var/_ in guard_types) + var/list/beside = list() + for(var/turf/candidate as anything in approaches) + if(get_dist(candidate, lead) <= 4) + beside += candidate + guard_spots += length(beside) ? pick(beside) : lead + spawn_field_objects(lead, guard_spots) + playsound(lead, 'sound/mobs/non-humanoids/space_dragon/space_dragon_roar.ogg', 50, TRUE, extrarange = 20) + +/// Whether a delayed arrival should still go ahead +/datum/mission_objective/field/kill_named/big_game/proc/arrival_still_wanted() + return active && !completed && mission && !mission.failed && !mission.completed && !mission.named_kill_completed && !target_mob -/datum/mission_objective/field/kill_named/big_game/spawn_field_objects(turf/spawn_turf) +/** + * Open ground a good way from the stake that nobody is close enough to see: + * the quarry's starting tiles. Empty where the site is too small, too crowded + * or too cluttered to hide an approach. + */ +/datum/mission_objective/field/kill_named/big_game/proc/approach_turfs() + . = list() + var/datum/mission_target/site = mission?.target + if(!lure_turf || !site) + return + var/list/watchers = list() + for(var/mob/living/player in GLOB.player_list) + var/turf/watcher_turf = get_turf(player) + if(watcher_turf?.z == lure_turf.z && player.stat != DEAD) + watchers += watcher_turf + for(var/turf/open/candidate in RANGE_TURFS(LURE_APPROACH_MAX, lure_turf)) + if(get_dist(candidate, lure_turf) < LURE_APPROACH_MIN) + continue + if(isspaceturf(candidate) || islava(candidate) || ischasm(candidate)) + continue + // Open planet ground only: no landed ship, no ruin, nothing past the site's edge + if(!istype(get_area(candidate), /area/overmap_encounter/planetoid) || !site.contains_turf(candidate)) + continue + // Not the docking strip: a ship coming in to land would crush whatever stands on it + if((candidate.turf_flags & NO_RUINS) || candidate.is_blocked_turf(exclude_mobs = TRUE)) + continue + var/seen = FALSE + for(var/turf/watcher_turf as anything in watchers) + if(get_dist(watcher_turf, candidate) < LURE_UNSEEN_RANGE) + seen = TRUE + break + if(!seen) + . += candidate + +/// Whether a straight run from the tile to the stake is open ground +/datum/mission_objective/field/kill_named/big_game/proc/approach_is_clear(turf/from) + for(var/turf/along as anything in get_line(from, lure_turf)) + if(!isopenturf(along) || islava(along) || ischasm(along) || along.is_blocked_turf(exclude_mobs = TRUE)) + return FALSE + return TRUE + +/** + * No hiding place for an approach: the ground shakes beside the lure and the + * pack climbs out of it, the same rumble the mission waves use. + */ +/datum/mission_objective/field/kill_named/big_game/proc/dig_out() + var/turf/lead = get_nearby_open_turf(lure_turf, 4) + var/list/guard_spots = list() + for(var/_ in guard_types) + guard_spots += get_nearby_open_turf(lure_turf, 4) + for(var/turf/spot as anything in list(lead) + guard_spots) + new /obj/effect/temp_visual/zone_mobs_emerge(spot) + playsound(lead, 'sound/effects/break_stone.ogg', 60, TRUE) + arrival_timer = addtimer(CALLBACK(src, PROC_REF(emerge_pack), lead, guard_spots), LURE_EMERGE_TIME, TIMER_STOPPABLE | TIMER_DELETE_ME) + +/datum/mission_objective/field/kill_named/big_game/proc/emerge_pack(turf/lead, list/guard_spots) + arrival_timer = null + arrival_pending = FALSE + if(!arrival_still_wanted()) + return + spawn_field_objects(lead, guard_spots, emerge = TRUE) + +/// The ground gives up a body: rubble underneath, then it rises out of the dirt +/datum/mission_objective/field/kill_named/big_game/proc/rise_from_ground(mob/living/body) + if(QDELETED(body)) + return + var/turf/where = get_turf(body) + if(where) + new /obj/effect/decal/cleanable/rubble(where) + playsound(where, 'sound/effects/shovel_dig.ogg', 60, TRUE) + // Parallel and relative so a mob's own idle animation (floating, bobbing) survives + var/final_alpha = body.alpha + body.alpha = 0 + body.pixel_z -= 16 + animate(body, pixel_z = 16, 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) + +/** + * Points a lured animal at the stake. It walks there whenever it has nothing + * of its own to hunt, so it goes for the first crew member it sees and + * otherwise comes straight in. + */ +/datum/mission_objective/field/kill_named/big_game/proc/send_to_lure(mob/living/body) + var/datum/ai_controller/brain = body?.ai_controller + if(QDELETED(body) || !istype(brain) || !lure_turf) + return + brain.set_blackboard_key(BB_TRAVEL_DESTINATION, lure_turf) + brain.set_blackboard_key(BB_LURE_CHARGE_EXPIRES, world.time + LURE_CHARGE_TIME) + var/list/subtrees = brain.planning_subtrees ? brain.planning_subtrees.Copy() : list() + subtrees += GLOB.ai_subtrees[/datum/ai_planning_subtree/travel_to_point/lure_charge] + brain.planning_subtrees = subtrees + // An animal this far from anyone would otherwise stand about until somebody wandered close + brain.can_idle = FALSE + brain.reset_ai_status() + +/datum/mission_objective/field/kill_named/big_game/spawn_field_objects(turf/spawn_turf, list/guard_spots, emerge = FALSE) if(mission.named_kill_completed) return ..() + // Anything that did not climb out of the ground has come a long way to get here + var/charging = !emerge && lure_turf var/mob/living/beast = spawn_field_npc(target_mob_type, spawn_turf, finalize = FALSE) beast.name = mission.objective_name beast.desc += " This one is old, scarred, and much too big. The guild wants it as a wall piece." @@ -307,11 +535,20 @@ // The entourage: lesser fauna drawn in by the blood on the wind. Killing // them pays nothing - the contract is the name on the trophy. for(var/guard_type in guard_types) - var/mob/living/guard = spawn_field_npc(guard_type, get_nearby_open_turf(spawn_turf), finalize = FALSE) + var/turf/guard_turf = length(guard_spots) ? pick_n_take(guard_spots) : get_nearby_open_turf(spawn_turf) + var/mob/living/guard = spawn_field_npc(guard_type, guard_turf, finalize = FALSE) guard.desc += " It followed something much bigger here." guard.npc_spawn_context.finalize() - beast.visible_message(span_boldwarning("[beast] comes crashing in and goes straight for the lure!")) - notify_crew("The lure's been taken. [mission.objective_name] is out in the open - good hunting.", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') + if(charging) + send_to_lure(guard) + if(emerge) + rise_from_ground(guard) + if(charging) + send_to_lure(beast) + if(emerge) + rise_from_ground(beast) + var/obj/structure/hunting_lure_stake/stake = lure_stake_ref?.resolve() + stake?.watch(beast) /datum/mission_objective/field/kill_named/big_game/get_proof_name() return "[mission.objective_name]'s [trophy_part]" @@ -319,6 +556,8 @@ /datum/mission_objective/field/kill_named/big_game/get_progress_string() if(!spawned) return "Draw [mission?.objective_name || "the beast"] out with the lure" + if(arrival_pending) + return "[mission?.objective_name || "The beast"] is coming for the lure" return "Bring down [mission?.objective_name || "the beast"]" // ========================================================================= @@ -335,8 +574,8 @@ * # Hunting Lure * * The kit handed over at accept. Stake it in hand, in open ground on the - * contracted planet's surface; the staking channel is not subtle, and the - * thing it calls arrives immediately. + * contracted planet's surface. The staking channel is not subtle; what it + * calls takes a little while to get there. */ /obj/item/hunting_lure name = "apex hunting lure" @@ -376,6 +615,87 @@ objective.on_planted(user, get_turf(user)) return TRUE +/** + * # Staked Hunting Lure + * + * What the kit turns into once it is in the ground: an anchored rig that + * thumps and stinks of chum until the beast it called tramples it or dies. + * Scenery only: not a quest atom, not an item, nothing to salvage, and the hunt + * carries on whatever happens to it. + */ +/obj/structure/hunting_lure_stake + name = "hunting lure" + desc = "A guild lure rig staked into the dirt. It stinks of chum and thumps like a heartbeat." + icon = 'voidcrew/modules/missions/icons/recovery.dmi' + icon_state = "recovery_anchored" + anchored = TRUE + density = FALSE + move_resist = INFINITY + resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF + /// Weakref to the beast that was called here + var/datum/weakref/watched_ref + /// Whether it is already coming down + var/toppled = FALSE + /// Process ticks since the last thump + var/thump_ticks = 0 + +/obj/structure/hunting_lure_stake/Initialize(mapload) + . = ..() + START_PROCESSING(SSobj, src) + +/obj/structure/hunting_lure_stake/Destroy() + STOP_PROCESSING(SSobj, src) + unwatch() + return ..() + +/obj/structure/hunting_lure_stake/process(seconds_per_tick) + thump_ticks++ + if(thump_ticks < 2) + return + thump_ticks = 0 + playsound(src, 'sound/effects/singlebeat.ogg', 40, TRUE, extrarange = 6) + animate(src, pixel_y = 2, time = 1) + animate(pixel_y = 0, time = 2) + +/// The beast it called is out: trample the rig when it gets here, drop it if the beast dies first +/obj/structure/hunting_lure_stake/proc/watch(mob/living/beast) + if(toppled || QDELETED(beast)) + return + unwatch() + watched_ref = WEAKREF(beast) + RegisterSignal(beast, COMSIG_MOVABLE_MOVED, PROC_REF(on_beast_moved)) + RegisterSignals(beast, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING), PROC_REF(on_beast_gone)) + +/obj/structure/hunting_lure_stake/proc/unwatch() + var/mob/living/beast = watched_ref?.resolve() + if(beast) + UnregisterSignal(beast, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_DEATH, COMSIG_QDELETING)) + watched_ref = null + +/obj/structure/hunting_lure_stake/proc/on_beast_moved(mob/living/source, atom/old_loc, movement_dir, forced, list/old_locs) + SIGNAL_HANDLER + if(get_dist(source, src) <= 1) + topple(source) + +/obj/structure/hunting_lure_stake/proc/on_beast_gone(datum/source) + SIGNAL_HANDLER + topple() + +/// The rig comes down and goes quiet, trampled by the beast if it got here +/obj/structure/hunting_lure_stake/proc/topple(mob/living/by) + if(toppled) + return + toppled = TRUE + STOP_PROCESSING(SSobj, src) + unwatch() + if(by) + visible_message(span_danger("[by] tramples [src].")) + else + visible_message(span_warning("[src] topples over and goes quiet.")) + playsound(src, 'sound/effects/clang.ogg', 50, TRUE) + animate(src, transform = turn(transform, 80), pixel_y = -4, alpha = 0, time = 1 SECONDS, easing = QUAD_EASING | EASE_IN) + QDEL_IN(src, 1 SECONDS) + /** * # Hunting Trophy * @@ -388,4 +708,39 @@ icon_state = "recovery" w_class = WEIGHT_CLASS_BULKY +// ========================================================================= +// THE CHARGE, lured animals walk in on the stake +// ========================================================================= + +/** + * The last thing a lured animal plans. Everything it can hunt on its own comes + * first, so it goes for the first crew member it sees and otherwise heads for + * the stake. Gives up after LURE_CHARGE_TIME and goes back to its own business. + */ +/datum/ai_planning_subtree/travel_to_point/lure_charge + travel_behaviour = /datum/ai_behavior/travel_towards/lure_charge + +/datum/ai_planning_subtree/travel_to_point/lure_charge/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + if(controller.blackboard[location_key] && world.time > controller.blackboard[BB_LURE_CHARGE_EXPIRES]) + controller.clear_blackboard_key(location_key) + return + return ..() + +/// Close enough to the stake counts as there; the goal is dropped once it is reached +/datum/ai_behavior/travel_towards/lure_charge + required_distance = 2 + +/datum/ai_behavior/travel_towards/lure_charge/finish_action(datum/ai_controller/controller, succeeded, target_key) + . = ..() + if(succeeded) + controller.clear_blackboard_key(target_key) + #undef LURE_STAKE_TIME +#undef LURE_ARRIVAL_MIN +#undef LURE_ARRIVAL_MAX +#undef LURE_APPROACH_MIN +#undef LURE_APPROACH_MAX +#undef LURE_UNSEEN_RANGE +#undef LURE_CHARGE_TIME +#undef LURE_EMERGE_TIME +#undef BB_LURE_CHARGE_EXPIRES diff --git a/voidcrew/modules/missions/missions/exploration.dm b/voidcrew/modules/missions/missions/exploration.dm index 9f94c4a82da..d719f8f0056 100644 --- a/voidcrew/modules/missions/missions/exploration.dm +++ b/voidcrew/modules/missions/missions/exploration.dm @@ -1,9 +1,15 @@ /** * # Exploration Mission * - * Fly the ship to marked coordinates, then come home for the pay. The - * coordinates come from the zone controller's own turf sets (no private ring - * math), and pay scales through the shared zone table. + * Fly the ship to marked coordinates, hold station there while the sensors sweep + * the sector, then come home for the pay. The coordinates come from the zone + * controller's own turf sets (no private ring math), and pay scales through the + * shared zone table. + * + * The sweep is the arrival beat: half a minute on station, a sonar ping, and + * sometimes a derelict signal nobody aboard had charted yet, pinned on the helm + * so the crew can decide whether to go and look. The signal is always one that + * is already out there; the sweep never makes anything. */ /datum/mission/exploration name = "Exploration Contract" @@ -12,6 +18,12 @@ // Green-band pay; apply_zone_scaling() raises it for deeper zones value_min = 150 value_max = 250 + /// The sweep step, for the waypoint label + var/datum/mission_objective/sector_sweep/sweep + +/datum/mission/exploration/Destroy() + sweep = null + return ..() /datum/mission/exploration/setup_target() var/datum/mission_target/coords/coords = new(src) @@ -28,17 +40,274 @@ return TRUE /datum/mission/exploration/build_objectives() - add_objective(new /datum/mission_objective/goto_coords) + var/datum/mission_objective/goto_coords/approach = new + // The sweep announces the arrival itself + approach.arrival_message = null + add_objective(approach) + sweep = new + add_objective(sweep) /datum/mission/exploration/update_text() name = "Exploration Contract: ([target.target_x], [target.target_y])" desc = "Chart the sector at ([target.target_x], [target.target_y]) in the [target_zone_name]." /datum/mission/exploration/waypoint_label() - return "Survey site" + return sweep?.completed ? "Charted sector" : "Survey site" /datum/mission/exploration/get_ui_data() var/list/data = ..() data["target_x"] = target.target_x data["target_y"] = target.target_y return data + +// ========================================================================= +// SECTOR SWEEP: hold station at the site while the sensors work +// ========================================================================= + +/** + * The ship holds within hold_range of the mission target for sweep_time. Drifting + * off pauses the sweep and keeps what it had; coming back resumes it. The possible + * find (an uncharted ordinary derelict signal near the site) is rolled once, the + * first time the sweep starts, so breaking off and coming back never rerolls it. + */ +/datum/mission_objective/sector_sweep + /// How long the ship has to hold station + var/sweep_time = 30 SECONDS + /// Overmap tiles from the site the ship may sit and keep sweeping + var/hold_range = 2 + /// How far from the site a derelict signal can show up on the sweep + var/find_range = 7 + /// Percent chance the sweep turns up a derelict signal, when one is out there + var/find_chance = 50 + /// Gap between "broken off" lines, so a ship drifting on the edge doesn't spam the crew + var/notice_gap = 10 SECONDS + /// Sweep time banked from earlier runs + var/banked_time = 0 + /// Whether the ship is on station and the sweep is running + var/running = FALSE + /// world.time the current run started + var/run_started = 0 + /// Whether the sweep has started at least once + var/started = FALSE + /// Timer: the sweep finishing + var/finish_timer + /// Timer: the faint return halfway through, when there is a find + var/return_timer + /// Whether the faint return has been called out + var/return_reported = FALSE + /// Whether a "broken off" line went out that still needs its "resumed" + var/break_reported = FALSE + /// Whether the find has been rolled for this sweep + var/find_rolled = FALSE + /// The derelict signal the sweep picked up, if any + var/datum/weakref/find_ref + COOLDOWN_DECLARE(break_notice_cooldown) + +/datum/mission_objective/sector_sweep/Destroy() + find_ref = null + return ..() + +/datum/mission_objective/sector_sweep/activate() + . = ..() + var/obj/structure/overmap/ship/ship = get_servant() + if(!ship) + return + RegisterSignal(ship, COMSIG_MOVABLE_MOVED, PROC_REF(on_ship_moved)) + check_station() + +/datum/mission_objective/sector_sweep/deactivate() + var/obj/structure/overmap/ship/ship = get_servant() + if(ship) + UnregisterSignal(ship, COMSIG_MOVABLE_MOVED) + stop_run() + return ..() + +/datum/mission_objective/sector_sweep/reset() + . = ..() + banked_time = 0 + running = FALSE + run_started = 0 + started = FALSE + return_reported = FALSE + break_reported = FALSE + find_rolled = FALSE + find_ref = null + +/datum/mission_objective/sector_sweep/proc/on_ship_moved(datum/source) + SIGNAL_HANDLER + check_station() + +/// Wrapped overmap distance from relative coordinates to the mission site, or null +/datum/mission_objective/sector_sweep/proc/distance_to_site(list/coords) + var/datum/mission_target/target = mission?.target + if(!coords || !target) + return null + var/dx = overmap_wrapped_delta(coords[1] - target.target_x, OVERMAP_SIZE - 2) + var/dy = overmap_wrapped_delta(coords[2] - target.target_y, OVERMAP_SIZE - 2) + return sqrt(dx * dx + dy * dy) + +/// Whether the servant ship is close enough to the site to sweep it +/datum/mission_objective/sector_sweep/proc/is_on_station() + var/obj/structure/overmap/ship/ship = get_servant() + if(!ship) + return FALSE + var/dist = distance_to_site(ship.get_relative_overmap_coords()) + return !isnull(dist) && dist <= hold_range + +/// Starts or pauses the sweep to match where the ship is +/datum/mission_objective/sector_sweep/proc/check_station() + if(completed || !active) + return + var/on_station = is_on_station() + if(on_station && !running) + start_run() + else if(!on_station && running) + stop_run() + if(COOLDOWN_FINISHED(src, break_notice_cooldown)) + COOLDOWN_START(src, break_notice_cooldown, notice_gap) + break_reported = TRUE + notify_crew("Sweep broken off.", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') + +/datum/mission_objective/sector_sweep/proc/start_run() + running = TRUE + run_started = world.time + if(!find_rolled) + find_rolled = TRUE + roll_find() + finish_timer = addtimer(CALLBACK(src, PROC_REF(finish_sweep)), max(sweep_time - banked_time, 1), TIMER_STOPPABLE) + var/halfway = sweep_time / 2 + if(find_ref && !return_reported && banked_time < halfway) + return_timer = addtimer(CALLBACK(src, PROC_REF(report_return)), halfway - banked_time, TIMER_STOPPABLE) + if(!started) + started = TRUE + notify_crew("Survey site reached. Sweeping the sector.", sound = 'sound/machines/sonar-ping.ogg') + else if(break_reported) + break_reported = FALSE + notify_crew("Back on station. Sweep resumed.", sound = 'sound/machines/sonar-ping.ogg') + +/// Banks the current run and stops its timers (safe to call while already stopped) +/datum/mission_objective/sector_sweep/proc/stop_run() + if(running) + banked_time += world.time - run_started + running = FALSE + if(finish_timer) + deltimer(finish_timer) + finish_timer = null + if(return_timer) + deltimer(return_timer) + return_timer = null + +/** + * Picks what the sweep turns up: the nearest ordinary derelict signal just past the + * ship's own sight from the site, that this ship has neither seen nor charted. Only + * plain naturally seeded signals with nobody's claim on them count, so the sweep + * never points at a rumour site, a contract's site, a bounty lair or a broadcast. + */ +/datum/mission_objective/sector_sweep/proc/roll_find() + find_ref = null + if(!prob(find_chance)) + return + var/obj/structure/overmap/ship/ship = get_servant() + var/turf/ship_turf = get_turf(ship) + if(!ship_turf) + return + var/obj/structure/overmap/space_ruin/best + var/best_dist + for(var/obj/structure/overmap/space_ruin/ruin as anything in GLOB.space_ruin_signals) + if(!is_ordinary_signal(ruin)) + continue + var/turf/ruin_turf = get_turf(ruin) + if(ruin_turf?.z != ship_turf.z) + continue + var/ruin_ref = REF(ruin) + if(ship.get_waypoint(ruin_ref)) + continue + var/datum/weakref/seen = ship.discovered_contacts[ruin_ref] + if(seen?.resolve() == ruin) + continue + var/dist = distance_to_site(ruin.get_relative_overmap_coords()) + if(isnull(dist) || dist <= SHIP_VIEW_RANGE || dist > find_range) + continue + if(isnull(best_dist) || dist < best_dist) + best = ruin + best_dist = dist + if(best) + find_ref = WEAKREF(best) + +/// A plain derelict signal from natural seeding, with no claim, lock, broadcast or rumour on it +/datum/mission_objective/sector_sweep/proc/is_ordinary_signal(obj/structure/overmap/space_ruin/ruin) + if(QDELETED(ruin) || ruin.type != /obj/structure/overmap/space_ruin || !ruin.sensor_detectable) + return FALSE + if(ruin.rare || ruin.no_replacement || ruin.mission_locked || ruin.mission_exclusive || ruin.mission_claims) + return FALSE + return !(ruin in GLOB.overmap_fleet_beacons) + +/// The find, if it is still out there +/datum/mission_objective/sector_sweep/proc/get_find() + var/obj/structure/overmap/space_ruin/find = find_ref?.resolve() + if(QDELETED(find)) + find_ref = null + return null + return find + +/// " to the northeast" from the ship to `object`, or "" when there is no bearing +/datum/mission_objective/sector_sweep/proc/bearing_to(obj/structure/overmap/object) + var/static/list/compass_words = list( + "N" = "north", "NE" = "northeast", "E" = "east", "SE" = "southeast", + "S" = "south", "SW" = "southwest", "W" = "west", "NW" = "northwest", + ) + var/obj/structure/overmap/ship/ship = get_servant() + var/list/from = ship?.get_relative_overmap_coords() + var/list/to_coords = object?.get_relative_overmap_coords() + if(!from || !to_coords) + return "" + var/dx = overmap_wrapped_delta(to_coords[1] - from[1], OVERMAP_SIZE - 2) + var/dy = overmap_wrapped_delta(to_coords[2] - from[2], OVERMAP_SIZE - 2) + var/compass = overmap_delta_to_compass(dx, dy) + if(!compass) + return "" + return " to the [compass_words[compass]]" + +/datum/mission_objective/sector_sweep/proc/report_return() + return_timer = null + if(!active || completed) + return + var/obj/structure/overmap/space_ruin/find = get_find() + if(!find) + return + return_reported = TRUE + notify_crew("Faint return[bearing_to(find)].", sound = 'sound/machines/sonar-ping.ogg') + +/datum/mission_objective/sector_sweep/proc/finish_sweep() + finish_timer = null + if(!active || completed) + return + running = FALSE + banked_time = sweep_time + if(return_timer) + deltimer(return_timer) + return_timer = null + var/static/list/quiet_lines = list( + "Sector charted. Quiet out here.", + "Sector charted. Nothing but dust.", + "Sector charted. Just old drive wakes.", + ) + var/line = pick(quiet_lines) + var/obj/structure/overmap/ship/ship = get_servant() + var/obj/structure/overmap/space_ruin/find = get_find() + // A scan the crew ran themselves meanwhile may have charted it already: no news then + if(ship && find && ship.chart_as_waypoint(find)) + line = "Sector charted. Derelict signal logged[bearing_to(find)]." + notify_crew("[line] Pay's waiting on the board.", sound = 'voidcrew/sound/notify2.ogg') + var/datum/mission/owner = mission + complete() + owner?.push_waypoint() + +/datum/mission_objective/sector_sweep/get_progress_string() + if(completed) + return "Sector charted" + if(running) + return "Sweeping the sector" + if(started) + return "Sweep broken off" + return "Sweep the sector" diff --git a/voidcrew/modules/missions/missions/field_expedition.dm b/voidcrew/modules/missions/missions/field_expedition.dm index 5ca8eaec4e4..ce12215fa5c 100644 --- a/voidcrew/modules/missions/missions/field_expedition.dm +++ b/voidcrew/modules/missions/missions/field_expedition.dm @@ -51,7 +51,9 @@ )) /datum/mission/field_expedition/build_objectives() - add_objective(new /datum/mission_objective/field/plant_quest) + var/datum/mission_objective/field/plant_quest/plant = new + plant.scene_type = /datum/mission_scene/crash + add_objective(plant) add_objective(new /datum/mission_objective/deliver/bound) /// Picking the core up can wake the neighborhood (once per era) diff --git a/voidcrew/modules/missions/missions/live_capture.dm b/voidcrew/modules/missions/missions/live_capture.dm index 17090950e32..494fd5a7763 100644 --- a/voidcrew/modules/missions/missions/live_capture.dm +++ b/voidcrew/modules/missions/missions/live_capture.dm @@ -232,6 +232,7 @@ mission.fail("No mission pad to dispense the capture crate to.") return FALSE kit = new(kit_turf) + mission_pad_delivery_effect(kit_turf) kit.objective_ref = WEAKREF(src) mission.bind_item(kit) // One crate per contract: losing it voids the capture diff --git a/voidcrew/modules/missions/missions/prospect_stake.dm b/voidcrew/modules/missions/missions/prospect_stake.dm index adcc1ff938b..bb847a7d425 100644 --- a/voidcrew/modules/missions/missions/prospect_stake.dm +++ b/voidcrew/modules/missions/missions/prospect_stake.dm @@ -1,16 +1,17 @@ /** * # Prospect Stake * - * "Plant our claim beacon at these red-zone coordinates and keep it alive - * for eight minutes. The filing goes out on Wideband, so expect... interest." + * "Plant our claim beacon on this rock and keep it standing until the claim + * matures. The filing goes out on Wideband, so expect... interest." * * The announced PvP flashpoint as a mission: a claim kit is dispensed at - * accept; deploying it (ship holding at the marked coordinates) files the - * claim galaxy-wide - the contested-cache broadcast pattern - and starts a - * defend clock that only runs on station. Boarding waves answer the filing; - * red space means anyone else can too. The beacon survives, it prints a - * bonded deed for the pad. Objectives: [fly there] -> [deploy & defend] -> - * [carry the deed home]. + * accept, and the crew lands on a contested or lawless planet to raise it on + * open ground, clear of the landing field and any parked hull. Deploying it + * files the claim galaxy-wide - the contested-cache broadcast pattern - and + * starts a defend clock that only runs while a crew member stands guard at + * the beacon. Waves answer the filing on the ground around it; red space + * means anyone else can too. The beacon survives, it prints a bonded deed for + * the pad. Objectives: [deploy & defend] -> [carry the deed home]. */ /datum/mission/prospect_stake name = "Prospect Stake" @@ -29,6 +30,7 @@ var/wave_theme /// The defense objective (kit dispensing at start) var/datum/mission_objective/claim_defense/defense + /datum/mission/prospect_stake/Destroy() defense = null return ..() @@ -36,26 +38,40 @@ /datum/mission/prospect_stake/get_archetype() return "claim" +/** + * Picks the planet to stake. An offer pinned to a band (the reserved top-band + * slots, the unarmed green bias) only tries that band, and a green pin finds + * nothing. Otherwise the band is rolled, falling back to the other band when + * the rolled one has no world to offer. + */ /datum/mission/prospect_stake/setup_target() - var/datum/mission_target/coords/coords = new(src) - // Yellow stakes are the on-ramp; red is the real thing - coords.zone_weights = list( - "[ZONE_YELLOW]" = 45, - "[ZONE_RED]" = 55, - ) - if(!coords.resolve()) - qdel(coords) - return FALSE - target = coords - return TRUE + var/list/bands = list() + if(!isnull(preferred_zone)) + bands += preferred_zone + else + // Yellow stakes are the on-ramp; red is the real thing + var/list/weights = list( + "[ZONE_YELLOW]" = 45, + "[ZONE_RED]" = 55, + ) + while(length(weights)) + var/band_key = pick_weight(weights) + weights -= band_key + bands += text2num(band_key) + for(var/band in bands) + var/datum/mission_target/planet/claim_site/site = new(src) + site.preferred_zone = band + if(site.resolve()) + target = site + return TRUE + qdel(site) + return FALSE /datum/mission/prospect_stake/generate_details() objective_name = "notarized claim deed" wave_theme = pick_weight(MISSION_WAVE_THEMES) + /datum/mission/prospect_stake/build_objectives() - var/datum/mission_objective/goto_coords/approach = new - approach.arrival_message = "On station over the claim." - add_objective(approach) defense = new defense.wave_theme = wave_theme add_objective(defense) @@ -65,18 +81,89 @@ defense?.dispense_kit() /datum/mission/prospect_stake/update_text() - name = "Prospect Stake: ([target.target_x], [target.target_y])" - desc = "File our mineral-rights claim at ([target.target_x], [target.target_y]) in the [target_zone_name]." + var/datum/mission_target/planet/site = target + var/site_name = istype(site) ? (site.planet?.name || "the planet") : "the planet" + name = "Prospect Stake: [site_name]" + desc = "File our mineral-rights claim on [site_name] at ([target.target_x], [target.target_y]) in the [target_zone_name]." /datum/mission/prospect_stake/waypoint_label() return "Prospect stake" +// ========================================================================= +// CLAIM SITE: a real world to stand on +// ========================================================================= + +/** + * # Claim Site + * + * The planet target narrowed to ground a claim can stand on: terrain worlds + * only (GLOB.overmap_planets also holds empty-space dock placeholders, crash + * sites and weak signals, none of which have any), and never neutral space. + * Picks a biome first and hands it to the planet target's wanted_planet + * filter, so every other rule (exclusivity, occupancy, field contacts, + * relocation tracking) is the planet target's own. + */ +/datum/mission_target/planet/claim_site + /// Biomes a field contact may be minted as when no terrain world is on offer + var/static/list/claim_biomes = list( + /datum/overmap/planet/lava, + /datum/overmap/planet/ice, + /datum/overmap/planet/jungle, + /datum/overmap/planet/beach, + /datum/overmap/planet/wasteland, + ) + +/// Claims are filed in contested and lawless space only +/datum/mission_target/planet/claim_site/zone_is_eligible(band) + return band != ZONE_GREEN && ..() + +/datum/mission_target/planet/claim_site/resolve() + var/list/biomes = list() + for(var/obj/structure/overmap/planet/candidate as anything in GLOB.overmap_planets) + if(QDELETED(candidate) || candidate == planet || candidate.mission_exclusive || !candidate.is_terrain_planet()) + continue + if(!istype(get_turf(candidate), /turf/open/overmap) || !zone_is_eligible(SSovermap_zones?.get_zone_type(get_turf(candidate)))) + continue + biomes |= candidate.planet + if(!length(biomes)) + // Never mint a contact in a band no claim can use (a green-pinned reserved slot + // would leave a stray planet on the chart for an offer that then fails) + if(!mission?.create_field_contact || !zone_is_eligible(preferred_zone)) + unhook() + return FALSE + // Nothing standing in the band: the planet target mints a contact of this biome + biomes = claim_biomes + wanted_planet = pick(biomes) + return ..() + +/** + * Why a claim beacon can't stand on this turf, as a balloon line, or null if + * it can. Open, solid ground on this world's own surface or caves - never a + * deck, a ruin, space, lava, water or a chasm - and clear of the landing + * berths and any parked hull, so no ship comes down on the claim and no wave + * lands on somebody's floor. + */ +/datum/mission_target/planet/claim_site/proc/claim_ground_refusal(turf/spot) + if(!spot || !isopenturf(spot) || isgroundlessturf(spot) || !contains_turf(spot)) + return "no claim ground here!" + if(!istype(get_area(spot), /area/overmap_encounter/planetoid) || spot.is_blocked_turf(exclude_mobs = TRUE)) + return "no claim ground here!" + var/datum/space_level/level = length(planet.mapzone?.z_levels) ? planet.mapzone.z_levels[1] : null + var/strip_top = planet.get_dock_strip_top_y(level) + if(!isnull(strip_top) && spot.y <= strip_top) + return "too close to the landing field!" + // One tile past where a wave can scatter, so no arrival lands on a deck + for(var/turf/nearby as anything in RANGE_TURFS(ZONE_MOBS_WAVE_SCATTER + 1, spot)) + if(istype(nearby.loc, /area/shuttle)) + return "too close to a ship!" + return null + /** * # Claim Beacon Kit * - * The packed beacon handed over at accept. Use in hand while the ship holds - * at the stake coordinates; the deployment channel raises the beacon on the - * spot you're standing. + * The packed beacon handed over at accept. Use in hand on open ground at the + * claim site; the deployment channel raises the beacon on the spot you're + * standing. */ /obj/item/claim_beacon_kit name = "claim beacon kit" @@ -93,29 +180,40 @@ if(.) return var/datum/mission_objective/claim_defense/objective = objective_ref?.resolve() - if(!objective?.mission || objective.mission.failed || objective.mission.completed) + if(!objective?.mission || objective.mission.failed || objective.mission.completed || !objective.active) balloon_alert(user, "contract expired!") return TRUE - if(!objective.active || !objective.ship_on_station()) - balloon_alert(user, "ship not holding at the stake coordinates!") + var/refusal = claim_refusal(objective, get_turf(user)) + if(refusal) + balloon_alert(user, refusal) return TRUE balloon_alert(user, "deploying beacon...") playsound(src, 'sound/items/tools/ratchet.ogg', 60, TRUE) if(!do_after(user, 8 SECONDS, target = user)) balloon_alert(user, "deployment interrupted!") return TRUE - if(!objective.ship_on_station()) - balloon_alert(user, "drifted off station!") + if(!objective.mission || objective.mission.failed || objective.mission.completed || !objective.active) + return TRUE + refusal = claim_refusal(objective, get_turf(user)) + if(refusal) + balloon_alert(user, refusal) return TRUE objective.deploy(user, get_turf(user)) return TRUE +/// Why the beacon can't go up here, or null if it can +/obj/item/claim_beacon_kit/proc/claim_refusal(datum/mission_objective/claim_defense/objective, turf/spot) + var/datum/mission_target/planet/claim_site/site = objective.mission?.target + if(!istype(site)) + return "no claim ground here!" + return site.claim_ground_refusal(spot) + /** * # Claim Beacon * * The deployed stake: destructible on purpose - defending it is the mission. - * Ticks the defend clock while the ship holds station, calls its own waves, - * and files every beat on Wideband like the contested cache does. + * Ticks the defend clock while a crew member stands guard, calls its own + * waves, and files every beat on Wideband like the contested cache does. */ /obj/structure/mission_claim_beacon name = "prospecting claim beacon" @@ -125,15 +223,13 @@ anchored = TRUE density = TRUE max_integrity = 400 + // Driven into the ground: wind, force pushes and gravity never shift it off the claim + move_resist = INFINITY /// Weakref to the claim_defense objective driving this beacon var/datum/weakref/objective_ref /// Internal wideband transmitter (the contested-cache broadcast pattern) var/obj/item/radio/headset/radio - /// world.time gate for the next defender wave - var/next_wave_at = 0 - /// Throttle for off-station warnings - COOLDOWN_DECLARE(offstation_warn_cooldown) /obj/structure/mission_claim_beacon/Initialize(mapload) . = ..() @@ -142,7 +238,6 @@ radio.canhear_range = 0 radio.set_listening(FALSE) radio.recalculateChannels() - next_wave_at = world.time + 1 MINUTES START_PROCESSING(SSobj, src) /obj/structure/mission_claim_beacon/Destroy() @@ -164,14 +259,6 @@ priority_announce(message, "Prospect Filing", sender_override = "Sector Claims Registry") radio?.talk_into(src, message, RADIO_CHANNEL_WIDEBAND) -/obj/structure/mission_claim_beacon/proc/show_offstation_warning() - if(!COOLDOWN_FINISHED(src, offstation_warn_cooldown)) - return - COOLDOWN_START(src, offstation_warn_cooldown, 15 SECONDS) - balloon_alert_to_viewers("off station!") - var/datum/mission_objective/claim_defense/objective = objective_ref?.resolve() - objective?.notify_crew("Claim beacon reports the ship off station.", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') - /// The claim matured: stop being a mission object, stay as scenery /obj/structure/mission_claim_beacon/proc/retire() STOP_PROCESSING(SSobj, src) diff --git a/voidcrew/modules/missions/missions/recovery_variants.dm b/voidcrew/modules/missions/missions/recovery_variants.dm index 2a53a981637..411e32095fc 100644 --- a/voidcrew/modules/missions/missions/recovery_variants.dm +++ b/voidcrew/modules/missions/missions/recovery_variants.dm @@ -165,6 +165,7 @@ /datum/mission/recovery/extraction/build_objectives() var/datum/mission_objective/field/plant_quest/plant = new plant.quest_item_type = /obj/item/mission_recovery/anchored + plant.scene_type = /datum/mission_scene/cargo_wreck add_objective(plant) add_objective(new /datum/mission_objective/deliver/bound) @@ -203,7 +204,7 @@ * # Anchored Recovery Cargo * * The extraction objective: a mission_recovery item that starts bolted to - * the deck. Unbolting is a channel that trips the mission's alarm. + * the deck. Unbolting is a wrench channel that trips the mission's alarm. */ /obj/item/mission_recovery/anchored desc = "Contracted salvage, bolted to the deck." @@ -214,26 +215,32 @@ /obj/item/mission_recovery/anchored/examine(mob/user) . = ..() if(anchored) - . += span_warning("It is bolted down.") + . += span_warning("It is bolted to the floor.") +/// Bare hands get nowhere with the bolts /obj/item/mission_recovery/anchored/attack_hand(mob/living/user, list/modifiers) if(!anchored) return ..() + balloon_alert(user, "it's bolted down") + return TRUE + +/obj/item/mission_recovery/anchored/wrench_act(mob/living/user, obj/item/tool) + if(!anchored) + return NONE balloon_alert(user, "wrenching it free...") - playsound(src, 'sound/items/tools/ratchet.ogg', 60, TRUE) - if(!do_after(user, EXTRACTION_UNBOLT_TIME, target = src)) + if(!tool.use_tool(src, user, EXTRACTION_UNBOLT_TIME, volume = 60)) balloon_alert(user, "still bolted!") - return TRUE + return ITEM_INTERACT_BLOCKING if(!anchored) balloon_alert(user, "already free") - return TRUE + return ITEM_INTERACT_BLOCKING anchored = FALSE balloon_alert(user, "wrenched free") playsound(src, 'sound/machines/click.ogg', 60, TRUE) var/datum/mission/recovery/extraction/mission = mission_ref?.resolve() if(istype(mission)) mission.trigger_extraction_alarm(src) - return TRUE + return ITEM_INTERACT_SUCCESS #undef SURVEY_CALIBRATE_TIME #undef EXTRACTION_UNBOLT_TIME diff --git a/voidcrew/modules/missions/missions/rescue.dm b/voidcrew/modules/missions/missions/rescue.dm index 626b0585f2a..fbae8504522 100644 --- a/voidcrew/modules/missions/missions/rescue.dm +++ b/voidcrew/modules/missions/missions/rescue.dm @@ -3,11 +3,11 @@ * * "A survivor's beacon is still pinging inside that wreck. Bring them home alive." * - * Recovery variant where the objective breathes: a survivor NPC spawns in - * the target ruin, follows whoever asks (or rides a fireman carry), and the - * mission turns in while they're alive beside the ship's mission pad. - * Survivor death burns a retarget ("another beacon"). The non-gunner's - * recovery mission. + * Recovery variant where the objective breathes: a survivor NPC hides in the + * target ruin, follows whoever asks, and the mission turns in while they're + * alive beside the ship's mission pad. Survivor death burns a retarget + * ("another beacon"). The non-gunner's recovery mission. The survivor + * themselves are in rescue_survivor.dm. */ /datum/mission/rescue name = "Rescue Contract" @@ -50,116 +50,3 @@ /datum/mission/rescue/waypoint_label() return "Rescue: [objective_name]" - -/// Blackboard: who a rescue survivor follows -#define BB_MISSION_SURVIVOR_LEADER "mission_survivor_leader" - -/** - * # Mission Survivor - * - * The living objective: friendly, fragile, and clingy on request. A real human body (the human NPC - * base, voidcrew/modules/human_npcs/): wounds, bleeding, crit, death and revival are a person's, and a - * crew can fireman-carry, drag, bag or treat them like anyone. An empty hand while they are up and - * about toggles follow; down, asleep or on fire it is tg's help (CPR, shaking awake, patting out - * flames). They never fight back. - * - * The contract puts them inside wrecks, which are airless and near absolute zero: they have been - * living in their emergency softsuit, helmet on and a tank on their back, and breathe from the tank - * when the air is bad, as a person does. Their body is the mission's: the corpse cleanup never takes - * it, since a dead survivor can still be brought back (the escort objective's revival window). - */ -/mob/living/carbon/human/npc/mission_survivor - name = "survivor" - desc = "Somebody who has had a very long week and would love to see a ship interior again. Their emergency softsuit is patched in three places and still holding." - faction = list(FACTION_NEUTRAL) - ai_controller = /datum/ai_controller/basic_controller/mission_survivor - npc_outfit = /datum/outfit/mission_survivor - npc_target_stat = HUMAN_NPC_SPARES_DOWNED - npc_corpse_lifetime = 0 - /// Who the survivor is currently following, if anyone - var/datum/weakref/following_ref - -/// A freighter hand who has been living in the emergency softsuit from the wreck's locker -/datum/outfit/mission_survivor - name = "Rescue survivor" - uniform = /obj/item/clothing/under/color/grey - suit = /obj/item/clothing/suit/space/fragile - head = /obj/item/clothing/head/helmet/space/fragile - mask = /obj/item/clothing/mask/breath - back = /obj/item/tank/internals/oxygen - shoes = /obj/item/clothing/shoes/sneakers/black - internals_slot = ITEM_SLOT_BACK - -/mob/living/carbon/human/npc/mission_survivor/Initialize(mapload, datum/human_npc_order/order) - var/static/list/survivor_names = list("Adler", "Bex", "Cato", "Dova", "Emin", "Farrow", "Ines", "Jun", "Kest", "Loami") - npc_name = "survivor ([pick(survivor_names)])" - return ..() - -/mob/living/carbon/human/npc/mission_survivor/Destroy() - following_ref = null - return ..() - -// A dry, worn-out voice -/mob/living/carbon/human/npc/mission_survivor/get_default_say_verb() - return "croaks" - -/mob/living/carbon/human/npc/mission_survivor/examine(mob/user) - . = ..() - if(stat == DEAD) - return - var/mob/following = following_ref?.resolve() - if(following) - . += span_notice("They're sticking close to [following].") - else - . += span_notice("They look lost.") - -/mob/living/carbon/human/npc/mission_survivor/attack_hand(mob/living/user, list/modifiers) - if(user.combat_mode || LAZYACCESS(modifiers, RIGHT_CLICK) || stat != CONSCIOUS || on_fire || body_position != STANDING_UP || HAS_TRAIT(src, TRAIT_INCAPACITATED)) - return ..() - var/mob/following = following_ref?.resolve() - if(following == user) - stop_following() - balloon_alert(user, "waiting here") - say("I'll... wait right here.") - else - start_following(user) - balloon_alert(user, "following you") - say("Right behind you. Please don't be wrong about the way out.") - return TRUE - -/mob/living/carbon/human/npc/mission_survivor/proc/start_following(mob/living/leader) - following_ref = WEAKREF(leader) - ai_controller?.set_blackboard_key(BB_MISSION_SURVIVOR_LEADER, leader) - -/mob/living/carbon/human/npc/mission_survivor/proc/stop_following() - following_ref = null - ai_controller?.clear_blackboard_key(BB_MISSION_SURVIVOR_LEADER) - -/mob/living/carbon/human/npc/mission_survivor/death(gibbed) - stop_following() - return ..() - -/** - * The survivor's brain: keeps up with whoever they follow, on their own feet. tg's basic controller - * already stops it while they are down, stunned, asleep or carried, so a survivor in crit is a body - * to carry, not one dragged along by a script. - */ -/datum/ai_controller/basic_controller/mission_survivor - blackboard = list() - ai_traits = PASSIVE_AI_FLAGS - ai_movement = /datum/ai_movement/jps - idle_behavior = null - planning_subtrees = list(/datum/ai_planning_subtree/mission_survivor_follow) - -/// Walks after their leader when more than a step behind, while the leader is near enough to follow -/datum/ai_planning_subtree/mission_survivor_follow - -/datum/ai_planning_subtree/mission_survivor_follow/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/survivor = controller.pawn - var/mob/living/leader = controller.blackboard[BB_MISSION_SURVIVOR_LEADER] - if(QDELETED(leader) || leader.z != survivor.z || get_dist(survivor, leader) <= 1 || get_dist(survivor, leader) > 12) - return - controller.queue_behavior(/datum/ai_behavior/travel_towards/stop_on_arrival, BB_MISSION_SURVIVOR_LEADER) - return SUBTREE_RETURN_FINISH_PLANNING - -#undef BB_MISSION_SURVIVOR_LEADER diff --git a/voidcrew/modules/missions/missions/rescue_survivor.dm b/voidcrew/modules/missions/missions/rescue_survivor.dm new file mode 100644 index 00000000000..10683117d53 --- /dev/null +++ b/voidcrew/modules/missions/missions/rescue_survivor.dm @@ -0,0 +1,1092 @@ +/** + * # Rescue survivor + * + * The person a rescue contract sends a crew to fetch. They are an ambient NPC (the world population + * core in voidcrew/modules/ambient_npcs/), so they get its looks, its walking, its activities and + * its dialogue cooldowns, and a real human body (voidcrew/modules/human_npcs/): wounds, bleeding, + * crit, death and revival are a person's, and a crew can fireman-carry, drag, bag or treat them + * like anyone. They behave like a frightened person: + * + * - placed somewhere sheltered in the wreck (a locker, a corner, an alcove), out of sight of + * whatever is loose in there (mission_survivor_hiding_place()); + * - hiding: crouched and quiet, fidgeting now and then; inside a locker, silent; + * - before anyone has found them, their beacon crackles a distress call to the contract crew's + * radios when they are a few screens away; + * - when they see a person, they call out and wave (or bang on the locker), and come over if + * nothing is about; + * - a hostile close by, or one going for them: they run, away from it, and hide again where they + * stop; one further off: they keep still, and if there are people about they shout a warning; + * - an empty hand makes them follow (or wait); following, they stay at their rescuer's side, + * duck and yelp at danger instead of running, climb out of anything they are shut in, and wait + * where they are if their rescuer goes; + * - they never fight; + * - removed by the contract (delivered, timed out, abandoned, re-targeted), they are taken up from + * orbit in the transporter's column of light (beam_out()), or deleted at once if nobody sees. + * + * The contract puts them inside wrecks, which are airless and near absolute zero: they have been + * living in their emergency softsuit, helmet on and a tank on their back, and breathe from the tank + * when the air is bad, as a person does. Their body is the mission's: the corpse cleanup never takes + * it, since a dead survivor can still be brought back (the escort objective's revival window). + */ + +/// How far they see people and threats +#define SURVIVOR_SIGHT 7 +/// How often they look around +#define SURVIVOR_LOOK_INTERVAL (1 SECONDS) +/// A threat this close, or one going for them, sends them running (until they have a rescuer) +#define SURVIVOR_FLEE_DISTANCE 4 +/// How far they run at most, per run +#define SURVIVOR_FLEE_RANGE 6 +/// How long one flight lasts before they settle wherever they got to +#define SURVIVOR_FLEE_TIME (12 SECONDS) +/// A threat that keeps coming can send them running this many more times in one flight +#define SURVIVOR_FLEE_RUNS 3 +/// The contract crew hear the distress call within this many tiles +#define SURVIVOR_DISTRESS_RANGE 30 +/// Between two distress calls +#define SURVIVOR_DISTRESS_GAP_LOW (50 SECONDS) +#define SURVIVOR_DISTRESS_GAP_HIGH (90 SECONDS) +/// Somebody they spotted this close (or nearer) gets walked up to, if nothing else is about +#define SURVIVOR_APPROACH_RANGE 6 +/// Somebody this close counts as right there (they stand up, they plead) +#define SURVIVOR_NEAR_RANGE 3 +/// Inside a locker they hear people this close +#define SURVIVOR_HEARING_RANGE 3 +/// Following: a leader further than this, or gone, or dead, is out of reach +#define SURVIVOR_FOLLOW_RANGE 14 +/// Following: a leader out of reach this long, and they stop and wait where they are +#define SURVIVOR_LOST_TIME (45 SECONDS) +/// Following outranks every reaction: nothing makes them run off from their rescuer +#define SURVIVOR_FOLLOW_PRIORITY 60 +/// Running outranks calling out +#define SURVIVOR_FLEE_PRIORITY 55 +/// Following: how long they stay down when they duck, and how soon they may duck again +#define SURVIVOR_DUCK_TIME (3 SECONDS) +#define SURVIVOR_DUCK_COOLDOWN (8 SECONDS) +/// Hiding place search: how far from the site's spawn point it looks +#define SURVIVOR_SHELTER_RADIUS 20 +/// Hiding place search: nothing hostile within this many tiles of it +#define SURVIVOR_SHELTER_THREAT_GAP 6 +/// Hiding place search: blocked neighbours (of 8) a floor tile needs to count as a corner or alcove +#define SURVIVOR_SHELTER_MIN_COVER 5 +/// The beam: the column comes down, they come apart in it, and they are gone this long after it started +#define SURVIVOR_BEAM_TIME (3 SECONDS) +/// The beam: how long the column takes to come down before they start to come apart +#define SURVIVOR_BEAM_DROP (0.4 SECONDS) +/// The beam is only drawn for someone with a client within this many tiles; otherwise they are deleted at once +#define SURVIVOR_BEAM_WATCH_RANGE 10 +/// Trait source for what the survivor puts on themselves +#define SURVIVOR_TRAIT "mission_survivor" + +// ========================================================================= +// THE SURVIVOR +// ========================================================================= + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor + name = "survivor" + desc = "Somebody who has had a very long week and would love to see a ship interior again. Their emergency suit is patched in three places and still holding." + death_cash_low = 0 + death_cash_high = 0 + speech_pace = 1.5 + outfit = /datum/outfit/mission_survivor + // Their body is the contract's until it lets go of them (corpse_lifetime()) + npc_corpse_lifetime = 0 + routine = list(/datum/ambient_activity/survivor_hide = 1) + ai_controller = /datum/ai_controller/basic_controller/ambient_npc/mission_survivor + /// The contract they belong to (a /datum/mission), for the distress call and to know its crew + var/datum/weakref/contract_ref + /// Who they were before this ("salvage tech"), from the contract + var/story + /// Where they keep their head down when they are not doing anything else + var/turf/hide_spot + /// The locker they were put in to hide, while they are still in it + var/datum/weakref/hid_in_ref + /// Someone has made them follow at least once + var/rescued = FALSE + /// They have seen a person: no more distress calls + var/contacted = FALSE + /// They said something on first stepping aboard a ship + var/said_aboard = FALSE + /// Being taken up in the beam: nothing else happens to them + var/beaming_out = FALSE + /// REFs of the people they already called out to + var/list/greeted + /// world.time they next look around, call for help on the radio, or fidget + var/next_look = 0 + var/next_distress = 0 + var/next_fidget = 0 + /// world.time they last saw a threat + var/last_threat_at = 0 + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/Initialize(mapload, datum/human_npc_order/order) + . = ..() + hide_spot = get_turf(src) + next_fidget = world.time + rand(20 SECONDS, 40 SECONDS) + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/Destroy() + contract_ref = null + hide_spot = null + hid_in_ref = null + greeted = null + return ..() + +// A dead survivor can be brought back inside the contract's window: the corpse cleanup leaves them be +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/corpse_lifetime() + return 0 + +/// Ties them to `contract`: its crew hear their distress call, and they take its story +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/join_contract(datum/mission/contract) + if(!contract) + return + contract_ref = WEAKREF(contract) + story = contract.objective_name + if(story) + var/article = (LOWER_TEXT(copytext(story, 1, 2)) in list("a", "e", "i", "o", "u")) ? "An" : "A" + desc = "[article] [story] who has had a very long week. [p_Their()] emergency suit is patched in three places and still holding." + +/** + * Puts them in their hiding place: into `locker` (shut) if there is one, or down in a crouch where + * they stand. Where they stand is where they come back to. + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/take_shelter(obj/structure/closet/locker) + hide_spot = get_turf(src) + if(QDELETED(locker)) + crouch() + return + if(locker.opened) + forceMove(locker.loc) + locker.close() + else + forceMove(locker) + if(loc == locker) + hid_in_ref = WEAKREF(locker) + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/examine(mob/user) + . = ..() + if(stat != CONSCIOUS) + return + var/datum/ambient_activity/survivor_follow/follow = activity + var/mob/leader = istype(follow) ? follow.anchor() : null + if(leader) + . += span_notice("[p_Theyre()] sticking close to [leader].") + else if(crouching) + . += span_notice("[p_Theyre()] shaking.") + +// ========================================================================= +// FOLLOWING +// ========================================================================= + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/talked_to(mob/living/user) + if(beaming_out || !talk_ready(user)) + return + if(!buckled) + face_atom(user) + var/datum/ambient_activity/survivor_follow/follow = activity + var/mob/living/leader = istype(follow) ? follow.anchor() : null + if(leader == user) + stop_following() + speak_context("wait", user, force = TRUE) + return + // Whoever came for them keeps them: a stranger can't walk off with them + if(leader && is_contract_crew(leader) && !is_contract_crew(user)) + speak_context("refuse", user, force = TRUE) + return + if(start_following(user)) + speak_context("follow", user, force = TRUE) + +/// They follow `leader` from now on. Returns the activity, or null. +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/start_following(mob/living/leader) + if(beaming_out || !isliving(leader)) + return null + rescued = TRUE + contacted = TRUE + return start_activity(new /datum/ambient_activity/survivor_follow(src, leader)) + +/// They stop following and wait where they are +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/stop_following() + hide_spot = get_turf(src) + if(is_following()) + end_activity() + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/is_following() + return istype(activity, /datum/ambient_activity/survivor_follow) + +/// Their rescuer is out of reach: they wait where they are. Called by the follow activity as it ends. +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/lose_leader() + hide_spot = get_turf(src) + +/// Their rescuer went down in front of them +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/leader_fell(mob/living/leader) + hide_spot = get_turf(src) + if(!buckled) + face_atom(leader) + speak_context("leader_down", leader, force = TRUE) + +/// Whether `person` is crew of the ship that took their contract +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/is_contract_crew(mob/living/person) + var/datum/mission/contract = contract_ref?.resolve() + if(!contract?.servant || !isliving(person)) + return FALSE + return ambient_crew_ship(person) == contract.servant + +/// Shut in something while following: they push it open, or bang on it if it won't +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/climb_out() + var/obj/structure/closet/container = loc + if(!istype(container) || !reaction_ready("climb_out", 3 SECONDS)) + return + if(container.open()) + return + if(reaction_ready("trapped", 12 SECONDS)) + bang_on(container) + speak_context("trapped", null, force = TRUE) + +/// Bangs on the inside of `container` +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/bang_on(obj/structure/closet/container) + if(QDELETED(container)) + return + container.Shake(2, 1, 0.5 SECONDS) + playsound(container, 'sound/effects/bang.ogg', 30, TRUE, -2) + +/// The first time they step aboard a crew's ship +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/check_aboard() + if(said_aboard || !istype(get_area(src), /area/shuttle/voidcrew)) + return + said_aboard = TRUE + speak_context("aboard", null, force = TRUE) + +// ========================================================================= +// LOOKING AROUND +// ========================================================================= + +/** + * About once a second while their AI is on: who and what can they see, and what do they do about + * it. Starts reactions (calling out, running) as activities; never sleeps. + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/look_around() + if(beaming_out || !can_act() || world.time < next_look) + return + next_look = world.time + SURVIVOR_LOOK_INTERVAL + var/turf/here = get_turf(src) + if(!here) + return + var/obj/structure/closet/container = istype(loc, /obj/structure/closet) ? loc : null + // Out of the locker they hid in: whoever let them out gets thanked + if(hid_in_ref && !container) + hid_in_ref = null + var/mob/living/opener = nearest_person(here, 2) + if(opener) + mark_greeted(opener) + contacted = TRUE + face_atom(opener) + speak_context("freed", opener, force = TRUE) + var/mob/living/threat = container ? null : nearest_threat(here) + if(threat) + last_threat_at = world.time + if(is_following()) + if(threat && reaction_ready("duck", SURVIVOR_DUCK_COOLDOWN)) + duck(threat) + return + if(threat) + react_threat(threat, here) + return + var/mob/living/person = new_person_in_sight(here, container) + if(person) + contacted = TRUE + start_activity(new /datum/ambient_activity/survivor_call(src, person)) + return + if(!contacted) + distress_call(here) + +/** + * A threat in sight, while nobody is leading them out. Close, or after them: they run. Further off: + * they keep still, and warn anyone there. + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/react_threat(mob/living/threat, turf/here) + var/after_us = threat.ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] == src + if(get_dist(here, threat) <= SURVIVOR_FLEE_DISTANCE || after_us) + if(!istype(activity, /datum/ambient_activity/survivor_flee)) + start_activity(new /datum/ambient_activity/survivor_flee(src, threat)) + return + if(istype(activity, /datum/ambient_activity/survivor_flee)) + return + // Walking up to someone with that about? No. + if(istype(activity, /datum/ambient_activity/survivor_call)) + end_activity() + if(isturf(loc) && !crouching) + crouch() + var/mob/living/person = nearest_person(here, SURVIVOR_SIGHT) + if(person) + contacted = TRUE + mark_greeted(person) + if(reaction_ready("warn", 15 SECONDS)) + speak_context("warn", person, force = TRUE) + return + if(!reaction_ready("cower", 30 SECONDS)) + return + if(prob(50)) + speak_context("cower", threat, force = TRUE) + else + manual_emote(pick("freezes.", "holds [p_their()] breath.", "presses [p_themselves()] against the wall.")) + +/// Following, and something is coming: they duck down and yelp, and stay with their rescuer +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/duck(mob/living/threat) + if(!isturf(loc)) + return + speak_context("duck", threat, force = TRUE) + if(crouching || buckled) + return + crouch() + addtimer(CALLBACK(src, PROC_REF(stop_ducking)), SURVIVOR_DUCK_TIME, TIMER_UNIQUE | TIMER_OVERRIDE) + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/stop_ducking() + if(crouching && is_following()) + stand_up() + +/// Whether `thing` is something they should be afraid of: awake, nobody's player, not a person, and out to hurt someone +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/is_threat(mob/living/thing) + if(thing == src || thing.stat != CONSCIOUS || thing.client || istype(thing, /mob/living/carbon/human/npc/ambient_npc)) + return FALSE + if(faction_check_atom(thing)) + return FALSE + return mission_survivor_dangerous(thing) + +/// The nearest threat they can see from `here`, or null +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/nearest_threat(turf/here) + var/mob/living/nearest + var/nearest_distance = INFINITY + for(var/mob/living/thing in hearers(SURVIVOR_SIGHT, here)) + if(!is_threat(thing)) + continue + var/distance = get_dist(here, thing) + if(distance < nearest_distance) + nearest = thing + nearest_distance = distance + return nearest + +/** + * The nearest awake person (someone played) within `range` of `here` that they can see, or null. + * From inside a locker they can't see out, so it goes by ear: anyone close enough counts. + * `skip_greeted` leaves out people they already called out to. + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/nearest_person(turf/here, range, by_ear = FALSE, skip_greeted = FALSE) + var/mob/living/nearest + var/nearest_distance = INFINITY + for(var/mob/living/person in SSspatial_grid.orthogonal_range_search(here, SPATIAL_GRID_CONTENTS_TYPE_CLIENTS, range)) + if(person == src || person.stat != CONSCIOUS) + continue + var/turf/there = get_turf(person) + if(!there || there.z != here.z) + continue + var/distance = get_dist(here, there) + if(distance > range || distance >= nearest_distance) + continue + if(skip_greeted && LAZYFIND(greeted, REF(person))) + continue + if(!by_ear && !can_see(here, there, range)) + continue + nearest = person + nearest_distance = distance + return nearest + +/// Someone they have not called out to yet, in sight (or in earshot from a locker), or null. They count as called out to from now. +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/new_person_in_sight(turf/here, obj/structure/closet/container) + var/mob/living/person = container ? nearest_person(here, SURVIVOR_HEARING_RANGE, by_ear = TRUE, skip_greeted = TRUE) : nearest_person(here, SURVIVOR_SIGHT, skip_greeted = TRUE) + if(person) + mark_greeted(person) + return person + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/mark_greeted(mob/living/person) + var/key = REF(person) + if(LAZYFIND(greeted, key)) + return + LAZYADD(greeted, key) + if(length(greeted) > 20) + greeted.Cut(1, 2) + +/** + * Nobody has found them yet: their beacon picks up the contract crew's ship and they talk into it. + * Heard on the radios of that crew within SURVIVOR_DISTRESS_RANGE, as a weak signal. + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/distress_call(turf/here) + if(world.time < next_distress) + return + var/datum/mission/contract = contract_ref?.resolve() + var/obj/structure/overmap/ship/ship = contract?.servant + if(!ship) + return + var/list/listeners = list() + for(var/mob/living/person in SSspatial_grid.orthogonal_range_search(here, SPATIAL_GRID_CONTENTS_TYPE_CLIENTS, SURVIVOR_DISTRESS_RANGE)) + if(person.stat == DEAD) + continue + var/turf/there = get_turf(person) + if(!there || there.z != here.z || get_dist(here, there) > SURVIVOR_DISTRESS_RANGE) + continue + if(ambient_crew_ship(person) != ship) + continue + listeners += person + if(!length(listeners)) + return + next_distress = world.time + rand(SURVIVOR_DISTRESS_GAP_LOW, SURVIVOR_DISTRESS_GAP_HIGH) + var/list/lines = get_lines("distress") + if(!length(lines)) + return + var/line = fill_line(pick(lines)) + for(var/mob/living/person as anything in listeners) + to_chat(person, span_radio("\[Distress\] [real_name] says, \"[line]\"")) + person.playsound_local(get_turf(person), 'sound/misc/interference.ogg', 20, FALSE) + +/** + * Their hiding activity's tick: up on their feet when someone is right there, down again when + * they are alone; a plea to whoever is close; otherwise a fidget now and then. + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/hide_tick() + var/turf/here = get_turf(src) + if(!here) + return + if(!isturf(loc)) + return // shut in somewhere, keeping quiet + var/mob/living/near = nearest_person(here, SURVIVOR_NEAR_RANGE) + var/scared = world.time - last_threat_at < 5 SECONDS + if(near && !scared) + if(crouching) + stand_up() + if(!buckled) + face_atom(near) + if(reaction_ready("plead", 40 SECONDS)) + speak_context(rescued ? "wait_idle" : "plead", near, force = TRUE) + return + if(!near && !crouching && !buckled) + crouch() + if(world.time < next_fidget) + return + next_fidget = world.time + rand(40 SECONDS, 80 SECONDS) + if(prob(40)) + speak_context(rescued ? "wait_idle" : "hide", null, force = TRUE) + return + manual_emote(pick( + "hugs [p_their()] knees.", + "shivers.", + "taps at the beacon on [p_their()] wrist.", + "listens, very still.", + "rocks back and forth.", + )) + +/** + * Where to run from `threat`: a free tile within SURVIVOR_FLEE_RANGE, further from it than they are, + * on their own side of it (so the way there doesn't pass it), in sight from where they stand (so + * the way there is short), best out of its sight with a wall at their back. Null if nowhere. + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/flee_tile(mob/living/threat, list/avoid) + var/turf/here = get_turf(src) + var/turf/danger = get_turf(threat) + if(!here || !danger || here.z != danger.z) + return null + var/start_gap = get_dist(here, danger) + var/turf/best + var/best_score = -INFINITY + for(var/turf/tile as anything in RANGE_TURFS(SURVIVOR_FLEE_RANGE, here)) + var/gap = get_dist(tile, danger) + if(gap < start_gap + 2 || get_dist(tile, here) >= gap) + continue + if(!standable(tile, avoid) || !can_see(here, tile, SURVIVOR_FLEE_RANGE + 1)) + continue + var/score = gap + rand(0, 3) + if(!can_see(danger, tile, SURVIVOR_SIGHT + 2)) + score += 4 + if(ambient_backed_by_wall_or_table(tile)) + score += 1 + if(score > best_score) + best = tile + best_score = score + return best + +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/react_attacked(atom/attacker) + if(stat != CONSCIOUS || fading || beaming_out || !reaction_ready("attacked", 4 SECONDS)) + return + var/mob/living/hitter = isliving(attacker) ? attacker : null + speak_context(hitter?.client ? "hurt_by_person" : "hurt", attacker, force = TRUE) + if(is_following()) + if(hitter) + duck(hitter) + return + if(hitter) + start_activity(new /datum/ambient_activity/survivor_flee(src, hitter)) + +// ========================================================================= +// LEAVING: THE BEAM +// ========================================================================= + +/** + * Taken up from orbit: a column of light comes down on them, they lift and come apart in it, and + * they are gone. They are held still meanwhile. Somewhere nobody can see, they just go. + * `farewell` has them say goodbye first (delivered home). `force_visual` draws the beam even + * with nobody about (unit tests). + */ +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/beam_out(farewell = FALSE, force_visual = FALSE) + if(beaming_out || QDELETED(src)) + return + var/turf/spot = get_turf(src) + if(!spot || (!force_visual && !mission_survivor_watched(spot))) + beaming_out = TRUE + qdel(src) + return + var/was_awake = stat == CONSCIOUS && isturf(loc) + if(was_awake) + setDir(SOUTH) // face front, so the dissolve reads + if(farewell) + speak_context("goodbye", null, force = TRUE) + manual_emote("waves.") + else + manual_emote("looks up.") + beaming_out = TRUE + fading = TRUE + end_activity() + stand_up() + add_traits(list(TRAIT_AI_PAUSED, TRAIT_IMMOBILIZED, TRAIT_NO_FLOATING_ANIM), SURVIVOR_TRAIT) + pulledby?.stop_pulling() + stop_pulling() + buckled?.unbuckle_mob(src, force = TRUE) + set_anchored(TRUE) + move_resist = INFINITY + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + playsound(spot, 'sound/effects/magic/teleport_diss.ogg', 40, TRUE) + new /obj/effect/temp_visual/transporter_beam(spot, SURVIVOR_BEAM_TIME + 0.5 SECONDS) + addtimer(CALLBACK(src, PROC_REF(beam_dissolve)), SURVIVOR_BEAM_DROP) + addtimer(CALLBACK(src, PROC_REF(beam_gone)), SURVIVOR_BEAM_TIME) + +/// The column is down: they lift a little and come apart in it, head first +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/beam_dissolve() + if(!isturf(loc)) + return // shut in a locker: the column takes them through it + var/dissolve_time = SURVIVOR_BEAM_TIME - SURVIVOR_BEAM_DROP + new /obj/effect/abstract/particle_holder(src, /particles/transporter_motes, PARTICLE_ATTACH_MOB) + transporter_dematerialise(src, dissolve_time) + animate(src, pixel_z = pixel_z + 8, time = dissolve_time, easing = SINE_EASING | EASE_IN, flags = ANIMATION_PARALLEL) + +/// Gone: the last flash where they stood, and the column lifts back up without them +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/proc/beam_gone() + var/turf/spot = get_turf(src) + if(spot) + new /obj/effect/temp_visual/transporter_flash/departure(spot) + playsound(spot, 'sound/effects/magic/teleport_app.ogg', 50, TRUE) + qdel(src) + +/// Whether anyone with a client is close enough to `spot` to see a beam come down there +/proc/mission_survivor_watched(turf/spot) + for(var/mob/viewer in SSspatial_grid.orthogonal_range_search(spot, SPATIAL_GRID_CONTENTS_TYPE_CLIENTS, SURVIVOR_BEAM_WATCH_RANGE)) + if(!viewer.client) + continue + var/turf/there = get_turf(viewer) + if(there?.z == spot.z && get_dist(there, spot) <= SURVIVOR_BEAM_WATCH_RANGE) + return TRUE + return FALSE + +// ========================================================================= +// WHAT THEY SAY +// ========================================================================= + +// Their own lines only: none of the ambient core's chatter fits someone in this state +/mob/living/carbon/human/npc/ambient_npc/mission_survivor/get_lines(context) + var/static/list/lines = list( + // Hiding alone, under their breath + "hide" = list( + "#Come on. Somebody heard it.", + "#Stay quiet. Stay quiet.", + "#Please, please, please.", + "#Beacon's still on. It's still on.", + ), + // A threat about and nobody there + "cower" = list( + "#Don't see me. Don't see me.", + "#Go away. Please go away.", + "#Oh no. Oh no.", + ), + // A threat about, and people there + "warn" = list( + "Look out!", + "There's more of them!", + "Watch it, they're coming!", + ), + // First sight of someone + "call" = list( + "Over here!", + "Hey! Hey, over here!", + "Is someone there? Please!", + "Here! I'm over here!", + "You came. You actually came.", + ), + // First sound of someone, from a locker + "call_locker" = list( + "In here! I'm in here!", + "Is someone out there? Let me out!", + "Don't go! I'm in here!", + ), + // Let out of the locker + "freed" = list( + "Oh, thank god.", + "Thank you. Thank you.", + "I thought you were one of them.", + ), + // Someone right there, not taking them yet + "plead" = list( + "Please, get me out of here.", + "Are you taking me out? Please say yes.", + "Can we go? Please?", + ), + "flee" = list( + "No no no!", + "Get away from me!", + "Help! Help!", + "Somebody help!", + ), + "hurt" = list( + "Agh!", + "Ow! Help!", + "Please! Stop!", + ), + "hurt_by_person" = list( + "Hey! I'm on your side!", + "Ow! What was that for?", + "Watch where you're shooting!", + ), + "follow" = list( + "Right behind you.", + "Okay. Okay. Let's go.", + "Don't leave me behind.", + "Right behind you. Please don't be wrong about the way out.", + ), + "wait" = list( + "I'll... wait right here.", + "Don't be long.", + "Okay. I'll be here.", + ), + "refuse" = list( + "I'm with them.", + "No. I'm going with them.", + ), + // Following, now and then + "follow_idle" = list( + "Is your ship far?", + "I thought nobody was coming.", + "How long was I in there?", + "Thank you. Really.", + "Do you have any water?", + ), + // Following, and something is coming + "duck" = list( + "What was that?", + "Something's moving!", + "Don't let it near me!", + "Get down!", + ), + "lost" = list( + "Hello? Where'd you go?", + "Don't leave me here!", + "Hello?", + ), + "leader_down" = list( + "No. No, no, no.", + "Get up. Please, get up.", + ), + "trapped" = list( + "Let me out!", + "Hey! Open this!", + ), + "aboard" = list( + "Is this your ship? Oh, thank god.", + "A real ship. Lights and everything.", + ), + // Waiting where they were told, or near someone after being rescued + "wait_idle" = list( + "Is it much further?", + "I'll stay right here.", + "Are we leaving soon?", + ), + "goodbye" = list( + "Thank you. I mean it.", + "I owe you. All of you.", + "Thank you. Really.", + ), + // Over the radio, before anyone has found them + "distress" = list( + "Is anyone out there? Please.", + "This is {name}. I'm still here.", + "I can hear a ship. Please don't leave.", + "Hello? Anyone? Please.", + "Still here. Still here. Please.", + ), + ) + var/list/found = lines[context] + return islist(found) ? found : list() + +// ========================================================================= +// THEIR LOOK +// ========================================================================= + +/// What they have been living in: an orange emergency suit over their work clothes, helmet on and a tank of air +/datum/outfit/mission_survivor + name = "Rescue Survivor" + uniform = /obj/item/clothing/under/color/grey + suit = /obj/item/clothing/suit/space/fragile + head = /obj/item/clothing/head/helmet/space/fragile + mask = /obj/item/clothing/mask/breath + back = /obj/item/tank/internals/oxygen + shoes = /obj/item/clothing/shoes/workboots + internals_slot = ITEM_SLOT_BACK + +// ========================================================================= +// THEIR BRAIN +// ========================================================================= + +/// The ambient routine runner, with their senses in front of it. Unlike the rest of the ambient +/// core they never resist being pulled, carried, buckled or shut in: that is how a crew gets them out. +/datum/ai_controller/basic_controller/ambient_npc/mission_survivor + planning_subtrees = list( + /datum/ai_planning_subtree/mission_survivor_senses, + /datum/ai_planning_subtree/ambient_routine, + ) + // Awake while a crew is still a few screens off, for the distress call + interesting_dist = 24 + +/// Looks around and reacts; the routine subtree after it does the walking +/datum/ai_planning_subtree/mission_survivor_senses + +/datum/ai_planning_subtree/mission_survivor_senses/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = controller.pawn + if(istype(survivor) && controller.ai_status == AI_STATUS_ON) + survivor.look_around() + +// ========================================================================= +// WHAT THEY DO +// ========================================================================= + +/// Keeping their head down where they are told to stay, or where they last stopped +/datum/ambient_activity/survivor_hide + name = "hiding" + +/datum/ambient_activity/survivor_hide/setup() + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + var/turf/hide_at = istype(survivor) ? survivor.hide_spot : null + if(isturf(doer.loc) && hide_at && hide_at != doer.loc && hide_at.z == doer.z && get_dist(doer, hide_at) <= SURVIVOR_FOLLOW_RANGE && doer.standable(hide_at, failed_spots)) + go_to(hide_at) + return TRUE + +/datum/ambient_activity/survivor_hide/act(seconds) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + if(istype(survivor)) + survivor.hide_tick() + return AMBIENT_STEP_CONTINUE + +/datum/ambient_activity/survivor_hide/spot_unreachable() + . = ..() + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + if(istype(survivor)) + survivor.hide_spot = get_turf(doer) + +/// Calling out to someone they spotted, waving, and coming over if it is safe; from a locker, banging on it +/datum/ambient_activity/survivor_call + name = "calling out" + priority = AMBIENT_PRIORITY_REACTION + duration_low = 15 SECONDS + duration_high = 20 SECONDS + +/datum/ambient_activity/survivor_call/setup() + var/mob/living/person = anchor() + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + if(!isliving(person) || !istype(survivor)) + return FALSE + set_duration() + if(istype(doer.loc, /obj/structure/closet)) + survivor.bang_on(doer.loc) + doer.speak_context("call_locker", person, force = TRUE) + return TRUE + doer.stand_up() + doer.face_atom(person) + doer.manual_emote(pick("waves both arms.", "waves.", "waves weakly.")) + doer.speak_context("call", person, force = TRUE) + var/distance = get_dist(doer, person) + if(distance > 2 && distance <= SURVIVOR_APPROACH_RANGE) + go_to(get_turf(person), 2) + return TRUE + +/datum/ambient_activity/survivor_call/act(seconds) + var/mob/living/person = anchor() + var/turf/there = get_turf(person) + if(!person || person.stat == DEAD || there?.z != doer.z) + return AMBIENT_STEP_DONE + var/obj/structure/closet/container = doer.loc + if(istype(container)) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + // Right outside: they push it open themselves + if(get_dist(container, person) <= 1 && container.open()) + return AMBIENT_STEP_DONE + if(istype(survivor) && survivor.reaction_ready("bang", 6 SECONDS)) + survivor.bang_on(container) + return AMBIENT_STEP_CONTINUE + if(spot && get_dist(doer, person) > 2) + if(LAZYACCESS(failed_spots, there)) + return AMBIENT_STEP_DONE + go_to(there, 2) + return AMBIENT_STEP_MOVE + if(!doer.buckled) + doer.face_atom(person) + return AMBIENT_STEP_DONE + +/datum/ambient_activity/survivor_call/finish() + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + if(istype(survivor) && isturf(survivor.loc)) + survivor.hide_spot = survivor.loc + return ..() + +/// Running from something, then down in a crouch wherever they got to +/datum/ambient_activity/survivor_flee + name = "running" + priority = SURVIVOR_FLEE_PRIORITY + /// How many more times a threat that keeps coming can send them on + var/runs_left = SURVIVOR_FLEE_RUNS + +/datum/ambient_activity/survivor_flee/setup() + var/mob/living/threat = anchor() + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + if(!isliving(threat) || !istype(survivor)) + return FALSE + ends_at = world.time + SURVIVOR_FLEE_TIME + doer.set_pace(running = TRUE) + if(survivor.reaction_ready("flee_line", 6 SECONDS)) + doer.speak_context("flee", threat, force = TRUE) + var/turf/away = isturf(doer.loc) ? survivor.flee_tile(threat, failed_spots) : null + if(away) + doer.stand_up() + go_to(away) + else + // Nowhere to go: down, arms over their head + doer.crouch() + return TRUE + +/datum/ambient_activity/survivor_flee/arrive() + doer.crouch() + +/datum/ambient_activity/survivor_flee/act(seconds) + var/mob/living/threat = anchor() + if(!threat || threat.stat != CONSCIOUS) + return AMBIENT_STEP_DONE + if(runs_left > 0 && get_dist(doer, threat) <= 2 && isturf(doer.loc)) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + var/turf/away = survivor.flee_tile(threat, failed_spots) + if(away) + runs_left-- + doer.stand_up() + go_to(away) + return AMBIENT_STEP_MOVE + return AMBIENT_STEP_CONTINUE + +/datum/ambient_activity/survivor_flee/finish() + if(!QDELETED(doer)) + doer.set_pace(running = FALSE) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + if(istype(survivor) && isturf(survivor.loc)) + survivor.hide_spot = survivor.loc + return ..() + +/// At their rescuer's side as they move, facing them when they stop; out of anything they get shut in +/datum/ambient_activity/survivor_follow + name = "following" + priority = SURVIVOR_FOLLOW_PRIORITY + spot_distance = 1 + /// world.time their rescuer went out of reach, or 0 + var/lost_since = 0 + /// They called out for their rescuer since losing them + var/called_lost = FALSE + +/datum/ambient_activity/survivor_follow/setup() + if(!isliving(anchor())) + return FALSE + next_line = world.time + rand(40 SECONDS, 80 SECONDS) + // They keep up with whoever is getting them out + doer.set_pace(running = TRUE) + return TRUE + +/datum/ambient_activity/survivor_follow/finish() + if(!QDELETED(doer)) + doer.set_pace(running = FALSE) + return ..() + +/// Whether `leader` can still be followed: alive, on this level, near enough +/datum/ambient_activity/survivor_follow/proc/in_reach(mob/living/leader) + var/turf/there = get_turf(leader) + var/turf/here = get_turf(doer) + return leader && leader.stat != DEAD && there && here && there.z == here.z && get_dist(here, there) <= SURVIVOR_FOLLOW_RANGE + +// Where they go is wherever their rescuer is now +/datum/ambient_activity/survivor_follow/at_spot() + if(!isturf(doer.loc)) + return TRUE // act() gets them out first + var/mob/living/leader = anchor() + if(!in_reach(leader) || get_dist(doer, leader) <= 1) + return TRUE + if(doer.crouching) + doer.stand_up() + var/turf/there = get_turf(leader) + if(spot != there) + go_to(there, 1) + return FALSE + +/datum/ambient_activity/survivor_follow/act(seconds) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/survivor = doer + if(!istype(survivor)) + return AMBIENT_STEP_DONE + if(!isturf(doer.loc)) + survivor.climb_out() + return AMBIENT_STEP_CONTINUE + var/mob/living/leader = anchor() + if(leader?.stat == DEAD && get_dist(doer, leader) <= SURVIVOR_SIGHT) + survivor.leader_fell(leader) + return AMBIENT_STEP_DONE + if(!in_reach(leader)) + if(!lost_since) + lost_since = world.time + if(!called_lost && world.time - lost_since > 8 SECONDS) + called_lost = TRUE + doer.speak_context("lost", null, force = TRUE) + if(world.time - lost_since >= SURVIVOR_LOST_TIME) + survivor.lose_leader() + return AMBIENT_STEP_DONE + return AMBIENT_STEP_CONTINUE + lost_since = 0 + called_lost = FALSE + if(get_dist(doer, leader) <= 2 && !doer.buckled) + doer.face_atom(leader) + survivor.check_aboard() + chatter("follow_idle", 60 SECONDS, 120 SECONDS) + return AMBIENT_STEP_CONTINUE + +// A spot they could not reach is just their rescuer's last one: they try again from where they are +/datum/ambient_activity/survivor_follow/spot_unreachable() + spot = null + arrived = FALSE + +// ========================================================================= +// WHERE THEY HIDE +// ========================================================================= + +/** + * Where a survivor hides at `target`, looking around `near` (the site's spawn point): list(turf, + * locker or null). Half the time a locker if there is one (they get in it), otherwise a corner or + * an alcove, never beside open space or on a docked ship, and never within + * SURVIVOR_SHELTER_THREAT_GAP of anything hostile already loose in there. Falls back to `near`. + * + * Bounded (a square of SURVIVOR_SHELTER_RADIUS around `near`) and never sleeps: it runs from the + * site's loaded signal. + */ +/proc/mission_survivor_hiding_place(turf/near, datum/mission_target/target) + . = list(near, null) + if(!near || !target) + return + var/list/dangers = list() + for(var/mob/living/thing as anything in GLOB.mob_living_list) + if(thing.z != near.z || thing.stat == DEAD || thing.client) + continue + if(get_dist(thing, near) > SURVIVOR_SHELTER_RADIUS + SURVIVOR_SHELTER_THREAT_GAP) + continue + if(FACTION_NEUTRAL in thing.faction) + continue + if(mission_survivor_dangerous(thing)) + dangers += get_turf(thing) + var/list/lockers = list() + var/list/nooks = list() + var/best_cover = 0 + for(var/turf/open/tile in RANGE_TURFS(SURVIVOR_SHELTER_RADIUS, near)) + if(isspaceturf(tile) || isgroundlessturf(tile) || islava(tile) || ischasm(tile)) + continue + if(istype(tile.loc, /area/shuttle) || !target.contains_turf(tile)) + continue + if(length(dangers) && ambient_too_close(tile, dangers, SURVIVOR_SHELTER_THREAT_GAP)) + continue + var/obj/structure/closet/locker = locate() in tile + if(locker) + if(mission_survivor_locker_ok(locker)) + lockers += locker + continue + if(tile.is_blocked_turf(exclude_mobs = TRUE)) + continue + var/cover = mission_survivor_cover(tile) + if(cover < SURVIVOR_SHELTER_MIN_COVER) + continue + nooks[tile] = cover + best_cover = max(best_cover, cover) + if(length(lockers) && (prob(50) || !length(nooks))) + var/obj/structure/closet/locker = pick(lockers) + return list(get_turf(locker), locker) + if(!length(nooks)) + return + // The snuggest spots, not always the single snuggest one + var/list/best = list() + for(var/turf/tile as anything in nooks) + if(nooks[tile] >= best_cover - 1) + best += tile + return list(pick(best), null) + +/// Neighbours (of 8) of `tile` that are walls or blocked, or 0 if it opens onto space or has no free way in +/proc/mission_survivor_cover(turf/tile) + var/blocked = 0 + var/way_in = FALSE + for(var/direction in GLOB.alldirs) + var/turf/neighbour = get_step(tile, direction) + if(!neighbour || isspaceturf(neighbour) || isgroundlessturf(neighbour)) + return 0 + if(neighbour.is_blocked_turf(exclude_mobs = TRUE)) + blocked++ + else if(direction in GLOB.cardinals) + way_in = TRUE + return way_in ? blocked : 0 + +/// A locker a survivor can shut themselves in, and that someone can get to and open +/proc/mission_survivor_locker_ok(obj/structure/closet/locker) + if(locker.locked || locker.welded || locker.wall_mounted || locker.horizontal) + return FALSE + if(istype(locker, /obj/structure/closet/body_bag) || (locker.resistance_flags & INDESTRUCTIBLE)) + return FALSE + if(locker.max_mob_size < MOB_SIZE_HUMAN || locker.mob_storage_capacity < 1 || (locate(/mob/living) in locker)) + return FALSE + if(locker.opened && !locker.can_close()) + return FALSE + for(var/direction in GLOB.cardinals) + var/turf/neighbour = get_step(locker, direction) + if(neighbour && !isspaceturf(neighbour) && !neighbour.is_blocked_turf(exclude_mobs = TRUE)) + return TRUE + return FALSE + +/** + * Whether `thing` is out to hurt people: a hostile legacy animal, or a mob whose AI picks targets. + * Faction is the caller's business. + */ +/proc/mission_survivor_dangerous(mob/living/thing) + if(istype(thing, /mob/living/simple_animal/hostile)) + return TRUE + return !!thing.ai_controller?.blackboard[BB_TARGETING_STRATEGY] + +#undef SURVIVOR_SIGHT +#undef SURVIVOR_LOOK_INTERVAL +#undef SURVIVOR_FLEE_DISTANCE +#undef SURVIVOR_FLEE_RANGE +#undef SURVIVOR_FLEE_TIME +#undef SURVIVOR_FLEE_RUNS +#undef SURVIVOR_DISTRESS_RANGE +#undef SURVIVOR_DISTRESS_GAP_LOW +#undef SURVIVOR_DISTRESS_GAP_HIGH +#undef SURVIVOR_APPROACH_RANGE +#undef SURVIVOR_NEAR_RANGE +#undef SURVIVOR_HEARING_RANGE +#undef SURVIVOR_FOLLOW_RANGE +#undef SURVIVOR_LOST_TIME +#undef SURVIVOR_FOLLOW_PRIORITY +#undef SURVIVOR_FLEE_PRIORITY +#undef SURVIVOR_DUCK_TIME +#undef SURVIVOR_DUCK_COOLDOWN +#undef SURVIVOR_SHELTER_RADIUS +#undef SURVIVOR_SHELTER_THREAT_GAP +#undef SURVIVOR_SHELTER_MIN_COVER +#undef SURVIVOR_BEAM_TIME +#undef SURVIVOR_BEAM_DROP +#undef SURVIVOR_BEAM_WATCH_RANGE +#undef SURVIVOR_TRAIT diff --git a/voidcrew/modules/missions/objectives/site_ops.dm b/voidcrew/modules/missions/objectives/site_ops.dm index ca946692ed3..519e75acb19 100644 --- a/voidcrew/modules/missions/objectives/site_ops.dm +++ b/voidcrew/modules/missions/objectives/site_ops.dm @@ -18,12 +18,15 @@ /datum/mission_objective/field/plant_quest /// The quest item type planted at the site var/quest_item_type = /obj/item/mission_recovery + /// Set dressing laid around the item (a /datum/mission_scene path, null for none) + var/scene_type = /datum/mission_scene/dropped_case /datum/mission_objective/field/plant_quest/spawn_field_objects(turf/spawn_turf) var/obj/item/mission_recovery/quest_item = new quest_item_type(spawn_turf) quest_item.name = mission.objective_name mission.bind_item(quest_item) mission.register_quest_atom(quest_item) + dress_mission_scene(scene_type, spawn_turf, mission.target) complete() /datum/mission_objective/field/plant_quest/get_progress_string() @@ -91,23 +94,30 @@ /datum/mission_objective/field/pylon_chain/proc/pick_spawn_spots(turf/anchor) var/list/spots = list(anchor) var/datum/mission_target/target = mission?.target + // Out of sight first; ground a crew can see is only used if the rest can't hold the set + var/datum/spawn_cover/cover = new(anchor.z) var/list/candidates = list() + var/list/in_view = list() for(var/turf/open/tile in RANGE_TURFS(PYLON_SCATTER_RADIUS, anchor)) if(isspaceturf(tile) || tile.is_blocked_turf(exclude_mobs = TRUE)) continue if(target && !target.contains_turf(tile)) continue - candidates += tile - while(length(spots) < points_total && length(candidates)) - var/turf/candidate = pick_n_take(candidates) - var/too_close = FALSE - for(var/turf/taken as anything in spots) - if(get_dist(candidate, taken) < PYLON_MIN_SPACING) - too_close = TRUE - break - if(too_close) - continue - spots += candidate + if(cover.is_hidden(tile)) + candidates += tile + else + in_view += tile + for(var/list/pool as anything in list(candidates, in_view)) + while(length(spots) < points_total && length(pool)) + var/turf/candidate = pick_n_take(pool) + var/too_close = FALSE + for(var/turf/taken as anything in spots) + if(get_dist(candidate, taken) < PYLON_MIN_SPACING) + too_close = TRUE + break + if(too_close) + continue + spots += candidate // Cramped site: take whatever's open rather than hand back a short set while(length(spots) < points_total) spots += get_nearby_open_turf(anchor, 3) @@ -121,6 +131,7 @@ pylon.name = "survey pylon [length(pylons) + 1] of [points_total]" pylon.objective_ref = WEAKREF(src) pylons += pylon + dress_mission_scene(/datum/mission_scene/pylon_drop, spawn_turf, mission?.target) /// The first pylon still waiting on calibration /datum/mission_objective/field/pylon_chain/proc/next_pylon() @@ -299,7 +310,7 @@ */ /datum/mission_objective/field/escort /// The survivor mob type - var/survivor_type = /mob/living/carbon/human/npc/mission_survivor + var/survivor_type = /mob/living/carbon/human/npc/ambient_npc/mission_survivor /// The live survivor var/mob/living/survivor /// Health fraction at turn-in for the "still walking" pay bonus @@ -341,6 +352,9 @@ * * The successful turn-in has already nulled the ref by the time deactivation * runs, so a repatriated survivor never reaches this. + * + * Whoever is watching sees them taken up from orbit in a column of light + * (beam_out()); this is usually aboard the crew's own ship, mid-escort. */ /datum/mission_objective/field/escort/proc/release_survivor() clear_grace() @@ -349,11 +363,20 @@ if(QDELETED(leaving)) return UnregisterSignal(leaving, list(COMSIG_LIVING_DEATH, COMSIG_LIVING_REVIVE)) - leaving.visible_message(span_notice("[leaving]'s beacon chirps, and they are teleported away.")) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/person = leaving + if(istype(person)) + person.beam_out() + return qdel(leaving) +/// The survivor goes somewhere sheltered in the site (a locker, a corner), not just any open tile /datum/mission_objective/field/escort/spawn_field_objects(turf/spawn_turf) - survivor = new survivor_type(spawn_turf) + var/list/hiding_place = mission_survivor_hiding_place(spawn_turf, mission?.target) + survivor = new survivor_type(hiding_place[1] || spawn_turf) + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/person = survivor + if(istype(person)) + person.join_contract(mission) + person.take_shelter(hiding_place[2]) protect_field_mob(survivor) RegisterSignal(survivor, COMSIG_LIVING_DEATH, PROC_REF(on_survivor_death)) RegisterSignal(survivor, COMSIG_LIVING_REVIVE, PROC_REF(on_survivor_revived)) @@ -444,14 +467,17 @@ if(!was_revived && survivor.health >= survivor.maxHealth * unharmed_threshold) mission.value *= unharmed_bonus notify_crew("Survivor recovered unharmed.") - // Repatriation: they step onto the pad and ship out + // Repatriation: a goodbye, and the beam takes them home from beside the pad var/mob/living/leaving = survivor UnregisterSignal(leaving, list(COMSIG_LIVING_DEATH, COMSIG_LIVING_REVIVE)) survivor = null - leaving.visible_message(span_notice("[leaving] waves goodbye and is teleported out.")) if(istype(reward_anchor, /obj/machinery/mission_pad)) var/obj/machinery/mission_pad/pad = reward_anchor pad.do_teleport_effect() + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/person = leaving + if(istype(person)) + person.beam_out(farewell = TRUE) + return qdel(leaving) /datum/mission_objective/field/escort/get_progress_string() @@ -470,20 +496,28 @@ /** * The prospect-stake centerpiece: a claim beacon kit is dispensed at accept; - * deploying it (only with the ship holding at the target coordinates) files - * the claim on Wideband - everyone hears - and starts a defend clock that - * only runs while the ship stays on station. The beacon survives, it prints - * the deed; the beacon dies, the contract dies with it. + * deploying it on the site's open ground (the kit decides where) files the + * claim on Wideband - everyone hears - and starts a defend clock that only + * runs while a crew member stands guard at the beacon. Waves come on that + * clock, not the wall clock, so stepping away never calls extra company. The + * beacon survives, it prints the deed; the beacon dies, the contract dies + * with it. */ /datum/mission_objective/claim_defense /// How long the beacon must survive after deployment var/defend_duration = 8 MINUTES /// Seconds of defense remaining (set on deploy) var/defend_remaining = 0 - /// How far (overmap tiles) the ship may drift from the stake coordinates - var/hold_range = 2 - /// Interval between defender waves while the clock runs + /// How close (tiles) a crew member must stand to the beacon for the clock to run + var/guard_range = 7 + /// A guard idle at the keyboard this long stops counting + var/guard_afk_time = 3 MINUTES + /// Guarded time before the first defender wave + var/first_wave_delay = 1 MINUTES + /// Guarded time between defender waves var/wave_interval = 2 MINUTES + /// Seconds of guarded time left until the next wave + var/wave_countdown = 0 /// zone_mobs theme answering the claim (set by the mission) var/wave_theme /// The kit handed over at accept @@ -492,6 +526,10 @@ var/obj/structure/mission_claim_beacon/beacon /// Whether the deed has printed (beacon survived) var/deed_printed = FALSE + /// Whether the last tick found nobody standing guard + var/unguarded = FALSE + /// Throttle for the unattended-beacon notice + COOLDOWN_DECLARE(unguarded_notice_cooldown) /datum/mission_objective/claim_defense/deactivate() if(beacon) @@ -516,19 +554,33 @@ mission.fail("No mission pad to dispense the claim beacon to.") return FALSE kit = new(kit_turf) + mission_pad_delivery_effect(kit_turf) kit.objective_ref = WEAKREF(src) notify_crew("Claim beacon kit delivered.") return TRUE -/// Whether the ship is close enough to the stake coordinates to count -/datum/mission_objective/claim_defense/proc/ship_on_station() +/** + * Whether a crew member is standing guard: alive, awake, at the keyboard, out + * on the site's ground rather than inside a hull, and within guard_range of + * the beacon. Nobody there, no clock. + */ +/datum/mission_objective/claim_defense/proc/is_guarded() var/obj/structure/overmap/ship/ship = get_servant() - var/datum/mission_target/target = mission?.target - if(!ship || !target) + var/datum/team/crew_team = ship?.ship_team + var/turf/beacon_turf = get_turf(beacon) + if(!crew_team || !beacon_turf) return FALSE - var/rel_x = ship.x - var/rel_y = ship.y - OVERMAP_SOUTH_SIDE_COORD + 1 - return sqrt((rel_x - target.target_x) ** 2 + (rel_y - target.target_y) ** 2) <= hold_range + for(var/datum/mind/member as anything in crew_team.members) + var/mob/living/guard = member?.current + if(!istype(guard) || guard.stat >= UNCONSCIOUS || !guard.client || guard.client.is_afk(guard_afk_time)) + continue + var/turf/guard_turf = get_turf(guard) + if(!guard_turf || guard_turf.z != beacon_turf.z || get_dist(guard_turf, beacon_turf) > guard_range) + continue + if(istype(get_area(guard_turf), /area/shuttle) || !mission.target?.contains_turf(guard_turf)) + continue + return TRUE + return FALSE /// The kit was used in hand and the channel finished: raise the beacon /datum/mission_objective/claim_defense/proc/deploy(mob/living/user, turf/where) @@ -537,26 +589,38 @@ beacon = new(where) beacon.objective_ref = WEAKREF(src) QDEL_NULL(kit) + unguarded = FALSE + wave_countdown = first_wave_delay / 10 var/datum/mission_target/target = mission.target - beacon.file_claim("Prospect filing: mineral-rights claim staked at grid [target.target_x], [target.target_y]. Claim matures in [round(defend_duration / (1 MINUTES))] minutes. All counterclaims settled on-site.") + var/datum/mission_target/planet/site = target + var/site_name = istype(site) ? site.planet?.name : null + beacon.file_claim("Prospect filing: mineral-rights claim staked[site_name ? " on [site_name]" : ""] at grid [target.target_x], [target.target_y]. All counterclaims settled on-site.") notify_crew("Claim filed on Wideband.", type = SHIP_NOTIFY_WARNING) -/// One second of defending, ticked by the beacon's process +/// One tick of defending, from the beacon's process /datum/mission_objective/claim_defense/proc/tick_defense(seconds) if(deed_printed || !active || !beacon) return - if(!ship_on_station()) - beacon.show_offstation_warning() + if(!is_guarded()) + if(!unguarded && COOLDOWN_FINISHED(src, unguarded_notice_cooldown)) + COOLDOWN_START(src, unguarded_notice_cooldown, 1 MINUTES) + notify_crew("Claim beacon unattended.", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') + unguarded = TRUE return + unguarded = FALSE defend_remaining -= seconds if(defend_remaining <= 0) print_deed() return - // 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), TRUE) - notify_crew("Claim jumpers inbound on the beacon!", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') + // Periodic company, counted in guarded time + if(!wave_theme) + return + wave_countdown -= seconds + if(wave_countdown > 0) + return + wave_countdown += wave_interval / 10 + 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 /datum/mission_objective/claim_defense/proc/print_deed() @@ -578,14 +642,19 @@ beacon = null if(deed_printed || !mission || mission.failed || mission.completed) return + // Left alone long enough for the site to empty out and be torn down + var/datum/mission_target/planet/site = mission.target + if(istype(site) && site.planet?.unloading) + mission.fail("Claim abandoned - the filing is void.") + return mission.fail("Claim beacon destroyed - the filing is void.") /datum/mission_objective/claim_defense/get_progress_string() if(deed_printed) return "Deed printed" if(beacon) - if(!ship_on_station()) - return "OFF STATION - claim clock paused" + if(unguarded) + return "Beacon unattended" return "Defend the beacon ([round(defend_remaining / 60)]:[add_leading(num2text(round(defend_remaining) % 60), 2, "0")])" var/datum/mission_target/target = mission?.target - return target ? "Deploy the beacon at ([target.target_x], [target.target_y])" : "Deploy the beacon" + return target ? "Stake the claim at ([target.target_x], [target.target_y])" : "Stake the claim" diff --git a/voidcrew/modules/missions/site_dressing.dm b/voidcrew/modules/missions/site_dressing.dm new file mode 100644 index 00000000000..75e6363f01a --- /dev/null +++ b/voidcrew/modules/missions/site_dressing.dm @@ -0,0 +1,375 @@ +/** + * # Mission Site Dressing + * + * A recovery item on its own is one sprite on a random tile: nothing on the site + * says anything happened there, and nothing draws the eye to it. A scene lays a + * little set dressing around the objective's anchor turf (a crater and wreckage + * for a crash, a dropped flare and some litter for a lost case) so the spot can be + * found by looking and reads like the job's story. + * + * Everything placed here is an /obj/effect: it can't be picked up, taken apart, + * broken for parts or sold. Footprint is the anchor plus up to two tiles around + * it, only on open, unblocked ground inside the site, never on another objective. + * The only lasting cost is a smoke emitter and a couple of lights, which burn out + * on one timer each; nothing processes. + */ + +/// How long a crash keeps smoking and a dropped flare keeps burning +#define MISSION_SCENE_BURN_TIME (15 MINUTES) + +/// Lays a scene around an objective's anchor turf. Null or a bad path does nothing. +/proc/dress_mission_scene(scene_type, turf/anchor, datum/mission_target/target) + if(!anchor || !ispath(scene_type, /datum/mission_scene)) + return + var/datum/mission_scene/scene = new scene_type + scene.dress(anchor, target) + +/datum/mission_scene + +/// Places the scene. The anchor holds the objective; only flat ground marks go on it. +/datum/mission_scene/proc/dress(turf/anchor, datum/mission_target/target) + return + +/// Whether one piece of dressing may go on this turf +/datum/mission_scene/proc/can_use(turf/tile, datum/mission_target/target) + var/static/list/objective_types = typecacheof(list( + /obj/item/mission_recovery, + /obj/structure/mission_survey_pylon, + /obj/structure/mission_claim_beacon, + /obj/structure/ingredient_cache, + /obj/item/drug_ingredient, + /obj/effect/anomaly, + /obj/effect/decal/mission_scene, + )) + if(!isopenturf(tile) || isspaceturf(tile) || isgroundlessturf(tile)) + return FALSE + if(tile.is_blocked_turf(exclude_mobs = TRUE)) + return FALSE + // A landed ship's floor flies off with whatever is on it + if(istype(get_area(tile), /area/shuttle)) + return FALSE + if(target && !target.contains_turf(tile)) + return FALSE + for(var/atom/movable/thing as anything in tile) + if(objective_types[thing.type]) + return FALSE + return TRUE + +/// Usable turfs within range of the anchor, the anchor itself excluded +/datum/mission_scene/proc/spots_around(turf/anchor, datum/mission_target/target, range = 1) + var/list/spots = list() + for(var/turf/tile as anything in RANGE_TURFS(range, anchor)) + if(tile != anchor && can_use(tile, target)) + spots += tile + return spots + +/** + * Puts one piece on a spot from the list, preferring one no other piece of this + * scene took. Returns the piece, or null when there was nowhere to put it. + */ +/datum/mission_scene/proc/place(piece_type, list/spots, list/taken) + if(!length(spots)) + return null + var/list/free = spots - taken + var/turf/spot = pick(length(free) ? free : spots) + taken += spot + return new piece_type(spot) + +// ========================================================================= +// CRASH: something came down hard (Field Expedition) +// ========================================================================= + +/datum/mission_scene/crash + +/datum/mission_scene/crash/dress(turf/anchor, datum/mission_target/target) + new /obj/effect/decal/mission_scene/scorch(anchor) + new /obj/effect/decal/mission_scene/scorch/core(anchor) + var/list/near = spots_around(anchor, target, 1) + var/list/far = spots_around(anchor, target, 2) - near + var/list/taken = list() + // The furrow it ploughed coming in, and the hull it shed at the end of it + var/skid_dir = pick_skid_dir(anchor, target) + if(skid_dir) + var/obj/effect/decal/mission_scene/skid/skid = new(anchor) + skid.point(skid_dir) + var/turf/beyond = get_step(anchor, REVERSE_DIR(skid_dir)) + if(beyond in near) + taken += beyond + new /obj/effect/decal/mission_scene/wreck(beyond) + else + place(/obj/effect/decal/mission_scene/wreck, near, taken) + else + place(/obj/effect/decal/mission_scene/wreck, near, taken) + place(/obj/effect/decal/mission_scene/wreck/dish, near, taken) + place(/obj/effect/decal/mission_scene/debris, near, taken) + place(/obj/effect/decal/mission_scene/debris/glass, near, taken) + place(/obj/effect/decal/mission_scene/debris, length(far) ? far : near, taken) + for(var/_ in 1 to 3) + place(/obj/effect/decal/mission_scene/debris/rubble, length(far) ? far : near, taken) + +/// A direction with two clear tiles for the furrow, or null +/datum/mission_scene/crash/proc/pick_skid_dir(turf/anchor, datum/mission_target/target) + for(var/direction in shuffle(GLOB.alldirs)) + var/turf/first = get_step(anchor, direction) + var/turf/second = first && get_step(first, direction) + if(second && can_use(first, target) && can_use(second, target)) + return direction + return null + +// ========================================================================= +// DROPPED CASE: somebody lost it here and lit a flare (recovery) +// ========================================================================= + +/datum/mission_scene/dropped_case + +/datum/mission_scene/dropped_case/dress(turf/anchor, datum/mission_target/target) + new /obj/effect/decal/mission_scene/scorch/scuff(anchor) + var/list/near = spots_around(anchor, target, 1) + var/list/taken = list() + place(/obj/effect/decal/mission_scene/flare, near, taken) + place(/obj/effect/decal/mission_scene/debris/glass, near, taken) + place(/obj/effect/decal/mission_scene/debris, near, taken) + +// ========================================================================= +// CARGO WRECK: the crate it came in, broken open (extraction) +// ========================================================================= + +/datum/mission_scene/cargo_wreck + +/datum/mission_scene/cargo_wreck/dress(turf/anchor, datum/mission_target/target) + new /obj/effect/decal/mission_scene/scorch/scuff(anchor) + var/list/near = spots_around(anchor, target, 1) + var/list/taken = list() + place(/obj/effect/decal/mission_scene/crate, near, taken) + place(/obj/effect/decal/mission_scene/flare, near, taken) + place(/obj/effect/decal/mission_scene/debris, near, taken) + place(/obj/effect/decal/mission_scene/debris/glass, near, taken) + +// ========================================================================= +// PYLON DROP: a survey pylon landed from orbit (survey, core sample) +// ========================================================================= + +/datum/mission_scene/pylon_drop + +/datum/mission_scene/pylon_drop/dress(turf/anchor, datum/mission_target/target) + new /obj/effect/decal/mission_scene/scorch/pylon(anchor) + var/list/near = spots_around(anchor, target, 1) + var/list/taken = list() + for(var/_ in 1 to 2) + place(/obj/effect/decal/mission_scene/debris/rubble, near, taken) + +// ========================================================================= +// THE PIECES +// ========================================================================= + +/// Set dressing. An effect, so it gives nothing when attacked, wrenched or blown up. +/obj/effect/decal/mission_scene + name = "wreckage" + desc = "Torn plating and burnt wiring." + icon = 'icons/mob/silicon/robots.dmi' + icon_state = "gib1" + plane = GAME_PLANE + layer = LOW_OBJ_LAYER + /// Icon states picked from at random, if any + var/list/random_states + /// Largest random pixel nudge either way + var/jitter = 6 + +/obj/effect/decal/mission_scene/Initialize(mapload) + . = ..() + if(length(random_states)) + icon_state = pick(random_states) + if(jitter) + pixel_x = base_pixel_x + rand(-jitter, jitter) + pixel_y = base_pixel_y + rand(-jitter, jitter) + +/// Scraps of hull and wiring +/obj/effect/decal/mission_scene/debris + random_states = list("gib1", "gib2", "gib3", "gib4", "gib5", "gib6") + +/obj/effect/decal/mission_scene/debris/glass + name = "broken glass" + desc = "Glittering shards from a shattered panel." + icon = 'icons/obj/debris.dmi' + icon_state = "tiny" + random_states = list("tiny", "small") + +/obj/effect/decal/mission_scene/debris/glass/Initialize(mapload) + . = ..() + setDir(pick(GLOB.cardinals)) + +/obj/effect/decal/mission_scene/debris/rubble + name = "rubble" + desc = "Loose chunks thrown clear by the impact." + icon = 'icons/obj/debris.dmi' + icon_state = "rubble" + random_states = null + +/// The burn at the center. Wide and soft; the core darkens the middle off-center. +/obj/effect/decal/mission_scene/scorch + name = "scorched ground" + desc = "Blackened and still warm." + icon = 'icons/effects/light_overlays/light_96.dmi' + icon_state = "light" + color = "#1e1610" + alpha = 170 + plane = FLOOR_PLANE + layer = ABOVE_OPEN_TURF_LAYER + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + blocks_emissive = EMISSIVE_BLOCK_NONE + jitter = 4 + SET_BASE_PIXEL(-32, -32) + /// Horizontal and vertical stretch of the sprite + var/spread_x = 0.95 + var/spread_y = 0.8 + +/obj/effect/decal/mission_scene/scorch/Initialize(mapload) + . = ..() + var/matrix/shape = matrix() + shape.Scale(spread_x, spread_y) + shape.Turn(rand(0, 179)) + transform = shape + +/obj/effect/decal/mission_scene/scorch/core + icon = 'icons/effects/light_overlays/light_64.dmi' + color = "#120c08" + alpha = 150 + jitter = 6 + SET_BASE_PIXEL(-16, -16) + spread_x = 0.6 + spread_y = 0.7 + +/// A light scuff where something heavy hit the deck +/obj/effect/decal/mission_scene/scorch/scuff + name = "scuff marks" + color = "#2a2420" + alpha = 110 + jitter = 0 + spread_x = 0.6 + spread_y = 0.6 + +/obj/effect/decal/mission_scene/scorch/pylon + alpha = 160 + jitter = 0 + spread_x = 0.7 + spread_y = 0.7 + +/// The furrow a crash ploughs: a long soft smudge pointed away from the anchor +/obj/effect/decal/mission_scene/skid + name = "furrow" + desc = "A long gouge in the ground." + icon = 'icons/effects/light_overlays/light_96.dmi' + icon_state = "light" + color = "#1a130d" + alpha = 150 + plane = FLOOR_PLANE + layer = ABOVE_OPEN_TURF_LAYER + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + blocks_emissive = EMISSIVE_BLOCK_NONE + jitter = 0 + SET_BASE_PIXEL(-32, -32) + +/// Lays the furrow out from the anchor toward direction +/obj/effect/decal/mission_scene/skid/proc/point(direction) + var/matrix/shape = matrix() + shape.Scale(ISDIAGONALDIR(direction) ? 1.2 : 0.9, 0.38) + shape.Turn(dir2angle(direction) - 90) + transform = shape + var/dx = (direction & EAST) ? 1 : ((direction & WEST) ? -1 : 0) + var/dy = (direction & NORTH) ? 1 : ((direction & SOUTH) ? -1 : 0) + pixel_x = base_pixel_x + dx * 44 + pixel_y = base_pixel_y + dy * 44 + +/// The biggest piece of what came down, smoking until it burns out +/obj/effect/decal/mission_scene/wreck + name = "smoking wreckage" + desc = "A buckled hull section, still smoking." + icon = 'icons/obj/fluff/general.dmi' + icon_state = "broken_canister" + color = "#8a8078" + layer = BELOW_OBJ_LAYER + jitter = 4 + light_range = 2 + light_power = 0.8 + light_color = LIGHT_COLOR_FIRE + /// Whether this piece puts up the smoke column + var/smokes = TRUE + +/obj/effect/decal/mission_scene/wreck/Initialize(mapload) + . = ..() + if(smokes) + particles = new /particles/smoke/mission_plume + addtimer(CALLBACK(src, PROC_REF(burn_out)), MISSION_SCENE_BURN_TIME, TIMER_DELETE_ME) + +/obj/effect/decal/mission_scene/wreck/Destroy(force) + QDEL_NULL(particles) + return ..() + +/obj/effect/decal/mission_scene/wreck/proc/burn_out() + QDEL_NULL(particles) + set_light(0) + name = "wreckage" + desc = "A buckled hull section, scorched black." + +/obj/effect/decal/mission_scene/wreck/dish + name = "bent antenna dish" + desc = "Snapped off its mount on the way down." + icon_state = "sat_dish" + color = "#a09890" + light_range = 0 + smokes = FALSE + +/obj/effect/decal/mission_scene/wreck/dish/Initialize(mapload) + . = ..() + setDir(pick(GLOB.cardinals)) + transform = transform.Turn(pick(-70, 70, 110, -110)) + +/// The crate the cargo came in +/obj/effect/decal/mission_scene/crate + name = "smashed crate" + desc = "Split open and empty." + icon = 'icons/obj/storage/crates.dmi' + icon_state = "crateopen" + color = "#8a8078" + layer = BELOW_OBJ_LAYER + jitter = 3 + +/obj/effect/decal/mission_scene/crate/Initialize(mapload) + . = ..() + transform = transform.Turn(rand(-20, 20)) + +/// Somebody lit it to mark the spot +/obj/effect/decal/mission_scene/flare + name = "flare" + desc = "A road flare, burning low." + icon = 'icons/obj/lighting.dmi' + icon_state = "flare-on" + light_range = 3 + light_power = 1 + light_color = LIGHT_COLOR_FLARE + +/obj/effect/decal/mission_scene/flare/Initialize(mapload) + . = ..() + transform = transform.Turn(rand(0, 359)) + addtimer(CALLBACK(src, PROC_REF(burn_out)), MISSION_SCENE_BURN_TIME, TIMER_DELETE_ME) + +/obj/effect/decal/mission_scene/flare/proc/burn_out() + set_light(0) + icon_state = "flare-empty" + name = "spent flare" + desc = "Burnt down to the stub." + +/// A tall, slow column a crew can spot from across the site. Client-side only. +/particles/smoke/mission_plume + width = 192 + height = 320 + count = 150 + spawning = 2 + lifespan = 4 SECONDS + fade = 2 SECONDS + position = generator(GEN_SPHERE, 0, 4, NORMAL_RAND) + scale = list(1.5, 1.5) + grow = list(0.05, 0.05) + gravity = list(0.08, 0.95) + +#undef MISSION_SCENE_BURN_TIME diff --git a/voidcrew/modules/missions/spawn_cover.dm b/voidcrew/modules/missions/spawn_cover.dm new file mode 100644 index 00000000000..f1b2ccde122 --- /dev/null +++ b/voidcrew/modules/missions/spawn_cover.dm @@ -0,0 +1,103 @@ +/** + * # Mission Spawn Cover + * + * Field objectives are placed on whatever turf the site sampler rolls, and the + * site can already be loaded with a crew standing in it: accept a contract while + * landed and the survivor, the bounty, the anomaly or the crash site would wink + * into existence in front of them. The pickers here sample the same candidates, + * skip any turf a living player could see right now, and when nowhere is hidden + * fall back to the candidate farthest from everyone watching. + * + * "Could see" is the watcher's screen rectangle (their own view size, so a scope + * or zoom counts), widened by a few tiles so whatever scatters around the anchor + * (guards, dressing, the rest of a pylon set) doesn't land on the edge of the + * screen, then a straight line of sight that walls and other opaque turfs block. + * Darkness is ignored: a dark tile in view still counts as seen. + */ + +/// Tiles past the edge of a watcher's screen still treated as in view +#define MISSION_SPAWN_COVER_MARGIN 3 +/// Random samples a hidden pick takes from a candidate list before falling back +#define MISSION_SPAWN_COVER_TRIES 40 + +/** + * Everyone who could be looking at one z-level, taken once per pick so each + * candidate check is a few subtractions and, only for turfs on somebody's screen, + * one line-of-sight walk. + */ +/datum/spawn_cover + /// One entry per watcher: list(eye turf, half view width, half view height), margin included + var/list/watchers = list() + /// The seen candidate farthest from its nearest watcher, for when nothing is hidden + var/turf/fallback + /// Chebyshev distance from the fallback to its nearest watcher + var/fallback_distance = -1 + +/datum/spawn_cover/New(z) + . = ..() + if(!z) + return + for(var/mob/living/player as anything in GLOB.alive_player_list) + var/client/viewer = player.client + if(!viewer) + continue + // The client's eye, not the body: an AI looks through its camera eye + var/turf/eye_turf = get_turf(viewer.eye || player) + if(!eye_turf || eye_turf.z != z) + continue + var/list/view_size = getviewsize(viewer.view) + add_watcher(eye_turf, CEILING((view_size[1] - 1) / 2, 1), CEILING((view_size[2] - 1) / 2, 1)) + +/// Registers one pair of eyes. Half sizes are the screen's, before the margin. +/datum/spawn_cover/proc/add_watcher(turf/eye_turf, half_width, half_height) + watchers += list(list(eye_turf, half_width + MISSION_SPAWN_COVER_MARGIN, half_height + MISSION_SPAWN_COVER_MARGIN)) + +/datum/spawn_cover/proc/has_watchers() + return length(watchers) > 0 + +/** + * TRUE when no watcher could see the candidate. A seen candidate is remembered + * as the fallback if it sits farther from its nearest watcher than the last one. + */ +/datum/spawn_cover/proc/is_hidden(turf/candidate) + if(!length(watchers)) + return TRUE + var/nearest = INFINITY + var/seen = FALSE + for(var/list/watcher as anything in watchers) + var/turf/eye_turf = watcher[1] + var/dx = abs(candidate.x - eye_turf.x) + var/dy = abs(candidate.y - eye_turf.y) + nearest = min(nearest, max(dx, dy)) + if(seen || dx > watcher[2] || dy > watcher[3]) + continue + if(inLineOfSight(eye_turf.x, eye_turf.y, candidate.x, candidate.y, candidate.z)) + seen = TRUE + if(!seen) + return TRUE + if(nearest > fallback_distance) + fallback = candidate + fallback_distance = nearest + return FALSE + +/** + * A random turf from candidates that nobody can see, or the sampled candidate + * farthest from any watcher. Candidates must already be valid spawn turfs on one + * z-level; this only decides between them. With nobody on the level it is a + * plain pick(). + */ +/proc/pick_unwatched_turf(list/candidates, tries = MISSION_SPAWN_COVER_TRIES) + if(!length(candidates)) + return null + var/turf/first = candidates[1] + var/datum/spawn_cover/cover = new(first.z) + if(!cover.has_watchers()) + return pick(candidates) + for(var/_ in 1 to tries) + var/turf/candidate = pick(candidates) + if(cover.is_hidden(candidate)) + return candidate + return cover.fallback + +#undef MISSION_SPAWN_COVER_MARGIN +#undef MISSION_SPAWN_COVER_TRIES diff --git a/voidcrew/modules/overmap/code/modules/overmap/space_ruin.dm b/voidcrew/modules/overmap/code/modules/overmap/space_ruin.dm index 2a88700fb42..a6a43e9ced1 100644 --- a/voidcrew/modules/overmap/code/modules/overmap/space_ruin.dm +++ b/voidcrew/modules/overmap/code/modules/overmap/space_ruin.dm @@ -649,8 +649,12 @@ GLOBAL_LIST_EMPTY(space_ruin_signals) /** * Picks a random non-dense, non-space turf inside the loaded ruin's template footprint. * Used by recovery missions to place objectives. Returns null if the ruin isn't loaded. + * + * unwatched: mission field spawns. Prefer solid ground nothing dense is standing on, and + * ones no living player can see right now (pick_unwatched_turf()), so a crew already + * aboard doesn't watch the objective appear. */ -/obj/structure/overmap/space_ruin/proc/get_random_interior_turf() +/obj/structure/overmap/space_ruin/proc/get_random_interior_turf(unwatched = FALSE) if(!loaded || !ruin_bottom_left || !ruin_template?.width || !ruin_template?.height) return null var/turf/top_right = locate( @@ -679,6 +683,12 @@ GLOBAL_LIST_EMPTY(space_ruin_signals) candidates += interior_turf if(!length(candidates)) return null + if(unwatched) + var/list/clear = list() + for(var/turf/candidate as anything in candidates) + if(!candidate.is_blocked_turf(exclude_mobs = TRUE) && !isgroundlessturf(candidate)) + clear += candidate + return pick_unwatched_turf(length(clear) ? clear : candidates) return pick(candidates) /obj/structure/overmap/space_ruin/proc/remove_docks() diff --git a/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm b/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm index 918d96de83f..af42e46864b 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm @@ -78,6 +78,9 @@ return /datum/prison_boss_move/slip_cuffs if(BOUNTY_KIT_HEAVY) return /datum/prison_boss_move/barricade + // Its chrome stays out of prison (decision 7): the Juggernaut's charge + if(BOUNTY_KIT_CYBERPSYCHO) + return /datum/prison_boss_move/charge return null /** diff --git a/voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm b/voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm index 102eb718f16..e62fdce1d11 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm @@ -264,6 +264,8 @@ return FALSE if(is_outpost_experiment_mob(victim) || HAS_TRAIT(victim, TRAIT_GODMODE)) return FALSE + if(cyberware_camo_hides(victim, parent)) // optical camo (cyberware_stealth.dm) + 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)) diff --git a/voidcrew/modules/trade/buyback_listed.dm b/voidcrew/modules/trade/buyback_listed.dm new file mode 100644 index 00000000000..b00b471edb0 --- /dev/null +++ b/voidcrew/modules/trade/buyback_listed.dm @@ -0,0 +1,123 @@ +/** + * # Listed buybacks: shared helpers for ledger rows that name their goods + * + * Most buyback rows take "any X". The depot's rare-goods rows instead take a + * fixed list of exact types (a red-zone rifle, one theme of MODsuit), so a toy + * or printed subtype of the same parent never reaches a voucher payout. These + * procs are shared by the outfitter, Skunkworks and Fitting Bay ledgers + * (shop_catalog_outfitter*.dm, shop_catalog_suit_vendor.dm). + * + * Two extra refusals ride along: + * - Loose goods only. The seller's contents sweep reaches inside everything, + * so a slime extract cycling inside a recurring crossbreed, or an anomaly + * core seated in a MOD module, would otherwise be ripped out and sold. + * - Ship's issue. Gear mapped aboard a player hull when it loads is part of + * what the crew bought with the ship, not a find. It is flagged here and the + * rare rows refuse it; the plain salvage rows still take it as before. + */ + +/obj/item + /// Mapped aboard a player hull at load (see check_buyback_hull_issue()). Rare buyback rows refuse it. + var/buyback_hull_issue = FALSE + +/// Item roots the rare rows buy from. Only these get the hull check, which keeps it off the hot path. +GLOBAL_LIST_INIT(buyback_hull_watch, typecacheof(list( + /obj/item/gun, + /obj/item/melee, + /obj/item/claymore, + /obj/item/katana, + /obj/item/cursed_katana, + /obj/item/energy_katana, + /obj/item/mjollnir, + /obj/item/spear, + /obj/item/shield, + /obj/item/cain_and_abel, + /obj/item/cane/shepherds_crook, + /obj/item/garrison_standard, + /obj/item/heave_ho, + /obj/item/hierophant_club, + /obj/item/knife/understudy, + /obj/item/lava_staff, + /obj/item/veilrender, + /obj/item/clothing/suit, + /obj/item/clothing/head, + /obj/item/mod/control, + /obj/item/mod/module, +))) + +/obj/item/Initialize(mapload) + . = ..() + if(mapload && GLOB.buyback_hull_watch[type]) + check_buyback_hull_issue() + +/** + * Flags gear that loads with a player hull. A player ship loads with + * SSshuttle.loading_ship (or a shipyard order) set; its upgrade modules load + * a moment later, by which time the hull's areas know their port and ship. + * NPC hulls use the same maps, but their loot is a find, so they stay clear. + */ +/obj/item/proc/check_buyback_hull_issue() + var/area/shuttle/voidcrew/hull_area = get_area(src) + if(!istype(hull_area)) + return + var/obj/structure/overmap/ship/hull_ship = SSshuttle.loading_ship || hull_area.shuttle_port?.current_ship + if(!hull_ship) + if(SSshuttle.loading_order) + buyback_hull_issue = TRUE + return + if(istype(hull_ship, /obj/structure/overmap/ship/npc)) + return + buyback_hull_issue = TRUE + +/// Carried loose: in hand, a pocket or slot, or a bag. Not seated inside some other device. +/proc/buyback_goods_loose(obj/item/offered) + var/atom/holder = offered.loc + if(ismob(holder)) + return TRUE + return !isnull(holder?.atom_storage) && !istype(holder, /obj/item/mod/control) + +/// Exact-type cache for a listed row. +/proc/buyback_exact_cache(list/types) + return typecacheof(types, only_root_path = TRUE) + +/// Shows a listed row with its display item's sprite. +/proc/buyback_use_display_icon(datum/shop_buyback/entry, obj/item/display_path) + if(!ispath(display_path)) + return + entry.icon_override = initial(display_path.icon) + entry.icon_state_override = initial(display_path.icon_state) + +/// Whether an item is this row's kind of goods, ignoring who owns it or where it sits. Listed rows override. +/datum/shop_buyback/proc/buyback_wanted_kind(obj/item/offered) + return istype(offered, item_path) + +/** + * Refusal text for a listed row. The stock one keys off item_path, which a + * listed row sets to a broad parent, so it named unrelated shop stock. + */ +/proc/buyback_listed_denial(datum/shop_buyback/entry, mob/living/user) + if(entry.demand <= 0) + return "Not buying any more this shift." + if(entry.count_carried_units(user) < 1) + for(var/obj/item/offered in user.get_all_contents()) + if(!entry.buyback_wanted_kind(offered)) + continue + if(is_trader_good(offered)) + return "I don't buy back shop stock." + if(offered.buyback_hull_issue) + return "That's your ship's own kit." + return "Carrying none of the goods: [entry.get_wanted_text()]." + if(entry.pay_credits > 0 && !get_shop_buyback_account(user)) + return "No bank account on your ID." + return null + +/** + * A core refined from a bought raw core is still the trader's stock. Without + * this, a raw core off Boffin's shelf came out of the refinery as a clean + * object and could go straight back over his counter. + */ +/obj/item/raw_anomaly_core/create_core(newloc, del_self = FALSE, count_towards_limit = FALSE) + var/from_trader = is_trader_good(src) + . = ..() + if(from_trader && .) + mark_trader_goods(.) diff --git a/voidcrew/modules/trade/shop.dm b/voidcrew/modules/trade/shop.dm index e08a0600377..fd78a978987 100644 --- a/voidcrew/modules/trade/shop.dm +++ b/voidcrew/modules/trade/shop.dm @@ -230,7 +230,7 @@ /** * The supply convoy came through: tops core stock back up, swaps one sold-out * rotating slot for a fresh pool pick, rerolls the special and softens the - * buyback demand caps. Driven by the outpost's restock timer. + * credit buyback demand caps. Driven by the outpost's restock timer. */ /datum/outpost_shop/proc/convoy_restock() // Core shelves creep back toward full @@ -273,8 +273,11 @@ sku.discount_pct = initial(sku.discount_pct) roll_special() - // The trader found room in the warehouse for a bit more of everything + // The trader found room in the warehouse for a bit more of everything. + // Voucher rows keep their round-start roll: that roll is the round's whole supply. for(var/datum/shop_buyback/buyback as anything in buybacks) + if(buyback.pay_vouchers > 0) + continue if(buyback.demand < buyback.demand_max) buyback.demand = min(buyback.demand_max, buyback.demand + max(1, round(buyback.demand_max / 2))) diff --git a/voidcrew/modules/trade/shop_buyback.dm b/voidcrew/modules/trade/shop_buyback.dm index 9ad15e40e0d..fbaf518af0f 100644 --- a/voidcrew/modules/trade/shop_buyback.dm +++ b/voidcrew/modules/trade/shop_buyback.dm @@ -10,10 +10,13 @@ * one sale-unit per click or in bulk. Credits land on the selected ship's account, * falling back to the ID account; voucher payouts materialize in hand. * - * Balance rule: entries that pay VOUCHERS must only ever buy loot that can't - * be manufactured aboard a ship (planet minerals, fauna harvests, ruin finds). - * Vouchers are the currency that can't be farmed safely, and a lathe-printable - * buyback would break that in one shift. + * Balance rule: entries that pay VOUCHERS buy loot a ship can't manufacture + * (planet minerals, fauna harvests, ruin finds) at whatever demand suits it. + * Ship-made goods (drinks, cooked food, plants, slime extracts, farmed fish) + * may pay vouchers only for their rare top tier: 1-3 vouchers a sale, with + * demand 1-3. Demand is per round and shared by every crew, so that roll is + * the whole round's supply for everyone. Commons pay credits. Anything a + * lathe, cargo pack or vendor turns out cheaply never pays vouchers. */ /datum/shop_buyback /// Display name of what the trader wants (defaults to the item's name) @@ -42,6 +45,10 @@ var/icon_state_override /// Cached base64 icon for the UI, computed once per instance var/cached_icon + /// Takes goods bought over a counter (TRAIT_TRADER_GOODS) as well as found + /// ones. Only the ripperdoc trade-in sets this, and only credit payouts + /// honour it, see takes_shop_stock(). + var/buys_shop_stock = FALSE /datum/shop_buyback/New() ..() @@ -88,11 +95,20 @@ cached_icon = icon2base64(icon(icon_file, state, SOUTH, frame = 1)) return cached_icon +/** + * Whether this ledger takes goods that were bought at a shop. Every ledger + * refuses them except the ripperdoc trade-in, and that one only while it pays + * credits alone: a voucher payout for bought goods would turn credits into + * vouchers. + */ +/datum/shop_buyback/proc/takes_shop_stock() + return buys_shop_stock && pay_vouchers <= 0 + /** * Whether this item counts for this ledger entry. */ /datum/shop_buyback/proc/matches(obj/item/offered) - if(is_trader_good(offered)) + if(is_trader_good(offered) && !takes_shop_stock()) return FALSE if(match_subtypes ? !istype(offered, item_path) : offered.type != item_path) return FALSE @@ -111,7 +127,7 @@ if(match_subtypes || !item_path) return null for(var/obj/item/offered in user.get_all_contents()) - if(istype(offered, item_path) && offered.type != item_path) + if(istype(offered, item_path) && offered.type != item_path && !shop_buyback_inside_body(offered)) return offered return null @@ -125,6 +141,11 @@ * the seller's own back, or the MODsuit they are standing in. Held items still * count (that hand-off is the whole gesture), and so does anything in a bag or * a pocket, because carrying it there is already a decision to bring it. + * + * The seller's own body is skipped too. Installed organs sit inside their + * bodypart, inside the mob, so the same sweep reaches them, and none of them + * is in get_equipped_items(): without this a chrome ledger would take the + * seller's working eyes out of their head. */ /datum/shop_buyback/proc/find_offered_items(mob/living/user) var/list/found = list() @@ -135,10 +156,29 @@ for(var/obj/item/offered in user.get_all_contents()) if((offered in found) || (offered in worn)) continue + if(shop_buyback_inside_body(offered)) + continue if(matches(offered)) found += offered return found +/** + * Whether an item is part of a body or rides inside one: an attached limb, an + * installed organ, or anything held inside either. The walk stops at the first + * mob, so a severed limb or a pulled organ in a bag still counts as goods. + */ +/proc/shop_buyback_inside_body(obj/item/offered) + for(var/atom/current = offered; current && !ismob(current); current = current.loc) + if(isorgan(current)) + var/obj/item/organ/organ = current + if(organ.owner) + return TRUE + else if(isbodypart(current)) + var/obj/item/bodypart/limb = current + if(limb.owner) + return TRUE + return FALSE + /** * How many sale-units the seller is carrying (stacks divide by `amount`). */ @@ -171,7 +211,7 @@ return "Not buying any more this shift." if(count_carried_units(user) < 1) for(var/obj/item/offered in user.get_all_contents()) - if(istype(offered, item_path) && is_trader_good(offered)) + if(istype(offered, item_path) && is_trader_good(offered) && !takes_shop_stock() && !shop_buyback_inside_body(offered)) return "I don't buy back shop stock." // Exact-type ledgers (match_subtypes = FALSE) refuse processed/lab-made // variants of the wanted goods. Without this, a player holding a refined diff --git a/voidcrew/modules/trade/shop_catalog_black_market_vendors.dm b/voidcrew/modules/trade/shop_catalog_black_market_vendors.dm index 86765451902..bcfabdca175 100644 --- a/voidcrew/modules/trade/shop_catalog_black_market_vendors.dm +++ b/voidcrew/modules/trade/shop_catalog_black_market_vendors.dm @@ -85,6 +85,10 @@ /datum/shop_buyback/dregs/hooch, /datum/shop_buyback/dregs/kong, /datum/shop_buyback/dregs/ritual_wine, + /datum/shop_buyback/dregs/cocktail/house, + /datum/shop_buyback/dregs/cocktail/fancy, + /datum/shop_buyback/dregs/cocktail/hot_ice_coffee, + /datum/shop_buyback/dregs/cocktail/the_juice, ) trader_lines = list( TRADER_LINE_SALE = list( @@ -310,6 +314,97 @@ demand_min = 1 demand_max = 2 +// Mixed drinks, sold by the glass. A glass counts when it holds at least +// min_volume of one wanted drink and that drink is most of what's in it, so a +// splash of The Juice topped up with water doesn't pass. Every one of these can +// be mixed aboard a ship, so only the two hardest pay vouchers, at small demand. +/datum/shop_buyback/dregs/cocktail + category = "The Bar" + item_path = /obj/item/reagent_containers/cup/glass/drinkingglass + icon_override = 'icons/obj/drinks/mixed_drinks.dmi' + /// Drink reagent types this entry pays for (exact types) + var/list/wanted_drinks + /// Least amount of the drink one glass must hold + var/min_volume = 30 + /// Share of the glass's contents the drink must make up + var/min_share = 0.8 + +/datum/shop_buyback/dregs/cocktail/matches(obj/item/offered) + if(!..() || !offered.reagents) + return FALSE + var/datum/reagents/holder = offered.reagents + if(holder.total_volume < min_volume) + return FALSE + for(var/drink in wanted_drinks) + var/poured = holder.get_reagent_amount(drink) + if(poured >= min_volume && poured >= holder.total_volume * min_share) + return TRUE + return FALSE + +/datum/shop_buyback/dregs/cocktail/get_wanted_text() + return "a full glass of [name]" + +/datum/shop_buyback/dregs/cocktail/house + name = "a proper cocktail" + desc = "Gargle Blasters, Long Islands, Demon's Blood. Anything with a real recipe." + icon_state_override = "gargleblasterglass" + wanted_drinks = list( + /datum/reagent/consumable/ethanol/gargle_blaster, + /datum/reagent/consumable/ethanol/longislandicedtea, + /datum/reagent/consumable/ethanol/b52, + /datum/reagent/consumable/ethanol/quintuple_sec, + /datum/reagent/consumable/ethanol/demonsblood, + /datum/reagent/consumable/ethanol/devilskiss, + /datum/reagent/consumable/ethanol/narsour, + /datum/reagent/consumable/ethanol/hippies_delight, + /datum/reagent/consumable/ethanol/atomicbomb, + /datum/reagent/consumable/ethanol/threemileisland, + /datum/reagent/consumable/ethanol/manhattan_proj, + /datum/reagent/consumable/ethanol/toxins_special, + /datum/reagent/consumable/ethanol/beepsky_smash, + /datum/reagent/consumable/ethanol/turbo, + /datum/reagent/consumable/ethanol/helianthus, + /datum/reagent/consumable/doctor_delight, + ) + pay_credits = 80 + demand_min = 3 + demand_max = 5 + +/datum/shop_buyback/dregs/cocktail/fancy + name = "a top-shelf cocktail" + desc = "Neurotoxin, Singulo, Planet Cracker. What the Undertow's big spenders order." + icon_state_override = "neurotoxinglass" + wanted_drinks = list( + /datum/reagent/consumable/ethanol/neurotoxin, + /datum/reagent/consumable/ethanol/singulo, + /datum/reagent/consumable/ethanol/planet_cracker, + /datum/reagent/consumable/ethanol/triumphal_arch, + /datum/reagent/consumable/ethanol/salt_and_swell, + /datum/reagent/consumable/red_queen, + ) + pay_credits = 200 + demand_min = 2 + demand_max = 3 + +/datum/shop_buyback/dregs/cocktail/hot_ice_coffee + name = "Hot Ice Coffee" + desc = "Coffee brewed over hot ice. One of Dram's regulars drinks nothing else." + icon_override = 'icons/obj/drinks/coffee.dmi' + icon_state_override = "hoticecoffee" + wanted_drinks = list(/datum/reagent/consumable/hot_ice_coffee) + pay_vouchers = 1 + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/dregs/cocktail/the_juice + name = "The Juice" + desc = "Dram has one regular who orders it and still walks out." + icon_state_override = "thejuice" + wanted_drinks = list(/datum/reagent/consumable/ethanol/the_juice) + pay_vouchers = 2 + demand_min = 1 + demand_max = 2 + // ========================================================================= // PATCH-UP CLINIC: Sawbones, practitioner (license pending since forever) // ========================================================================= @@ -391,6 +486,9 @@ /datum/shop_buyback/clinic/liver, /datum/shop_buyback/clinic/lungs, /datum/shop_buyback/clinic/monster_gland, + /datum/shop_buyback/clinic_exotic/species, + /datum/shop_buyback/clinic_exotic/voltaic_heart, + /datum/shop_buyback/clinic_exotic/meridian_heart, ) trader_lines = list( TRADER_LINE_SALE = list( @@ -637,12 +735,34 @@ price_vouchers = 0 // ===== SAWBONES' INTAKE LEDGER (buybacks) ===== -// Natural donor organs and monster glands only. +// Natural donor organs and monster glands, plus the exotic intake below. + +/// Organs from the off-world playable species. Sawbones prices these on their own +/// line, so the plain donor heart/liver/lungs lines never take one cheap. +GLOBAL_LIST_INIT(clinic_species_organs, typecacheof(list( + /obj/item/organ/brain/lizard, + /obj/item/organ/eyes/lizard, + /obj/item/organ/tongue/lizard, + /obj/item/organ/eyes/moth, + /obj/item/organ/tongue/moth, + /obj/item/organ/ears/cat, + /obj/item/organ/tongue/cat, + /obj/item/organ/lungs/plasmaman, + /obj/item/organ/liver/bone/plasmaman, + /obj/item/organ/stomach/bone/plasmaman, + /obj/item/organ/tongue/bone/plasmaman, + /obj/item/organ/heart/ethereal, + /obj/item/organ/lungs/ethereal, + /obj/item/organ/stomach/ethereal, + /obj/item/organ/tongue/ethereal, +))) /datum/shop_buyback/clinic/matches(obj/item/offered) if(!..() || !istype(offered, /obj/item/organ)) return FALSE var/obj/item/organ/organ = offered + if(is_type_in_typecache(organ, GLOB.clinic_species_organs)) + return FALSE return (organ.organ_flags & ORGAN_ORGANIC) && !(organ.organ_flags & ORGAN_ROBOTIC) && !HAS_TRAIT(organ, TRAIT_PRINTED_ORGAN) /datum/shop_buyback/clinic/heart @@ -692,3 +812,55 @@ if(istype(offered, item_path) && is_dead_monster_core(offered) && !is_trader_good(offered)) return "That core's gone dead." return ..() + +// Exotic intake. Never a limbgrower print (TRAIT_PRINTED_ORGAN), and never a +// dead or broken organ. Species organs come off any body of that species, so +// they pay credits. The voucher lines are organs a ship can't make: +// the voltaic heart's shell prints in a lathe, but the flux core inside comes +// out of a live anomaly, and the Meridian heart only turns up in ruin caches. +/datum/shop_buyback/clinic_exotic + category = "Exotic Intake" + item_path = /obj/item/organ + +/datum/shop_buyback/clinic_exotic/matches(obj/item/offered) + if(!..()) + return FALSE + var/obj/item/organ/organ = offered + return !HAS_TRAIT(organ, TRAIT_PRINTED_ORGAN) && !(organ.organ_flags & ORGAN_FAILING) + +/datum/shop_buyback/clinic_exotic/species + name = "off-world donor organ" + desc = "Lizard, moth, felinid, plasmaman or ethereal. Sawbones has clients who need a match." + icon_override = 'icons/obj/medical/organs/organs.dmi' + icon_state_override = "tonguelizard" + pay_credits = 200 + demand_min = 2 + demand_max = 4 + +/datum/shop_buyback/clinic_exotic/species/matches(obj/item/offered) + if(!..() || !is_type_in_typecache(offered, GLOB.clinic_species_organs)) + return FALSE + var/obj/item/organ/organ = offered + return !(organ.organ_flags & ORGAN_ROBOTIC) + +/datum/shop_buyback/clinic_exotic/voltaic_heart + name = "voltaic heart, cored" + desc = "A voltaic cyberheart with a live flux core seated. Sawbones won't say who it's for." + item_path = /obj/item/organ/heart/cybernetic/anomalock + pay_vouchers = 1 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/clinic_exotic/voltaic_heart/matches(obj/item/offered) + if(!..()) + return FALSE + var/obj/item/organ/heart/cybernetic/anomalock/heart = offered + return istype(heart.core, heart.required_anomaly) && !is_trader_good(heart.core) + +/datum/shop_buyback/clinic_exotic/meridian_heart + name = "Meridian heart" + desc = "The cold-chain heart with its own defib charge. Sawbones has a buyer and a cooler waiting." + item_path = /obj/item/organ/heart/cybernetic/meridian + pay_vouchers = 1 + demand_min = 1 + demand_max = 1 diff --git a/voidcrew/modules/trade/shop_catalog_diner.dm b/voidcrew/modules/trade/shop_catalog_diner.dm index 5a20c3b1341..c9306ef6273 100644 --- a/voidcrew/modules/trade/shop_catalog_diner.dm +++ b/voidcrew/modules/trade/shop_catalog_diner.dm @@ -23,8 +23,9 @@ * and both the buyback ledger and the Kitchen Order contracts accept only * HAS_TRAIT_NOT_FROM that source: Roux never buys her own plates back, and * contracts can't be settled off her own counter. - * - Every ledger payout sits below the cheapest plated SKU, so buy-to-sell-back - * loses money even before the source gate. + * - Every order-wheel payout sits below the cheapest plated SKU, so + * buy-to-sell-back loses money even before the source gate. The specials pay + * more, but Roux plates none of them. * - Nothing here prints on a stock ship autolathe; dishes need a real kitchen. */ @@ -109,7 +110,18 @@ /datum/shop_sku/diner/plated/rare/birthday_cake, /datum/shop_sku/diner/plated/rare/berry_clafoutis, ) + // Specials sit ahead of the catch-alls so a counter quote prices them right buyback_types = list( + /datum/shop_buyback/diner/special/stuffed_legion, + /datum/shop_buyback/diner/special/energy_cake, + /datum/shop_buyback/diner/special/royal_cheese, + /datum/shop_buyback/diner/special/gondola_pocket, + /datum/shop_buyback/diner/special/mimana_bread, + /datum/shop_buyback/diner/special/ghost_burger, + /datum/shop_buyback/diner/special/chaos_donut, + /datum/shop_buyback/diner/special/xenoburger, + /datum/shop_buyback/diner/special/spell_burger, + /datum/shop_buyback/diner/special/notasandwich, /datum/shop_buyback/diner/home_cooking, /datum/shop_buyback/diner/pie_case, /datum/shop_buyback/diner/whole_cake, @@ -457,6 +469,8 @@ // Cooked by an actual person, and not by this kitchen if(!HAS_TRAIT_NOT_FROM(offered, TRAIT_FOOD_CHEF_MADE, TRAIT_SOURCE_OUTPOST_KITCHEN)) return FALSE + if(claimed_by_buyback_family(offered, /datum/shop_buyback/diner/special)) + return FALSE var/obj/item/food/dish = offered return dish.crafting_complexity >= min_complexity @@ -486,6 +500,8 @@ /datum/shop_buyback/diner/whole_cake/matches(obj/item/offered) if(!..()) return FALSE + if(claimed_by_buyback_family(offered, /datum/shop_buyback/diner/special)) + return FALSE return HAS_TRAIT_NOT_FROM(offered, TRAIT_FOOD_CHEF_MADE, TRAIT_SOURCE_OUTPOST_KITCHEN) // The scavenger's rung: no chef gate, pocket change. Donk Co. pays a standing @@ -498,3 +514,108 @@ pay_credits = 20 demand_min = 6 demand_max = 12 + +// The gondola pocket has its own row +/datum/shop_buyback/diner/donk_recall/matches(obj/item/offered) + if(!..()) + return FALSE + return !claimed_by_buyback_family(offered, /datum/shop_buyback/diner/special) + +// ===== ROUX'S SPECIALS ===== +// Dishes that need an ingredient a galley can't just order. Same chef gate as +// the order wheel: cooked by a person, and not on Roux's own pass. Loot-spawned +// plates carry no chef trait and don't count. +// +// Voucher rows each burn something that is itself worth a fight: a legion core +// (the black market pays a voucher for one on its own, so the dish pays two), +// an energy sword (4 vouchers on the black market shelf, so the cake can't +// launder a bought one into profit), strange reagent plus a crown, or gondola +// toxin, which only comes off a gondola. Credit rows use ingredients a ship +// can get with some effort: ectoplasm off a ghost-eaten meal, a mime banana +// mutation, frost oil from ice peppers, xeno meat (a cargo meat crate can roll +// it), a costume wizard hat or a fake moustache from the autodrobe. +// Bread cat and bread dog are mobs, not plates, so they aren't listed. + +/datum/shop_buyback/diner/special + category = "Chef's Specials" + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/diner/special/matches(obj/item/offered) + if(!..()) + return FALSE + return HAS_TRAIT_NOT_FROM(offered, TRAIT_FOOD_CHEF_MADE, TRAIT_SOURCE_OUTPOST_KITCHEN) + +/datum/shop_buyback/diner/special/stuffed_legion + name = "stuffed legion" + desc = "Goliath steak wrapped round a legion core. Roux plates it under a cloche and charges whatever she likes." + item_path = /obj/item/food/stuffedlegion + pay_vouchers = 2 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/diner/special/energy_cake + name = "energy cake" + desc = "A birthday cake with an energy sword baked in. Roux cuts it with oven mitts on." + item_path = /obj/item/food/cake/birthday/energy + pay_vouchers = 2 + demand_min = 1 + demand_max = 1 + +/datum/shop_buyback/diner/special/royal_cheese + name = "royal cheese" + desc = "A cheese wheel that wears a crown. Roux bows to it. Nobody laughs." + item_path = /obj/item/food/cheese/royal + pay_vouchers = 1 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/diner/special/gondola_pocket + name = "gondola pocket" + desc = "A pocket pastry with gondola in it. Roux serves it to people she trusts, and only once." + item_path = /obj/item/food/donkpocket/gondola + pay_vouchers = 1 + demand_min = 1 + demand_max = 2 + +// The microwaved one is a sibling type, not a subtype +/datum/shop_buyback/diner/special/gondola_pocket/matches(obj/item/offered) + if(istype(offered, /obj/item/food/donkpocket/warm/gondola) && !is_trader_good(offered) && !(offered.item_flags & ABSTRACT) && !(offered.flags_1 & HOLOGRAM_1)) + return HAS_TRAIT_NOT_FROM(offered, TRAIT_FOOD_CHEF_MADE, TRAIT_SOURCE_OUTPOST_KITCHEN) + return ..() + +/datum/shop_buyback/diner/special/mimana_bread + name = "mimana bread (whole loaf)" + desc = "Bread made with a mime's banana. It makes no sound when you cut it." + item_path = /obj/item/food/bread/mimana + pay_credits = 300 + +/datum/shop_buyback/diner/special/ghost_burger + name = "ghost burger" + desc = "A burger with ectoplasm in it. It's cold all the way through and always will be." + item_path = /obj/item/food/burger/ghost + pay_credits = 200 + +/datum/shop_buyback/diner/special/chaos_donut + name = "chaos donut" + desc = "Frost oil and capsaicin in one donut. Roux sells them on a dare." + item_path = /obj/item/food/donut/chaos + pay_credits = 150 + +/datum/shop_buyback/diner/special/xenoburger + name = "xenoburger" + desc = "A burger made from xeno meat. Roux doesn't say where hers comes from." + item_path = /obj/item/food/burger/xeno + pay_credits = 150 + +/datum/shop_buyback/diner/special/spell_burger + name = "spell burger" + desc = "A burger with a wizard hat cooked into it. Customers swear it talks." + item_path = /obj/item/food/burger/spell + pay_credits = 100 + +/datum/shop_buyback/diner/special/notasandwich + name = "not-a-sandwich" + desc = "Two slices of bread wearing a fake moustache. It's not a sandwich. Roux has stopped arguing." + item_path = /obj/item/food/sandwich/notasandwich + pay_credits = 80 diff --git a/voidcrew/modules/trade/shop_catalog_general.dm b/voidcrew/modules/trade/shop_catalog_general.dm index cb06bf4da6b..a324885a399 100644 --- a/voidcrew/modules/trade/shop_catalog_general.dm +++ b/voidcrew/modules/trade/shop_catalog_general.dm @@ -725,6 +725,38 @@ demand_min = 5 demand_max = 8 +// Barnaby sends anything Pike wants for the wall next door, so a trophy fish +// never goes in the chowder for less by accident. +/datum/shop_buyback/general/fresh_catch/matches(obj/item/offered) + if(!..()) + return FALSE + return !claimed_by_buyback_family(offered, /datum/shop_buyback/bait) + +/** + * Whether any ledger entry under `family` (a /datum/shop_buyback base type) + * would take `offered`. A catch-all entry ("any fish", "any produce", "any + * dish") calls this to step aside for the specific entries that pay more, so + * a rare item can't be sold cheap by surprise and the two lists never drift: + * adding a rare entry excludes it from the catch-all automatically. + * + * Asks real matches() on one cached prototype per entry, so conditions like a + * potency floor or an excluded subtype carry over exactly. + */ +/proc/claimed_by_buyback_family(obj/item/offered, family) + var/static/list/prototypes_by_family = list() + var/list/prototypes = prototypes_by_family[family] + if(isnull(prototypes)) + prototypes = list() + for(var/datum/shop_buyback/entry_type as anything in subtypesof(family)) + if(!initial(entry_type.item_path)) + continue + prototypes += new entry_type + prototypes_by_family[family] = prototypes + for(var/datum/shop_buyback/prototype as anything in prototypes) + if(prototype.matches(offered)) + return TRUE + return FALSE + /datum/shop_buyback/general/bear_pelt name = "bear hide" desc = "Cave bear hide off the green worlds. Barnaby says it's for the guest bunks. There are no guest bunks." diff --git a/voidcrew/modules/trade/shop_catalog_general_vendors.dm b/voidcrew/modules/trade/shop_catalog_general_vendors.dm index 7abbb058ffd..8abcd744dcc 100644 --- a/voidcrew/modules/trade/shop_catalog_general_vendors.dm +++ b/voidcrew/modules/trade/shop_catalog_general_vendors.dm @@ -15,7 +15,8 @@ * - Fern stocks seeds and supplies rather than printable hand tools. Her * tray board is the fabrication-gated infrastructure for adding a garden. * - Fern's produce and graft buybacks pay pocket change on purpose: it's the - * "sell your harvest at the waystation" fantasy, not an economy. Her graft + * "sell your harvest at the waystation" fantasy, not an economy. Only her + * prize-plant rows (mutation-chain crops over a potency bar) pay real money. Her graft * ledger refuses plain repeated-harvest cuttings so a tray of wheat can't be * farmed into credits; see the matches() override below. * - Pike never buys what his own pond stocks at meaningful prices; the @@ -96,7 +97,15 @@ /datum/shop_sku/potting/rare/gaia, /datum/shop_sku/potting/rare/mystery_seeds, ) + // Prize plants sit ahead of the farm stand so a counter quote prices them right buyback_types = list( + /datum/shop_buyback/potting/prize/gatfruit, + /datum/shop_buyback/potting/prize/omega_weed, + /datum/shop_buyback/potting/prize/bluespace_tomato, + /datum/shop_buyback/potting/prize/holymelon, + /datum/shop_buyback/potting/prize/golden_apple, + /datum/shop_buyback/potting/prize/bluespace_banana, + /datum/shop_buyback/potting/prize/glowcap, /datum/shop_buyback/potting/graft, /datum/shop_buyback/potting/ash_flora, /datum/shop_buyback/potting/produce, @@ -363,6 +372,97 @@ demand_min = 5 demand_max = 10 +// A prize plant good enough for Fern's own ledger never goes on the farm stand. +// One below her bar does, at farm-stand rates. +/datum/shop_buyback/potting/produce/matches(obj/item/offered) + if(!..()) + return FALSE + return !claimed_by_buyback_family(offered, /datum/shop_buyback/potting/prize) + +// ===== FERN'S PRIZE PLANTS ===== +// Mutation-chain crops, bought one at a time. Once a crew has the seed it can +// grow these forever, so the cap is demand (1-3, and the voucher rows never +// refill), and the bar is seed potency: a fresh mutation comes out weak, and +// only a few generations of real breeding clears min_potency. Anything under +// the bar still sells on the farm stand. Seed sources checked: none of these +// seeds is on a vendor, a cargo pack or a trader shelf. Gatfruit seeds only +// spawn as loot; omega weed is a 1-in-5 mutation off contraband cannabis; +// bluespace tomato is two mutations deep off a stock tomato. The credit rows +// are one mutation off seeds anyone can buy. + +/datum/shop_buyback/potting/prize + category = "Prize Plants" + item_path = null + demand_min = 1 + demand_max = 3 + /// Lowest seed potency Fern will take for this entry + var/min_potency = 30 + +/datum/shop_buyback/potting/prize/matches(obj/item/offered) + if(!..()) + return FALSE + var/obj/item/food/grown/crop = offered + return crop.seed?.potency >= min_potency + +/datum/shop_buyback/potting/prize/get_denial_reason(mob/living/user) + . = ..() + if(!. || demand <= 0 || count_carried_units(user) >= 1) + return + for(var/obj/item/food/grown/crop in user.get_all_contents()) + if(istype(crop, item_path) && !is_trader_good(crop)) + return "Not that one. Grow me a stronger one." + +/datum/shop_buyback/potting/prize/gatfruit + name = "gatfruit" + desc = "Fruit that grows bullets. Fern keeps hers in a locked drawer." + item_path = /obj/item/food/grown/gatfruit + pay_vouchers = 2 + min_potency = 50 + demand_min = 1 + demand_max = 1 + +/datum/shop_buyback/potting/prize/omega_weed + name = "omega weed" + desc = "Top-shelf omega weed. Fern says it's for a study." + item_path = /obj/item/food/grown/cannabis/ultimate + pay_vouchers = 1 + min_potency = 50 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/potting/prize/bluespace_tomato + name = "bluespace tomato" + desc = "A tomato that isn't entirely in one place. Fern wants a strong one." + item_path = /obj/item/food/grown/tomato/blue/bluespace + pay_vouchers = 1 + min_potency = 50 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/potting/prize/holymelon + name = "holy melon" + desc = "A melon full of holy water. The chaplain on the next ring orders them by the crate." + item_path = /obj/item/food/grown/holymelon + pay_credits = 200 + +/datum/shop_buyback/potting/prize/golden_apple + name = "golden apple" + desc = "An apple with real gold in it. Fern doesn't eat them." + item_path = /obj/item/food/grown/apple/gold + pay_credits = 200 + +/datum/shop_buyback/potting/prize/bluespace_banana + name = "bluespace banana" + desc = "A banana that slips through space. Fern handles them with tongs." + item_path = /obj/item/food/grown/banana/bluespace + pay_credits = 150 + +/datum/shop_buyback/potting/prize/glowcap + name = "glowcap" + desc = "A mushroom that glows and holds a charge. Halcyon's night lights run on them." + item_path = /obj/item/food/grown/mushroom/glowshroom/glowcap + pay_credits = 150 + // ========================================================================= // PIKE'S BAIT & TACKLE: Pike, resident angler // ========================================================================= @@ -420,9 +520,17 @@ /datum/shop_sku/bait/rotating/stocked_aquarium, ) buyback_types = list( - /datum/shop_buyback/bait/pike, + /datum/shop_buyback/bait/mastodon, + /datum/shop_buyback/bait/nessie, + /datum/shop_buyback/bait/moonfish, + /datum/shop_buyback/bait/chainsawfish, + /datum/shop_buyback/bait/armored_pike, /datum/shop_buyback/bait/donkfish, - /datum/shop_buyback/bait/goldfish, + /datum/shop_buyback/bait/swordfish, + /datum/shop_buyback/bait/pike, + /datum/shop_buyback/bait/lavaloop, + /datum/shop_buyback/bait/starfish, + /datum/shop_buyback/bait/fritterish, ) trader_lines = list( TRADER_LINE_SALE = list( @@ -578,14 +686,67 @@ price_credits = 600 // ===== PIKE'S TROPHY LEDGER (buybacks) ===== -// The weird stuff only. Barnaby handles the by-the-fin chowder trade. +// The weird stuff only. Barnaby's chowder pot takes every other fish, and +// steps aside for anything on this list (see fresh_catch/matches()), so the +// two ledgers never overlap. +// +// Where they come from: the fishing portal (printable from roundstart) opens +// ocean and hyperspace water after fish-scanning experiments and syndicate +// water when emagged, so swordfish, moonfish, starfish, donk-fish, +// chainsawfish and armored pike are all ship-farmable, and fish breed in an +// aquarium. Those pay credits. The two voucher rows can't be pulled from a +// portal: nessie comes out of a deep fryer about once every 22 minutes on a +// hard catch, and the mastodon out of an oil well in a ruin, or a big-fish +// breeding project. Rift fish (chrystarfish aside) only come out of heretic +// influences, which Voidcrew never spawns, so they aren't listed. + +/datum/shop_buyback/bait/mastodon + name = "unmarine mastodon" + desc = "The big one. Pike has cleared a whole wall for it." + category = "Trophy Wall" + item_path = /obj/item/fish/mastodon + pay_vouchers = 2 + demand_min = 1 + demand_max = 1 -/datum/shop_buyback/bait/pike - name = "pike (the fish)" - desc = "He wants one for the wall. He is aware of the name situation. Do not bring up the name situation." +/datum/shop_buyback/bait/nessie + name = "nessie-fish" + desc = "Pulled out of a deep fryer, they say. Pike has stopped asking how." category = "Trophy Wall" - item_path = /obj/item/fish/pike - pay_credits = 300 + item_path = /obj/item/fish/fryish/nessie + pay_vouchers = 1 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/bait/moonfish + name = "zagoskian moonfish" + desc = "A full-grown moonfish. The dwarf ones go in the chowder." + category = "Trophy Wall" + item_path = /obj/item/fish/moonfish + pay_credits = 400 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/bait/moonfish/matches(obj/item/offered) + if(!..()) + return FALSE + return !istype(offered, /obj/item/fish/moonfish/dwarf) + +/datum/shop_buyback/bait/chainsawfish + name = "chainsawfish" + desc = "Pike mounts them with the motor still in. He has the scars to prove it." + category = "Trophy Wall" + item_path = /obj/item/fish/chainsawfish + pay_credits = 400 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/bait/armored_pike + name = "armored pike" + desc = "A pike with plating. Pike takes it personally, in a good way." + category = "Trophy Wall" + item_path = /obj/item/fish/pike/armored + pay_credits = 400 demand_min = 1 demand_max = 2 @@ -598,11 +759,54 @@ demand_min = 1 demand_max = 2 -/datum/shop_buyback/bait/goldfish - name = "goldfish" - desc = "Pity rates. Everyone's first catch deserves a buyer, and Pike remembers his." +/datum/shop_buyback/bait/swordfish + name = "swordfish" + desc = "Deep water, long bill, bad attitude. Pike wants it for over the door." category = "Trophy Wall" - item_path = /obj/item/fish/goldfish - pay_credits = 25 - demand_min = 3 - demand_max = 5 + item_path = /obj/item/fish/swordfish + pay_credits = 300 + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/bait/pike + name = "pike (the fish)" + desc = "He wants one for the wall. He is aware of the name situation. Do not bring up the name situation." + category = "Trophy Wall" + item_path = /obj/item/fish/pike + pay_credits = 300 + demand_min = 1 + demand_max = 2 + +// The armored kind has its own row +/datum/shop_buyback/bait/pike/matches(obj/item/offered) + if(!..()) + return FALSE + return !istype(offered, /obj/item/fish/pike/armored) + +/datum/shop_buyback/bait/lavaloop + name = "lavaloop" + desc = "A fish that swims in lava. Pike keeps it in a steel bucket on a hot plate." + category = "Trophy Wall" + item_path = /obj/item/fish/lavaloop + pay_credits = 250 + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/bait/starfish + name = "cosmostarfish" + desc = "Fished out of open space. Pike checks it twice for a pulse." + category = "Trophy Wall" + item_path = /obj/item/fish/starfish + pay_credits = 200 + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/bait/fritterish + name = "fritterish" + desc = "Grown up from a fryer catch. It still smells of oil." + category = "Trophy Wall" + item_path = /obj/item/fish/fryish/fritterish + pay_credits = 200 + demand_min = 1 + demand_max = 2 + diff --git a/voidcrew/modules/trade/shop_catalog_outfitter.dm b/voidcrew/modules/trade/shop_catalog_outfitter.dm index 84086db044e..d6ef62da5e9 100644 --- a/voidcrew/modules/trade/shop_catalog_outfitter.dm +++ b/voidcrew/modules/trade/shop_catalog_outfitter.dm @@ -176,6 +176,12 @@ /datum/shop_buyback/outfitter/goliath_plates, /datum/shop_buyback/outfitter/sinew, /datum/shop_buyback/outfitter/glacial_core, + /datum/shop_buyback/outfitter/listed/officer_armor, + /datum/shop_buyback/outfitter/listed/military_armor, + /datum/shop_buyback/outfitter/listed/service_arms, + /datum/shop_buyback/outfitter/listed/heavy_arms, + /datum/shop_buyback/outfitter/listed/military_arms, + /datum/shop_buyback/outfitter/listed/collector_pieces, ) // Field harvests for depot resupply mission_requests = list( @@ -788,13 +794,15 @@ price_credits = 2000 // ===== SARGE'S SALVAGE COUNTER (buybacks) ===== -// Credits only; guns and armor can come off a lathe, so they never pay vouchers. +// Plain salvage pays credits. The rare rows below take exact types only +// (buyback_listed.dm): a row typed at /obj/item/gun would pay out on cargo's +// toy crates, 400 cr buys eight foam shotguns, so every gun row names its guns. // -// No gun line here either. Any buyback typed at /obj/item/gun or -// /obj/item/gun/energy pays out on cargo's toy crates, 400 cr buys eight foam -// shotguns or six laser-tag rifles, and none of them can be told apart from the -// real thing at the counter. Armor's bid includes room for discounted cargo and -// the crate/manifest return; security packs cannot receive ordinary coupons. +// Tiers follow tools/gear_catalog/ratings/. Anything a crew can buy, order or +// print pays credits at a fraction of its cheapest shelf price (peddler and +// depot prices); only gear with no buy, print or order route pays vouchers. +// Armor's bid includes room for discounted cargo and the crate/manifest +// return; security packs cannot receive ordinary coupons. /datum/shop_buyback/outfitter/salvage_armor name = "armored suit (salvage)" @@ -805,6 +813,14 @@ demand_min = 3 demand_max = 6 +/// The rare armor rows outbid this one, so their goods go there. Ship's issue still sells here. +/datum/shop_buyback/outfitter/salvage_armor/matches(obj/item/offered) + if(!..()) + return FALSE + if(offered.buyback_hull_issue) + return TRUE + return !(GLOB.depot_officer_armor[offered.type] || GLOB.depot_military_armor[offered.type] || GLOB.depot_collector_pieces[offered.type]) + // Planet megafauna materials: armor-grade feedstock the depot can't lathe /datum/shop_buyback/outfitter/goliath_plates name = "goliath hide plates" @@ -839,6 +855,240 @@ demand_min = 3 demand_max = 5 +// --- Rare arms and armor: exact types, priced by gear rating --- + +/// Yellow-tier armor with no shelf, plus the depot's own ablative vest (1 voucher + 3,600 cr new). +GLOBAL_LIST_INIT(depot_officer_armor, buyback_exact_cache(list( + /obj/item/clothing/suit/armor/hos, + /obj/item/clothing/suit/armor/hos/trenchcoat, + /obj/item/clothing/suit/armor/hos/trenchcoat/winter, + /obj/item/clothing/suit/armor/vest/capcarapace, + /obj/item/clothing/suit/armor/vest/capcarapace/syndicate, + /obj/item/clothing/suit/armor/vest/capcarapace/captains_formal, + /obj/item/clothing/suit/armor/vest/marine/sulaco, + /obj/item/clothing/suit/armor/reactive/teleport, + /obj/item/clothing/suit/armor/swat, + /obj/item/clothing/suit/armor/riot/knight/warlord, + /obj/item/clothing/suit/armor/laserproof, + /obj/item/clothing/suit/costume/pirate/armored, + /obj/item/clothing/suit/costume/pirate/captain/armored, + /obj/item/clothing/head/helmet/swat, + /obj/item/clothing/head/helmet/knight/warlord, + /obj/item/clothing/head/costume/pirate/armored, + /obj/item/clothing/head/costume/pirate/bandana/armored, +))) + +/// Red-tier armor: no shelf, no lathe, no cargo pack. Red caches and megafauna. +GLOBAL_LIST_INIT(depot_military_armor, buyback_exact_cache(list( + /obj/item/clothing/suit/armor/heavy, + /obj/item/clothing/suit/armor/vest/marine, + /obj/item/clothing/suit/armor/vest/marine/pmc, + /obj/item/clothing/suit/armor/vest/marine/security, + /obj/item/clothing/suit/hooded/berserker, + /obj/item/clothing/suit/hooded/hostile_environment, + /obj/item/clothing/head/helmet/marine, + /obj/item/clothing/head/helmet/marine/pmc, + /obj/item/shield/energy, +))) + +/// Yellow-tier arms. Shelf ones start at 1,125 cr (peddler laser), so 300 cr is under a third of any of them. +GLOBAL_LIST_INIT(depot_service_arms, buyback_exact_cache(list( + /obj/item/gun/energy/laser, + /obj/item/gun/energy/e_gun, + /obj/item/gun/energy/e_gun/lethal, + /obj/item/gun/energy/e_gun/old, + /obj/item/gun/energy/e_gun/hos, + /obj/item/gun/energy/laser/captain, + /obj/item/gun/energy/laser/retro, + /obj/item/gun/energy/laser/retro/old, + /obj/item/gun/energy/laser/luxurypaywall, + /obj/item/gun/energy/ionrifle, + /obj/item/gun/energy/disabler/smg, + /obj/item/gun/energy/laser/carbine/cybersun/unrestricted, + /obj/item/gun/ballistic/automatic/c20r/unrestricted, + /obj/item/gun/ballistic/automatic/wt550, + /obj/item/gun/ballistic/automatic/mini_uzi, + /obj/item/gun/ballistic/automatic/pistol/aps, + /obj/item/gun/ballistic/automatic/pistol/deagle, + /obj/item/gun/ballistic/automatic/pistol/deagle/camo, + /obj/item/gun/ballistic/automatic/pistol/deagle/gold, + /obj/item/gun/ballistic/automatic/proto/unrestricted, + /obj/item/gun/ballistic/revolver, + /obj/item/gun/ballistic/revolver/mateba, + /obj/item/gun/ballistic/revolver/nagant, + /obj/item/gun/ballistic/revolver/golden, + /obj/item/gun/ballistic/revolver/grenadelauncher/unrestricted, + /obj/item/gun/ballistic/rifle/boltaction, + /obj/item/gun/ballistic/rifle/boltaction/donkrifle, + /obj/item/gun/ballistic/shotgun/automatic/dual_tube, + /obj/item/gun/syringe/syndicate, + /obj/item/claymore, + /obj/item/claymore/cutlass, + /obj/item/claymore/cutlass/old, + /obj/item/fireaxe/boardingaxe, +))) + +/// Red-tier arms the peddler or a crafting kit can supply (4,950-6,600 cr new), so credits only. +GLOBAL_LIST_INIT(depot_heavy_arms, buyback_exact_cache(list( + /obj/item/gun/energy/laser/carbine, + /obj/item/gun/energy/lasercannon/unrestricted, + /obj/item/gun/energy/laser/scatter, + /obj/item/gun/energy/laser/hellgun, + /obj/item/gun/energy/e_gun/nuclear, + /obj/item/gun/energy/xray, + /obj/item/gun/ballistic/shotgun/automatic/combat, + /obj/item/gun/ballistic/shotgun/bulldog/unrestricted, + /obj/item/gun/ballistic/automatic/tommygun, + /obj/item/katana, + /obj/item/melee/energy/sword/pirate, + /obj/item/melee/energy/sword/saber, + /obj/item/melee/energy/sword/saber/blue, + /obj/item/melee/energy/sword/saber/purple, + /obj/item/melee/energy/sword/saber/red, +))) + +/// Red-tier arms with no buy, print or order route at all. +GLOBAL_LIST_INIT(depot_military_arms, buyback_exact_cache(list( + /obj/item/gun/ballistic/automatic/ar, + /obj/item/gun/ballistic/automatic/l6_saw/unrestricted, + /obj/item/gun/ballistic/automatic/m90/unrestricted, + /obj/item/gun/ballistic/rifle/boltaction/prime, + /obj/item/gun/ballistic/rifle/sniper_rifle, + /obj/item/gun/ballistic/rocketlauncher/unrestricted, + /obj/item/mjollnir, + /obj/item/spear/grey_tide, +))) + +/// Above-tier finds: authored uniques and megafauna prizes. Never on any shelf. +/// The soulscythe is left off on purpose: it can hold a player's soul. +GLOBAL_LIST_INIT(depot_collector_pieces, buyback_exact_cache(list( + /obj/item/gun/ballistic/revolver/c38/housecall, + /obj/item/gun/ballistic/shotgun/musket/no_quarter, + /obj/item/gun/magic/hook/marlinspike, + /obj/item/cain_and_abel, + /obj/item/cane/shepherds_crook, + /obj/item/claymore/cutlass/parley, + /obj/item/cursed_katana, + /obj/item/energy_katana, + /obj/item/garrison_standard, + /obj/item/heave_ho, + /obj/item/hierophant_club, + /obj/item/knife/understudy, + /obj/item/lava_staff, + /obj/item/melee/cleaving_saw, + /obj/item/melee/ghost_sword, + /obj/item/melee/verdigris_staff, + /obj/item/veilrender, + /obj/item/shield/riot/phalanx_buckler, + /obj/item/clothing/suit/armor/hos/trenchcoat/heirloom_coat, + /obj/item/clothing/suit/hooded/cloak/second_shadow, + /obj/item/clothing/suit/hooded/explorer/second_season_duster, + /obj/item/clothing/suit/the_occasion, + /obj/item/clothing/suit/toggle/labcoat/eventide_courier, + /obj/item/clothing/suit/wizrobe/verdigris, + /obj/item/clothing/head/stage_presence, + /obj/item/clothing/head/wizard/verdigris, +))) + +/** + * A row that takes an exact list of types (see buyback_listed.dm). Loose goods + * only, never shop stock, never a hull's own kit. + */ +/datum/shop_buyback/outfitter/listed + item_path = /obj/item + category = "Arms & Armor" + /// The GLOB typecache this row buys from + var/list/wanted_cache + /// Item whose sprite the ledger shows + var/obj/item/display_path + +/datum/shop_buyback/outfitter/listed/New() + ..() + buyback_use_display_icon(src, display_path) + +/datum/shop_buyback/outfitter/listed/buyback_wanted_kind(obj/item/offered) + return wanted_cache?[offered.type] + +/datum/shop_buyback/outfitter/listed/matches(obj/item/offered) + if(!..()) + return FALSE + return buyback_wanted_kind(offered) && !offered.buyback_hull_issue && buyback_goods_loose(offered) + +/datum/shop_buyback/outfitter/listed/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +/datum/shop_buyback/outfitter/listed/officer_armor + name = "officer's armor" + desc = "Commanders' coats, carapaces, tactical helmets. Good armor with someone else's rank still on it." + display_path = /obj/item/clothing/suit/armor/hos + pay_credits = 350 + demand_min = 2 + demand_max = 4 + +/datum/shop_buyback/outfitter/listed/officer_armor/New() + wanted_cache = GLOB.depot_officer_armor + return ..() + +/datum/shop_buyback/outfitter/listed/military_armor + name = "military armor" + desc = "Marine plate, heavy vests and their helmets. The depot can't get it through any honest channel." + display_path = /obj/item/clothing/suit/armor/vest/marine + pay_vouchers = 1 + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/outfitter/listed/military_armor/New() + wanted_cache = GLOB.depot_military_armor + return ..() + +/datum/shop_buyback/outfitter/listed/service_arms + name = "service arms" + desc = "Sidearms, rifles and boarding blades in working order. Sarge test-fires everything before it goes on a rack." + display_path = /obj/item/gun/energy/e_gun + pay_credits = 300 + demand_min = 3 + demand_max = 5 + +/datum/shop_buyback/outfitter/listed/service_arms/New() + wanted_cache = GLOB.depot_service_arms + return ..() + +/datum/shop_buyback/outfitter/listed/heavy_arms + name = "heavy arms" + desc = "Laser cannons, combat shotguns, energy blades. Sarge knows a buyer for every one of them." + display_path = /obj/item/gun/energy/lasercannon/unrestricted + pay_credits = 900 + demand_min = 2 + demand_max = 4 + +/datum/shop_buyback/outfitter/listed/heavy_arms/New() + wanted_cache = GLOB.depot_heavy_arms + return ..() + +/datum/shop_buyback/outfitter/listed/military_arms + name = "military arms" + desc = "Machine guns, marksman rifles, launchers. The kind of thing nobody admits to losing." + display_path = /obj/item/gun/ballistic/automatic/l6_saw/unrestricted + pay_vouchers = 1 + demand_min = 1 + demand_max = 3 + +/datum/shop_buyback/outfitter/listed/military_arms/New() + wanted_cache = GLOB.depot_military_arms + return ..() + +/datum/shop_buyback/outfitter/listed/collector_pieces + name = "one-of-a-kind pieces" + desc = "Named blades, heirloom guns, the gear people tell stories about. Sarge keeps a short list of collectors." + display_path = /obj/item/claymore/cutlass/parley + pay_vouchers = 2 + demand_min = 1 + demand_max = 2 + +/datum/shop_buyback/outfitter/listed/collector_pieces/New() + wanted_cache = GLOB.depot_collector_pieces + return ..() + // Barter: the depot always needs hull stock /datum/shop_sku/barter/plasteel_for_shield zone_permission = ZONE_PERMISSION_YELLOW diff --git a/voidcrew/modules/trade/shop_catalog_outfitter_vendors.dm b/voidcrew/modules/trade/shop_catalog_outfitter_vendors.dm index 54aadded283..21d3584acca 100644 --- a/voidcrew/modules/trade/shop_catalog_outfitter_vendors.dm +++ b/voidcrew/modules/trade/shop_catalog_outfitter_vendors.dm @@ -17,8 +17,9 @@ * carries them) and anomaly charts. Both sit on small weighted rotations of * two slots, one unit each. A sold slot turns over to a different type at * the next convoy. Both take the normal specials. The - * 400 cr core buyback is far below any core's price, so buying to resell - * loses money. + * core buybacks sit far below any core's price, and a core refined from a + * bought raw core keeps the shop's stamp (buyback_listed.dm), so it can't + * be sold back at all. * - The buyback ledger only wants what a ship can't print: anomaly cores, * slime extracts, and raw exotics out of the ground. No circuit boards. * Anything a lathe spits out is a money loop waiting to happen. @@ -98,7 +99,18 @@ ) buyback_types = list( /datum/shop_buyback/skunk/anomaly_core, + /datum/shop_buyback/skunk/anomaly_core/uncommon, + /datum/shop_buyback/skunk/anomaly_core/rare, + /datum/shop_buyback/skunk/anomaly_core/raw, + /datum/shop_buyback/skunk/anomaly_core/raw/uncommon, + /datum/shop_buyback/skunk/anomaly_core/raw/rare, /datum/shop_buyback/skunk/slime_extract, + /datum/shop_buyback/skunk/slime_extract/common, + /datum/shop_buyback/skunk/slime_extract/rare, + /datum/shop_buyback/skunk/slime_extract/exotic, + /datum/shop_buyback/skunk/slime_extract/rainbow, + /datum/shop_buyback/skunk/crossbred, + /datum/shop_buyback/skunk/crossbred/rare, /datum/shop_buyback/skunk/bluespace_crystal, /datum/shop_buyback/skunk/uranium, ) @@ -365,23 +377,278 @@ // ===== BOFFIN'S SPECIMEN LEDGER (buybacks) ===== // Nothing a lathe can print. Planet exotics and things that glow wrong. +// Anomaly cores, priced the way his own shelf weights them: flux, grav, +// hallucination and pyro turn up most; bioscrambler, ectoplasm and dimensional +// less; bluespace and vortex rarely. "Raw" is /obj/item/raw_anomaly_core, the +// sealed core that still needs the refinery's implosion; a refined core +// (/obj/item/assembly/signaler/anomaly) is what drops when a crew neutralizes a +// live anomaly. Raw cores on his shelf cost 8,000-12,000 cr, and the refinery +// carries the shop's stamp onto the refined core, so neither can be sold back. + /datum/shop_buyback/skunk/anomaly_core - name = "anomaly core (any)" - desc = "An intact core out of a collapsed anomaly. Boffin pays full rate and asks that you not shake the container. He asks this several times." - category = "Specimens" + name = "anomaly core" + desc = "An intact core out of a collapsed anomaly. Boffin pays well and asks that you not shake the container. He asks this several times." + category = "Anomalies" item_path = /obj/item/assembly/signaler/anomaly - pay_credits = 400 + pay_credits = 800 + demand_min = 2 + demand_max = 4 + /// Exact core types this row takes + var/list/core_types = list( + /obj/item/assembly/signaler/anomaly/flux, + /obj/item/assembly/signaler/anomaly/grav, + /obj/item/assembly/signaler/anomaly/hallucination, + /obj/item/assembly/signaler/anomaly/pyro, + ) + var/list/core_cache + /// Core whose sprite the ledger shows + var/obj/item/display_path = /obj/item/assembly/signaler/anomaly/flux + +/datum/shop_buyback/skunk/anomaly_core/New() + ..() + core_cache = buyback_exact_cache(core_types) + buyback_use_display_icon(src, display_path) + +/datum/shop_buyback/skunk/anomaly_core/buyback_wanted_kind(obj/item/offered) + return core_cache?[offered.type] + +/datum/shop_buyback/skunk/anomaly_core/matches(obj/item/offered) + if(!..()) + return FALSE + // Loose only: a core seated in a MOD module or a device stays where it is + return buyback_wanted_kind(offered) && buyback_goods_loose(offered) + +/datum/shop_buyback/skunk/anomaly_core/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +/datum/shop_buyback/skunk/anomaly_core/uncommon + name = "uncommon anomaly core" + desc = "Bioscrambler, ectoplasmic or dimensional. Boffin has a shelf for each and they are all nearly empty." + pay_credits = 1500 demand_min = 2 demand_max = 3 + core_types = list( + /obj/item/assembly/signaler/anomaly/bioscrambler, + /obj/item/assembly/signaler/anomaly/ectoplasm, + /obj/item/assembly/signaler/anomaly/dimensional, + ) + display_path = /obj/item/assembly/signaler/anomaly/dimensional + +/datum/shop_buyback/skunk/anomaly_core/rare + name = "bluespace or vortex core" + desc = "The two he has never managed to buy twice. He'll pay in vouchers, which he hates parting with." + pay_credits = 0 + pay_vouchers = 2 + demand_min = 1 + demand_max = 2 + core_types = list( + /obj/item/assembly/signaler/anomaly/bluespace, + /obj/item/assembly/signaler/anomaly/vortex, + ) + display_path = /obj/item/assembly/signaler/anomaly/vortex + +/datum/shop_buyback/skunk/anomaly_core/raw + name = "raw anomaly core" + desc = "A sealed core nobody has run through a refinery yet. Boffin has a refinery. He also has a long list of complaints about it." + category = "Anomalies" + item_path = /obj/item/raw_anomaly_core + pay_credits = 400 + demand_min = 1 + demand_max = 2 + core_types = list( + /obj/item/raw_anomaly_core/flux, + /obj/item/raw_anomaly_core/grav, + /obj/item/raw_anomaly_core/hallucination, + /obj/item/raw_anomaly_core/pyro, + ) + display_path = /obj/item/raw_anomaly_core/flux + +/datum/shop_buyback/skunk/anomaly_core/raw/uncommon + name = "uncommon raw core" + desc = "Unrefined bioscrambler, ectoplasmic or dimensional cores." + pay_credits = 700 + core_types = list( + /obj/item/raw_anomaly_core/bioscrambler, + /obj/item/raw_anomaly_core/ectoplasm, + /obj/item/raw_anomaly_core/dimensional, + ) + display_path = /obj/item/raw_anomaly_core/dimensional + +/datum/shop_buyback/skunk/anomaly_core/raw/rare + name = "raw bluespace or vortex core" + desc = "Unrefined, and still the best thing anyone has brought him all week." + pay_credits = 1200 + core_types = list( + /obj/item/raw_anomaly_core/bluespace, + /obj/item/raw_anomaly_core/vortex, + ) + display_path = /obj/item/raw_anomaly_core/vortex + +// Slime extracts by colour, following the mutation ladder from grey to +// rainbow. Only whole, unspent extracts: a cored-out one is jelly. Ship labs +// make these, so only rainbow and the rarer crossbreeds pay vouchers, on +// small demand that every crew shares. /datum/shop_buyback/skunk/slime_extract - name = "slime extract (any)" - desc = "Cores cut out of slimes. Every color does something different, and Boffin intends to try all of them." - category = "Specimens" + name = "grey slime extract" + desc = "Every lab's first extract. Boffin keeps a jar of them for when he runs out of the interesting ones." + category = "Slime Extracts" item_path = /obj/item/slime_extract - pay_credits = 200 + pay_credits = 50 + demand_min = 4 + demand_max = 8 + /// Exact extract types this row takes + var/list/extract_types = list(/obj/item/slime_extract/grey) + var/list/extract_cache + /// Extract whose sprite the ledger shows + var/obj/item/display_path = /obj/item/slime_extract/grey + +/datum/shop_buyback/skunk/slime_extract/New() + ..() + extract_cache = buyback_exact_cache(extract_types) + buyback_use_display_icon(src, display_path) + +/datum/shop_buyback/skunk/slime_extract/buyback_wanted_kind(obj/item/offered) + return extract_cache?[offered.type] + +/datum/shop_buyback/skunk/slime_extract/matches(obj/item/offered) + if(!..()) + return FALSE + if(!buyback_wanted_kind(offered) || !buyback_goods_loose(offered)) + return FALSE + var/obj/item/slime_extract/extract = offered + // Spent cores are jelly, and a recurring crossbreed's core belongs to it + return extract.extract_uses > 0 && !extract.recurring + +/datum/shop_buyback/skunk/slime_extract/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +/datum/shop_buyback/skunk/slime_extract/common + name = "common slime extract" + desc = "Orange, purple, blue, metal, yellow, dark purple, dark blue or silver." + pay_credits = 150 + demand_min = 3 + demand_max = 6 + extract_types = list( + /obj/item/slime_extract/orange, + /obj/item/slime_extract/purple, + /obj/item/slime_extract/blue, + /obj/item/slime_extract/metal, + /obj/item/slime_extract/yellow, + /obj/item/slime_extract/darkpurple, + /obj/item/slime_extract/darkblue, + /obj/item/slime_extract/silver, + ) + display_path = /obj/item/slime_extract/orange + +/datum/shop_buyback/skunk/slime_extract/rare + name = "rare slime extract" + desc = "Bluespace, sepia, cerulean or pyrite. The ones that start doing strange things to the room." + pay_credits = 300 demand_min = 3 demand_max = 5 + extract_types = list( + /obj/item/slime_extract/bluespace, + /obj/item/slime_extract/sepia, + /obj/item/slime_extract/cerulean, + /obj/item/slime_extract/pyrite, + ) + display_path = /obj/item/slime_extract/bluespace + +/datum/shop_buyback/skunk/slime_extract/exotic + name = "exotic slime extract" + desc = "Red, green, pink, gold, oil, black, light pink or adamantine. Boffin has a waiting list for most of them." + pay_credits = 550 + demand_min = 2 + demand_max = 4 + extract_types = list( + /obj/item/slime_extract/red, + /obj/item/slime_extract/green, + /obj/item/slime_extract/pink, + /obj/item/slime_extract/gold, + /obj/item/slime_extract/oil, + /obj/item/slime_extract/black, + /obj/item/slime_extract/lightpink, + /obj/item/slime_extract/adamantine, + ) + display_path = /obj/item/slime_extract/adamantine + +/datum/shop_buyback/skunk/slime_extract/rainbow + name = "rainbow slime extract" + desc = "The end of the ladder. Boffin has seen two in his life and wants a third." + pay_credits = 0 + pay_vouchers = 1 + demand_min = 1 + demand_max = 2 + extract_types = list(/obj/item/slime_extract/rainbow) + display_path = /obj/item/slime_extract/rainbow + +/// Crossbreeds, priced by the colour of the slime that made them. Self-sustaining +/// ones split on the spot and are never offered whole, so they're left out. +/datum/shop_buyback/skunk/crossbred + name = "crossbred extract" + desc = "Any crossbreed off a common slime. Ten extracts went into each, which is the part Boffin respects." + category = "Slime Extracts" + item_path = /obj/item/slimecross + pay_credits = 450 + demand_min = 2 + demand_max = 3 + /// Slime colours (SLIME_TYPE_*) this row takes + var/list/colours = list( + SLIME_TYPE_GREY, + SLIME_TYPE_ORANGE, + SLIME_TYPE_PURPLE, + SLIME_TYPE_BLUE, + SLIME_TYPE_METAL, + SLIME_TYPE_YELLOW, + SLIME_TYPE_DARK_PURPLE, + SLIME_TYPE_DARK_BLUE, + SLIME_TYPE_SILVER, + ) + /// Crossbreed whose sprite the ledger shows + var/obj/item/display_path = /obj/item/slimecross/stabilized/grey + +/datum/shop_buyback/skunk/crossbred/New() + ..() + buyback_use_display_icon(src, display_path) + +/datum/shop_buyback/skunk/crossbred/buyback_wanted_kind(obj/item/offered) + if(!istype(offered, /obj/item/slimecross) || istype(offered, /obj/item/slimecross/selfsustaining)) + return FALSE + var/obj/item/slimecross/cross = offered + return cross.colour in colours + +/datum/shop_buyback/skunk/crossbred/matches(obj/item/offered) + if(!..()) + return FALSE + return buyback_wanted_kind(offered) && buyback_goods_loose(offered) + +/datum/shop_buyback/skunk/crossbred/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +/datum/shop_buyback/skunk/crossbred/rare + name = "rare crossbred extract" + desc = "A crossbreed off a rare slime, up to rainbow. Stabilized ones especially; he wears three." + pay_credits = 0 + pay_vouchers = 1 + demand_min = 1 + demand_max = 3 + colours = list( + SLIME_TYPE_BLUESPACE, + SLIME_TYPE_SEPIA, + SLIME_TYPE_CERULEAN, + SLIME_TYPE_PYRITE, + SLIME_TYPE_RED, + SLIME_TYPE_GREEN, + SLIME_TYPE_PINK, + SLIME_TYPE_GOLD, + SLIME_TYPE_OIL, + SLIME_TYPE_BLACK, + SLIME_TYPE_LIGHT_PINK, + SLIME_TYPE_ADAMANTINE, + SLIME_TYPE_RAINBOW, + ) + display_path = /obj/item/slimecross/stabilized/rainbow /datum/shop_buyback/skunk/bluespace_crystal name = "bluespace crystals" diff --git a/voidcrew/modules/trade/shop_catalog_suit_vendor.dm b/voidcrew/modules/trade/shop_catalog_suit_vendor.dm index 5563133983a..b1a65516c61 100644 --- a/voidcrew/modules/trade/shop_catalog_suit_vendor.dm +++ b/voidcrew/modules/trade/shop_catalog_suit_vendor.dm @@ -22,10 +22,11 @@ * - The core shelf is the ladder spine; the rotating and rare pools carry the * breadth, so a round shows a slice of ~200 modules rather than all of them. * Plating rotates on purpose: which themes you can BUILD varies by round. - * - Buybacks are credits-only and deliberately narrow. Modules, frame parts - * and plating are all mechfab-printable, so buying them back would be a - * money loop for any crew with a fabricator. Wick only buys things no lathe - * makes: dead cores and whole salvaged suits. + * - Buybacks stay narrow. Frame parts, plating and the common modules are + * mechfab-printable, so buying them back would be a money loop for any crew + * with a fabricator. Wick buys dead cores, whole suits (by theme: only the + * unprintable combat themes pay vouchers), anomaly modules with a field core + * seated, and the handful of modules no lathe or shelf supplies. */ // ========================================================================= @@ -189,11 +190,37 @@ /datum/shop_sku/fitter/rare/mod_projectile_dampener, /datum/shop_sku/fitter/rare/bomb_suit, ) - // Credits only, and only things no fabricator makes: dead cores and whole - // suits off whoever stopped needing them + // Dead cores and whole suits off whoever stopped needing them, the rare + // suits and modules by name. Keep scrap_control ahead of the rare suit rows: + // get_counter_value() prices the salvaged-suit contract off the first match. buyback_types = list( /datum/shop_buyback/fitter/broken_core, /datum/shop_buyback/fitter/scrap_control, + /datum/shop_buyback/fitter/rare_suit/civilian, + /datum/shop_buyback/fitter/rare_suit/cosmohonk, + /datum/shop_buyback/fitter/rare_suit/engineering, + /datum/shop_buyback/fitter/rare_suit/medical, + /datum/shop_buyback/fitter/rare_suit/atmospheric, + /datum/shop_buyback/fitter/rare_suit/loader, + /datum/shop_buyback/fitter/rare_suit/mining, + /datum/shop_buyback/fitter/rare_suit/research, + /datum/shop_buyback/fitter/rare_suit/rescue, + /datum/shop_buyback/fitter/rare_suit/security, + /datum/shop_buyback/fitter/rare_suit/prototype, + /datum/shop_buyback/fitter/rare_suit/advanced, + /datum/shop_buyback/fitter/rare_suit/responsory, + /datum/shop_buyback/fitter/rare_suit/syndicate, + /datum/shop_buyback/fitter/rare_suit/safeguard, + /datum/shop_buyback/fitter/rare_suit/interdyne, + /datum/shop_buyback/fitter/rare_suit/infiltrator, + /datum/shop_buyback/fitter/rare_suit/elite, + /datum/shop_buyback/fitter/rare_suit/magnate, + /datum/shop_buyback/fitter/rare_suit/enchanted, + /datum/shop_buyback/fitter/rare_suit/spider_clan, + /datum/shop_buyback/fitter/anomaly_module, + /datum/shop_buyback/fitter/anomaly_module/teleporter, + /datum/shop_buyback/fitter/rare_module, + /datum/shop_buyback/fitter/rare_module/combat, /datum/shop_buyback/fitter/salvage_spacesuit, /datum/shop_buyback/fitter/salvage_space_helmet, ) @@ -899,9 +926,12 @@ // ========================================================================= // WICK'S SALVAGE BENCH (buybacks) -// Credits only, and nothing a fabricator prints. Modules, frame parts and -// plating are all MECHFAB designs. Buying those back would be a money loop -// for any crew with an exosuit fabricator, so Wick doesn't take them. +// Nothing a fabricator prints pays more than scrap. Frame parts, plating and +// most modules are MECHFAB designs, so Wick doesn't take them loose. Whole +// suits are priced theme by theme: printable work themes pay little more than +// their materials, the rest about a quarter of shelf price, and the unprintable +// combat themes vouchers (well under the black market's voucher prices). A suit +// mapped aboard a player hull, or a theme with no row, only sells as scrap. // ========================================================================= /datum/shop_buyback/fitter/broken_core @@ -914,11 +944,11 @@ demand_max = 3 /datum/shop_buyback/fitter/scrap_control - name = "MOD control unit (any)" - desc = "A whole suit with its core seated, working or not, modules included. Wick strips it to the frame and asks nothing about the previous owner." + name = "scrap MODsuit" + desc = "Any other suit with its core seated, working or not. Wick strips it to the frame and asks nothing about the previous owner." category = "Suit Salvage" item_path = /obj/item/mod/control - pay_credits = 500 + pay_credits = 100 demand_min = 2 demand_max = 3 @@ -929,12 +959,348 @@ * * It also has to have a core. A frame and plating print for about 100 cr, so a * coreless unit was a money loop: sell it, wrench the core out of the next one. + * For the same reason the core can't be shop stock (Wick's shelf, cargo). */ /datum/shop_buyback/fitter/scrap_control/matches(obj/item/offered) if(!..()) return FALSE var/obj/item/mod/control/suit = offered - return isnull(suit.wearer) && !isnull(suit.core) + if(!isnull(suit.wearer) || isnull(suit.core) || is_trader_good(suit.core)) + return FALSE + // A rare theme goes to its own row; the ship's own suits still sell here as scrap + return suit.buyback_hull_issue || !buyback_rare_mod_theme(suit) + +/// Every theme that has its own row on Wick's bench, built from the rows themselves. +GLOBAL_LIST_INIT(fitter_suit_row_themes, init_fitter_suit_row_themes()) + +/proc/init_fitter_suit_row_themes() + var/list/themes = list() + for(var/row_type in subtypesof(/datum/shop_buyback/fitter/rare_suit)) + var/datum/shop_buyback/fitter/rare_suit/row = new row_type + for(var/theme in row.theme_types) + themes[theme] = TRUE + qdel(row) + return themes + +/// Whether a suit's theme belongs to one of Wick's named rows. +/proc/buyback_rare_mod_theme(obj/item/mod/control/suit) + var/theme_type = suit.theme?.type + if(!theme_type) + return FALSE + return !!GLOB.fitter_suit_row_themes[theme_type] + +/** + * A whole suit of one theme. Off a body, core seated, the core not shop stock, + * and not one of the suits the crew's own hull came with. Each theme pays + * roughly a quarter of what a shelf asks for it. Themes whose plating a + * fabricator prints pay little more than the materials. + */ +/datum/shop_buyback/fitter/rare_suit + category = "Suits" + item_path = /obj/item/mod/control + demand_min = 1 + demand_max = 3 + /// The themes this row buys + var/list/theme_types + /// Control unit sprites are picked by theme at runtime, so name the state + var/display_state + +/datum/shop_buyback/fitter/rare_suit/New() + ..() + icon_override = 'icons/obj/clothing/modsuit/mod_clothing.dmi' + icon_state_override = display_state + +/datum/shop_buyback/fitter/rare_suit/buyback_wanted_kind(obj/item/offered) + if(!istype(offered, /obj/item/mod/control)) + return FALSE + var/obj/item/mod/control/suit = offered + return suit.theme && (suit.theme.type in theme_types) + +/datum/shop_buyback/fitter/rare_suit/matches(obj/item/offered) + if(!..()) + return FALSE + if(!buyback_wanted_kind(offered) || offered.buyback_hull_issue || !buyback_goods_loose(offered)) + return FALSE + var/obj/item/mod/control/suit = offered + return isnull(suit.wearer) && !isnull(suit.core) && !is_trader_good(suit.core) + +/datum/shop_buyback/fitter/rare_suit/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +// Work suits. Civilian, engineering, atmospheric, medical and cosmohonk plating all print. + +/datum/shop_buyback/fitter/rare_suit/civilian + name = "civilian MODsuit" + desc = "The suit every hauler starts in. Wick has a crate of them." + theme_types = list(/datum/mod_theme/civilian) + display_state = "civilian-control" + pay_credits = 100 + demand_min = 2 + demand_max = 4 + +/datum/shop_buyback/fitter/rare_suit/cosmohonk + name = "cosmohonk MODsuit" + desc = "Wick takes it so nobody else has to look at it." + theme_types = list(/datum/mod_theme/cosmohonk) + display_state = "cosmohonk-control" + pay_credits = 100 + demand_max = 2 + +/datum/shop_buyback/fitter/rare_suit/engineering + name = "engineering MODsuit" + desc = "Yellow, scuffed and built to be stood in a fire." + theme_types = list(/datum/mod_theme/engineering) + display_state = "engineering-control" + pay_credits = 150 + +/datum/shop_buyback/fitter/rare_suit/medical + name = "medical MODsuit" + desc = "Clean white plating. Wick wipes it down anyway." + theme_types = list(/datum/mod_theme/medical) + display_state = "medical-control" + pay_credits = 150 + +/datum/shop_buyback/fitter/rare_suit/atmospheric + name = "atmospheric MODsuit" + desc = "Heat-rated plating for people who walk into burning rooms on purpose." + theme_types = list(/datum/mod_theme/atmospheric) + display_state = "atmospheric-control" + pay_credits = 150 + +/datum/shop_buyback/fitter/rare_suit/loader + name = "loader MODsuit" + desc = "Cargo hydraulics. The arms still twitch when it's powered down." + theme_types = list(/datum/mod_theme/loader) + display_state = "loader-control" + pay_credits = 700 + +/datum/shop_buyback/fitter/rare_suit/mining + name = "mining MODsuit" + desc = "Ash-scoured and dented by things with teeth." + theme_types = list(/datum/mod_theme/mining) + display_state = "mining-control" + pay_credits = 900 + +/datum/shop_buyback/fitter/rare_suit/research + name = "research MODsuit" + desc = "Blast plating with a scientist's coffee stains on the inside." + theme_types = list(/datum/mod_theme/research) + display_state = "research-control" + pay_credits = 900 + +/datum/shop_buyback/fitter/rare_suit/rescue + name = "rescue MODsuit" + desc = "Paramedic plating, built to run into a firefight and back out." + theme_types = list(/datum/mod_theme/rescue) + display_state = "rescue-control" + pay_credits = 1000 + +// Armored suits + +/datum/shop_buyback/fitter/rare_suit/security + name = "security MODsuit" + desc = "Red-striped plating with the badge numbers ground off." + theme_types = list(/datum/mod_theme/security) + display_state = "security-control" + pay_credits = 1000 + +/datum/shop_buyback/fitter/rare_suit/prototype + name = "prototype MODsuit" + desc = "An early, heavy model. Collectors want them; nobody wants to wear one." + theme_types = list(/datum/mod_theme/prototype) + display_state = "prototype-control" + pay_credits = 1200 + +/datum/shop_buyback/fitter/rare_suit/advanced + name = "advanced MODsuit" + desc = "A chief engineer's suit. Wick knows three crews who'd kill for it, and one who did." + theme_types = list(/datum/mod_theme/advanced) + display_state = "advanced-control" + pay_credits = 1400 + +/datum/shop_buyback/fitter/rare_suit/responsory + name = "response team MODsuit" + desc = "Emergency response plating. Nobody ever comes to collect it." + theme_types = list(/datum/mod_theme/responsory, /datum/mod_theme/responsory/traitor) + display_state = "responsory-control" + pay_credits = 1500 + +// Combat suits + +/datum/shop_buyback/fitter/rare_suit/syndicate + name = "syndicate MODsuit" + desc = "Blood-red combat plating. Wick files the serials off before anyone asks." + theme_types = list(/datum/mod_theme/syndicate) + display_state = "syndicate-control" + pay_vouchers = 1 + demand_max = 2 + +/datum/shop_buyback/fitter/rare_suit/safeguard + name = "safeguard MODsuit" + desc = "A security chief's suit, still smelling of somebody's cigar." + theme_types = list(/datum/mod_theme/safeguard) + display_state = "safeguard-control" + pay_vouchers = 1 + demand_max = 2 + +/datum/shop_buyback/fitter/rare_suit/interdyne + name = "Interdyne MODsuit" + desc = "Interdyne's black and green. Their lawyers never come looking." + theme_types = list(/datum/mod_theme/interdyne) + display_state = "interdyne-control" + pay_vouchers = 2 + demand_max = 2 + +/datum/shop_buyback/fitter/rare_suit/infiltrator + name = "infiltrator MODsuit" + desc = "Thin, quiet plating. Wick doesn't ask what it was for." + theme_types = list(/datum/mod_theme/infiltrator) + display_state = "infiltrator-control" + pay_vouchers = 2 + demand_max = 2 + +/datum/shop_buyback/fitter/rare_suit/elite + name = "elite MODsuit" + desc = "Black and red assault plating. Wick has buyers who don't haggle." + theme_types = list(/datum/mod_theme/elite) + display_state = "elite-control" + pay_vouchers = 2 + demand_max = 2 + +/datum/shop_buyback/fitter/rare_suit/magnate + name = "magnate MODsuit" + desc = "A captain's suit, gold trim and all." + theme_types = list(/datum/mod_theme/magnate) + display_state = "magnate-control" + pay_vouchers = 2 + demand_max = 2 + +/datum/shop_buyback/fitter/rare_suit/enchanted + name = "enchanted MODsuit" + desc = "It hums in a key Wick doesn't like. He'll take it anyway." + theme_types = list(/datum/mod_theme/enchanted) + display_state = "enchanted-control" + pay_vouchers = 2 + demand_max = 1 + +/datum/shop_buyback/fitter/rare_suit/spider_clan + name = "spider clan suit" + desc = "Wick has only ever seen one in a picture. He'd like to see one on his bench." + theme_types = list(/datum/mod_theme/ninja) + display_state = "ninja-control" + pay_vouchers = 3 + demand_max = 1 + +/** + * An anomaly module with a field core seated. The module prints, so the core + * is what's being paid for, a little over Boffin's price for the bare core. + * Loose modules only: one still installed goes with its suit. + */ +/datum/shop_buyback/fitter/anomaly_module + name = "anomaly module" + desc = "An anti-gravity or kinesis module with its core seated and humming. Wick fits them for crews who can't find a core of their own." + category = "Modules" + item_path = /obj/item/mod/module/anomaly_locked + pay_credits = 1200 + demand_min = 1 + demand_max = 3 + /// Exact module types this row takes + var/list/module_types = list( + /obj/item/mod/module/anomaly_locked/antigrav, + /obj/item/mod/module/anomaly_locked/kinesis, + ) + var/list/module_cache + /// Item whose sprite the ledger shows + var/obj/item/display_path = /obj/item/mod/module/anomaly_locked/antigrav + +/datum/shop_buyback/fitter/anomaly_module/New() + ..() + module_cache = buyback_exact_cache(module_types) + buyback_use_display_icon(src, display_path) + +/datum/shop_buyback/fitter/anomaly_module/buyback_wanted_kind(obj/item/offered) + return module_cache?[offered.type] + +/datum/shop_buyback/fitter/anomaly_module/matches(obj/item/offered) + if(!..()) + return FALSE + if(!buyback_wanted_kind(offered) || offered.buyback_hull_issue || !buyback_goods_loose(offered)) + return FALSE + var/obj/item/mod/module/anomaly_locked/module = offered + return !isnull(module.core) && !is_trader_good(module.core) + +/datum/shop_buyback/fitter/anomaly_module/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +/datum/shop_buyback/fitter/anomaly_module/teleporter + name = "teleporter module" + desc = "A teleporter module with a bluespace core seated. Wick wants one badly enough to pay in vouchers." + pay_credits = 0 + pay_vouchers = 2 + demand_min = 1 + demand_max = 1 + module_types = list(/obj/item/mod/module/anomaly_locked/teleporter) + display_path = /obj/item/mod/module/anomaly_locked/teleporter + +/** + * Modules no lathe prints and no shelf sells: they come out of rare suits. + * Credits only, since they usually arrive with a suit that already paid. + */ +/datum/shop_buyback/fitter/rare_module + name = "rare module" + desc = "Advanced magboots, night vision, ash plating, the odd syndicate fitting. Things Wick can't order." + category = "Modules" + item_path = /obj/item/mod/module + pay_credits = 400 + demand_min = 2 + demand_max = 4 + /// Exact module types this row takes + var/list/module_types = list( + /obj/item/mod/module/ash_accretion, + /obj/item/mod/module/infiltrator, + /obj/item/mod/module/night, + /obj/item/mod/module/sphere_transform, + /obj/item/mod/module/magboot/advanced, + /obj/item/mod/module/quick_carry/advanced, + /obj/item/mod/module/reagent_scanner/advanced, + /obj/item/mod/module/welding/syndicate, + /obj/item/mod/module/welding/camera_vision, + /obj/item/mod/module/weapon_recall, + /obj/item/mod/module/quick_cuff, + /obj/item/mod/module/shove_blocker/locked, + ) + var/list/module_cache + /// Item whose sprite the ledger shows + var/obj/item/display_path = /obj/item/mod/module/magboot/advanced + +/datum/shop_buyback/fitter/rare_module/New() + ..() + module_cache = buyback_exact_cache(module_types) + buyback_use_display_icon(src, display_path) + +/datum/shop_buyback/fitter/rare_module/buyback_wanted_kind(obj/item/offered) + return module_cache?[offered.type] + +/datum/shop_buyback/fitter/rare_module/matches(obj/item/offered) + if(!..()) + return FALSE + return buyback_wanted_kind(offered) && !offered.buyback_hull_issue && buyback_goods_loose(offered) + +/datum/shop_buyback/fitter/rare_module/get_denial_reason(mob/living/user) + return buyback_listed_denial(src, user) + +/datum/shop_buyback/fitter/rare_module/combat + name = "combat module" + desc = "Energy nets, combat defibrillators, hacking gloves. Wick doesn't fit these for anyone he likes." + pay_credits = 1000 + demand_min = 1 + demand_max = 2 + module_types = list( + /obj/item/mod/module/energy_net, + /obj/item/mod/module/defibrillator/combat, + /obj/item/mod/module/hacker, + ) + display_path = /obj/item/mod/module/energy_net /datum/shop_buyback/fitter/salvage_spacesuit name = "space suit (salvage)" diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 54ae6a7919c..609aaa01250 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -44,8 +44,19 @@ #include "voidcrew_bounty_admin.dm" #include "voidcrew_bounty_ai.dm" #include "voidcrew_bounty_board.dm" +#include "voidcrew_bounty_boss_reach.dm" #include "voidcrew_bounty_bosses.dm" +#include "voidcrew_bounty_chrome.dm" +#include "voidcrew_bounty_chrome_cascade.dm" +#include "voidcrew_bounty_chrome_deadeye.dm" +#include "voidcrew_bounty_chrome_gorilla.dm" +#include "voidcrew_bounty_chrome_lazarus.dm" +#include "voidcrew_bounty_chrome_mantis.dm" +#include "voidcrew_bounty_chrome_piledriver.dm" +#include "voidcrew_bounty_chrome_redline.dm" +#include "voidcrew_bounty_companions_backup.dm" #include "voidcrew_bounty_criminal.dm" +#include "voidcrew_bounty_cyberpsycho.dm" #include "voidcrew_bounty_guns.dm" #include "voidcrew_bounty_identity.dm" #include "voidcrew_bounty_kingpin.dm" @@ -53,8 +64,12 @@ #include "voidcrew_bounty_lair_maps.dm" #include "voidcrew_bounty_lairs.dm" #include "voidcrew_bounty_outpost.dm" +#include "voidcrew_bounty_pace.dm" #include "voidcrew_bounty_seams.dm" #include "voidcrew_bounty_suits.dm" +#include "voidcrew_buyback_barnaby.dm" +#include "voidcrew_buyback_depot.dm" +#include "voidcrew_buyback_vex.dm" #include "voidcrew_camera_scope.dm" #include "voidcrew_cargo_cart.dm" #include "voidcrew_cargo_docking.dm" @@ -65,6 +80,7 @@ #include "voidcrew_checkpoint_mergers.dm" #include "voidcrew_checkpoints.dm" #include "voidcrew_checkpoints_every_ship.dm" +#include "voidcrew_chrome_wheel.dm" #include "voidcrew_cloning_vat_claim.dm" #include "voidcrew_colosseum.dm" #include "voidcrew_combat_camera_breaches.dm" @@ -76,6 +92,22 @@ #include "voidcrew_crew_antag_gc.dm" #include "voidcrew_crew_hud.dm" #include "voidcrew_cyberware.dm" +#include "voidcrew_cyberware_anim.dm" +#include "voidcrew_cyberware_anim2.dm" +#include "voidcrew_cyberware_camo.dm" +#include "voidcrew_cyberware_deflect.dm" +#include "voidcrew_cyberware_final.dm" +#include "voidcrew_cyberware_kit.dm" +#include "voidcrew_cyberware_mantis.dm" +#include "voidcrew_cyberware_matrix.dm" +#include "voidcrew_cyberware_models_a.dm" +#include "voidcrew_cyberware_models_b.dm" +#include "voidcrew_cyberware_npcs.dm" +#include "voidcrew_cyberware_passives.dm" +#include "voidcrew_cyberware_soak.dm" +#include "voidcrew_cyberware_text.dm" +#include "voidcrew_cyberware_widowline.dm" +#include "voidcrew_cyberware_zoom.dm" #include "voidcrew_derelict_helpers.dm" #include "voidcrew_derelict_layout.dm" #include "voidcrew_derelict_leash.dm" @@ -89,11 +121,13 @@ #include "voidcrew_dynamic_events.dm" #include "voidcrew_economy_metrics.dm" #include "voidcrew_event_horizon.dm" +#include "voidcrew_exploration_sweep.dm" #include "voidcrew_fleet_waypoints.dm" #include "voidcrew_fresh_cores.dm" #include "voidcrew_gear_behaviour.dm" #include "voidcrew_gear_fixes.dm" #include "voidcrew_gene_injector_loot.dm" +#include "voidcrew_gorilla_gore.dm" #include "voidcrew_gun_feel.dm" #include "voidcrew_helm_access.dm" #include "voidcrew_helpers.dm" @@ -121,6 +155,8 @@ #include "voidcrew_lich.dm" #include "voidcrew_linda_space_share.dm" #include "voidcrew_loot.dm" +#include "voidcrew_mantis_gore.dm" +#include "voidcrew_mantis_swing.dm" #include "voidcrew_map_packing.dm" #include "voidcrew_mapload_floor_dir.dm" #include "voidcrew_medical_research_links.dm" @@ -131,6 +167,7 @@ #include "voidcrew_mission_console_rewards.dm" #include "voidcrew_mission_gps.dm" #include "voidcrew_mission_metrics.dm" +#include "voidcrew_mission_spawn_cover.dm" #include "voidcrew_missions.dm" #include "voidcrew_nanite_research.dm" #include "voidcrew_nanite_sync.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm index 67e25b387fb..b7b6d74ecd0 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm @@ -140,7 +140,7 @@ // A random kit is still a kit. 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]") + TEST_ASSERT((random_boss?.record?.kit in list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy", "cyberpsycho")), "A boss with a random kit has the kit [random_boss?.record?.kit]") // Bad requests are refused, with a reason and no log line. var/logged = length(panel.operations) @@ -354,7 +354,7 @@ // A boss record always has a kit. var/datum/bounty_record/boss_record = panel.admin_pool_add(operator, 3, "boss", null) // BOUNTY_TIER_MOST_WANTED - TEST_ASSERT((boss_record?.kit in list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy")), "A boss test record has the kit [boss_record?.kit]") + TEST_ASSERT((boss_record?.kit in list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy", "cyberpsycho")), "A boss test record has the kit [boss_record?.kit]") TEST_ASSERT_EQUAL(length(panel.pool_rows()), 2, "The pool does not list both records") // Through the menu: the list names the records, and a record added there joins. diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm index 7e83faaaf40..b9439b42f83 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm @@ -1071,6 +1071,22 @@ 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) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_boss_reach.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_boss_reach.dm new file mode 100644 index 00000000000..bbf9f942544 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_boss_reach.dm @@ -0,0 +1,561 @@ +/** + * Bounty hunting: the mini-bosses' reach, cover, Gorilla Arms smash, longer tells and the whole hunting + * crew at the site, for voidcrew/modules/bounties/bounty_boss.dm and bounty_boss_kits.dm (port package + * C5 of PR #507 onto the human bosses). + * + * 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, or one planning subtree, directly with the mob in place and + * its AI off; none waits on a timer or an AI walk. + */ + +/// Shared helpers for these tests; not a test itself +/datum/unit_test/voidcrew_bounty_boss/reach + abstract_type = /datum/unit_test/voidcrew_bounty_boss/reach + /// Turfs a test changed -> the type each had first, put back when it ends (outside the room they are space) + var/list/reach_turfs = list() + +/datum/unit_test/voidcrew_bounty_boss/reach/Destroy() + for(var/turf/changed as anything in reach_turfs) + changed.ChangeTurf(reach_turfs[changed]) + reach_turfs = null + return ..() + +// Remembers what the turf was, not plain floor: outside the test room it is space +/datum/unit_test/voidcrew_bounty_boss/reach/change_turf(turf/where, new_type) + if(isnull(reach_turfs[where])) + reach_turfs[where] = where.type + return where.ChangeTurf(new_type) + +/// The tile `dx`, `dy` from the test room's bottom-left corner, outside the room too (space on the test level until a test floors it) +/datum/unit_test/voidcrew_bounty_boss/reach/proc/outside(dx, dy) + return locate(clamp(run_loc_floor_bottom_left.x + dx, 1, world.maxx), clamp(run_loc_floor_bottom_left.y + dy, 1, world.maxy), run_loc_floor_bottom_left.z) + +/// Floors the rectangle `dx`..`dx2`, `dy`..`dy2` from the room's corner (outside the room), to be put back when the test ends +/datum/unit_test/voidcrew_bounty_boss/reach/proc/floor_area(dx, dy, dx2, dy2) + for(var/x_offset in dx to dx2) + for(var/y_offset in dy to dy2) + change_turf(outside(x_offset, y_offset), /turf/open/floor/iron) + +/// Whether `controller`'s last plan has `behavior_type` among its planned behaviours +/datum/unit_test/voidcrew_bounty_boss/reach/proc/planned(datum/ai_controller/controller, behavior_type) + return !!controller.planned_behaviors[GET_AI_BEHAVIOR(behavior_type)] + +/// Runs `boss`'s planning subtree of `subtree_type` once, as a planning pass would, and returns what it returned +/datum/unit_test/voidcrew_bounty_boss/reach/proc/plan_with(mob/living/carbon/human/npc/bounty_criminal/boss/boss, subtree_type) + var/datum/ai_controller/controller = boss.ai_controller + var/datum/ai_planning_subtree/subtree = locate(subtree_type) in controller.planning_subtrees + TEST_ASSERT_NOTNULL(subtree, "[boss.type] doesn't plan with [subtree_type]") + controller.planned_behaviors.Cut() + return subtree.SelectBehaviors(controller, 1) + +/// A boss of `boss_type` at `where` with its AI off, so it stays where the test puts it +/datum/unit_test/voidcrew_bounty_boss/reach/proc/boss_at(boss_type, turf/where) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = allocate(boss_type, where) + boss.ai_controller?.set_ai_status(AI_STATUS_OFF) + return boss + +/// A Juggernaut at `where` with a real pair of Gorilla Arms put in, the way an NPC gets its chrome (npc_install_cyberware()) +/datum/unit_test/voidcrew_bounty_boss/reach/proc/gorilla_boss(turf/where) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, where) + TEST_ASSERT_NOTNULL(boss.npc_install_cyberware(/obj/item/organ/cyberimp/cyberware/gorilla_arms), "The right Gorilla Arm didn't go in") + TEST_ASSERT_NOTNULL(boss.npc_install_cyberware(/obj/item/organ/cyberimp/cyberware/gorilla_arms/left), "The left Gorilla Arm didn't go in") + TEST_ASSERT_EQUAL(length(boss.boss_gorilla_arms()), 2, "The boss's Gorilla Arms aren't both working") + return boss + +/// Every arm's own punch cooldown over, and its body ready to click +/datum/unit_test/voidcrew_bounty_boss/reach/proc/ready_fists(mob/living/carbon/human/npc/bounty_criminal/boss/boss) + ready_hands(boss) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in boss.organs) + arm.slam_cooldown = 0 + +// ===== LONGER TELLS AND COVER LINES (review r2) ===== + +/datum/unit_test/voidcrew_bounty_boss/reach/tells + +/datum/unit_test/voidcrew_bounty_boss/reach/tells/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/ghost = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, spot(0, 0)) + var/datum/action/cooldown/mob_cooldown/bounty_boss/dash/dash = ability_of(ghost, /datum/action/cooldown/mob_cooldown/bounty_boss/dash) + TEST_ASSERT(abs(dash.windup - 6) < 0.01, "The Ghost's dash tell is [dash.windup / 10] s") // BOUNTY_GHOST_DASH_WINDUP 0.6 s + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac, spot(2, 0)) + var/datum/action/cooldown/mob_cooldown/bounty_boss/flamer/flamer = ability_of(pyro, /datum/action/cooldown/mob_cooldown/bounty_boss/flamer) + TEST_ASSERT(abs(flamer.windup - 8) < 0.01, "The flamer's tell is [flamer.windup / 10] s") // BOUNTY_PYROMANIAC_FLAMER_WINDUP 0.8 s + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/juggernaut = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(4, 0)) + var/datum/action/cooldown/mob_cooldown/bounty_boss/slam/slam = ability_of(juggernaut, /datum/action/cooldown/mob_cooldown/bounty_boss/slam) + TEST_ASSERT(abs(slam.windup - 8) < 0.01, "The slam's tell is [slam.windup / 10] s") // BOUNTY_JUGGERNAUT_SLAM_WINDUP 0.8 s + + // Every kit has its own lines for breaking cover (boss_bark("cover")), as many as any other context + var/list/lines = bounty_identity_strings("lines") + for(var/kit in list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy")) // BOUNTY_KIT_* + TEST_ASSERT(length(lines["[kit]_cover"]?["any"]) >= 6, "The [kit] has fewer than 6 lines for taking cover") + +// ===== THE WHOLE HUNTING CREW AT ITS SITE OWES COMPANIONS (review r1, r2; OC-8) ===== + +/** + * Turning hostile, it counts every crew member of a ship hunting it who is playing and at its site, + * seen or not: on the site, on its dock strip. One hunter can't wake it alone while the crew waits by + * the ship. Crew elsewhere on its level (another site in the same lattice), SSD crew, and strangers + * don't count. Each one beyond the first owes it a companion; nothing changes its health. + */ +/datum/unit_test/voidcrew_bounty_boss/reach/crews + /// The test crew, let go of its minds before it goes + var/datum/team/voidcrew/crew + +/datum/unit_test/voidcrew_bounty_boss/reach/crews/Run() + board_test_begin() + var/datum/criminal_bounty/posting = board_test_posting(3, null, 3400, 2, "boss") + posting.record.kit = "juggernaut" // BOUNTY_KIT_JUGGERNAUT + var/obj/structure/overmap/ship/ship = board_test_ship() + crew = new + crew.ship = ship + ship.ship_team = crew + var/mob/living/carbon/human/consistent/tagger = hunter_at(spot(2, 0)) + // Out of its sight past the room's walls, but on its site + var/mob/living/carbon/human/consistent/on_site = hunter_at(outside(0, 20)) + // On the dock strip, at the bottom of its site + var/mob/living/carbon/human/consistent/on_dock = hunter_at(outside(3, -2)) + // On its level, off its site: another planet in the lattice + var/mob/living/carbon/human/consistent/elsewhere = hunter_at(outside(40, 0)) + // On its site, but SSD + var/mob/living/carbon/human/consistent/asleep = hunter_at(outside(1, 20)) + // On its site and playing, but not hunting it + var/mob/living/carbon/human/consistent/stranger = hunter_at(outside(2, 20)) + TEST_ASSERT(get_dist(on_site, run_loc_floor_bottom_left) > 9, "The on-site crewmate is within the boss's sight") // BOUNTY_BOSS_POSSE_RANGE + for(var/mob/living/carbon/human/consistent/playing as anything in list(tagger, on_site, on_dock, elsewhere, stranger)) + playing.mock_client = allocate(/datum/client_interface) + for(var/mob/living/carbon/human/consistent/member as anything in list(tagger, on_site, on_dock, elsewhere, asleep)) + crew.join_member(member.mind) + TEST_ASSERT_EQUAL(posting.hunt(ship), TRUE, "The test ship couldn't hunt the bounty") + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = spawn_bounty_criminal(posting.record, spot(0, 0), posting) + if(boss) + allocated += boss + TEST_ASSERT(istype(boss), "The posted Juggernaut spawned as [boss?.type]") + boss.ai_controller?.set_ai_status(AI_STATUS_OFF) + // Its site: the room and well around it, with a dock strip along the bottom + var/turf/corner = run_loc_floor_bottom_left + boss.site_bounds = list(corner.x - 3, corner.y - 3, corner.x + 25, corner.y + 25, corner.z) + boss.body_dock_top_y = corner.y - 1 + TEST_ASSERT(boss.body_on_site(get_turf(on_site)), "The test's on-site spot is off the site") + TEST_ASSERT(!boss.body_on_site(get_turf(on_dock)) && boss.body_on_dock_strip(get_turf(on_dock)), "The test's dock strip spot isn't on the dock strip") + TEST_ASSERT(!boss.body_on_site(get_turf(elsewhere)), "The test's off-site spot is on the site") + + boss.body_add_grudge(tagger) + boss.boss_turn_hostile(tagger) + TEST_ASSERT(boss.boss_engaged[REF(tagger)], "The hunter who woke it isn't in its posse") + TEST_ASSERT(boss.boss_engaged[REF(on_site)], "A crewmate out of its sight on its site isn't in its posse") + TEST_ASSERT(boss.boss_engaged[REF(on_dock)], "A crewmate waiting on the dock strip isn't in its posse") + TEST_ASSERT(!boss.boss_engaged[REF(elsewhere)], "A crewmate on another site on its level joined its posse") + TEST_ASSERT(!boss.boss_engaged[REF(asleep)], "An SSD crewmate joined its posse") + TEST_ASSERT(!boss.boss_engaged[REF(stranger)], "Someone out of its sight who isn't hunting it joined its posse") + // Three of the crew at its site: two companions owed (one per hunter beyond the first), and its body as it was + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed + boss.boss_reinforcements_sent, 2, "Woken with three of a crew at its site, it owes the wrong number of companions") + TEST_ASSERT_NOTNULL(boss.boss_reinforce_timer, "The companions owed weren't scheduled") + TEST_ASSERT_EQUAL(boss.maxHealth, 100, "The crew changed the boss's health") // MAX_LIVING_HEALTH + for(var/datum/mind/member as anything in crew.members.Copy()) + member.ship_teams = null + crew.members.Cut() + crew.ship = null + ship.ship_team = null + QDEL_NULL(crew) + board_test_end() + +// ===== HURT FROM WHERE IT CAN'T REACH (review r1 F4) ===== + +/** + * Shot from behind glass it can't break, with no way round: it doesn't go after the shooter, and it + * breaks for cover out of their sight on its own side, with a line. Once they come round, it goes after + * them again. + */ +/datum/unit_test/voidcrew_bounty_boss/reach/out_of_reach + +/datum/unit_test/voidcrew_bounty_boss/reach/out_of_reach/Run() + // A wall down the middle of the room: reinforced glass low, solid wall high + for(var/dy in 0 to 2) + allocate(/obj/structure/window/reinforced/fulltile, spot(2, dy)) + change_turf(spot(2, 3), /turf/closed/wall/r_wall) + change_turf(spot(2, 4), /turf/closed/wall/r_wall) + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/ghost = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, spot(0, 0)) + var/datum/ai_controller/controller = ghost.ai_controller + var/mob/living/carbon/human/consistent/sniper = hunter_at(spot(4, 4)) + var/atom/barrier = ghost.boss_barrier_between(get_turf(ghost), get_turf(sniper)) + TEST_ASSERT(istype(barrier, /obj/structure/window), "The glass between them isn't what stops it: [barrier?.type]") + TEST_ASSERT(!ghost.boss_goes_through(barrier), "The Ghost goes through reinforced glass") + TEST_ASSERT(!ghost.boss_can_reach(sniper), "The Ghost can reach someone behind glass with no way round") + TEST_ASSERT(ghost.boss_valid_target(sniper), "Before a shot, the Ghost won't go after someone it can see") + + // Shot from there: it keeps away from them + ghost.body_add_grudge(sniper) + TEST_ASSERT(ghost.boss_note_attacker(sniper), "The shot wasn't noted") + TEST_ASSERT(ghost.boss_shuns(sniper), "Shot from behind glass, the Ghost doesn't keep away from the shooter") + TEST_ASSERT(!ghost.boss_valid_target(sniper), "Shot from behind glass, the Ghost still goes after the shooter") + TEST_ASSERT_NULL(ghost.boss_revenge_target(), "Shot from behind glass, the Ghost turns on the shooter") + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(/datum/targeting_strategy/basic/human_npc/bounty_boss) + TEST_ASSERT(!strategy.can_attack(ghost, sniper, 9), "The boss's targeting picks a shooter it can't get at") // BOUNTY_BOSS_POSSE_RANGE + TEST_ASSERT_NULL(ghost.boss_nearest_hunter(list(sniper)), "The hunt walks it out at a shooter behind glass") + var/list/watchers = ghost.boss_watchers() + TEST_ASSERT(sniper in watchers, "The shooter isn't one it hides from") + TEST_ASSERT(ghost.boss_seen_from(get_turf(ghost), watchers), "The test needs the shooter to see the Ghost where it stands") + var/turf/cover = ghost.boss_find_cover(watchers) + TEST_ASSERT_NOTNULL(cover, "The Ghost found no cover on its side of the glass") + TEST_ASSERT(!can_see(sniper, cover, 9), "The Ghost's cover is in the shooter's sight") // BOUNTY_BOSS_COVER_SIGHT + TEST_ASSERT(cover.x < spot(2, 0).x, "The Ghost's cover is on the shooter's side") + + // Its planner breaks for that cover, with a line of its own + var/datum/component/bounty_identity_voice/voice = ghost.LoadComponent(/datum/component/bounty_identity_voice) + voice.line_cooldown = 0 + voice.last_line = null + TEST_ASSERT_EQUAL(plan_with(ghost, /datum/ai_planning_subtree/bounty_boss_cover), SUBTREE_RETURN_FINISH_PLANNING, "Seen by a shooter it can't get at, it planned nothing") + TEST_ASSERT_NOTNULL(controller.blackboard["BB_bounty_boss_cover"], "Seen by a shooter it can't get at, it stays put") // BB_BOUNTY_BOSS_COVER + TEST_ASSERT(planned(controller, /datum/ai_behavior/travel_towards), "It doesn't walk for cover") + TEST_ASSERT(voice.last_line in bounty_identity_strings("lines")["ghost_cover"]["any"], "Breaking for cover, the Ghost said [voice.last_line || "nothing"]") + controller.CancelActions() + controller.clear_blackboard_key("BB_bounty_boss_cover") + + // Come round: fair game again + sniper.forceMove(spot(1, 0)) + TEST_ASSERT(ghost.boss_can_reach(sniper), "The Ghost can't reach someone right beside it") + TEST_ASSERT(!ghost.boss_shuns(sniper), "The Ghost keeps away from someone who came round to it") + TEST_ASSERT(ghost.boss_valid_target(sniper), "The Ghost won't go after someone who came round to it") + TEST_ASSERT(!(sniper in ghost.boss_watchers()), "It still hides from someone who came round to it") + +/** + * A sniper far off (review r2): past the walk it works out, and past BOUNTY_BOSS_COVER_SIGHT. On its + * site with open ground round the table between them, it goes after them. Off its site (where it can't + * follow), it sees that they see it and backs off, keeps walking until it gets there, and hides + * behind a wall when one is near. Its walk is always worked out from the tile it stands on. + */ +/datum/unit_test/voidcrew_bounty_boss/reach/far_sniper + +/datum/unit_test/voidcrew_bounty_boss/reach/far_sniper/Run() + // Open floor north of the room: 21 wide, 5 deep + floor_area(0, 10, 20, 14) + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/ghost = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, outside(0, 12)) + var/datum/ai_controller/controller = ghost.ai_controller + allocate(/obj/structure/table, outside(2, 12)) + var/mob/living/carbon/human/consistent/sniper = hunter_at(outside(13, 12)) + TEST_ASSERT(get_dist(ghost, sniper) > 10, "The sniper isn't past the walk it works out") // BOUNTY_BOSS_REACH_RANGE + TEST_ASSERT(istype(ghost.boss_barrier_between(get_turf(ghost), get_turf(sniper)), /obj/structure/table), "The table isn't between them") + + // On its site, open ground round the table: in reach, and it goes after them + TEST_ASSERT(ghost.boss_can_reach(sniper), "A sniper 13 tiles off across open ground is out of its reach") + ghost.body_add_grudge(sniper) + TEST_ASSERT(ghost.boss_note_attacker(sniper), "The shot wasn't noted") + TEST_ASSERT(!ghost.boss_shuns(sniper), "Shot from 13 tiles off across open ground, it keeps away from the shooter") + TEST_ASSERT(ghost.boss_valid_target(sniper), "Shot from 13 tiles off, it won't go after the shooter") + TEST_ASSERT(!(sniper in ghost.boss_watchers()), "It hides from a shooter it can walk to") + TEST_ASSERT_EQUAL(ghost.boss_nearest_hunter(list(sniper)), sniper, "The hunt doesn't pick the shooter") + controller.set_blackboard_key("BB_bounty_boss_prey", sniper) // BB_BOUNTY_BOSS_PREY + controller.set_blackboard_key("BB_bounty_boss_hunt_at", world.time + 10 SECONDS) // BB_BOUNTY_BOSS_HUNT_AT + TEST_ASSERT_EQUAL(plan_with(ghost, /datum/ai_planning_subtree/bounty_boss_hunt), SUBTREE_RETURN_FINISH_PLANNING, "The hunt planned nothing") + TEST_ASSERT(planned(controller, /datum/ai_behavior/travel_towards/adjacent), "It doesn't walk after the shooter") + controller.CancelActions() + controller.clear_blackboard_key("BB_bounty_boss_prey") + + // Walled in near it, the same sniper is out of reach: the walk never gets it closer to them + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boxed = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, outside(0, 12)) + for(var/dy in 10 to 14) + change_turf(outside(1, dy), /turf/closed/wall/r_wall) + TEST_ASSERT(!boxed.boss_can_reach(sniper), "Walled in, it can reach a sniper 13 tiles off") + for(var/dy in 10 to 14) + change_turf(outside(1, dy), /turf/open/floor/iron) + qdel(boxed) + + // Off its site (in their ship), 12 tiles off with a clear line: it can't follow, and it knows they see it + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/hider = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, outside(7, 12)) + controller = hider.ai_controller + var/turf/ship_floor = make_ship_tile(outside(19, 12)) + sniper.forceMove(ship_floor) + hider.body_add_grudge(sniper) + TEST_ASSERT(hider.boss_note_attacker(sniper), "The shot from the ship wasn't noted") + TEST_ASSERT(hider.boss_shuns(sniper), "Shot from off its site, it doesn't keep away from the shooter") + var/list/watchers = hider.boss_watchers() + TEST_ASSERT(sniper in watchers, "The shooter in their ship isn't one it hides from") + TEST_ASSERT(hider.boss_seen_from(get_turf(hider), watchers), "12 tiles off with a clear line, it thinks the shooter can't see it") + + // Nowhere hidden in reach: it backs off as far as it can, saying so, and keeps going (review r2 bug 3) + var/datum/component/bounty_identity_voice/voice = hider.LoadComponent(/datum/component/bounty_identity_voice) + voice.line_cooldown = 0 + voice.last_line = null + var/turf/start = get_turf(hider) + TEST_ASSERT_EQUAL(plan_with(hider, /datum/ai_planning_subtree/bounty_boss_cover), SUBTREE_RETURN_FINISH_PLANNING, "In the open in a shooter's sight, it planned nothing") + var/turf/away = controller.blackboard["BB_bounty_boss_cover"] // BB_BOUNTY_BOSS_COVER + TEST_ASSERT_NOTNULL(away, "In the open in a shooter's sight, it stays put") + TEST_ASSERT(get_dist(away, sniper) > get_dist(start, sniper), "It doesn't back away from the shooter") + TEST_ASSERT(planned(controller, /datum/ai_behavior/travel_towards), "It doesn't walk away from the shooter") + TEST_ASSERT(voice.last_line in bounty_identity_strings("lines")["ghost_cover"]["any"], "Breaking for cover, the Ghost said [voice.last_line || "nothing"]") + // The next plan, still on its way: it keeps walking + TEST_ASSERT_EQUAL(plan_with(hider, /datum/ai_planning_subtree/bounty_boss_cover), SUBTREE_RETURN_FINISH_PLANNING, "On its way, it planned nothing") + TEST_ASSERT(planned(controller, /datum/ai_behavior/travel_towards), "On its way to the farthest spot, it dropped its own walk") + TEST_ASSERT_EQUAL(controller.blackboard["BB_bounty_boss_cover"], away, "On its way, it changed its mind") // BB_BOUNTY_BOSS_COVER + controller.CancelActions() + + // A wall near it: it hides behind that, out of the shooter's line + for(var/dy in 11 to 13) + change_turf(outside(5, dy), /turf/closed/wall/r_wall) + hider.boss_walk_cache = null + var/turf/cover = hider.boss_find_cover(watchers) + TEST_ASSERT_NOTNULL(cover, "With a wall near it, it found no cover from a shooter 12 tiles off") + TEST_ASSERT(!hider.boss_seen_from(cover, watchers), "Its cover is in the shooter's line") + TEST_ASSERT(cover.x < outside(5, 12).x, "Its cover isn't behind the wall") + + // Its walk is worked out from where it stands, not where it stood + var/list/steps = hider.boss_walkable() + TEST_ASSERT_EQUAL(steps[get_turf(hider)], 0, "Its walk doesn't start where it stands") + hider.forceMove(outside(8, 10)) + steps = hider.boss_walkable() + TEST_ASSERT_EQUAL(steps[get_turf(hider)], 0, "A step later, its walk still starts where it stood") + +/** + * The breach planner (review r2): with its charge on cooldown and a way round, the Juggernaut goes + * round rather than wait at the glass; with the charge ready it walks up; with no way round it waits + * at the glass for the charge. + */ +/datum/unit_test/voidcrew_bounty_boss/reach/breach + +/datum/unit_test/voidcrew_bounty_boss/reach/breach/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 2)) + var/datum/ai_controller/controller = boss.ai_controller + var/mob/living/carbon/human/consistent/behind = hunter_at(spot(4, 2)) + var/obj/structure/window/fulltile/pane = allocate(/obj/structure/window/fulltile, spot(2, 2)) + var/datum/action/cooldown/mob_cooldown/bounty_boss/charge/charge = ability_of(boss, /datum/action/cooldown/mob_cooldown/bounty_boss/charge) + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, behind) + TEST_ASSERT(boss.boss_goes_through(pane), "The Juggernaut's charge doesn't go through plain glass") + var/list/blockers = boss.boss_line_blockers(get_turf(boss), get_turf(behind)) + TEST_ASSERT_EQUAL(length(blockers), 1, "One plain window reads as [length(blockers)] things in its way") + TEST_ASSERT(boss.boss_gets_through(blockers), "The Juggernaut's charge doesn't get through one plain window") + TEST_ASSERT_EQUAL(controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], behind, "The test's target didn't stick") + + // Charge on cooldown, a way round: no breach, so the melee planner walks it round + charge.next_use_time = world.time + 100 SECONDS + TEST_ASSERT(!boss.boss_breaks_through_now(pane), "The Juggernaut's charge is ready on cooldown") + TEST_ASSERT_NULL(plan_with(boss, /datum/ai_planning_subtree/bounty_boss_breach), "With its charge on cooldown and a way round, it went at the glass") + TEST_ASSERT_NULL(controller.blackboard["BB_bounty_boss_spot"], "With its charge on cooldown and a way round, it picked a spot at the glass") // BB_BOUNTY_BOSS_SPOT + + // Charge ready: it walks up to the glass + charge.next_use_time = 0 + TEST_ASSERT(boss.boss_breaks_through_now(pane), "The Juggernaut's charge isn't ready off cooldown") + TEST_ASSERT_EQUAL(plan_with(boss, /datum/ai_planning_subtree/bounty_boss_breach), SUBTREE_RETURN_FINISH_PLANNING, "With its charge ready, it didn't go at the glass") + TEST_ASSERT_EQUAL(controller.blackboard["BB_bounty_boss_spot"], spot(1, 2), "With its charge ready, it isn't walking up to the glass") // BB_BOUNTY_BOSS_SPOT + TEST_ASSERT(planned(controller, /datum/ai_behavior/travel_towards), "With its charge ready, it doesn't walk") + controller.CancelActions() + controller.clear_blackboard_key("BB_bounty_boss_spot") + + // No way round: it waits at the glass for its charge + for(var/dy in list(0, 1, 3, 4)) + allocate(/obj/structure/window/reinforced/fulltile, spot(2, dy)) + boss.boss_walk_cache = null + charge.next_use_time = world.time + 100 SECONDS + TEST_ASSERT(!boss.boss_walks_to(get_turf(behind)), "The test's glass wall has a way round") + TEST_ASSERT_EQUAL(plan_with(boss, /datum/ai_planning_subtree/bounty_boss_breach), SUBTREE_RETURN_FINISH_PLANNING, "With no way round, it didn't go at the glass") + TEST_ASSERT_EQUAL(controller.blackboard["BB_bounty_boss_spot"], spot(1, 2), "With no way round, it isn't walking up to the glass") // BB_BOUNTY_BOSS_SPOT + controller.CancelActions() + +// ===== GORILLA ARMS THROUGH GLASS: THE IMPLANT'S OWN PUNCHES ===== + +/** + * Smashing is all or nothing (review r2): Gorilla Arms leave alone a grille with glass behind it they + * can't break in a few punches, and go at one with glass they can. + */ +/datum/unit_test/voidcrew_bounty_boss/reach/smash_line + +/datum/unit_test/voidcrew_bounty_boss/reach/smash_line/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = gorilla_boss(spot(0, 1)) + var/datum/ai_controller/controller = boss.ai_controller + var/mob/living/carbon/human/consistent/behind = hunter_at(spot(4, 1)) + var/obj/structure/grille/grille = allocate(/obj/structure/grille, spot(2, 1)) + var/obj/structure/window/reinforced/fulltile/thick = allocate(/obj/structure/window/reinforced/fulltile, spot(2, 1)) + var/list/blockers = boss.boss_line_blockers(get_turf(boss), get_turf(behind)) + TEST_ASSERT((grille in blockers) && (thick in blockers), "The grille and the glass on one tile aren't both in its way") + TEST_ASSERT(boss.boss_gorilla_goes_through(grille), "Gorilla Arms don't go through a grille") + TEST_ASSERT(!boss.boss_gorilla_goes_through(thick), "Gorilla Arms go through reinforced glass") + TEST_ASSERT(!boss.boss_gets_through(blockers), "It goes at a grille with glass behind it it can't break") + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, behind) + TEST_ASSERT_NULL(plan_with(boss, /datum/ai_planning_subtree/bounty_boss_breach), "It went at a grille with glass behind it it can't break") + TEST_ASSERT_NULL(controller.blackboard["BB_bounty_boss_spot"], "It picked a spot at glass it can't break") // BB_BOUNTY_BOSS_SPOT + + // Plain glass behind the grille: all of it breaks, so it goes at it, its Gorilla Arms ready with the charge on cooldown + qdel(thick) + var/obj/structure/window/fulltile/pane = allocate(/obj/structure/window/fulltile, spot(2, 1)) + var/datum/action/cooldown/mob_cooldown/bounty_boss/charge/charge = ability_of(boss, /datum/action/cooldown/mob_cooldown/bounty_boss/charge) + charge.next_use_time = world.time + 100 SECONDS + boss.boss_walk_cache = null + blockers = boss.boss_line_blockers(get_turf(boss), get_turf(behind)) + TEST_ASSERT((grille in blockers) && (pane in blockers), "The grille and the plain glass on one tile aren't both in its way") + TEST_ASSERT_EQUAL(length(blockers), 2, "A grille and a window on one tile read as [length(blockers)] things in its way") + TEST_ASSERT(boss.boss_gets_through(blockers), "It won't go at a grille with plain glass behind it") + TEST_ASSERT(boss.boss_breaks_through_now(grille), "Its Gorilla Arms aren't ready for the grille") + TEST_ASSERT_EQUAL(plan_with(boss, /datum/ai_planning_subtree/bounty_boss_breach), SUBTREE_RETURN_FINISH_PLANNING, "It didn't go at a grille and glass it can break") + TEST_ASSERT_EQUAL(controller.blackboard["BB_bounty_boss_spot"], spot(1, 1), "It isn't walking up to glass it can break") // BB_BOUNTY_BOSS_SPOT + controller.CancelActions() + +/** + * The smash: a tell first, then the implant's own punches through a plain window, never reinforced glass + * or an airlock, never off its site or near a ship, never with an EMP'd arm or a full hand, and nothing + * lands if it is stopped in the tell. Then what the other kits get through. + */ +/datum/unit_test/voidcrew_bounty_boss/reach/smash + +/datum/unit_test/voidcrew_bounty_boss/reach/smash/Run() + var/obj/structure/window/fulltile/pane = allocate(/obj/structure/window/fulltile, spot(1, 2)) + var/obj/structure/window/reinforced/fulltile/thick = allocate(/obj/structure/window/reinforced/fulltile, spot(1, 4)) + var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, spot(1, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = gorilla_boss(spot(0, 2)) + TEST_ASSERT(boss.boss_gorilla_goes_through(pane), "Gorilla Arms don't go through plain glass") + TEST_ASSERT(!boss.boss_gorilla_goes_through(thick), "Gorilla Arms go through reinforced glass") + TEST_ASSERT(!boss.boss_can_smash(door), "Gorilla Arms smash an airlock instead of forcing it") + + // The tell: rooted, glowing, the tile lit, nothing broken yet + var/integrity = pane.get_integrity() + TEST_ASSERT(boss.boss_start_smash(pane), "The smash didn't start") + var/serial = boss.boss_busy_serial + TEST_ASSERT_EQUAL(boss.boss_busy, "smash", "The smash doesn't hold the boss") // BOUNTY_BOSS_BUSY_SMASH + TEST_ASSERT(HAS_TRAIT(boss, TRAIT_IMMOBILIZED), "It walks about mid-smash") + TEST_ASSERT_NOTNULL(boss.get_filter("bounty_boss_smash"), "The smash's tell doesn't glow") // BOUNTY_BOSS_SMASH_FILTER + TEST_ASSERT(marks_near(pane, 0) > 0, "The smash marks nothing") + TEST_ASSERT_EQUAL(pane.get_integrity(), integrity, "The glass broke before the tell was over") + TEST_ASSERT(!boss.boss_start_smash(pane), "A second smash started mid-smash") + + // The punches: the implant's own, each what one Gorilla Arms punch does to that glass + var/expected = pane.run_atom_armor(40, BRUTE, MELEE) // BOUNTY_BOSS_SMASH_BLOW, CYBERWARE_GORILLA_STRUCTURE_DAMAGE + ready_fists(boss) + TEST_ASSERT(boss.boss_smash_blow(serial), "The first punch wasn't thrown") + TEST_ASSERT(abs((integrity - pane.get_integrity()) - expected) < 0.1, "A Gorilla Arms punch took [integrity - pane.get_integrity()] off the glass, not the [expected] the smash counts on") + var/punches = 1 + for(var/i in 1 to 6) // BOUNTY_BOSS_SMASH_MOST_BLOWS + if(boss.boss_busy != "smash") + break + ready_fists(boss) + if(boss.boss_smash_blow(serial)) + punches++ + TEST_ASSERT(QDELETED(pane) || !pane.density, "[punches] punches didn't get it through the plain window") + TEST_ASSERT(punches <= 6, "It threw [punches] punches") // BOUNTY_BOSS_SMASH_MOST_BLOWS + TEST_ASSERT_NULL(boss.boss_busy, "The smash kept the boss after it got through") + TEST_ASSERT(!HAS_TRAIT(boss, TRAIT_IMMOBILIZED), "The boss is still rooted after the smash") + TEST_ASSERT_NULL(boss.get_filter("bounty_boss_smash"), "The smash's glow outlived it") + TEST_ASSERT_EQUAL(marks_near(spot(1, 2), 0), 0, "The smash's mark outlived it") + + // Stopped in the tell: nothing lands, the mark goes + var/obj/structure/window/fulltile/other_pane = allocate(/obj/structure/window/fulltile, spot(0, 3)) + boss.boss_next_ability_at = 0 + integrity = other_pane.get_integrity() + TEST_ASSERT(boss.boss_start_smash(other_pane), "The second smash didn't start") + serial = boss.boss_busy_serial + boss.boss_interrupt() + ready_fists(boss) + TEST_ASSERT(!boss.boss_smash_blow(serial), "An interrupted smash threw a punch") + TEST_ASSERT_EQUAL(other_pane.get_integrity(), integrity, "An interrupted smash hurt the glass") + TEST_ASSERT_EQUAL(marks_near(other_pane, 0), 0, "An interrupted smash left its mark") + + // EMP'd, the arms are dead weight until they reboot + boss.boss_next_ability_at = 0 + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in boss.organs) + var/datum/component/cyberware/ware = arm.GetComponent(/datum/component/cyberware) + ware.start_emp_reboot() + TEST_ASSERT(!boss.boss_gorilla_goes_through(other_pane), "EMP'd Gorilla Arms go through glass") + TEST_ASSERT(!boss.boss_start_smash(other_pane), "EMP'd Gorilla Arms smashed glass") + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in boss.organs) + var/datum/component/cyberware/ware = arm.GetComponent(/datum/component/cyberware) + ware.tune_up() + TEST_ASSERT(boss.boss_gorilla_goes_through(other_pane), "Rebooted Gorilla Arms don't go through glass") + + // Both hands full: no fist to punch with (the Juggernaut's off hand already holds its shield, C8) + var/obj/item/wrench/left_load = allocate(/obj/item/wrench) + var/obj/item/screwdriver/right_load = allocate(/obj/item/screwdriver) + if(length(boss.get_empty_held_indexes())) + boss.put_in_hands(left_load) + if(length(boss.get_empty_held_indexes())) + boss.put_in_hands(right_load) + TEST_ASSERT(!length(boss.get_empty_held_indexes()), "Test fixture: the boss couldn't fill both hands") + TEST_ASSERT(!boss.boss_has_gorilla_fist(), "With both hands full, it still has a fist to punch with") + TEST_ASSERT(!boss.boss_gorilla_goes_through(other_pane), "With both hands full, its Gorilla Arms go through glass") + qdel(left_load) + qdel(right_load) + TEST_ASSERT(boss.boss_has_gorilla_fist(), "Hands empty again, it has no fist") + + // Off its site: never + var/turf/corner = run_loc_floor_bottom_left + boss.site_bounds = list(corner.x, corner.y, corner.x + 1, corner.y + 2, corner.z) + TEST_ASSERT(!boss.boss_can_smash(other_pane), "Gorilla Arms go at glass off its site") + boss.site_bounds = null + + // The other kits + var/obj/structure/window/fulltile/plain = allocate(/obj/structure/window/fulltile, spot(3, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/juggernaut = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(4, 0)) + TEST_ASSERT(juggernaut.boss_goes_through(plain), "The Juggernaut's charge doesn't go through plain glass") + TEST_ASSERT(!juggernaut.boss_goes_through(thick), "The Juggernaut's charge goes through reinforced glass") + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/heavy, spot(4, 3)) + TEST_ASSERT(heavy.boss_goes_through(thick), "The Heavy's rounds don't chip interior glass") + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac, spot(3, 3)) + TEST_ASSERT(!pyro.boss_goes_through(thick), "The Pyromaniac's molotov goes through reinforced glass") + TEST_ASSERT(!pyro.boss_goes_through(door), "The Pyromaniac's molotov goes over a shut airlock") + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/ghost = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, spot(4, 4)) + TEST_ASSERT(!ghost.boss_goes_through(plain), "The Ghost goes through glass") + + // Near a player's ship: never (BOUNTY_ENV_SAFE_RANGE) + make_ship_tile(spot(4, 1)) + TEST_ASSERT(!boss.boss_can_smash(other_pane), "Gorilla Arms go at glass near a player's ship") + TEST_ASSERT(!boss.boss_gorilla_goes_through(other_pane), "Gorilla Arms go through glass near a player's ship") + +// ===== THROWS STOP AT GLASS ===== + +/** + * A thrown molotov, grenade or smoke grenade goes where a real thrown item would: a hunter behind + * reinforced glass or a shut glass airlock is no throw target for the Pyromaniac or the Demolitionist, + * and their throws don't count as getting through it. Over a table, or with nothing in the way, they do. + */ +/datum/unit_test/voidcrew_bounty_boss/reach/throws_stop_at_glass + +/datum/unit_test/voidcrew_bounty_boss/reach/throws_stop_at_glass/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac, spot(0, 2)) + var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(4, 2)) + var/datum/action/cooldown/mob_cooldown/bounty_boss/molotov/molotov = ability_of(pyro, /datum/action/cooldown/mob_cooldown/bounty_boss/molotov) + var/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/smoke = ability_of(pyro, /datum/action/cooldown/mob_cooldown/bounty_boss/smoke) + TEST_ASSERT_NOTNULL(molotov, "The Pyromaniac has no molotov") + TEST_ASSERT_NOTNULL(smoke, "The Pyromaniac has no smoke") + TEST_ASSERT(fight(pyro, hunter), "Test fixture: the Pyromaniac didn't turn hostile") + + // Behind reinforced glass: seen, but no throw lands on them + var/obj/structure/window/reinforced/fulltile/glass = allocate(/obj/structure/window/reinforced/fulltile, spot(2, 2)) + TEST_ASSERT(can_see(pyro, hunter, 7), "Test fixture: the Pyromaniac can't see through the glass") + TEST_ASSERT(!pyro.boss_throw_reaches(spot(0, 2), spot(4, 2)), "A throw goes through reinforced glass") + TEST_ASSERT(!pyro.boss_goes_through(glass), "The Pyromaniac's molotov goes through reinforced glass") + TEST_ASSERT(!pyro.boss_breaks_through_now(glass), "The Pyromaniac walks up to glass to throw over it") + TEST_ASSERT(!molotov.worth_using(hunter), "The Pyromaniac throws a molotov at someone behind glass") + pyro.boss_last_attacker = WEAKREF(hunter) + pyro.boss_last_attacked_at = world.time + TEST_ASSERT(!smoke.worth_using(hunter), "The Pyromaniac throws smoke at someone behind glass") + + // A shut glass airlock: the same + qdel(glass) + var/obj/machinery/door/airlock/glass/airlock = allocate(/obj/machinery/door/airlock/glass, spot(2, 2)) + TEST_ASSERT(airlock.density && !airlock.opacity, "Test fixture: the glass airlock isn't shut and see-through") + TEST_ASSERT(!pyro.boss_throw_reaches(spot(0, 2), spot(4, 2)), "A throw goes through a shut glass airlock") + TEST_ASSERT(!pyro.boss_goes_through(airlock), "The Pyromaniac's molotov goes through a shut glass airlock") + TEST_ASSERT(!molotov.worth_using(hunter), "The Pyromaniac throws a molotov through a shut glass airlock") + qdel(airlock) + + // In the open: they are + TEST_ASSERT(pyro.boss_throw_reaches(spot(0, 2), spot(4, 2)), "A throw doesn't cross open floor") + TEST_ASSERT(molotov.worth_using(hunter), "The Pyromaniac won't throw a molotov at someone in the open") + pyro.boss_last_attacker = WEAKREF(hunter) + pyro.boss_last_attacked_at = world.time + TEST_ASSERT(smoke.worth_using(hunter), "The Pyromaniac won't throw smoke at someone in the open who shot it") + + // Over a table: still + var/obj/structure/table/table = allocate(/obj/structure/table, spot(2, 2)) + TEST_ASSERT(pyro.boss_throw_reaches(spot(0, 2), spot(4, 2)), "A throw doesn't go over a table") + TEST_ASSERT(pyro.boss_goes_through(table), "The Pyromaniac's molotov doesn't go over a table") + qdel(table) + + // The Demolitionist's grenades, from the same spot + qdel(pyro) + var/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/demo = boss_at(/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist, spot(0, 2)) + var/datum/action/cooldown/mob_cooldown/bounty_boss/grenade/grenade = ability_of(demo, /datum/action/cooldown/mob_cooldown/bounty_boss/grenade) + TEST_ASSERT_NOTNULL(grenade, "The Demolitionist has no grenade") + TEST_ASSERT(fight(demo, hunter), "Test fixture: the Demolitionist didn't turn hostile") + TEST_ASSERT(grenade.worth_using(hunter), "The Demolitionist won't throw a grenade at someone in the open") + TEST_ASSERT(demo.boss_has_next_throw(hunter), "The Demolitionist has no throw for someone in the open") + glass = allocate(/obj/structure/window/reinforced/fulltile, spot(2, 2)) + TEST_ASSERT(!grenade.worth_using(hunter), "The Demolitionist throws a grenade at someone behind glass") + TEST_ASSERT(!demo.boss_goes_through(glass), "The Demolitionist's grenade goes through reinforced glass") + TEST_ASSERT(!demo.boss_breaks_through_now(glass), "The Demolitionist walks up to glass to throw over it") + TEST_ASSERT(!demo.boss_has_next_throw(hunter), "The Demolitionist holds its range for a throw that hits glass") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm index 3c40f30f99a..de17dafb544 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm @@ -104,6 +104,32 @@ /datum/unit_test/voidcrew_bounty_boss/proc/carried(mob/living/holder, item_type) return length(holder.get_all_contents_type(item_type)) +/** + * A real `projectile_type` landing on `target` from `from_turf`, the way a projectile's hit loop lands one + * (process_hit_loop(): its PREHIT, then projectile_hit()), aimed at `zone`. Returns what bullet_act() + * returned, or 0 if something stopped it before it landed (a shield). + */ +/datum/unit_test/voidcrew_bounty_boss/proc/shoot(mob/living/target, turf/from_turf, mob/living/firer, projectile_type = /obj/projectile/beam/disabler, zone = BODY_ZONE_CHEST) + var/obj/projectile/shot = allocate(projectile_type, from_turf) + shot.firer = firer + shot.fired_from = firer + shot.starting = from_turf + shot.def_zone = zone + if(SEND_SIGNAL(target, COMSIG_PROJECTILE_PREHIT, shot) & PROJECTILE_INTERRUPT_HIT) + return 0 + return target.projectile_hit(shot, zone) + +/// The combat sense planning subtree's shared instance, which every boss plans with +/datum/unit_test/voidcrew_bounty_boss/proc/sense_subtree() + return GLOB.ai_subtrees[/datum/ai_planning_subtree/npc_combat_sense] + +/// `boss` in a fight with `hunter`: on its grudge list, hostile, and its target +/datum/unit_test/voidcrew_bounty_boss/proc/fight(mob/living/carbon/human/npc/bounty_criminal/boss/boss, mob/living/hunter) + boss.body_add_grudge(hunter) + boss.boss_turn_hostile(hunter) + boss.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + return boss.boss_hostile + // ===== EACH KIT IS A REAL HUMAN IN REAL GEAR, AND GOES CLEANLY ===== /datum/unit_test/voidcrew_bounty_boss/kits @@ -120,7 +146,8 @@ 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") + // Two each; the Pyromaniac's smoke is a third (C9) + TEST_ASSERT_EQUAL(length(boss.boss_abilities), kit_type == /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac ? 3 : 2, "[kit_type] has [length(boss.boss_abilities)] abilities") TEST_ASSERT(istype(boss.ai_controller, /datum/ai_controller/basic_controller/bounty_boss), "[kit_type] doesn't have the boss AI") 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). @@ -129,9 +156,17 @@ 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 + // Its stimulants and a bruise pack, carried for real, the pens used by its combat sense (C8). + TEST_ASSERT_EQUAL(carried(boss, /obj/item/reagent_containers/hypospray/medipen/stimpack) - carried(boss, /obj/item/reagent_containers/hypospray/medipen/stimpack/traitor), 2, "[kit_type] doesn't carry its two stimulants") // BOUNTY_BOSS_STIMULANTS + // And one combat stimpack, issued to it: used up or gone, never loot (BOUNTY_BOSS_COMBAT_STIMULANT) + TEST_ASSERT_EQUAL(carried(boss, /obj/item/reagent_containers/hypospray/medipen/stimpack/traitor), 1, "[kit_type] doesn't carry one combat stimpack") + var/obj/item/reagent_containers/hypospray/medipen/combat_pen = locate(/obj/item/reagent_containers/hypospray/medipen/stimpack/traitor) in boss.get_all_contents() + TEST_ASSERT(human_npc_gear_consumable(combat_pen), "[kit_type]'s combat stimpack isn't issued to it") + TEST_ASSERT(human_npc_can_draw(boss, combat_pen), "[kit_type] can't reach its combat stimpack") TEST_ASSERT(carried(boss, /obj/item/stack/medical/bruise_pack) >= 1, "[kit_type] carries nothing to patch itself up with") + var/datum/component/npc_combat_sense/sense = boss.GetComponent(/datum/component/npc_combat_sense) + TEST_ASSERT(istype(sense?.rules, /datum/npc_combat_sense/bounty/boss), "[kit_type] has no boss combat sense") + TEST_ASSERT(sense_subtree() in boss.ai_controller.planning_subtrees, "[kit_type]'s AI doesn't plan its combat sense") TEST_ASSERT(boss.boss_gear_text(), "[kit_type] has no gear line on examine") var/list/abilities = boss.boss_abilities.Copy() qdel(boss) @@ -139,27 +174,54 @@ for(var/datum/ability as anything in abilities) TEST_ASSERT(QDELETED(ability), "[kit_type]'s [ability.type] outlived it") - // The Juggernaut: riot armour, and a real gene for its size (CB-5, CB-21). + // The Juggernaut: riot armour, a real gene for its size (CB-5, CB-21), and a real tower shield in hand, locked to it, not yet raised (C8). 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/obj/item/shield/riot/phalanx_buckler/shield = jugg.boss_shield() + TEST_ASSERT_NOTNULL(shield, "The Juggernaut holds no tower shield") // BOUNTY_JUGGERNAUT_SHIELD + TEST_ASSERT(human_npc_gear_locked(shield), "The Juggernaut's shield isn't locked to it") + TEST_ASSERT(!shield.raised, "The Juggernaut has its shield up before any fight") + TEST_ASSERT(length(jugg.get_empty_held_indexes()), "The Juggernaut has no free fist beside its shield") + TEST_ASSERT(findtext(jugg.boss_gear_text(), "shield"), "The Juggernaut's examine doesn't show its shield") + + // The Pyromaniac: its fire suit and helmet keep fire off it, not a trait (CB-7). A real flamethrower, fuelled, and a real molotov in hand; a real gas mask on. 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/obj/item/flamethrower/flamer = pyro.boss_flamethrower() + TEST_ASSERT_NOTNULL(flamer, "The Pyromaniac holds no flamethrower") + TEST_ASSERT(bounty_pyro_flamer_fuelled(flamer), "The Pyromaniac's flamethrower has no igniter or plasma") + TEST_ASSERT(!flamer.lit, "The Pyromaniac's flamethrower is lit before any fight") + TEST_ASSERT(human_npc_gear_locked(flamer), "The Pyromaniac's flamethrower isn't locked to it") + TEST_ASSERT(human_npc_gear_locked(flamer.ptank), "The Pyromaniac's plasma tank isn't locked to it") + var/obj/item/reagent_containers/cup/glass/bottle/molotov/bottle = locate() in pyro.held_items + TEST_ASSERT_NOTNULL(bottle, "The Pyromaniac holds no molotov") + TEST_ASSERT(human_npc_gear_consumable(bottle), "The Pyromaniac's molotov isn't issued as a consumable") + TEST_ASSERT(istype(pyro.wear_mask, /obj/item/clothing/mask/gas), "The Pyromaniac isn't wearing a gas mask") + TEST_ASSERT(pyro.has_smoke_protection(), "The Pyromaniac's mask doesn't keep smoke out") + TEST_ASSERT(pyro.boss_hand_for_grenade(), "The Pyromaniac has no hand for its smoke grenade") + var/obj/item/card/id/pyro_card = pyro.wear_id + TEST_ASSERT(istype(pyro_card), "The Pyromaniac has no ID") + TEST_ASSERT_EQUAL(pyro.get_visible_name(), pyro.real_name, "Masked, the Pyromaniac doesn't go by its name") + TEST_ASSERT(!length(pyro_card.access), "The Pyromaniac's ID opens doors") + TEST_ASSERT(!pyro_card.registered_account?.account_balance, "The Pyromaniac's ID holds money") + TEST_ASSERT(human_npc_gear_locked(pyro_card), "The Pyromaniac's ID isn't locked to it") + for(var/obj/item/tank/internals/plasma/spare as anything in pyro.get_all_contents_type(/obj/item/tank/internals/plasma)) + TEST_ASSERT(human_npc_gear_locked(spare), "A Pyromaniac's plasma tank isn't locked to it") + + // The Demolitionist: a hard hat, its crowbar in its bag until the fight starts, and a real CNS rebooter in its head (C8). 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") + var/obj/item/organ/cyberimp/brain/anti_stun/implant = demo.boss_rebooter() + TEST_ASSERT_NOTNULL(implant, "The Demolitionist has no CNS rebooter") // BOUNTY_DEMOLITIONIST_REBOOTER + TEST_ASSERT_EQUAL(implant.owner, demo, "The Demolitionist's implant isn't in its body") + TEST_ASSERT(get_chrome_load(demo) <= get_chrome_capacity(demo), "The Demolitionist's rebooter puts it over its neural capacity") 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") @@ -174,10 +236,11 @@ 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). + // The Heavy: an ablative trenchcoat with its hood up (C8), 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") + TEST_ASSERT(istype(heavy.wear_suit, /obj/item/clothing/suit/hooded/ablative), "The Heavy isn't wearing its ablative coat") // BOUNTY_HEAVY_COAT + TEST_ASSERT(istype(heavy.head, /obj/item/clothing/head/hooded/ablative), "The Heavy's ablative hood isn't up") + TEST_ASSERT(human_npc_gear_locked(heavy.wear_suit) && human_npc_gear_locked(heavy.head), "The Heavy's coat and hood aren't locked to it") 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") @@ -406,6 +469,68 @@ boss.boss_strict_rotation = TRUE TEST_ASSERT_NULL(boss.boss_choose_ability(far), "The strict rotation chose the same ability twice in a row") +// ===== THE PYROMANIAC'S FLAMETHROWER: SWEEPS, A DRY TANK, A TANK CHANGE ===== + +/// Lit for the wind-up, a jet of the boss fire down the lit line; each sweep spends a share of the tank, dry after four; then it changes tanks for a spare in no less than three seconds, the empty gone +/datum/unit_test/voidcrew_bounty_boss/flamethrower + +/datum/unit_test/voidcrew_bounty_boss/flamethrower/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/hunter = hunter_at(spot(2, 2)) + pyro.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/obj/item/flamethrower/flamer = pyro.boss_flamethrower() + TEST_ASSERT_NOTNULL(flamer, "The Pyromaniac holds no flamethrower") + TEST_ASSERT_EQUAL(carried(pyro, /obj/item/tank/internals/plasma), 3, "The Pyromaniac doesn't carry its flamethrower's tank and two spares") // BOUNTY_PYROMANIAC_SPARE_TANKS + var/datum/action/cooldown/mob_cooldown/bounty_boss/flamer/sweep = ability_of(pyro, /datum/action/cooldown/mob_cooldown/bounty_boss/flamer) + ready(pyro) + TEST_ASSERT(sweep.worth_using(hunter), "The flamer isn't worth using two tiles off") + var/pressure_before = flamer.ptank.return_air().return_pressure() + TEST_ASSERT(sweep.Trigger(target = hunter), "The flamer didn't start") + TEST_ASSERT(flamer.lit, "The flamethrower wasn't lit for the wind-up") + TEST_ASSERT(sweep.finish_windup(sweep.pending_serial), "The flamer's wind-up didn't finish") + TEST_ASSERT(hunter.on_fire && hunter.getFireLoss() > 0, "The jet didn't burn and light the hunter on its line") + TEST_ASSERT(locate(/obj/effect/bounty_boss_fire_pool) in GLOB.bounty_boss_fire_pools, "The jet left no burning floor") + var/datum/gas_mixture/spare_air = flamer.ptank.return_air() + TEST_ASSERT(spare_air.return_pressure() < pressure_before, "The sweep spent none of the tank") + TEST_ASSERT(spare_air.return_pressure() > pressure_before * 0.7, "One sweep spent more than its share of the tank") + sleep(1.2 SECONDS) // BOUNTY_PYROMANIAC_FLAMER_SHUTOFF + TEST_ASSERT(!flamer.lit, "The valve wasn't shut after the sweep") + hunter.extinguish_mob() + for(var/obj/effect/bounty_boss_fire_pool/pool as anything in GLOB.bounty_boss_fire_pools) + qdel(pool) + + // Three more sweeps and the tank is dry: no more sweeps until it changes tanks + for(var/i in 1 to 3) + pyro.boss_spend_flamer_fuel(flamer) + TEST_ASSERT(!bounty_pyro_flamer_fuelled(flamer), "The tank isn't dry after four sweeps") // BOUNTY_PYROMANIAC_FLAMER_SWEEPS + TEST_ASSERT(!sweep.worth_using(hunter), "The flamer is worth using on a dry tank") + + // The change: the plan picks it, and it takes at least three seconds + var/datum/ai_controller/controller = pyro.ai_controller + TEST_ASSERT(pyro.boss_gear_plan(controller), "With a dry tank and a spare, the Pyromaniac didn't plan a tank change") + controller.CancelActions() + var/obj/item/tank/internals/plasma/empty = flamer.ptank + var/datum/ai_behavior/bounty_pyro_reload/change = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_pyro_reload) + var/started = world.time + change.setup(controller) + var/result = 0 + for(var/i in 1 to 30) + pyro.next_move = 0 + result = change.perform(1, controller) + if(result & (AI_BEHAVIOR_SUCCEEDED | AI_BEHAVIOR_FAILED)) + break + sleep(0.5 SECONDS) + change.finish_action(controller, !!(result & AI_BEHAVIOR_SUCCEEDED)) + TEST_ASSERT(result & AI_BEHAVIOR_SUCCEEDED, "The tank change didn't finish") + TEST_ASSERT(world.time - started >= 3 SECONDS, "The tank change took [world.time - started] deciseconds, under three seconds") // BOUNTY_PYROMANIAC_RELOAD_TIME + TEST_ASSERT(bounty_pyro_flamer_fuelled(flamer), "The flamethrower isn't fuelled after the change") + TEST_ASSERT(flamer.ptank != empty, "The empty tank is still on the flamethrower") + TEST_ASSERT_EQUAL(pyro.boss_flamer_sweeps, 0, "The sweep count didn't start over on the new tank") + sleep(0.2 SECONDS) + TEST_ASSERT(QDELETED(empty), "The dropped empty tank is loot") + TEST_ASSERT_EQUAL(carried(pyro, /obj/item/tank/internals/plasma), 2, "The Pyromaniac doesn't have its flamethrower's tank and one spare left") + TEST_ASSERT(sweep.worth_using(hunter), "The flamer isn't worth using after the change") + // ===== FIRE IS TG'S FIRE, ON ANYONE IT CATCHES (CB-8, CB-11) ===== /datum/unit_test/voidcrew_bounty_boss/fire @@ -618,64 +743,95 @@ 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) ===== +// ===== WORN OUT AND THE STIMULANT: REAL STATE, REAL PENS (CB-2, CB-4, CR-4, C8) ===== +/** + * Its stimulant pens go in by combat sense's own rule (human_npc_combat_sense.dm): when it tires in a + * fight, never at the fight's start, never while one is still in its blood, and nothing else injects + * them. Worn out, it takes the pen first and then falls back. + */ /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") + var/datum/ai_planning_subtree/npc_combat_sense/subtree = sense_subtree() + var/datum/component/npc_combat_sense/sense = boss.GetComponent(/datum/component/npc_combat_sense) + var/datum/ai_behavior/npc_combat_sense_stim/stim = GET_AI_BEHAVIOR(/datum/ai_behavior/npc_combat_sense_stim) - // Stamina works on it from the first hit (CB-2): no fresh immunity. + // Winded but not yet hostile: nothing. + boss.setStaminaLoss(55) + TEST_ASSERT_NULL(subtree.SelectBehaviors(controller, 1), "A boss that isn't fighting used a stimulant") + boss.setStaminaLoss(0) + TEST_ASSERT(fight(boss, hunter), "Test fixture: the boss didn't turn hostile") + + // Stamina works on it from the first hit (CB-2): no fresh immunity, and no pen at the fight's start. 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") + TEST_ASSERT_NULL(subtree.SelectBehaviors(controller, 1), "The boss reached for a stimulant before it tired") + + // Tired (55 of the 100 that stamcrit it), still short of worn out: it uses a real pen it carries. + boss.setStaminaLoss(55) + TEST_ASSERT(!boss.boss_is_worn_out(), "Test fixture: 55 stamina loss counts as worn out") + TEST_ASSERT_EQUAL(subtree.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "The tired boss didn't reach for its stimulant") + TEST_ASSERT(controller.current_behaviors[stim], "The tired boss didn't plan to use its stimulant") + var/obj/item/reagent_containers/hypospray/medipen/stimpack/pen = controller.blackboard["human_npc_stim_item"] // BB_HUMAN_NPC_STIM_ITEM + TEST_ASSERT(istype(pen), "The boss reached for something other than its stimpack") var/finished = FALSE - for(var/step in 1 to 10) + for(var/step in 1 to 6) ready_hands(boss) - var/result = treat.perform(1, controller, "human_npc_treat_item") // BB_HUMAN_NPC_TREAT_ITEM + var/result = stim.perform(1, controller, "human_npc_stim_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") + stim.finish_action(controller, TRUE, "human_npc_stim_item") 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") + TEST_ASSERT(pen.used_up, "The stimpack isn't spent") + TEST_ASSERT_EQUAL(sense.stims_used, 1, "The stimulant wasn't counted") + TEST_ASSERT(boss.boss_shield()?.loc == boss, "Using the stimulant cost the Juggernaut its shield") - // Worn out is its real stamina (over half its pool): it says so, shows the hunters, and falls back. - boss.setStaminaLoss(0) + // One in its blood: the second pen waits, however tired it gets. + TEST_ASSERT_NULL(subtree.SelectBehaviors(controller, 1), "With a stimulant already in its blood, it reached for another") + + // Worn out is its real stamina (over half its pool): it says so, shows the hunters, takes its second pen first... boss.reagents.clear_reagents() - boss.adjustStaminaLoss(70) + boss.setStaminaLoss(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_EQUAL(worn.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A worn-out boss did nothing") 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(controller.current_behaviors[stim], "Worn out with a pen left, it fell back without it") + finished = FALSE + for(var/step in 1 to 6) + ready_hands(boss) + var/result = stim.perform(1, controller, "human_npc_stim_item") + if(result & AI_BEHAVIOR_SUCCEEDED) + finished = TRUE + break + TEST_ASSERT(finished, "The worn-out boss never used its second pen") + stim.finish_action(controller, TRUE, "human_npc_stim_item") + TEST_ASSERT_EQUAL(sense.stims_used, 2, "The second stimulant wasn't counted") + + // ...then falls back, its abilities waiting. + TEST_ASSERT_EQUAL(worn.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A worn-out boss didn't fall back") + TEST_ASSERT(controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/run_away_from_target)], "A worn-out boss isn't falling back from its target") 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. + // No pens left: it just falls back, and once that is over it fights on. Its combat stimpack, its third pen, goes too. + boss.reagents.clear_reagents() + for(var/obj/item/reagent_containers/hypospray/medipen/left as anything in boss.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen)) + if(human_npc_is_stim(left)) + qdel(left) + TEST_ASSERT_NULL(human_npc_find_stim(boss), "Test fixture: the boss still has a stimulant") + TEST_ASSERT_EQUAL(worn.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "With no pens left, the worn-out boss didn't fall back") + TEST_ASSERT(!controller.current_behaviors[stim], "With no pens left, it tried to use one") 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") + TEST_ASSERT_NULL(worn.SelectBehaviors(controller, 1), "Its fall back over, the boss kept falling back") // Its stamina back, it is no longer worn out. boss.setStaminaLoss(0) @@ -950,3 +1106,394 @@ 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") + +// ===== EACH KIT'S ANSWER TO A DISABLER (C8) ===== + +/** + * The Juggernaut raises its real tower shield (the Phalanx buckler) the player's way once its fight is on. + * Raised, shots from the half of the map it faces stop at it; from the side or behind a disabler bolt + * lands (a riot shield lets beams through). It keeps hold of it through a stun, as locked gear does, and + * bullets from the flank wear it out until it breaks. + */ +/datum/unit_test/voidcrew_bounty_boss/juggernaut_shield + +/datum/unit_test/voidcrew_bounty_boss/juggernaut_shield/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(2, 2)) + var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(2, 4)) + var/datum/ai_controller/controller = boss.ai_controller + var/obj/item/shield/riot/phalanx_buckler/shield = boss.boss_shield() + TEST_ASSERT_NOTNULL(shield, "Test fixture: the Juggernaut has no shield") + var/datum/ai_planning_subtree/bounty_boss_gear/gear = GLOB.ai_subtrees[/datum/ai_planning_subtree/bounty_boss_gear] + TEST_ASSERT_NULL(gear.SelectBehaviors(controller, 1), "The Juggernaut raised its shield with no fight on") + + // Its fight on, it raises the shield it holds, used in hand + TEST_ASSERT(fight(boss, hunter), "Test fixture: the Juggernaut didn't turn hostile") + TEST_ASSERT_EQUAL(gear.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "The Juggernaut didn't plan to raise its shield") + var/datum/ai_behavior/bounty_juggernaut_raise_shield/raise = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_juggernaut_raise_shield) + ready_hands(boss) + TEST_ASSERT(raise.perform(1, controller) & AI_BEHAVIOR_SUCCEEDED, "The Juggernaut couldn't raise its shield") + TEST_ASSERT(shield.raised, "The Juggernaut's shield isn't raised") + TEST_ASSERT(!boss.boss_gear_plan(controller), "With its shield up, it went to raise it again") + TEST_ASSERT(boss.has_movespeed_modifier(/datum/movespeed_modifier/phalanx_raised), "The raised shield doesn't slow it as it slows anyone") + + // Facing its shooter: bolts from in front, straight or at an angle, stop at the shield + boss.setDir(NORTH) + TEST_ASSERT_EQUAL(shoot(boss, spot(2, 4), hunter), 0, "A bolt from in front got past the raised shield") + TEST_ASSERT_EQUAL(shoot(boss, spot(4, 4), hunter), 0, "A bolt from in front and to one side got past the raised shield") + TEST_ASSERT_EQUAL(boss.getStaminaLoss(), 0, "Bolts from in front did [boss.getStaminaLoss()] stamina damage through the shield") + // From the side and from behind they land, through riot armour's energy 10 + for(var/turf/flank as anything in list(spot(4, 2), spot(0, 2), spot(2, 0))) + boss.setStaminaLoss(0) + TEST_ASSERT(shoot(boss, flank, hunter), "A bolt from [flank.x - boss.x], [flank.y - boss.y] never landed") + TEST_ASSERT(abs(boss.getStaminaLoss() - 27) < 1, "A bolt from [flank.x - boss.x], [flank.y - boss.y] did [boss.getStaminaLoss()] stamina, not 27") + // Turned round, the same shooter gets through + boss.setStaminaLoss(0) + boss.setDir(SOUTH) + TEST_ASSERT(shoot(boss, spot(2, 4), hunter) && boss.getStaminaLoss() > 0, "Its back to the shooter, the shield still stopped the bolt") + boss.setStaminaLoss(0) + + // Paralysed, it keeps hold of its shield (the gear lock refuses the drop), still raised and still facing + boss.setDir(NORTH) + boss.Paralyze(2 SECONDS) + TEST_ASSERT(shield.loc == boss && shield.raised, "Paralysed, the Juggernaut let go of its shield") + TEST_ASSERT_EQUAL(shoot(boss, spot(2, 4), hunter), 0, "Down and facing its shooter, the shield stopped nothing") + boss.SetParalyzed(0) + boss.setStaminaLoss(0) + + // Bullets from the flank: a riot shield's block, and every block wears it until it breaks + var/shots = 0 + while(!QDELETED(shield) && shots < 80) + shots++ + shoot(boss, spot(4, 2), hunter, /obj/projectile/bullet/c9mm) + boss.adjustBruteLoss(-100) + TEST_ASSERT(QDELETED(shield), "[shots] bullets from the flank didn't break the Juggernaut's shield") + TEST_ASSERT_NULL(boss.boss_shield(), "The broken shield is still in the Juggernaut's hand") + TEST_ASSERT(shoot(boss, spot(2, 4), hunter) && boss.getStaminaLoss() > 0, "With its shield broken, bolts from in front still stop") + TEST_ASSERT(!findtext(boss.boss_gear_text(), "shield"), "The Juggernaut's examine still shows a shield it has lost") + boss.setStaminaLoss(0) + +/** + * The Heavy's ablative coat and hood: half of the disabler bolts that hit it reflect, wherever they hit, + * and the rest do what energy armour 60 lets through. A bullet goes into it like into cloth. + */ +/datum/unit_test/voidcrew_bounty_boss/heavy_coat + +/datum/unit_test/voidcrew_bounty_boss/heavy_coat/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/heavy, spot(2, 2)) + var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(2, 4)) + TEST_ASSERT(findtext(heavy.boss_gear_text(), "reflective"), "The Heavy's examine doesn't show its coat") + var/blocks = 0 + var/list/zones = list() + for(var/i in 1 to 240) + var/zone = pick(BODY_ZONE_CHEST, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG, BODY_ZONE_PRECISE_GROIN) + heavy.setStaminaLoss(0) + var/result = shoot(heavy, spot(2, 4), hunter, /obj/projectile/beam/disabler, zone) + if(result == BULLET_ACT_FORCE_PIERCE) + blocks++ + zones[zone] = TRUE + TEST_ASSERT_EQUAL(heavy.getStaminaLoss(), 0, "A bolt the coat reflected still did stamina damage") + continue + TEST_ASSERT(abs(heavy.getStaminaLoss() - 12) < 0.5, "A bolt on its [zone] did [heavy.getStaminaLoss()] stamina, not the 12 that energy armour 60 lets through") + TEST_ASSERT(blocks > 80 && blocks < 160, "The coat reflected [blocks] of 240 bolts, not about half") + for(var/zone in list(BODY_ZONE_CHEST, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG)) + TEST_ASSERT(zones[zone], "No bolt to its [zone] was ever reflected") + heavy.setStaminaLoss(0) + + // Bullets are another matter: no reflection, and bullet armour 10 + var/result = shoot(heavy, spot(2, 4), hunter, /obj/projectile/bullet/c9mm) + TEST_ASSERT(result && result != BULLET_ACT_FORCE_PIERCE, "A bullet bounced off the Heavy's coat") + TEST_ASSERT(heavy.getBruteLoss() > 12, "A pistol round did only [heavy.getBruteLoss()] brute through the coat") + +/** + * The Demolitionist's CNS rebooter, tg's own: its first stamina crit of a minute is over in a second, then + * it can't be put down for six; the next one, inside that minute, holds as long as anyone's. + */ +/datum/unit_test/voidcrew_bounty_boss/demolitionist_rebooter + +/datum/unit_test/voidcrew_bounty_boss/demolitionist_rebooter/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/demo = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist, spot(2, 2)) + demo.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/obj/item/organ/implant = demo.boss_rebooter() + TEST_ASSERT_NOTNULL(implant, "Test fixture: the Demolitionist has no implant") + TEST_ASSERT(findtext(demo.boss_gear_text(), "skull"), "The Demolitionist's examine doesn't show its implant") + + demo.apply_damage(120, STAMINA) + TEST_ASSERT(demo.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Test fixture: 120 stamina didn't stamcrit the Demolitionist") + sleep(1.5 SECONDS) + TEST_ASSERT(!demo.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "The rebooter didn't get the Demolitionist up a second after it went down") + TEST_ASSERT_EQUAL(demo.getStaminaLoss(), 0, "The rebooter left it [demo.getStaminaLoss()] stamina loss") + TEST_ASSERT(HAS_TRAIT_FROM(demo, TRAIT_STUNIMMUNE, REF(implant)), "The implant gave it no stun immunity") + + // The window: it can't go down again + demo.apply_damage(120, STAMINA) + TEST_ASSERT(!demo.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "It went down again inside its rebooter's window") + sleep(6 SECONDS) + TEST_ASSERT(!HAS_TRAIT(demo, TRAIT_STUNIMMUNE), "The rebooter's window never closed") + TEST_ASSERT_EQUAL(demo.getStaminaLoss(), 0, "The rebooter didn't clear its stamina as its window closed") + + // The gap: the rebooter is spent for a minute, and the next stamina crit holds long enough for cuffs + demo.apply_damage(120, STAMINA) + TEST_ASSERT(demo.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "After the window it couldn't be put down") + sleep(4.5 SECONDS) + TEST_ASSERT(demo.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "The rebooter got it up twice in a minute") + demo.setStaminaLoss(0) + +/** + * The Ghost under stun fire from beyond its dash: it breaks the shooter's line, a few steps to cover. + * With its dash ready and someone in reach, the dash goes first. + */ +/datum/unit_test/voidcrew_bounty_boss/ghost_cover + +/datum/unit_test/voidcrew_bounty_boss/ghost_cover/Run() + // A short wall east of the middle: the far corner behind it is out of a western hunter's line + change_turf(spot(3, 3), /turf/closed/wall) + change_turf(spot(3, 4), /turf/closed/wall) + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/ghost = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, spot(2, 2)) + var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(0, 2)) + var/datum/ai_controller/controller = ghost.ai_controller + var/datum/ai_planning_subtree/npc_combat_sense/subtree = sense_subtree() + var/datum/component/npc_combat_sense/sense = ghost.GetComponent(/datum/component/npc_combat_sense) + TEST_ASSERT(istype(sense?.rules, /datum/npc_combat_sense/bounty/boss/ghost), "The Ghost doesn't have its own combat sense") + TEST_ASSERT(fight(ghost, hunter), "Test fixture: the Ghost didn't turn hostile") + // Nothing of its own ready: its knife still in its pocket and its abilities waiting + ghost.boss_next_ability_at = world.time + 100 SECONDS + TEST_ASSERT_NULL(subtree.SelectBehaviors(controller, 1), "The Ghost took cover before anyone shot at it") + + TEST_ASSERT(shoot(ghost, spot(0, 2), hunter), "Test fixture: the bolt didn't land on the Ghost") + TEST_ASSERT(ghost.getStaminaLoss() > 0, "Test fixture: the bolt did no stamina damage") + TEST_ASSERT_EQUAL(subtree.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "Shot with a disabler, the Ghost stood in the open") + var/turf/cover = controller.blackboard["human_npc_cover"] // BB_HUMAN_NPC_COVER + TEST_ASSERT_NOTNULL(cover, "The Ghost picked no cover") + TEST_ASSERT(!human_npc_line_of_fire(get_turf(hunter), cover, PASSTABLE | PASSGLASS | PASSGRILLE), "The Ghost's cover is in the hunter's line of fire") + TEST_ASSERT(get_dist(ghost, cover) <= 5, "The Ghost's cover is further than it runs") // BOUNTY_GHOST_COVER_STEPS + TEST_ASSERT(controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/npc_combat_sense_take_cover)], "The Ghost didn't set off for its cover") + + // Its knife out and its dash ready, with the shooter in reach: the dash goes first + sense.end_exchange(controller) + controller.CancelActions() + 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), "Test fixture: the Ghost couldn't draw its knife") + ready(ghost) + ghost.setStaminaLoss(0) + shoot(ghost, spot(0, 2), hunter) + TEST_ASSERT_NULL(subtree.SelectBehaviors(controller, 1), "With its dash ready and the shooter in reach, the Ghost ran for cover") + TEST_ASSERT_NULL(controller.blackboard["human_npc_cover"], "With its dash ready, the Ghost picked cover") + ghost.setStaminaLoss(0) + +/** + * The Pyromaniac under stun fire goes for whoever is shooting it, until its flamer reaches them; a ready + * molotov or flamer goes first. The kits without a reaction of their own (Juggernaut, Heavy, Demolitionist) + * fight on as they were. + */ +/datum/unit_test/voidcrew_bounty_boss/pyromaniac_charge + +/datum/unit_test/voidcrew_bounty_boss/pyromaniac_charge/Run() + 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/first = hunter_at(spot(1, 0)) + var/mob/living/carbon/human/consistent/shooter = hunter_at(spot(4, 4)) + var/datum/ai_controller/controller = pyro.ai_controller + var/datum/ai_planning_subtree/npc_combat_sense/subtree = sense_subtree() + TEST_ASSERT(fight(pyro, first), "Test fixture: the Pyromaniac didn't turn hostile") + pyro.boss_next_ability_at = world.time + 100 SECONDS + + TEST_ASSERT(shoot(pyro, spot(4, 4), shooter), "Test fixture: the bolt didn't land on the Pyromaniac") + TEST_ASSERT_EQUAL(subtree.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "Shot with a disabler, the Pyromaniac didn't go for the shooter") + TEST_ASSERT_EQUAL(controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], shooter, "The Pyromaniac didn't turn on whoever shot it") + TEST_ASSERT(controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_close_in)], "The Pyromaniac isn't closing on its shooter") + TEST_ASSERT_EQUAL(controller.blackboard["human_npc_stun_shooter"], shooter, "The Pyromaniac is closing on someone else") // BB_HUMAN_NPC_STUN_SHOOTER + TEST_ASSERT_NULL(controller.blackboard["human_npc_cover"], "The Pyromaniac ran for cover") + controller.CancelActions() + + // Within its flamer's reach it stops closing: the flamer does the rest + pyro.forceMove(spot(2, 2)) + TEST_ASSERT_NULL(subtree.SelectBehaviors(controller, 1), "Within its flamer's reach, the Pyromaniac kept closing") + + // A molotov ready: it throws rather than runs + pyro.forceMove(spot(0, 0)) + ready(pyro) + shoot(pyro, spot(4, 4), shooter) + TEST_ASSERT_NULL(subtree.SelectBehaviors(controller, 1), "With its molotov ready, the Pyromaniac ran at the shooter instead") + pyro.setStaminaLoss(0) + + // The kits with no reaction of their own stand their ground (their answer is their gear) + for(var/kit_type in list(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, /mob/living/carbon/human/npc/bounty_criminal/boss/heavy, /mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = allocate(kit_type, spot(0, 4)) + TEST_ASSERT(fight(boss, shooter), "Test fixture: [kit_type] didn't turn hostile") + boss.boss_next_ability_at = world.time + 100 SECONDS + shoot(boss, spot(4, 4), shooter) + TEST_ASSERT_NULL(subtree.SelectBehaviors(boss.ai_controller, 1), "[kit_type] reacted to one disabler bolt with combat sense") + TEST_ASSERT_NULL(boss.ai_controller.blackboard["human_npc_cover"], "[kit_type] ran for cover") + qdel(boss) + +/** + * The Pyromaniac's smoke (C9): two real smoke grenades in its pockets, issued as consumables. Shot from + * past its flamer's reach it takes one out, pulls the pin and throws it halfway to the shooter: never at someone in its + * flamer's reach, never cuffed, never again inside its cooldown, and never more than the two it carries. + * The cloud is tg's. With the shooter out of sight, it makes for where the shots came from. + */ +/datum/unit_test/voidcrew_bounty_boss/pyromaniac_smoke + +/datum/unit_test/voidcrew_bounty_boss/pyromaniac_smoke/Run() + 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/shooter = hunter_at(spot(4, 4)) + var/mob/living/carbon/human/consistent/near = hunter_at(spot(1, 0)) + var/datum/ai_controller/controller = pyro.ai_controller + var/datum/action/cooldown/mob_cooldown/bounty_boss/smoke/smoke = ability_of(pyro, /datum/action/cooldown/mob_cooldown/bounty_boss/smoke) + TEST_ASSERT_NOTNULL(smoke, "The Pyromaniac has no smoke") + + // Two real smoke grenades, issued to it: nobody can strip them, and taken off it they are gone + TEST_ASSERT_EQUAL(carried(pyro, /obj/item/grenade/smokebomb), 2, "The Pyromaniac doesn't carry its two smoke grenades") + for(var/obj/item/grenade/smokebomb/grenade as anything in pyro.get_all_contents_type(/obj/item/grenade/smokebomb)) + TEST_ASSERT(human_npc_gear_consumable(grenade), "The Pyromaniac's smoke grenade isn't issued to it") + TEST_ASSERT(HAS_TRAIT(grenade, TRAIT_NO_STRIP), "The Pyromaniac's smoke grenade can be stripped") + TEST_ASSERT_EQUAL(grenade.det_time, 3 SECONDS, "The Pyromaniac's smoke grenade has a [grenade.det_time] fuse") // BOUNTY_PYROMANIAC_SMOKE_FUSE + TEST_ASSERT(!grenade.active && !pyro.is_holding(grenade), "The Pyromaniac has a smoke grenade out before any fight") + + TEST_ASSERT(fight(pyro, shooter), "Test fixture: the Pyromaniac didn't turn hostile") + ready(pyro) + TEST_ASSERT(!smoke.worth_using(shooter), "The Pyromaniac wanted its smoke before anyone shot it") + + // Shot from within its flamer's reach: no smoke + TEST_ASSERT(shoot(pyro, spot(1, 0), near), "Test fixture: the close bolt didn't land") + pyro.setStaminaLoss(0) + TEST_ASSERT(!smoke.worth_using(near), "The Pyromaniac wanted smoke for someone in its flamer's reach") + + // Shot from past it: the smoke goes first + TEST_ASSERT(shoot(pyro, spot(4, 4), shooter), "Test fixture: the bolt didn't land") + pyro.setStaminaLoss(0) + TEST_ASSERT_EQUAL(pyro.boss_choose_ability(shooter), smoke, "Shot from past its flamer's reach, the Pyromaniac didn't choose its smoke") + + // Stunned in its wind-up: the pin stays in, nothing is thrown, and the grenade is kept + TEST_ASSERT(smoke.Trigger(target = shooter), "The smoke didn't start for the stun check") + var/obj/item/grenade/smokebomb/kept = locate() in pyro.held_items + pyro.Paralyze(1 SECONDS) + TEST_ASSERT(!smoke.finish_windup(smoke.pending_serial), "The smoke went ahead with the Pyromaniac stunned") + TEST_ASSERT(!QDELETED(kept) && !kept.active, "A smoke grenade was set off by a stunned Pyromaniac") + pyro.SetParalyzed(0) + if(!QDELETED(kept) && !pyro.is_holding(kept)) + pyro.put_in_hands(kept) + TEST_ASSERT_EQUAL(carried(pyro, /obj/item/grenade/smokebomb), 2, "A stunned Pyromaniac lost a smoke grenade") + ready(pyro) + shoot(pyro, spot(4, 4), shooter) + pyro.setStaminaLoss(0) + + // Not while cuffed + var/obj/item/restraints/handcuffs/cuffs = new(pyro) + pyro.set_handcuffed(cuffs) + pyro.update_handcuffed() + TEST_ASSERT(pyro.is_restrained(), "Test fixture: the cuffs didn't go on") + TEST_ASSERT_NULL(pyro.boss_choose_ability(shooter), "The Pyromaniac chose an ability in cuffs") + pyro.set_handcuffed(null) + pyro.update_handcuffed() + qdel(cuffs) + // The cuffs knocked the grenade out of its hand (tg's): back in hand, so both stay its own + if(!QDELETED(kept) && !pyro.is_holding(kept)) + pyro.put_in_hands(kept) + TEST_ASSERT_EQUAL(carried(pyro, /obj/item/grenade/smokebomb), 2, "Test fixture: the Pyromaniac's dropped smoke grenade didn't go back in hand") + + // A lethal hit from past its reach counts too + controller.CancelActions() + var/datum/component/npc_combat_sense/sense = pyro.GetComponent(/datum/component/npc_combat_sense) + sense.end_exchange(controller) + pyro.boss_last_attacked_at = 0 + TEST_ASSERT(!smoke.worth_using(shooter), "The Pyromaniac wanted its smoke with nobody shooting at it") + pyro.boss_note_attacker(shooter) + TEST_ASSERT(smoke.worth_using(shooter), "Hurt from past its flamer's reach, the Pyromaniac didn't want its smoke") + + // It takes one out, aimed halfway to the shooter; the pin comes out as it throws + TEST_ASSERT(smoke.Trigger(target = shooter), "The smoke didn't start") + var/obj/item/grenade/smokebomb/first = locate() in pyro.held_items + TEST_ASSERT_NOTNULL(first, "The Pyromaniac didn't take out a smoke grenade") + TEST_ASSERT(!first.active, "The Pyromaniac pulled the pin before its wind-up was over") + TEST_ASSERT_EQUAL(smoke.landing, spot(2, 2), "The smoke is aimed at [smoke.landing], not halfway to the shooter") + TEST_ASSERT(smoke.next_use_time >= world.time + 19 SECONDS, "The smoke has no cooldown") // BOUNTY_PYROMANIAC_SMOKE_COOLDOWN + TEST_ASSERT(smoke.finish_windup(smoke.pending_serial), "The smoke's wind-up didn't finish") + TEST_ASSERT(!pyro.is_holding(first), "The Pyromaniac didn't throw its smoke grenade") + TEST_ASSERT(isturf(first.loc), "The thrown smoke grenade isn't loose") + TEST_ASSERT(first.active, "The Pyromaniac threw its smoke grenade with the pin in") + + // The cooldown holds, shot again or not + pyro.boss_next_ability_at = 0 + shoot(pyro, spot(4, 4), shooter) + pyro.setStaminaLoss(0) + TEST_ASSERT(pyro.boss_choose_ability(shooter) != smoke, "The Pyromaniac threw smoke again inside its cooldown") + + // The cloud is tg's: opaque smoke where the grenade goes off, and the grenade spent. tg starts the + // cloud inside the grenade and spreads it a tile per smoke tick, so give it time to fill in (and the + // Pyromaniac time to get back up from the stun above, tg's one-second get_up()) + var/turf/where = get_turf(first) + first.detonate() + TEST_ASSERT(QDELETED(first), "The smoke grenade wasn't used up") + controller.set_ai_status(AI_STATUS_OFF) + sleep(1.5 SECONDS) + controller.set_ai_status(AI_STATUS_ON) + var/obj/effect/particle_effect/fluid/smoke/cloud = locate() in where + TEST_ASSERT_NOTNULL(cloud, "No smoke came out of the grenade") + TEST_ASSERT(cloud.opacity, "The smoke can be seen through") + TEST_ASSERT_EQUAL(carried(pyro, /obj/item/grenade/smokebomb), 1, "The Pyromaniac doesn't have one smoke grenade left") + + // Out of sight in smoke, it makes for where the shots came from, not for where the shooter is now + var/obj/item/grenade/smokebomb/bounty_boss/wall = allocate(/obj/item/grenade/smokebomb/bounty_boss, spot(2, 2)) + wall.detonate() + TEST_ASSERT(!can_see(pyro, shooter, 9), "Test fixture: the Pyromaniac can see through the smoke") + controller.CancelActions() + pyro.boss_next_ability_at = world.time + 100 SECONDS + shoot(pyro, spot(4, 4), shooter) + pyro.setStaminaLoss(0) + shooter.forceMove(spot(3, 4)) + TEST_ASSERT(!can_see(pyro, shooter, 9), "Test fixture: the Pyromaniac can see its shooter round the smoke") + TEST_ASSERT_EQUAL(sense_subtree().SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "In smoke, the Pyromaniac stopped coming") + TEST_ASSERT_EQUAL(controller.blackboard["human_npc_stun_shooter"], spot(4, 4), "In smoke, the Pyromaniac isn't making for where the shots came from") // BB_HUMAN_NPC_STUN_SHOOTER + TEST_ASSERT(controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_close_in)], "In smoke, the Pyromaniac isn't moving") + controller.CancelActions() + + // Two grenades, two clouds: then none + ready(pyro) + TEST_ASSERT(smoke.Trigger(target = shooter), "The second smoke didn't start") + var/obj/item/grenade/smokebomb/second = locate() in pyro.held_items + TEST_ASSERT_NOTNULL(second, "The Pyromaniac didn't take out its second grenade") + smoke.finish_windup(smoke.pending_serial) + TEST_ASSERT(second.active, "The Pyromaniac didn't pull the pin on its second grenade") + if(!QDELETED(second)) + second.detonate() + ready(pyro) + pyro.boss_note_attacker(shooter) + TEST_ASSERT_EQUAL(carried(pyro, /obj/item/grenade/smokebomb), 0, "The Pyromaniac has smoke grenades left after two") + TEST_ASSERT(!smoke.worth_using(shooter), "The Pyromaniac wanted smoke with none left") + + for(var/turf/place as anything in RANGE_TURFS(9, spot(2, 2))) + for(var/obj/effect/particle_effect/fluid/smoke/puff in place) + qdel(puff) + +#ifdef BOUNTY_BOSS_RENDERS +/** + * Not a check: renders the kits whose looks changed (C8), before and after, facing each way, to + * data/c8_renders/. Compile with -DBOUNTY_BOSS_RENDERS to run it. "Before" puts the old kit back on the + * same body: no shield on the Juggernaut, SWAT armour and helmet on the Heavy. + */ +/datum/unit_test/voidcrew_bounty_boss/renders + +/datum/unit_test/voidcrew_bounty_boss/renders/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/jugg = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(1, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/heavy, spot(3, 1)) + jugg.ai_controller?.set_ai_status(AI_STATUS_OFF) + heavy.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/obj/item/shield/riot/phalanx_buckler/shield = jugg.boss_shield() + shield?.raise_shield(jugg) + for(var/facing in list(SOUTH, EAST, NORTH, WEST)) + jugg.setDir(facing) + heavy.setDir(facing) + fcopy(getFlatIcon(jugg, facing, no_anim = TRUE), "data/c8_renders/juggernaut_after_[dir2text(facing)].png") + fcopy(getFlatIcon(heavy, facing, no_anim = TRUE), "data/c8_renders/heavy_after_[dir2text(facing)].png") + qdel(shield) + qdel(heavy.wear_suit) + if(heavy.head) + qdel(heavy.head) + heavy.equip_to_slot_or_del(new /obj/item/clothing/suit/armor/swat(heavy), ITEM_SLOT_OCLOTHING) + heavy.equip_to_slot_or_del(new /obj/item/clothing/head/helmet/swat(heavy), ITEM_SLOT_HEAD) + for(var/facing in list(SOUTH, EAST, NORTH, WEST)) + jugg.setDir(facing) + heavy.setDir(facing) + fcopy(getFlatIcon(jugg, facing, no_anim = TRUE), "data/c8_renders/juggernaut_before_[dir2text(facing)].png") + fcopy(getFlatIcon(heavy, facing, no_anim = TRUE), "data/c8_renders/heavy_before_[dir2text(facing)].png") +#endif diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome.dm new file mode 100644 index 00000000000..a1e064ba4f6 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome.dm @@ -0,0 +1,687 @@ +/** + * Bounty hunting: chrome core's tests (C0), for voidcrew/modules/bounties/bounty_chrome.dm. + * + * Fork defines are included after the tests, so a test uses the literal value with a comment naming the + * define. Criminals are real human NPCs with the real implants in them; the tests read tg's own state. + * Their AI is switched off where a test drives the chrome by hand, so nothing else happens in between. + * + * Renders: compile with -DBOUNTY_CHROME_RENDERS and the dressed_to_show and malfunction tests write + * flat icons to data/bounty_chrome_renders/ (before: the same body and implants in the outfit it would + * have worn; after: the criminal as spawned). + */ + +/// A piece for the tests only: weight 0, so it never rolls and no admin is offered it. A Cascade lattice. +/datum/bounty_chrome_piece/unit_test + key = "unit_test" + name = "test chrome" + weight = 0 + organs = list(/obj/item/organ/cyberimp/cyberware/cascade) + +/// The test piece's move: a one second tell, then the lattice's own surge. It counts its hooks. +/datum/bounty_chrome_move/unit_test + piece_key = "unit_test" + name = "test surge" + action_type = /datum/action/cooldown/cyberware/cascade_surge + tell_time = 1 SECONDS + tell_sound = null + var/fights = 0 + var/ends = 0 + var/downs = 0 + var/deaths = 0 + var/emps = 0 + var/fired = 0 + var/list/cancels = list() + +/datum/bounty_chrome_move/unit_test/on_fight_start(atom/target) + fights++ + +/datum/bounty_chrome_move/unit_test/on_fight_end() + ends++ + +/datum/bounty_chrome_move/unit_test/on_downed() + downs++ + +/datum/bounty_chrome_move/unit_test/on_death() + deaths++ + +/datum/bounty_chrome_move/unit_test/on_emp(severity) + emps++ + +/datum/bounty_chrome_move/unit_test/cancel(reason) + cancels += reason + +/datum/bounty_chrome_move/unit_test/effect(atom/target) + fired++ + return ..() + +/// The chrome core's tests, and their helpers +/datum/unit_test/voidcrew_bounty_chrome + abstract_type = /datum/unit_test/voidcrew_bounty_chrome + +/// A record of `tier`, `archetype` and `style` or `kit`, carrying `chrome`, for a human +/datum/unit_test/voidcrew_bounty_chrome/proc/make_record(tier = 2, archetype = "normal", style = "brawler", kit, list/chrome) + var/datum/bounty_record/record = generate_bounty_record(tier, archetype, "planet", /datum/species/human) // BOUNTY_PLACEMENT_PLANET + record.tier = tier + record.archetype = archetype + record.style = archetype == "boss" ? null : style // BOUNTY_ARCHETYPE_BOSS + record.kit = kit + record.chrome = chrome + return record + +/// The criminal for `record` at `where`, built now, with no posting, deleted with the test +/datum/unit_test/voidcrew_bounty_chrome/proc/make_criminal(datum/bounty_record/record, turf/where) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(record, where || run_loc_floor_bottom_left, null) + if(criminal) + allocated += criminal + return criminal + +/// The organ types of the chrome in `body` +/datum/unit_test/voidcrew_bounty_chrome/proc/chrome_types(mob/living/carbon/body) + . = list() + for(var/obj/item/organ/organ in body.organs) + if(organ.GetComponent(/datum/component/cyberware)) + . += organ.type + +/// A person with a mind at `where`, deleted with the test +/datum/unit_test/voidcrew_bounty_chrome/proc/make_person(turf/where) + var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human/consistent, where || run_loc_floor_top_right) + person.mind_initialize() + return person + +/// A turf `dx`, `dy` from the bottom left of the test room +/datum/unit_test/voidcrew_bounty_chrome/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +// ===== THE PIECES ===== + +/// Every piece is real chrome that fits in a body on its own; the roll rules hold the design (companions never Lazarus or the Piledriver, the meek nothing, the fists and blades melee only); and the Ghost's kit chrome is what the roll fits around +/datum/unit_test/voidcrew_bounty_chrome/pieces + +/datum/unit_test/voidcrew_bounty_chrome/pieces/Run() + var/list/keys = list("cascade", "mantis", "gorilla", "redline", "piledriver", "lazarus", "deadeye") // BOUNTY_CHROME_* + for(var/key in keys) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + TEST_ASSERT_NOTNULL(piece, "There is no [key] piece") + TEST_ASSERT(length(piece.organs), "The [key] piece has no implants") + TEST_ASSERT(piece.weight > 0, "The [key] piece never rolls") + TEST_ASSERT(bounty_chrome_organs_fit(piece.organs), "The [key] piece doesn't fit in a body on its own") + for(var/organ_type in piece.organs) + TEST_ASSERT(ispath(organ_type, /obj/item/organ/cyberimp/cyberware) || ispath(organ_type, /obj/item/organ/cyberimp/arm/toolkit/cyberware) || ispath(organ_type, /obj/item/organ/eyes/robotic/cyberware), "The [key] piece's [organ_type] isn't chrome") + TEST_ASSERT(!("meek" in piece.archetypes), "The meek roll [key]") // BOUNTY_ARCHETYPE_MEEK + var/datum/bounty_chrome_piece/lazarus = GLOB.bounty_chrome_pieces["lazarus"] + var/datum/bounty_chrome_piece/piledriver = GLOB.bounty_chrome_pieces["piledriver"] + TEST_ASSERT(!lazarus.companion && !piledriver.companion, "Companions can roll Lazarus or the Piledriver") + for(var/melee_key in list("gorilla", "mantis")) + var/datum/bounty_chrome_piece/melee = GLOB.bounty_chrome_pieces[melee_key] + for(var/gun_style in list("pistol", "shotgun", "bottle")) + TEST_ASSERT(!melee.can_roll(3, "normal", gun_style, null, list()), "[melee_key] rolls on a [gun_style] criminal") + var/datum/bounty_chrome_piece/deadeye = GLOB.bounty_chrome_pieces["deadeye"] + TEST_ASSERT(deadeye.can_roll(1, "normal", "pistol", null, list()), "A pistol criminal can't roll Deadeye") + TEST_ASSERT(!deadeye.can_roll(3, "normal", "brawler", null, list()), "A brawler can roll Deadeye") + // Cascade and Redline share the operating-system slot + TEST_ASSERT(!bounty_chrome_organs_fit(bounty_chrome_organ_types(list("cascade", "redline"))), "Cascade and Redline fit in one body") + TEST_ASSERT(!bounty_chrome_organs_fit(bounty_chrome_organ_types(list("gorilla", "mantis"))), "Gorilla Arms and Mantis Blades fit in one pair of arms") + + // The Ghost's chrome, as the roll knows it, is what the real Ghost carries + var/mob/living/carbon/human/npc/bounty_criminal/ghost = make_criminal(make_record(3, "boss", null, "ghost")) // BOUNTY_TIER_MOST_WANTED, BOUNTY_KIT_GHOST + TEST_ASSERT(istype(ghost, /mob/living/carbon/human/npc/bounty_criminal/boss/ghost), "No Ghost spawned") + var/list/known = bounty_chrome_kit_organs("ghost") + var/list/carried = chrome_types(ghost) + for(var/organ_type in known) + TEST_ASSERT(organ_type in carried, "The Ghost doesn't carry [organ_type], which its rolls fit around") + for(var/organ_type in carried) + TEST_ASSERT(organ_type in known, "The Ghost carries [organ_type], which its rolls don't know about") + for(var/kit in list("juggernaut", "pyromaniac", "demolitionist", "heavy")) + var/mob/living/carbon/human/npc/bounty_criminal/boss = make_criminal(make_record(3, "boss", null, kit)) + TEST_ASSERT_EQUAL(length(chrome_types(boss)), length(bounty_chrome_kit_organs(kit)), "The [kit] carries chrome its rolls don't know about") + +// ===== ROLLING ===== + +/// Chrome rolls by tier, 10, 35 and 60 percent, with a second piece now and then from Wanted up; companions far less often, one piece, never Lazarus or the Piledriver; the meek never +/datum/unit_test/voidcrew_bounty_chrome/roll_odds + +/datum/unit_test/voidcrew_bounty_chrome/roll_odds/Run() + var/list/expected = list(10, 35, 60) // BOUNTY_CHROME_CHANCE_PETTY, _WANTED, _MOST_WANTED + var/tries = 1000 + for(var/tier in 1 to 3) + var/carriers = 0 + var/pairs = 0 + for(var/i in 1 to tries) + var/list/rolled = bounty_chrome_roll(tier, "normal", "brawler", null, list()) + if(!rolled) + continue + carriers++ + if(length(rolled) == 2) + pairs++ + TEST_ASSERT(length(rolled) <= (tier >= 2 ? 2 : 1), "A tier [tier] criminal rolled [length(rolled)] pieces") + var/percent = carriers * 100 / tries + TEST_ASSERT(abs(percent - expected[tier]) <= 5, "Tier [tier] carries chrome [percent]% of the time, not about [expected[tier]]%") + if(tier == 3) + var/second = pairs * 100 / max(carriers, 1) + TEST_ASSERT(abs(second - 30) <= 7, "A Most Wanted carrier has a second piece [second]% of the time, not about 30%") // BOUNTY_CHROME_SECOND_CHANCE + for(var/i in 1 to 200) + TEST_ASSERT_NULL(bounty_chrome_roll(3, "meek", "holdout", null, list()), "A meek criminal rolled chrome") + var/companions = 0 + for(var/i in 1 to tries) + var/list/rolled = bounty_chrome_roll_companion(3, "knife") + if(!rolled) + continue + companions++ + TEST_ASSERT_EQUAL(length(rolled), 1, "A companion rolled [length(rolled)] pieces") + TEST_ASSERT(!(rolled[1] in list("lazarus", "piledriver")), "A companion rolled [rolled[1]]") + var/companion_percent = companions * 100 / tries + TEST_ASSERT(abs(companion_percent - 20) <= 5, "A Most Wanted criminal's companion carries chrome [companion_percent]% of the time, not about 20%") // 60 / BOUNTY_CHROME_COMPANION_DIVISOR + +/// No roll ever puts two implants in one slot or goes over capacity, for any tier, style or kit (the Ghost's own chrome included), and the real bodies agree: nothing browns out +/datum/unit_test/voidcrew_bounty_chrome/no_brownout + +/datum/unit_test/voidcrew_bounty_chrome/no_brownout/Run() + var/list/styles = list("brawler", "knife", "pistol", "shotgun", "club", "bottle") + var/list/kits = list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy") + for(var/tier in 1 to 3) + for(var/style in styles) + for(var/i in 1 to 150) + var/list/rolled = bounty_chrome_roll(tier, "normal", style, null, list()) + TEST_ASSERT(bounty_chrome_organs_fit(bounty_chrome_organ_types(rolled)), "A tier [tier] [style] criminal rolled [jointext(rolled, ", ")], which won't fit") + for(var/kit in kits) + var/list/kit_organs = bounty_chrome_kit_organs(kit) + for(var/i in 1 to 150) + var/list/rolled = bounty_chrome_roll(tier, "boss", null, kit, kit_organs) + TEST_ASSERT(bounty_chrome_organs_fit(kit_organs + bounty_chrome_organ_types(rolled)), "A [kit] rolled [jointext(rolled, ", ")], which won't fit beside its kit's chrome") + // Real bodies: each piece alone, all that fits, and the most that fits beside the Ghost's chrome + var/list/sets = list() + for(var/key in list("cascade", "mantis", "gorilla", "redline", "piledriver", "lazarus", "deadeye")) + sets += list(list("normal", key == "deadeye" ? "pistol" : (key == "mantis" ? "knife" : "brawler"), null, list(key))) + sets += list(list("normal", "brawler", null, bounty_chrome_all_that_fits(list()))) + sets += list(list("boss", null, "ghost", bounty_chrome_all_that_fits(bounty_chrome_kit_organs("ghost")))) + sets += list(list("boss", null, "juggernaut", list("cascade", "gorilla"))) + for(var/list/body_set as anything in sets) + var/list/chrome = body_set[4] + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(3, body_set[1], body_set[2], body_set[3], chrome.Copy())) + TEST_ASSERT_NOTNULL(criminal, "No criminal spawned with [jointext(chrome, ", ")]") + TEST_ASSERT(get_chrome_load(criminal) <= get_chrome_capacity(criminal), "[jointext(chrome, ", ")] put [get_chrome_load(criminal)] load on a body of [get_chrome_capacity(criminal)]") + var/list/carried = chrome_types(criminal) + for(var/organ_type in bounty_chrome_organ_types(chrome)) + TEST_ASSERT(organ_type in carried, "[jointext(chrome, ", ")]: [organ_type] isn't in the body") + for(var/obj/item/organ/organ in criminal.organs) + var/datum/component/cyberware/ware = organ.GetComponent(/datum/component/cyberware) + TEST_ASSERT(!ware?.browned_out, "[jointext(chrome, ", ")]: [organ] browned out") + TEST_ASSERT(isnull(locate(/obj/item/organ/eyes) in get_turf(criminal)), "[jointext(chrome, ", ")]: the eyes it was born with lie on the floor") + qdel(criminal) + +// ===== THE BODY ===== + +/// The record's chrome is real implants in the body, with its moves; they burn out to scrap when the criminal dies +/datum/unit_test/voidcrew_bounty_chrome/installed + +/datum/unit_test/voidcrew_bounty_chrome/installed/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("gorilla", "lazarus"))) // BOUNTY_TIER_WANTED + var/list/carried = chrome_types(criminal) + for(var/organ_type in list(/obj/item/organ/cyberimp/cyberware/gorilla_arms, /obj/item/organ/cyberimp/cyberware/gorilla_arms/left, /obj/item/organ/cyberimp/cyberware/lazarus)) + TEST_ASSERT(organ_type in carried, "A criminal with Gorilla Arms and Lazarus doesn't carry [organ_type]") + TEST_ASSERT_EQUAL(length(criminal.record.chrome), 2, "The record lost chrome that fits") + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + TEST_ASSERT_NOTNULL(chrome, "A chromed criminal has no chrome AI") + TEST_ASSERT(("gorilla" in chrome.keys) && ("lazarus" in chrome.keys), "The chrome AI doesn't know what it carries") + var/turf/here = get_turf(criminal) + criminal.death() + TEST_ASSERT_EQUAL(length(chrome_types(criminal)), 0, "A dead criminal still carries working chrome") + var/scrap = 0 + for(var/obj/item/burnt_chrome/burnt in here) + scrap++ + TEST_ASSERT_EQUAL(scrap, 3, "A dead criminal's three implants left [scrap] pieces of scrap") + // Prisoners and decoys never take the record's chrome, nor does the kingpin's record roll any + var/datum/bounty_record/kingpin_record = generate_bounty_record(3, "normal", "kingpin_lounge") // BOUNTY_PLACEMENT_KINGPIN + TEST_ASSERT_NULL(kingpin_record.chrome, "A kingpin's record rolled chrome") + var/mob/living/carbon/human/npc/bounty_criminal/meek = make_criminal(make_record(2, "meek", "holdout", null, list("gorilla")), spot(1, 1)) + TEST_ASSERT_NULL(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) in meek.organs, "A meek criminal took the chrome on its record") + TEST_ASSERT_NULL(meek.GetComponent(/datum/component/bounty_chrome), "A meek criminal got a chrome AI") + +/// Carriers dress so the chrome shows: their own jumpsuit stays on (chrome draws over it), no coat over arm or chest chrome, no gloves over arm chrome; armour stays on; a mini-boss wears its kit +/datum/unit_test/voidcrew_bounty_chrome/dressed_to_show + +/datum/unit_test/voidcrew_bounty_chrome/dressed_to_show/Run() + var/list/cases = list( + list("gorilla", "brawler", 1), + list("gorilla", "brawler", 2), + list("mantis", "knife", 1), + list("cascade", "brawler", 2), + list("redline", "club", 2), + list("piledriver", "brawler", 2), + list("lazarus", "brawler", 2), + list("deadeye", "pistol", 1), + ) + for(var/list/dress_case as anything in cases) + var/key = dress_case[1] + var/tier = dress_case[3] + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(tier, "normal", dress_case[2], null, list(key))) + var/label = "A tier [tier] [key] carrier" + if(key == "gorilla" || key == "mantis") + TEST_ASSERT_NULL(criminal.gloves, "[label] wears gloves over the arms") + // Chrome draws over the jumpsuit, so nobody trades theirs for trousers or shorts + TEST_ASSERT_NOTNULL(criminal.w_uniform, "[label] lost its clothes") + TEST_ASSERT(!istype(criminal.w_uniform, /obj/item/clothing/under/shorts), "[label] changed into [criminal.w_uniform] to show its chrome") + if(tier >= 2) + TEST_ASSERT(istype(criminal.wear_suit, /obj/item/clothing/suit/armor/vest), "[label] took its armour vest off") + else if(key in list("gorilla", "mantis", "cascade", "redline")) + TEST_ASSERT_NULL(criminal.wear_suit, "[label] wears a coat over the chrome") + TEST_ASSERT(criminal.belt || dress_case[2] == "brawler" || dress_case[2] == "knife" || dress_case[2] == "club", "[label] lost the belt its style carries") +#ifdef BOUNTY_CHROME_RENDERS + render_pair(criminal, "[key]_t[tier]") +#endif + qdel(criminal) + // A mini-boss keeps its kit on + var/mob/living/carbon/human/npc/bounty_criminal/juggernaut = make_criminal(make_record(3, "boss", null, "juggernaut", list("gorilla"))) // BOUNTY_KIT_JUGGERNAUT + TEST_ASSERT(istype(juggernaut.wear_suit, /obj/item/clothing/suit/armor/riot), "A Juggernaut with Gorilla Arms took its riot armour off") + TEST_ASSERT((/obj/item/organ/cyberimp/cyberware/gorilla_arms in chrome_types(juggernaut)), "A Juggernaut's Gorilla Arms didn't go in") + // An outfit with a sealed suit stays shut + var/datum/outfit/sealed = new + sealed.uniform = /obj/item/clothing/under/color/grey + sealed.suit = /obj/item/clothing/suit/space/eva + sealed.head = /obj/item/clothing/head/helmet/space/eva + bounty_chrome_expose_outfit(sealed, list(/obj/item/organ/cyberimp/cyberware/cascade)) + TEST_ASSERT_EQUAL(sealed.uniform, /obj/item/clothing/under/color/grey, "Chrome under a space suit undressed it") + TEST_ASSERT_EQUAL(sealed.suit, /obj/item/clothing/suit/space/eva, "Chrome under a space suit took the suit off") + qdel(sealed) + +#ifdef BOUNTY_CHROME_RENDERS +/// Writes `criminal` as spawned, and the same face and implants in the outfit it would have worn, to data/bounty_chrome_renders/ +/datum/unit_test/voidcrew_bounty_chrome/proc/render_pair(mob/living/carbon/human/npc/bounty_criminal/criminal, name) + for(var/facing in list(SOUTH, NORTH)) + fcopy(getFlatIcon(criminal, facing), "data/bounty_chrome_renders/[name]_after_[dir2text(facing)].png") + var/mob/living/carbon/human/dummy/before = bounty_look_dummy(criminal.record.look, criminal.bounty_build_outfit("green"), null) // ZONE_GREEN + if(!before) + return + for(var/organ_type in chrome_types(criminal)) + var/obj/item/organ/organ = new organ_type + organ.Insert(before, special = TRUE, movement_flags = DELETE_IF_REPLACED) + for(var/facing in list(SOUTH, NORTH)) + fcopy(getFlatIcon(before, facing), "data/bounty_chrome_renders/[name]_before_[dir2text(facing)].png") + qdel(before) +#endif + +// ===== MOVES ===== + +/// A move tells for its tell_time (never under 0.8 s), standing still and outlined, then fires the implant's own action; the fight's hooks reach it +/datum/unit_test/voidcrew_bounty_chrome/moves + +/datum/unit_test/voidcrew_bounty_chrome/moves/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("unit_test"))) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + TEST_ASSERT_NOTNULL(chrome, "The test chrome gave no chrome AI") + var/datum/bounty_chrome_move/unit_test/move = chrome.move_of(/datum/bounty_chrome_move/unit_test) + TEST_ASSERT_NOTNULL(move, "The test piece's move wasn't made") + TEST_ASSERT_EQUAL(move.owner, criminal, "The move isn't in its criminal") + TEST_ASSERT_NULL(chrome.plan(criminal.ai_controller, 1), "A criminal out of a fight planned a chrome move") + + TEST_ASSERT(criminal.ai_start_fight(hunter), "The criminal wouldn't fight") + chrome.update_fight() + TEST_ASSERT_EQUAL(move.fights, 1, "The move didn't hear the fight start") + TEST_ASSERT_NULL(chrome.plan(criminal.ai_controller, 1), "A chrome move started before the fight's opening") + chrome.next_move_at = 0 + TEST_ASSERT(move.can_start(hunter), "The move won't start on a hunter in sight") + TEST_ASSERT_EQUAL(chrome.plan(criminal.ai_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A ready move didn't start") + TEST_ASSERT_EQUAL(chrome.telling, move, "The move's tell isn't running") + TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The criminal doesn't stand still through the tell") // BOUNTY_CHROME_TRAIT + TEST_ASSERT_NOTNULL(criminal.get_filter(move.tell_filter()), "The tell has no outline") + TEST_ASSERT_EQUAL(chrome.plan(criminal.ai_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "Something else was planned during the tell") + sleep(0.6 SECONDS) + TEST_ASSERT_EQUAL(move.fired, 0, "The move fired before its tell was over") + sleep(0.6 SECONDS) + TEST_ASSERT_EQUAL(move.fired, 1, "The move didn't fire after its tell") + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/cyberware_cascade_window), "The tell ended but the lattice's own surge didn't run") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The criminal still stands still after the tell") + TEST_ASSERT_NULL(criminal.get_filter(move.tell_filter()), "The tell's outline stayed on") + TEST_ASSERT(chrome.next_move_at >= world.time + 3 SECONDS, "Another chrome move may start straight away") // BOUNTY_CHROME_MOVE_GAP + TEST_ASSERT(!move.can_start(hunter), "The move would start again with the lattice cycling") + + // The floor of a tell: a move asking for less still tells for 0.8 s + var/datum/bounty_chrome_move/unit_test/quick = new + quick.tell_time = 1 + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/wrapped = new(criminal) + wrapped.set_move(quick) + TEST_ASSERT(wrapped.windup >= 0.8 SECONDS, "A mini-boss chrome ability winds up for [wrapped.windup / 10] s") // BOUNTY_CHROME_TELL_MIN + qdel(wrapped) + qdel(quick) + + // The fight ending, and death, reach the move + criminal.ai_calm_down() + chrome.update_fight() + TEST_ASSERT_EQUAL(move.ends, 1, "The move didn't hear the fight end") + criminal.death() + TEST_ASSERT_EQUAL(move.deaths, 1, "The move didn't hear its criminal die") + +/// A tell cut short by a stun, an EMP, crit or cuffs fires nothing; a criminal that can't act starts nothing +/datum/unit_test/voidcrew_bounty_chrome/interrupted + +/datum/unit_test/voidcrew_bounty_chrome/interrupted/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 0)) + var/list/ways = list("stunned", "emp", "downed", "restrained") + for(var/way in ways) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("unit_test"))) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/unit_test/move = chrome.move_of(/datum/bounty_chrome_move/unit_test) + criminal.ai_start_fight(hunter) + chrome.update_fight() + TEST_ASSERT(chrome.start_move(move, hunter), "[way]: the tell didn't start") + switch(way) + if("stunned") + criminal.Paralyze(3 SECONDS) + if("emp") + criminal.emp_act(EMP_HEAVY) + if("downed") + // Into soft crit, short of hard crit and death + criminal.setOxyLoss(criminal.health + 20) + if("restrained") + var/obj/item/restraints/handcuffs/cuffs = new(criminal) + criminal.set_handcuffed(cuffs) + criminal.update_handcuffed() + TEST_ASSERT_NULL(chrome.telling, "[way]: the tell kept running") + TEST_ASSERT(length(move.cancels), "[way]: the move wasn't told its tell was cut short") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "[way]: the hold stayed on") + sleep(1.2 SECONDS) + TEST_ASSERT_EQUAL(move.fired, 0, "[way]: the move fired anyway") + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/cyberware_cascade_window), "[way]: the lattice surged anyway") + chrome.next_move_at = 0 + if(way != "emp") + TEST_ASSERT(!move.can_start(hunter), "[way]: a criminal that can't act would start a move") + if(way == "emp") + TEST_ASSERT_EQUAL(move.emps, 1, "The EMP didn't reach the move") + TEST_ASSERT(!move.ready(), "The lattice is ready through its EMP reboot") + if(way == "downed") + TEST_ASSERT_EQUAL(move.downs, 1, "Going down didn't reach the move") + qdel(criminal) + +/// A mini-boss uses its chrome through its own ability rotation: the wind-up is the move's tell, the effect the implant's own action +/datum/unit_test/voidcrew_bounty_chrome/boss + +/datum/unit_test/voidcrew_bounty_chrome/boss/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = make_criminal(make_record(3, "boss", null, "juggernaut", list("unit_test"))) + boss.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability = locate() in boss.boss_abilities + TEST_ASSERT_NOTNULL(ability, "The Juggernaut's chrome isn't in its ability rotation") + var/datum/bounty_chrome_move/unit_test/move = ability.move + TEST_ASSERT_NOTNULL(move, "The chrome ability runs no move") + TEST_ASSERT_EQUAL(move.owner, boss, "The chrome ability runs someone else's move") + TEST_ASSERT(ability.windup >= 0.8 SECONDS, "The chrome ability winds up for [ability.windup / 10] s") // BOUNTY_CHROME_TELL_MIN + TEST_ASSERT(ability.worth_using(hunter), "The chrome ability isn't worth using on a hunter in sight") + // A move with its own lines says one of them, and the kit's ability line stays unsaid: one line per tell + move.tell_lines = list("Watch this.") + var/datum/component/bounty_identity_voice/voice = boss.LoadComponent(/datum/component/bounty_identity_voice) + COOLDOWN_RESET(voice, line_cooldown) + voice.last_line = null + TEST_ASSERT(ability.Trigger(target = hunter), "The chrome ability wouldn't start") + TEST_ASSERT_NULL(voice.last_line, "The Juggernaut barked its kit's ability line over its chrome's own tell line") + TEST_ASSERT_EQUAL(boss.boss_busy, "windup", "The Juggernaut isn't winding up") + TEST_ASSERT_NOTNULL(boss.get_filter(move.tell_filter()), "The wind-up has no outline") + sleep(1.3 SECONDS) + TEST_ASSERT_EQUAL(move.fired, 1, "The chrome ability didn't fire after its wind-up") + TEST_ASSERT_NOTNULL(boss.has_status_effect(/datum/status_effect/cyberware_cascade_window), "The wind-up ended but the lattice's own surge didn't run") + TEST_ASSERT_NULL(boss.get_filter(move.tell_filter()), "The wind-up's outline stayed on") + // Cut short, nothing fires and the look goes + var/mob/living/carbon/human/npc/bounty_criminal/boss/second = make_criminal(make_record(3, "boss", null, "juggernaut", list("unit_test"))) + second.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/second_ability = locate() in second.boss_abilities + var/datum/bounty_chrome_move/unit_test/second_move = second_ability.move + TEST_ASSERT(second_ability.Trigger(target = hunter), "The second chrome ability wouldn't start") + second.emp_act(EMP_HEAVY) + TEST_ASSERT_NULL(second.boss_busy, "An EMP didn't cut the Juggernaut's chrome wind-up short") + TEST_ASSERT_NULL(second.get_filter(second_move.tell_filter()), "The cut-short wind-up's outline stayed on") + sleep(1.3 SECONDS) + TEST_ASSERT_EQUAL(second_move.fired, 0, "A cut-short chrome wind-up fired anyway") + +// ===== WHO AN AREA MOVE MAY CATCH ===== + +/// An area move never starts with someone outside the fight where it lands: a bystander, its own companion; the one it is going for, someone it holds a grudge against, the dead and the site's creatures don't stop it +/datum/unit_test/voidcrew_bounty_chrome/bystanders + +/datum/unit_test/voidcrew_bounty_chrome/bystanders/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler")) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/turf/hunter_spot = spot(2, 0) + var/turf/bystander_spot = spot(2, 1) + var/mob/living/carbon/human/hunter = make_person(hunter_spot) + var/mob/living/carbon/human/bystander = make_person(bystander_spot) + TEST_ASSERT(!bounty_chrome_area_clear(criminal, list(hunter_spot)), "An area move starts on someone not in its fight") + criminal.body_add_grudge(hunter) + TEST_ASSERT(bounty_chrome_area_clear(criminal, list(hunter_spot)), "An area move won't start on someone who attacked it") + TEST_ASSERT(!bounty_chrome_area_clear(criminal, list(hunter_spot, bystander_spot)), "An area move starts with a bystander in it") + TEST_ASSERT(bounty_chrome_area_clear(criminal, list(bystander_spot), bystander), "An area move won't start on the one it is aimed at") + criminal.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, bystander) + TEST_ASSERT(bounty_chrome_area_clear(criminal, list(bystander_spot)), "An area move won't start on the one it is going for") + criminal.ai_controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + // A crewmate of someone it holds a grudge against is in the fight too: an idle friend can't shield the crew + var/datum/team/voidcrew/crew = new + LAZYADD(hunter.mind.ship_teams, crew) + LAZYADD(bystander.mind.ship_teams, crew) + var/crewmate_clear = bounty_chrome_area_clear(criminal, list(bystander_spot)) + hunter.mind.ship_teams = null + bystander.mind.ship_teams = null + qdel(crew) + TEST_ASSERT(crewmate_clear, "An idle crewmate of the one who attacked it stops an area move") + // Its own companion is in the way, never a target + var/list/buddies = criminal.spawn_companions(1, TRUE) + TEST_ASSERT(length(buddies), "No companion spawned") + allocated += buddies + var/mob/living/carbon/human/npc/bounty_companion/buddy = buddies[1] + var/turf/buddy_spot = spot(4, 1) + buddy.forceMove(buddy_spot) + TEST_ASSERT(!bounty_chrome_area_clear(criminal, list(buddy_spot)), "An area move starts on its own companion") + TEST_ASSERT(!bounty_chrome_in_posse(buddy, criminal), "A companion counts its own criminal as fair game") + // The dead, and creatures with nobody behind them, don't stop it + bystander.death() + TEST_ASSERT(bounty_chrome_area_clear(criminal, list(bystander_spot)), "A dead bystander stops an area move") + var/turf/mouse_spot = spot(4, 0) + allocate(/mob/living/basic/mouse, mouse_spot) + TEST_ASSERT(bounty_chrome_area_clear(criminal, list(mouse_spot)), "A mouse stops an area move") + +// ===== NOTICED ===== + +/// A bounty NPC feels a chrome read through real optics and tells the reader off, once in a while; never while hiding or fighting, and never with nothing to read +/datum/unit_test/voidcrew_bounty_chrome/read_noticed + +/datum/unit_test/voidcrew_bounty_chrome/read_noticed/Run() + var/mob/living/carbon/human/reader = make_person(spot(3, 0)) + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = new + TEST_ASSERT(optics.Insert(reader, special = TRUE, movement_flags = DELETE_IF_REPLACED), "The reader's optics didn't go in") + // Chrome abilities never join mob.actions (chrome_hud.dm): the read lives on the optics + var/datum/action/cooldown/cyberware/chrome_read/read = locate() in optics.actions + TEST_ASSERT_NOTNULL(read, "The reader's optics have no chrome read") + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(1, "normal", "brawler", null, list("gorilla"))) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(read.Trigger(target = criminal), "The chrome read didn't go off") + TEST_ASSERT(criminal.chrome_read_answer_at > world.time, "A calm criminal didn't feel the read") + TEST_ASSERT(!bounty_chrome_read_noticed(criminal, reader), "A criminal answered two reads in a row") + criminal.chrome_read_answer_at = 0 + criminal.hidden = TRUE + TEST_ASSERT(!bounty_chrome_read_noticed(criminal, reader), "A hiding criminal answered a read") + criminal.hidden = FALSE + criminal.ai_start_fight(reader) + TEST_ASSERT(!bounty_chrome_read_noticed(criminal, reader), "A fighting criminal stopped to answer a read") + var/mob/living/carbon/human/npc/bounty_criminal/clean = make_criminal(make_record(1, "normal", "brawler"), spot(1, 1)) + TEST_ASSERT(!bounty_chrome_read_noticed(clean, reader), "A criminal with no chrome answered a read") + +/// An NPC under fire says its dodge at most once every 1.5 s; a player always hears theirs +/datum/unit_test/voidcrew_bounty_chrome/dodge_line + +/datum/unit_test/voidcrew_bounty_chrome/dodge_line/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(1, "normal", "brawler")) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/datum/component/cyberware_dodge/arbiter = criminal.LoadComponent(/datum/component/cyberware_dodge) + var/obj/projectile/bullet/shot = allocate(/obj/projectile/bullet) + arbiter.perform_sidestep(criminal, shot) + TEST_ASSERT_EQUAL(arbiter.last_message_at, world.time, "An NPC's first dodge wasn't said") + var/said_at = world.time - 1 SECONDS + arbiter.last_message_at = said_at + arbiter.perform_sidestep(criminal, shot) + TEST_ASSERT_EQUAL(arbiter.last_message_at, said_at, "An NPC said a second dodge within 1.5 s") // CYBERWARE_DODGE_LINE_GAP + arbiter.last_message_at = world.time - 2 SECONDS + arbiter.perform_sidestep(criminal, shot) + TEST_ASSERT_EQUAL(arbiter.last_message_at, world.time, "An NPC never said its dodge again") + +// ===== A MALFUNCTION ===== + +/// An EMP that knocks chrome out shows it for the reboot, as a picture only; it ends when the NPC dies, and an NPC with no chrome shows nothing +/datum/unit_test/voidcrew_bounty_chrome/malfunction + +/datum/unit_test/voidcrew_bounty_chrome/malfunction/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("gorilla"))) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/health_before = criminal.health + criminal.emp_act(EMP_HEAVY) + sleep(2) + var/datum/status_effect/bounty_chrome_malfunction/sparks = criminal.has_status_effect(/datum/status_effect/bounty_chrome_malfunction) + TEST_ASSERT_NOTNULL(sparks, "An EMP knocked chrome out with no malfunction to see") + TEST_ASSERT(sparks.duration > world.time + 5 SECONDS, "The malfunction is shorter than the chrome's reboot") + TEST_ASSERT_EQUAL(criminal.health, health_before, "The malfunction hurt them") +#ifdef BOUNTY_CHROME_RENDERS + fcopy(getFlatIcon(criminal, SOUTH), "data/bounty_chrome_renders/malfunction_south.png") +#endif + criminal.death() + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/bounty_chrome_malfunction), "A corpse kept malfunctioning") + var/mob/living/carbon/human/npc/bounty_criminal/clean = make_criminal(make_record(2, "normal", "brawler"), spot(1, 1)) + clean.emp_act(EMP_HEAVY) + sleep(2) + TEST_ASSERT_NULL(clean.has_status_effect(/datum/status_effect/bounty_chrome_malfunction), "An EMP on a criminal with no chrome showed a malfunction") + +// ===== FUGITIVES ===== + +/** + * A chromed fugitive passing as a patron looks and examines like its decoys, who carry the same chrome + * under the same clothes; when the act drops, the coat and gloves over its chrome come off and it shows. + * P6's helpers (voidcrew_bounty_outpost.dm) make the outpost. + */ +/datum/unit_test/voidcrew_bounty_outpost/chrome_fugitive + +/datum/unit_test/voidcrew_bounty_outpost/chrome_fugitive/Run() + outpost = make_outpost(/obj/structure/overmap/trader_outpost/outfitter) + outpost.lobby_alcove_turfs = list(run_loc_floor_top_right) + var/datum/bounty_record/record = generate_bounty_record(2, "normal", "trader_outpost", /datum/species/human) // BOUNTY_TIER_WANTED, BOUNTY_PLACEMENT_TRADER_OUTPOST + record.style = "brawler" // BOUNTY_STYLE_BRAWLER + record.chrome = list("gorilla") // BOUNTY_CHROME_GORILLA + var/datum/criminal_bounty/outpost_test/posting = allocate(/datum/criminal_bounty/outpost_test) + posting.record = record + posting.placement_kind = "trader_outpost" + posting.site_ref = WEAKREF(outpost) + posting.value = 1234 + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = make_fugitive(/mob/living/carbon/human/npc/bounty_criminal/normal, null, record) + fugitive.posting_ref = WEAKREF(posting) + posting.criminal_ref = WEAKREF(fugitive) + GLOB.criminal_bounties += posting + fugitive.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) in fugitive.organs, "The fugitive's Gorilla Arms didn't go 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(length(decoys), "No decoys to compare with") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) in decoy.organs, "A decoy doesn't carry its fugitive's chrome") + TEST_ASSERT_NULL(locate(/obj/item/organ/eyes) in get_turf(decoy), "A decoy's own eyes lie on the floor") + // Under the same clothes + for(var/slot in list(ITEM_SLOT_ICLOTHING, ITEM_SLOT_OCLOTHING, ITEM_SLOT_GLOVES, ITEM_SLOT_FEET)) + var/obj/item/fugitive_wears = fugitive.get_item_by_slot(slot) + var/obj/item/decoy_wears = decoy.get_item_by_slot(slot) + TEST_ASSERT_EQUAL(fugitive_wears?.type, decoy_wears?.type, "Passing as a patron, the fugitive wears [fugitive_wears || "nothing"] where a decoy wears [decoy_wears || "nothing"]") + var/mob/living/carbon/human/viewer = make_hunter() + TEST_ASSERT_EQUAL(examine_without_features(decoy, viewer), examine_without_features(fugitive, viewer), "The chromed fugitive examines differently from a decoy") + // The act drops: the coat and gloves come off over the plating, the pockets stay + var/obj/item/pocketed = fugitive.l_store + var/obj/item/shirt = fugitive.w_uniform + posting.outpost_confront(fugitive, viewer) + TEST_ASSERT(!fugitive.blended, "The confronted fugitive is still blending in") + TEST_ASSERT_NULL(fugitive.wear_suit, "The exposed fugitive's coat still covers the plating") + TEST_ASSERT_NULL(fugitive.gloves, "The exposed fugitive's gloves still cover the plating") + TEST_ASSERT_EQUAL(fugitive.w_uniform, shirt, "The exposed fugitive changed its clothes: chrome shows over a jumpsuit") + if(pocketed) + TEST_ASSERT_EQUAL(fugitive.l_store, pocketed, "The exposed fugitive lost what was in its pocket") + TEST_ASSERT_NOTNULL(decoy.wear_suit, "A decoy took its coat off with the fugitive") + +/** + * `patron`'s examine as plain text without its own features: their lines, and the lines naming the + * glasses or scarf it wears for them, matched by the item's own name (an embedded "[item]" reads "the + * circle glasses", where examine says "some circle glasses"). + */ +/datum/unit_test/voidcrew_bounty_outpost/chrome_fugitive/proc/examine_without_features(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_items = list() + for(var/obj/item/worn in list(patron.glasses, patron.wear_neck)) + feature_items += worn.name + 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) + continue + var/names_feature_item = FALSE + for(var/item_name in feature_items) + if(findtext(plain, item_name)) + names_feature_item = TRUE + break + if(!names_feature_item) + lines += plain + return lines.Join(" | ") + +// ===== THE BOUNTY PANEL ===== + +/// The panel spawns a criminal with exactly the chrome asked for (any piece, none, all that fits) or rolls it as usual for the style or kit picked; a style the chrome can't fight with is changed, and what won't fit beside a kit's own chrome is left off with a word to the admin +/datum/unit_test/voidcrew_bounty_admin/chrome + +/datum/unit_test/voidcrew_bounty_admin/chrome/Run() + var/turf/spot = run_loc_floor_bottom_left + 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) + var/list/choices = panel.chrome_choices() + TEST_ASSERT_EQUAL(length(choices), 10, "The chrome menu offers [length(choices)] choices, not rolled, none, the seven pieces and all of it") + TEST_ASSERT_EQUAL(choices["All of it"], "all", "The chrome menu has no all of it") // BOUNTY_ADMIN_CHROME_ALL + + // Deadeye on a brawler: a style it would never roll on, kept + var/mob/living/carbon/human/npc/bounty_criminal/deadeye = panel.admin_spawn_criminal(operator, 2, "normal", "brawler", null, spot, list("deadeye")) + allocated += deadeye + TEST_ASSERT(locate(/obj/item/organ/eyes/robotic/cyberware/deadeye) in deadeye.organs, "The chosen Deadeye isn't in them") + TEST_ASSERT(length(deadeye.record.chrome) == 1 && deadeye.record.chrome[1] == "deadeye", "The record doesn't carry the chosen chrome") + TEST_ASSERT_EQUAL(deadeye.record.style, "brawler", "Deadeye changed a brawler's style") + // Gorilla Arms on a pistol criminal: they fight with their fists instead + var/mob/living/carbon/human/npc/bounty_criminal/gorilla = panel.admin_spawn_criminal(operator, 2, "normal", "pistol", null, spot, list("gorilla")) + allocated += gorilla + TEST_ASSERT_EQUAL(gorilla.record.style, "brawler", "A pistol criminal given Gorilla Arms came out a [gorilla.record.style]") + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/left) in gorilla.organs, "The chosen Gorilla Arms aren't in them") + // None + var/mob/living/carbon/human/npc/bounty_criminal/clean = panel.admin_spawn_criminal(operator, 3, "normal", null, null, spot, list()) + allocated += clean + TEST_ASSERT_NULL(clean.record.chrome, "Asking for no chrome still gave them some") + TEST_ASSERT_NULL(clean.GetComponent(/datum/component/bounty_chrome), "Asking for no chrome still gave them a chrome AI") + // All of it: the cyberpsycho (C6, chrome/bounty_cyberpsycho.dm), whose body carries it all, nothing browned out + var/mob/living/carbon/human/npc/bounty_criminal/all = panel.admin_spawn_criminal(operator, 3, "normal", "brawler", null, spot, "all") + allocated += all + TEST_ASSERT(istype(all, /mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho), "All of it spawned [all?.type], not the cyberpsycho") + TEST_ASSERT_EQUAL(all?.record?.kit, "cyberpsycho", "All of it isn't on the record as the cyberpsycho's kit") // BOUNTY_KIT_CYBERPSYCHO + TEST_ASSERT(get_chrome_load(all) > 20, "All of it carries only [get_chrome_load(all)] load") // CYBERWARE_BASE_CAPACITY + TEST_ASSERT(get_chrome_load(all) <= get_chrome_capacity(all), "All of it browned them out") + // Redline on a Ghost: its own Cascade has the slot, so it's left off and the admin hears why + var/mob/living/carbon/human/npc/bounty_criminal/ghost = panel.admin_spawn_criminal(operator, 3, "boss", "ghost", null, spot, list("redline")) + allocated += ghost + TEST_ASSERT_NULL(ghost.record.chrome, "A Ghost took a Redline core beside its Cascade lattice") + TEST_ASSERT_NULL(locate(/obj/item/organ/cyberimp/cyberware/redline) in ghost.organs, "A Ghost has a Redline core in it") + TEST_ASSERT(panel.said("didn't fit"), "The admin wasn't told the Redline didn't fit") + // Rolled as usual: for the style asked for + for(var/i in 1 to 40) + var/datum/bounty_record/pistol = generate_bounty_record(3, "normal", "planet") + pistol.style = "pistol" + panel.admin_set_chrome(pistol, "roll") // BOUNTY_ADMIN_CHROME_ROLL + for(var/key in pistol.chrome) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[key] + TEST_ASSERT(piece?.can_roll(3, "normal", "pistol", null, list()), "A pistol criminal rolled as usual got [key]") + // Through the menu + panel.answers = list("Spawn a criminal with chosen chrome", "Normal", "Wanted", "Brawler", "Gorilla Arms", "None") + panel.run_menu(operator) + TEST_ASSERT_EQUAL(length(panel.missed), 0, "The chrome spawn menu did not offer: [jointext(panel.missed, "; ")]") + 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 chrome spawn menu put nobody at the admin's feet") + allocated += from_menu + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) in from_menu.organs, "The chrome spawn menu's criminal has no Gorilla Arms") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_cascade.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_cascade.dm new file mode 100644 index 00000000000..6bf48a69880 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_cascade.dm @@ -0,0 +1,289 @@ +/** + * Bounty hunting: the Cascade lattice on a criminal (C1), for + * voidcrew/modules/bounties/chrome/bounty_chrome_cascade.dm. + * + * Fork defines are included after the tests, so a test uses the literal value with a comment naming the + * define. Criminals are real human NPCs with the player's lattice in them; the tests read tg's state. + * Their AI is off, and each test drives the chrome by hand. + * + * Renders: compile with -DBOUNTY_CHROME_RENDERS and the renders test writes flat icons to + * data/bounty_chrome_renders/ (the carrier, and the lattice's afterimage at a few hues). + */ +/datum/unit_test/voidcrew_bounty_chrome_cascade + abstract_type = /datum/unit_test/voidcrew_bounty_chrome_cascade + +/// A record of `tier`, `archetype` and `style` or `kit`, carrying `chrome`, for a human +/datum/unit_test/voidcrew_bounty_chrome_cascade/proc/make_record(tier = 2, archetype = "normal", style = "brawler", kit, list/chrome) + var/datum/bounty_record/record = generate_bounty_record(tier, archetype, "planet", /datum/species/human) // BOUNTY_PLACEMENT_PLANET + record.tier = tier + record.archetype = archetype + record.style = archetype == "boss" ? null : style // BOUNTY_ARCHETYPE_BOSS + record.kit = kit + record.chrome = chrome + return record + +/// The criminal for `record` at `where`, its AI off, deleted with the test +/datum/unit_test/voidcrew_bounty_chrome_cascade/proc/make_criminal(datum/bounty_record/record, turf/where) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(record, where || run_loc_floor_bottom_left, null) + if(criminal) + allocated += criminal + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + return criminal + +/// A person with a mind at `where`, deleted with the test +/datum/unit_test/voidcrew_bounty_chrome_cascade/proc/make_person(turf/where) + var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human/consistent, where || run_loc_floor_top_right) + person.mind_initialize() + return person + +/// A turf `dx`, `dy` from the bottom left of the test room (a 5x5 floor) +/datum/unit_test/voidcrew_bounty_chrome_cascade/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +/// Whether the lattice's window is open on `body` +/datum/unit_test/voidcrew_bounty_chrome_cascade/proc/surging(mob/living/body) + return !isnull(body.has_status_effect(/datum/status_effect/cyberware_cascade_window)) + +/// The lattice's own surge button in `body` +/datum/unit_test/voidcrew_bounty_chrome_cascade/proc/surge_action(mob/living/carbon/human/npc/body) + return bounty_chrome_action(body, /datum/action/cooldown/cyberware/cascade_surge) + +// ===== THE SURGE ===== + +/// The lattice's own surge fires after its tell (a glow and a whine, standing still, at least 0.8 s), early in a fight, and the body and its AI then run at the lattice's pace +/datum/unit_test/voidcrew_bounty_chrome_cascade/surge + +/datum/unit_test/voidcrew_bounty_chrome_cascade/surge/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("cascade"))) // BOUNTY_TIER_WANTED, BOUNTY_CHROME_CASCADE + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/cascade) in criminal.organs, "The criminal has no lattice in it") + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + TEST_ASSERT_NOTNULL(chrome, "A criminal with a lattice has no chrome AI") + var/datum/bounty_chrome_move/cascade/move = chrome.move_of(/datum/bounty_chrome_move/cascade) + TEST_ASSERT_NOTNULL(move, "The lattice has no move") + TEST_ASSERT(move.tell_time >= 0.8 SECONDS, "The surge's tell is [move.tell_time / 10] s") // BOUNTY_CHROME_TELL_MIN + TEST_ASSERT(move.boss_usable, "A mini-boss can't use the lattice") + + TEST_ASSERT(criminal.ai_start_fight(hunter), "The criminal wouldn't fight") + chrome.update_fight() + TEST_ASSERT(chrome.next_move_at - world.time <= 1.5 SECONDS, "The first surge waits [(chrome.next_move_at - world.time) / 10] s into the fight") // BOUNTY_CHROME_OPENING + TEST_ASSERT_NULL(chrome.plan(criminal.ai_controller, 1), "It surged the moment the fight started") + chrome.next_move_at = 0 + TEST_ASSERT(move.can_start(hunter), "It won't surge with a hunter close and in sight") + var/slowdown_before = criminal.cached_multiplicative_slowdown + TEST_ASSERT_EQUAL(chrome.plan(criminal.ai_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A ready surge didn't start") + TEST_ASSERT_EQUAL(chrome.telling, move, "The surge's tell isn't running") + TEST_ASSERT_NOTNULL(criminal.get_filter(move.tell_filter()), "The tell doesn't glow") + TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "It doesn't stand still through the tell") // BOUNTY_CHROME_TRAIT + sleep(0.6 SECONDS) + TEST_ASSERT(!surging(criminal), "The lattice surged before the tell was over") + sleep(0.4 SECONDS) + TEST_ASSERT(surging(criminal), "The tell ended but the lattice's own surge didn't run") + var/datum/action/cooldown/cyberware/cascade_surge/surge_button = surge_action(criminal) + TEST_ASSERT(surge_button.next_use_time > world.time + 50 SECONDS, "The surge didn't start the lattice's own minute of cooldown") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "It still stands still in the window") + TEST_ASSERT_NULL(criminal.get_filter(move.tell_filter()), "The tell's glow stayed on") + // The lattice's speed is on the body, and the AI moves the body at its own pace + TEST_ASSERT(abs(criminal.cached_multiplicative_slowdown - (slowdown_before - 1)) < 0.01, "The window's pace is [criminal.cached_multiplicative_slowdown], not the lattice's [slowdown_before - 1]") + TEST_ASSERT(abs(criminal.ai_controller.movement_delay - criminal.cached_multiplicative_slowdown) < 0.01, "Its AI moves it every [criminal.ai_controller.movement_delay], not at its body's pace [criminal.cached_multiplicative_slowdown]") + TEST_ASSERT(!move.can_start(hunter), "It would surge again with the lattice cycling") + chrome.next_move_at = 0 + TEST_ASSERT_NULL(chrome.plan(criminal.ai_controller, 1), "It started a second surge in the window") + +/// An EMP, a stun or crit during the tell stops it: no surge and no cooldown spent; a stunned or downed criminal starts none +/datum/unit_test/voidcrew_bounty_chrome_cascade/interrupted + +/datum/unit_test/voidcrew_bounty_chrome_cascade/interrupted/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 0)) + for(var/way in list("emp", "stunned", "downed")) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("cascade"))) + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/cascade/move = chrome.move_of(/datum/bounty_chrome_move/cascade) + TEST_ASSERT(criminal.ai_start_fight(hunter), "[way]: the criminal wouldn't fight") + chrome.update_fight() + TEST_ASSERT(chrome.start_move(move, hunter), "[way]: the tell didn't start") + switch(way) + if("emp") + criminal.emp_act(EMP_HEAVY) + if("stunned") + criminal.Paralyze(3 SECONDS) + if("downed") + // Into soft crit, short of hard crit and death + criminal.setOxyLoss(criminal.health + 20) + TEST_ASSERT_NULL(chrome.telling, "[way]: the tell kept running") + sleep(1.1 SECONDS) + TEST_ASSERT(!surging(criminal), "[way]: the lattice surged anyway") + var/datum/action/cooldown/cyberware/cascade_surge/surge_button = surge_action(criminal) + TEST_ASSERT(surge_button.next_use_time <= world.time, "[way]: the lattice's cooldown was spent on a surge that never came") + chrome.next_move_at = 0 + if(way == "emp") + TEST_ASSERT(!move.ready(), "The lattice is ready through its EMP reboot") + else + TEST_ASSERT(!move.can_start(hunter), "[way]: it would start a surge") + TEST_ASSERT_NULL(chrome.plan(criminal.ai_controller, 1), "[way]: it planned a surge") + qdel(criminal) + +// ===== IN THE WINDOW ===== + +/** + * A gunman in the window strafes across its line to its target, a step at a time, paced by its body: + * never twice inside the gap or its move delay, never held still, never off its leash, and a companion + * never off its criminal's. A fighter with no gun ready closes in through its AI instead, and the + * strafing ends with the window. + */ +/datum/unit_test/voidcrew_bounty_chrome_cascade/strafe + +/datum/unit_test/voidcrew_bounty_chrome_cascade/strafe/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/gunman = make_criminal(make_record(2, "normal", "pistol", null, list("cascade")), spot(0, 2)) // BOUNTY_STYLE_PISTOL + var/datum/component/bounty_chrome/chrome = gunman.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/cascade/move = chrome.move_of(/datum/bounty_chrome_move/cascade) + TEST_ASSERT(gunman.ai_start_fight(hunter), "The gunman wouldn't fight") + chrome.update_fight() + var/datum/bounty_style/style = GLOB.bounty_styles["pistol"] + var/obj/item/gun/gun = style.carried_ranged(gunman) + TEST_ASSERT_NOTNULL(gun, "The gunman carries no pistol") + TEST_ASSERT(human_npc_take_in_hand(gunman, gun), "The gunman couldn't draw its pistol") + TEST_ASSERT_NOTNULL(style.ready_in_hand(gunman), "The pistol in its hand won't fire") + + TEST_ASSERT(!move.strafe(), "It strafed with no lattice running") + TEST_ASSERT(move.fire(hunter), "The lattice didn't surge") + TEST_ASSERT(surging(gunman), "The surge opened no window") + TEST_ASSERT_NOTNULL(move.strafe_timer, "Nothing strafes in the window") + move.next_strafe_at = 0 + move.last_step_at = 0 + var/turf/strafed_from = get_turf(gunman) + TEST_ASSERT(move.strafe(), "A gunman in the window didn't strafe") + TEST_ASSERT(get_turf(gunman) != strafed_from, "It strafed without moving") + TEST_ASSERT_EQUAL(gunman.x, strafed_from.x, "Its strafe went toward or away from its target") + TEST_ASSERT_EQUAL(get_dist(gunman, hunter), get_dist(strafed_from, hunter), "Its strafe changed its distance") + TEST_ASSERT_NOTNULL(locate(/obj/effect/temp_visual/decoy/fading/cascade) in strafed_from, "Its strafe left no afterimage") + TEST_ASSERT_EQUAL(move.last_step_at, world.time, "Its step wasn't noted") + + // Paced by its body: never again inside the gap, and never sooner than its move delay + TEST_ASSERT(!move.strafe(), "It strafed twice at once") + move.next_strafe_at = 0 + TEST_ASSERT(gunman.cached_multiplicative_slowdown > 0, "The gunman's body moves with no delay at all") + TEST_ASSERT(!move.strafe(), "It stepped again sooner than its body's move delay") + move.last_step_at = 0 + + // Held still, it doesn't + ADD_TRAIT(gunman, TRAIT_IMMOBILIZED, TRAIT_GENERIC) + TEST_ASSERT(!move.strafe(), "Held still, it strafed") + REMOVE_TRAIT(gunman, TRAIT_IMMOBILIZED, TRAIT_GENERIC) + + // Off its leash it doesn't: its site is the one row it stands on + var/turf/corner = spot(0, 0) + gunman.site_bounds = list(corner.x, gunman.y, corner.x + 4, gunman.y, corner.z) + var/turf/leashed_at = get_turf(gunman) + TEST_ASSERT(!move.strafe(), "It strafed off its leash") + TEST_ASSERT_EQUAL(get_turf(gunman), leashed_at, "It moved off its leash") + gunman.site_bounds = null + + // With no gun ready it closes in through its AI instead + bounty_ai_apply_style(gunman, "brawler") // BOUNTY_STYLE_BRAWLER + TEST_ASSERT(!move.strafe(), "A brawler strafed instead of closing in") + bounty_ai_apply_style(gunman, "pistol") + TEST_ASSERT(move.strafe(), "Its gun back in play, it didn't strafe") + + // A companion's steps stay on its criminal's leash + var/list/buddies = gunman.spawn_companions(1, TRUE) + TEST_ASSERT(length(buddies), "No companion spawned") + allocated += buddies + var/mob/living/carbon/human/npc/bounty_companion/buddy = buddies[1] + buddy.ai_controller?.set_ai_status(AI_STATUS_OFF) + buddy.forceMove(spot(1, 2)) + TEST_ASSERT("cascade" in bounty_chrome_install_now(buddy, list("cascade")), "The companion's lattice didn't go in") + var/datum/component/bounty_chrome/buddy_chrome = buddy.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/cascade/buddy_move = buddy_chrome?.move_of(/datum/bounty_chrome_move/cascade) + TEST_ASSERT_NOTNULL(buddy_move, "The companion's lattice has no move") + buddy.ai_join_fight(hunter) + buddy.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + bounty_ai_apply_style(buddy, "pistol") + var/obj/item/gun/buddy_gun = new /obj/item/gun/ballistic/automatic/pistol/aps(get_turf(buddy)) + TEST_ASSERT(buddy.put_in_hands(buddy_gun), "The companion couldn't hold a pistol") + TEST_ASSERT(buddy_move.fire(hunter), "The companion's lattice didn't surge") + buddy_move.next_strafe_at = 0 + buddy_move.last_step_at = 0 + gunman.site_bounds = list(corner.x, buddy.y, corner.x + 4, buddy.y, corner.z) + var/turf/buddy_was = get_turf(buddy) + TEST_ASSERT(!buddy_move.strafe(), "A companion strafed off its criminal's leash") + TEST_ASSERT_EQUAL(get_turf(buddy), buddy_was, "A companion moved off its criminal's leash") + gunman.site_bounds = null + TEST_ASSERT(buddy_move.strafe(), "A companion on its criminal's ground didn't strafe") + + // The window ends, and the strafing with it + gunman.remove_status_effect(/datum/status_effect/cyberware_cascade_window) + move.strafe_pulse() + TEST_ASSERT_NULL(move.strafe_timer, "It kept strafing after the window") + TEST_ASSERT(gunman.has_status_effect(/datum/status_effect/cyberware_cascade_crash), "The window ended with no crash") + +// ===== MINI-BOSSES ===== + +/** + * One lattice, one driver: a Ghost's kit lattice is fired by its dash, so a rolled Cascade never goes + * in beside it, and a Cascade move handed to a Ghost never drives it. A Juggernaut with a rolled + * lattice surges through its ability rotation. + */ +/datum/unit_test/voidcrew_bounty_chrome_cascade/bosses + +/datum/unit_test/voidcrew_bounty_chrome_cascade/bosses/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost = make_criminal(make_record(3, "boss", null, "ghost", list("cascade"))) // BOUNTY_TIER_MOST_WANTED, BOUNTY_KIT_GHOST + TEST_ASSERT(istype(ghost, /mob/living/carbon/human/npc/bounty_criminal/boss/ghost), "No Ghost spawned") + TEST_ASSERT_NULL(ghost.record.chrome, "A Ghost's record kept a second lattice") + var/lattices = 0 + for(var/obj/item/organ/cyberimp/cyberware/cascade/lattice in ghost.organs) + lattices++ + TEST_ASSERT_EQUAL(lattices, 1, "The Ghost carries [lattices] lattices") + var/datum/component/bounty_chrome/ghost_chrome = ghost.GetComponent(/datum/component/bounty_chrome) + TEST_ASSERT(!ghost_chrome?.move_of(/datum/bounty_chrome_move/cascade), "The Ghost's kit lattice got a chrome move") + ghost_chrome = bounty_chrome_equip(ghost, list("cascade")) + var/datum/bounty_chrome_move/cascade/ghost_move = ghost_chrome?.move_of(/datum/bounty_chrome_move/cascade) + TEST_ASSERT_NOTNULL(ghost_move, "A Cascade move handed to the Ghost wasn't made") + TEST_ASSERT(ghost_move.ready(), "The Ghost's lattice isn't ready") + TEST_ASSERT(!ghost_move.can_start(hunter), "A Cascade move would fire the lattice the Ghost's dash fires") + TEST_ASSERT(!ghost_move.boss_ability?.worth_using(hunter), "The Ghost's rotation would fire its kit lattice a second way") + + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut = make_criminal(make_record(3, "boss", null, "juggernaut", list("cascade")), spot(1, 1)) // BOUNTY_KIT_JUGGERNAUT + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/wrapped in juggernaut.boss_abilities) + if(istype(wrapped.move, /datum/bounty_chrome_move/cascade)) + ability = wrapped + TEST_ASSERT_NOTNULL(ability, "The Juggernaut's lattice isn't in its ability rotation") + TEST_ASSERT(ability.windup >= 0.8 SECONDS, "The Juggernaut's surge winds up for [ability.windup / 10] s") // BOUNTY_CHROME_TELL_MIN + TEST_ASSERT(ability.worth_using(hunter), "The Juggernaut won't surge at a hunter in sight") + TEST_ASSERT(ability.Trigger(target = hunter), "The Juggernaut's surge wouldn't start") + TEST_ASSERT(!surging(juggernaut), "The Juggernaut surged before its wind-up") + sleep(1.2 SECONDS) + TEST_ASSERT(surging(juggernaut), "The Juggernaut's wind-up ended with no surge") + +// ===== RENDERS ===== + +/** + * Not a check: with -DBOUNTY_CHROME_RENDERS, writes a Cascade carrier (a brawler and a gunman) and the + * lattice's afterimage at three hues to data/bounty_chrome_renders/, for a person to look at. + */ +/datum/unit_test/voidcrew_bounty_chrome_cascade/renders + +/datum/unit_test/voidcrew_bounty_chrome_cascade/renders/Run() + var/mob/living/carbon/human/npc/bounty_criminal/brawler = make_criminal(make_record(2, "normal", "brawler", null, list("cascade")), spot(1, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/gunman = make_criminal(make_record(2, "normal", "pistol", null, list("cascade")), spot(3, 1)) + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/cascade) in brawler.organs, "The brawler has no lattice") + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/cascade) in gunman.organs, "The gunman has no lattice") +#ifdef BOUNTY_CHROME_RENDERS + var/datum/bounty_style/style = GLOB.bounty_styles["pistol"] + var/obj/item/gun/gun = style.carried_ranged(gunman) + if(gun) + human_npc_take_in_hand(gunman, gun) + for(var/facing in list(SOUTH, EAST)) + fcopy(getFlatIcon(brawler, facing), "data/bounty_chrome_renders/cascade_brawler_[dir2text(facing)].png") + fcopy(getFlatIcon(gunman, facing), "data/bounty_chrome_renders/cascade_gunman_[dir2text(facing)].png") + // The afterimage a step leaves, tinted as the lattice's trail is (a flat icon drops an atom's colour, so the tint goes on by hand) + var/obj/effect/temp_visual/decoy/fading/cascade/afterimage = new(spot(2, 3), gunman, 0) + for(var/hue in list(0, 120, 280)) + var/icon/trail = getFlatIcon(gunman, EAST) + trail.MapColors(arglist(afterimage.cascade_tint_matrix(hue))) + fcopy(trail, "data/bounty_chrome_renders/cascade_afterimage_[hue].png") + qdel(afterimage) +#endif diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_deadeye.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_deadeye.dm new file mode 100644 index 00000000000..8c15708ab1f --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_deadeye.dm @@ -0,0 +1,153 @@ +/** + * Deadeye link on a bounty gunman (voidcrew/modules/bounties/chrome/bounty_chrome_deadeye.dm): the AI's + * opening lock and its tell, then the implant's own tag (ware_pro_combat.dm) homing its real rounds, and + * letting go when the mark breaks line of sight. Real human NPCs, real implants and a real pistol. + */ + +/// The test's record of the last round the gunman fired: the projectile, read after the optics have had their say +/datum/unit_test/voidcrew_bounty_chrome/var/obj/projectile/last_round + +/datum/unit_test/voidcrew_bounty_chrome/proc/note_round(mob/living/source, obj/projectile/shot, datum/fired_from, atom/clicked) + SIGNAL_HANDLER + last_round = shot + +/// A Petty pistol criminal with Deadeye optics, its AI off, fighting `hunter`. Returns the criminal. +/datum/unit_test/voidcrew_bounty_chrome/proc/deadeye_gunman(mob/living/hunter, style = "pistol") // BOUNTY_STYLE_PISTOL + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(1, "normal", style, null, list("deadeye"))) // BOUNTY_TIER_PETTY, BOUNTY_CHROME_DEADEYE + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + criminal.ai_start_fight(hunter) + return criminal + +/// Its opening lock comes half a second into the fight: a one second tell (red eyes, a red line, and it keeps acting), then the implant's tag on the hunter, and its next real rounds home in +/datum/unit_test/voidcrew_bounty_chrome/deadeye_lock + +/datum/unit_test/voidcrew_bounty_chrome/deadeye_lock/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = deadeye_gunman(hunter) + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = criminal.get_organ_slot(ORGAN_SLOT_EYES) + TEST_ASSERT(istype(optics), "The gunman has no Deadeye optics") + var/datum/component/bounty_chrome/chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/deadeye/move = chrome_ai?.move_of(/datum/bounty_chrome_move/deadeye) + TEST_ASSERT_NOTNULL(move, "A Deadeye carrier has no Deadeye move") + var/eyes_before = criminal.get_left_eye_color() + chrome_ai.update_fight() + TEST_ASSERT_NULL(chrome_ai.telling, "The lock started the moment the fight did") + sleep(0.7 SECONDS) // BOUNTY_DEADEYE_OPENING 0.5 seconds + TEST_ASSERT_EQUAL(chrome_ai.telling, move, "The opening lock didn't start half a second into the fight") + TEST_ASSERT_EQUAL(criminal.get_left_eye_color(), "#ff3300", "Its eyes didn't go red for the lock") + TEST_ASSERT(length(move.marks), "The lock has no red line on the mark") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The gunman stands still through its lock") // BOUNTY_CHROME_TRAIT + TEST_ASSERT_NULL(chrome_ai.plan(criminal.ai_controller, 1), "The lock's tell stopped the gunman's other planning") + TEST_ASSERT_NULL(optics.tagged_ref?.resolve(), "The tag landed before the tell was over") + sleep(0.4 SECONDS) + TEST_ASSERT_NULL(optics.tagged_ref?.resolve(), "The tag landed before the tell's 0.8 seconds were up") // BOUNTY_CHROME_TELL_MIN + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(optics.tagged_ref?.resolve(), hunter, "The tell ended but the implant's tag isn't on the hunter") + TEST_ASSERT_NOTNULL(hunter.get_filter("deadeye_mark"), "The hunter carries no reticle") + TEST_ASSERT_EQUAL(criminal.get_left_eye_color(), "#ff3300", "Its eyes went back while the tag holds") + TEST_ASSERT(!move.ready(), "The tag isn't cooling down") + TEST_ASSERT_NULL(move.marks, "The red line outlived the tell") + + // A real round from a real pistol homes in + var/obj/item/gun/ballistic/automatic/pistol/gun = allocate(/obj/item/gun/ballistic/automatic/pistol) + TEST_ASSERT(criminal.put_in_hands(gun), "The gunman couldn't hold the test pistol") + RegisterSignal(criminal, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, PROC_REF(note_round)) + gun.process_fire(hunter, criminal) + UnregisterSignal(criminal, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE) + TEST_ASSERT_NOTNULL(last_round, "The pistol fired no round") + TEST_ASSERT_EQUAL(last_round.homing_target, hunter, "The round didn't home in on the tagged hunter") + TEST_ASSERT_EQUAL(optics.shots_left, 2, "The tag didn't count the homing round") + last_round = null + + // The tag spent, it stops watching and its eyes go back + optics.end_tag(criminal) + sleep(0.6 SECONDS) + TEST_ASSERT_NULL(move.mark_ref, "It kept watching a spent tag") + TEST_ASSERT_EQUAL(criminal.get_left_eye_color(), eyes_before, "Its eyes stayed red after the tag") + +/// Breaking line of sight lets the tag go, and one broken during the tell never lands; a melee style, a downed mark or a mark out of sight never gets one +/datum/unit_test/voidcrew_bounty_chrome/deadeye_sight + /// The floor turned into a wall between them, and what it was, put back whatever happens + var/turf/between + var/floor_type + +/datum/unit_test/voidcrew_bounty_chrome/deadeye_sight/Destroy() + if(between && floor_type && between.type != floor_type) + between.ChangeTurf(floor_type) + restore_atmos() + between = null + return ..() + +/datum/unit_test/voidcrew_bounty_chrome/deadeye_sight/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 0)) + between = spot(2, 0) + floor_type = between.type + var/mob/living/carbon/human/npc/bounty_criminal/criminal = deadeye_gunman(hunter) + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = criminal.get_organ_slot(ORGAN_SLOT_EYES) + var/datum/component/bounty_chrome/chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/deadeye/move = chrome_ai.move_of(/datum/bounty_chrome_move/deadeye) + chrome_ai.update_fight() + TEST_ASSERT(chrome_ai.start_move(move, hunter), "The lock didn't start") + sleep(1.2 SECONDS) + TEST_ASSERT_EQUAL(optics.tagged_ref?.resolve(), hunter, "The tag didn't land") + // A wall between them + between.ChangeTurf(/turf/closed/wall/r_wall) + sleep(0.7 SECONDS) // BOUNTY_DEADEYE_WATCH 0.5 seconds + TEST_ASSERT_NULL(optics.tagged_ref?.resolve(), "The tag held with a wall between them") + TEST_ASSERT_NULL(hunter.get_filter("deadeye_mark"), "The reticle stayed on the hunter behind the wall") + TEST_ASSERT_NOTEQUAL(criminal.get_left_eye_color(), "#ff3300", "Its eyes stayed red after it let go") + between.ChangeTurf(floor_type) + restore_atmos() + qdel(criminal) + + // Line of sight broken during the tell: the implant refuses the tag + criminal = deadeye_gunman(hunter) + optics = criminal.get_organ_slot(ORGAN_SLOT_EYES) + chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + move = chrome_ai.move_of(/datum/bounty_chrome_move/deadeye) + chrome_ai.update_fight() + TEST_ASSERT(chrome_ai.start_move(move, hunter), "The second lock didn't start") + between.ChangeTurf(/turf/closed/wall/r_wall) + sleep(1.2 SECONDS) + TEST_ASSERT_NULL(optics.tagged_ref?.resolve(), "The tag landed through a wall") + TEST_ASSERT_NOTEQUAL(criminal.get_left_eye_color(), "#ff3300", "Its eyes stayed red after the lock failed") + TEST_ASSERT(move.ready(), "A tag that never landed went on cooldown") + between.ChangeTurf(floor_type) + restore_atmos() + + // A downed mark is never tagged + hunter.adjustOxyLoss(hunter.health + 10) + hunter.updatehealth() + TEST_ASSERT(!move.can_start(hunter), "It would lock onto a hunter in crit") + qdel(criminal) + + // A brawler given the optics (an admin's pick) has nothing to home + var/mob/living/carbon/human/brawled = make_person(spot(4, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/brawler = deadeye_gunman(brawled, "brawler") // BOUNTY_STYLE_BRAWLER + var/datum/component/bounty_chrome/brawler_ai = brawler.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/deadeye/brawler_move = brawler_ai.move_of(/datum/bounty_chrome_move/deadeye) + TEST_ASSERT(!brawler_move.can_start(brawled), "A brawler locks on with Deadeye") + brawler_ai.update_fight() + sleep(0.7 SECONDS) + TEST_ASSERT_NULL(brawler_ai.telling, "A brawler's opening lock started") + +/// Down or dead, it lets go of its tag and its eyes go back +/datum/unit_test/voidcrew_bounty_chrome/deadeye_downed + +/datum/unit_test/voidcrew_bounty_chrome/deadeye_downed/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = deadeye_gunman(hunter) + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = criminal.get_organ_slot(ORGAN_SLOT_EYES) + var/datum/component/bounty_chrome/chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/deadeye/move = chrome_ai.move_of(/datum/bounty_chrome_move/deadeye) + chrome_ai.update_fight() + TEST_ASSERT(chrome_ai.start_move(move, hunter), "The lock didn't start") + sleep(1.2 SECONDS) + TEST_ASSERT_EQUAL(optics.tagged_ref?.resolve(), hunter, "The tag didn't land") + beat_down(criminal) + TEST_ASSERT(criminal.is_downed(), "The gunman didn't go down") + TEST_ASSERT_NULL(optics.tagged_ref?.resolve(), "A downed gunman kept its tag") + TEST_ASSERT_NULL(hunter.get_filter("deadeye_mark"), "The reticle stayed on the hunter when the gunman went down") + TEST_ASSERT_NOTEQUAL(criminal.get_left_eye_color(), "#ff3300", "A downed gunman's eyes stayed red") + criminal.death() + TEST_ASSERT_NULL(move.mark_ref, "A dead gunman kept watching a tag") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_gorilla.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_gorilla.dm new file mode 100644 index 00000000000..517363ed717 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_gorilla.dm @@ -0,0 +1,399 @@ +/** + * Bounty chrome: Gorilla Arms (C2), for voidcrew/modules/bounties/chrome/bounty_chrome_gorilla.dm. + * + * Criminals carry the real lattices; the tests read tg's own state (the arms' cooldowns, tg's pull and + * grab state, damage, throws, doors). The AI is switched off and the chrome driven through its own procs; + * the grab's own clock is left to run where the test is about its timing. Fork defines are included after + * the tests, so literals stand in for them with a comment naming the define. The test room is a 5x5 floor. + */ + +/// A Petty brawler with Gorilla Arms at `where`, its AI off +/datum/unit_test/voidcrew_bounty_chrome/proc/make_gorilla(turf/where) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(1, "normal", "brawler", null, list("gorilla")), where) // BOUNTY_CHROME_GORILLA + criminal?.ai_controller?.set_ai_status(AI_STATUS_OFF) + return criminal + +/// Sets `arm`'s punch to be loaded again in `left` (0: loaded now) +/datum/unit_test/voidcrew_bounty_chrome/proc/arm_reload(obj/item/organ/cyberimp/cyberware/gorilla_arms/arm, left) + arm.slam_cooldown = left ? world.time + left : 0 + +/// Whether `hunter` is held fast by `criminal`: tg's aggressive grab +/datum/unit_test/voidcrew_bounty_chrome/proc/held_by(mob/living/hunter, mob/living/criminal) + return hunter.pulledby == criminal && criminal.grab_state >= GRAB_AGGRESSIVE + +/// Plain fists only for its ordinary blows: with both fists loaded it throws nothing; with one used, every blow is that fist's, and the loaded one stays loaded +/datum/unit_test/voidcrew_bounty_chrome/gorilla_fists + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_fists/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_gorilla(spot(1, 2)) + var/list/arms = bounty_gorilla_arms(criminal) + TEST_ASSERT_EQUAL(length(arms), 2, "The criminal carries [length(arms)] Gorilla lattices, not the pair") + var/datum/status_effect/organ_set_bonus/cyberware_gorilla/bonus = criminal.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_gorilla) + TEST_ASSERT(bonus?.bonus_active, "The pair's set bonus (prying doors) isn't working") + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/ai_controller/controller = criminal.ai_controller + var/datum/ai_behavior/basic_melee_attack/human_npc/bounty/gorilla/brawl = GET_AI_BEHAVIOR(/datum/ai_behavior/basic_melee_attack/human_npc/bounty/gorilla) + + // Planning in its fight queues its own blows, not the bounty melee's + var/datum/bounty_chrome_move/gorilla_punch/punch = chrome.move_of(/datum/bounty_chrome_move/gorilla_punch) + TEST_ASSERT_NOTNULL(punch, "The piston punch's move wasn't made") + TEST_ASSERT(punch.plan(controller, hunter), "The gorilla planned nothing in its fight") + TEST_ASSERT(controller.current_behaviors[brawl], "The gorilla's plain-fist blows weren't queued") + TEST_ASSERT_NULL(chrome.telling, "A piston punch started inside its opener") + + // Both fists loaded: nothing thrown + for(var/i in 1 to 3) + criminal.next_move = 0 + criminal.next_click = 0 + controller.set_blackboard_key(BB_BASIC_MOB_MELEE_COOLDOWN_TIMER, world.time - 1) + brawl.perform(1, controller, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "The gorilla threw a blow with both fists loaded") + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in arms) + TEST_ASSERT(bounty_gorilla_loaded(arm), "An ordinary blow spent the [arm]'s punch") + + // One fist used: its blows are that fist's plain punches + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/used = arms[1] + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/loaded = arms[2] + arm_reload(used, 30 SECONDS) + for(var/i in 1 to 5) + criminal.next_move = 0 + criminal.next_click = 0 + controller.set_blackboard_key(BB_BASIC_MOB_MELEE_COOLDOWN_TIMER, world.time - 1) + var/before = hunter.getBruteLoss() + brawl.perform(1, controller, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + TEST_ASSERT_EQUAL(bounty_gorilla_arm_of_hand(criminal, criminal.active_hand_index), used, "A blow was thrown with the loaded fist") + // A plain punch is 5 to 10 (a human arm's unarmed damage); the implant's is 20 + TEST_ASSERT(hunter.getBruteLoss() - before <= 10, "An ordinary blow did [hunter.getBruteLoss() - before] brute: it was the implant's punch") + hunter.forceMove(spot(2, 2)) + hunter.SetKnockdown(0) + hunter.get_up(instant = TRUE) + TEST_ASSERT(bounty_gorilla_loaded(loaded), "An ordinary blow spent the loaded fist's punch") + +/// The piston punch: an orange outline and the lit tile for its tell, then a loaded fist's punch, the implant's (its brute, its knock-back, that arm's cooldown); stepping off the lit tile, it hits air; never toward a drop +/datum/unit_test/voidcrew_bounty_chrome/gorilla_punch + /// Turfs it changed, put back when it ends + var/list/turf/changed_turfs = list() + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_punch/Destroy() + for(var/turf/changed as anything in changed_turfs) + changed.ChangeTurf(/turf/open/floor/iron) + changed_turfs = null + return ..() + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_punch/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_gorilla(spot(1, 2)) + var/list/arms = bounty_gorilla_arms(criminal) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/gorilla_punch/punch = chrome.move_of(/datum/bounty_chrome_move/gorilla_punch) + TEST_ASSERT(punch.opens_at > world.time, "The first piston punch may come the moment the fight starts") + TEST_ASSERT(punch.opens_at <= world.time + 1.5 SECONDS, "The first piston punch waits more than 1.5 s") // BOUNTY_GORILLA_PUNCH_OPENING + TEST_ASSERT(punch.can_start(hunter), "The piston punch won't start at a hunter beside it") + + TEST_ASSERT(chrome.start_move(punch, hunter), "The piston punch's tell didn't start") + TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The gorilla doesn't stand still through the tell") // BOUNTY_CHROME_TRAIT + TEST_ASSERT_NOTNULL(criminal.get_filter(punch.tell_filter()), "The tell has no outline") + var/obj/effect/temp_visual/bounty_boss_mark/mark = locate() in spot(2, 2) + TEST_ASSERT_NOTNULL(mark, "The tile it aims at isn't lit") + sleep(0.4 SECONDS) + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "The punch landed before the tell was over") + // The tell, then the fist's own travel (hyperviolence_gorilla/gorilla_thrust.dm) + sleep(0.8 SECONDS) + TEST_ASSERT(hunter.getBruteLoss() >= 15, "The piston punch did [hunter.getBruteLoss()] brute, not the implant's 20") // CYBERWARE_GORILLA_PUNCH_DAMAGE + var/spent = 0 + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in arms) + if(!bounty_gorilla_loaded(arm)) + spent++ + TEST_ASSERT_EQUAL(spent, 1, "[spent] arms went on cooldown, not the one that punched") + sleep(0.5 SECONDS) + TEST_ASSERT(get_dist(criminal, hunter) >= 2, "The punch didn't knock the hunter back") + + // Off the lit tile: it hits air, and spends nothing + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in arms) + arm_reload(arm, 0) + hunter.forceMove(spot(2, 2)) + hunter.SetKnockdown(0) + hunter.get_up(instant = TRUE) + hunter.fully_heal() + chrome.next_move_at = 0 + criminal.next_move = 0 + criminal.next_click = 0 + TEST_ASSERT(chrome.start_move(punch, hunter), "The second piston punch's tell didn't start") + hunter.forceMove(spot(2, 3)) + sleep(1 SECONDS) + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "The punch followed the hunter off the lit tile") + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm as anything in arms) + TEST_ASSERT(bounty_gorilla_loaded(arm), "A punch at air spent the [arm]'s punch") + + // Never toward a drop: the tile behind the hunter is space + hunter.forceMove(spot(2, 2)) + var/turf/behind = spot(3, 2) + changed_turfs += behind + behind.ChangeTurf(/turf/open/space) + TEST_ASSERT(!punch.can_start(hunter), "A piston punch would knock the hunter out into space") + +/// The grab: a fist just used and one loaded; its hand on the hunter (tg's pull) and a ring for the tell; then tg's aggressive grab, two face punches with the used fist, and the loaded fist's punch, the implant's hurl; the guard after +/datum/unit_test/voidcrew_bounty_chrome/gorilla_grab + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_grab/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_gorilla(spot(1, 2)) + var/list/arms = bounty_gorilla_arms(criminal) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/used = arms[1] + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/loaded = arms[2] + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/gorilla_grab/grab = chrome.move_of(/datum/bounty_chrome_move/gorilla_grab) + TEST_ASSERT_NOTNULL(grab, "The grab's move wasn't made") + TEST_ASSERT(grab.grab_ready_at > world.time + 2 SECONDS, "The first grab may come inside the fight's first moments") // BOUNTY_GORILLA_GRAB_OPENING + TEST_ASSERT(!grab.can_start(hunter), "A grab could start inside its opener") + grab.grab_ready_at = 0 + TEST_ASSERT(!grab.can_start(hunter), "A grab could start with both fists loaded, so its face punches would be the implant's") + arm_reload(used, 3.9 SECONDS) + TEST_ASSERT(grab.can_start(hunter), "No grab with one fist just used and the other loaded") + + // The tell: its hand on them, a ring under them, nothing harmful yet + chrome.next_move_at = 0 + TEST_ASSERT(chrome.start_move(grab, hunter), "The grab's tell didn't start") + TEST_ASSERT_EQUAL(criminal.pulling, hunter, "The gorilla's hand isn't on the hunter through the tell") + TEST_ASSERT_EQUAL(criminal.grab_state, GRAB_PASSIVE, "The grip tightened before the tell was over") + var/obj/effect/temp_visual/bounty_boss_mark/ring = locate() in spot(2, 2) + TEST_ASSERT_EQUAL(ring?.icon_state, "target_circle", "No ring under the hunter it reaches for") + TEST_ASSERT_NOTNULL(criminal.get_filter(grab.tell_filter()), "The tell has no outline") + + // The grip tightens: tg's aggressive grab + sleep(1 SECONDS) + TEST_ASSERT(held_by(hunter, criminal), "The grip didn't tighten into an aggressive grab") + TEST_ASSERT(HAS_TRAIT_FROM(hunter, TRAIT_IMMOBILIZED, CHOKEHOLD_TRAIT), "The grabbed hunter can walk off, as in no aggressive grab of tg's") + TEST_ASSERT(HAS_TRAIT_FROM(hunter, TRAIT_HANDS_BLOCKED, CHOKEHOLD_TRAIT), "The grabbed hunter's hands are free, as in no aggressive grab of tg's") + TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome_gorilla"), "Holding on, the gorilla can walk off") // BOUNTY_GORILLA_TRAIT + TEST_ASSERT(grab.plan(criminal.ai_controller, hunter), "Holding on, the gorilla would plan something else") + + // Two punches to the face, a click apart, still held + sleep(1 SECONDS) + TEST_ASSERT(held_by(hunter, criminal), "Let go after the first face punch") + sleep(0.8 SECONDS) + TEST_ASSERT(held_by(hunter, criminal), "Let go after the second face punch") + TEST_ASSERT_EQUAL(grab.punches, 2, "[grab.punches] face punches before the finisher") + TEST_ASSERT(bounty_gorilla_loaded(loaded), "A face punch spent the loaded fist") + var/before_finisher = hunter.getBruteLoss() + + // The finisher: the loaded fist's punch on someone held fast is the implant's hurl + sleep(0.8 SECONDS) + TEST_ASSERT(!held_by(hunter, criminal), "The finisher didn't let go") + TEST_ASSERT_NULL(criminal.pulling, "The finisher left the gorilla pulling the hunter") + TEST_ASSERT(!bounty_gorilla_loaded(loaded), "The finisher wasn't the loaded fist's punch") + TEST_ASSERT(hunter.getBruteLoss() >= before_finisher + 15, "The finisher did [hunter.getBruteLoss() - before_finisher] brute, not the implant's 20") // CYBERWARE_GORILLA_PUNCH_DAMAGE + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome_gorilla"), "Still rooted after the finisher") + TEST_ASSERT_NULL(grab.held_ref, "The grab still holds someone after the finisher") + sleep(1 SECONDS) + TEST_ASSERT(get_dist(criminal, hunter) >= 3, "The finisher didn't hurl the hunter across the room") + + // The guard: not grabbed again straight away + hunter.forceMove(spot(2, 2)) + hunter.SetKnockdown(0) + hunter.SetParalyzed(0) + hunter.get_up(instant = TRUE) + arm_reload(used, 3.9 SECONDS) + arm_reload(loaded, 0) + grab.grab_ready_at = 0 + criminal.next_move = 0 + criminal.next_click = 0 + // The hurl's own wait, shared with the slam, is over too: only the guard is left + TIMER_COOLDOWN_END(criminal, "gorilla_grab_move") // COOLDOWN_GORILLA_GRAB_MOVE + TEST_ASSERT(!grab.can_start(hunter), "The hunter was grabbed again the moment they were let go") + grab.guard = null + TEST_ASSERT(grab.can_start(hunter), "With the guard gone, no second grab") + +/// Ways out, tg's: a step or Resist during the tell; Resist, a friend's pull, a stun or an EMP while held fast; anyone who goes down is let go and never grabbed from the floor; someone tg's grab can't hold, or held by another, isn't grabbed +/datum/unit_test/voidcrew_bounty_chrome/gorilla_grab_ways_out + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_grab_ways_out/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 2)) + var/mob/living/carbon/human/friend = make_person(spot(2, 3)) + var/list/ways = list("step", "resist_reach", "resist", "friend", "stunned", "emp", "knocked_down") + for(var/way in ways) + hunter.forceMove(spot(2, 2)) + hunter.fully_heal() + hunter.SetKnockdown(0) + hunter.SetParalyzed(0) + hunter.get_up(instant = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_gorilla(spot(1, 2)) + var/list/arms = bounty_gorilla_arms(criminal) + arm_reload(arms[1], 3.9 SECONDS) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/gorilla_grab/grab = chrome.move_of(/datum/bounty_chrome_move/gorilla_grab) + grab.grab_ready_at = 0 + chrome.next_move_at = 0 + TEST_ASSERT(grab.can_start(hunter), "[way]: no grab could start") + TEST_ASSERT(chrome.start_move(grab, hunter), "[way]: the grab's tell didn't start") + switch(way) + if("step") + hunter.forceMove(spot(3, 2)) + if("resist_reach") + hunter.next_move = 0 + hunter.execute_resist() + if(way == "step" || way == "resist_reach") + TEST_ASSERT_NULL(hunter.pulledby, "[way]: the hunter is still in the gorilla's hand") + sleep(1 SECONDS) + TEST_ASSERT(!held_by(hunter, criminal), "[way]: the hunter was grabbed anyway") + TEST_ASSERT_NULL(grab.held_ref, "[way]: the gorilla holds someone it never got") + sleep(2.4 SECONDS) + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "[way]: the hunter was punched anyway") + qdel(criminal) + continue + sleep(1 SECONDS) + TEST_ASSERT(held_by(hunter, criminal), "[way]: the grip didn't tighten") + switch(way) + if("resist") + // tg's own resist at tg's odds: a few tries; a failed one costs stamina, put back between tries + for(var/attempt in 1 to 20) + if(!held_by(hunter, criminal)) + break + hunter.next_move = 0 + hunter.last_special = 0 + hunter.setStaminaLoss(0) + hunter.execute_resist() + if("friend") + TEST_ASSERT(friend.start_pulling(hunter), "The friend couldn't take hold of the held hunter") + if("stunned") + criminal.Paralyze(2 SECONDS) + if("emp") + criminal.emp_act(EMP_HEAVY) + if("knocked_down") + hunter.Knockdown(2 SECONDS) + TEST_ASSERT(!grab.may_grab(hunter), "Someone on the floor could be grabbed") + if(way == "knocked_down") + // Its next click finds them on the floor and lets go + sleep(1 SECONDS) + TEST_ASSERT(!held_by(hunter, criminal), "[way]: the gorilla kept hold") + TEST_ASSERT(criminal.pulling != hunter, "[way]: the gorilla still pulls the hunter") + TEST_ASSERT_NULL(grab.held_ref, "[way]: the grab still holds the hunter") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome_gorilla"), "[way]: the gorilla is still rooted") // BOUNTY_GORILLA_TRAIT + var/hurt = hunter.getBruteLoss() + sleep(2.4 SECONDS) + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), hurt, "[way]: a punch landed after the hold ended") + if(way == "friend") + friend.stop_pulling() + friend.forceMove(spot(2, 3)) + qdel(criminal) + + // Never: someone tg's grab can't tighten on, or someone another holds fast + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_gorilla(spot(1, 2)) + arm_reload(bounty_gorilla_arms(criminal)[1], 3.9 SECONDS) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/gorilla_grab/grab = chrome.move_of(/datum/bounty_chrome_move/gorilla_grab) + grab.grab_ready_at = 0 + hunter.forceMove(spot(2, 2)) + hunter.SetKnockdown(0) + hunter.get_up(instant = TRUE) + TEST_ASSERT(grab.can_start(hunter), "No grab could start for the last checks") + ADD_TRAIT(hunter, TRAIT_PUSHIMMUNE, "unit_test") + TEST_ASSERT(!grab.can_start(hunter), "A grab would start on someone tg's grab can't tighten on") + REMOVE_TRAIT(hunter, TRAIT_PUSHIMMUNE, "unit_test") + friend.forceMove(spot(2, 3)) + friend.start_pulling(hunter) + hunter.grabbedby(friend) + TEST_ASSERT(held_by(hunter, friend), "The friend didn't hold the hunter fast for the check") + TEST_ASSERT(!grab.can_start(hunter), "A grab would start on someone another holds fast") + +/// Doors: forced when the hunter is behind one, with the set bonus's own pry; never a bolted one, one onto space, or one on a ship +/datum/unit_test/voidcrew_bounty_chrome/gorilla_doors + /// Turfs it changed, put back when it ends + var/list/turf/changed_turfs = list() + /// Turf -> the area it had before it was made part of a ship + var/list/original_areas = list() + /// Areas it made + var/list/test_areas = list() + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_doors/Destroy() + for(var/turf/changed as anything in changed_turfs) + changed.ChangeTurf(/turf/open/floor/iron) + changed_turfs = null + for(var/turf/moved as anything in original_areas) + moved.change_area(get_area(moved), original_areas[moved]) + original_areas = null + QDEL_LIST(test_areas) + return ..() + +/// A shut airlock at `where`, unpowered, so a pry opens it at once +/datum/unit_test/voidcrew_bounty_chrome/gorilla_doors/proc/make_door(turf/where) + var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, where) + door.set_machine_stat(door.machine_stat | NOPOWER) + return door + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_doors/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_gorilla(spot(1, 2)) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/gorilla_doors/doors = chrome.move_of(/datum/bounty_chrome_move/gorilla_doors) + TEST_ASSERT_NOTNULL(doors, "The door move wasn't made") + + // Bolted: left alone + var/obj/machinery/door/airlock/door = make_door(spot(2, 2)) + door.bolt() + TEST_ASSERT(!doors.try_door(), "The gorilla went for a bolted door") + door.unbolt() + + // Space behind it: left shut + var/turf/outside = spot(2, 3) + changed_turfs += outside + outside.ChangeTurf(/turf/open/space) + TEST_ASSERT(!doors.try_door(), "The gorilla went for a door with space behind it") + outside = spot(2, 3) + outside.ChangeTurf(/turf/open/floor/iron) + + // On a ship: left shut + var/area/shuttle/ship_area = new() + test_areas += ship_area + original_areas[spot(2, 2)] = get_area(spot(2, 2)) + var/turf/door_turf = spot(2, 2) + door_turf.change_area(get_area(door_turf), ship_area) + TEST_ASSERT(!doors.try_door(), "The gorilla went for a door on a ship") + door_turf.change_area(ship_area, original_areas[door_turf]) + original_areas -= door_turf + + // The hunter behind a plain shut door: a hand on it, and the set bonus forces it + TEST_ASSERT(doors.try_door(), "The gorilla didn't go for the door the hunter is behind") + sleep(2 SECONDS) + TEST_ASSERT(!door.density, "The set bonus didn't force the door open") + TEST_ASSERT_EQUAL(get_turf(criminal), spot(1, 2), "The gorilla walked through instead of forcing the door") + +/// A Juggernaut with the arms gets the grab in its own rotation: not while its shield fills a hand, then held busy while it holds on, and free again after +/datum/unit_test/voidcrew_bounty_chrome/gorilla_juggernaut + +/datum/unit_test/voidcrew_bounty_chrome/gorilla_juggernaut/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = make_criminal(make_record(3, "boss", null, "juggernaut", list("gorilla")), spot(1, 2)) // BOUNTY_KIT_JUGGERNAUT + boss.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/list/arms = bounty_gorilla_arms(boss) + TEST_ASSERT_EQUAL(length(arms), 2, "The Juggernaut's Gorilla Arms didn't go in") + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/wrapped in boss.boss_abilities) + if(istype(wrapped.move, /datum/bounty_chrome_move/gorilla_grab)) + ability = wrapped + TEST_ASSERT_NOTNULL(ability, "The Juggernaut's grab isn't in its ability rotation") + TEST_ASSERT(ability.windup >= 0.8 SECONDS, "The grab winds up for [ability.windup / 10] s") // BOUNTY_CHROME_TELL_MIN + arm_reload(arms[1], 3.9 SECONDS) + // Its tower shield fills its off hand (C8): one fist free, and the grab takes two + var/obj/item/shield/riot/phalanx_buckler/shield = locate() in boss.held_items + TEST_ASSERT_NOTNULL(shield, "The Juggernaut isn't holding its shield") + TEST_ASSERT_EQUAL(length(boss.get_empty_held_indexes()), 1, "With its shield in hand, the Juggernaut doesn't have one fist free") + TEST_ASSERT(!bounty_gorilla_fists_for_grab(boss), "With its shield in hand, the Juggernaut has two fists for the grab") + TEST_ASSERT(!ability.worth_using(hunter), "The Juggernaut wanted the grab with its shield in hand") + // Its shield broken (the gear lock keeps it from being dropped), both fists are free and the grab comes back + qdel(shield) + TEST_ASSERT(bounty_gorilla_fists_for_grab(boss), "Its shield gone, the Juggernaut doesn't have two fists for the grab") + TEST_ASSERT(ability.worth_using(hunter), "The grab isn't worth using on a hunter beside it") + TEST_ASSERT(ability.Trigger(target = hunter), "The grab ability wouldn't start") + TEST_ASSERT_EQUAL(boss.pulling, hunter, "The Juggernaut's hand isn't on the hunter through its wind-up") + sleep(1 SECONDS) + TEST_ASSERT(held_by(hunter, boss), "The Juggernaut's grip didn't tighten") + TEST_ASSERT_EQUAL(boss.boss_busy, "gorilla_hold", "Holding on, the Juggernaut isn't busy") // BOUNTY_GORILLA_BOSS_BUSY + // The finisher or the hold's own clock (BOUNTY_GORILLA_HOLD_MAX, 4 s from the grip) lets go, whichever comes first + var/waited = 0 + while((held_by(hunter, boss) || boss.boss_busy) && waited < 5 SECONDS) + sleep(0.2 SECONDS) + waited += 0.2 SECONDS + TEST_ASSERT(!held_by(hunter, boss), "The Juggernaut never let go") + TEST_ASSERT_NULL(boss.boss_busy, "The Juggernaut is still busy after the hold") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_lazarus.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_lazarus.dm new file mode 100644 index 00000000000..bf6f3bbea94 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_lazarus.dm @@ -0,0 +1,103 @@ +/** + * Lazarus on a bounty NPC: nothing to drive. The player node (ware_military_body.dm) fires itself when its + * bearer goes into crit, with its charge glow (cyberware_anim2.dm) through the windup. These run + * the node's real timers on a real human NPC, and on a plain human as a player would be. + */ + +/// Puts `body` down in crit with brute, as a beating would: on the floor, short of death +/datum/unit_test/voidcrew_bounty_chrome/proc/beat_down(mob/living/carbon/body) + for(var/i in 1 to 30) + if(body.stat != CONSCIOUS) + break + body.adjustBruteLoss(10) + body.updatehealth() + +/// The node stands a criminal beaten into crit back up after its real one second charge, its charge glowing on it meanwhile; cuffs put on mid-charge stay on, so it stands up cuffed; and it does it once in six minutes +/datum/unit_test/voidcrew_bounty_chrome/lazarus_jolt + +/datum/unit_test/voidcrew_bounty_chrome/lazarus_jolt/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("lazarus"))) // BOUNTY_TIER_WANTED, BOUNTY_CHROME_LAZARUS + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/obj/item/organ/cyberimp/cyberware/lazarus/node = locate() in criminal.organs + TEST_ASSERT_NOTNULL(node, "The criminal has no Lazarus node in it") + + beat_down(criminal) + TEST_ASSERT(criminal.is_downed(), "The beating didn't put the criminal in crit (health [criminal.health])") + TEST_ASSERT(node.jolting, "Going into crit didn't start the node's charge") + TEST_ASSERT_NOTNULL(criminal.get_filter("cyberware_lazarus_charge"), "No charge glow while the node charges") + TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A criminal down and charging isn't downed for the pad") // BOUNTY_STATE_DOWNED + + // Cuffs go on mid-charge + sleep(0.4 SECONDS) + var/obj/item/restraints/handcuffs/cuffs = new(criminal) + criminal.set_handcuffed(cuffs) + criminal.update_handcuffed() + TEST_ASSERT(criminal.is_restrained(), "The cuffs didn't go on") + TEST_ASSERT_NOTNULL(criminal.get_filter("cyberware_lazarus_charge"), "The charge glow stopped when the cuffs went on") + sleep(0.9 SECONDS) + TEST_ASSERT(!node.jolting, "The charge never fired") + TEST_ASSERT_EQUAL(criminal.stat, CONSCIOUS, "The node didn't stand the criminal up (health [criminal.health])") + // The node heals "to 30%" of the damage it counts, but a body's health counts limb damage at three quarters (updatehealth()), so it lands a little under + TEST_ASSERT(criminal.health >= criminal.maxHealth * 0.15, "The node stood it up at only [criminal.health] health") + TEST_ASSERT_EQUAL(criminal.handcuffed, cuffs, "The jolt took the cuffs off") + TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A jolted criminal in cuffs isn't restrained for the pad") // BOUNTY_STATE_RESTRAINED + TEST_ASSERT_NULL(criminal.get_filter("cyberware_lazarus_charge"), "The charge glow outlived the jolt") + TEST_ASSERT(!COOLDOWN_FINISHED(node, jolt_cooldown), "The jolt didn't spend the node") + // Out of crit it gets up as anyone does, in tg's get_up() second, cuffs and all + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_FLOORED), "The jolted criminal is still floored") + sleep(1.5 SECONDS) + TEST_ASSERT_EQUAL(criminal.body_position, STANDING_UP, "The jolted criminal never got up off the floor") + + // Once: down again within six minutes, it stays down + beat_down(criminal) + TEST_ASSERT(criminal.is_downed(), "The second beating didn't put the criminal in crit") + TEST_ASSERT(!node.jolting, "The node charged twice in six minutes") + TEST_ASSERT_NULL(criminal.get_filter("cyberware_lazarus_charge"), "The spent node showed its charge glow again") + sleep(1.2 SECONDS) + TEST_ASSERT(criminal.is_downed(), "The criminal got up a second time inside six minutes") + +/// Killed outright, the node does nothing; killed mid-charge, the charge glow goes at once and it stays dead +/datum/unit_test/voidcrew_bounty_chrome/lazarus_dead + +/datum/unit_test/voidcrew_bounty_chrome/lazarus_dead/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, "normal", "brawler", null, list("lazarus"))) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + criminal.death() + TEST_ASSERT_NULL(criminal.get_filter("cyberware_lazarus_charge"), "A criminal killed outright showed the node's charge glow") + sleep(1.2 SECONDS) + TEST_ASSERT_EQUAL(criminal.stat, DEAD, "The node brought a dead criminal back") + + var/mob/living/carbon/human/npc/bounty_criminal/second = make_criminal(make_record(2, "normal", "brawler", null, list("lazarus")), spot(1, 1)) + second.ai_controller?.set_ai_status(AI_STATUS_OFF) + beat_down(second) + TEST_ASSERT_NOTNULL(second.get_filter("cyberware_lazarus_charge"), "The second criminal's node didn't charge") + second.death() + TEST_ASSERT_NULL(second.get_filter("cyberware_lazarus_charge"), "The charge glow kept crawling over a corpse") + sleep(1.2 SECONDS) + TEST_ASSERT_EQUAL(second.stat, DEAD, "The node brought back someone killed mid-charge") + +/// The charge glow is the player node's own: a plain human (a player) shows it and is stood up the same way; an EMP mid-charge cuts the charge and its charge glow +/datum/unit_test/voidcrew_bounty_chrome/lazarus_player + +/datum/unit_test/voidcrew_bounty_chrome/lazarus_player/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/organ/cyberimp/cyberware/lazarus/node = allocate(/obj/item/organ/cyberimp/cyberware/lazarus) + TEST_ASSERT(node.Insert(patient, special = TRUE), "The node didn't go in") + beat_down(patient) + TEST_ASSERT(patient.stat == SOFT_CRIT || patient.stat == HARD_CRIT, "The beating didn't put the patient in crit") + TEST_ASSERT_NOTNULL(patient.get_filter("cyberware_lazarus_charge"), "A player's node charges with no charge glow") + sleep(1.3 SECONDS) + TEST_ASSERT_EQUAL(patient.stat, CONSCIOUS, "The node didn't stand the patient up") + TEST_ASSERT_NULL(patient.get_filter("cyberware_lazarus_charge"), "The charge glow outlived the player's jolt") + + var/mob/living/carbon/human/second = allocate(/mob/living/carbon/human/consistent, spot(3, 1)) + var/obj/item/organ/cyberimp/cyberware/lazarus/second_node = allocate(/obj/item/organ/cyberimp/cyberware/lazarus) + TEST_ASSERT(second_node.Insert(second, special = TRUE), "The second node didn't go in") + beat_down(second) + TEST_ASSERT_NOTNULL(second.get_filter("cyberware_lazarus_charge"), "The second node charges with no charge glow") + second.emp_act(EMP_HEAVY) + TEST_ASSERT(!second_node.jolting, "An EMP didn't cut the node's charge") + sleep(0.7 SECONDS) + TEST_ASSERT_NULL(second.get_filter("cyberware_lazarus_charge"), "The charge glow kept going after an EMP cut the charge") + sleep(1 SECONDS) + TEST_ASSERT(second.stat != CONSCIOUS && second.stat != DEAD, "A node cut by an EMP still stood the patient up") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_mantis.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_mantis.dm new file mode 100644 index 00000000000..d280371e732 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_mantis.dm @@ -0,0 +1,365 @@ +/** + * Bounty chrome: Mantis Blades (C2), for voidcrew/modules/bounties/chrome/bounty_chrome_mantis.dm. + * + * Criminals carry the real housings; the tests read tg's own state (held items, wounds, knockdown, the + * lunge action's cooldown). The AI is switched off and the chrome driven through its own procs, so nothing + * else happens in between. Fork defines are included after the tests, so literals stand in for them with + * a comment naming the define. The test room is a 5x5 floor. + */ + +/// A Petty knife criminal with the blades in at `where`, its AI off +/datum/unit_test/voidcrew_bounty_chrome/proc/make_mantis(turf/where, style = "knife") + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(1, "normal", style, null, list("mantis")), where) // BOUNTY_CHROME_MANTIS + criminal?.ai_controller?.set_ai_status(AI_STATUS_OFF) + return criminal + +/// Starts `criminal`'s fight with `hunter` and returns its chrome +/datum/unit_test/voidcrew_bounty_chrome/proc/chrome_fight(mob/living/carbon/human/npc/bounty_criminal/criminal, mob/living/hunter) + criminal.ai_start_fight(hunter) + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + chrome?.update_fight() + return chrome + +/// The mantis blades `body` holds +/datum/unit_test/voidcrew_bounty_chrome/proc/held_blades(mob/living/carbon/body) + . = list() + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade in body.held_items) + . += blade + +/// Blades out in a fight, one a click, into free hands; its knife stays in its pocket; the blade is its weapon and cuts real wounds; it can't be made to drop them; they go back in when it goes down +/datum/unit_test/voidcrew_bounty_chrome/mantis_blades + +/datum/unit_test/voidcrew_bounty_chrome/mantis_blades/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_mantis(spot(1, 2)) + TEST_ASSERT_NOTNULL(criminal, "No Mantis criminal spawned") + var/list/housings = bounty_mantis_housings(criminal) + TEST_ASSERT_EQUAL(length(housings), 2, "The criminal carries [length(housings)] Mantis housings, not the pair") + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in housings) + TEST_ASSERT(!housing.blade_extended(), "A blade is out before any fight") + for(var/obj/item/blade as anything in bounty_mantis_blades(housing)) + TEST_ASSERT(human_npc_gear_locked(blade), "The [housing]'s blade isn't locked to the body like its other gear") + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + TEST_ASSERT_NOTNULL(chrome, "The Mantis criminal has no chrome AI") + var/datum/bounty_chrome_move/mantis_blades/blades = chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + TEST_ASSERT_NOTNULL(blades, "The blades' move wasn't made") + TEST_ASSERT(!blades.plan(criminal.ai_controller, hunter), "A blade came out with no fight on") + + chrome_fight(criminal, hunter) + TEST_ASSERT(blades.plan(criminal.ai_controller, hunter), "No blade came out when the fight started") + TEST_ASSERT_EQUAL(length(held_blades(criminal)), 1, "Both blades came out in one click") + TEST_ASSERT(blades.plan(criminal.ai_controller, hunter), "The second blade didn't come out") + TEST_ASSERT(!blades.plan(criminal.ai_controller, hunter), "A third click put something out") + var/list/out = held_blades(criminal) + TEST_ASSERT_EQUAL(length(out), 2, "The criminal holds [length(out)] blades, not one in each hand") + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in housings) + TEST_ASSERT(housing.blade_extended(), "The [housing]'s blade isn't out") + TEST_ASSERT_NULL(locate(/obj/item/knife) in criminal.held_items, "The criminal drew its knife as well") + TEST_ASSERT_NOTNULL(locate(/obj/item/knife) in criminal.get_all_contents(), "The criminal lost its knife") + var/obj/item/weapon = human_npc_held_melee_weapon(criminal) + TEST_ASSERT(istype(weapon, /obj/item/melee/energy/blade/hardlight/cyberware_mantis), "The criminal fights with [weapon], not its blades") + + // They never leave its hands + var/obj/item/blade = out[1] + TEST_ASSERT(HAS_TRAIT(blade, TRAIT_NODROP), "A blade that is out can be dropped") + TEST_ASSERT(HAS_TRAIT(blade, TRAIT_NO_STRIP), "A blade that is out can be stripped") + criminal.dropItemToGround(blade) + criminal.drop_all_held_items() + TEST_ASSERT_EQUAL(length(held_blades(criminal)), 2, "Dropping things made the criminal let go of a blade") + TEST_ASSERT_NULL(locate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis) in spot(1, 2), "A blade lies on the floor") + + // Its cuts are the blade's own: brute, and in time tg's slash wound + hunter.forceMove(spot(2, 2)) + var/datum/wound/slash/cut + for(var/i in 1 to 8) + criminal.next_move = 0 + criminal.next_click = 0 + criminal.zone_selected = BODY_ZONE_CHEST + human_npc_ready_item(criminal, blade) + criminal.ai_controller.ai_interact(target = hunter, combat_mode = TRUE) + cut = locate() in hunter.all_wounds + if(cut || hunter.stat == DEAD) + break + TEST_ASSERT(hunter.getBruteLoss() > 0, "The blades did nothing") + TEST_ASSERT_NOTNULL(cut, "Eight blade hits opened no slash wound") + + // Down in crit: they go back in, into the housings + criminal.setOxyLoss(criminal.health + 20) + TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_CRITICAL_CONDITION), "The criminal isn't in crit for the downed check") + TEST_ASSERT_EQUAL(length(held_blades(criminal)), 0, "Downed, the criminal still holds its blades") + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in housings) + TEST_ASSERT(!housing.blade_extended(), "Downed, the [housing]'s blade is still out") + for(var/obj/item/housed as anything in bounty_mantis_blades(housing)) + TEST_ASSERT_EQUAL(housed.loc, housing, "Downed, a blade is somewhere other than its housing") + +/// The blades go away when the fight is over, when it is cuffed, during an EMP's reboot, and with the chrome when it dies; a bat stays in hand and the other blade does the work +/datum/unit_test/voidcrew_bounty_chrome/mantis_blades_away + +/datum/unit_test/voidcrew_bounty_chrome/mantis_blades_away/Run() + var/mob/living/carbon/human/hunter = make_person(spot(3, 2)) + var/list/ways = list("calm", "cuffed", "emp", "death") + for(var/way in ways) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_mantis(spot(1, 2)) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/mantis_blades/blades = chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + blades.plan(criminal.ai_controller, hunter) + blades.plan(criminal.ai_controller, hunter) + var/list/out = held_blades(criminal) + TEST_ASSERT_EQUAL(length(out), 2, "[way]: the blades didn't come out") + switch(way) + if("calm") + criminal.ai_calm_down() + chrome.update_fight() + if("cuffed") + var/obj/item/restraints/handcuffs/cuffs = new(criminal) + criminal.set_handcuffed(cuffs) + criminal.update_handcuffed() + if("emp") + criminal.emp_act(EMP_HEAVY) + if("death") + criminal.death() + TEST_ASSERT_EQUAL(length(held_blades(criminal)), 0, "[way]: a blade is still in hand") + if(way == "emp") + // Through the reboot nothing comes out, however often it plans + TEST_ASSERT(!blades.plan(criminal.ai_controller, hunter), "A blade came out during the EMP's reboot") + TEST_ASSERT_EQUAL(length(held_blades(criminal)), 0, "A blade is out during the EMP's reboot") + if(way == "death") + sleep(1) + for(var/obj/item/blade as anything in out) + TEST_ASSERT(QDELETED(blade), "A dead criminal's blade outlived its burnt-out housing") + TEST_ASSERT_NULL(locate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis) in spot(1, 2), "A dead criminal left a blade on the floor") + qdel(criminal) + + // A club fighter's bat has nowhere to go: that arm keeps it, and the other blade comes out + var/mob/living/carbon/human/npc/bounty_criminal/clubber = make_mantis(spot(1, 2), "club") + var/datum/component/bounty_chrome/club_chrome = chrome_fight(clubber, hunter) + var/datum/bounty_chrome_move/mantis_blades/club_blades = club_chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + var/obj/item/bat = locate(/obj/item/melee/baseball_bat) in clubber.held_items + TEST_ASSERT_NOTNULL(bat, "The club fighter holds no bat") + club_blades.plan(clubber.ai_controller, hunter) + club_blades.plan(clubber.ai_controller, hunter) + TEST_ASSERT_EQUAL(length(held_blades(clubber)), 1, "The club fighter has [length(held_blades(clubber))] blades out, not the one its free hand takes") + TEST_ASSERT(clubber.is_holding(bat), "The club fighter dropped its bat for a blade") + TEST_ASSERT_NULL(locate(/obj/item/melee/baseball_bat) in spot(1, 2), "The bat ended up on the floor") + TEST_ASSERT(istype(human_npc_held_melee_weapon(clubber), /obj/item/melee/energy/blade/hardlight/cyberware_mantis), "The club fighter swings its bat, not its blade") + +/// The lunge: never before its opener; a blue line and outline for its tell, standing still; then the housing's own Mantis Lunge: the dash, the cut and the knockdown, and its cooldown +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge + +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_mantis(spot(1, 2)) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/mantis_blades/blades = chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + var/datum/bounty_chrome_move/mantis_lunge/lunge = chrome.move_of(/datum/bounty_chrome_move/mantis_lunge) + TEST_ASSERT_NOTNULL(lunge, "The lunge's move wasn't made") + TEST_ASSERT(!lunge.can_start(hunter), "The lunge would start with the blades in") + blades.plan(criminal.ai_controller, hunter) + blades.plan(criminal.ai_controller, hunter) + TEST_ASSERT(lunge.opens_at > world.time, "The first lunge may come the moment the fight starts") + TEST_ASSERT(lunge.opens_at <= world.time + 1 SECONDS, "The first lunge waits more than a second") // BOUNTY_MANTIS_OPENING + TEST_ASSERT(!lunge.plan(criminal.ai_controller, hunter), "A lunge started inside its opener") + lunge.opens_at = 0 + TEST_ASSERT(lunge.can_start(hunter), "The lunge won't start at a hunter three tiles off in a clear line") + TEST_ASSERT(lunge.plan(criminal.ai_controller, hunter), "A ready lunge didn't start") + TEST_ASSERT_EQUAL(chrome.telling, lunge, "The lunge's tell isn't running") + TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The criminal doesn't stand still through the tell") // BOUNTY_CHROME_TRAIT + TEST_ASSERT_NOTNULL(criminal.get_filter(lunge.tell_filter()), "The tell has no outline") + for(var/dx in 2 to 4) + var/obj/effect/temp_visual/bounty_boss_mark/mark = locate() in spot(dx, 2) + TEST_ASSERT_NOTNULL(mark, "The line isn't marked [dx - 1] tiles out") + TEST_ASSERT_EQUAL(mark?.icon_state, dx == 4 ? "target_circle" : "target_box", "The line's mark [dx - 1] tiles out is the wrong one") + TEST_ASSERT_NULL(locate(/obj/effect/temp_visual/bounty_boss_mark) in spot(0, 2), "The line is marked behind the criminal") + sleep(0.6 SECONDS) + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "The hunter was cut before the tell was over") + // Standing still through the tell greys the button out (the lunge checks immobility), so read its cooldown + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in bounty_mantis_housings(criminal)) + var/datum/action/cooldown/cyberware/mantis_lunge/housing_lunge = locate() in housing.actions + TEST_ASSERT(!housing_lunge || housing_lunge.next_use_time <= world.time, "The lunge was used before the tell was over") + // The tell ends at 0.9 s, the implant's own telegraph runs 0.3 s, then the dash + sleep(1 SECONDS) + TEST_ASSERT_NULL(lunge.lunge_action(), "The housing's own Mantis Lunge wasn't used: it isn't cooling down") + TEST_ASSERT_EQUAL(get_dist(criminal, hunter), 1, "The dash didn't carry the criminal to the hunter") + TEST_ASSERT(hunter.getBruteLoss() > 0, "The lunge didn't cut the hunter") + TEST_ASSERT(hunter.IsKnockdown() || hunter.body_position == LYING_DOWN, "The lunge didn't put the hunter down") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The criminal still stands still after the tell") + TEST_ASSERT_NULL(locate(/obj/effect/temp_visual/bounty_boss_mark) in spot(3, 2), "The line stayed lit after the tell") + TEST_ASSERT(!lunge.can_start(hunter), "The lunge would start again at once") + +/// No lunge at someone right beside it, on the floor, through a table, past a drop beside the line, or with a stun or an EMP in its tell +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_refusals + /// Turfs it changed, put back when it ends + var/list/turf/changed_turfs = list() + +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_refusals/Destroy() + for(var/turf/changed as anything in changed_turfs) + changed.ChangeTurf(/turf/open/floor/iron) + changed_turfs = null + return ..() + +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_refusals/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_mantis(spot(1, 2)) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/mantis_blades/blades = chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + var/datum/bounty_chrome_move/mantis_lunge/lunge = chrome.move_of(/datum/bounty_chrome_move/mantis_lunge) + blades.plan(criminal.ai_controller, hunter) + blades.plan(criminal.ai_controller, hunter) + lunge.opens_at = 0 + TEST_ASSERT(lunge.can_start(hunter), "The lunge won't start in the clear") + + hunter.forceMove(spot(2, 2)) + TEST_ASSERT(!lunge.can_start(hunter), "A lunge would start at someone right beside it") + hunter.forceMove(spot(4, 2)) + + hunter.Knockdown(2 SECONDS) + TEST_ASSERT(!lunge.can_start(hunter), "A lunge would start at someone on the floor") + hunter.SetKnockdown(0) + hunter.get_up(instant = TRUE) + TEST_ASSERT(lunge.can_start(hunter), "The lunge won't start once the hunter is up") + + var/obj/structure/table/table = allocate(/obj/structure/table, spot(3, 2)) + TEST_ASSERT(!lunge.can_start(hunter), "A lunge would start through a table it falls short at") + qdel(table) + + var/turf/beside_line = spot(2, 3) + changed_turfs += beside_line + beside_line.ChangeTurf(/turf/open/space) + TEST_ASSERT(!lunge.can_start(hunter), "A lunge would start beside open space") + beside_line = spot(2, 3) + beside_line.ChangeTurf(/turf/open/floor/iron) + TEST_ASSERT(lunge.can_start(hunter), "The lunge won't start once the space is floor again") + + // Cut short: nothing fires, and the housing's lunge isn't spent + for(var/way in list("stunned", "emp")) + chrome.next_move_at = 0 + TEST_ASSERT(chrome.start_move(lunge, hunter), "[way]: the lunge's tell didn't start") + if(way == "stunned") + criminal.Paralyze(2 SECONDS) + else + criminal.emp_act(EMP_HEAVY) + TEST_ASSERT_NULL(chrome.telling, "[way]: the tell kept running") + sleep(1.4 SECONDS) + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "[way]: the hunter was cut anyway") + TEST_ASSERT(get_dist(criminal, hunter) > 1, "[way]: the criminal dashed anyway") + criminal.SetParalyzed(0) + criminal.get_up(instant = TRUE) + // The EMP put the blades away for its reboot: no lunge with them in + TEST_ASSERT_EQUAL(length(held_blades(criminal)), 0, "The blades stayed out through the EMP") + TEST_ASSERT(!lunge.can_start(hunter), "A lunge would start with the blades in after the EMP") + +/// The dash runs down the line the tell lit: a hunter who steps off it is missed, and it stops on the tile before the line's end +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_follows_line + +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_follows_line/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_mantis(spot(1, 2)) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/mantis_blades/blades = chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + var/datum/bounty_chrome_move/mantis_lunge/lunge = chrome.move_of(/datum/bounty_chrome_move/mantis_lunge) + blades.plan(criminal.ai_controller, hunter) + blades.plan(criminal.ai_controller, hunter) + lunge.opens_at = 0 + chrome.next_move_at = 0 + TEST_ASSERT(chrome.start_move(lunge, hunter), "The lunge's tell didn't start") + // One step off the lit line during the tell: still next to where the dash stops, but off the marked tile + hunter.forceMove(spot(4, 3)) + sleep(1.6 SECONDS) + TEST_ASSERT_NULL(lunge.lunge_action(), "The housing's own Mantis Lunge wasn't used") + TEST_ASSERT_EQUAL(get_turf(criminal), spot(3, 2), "The dash didn't run down the lit line to its last tile") + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "The dash cut a hunter who had stepped off its line") + +/// The player's lunge is the implant's ordinary one: it follows its target through the wind-up, passes over someone standing in the way, and stops at a window +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_player + +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_player/Run() + var/mob/living/carbon/human/lunger = make_person(spot(0, 2)) + var/mob/living/carbon/human/victim = make_person(spot(4, 2)) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + TEST_ASSERT(housing.Insert(lunger, special = TRUE), "The housing wouldn't go in") + housing.Extend(housing.contents[1]) + TEST_ASSERT(housing.blade_extended(), "The blade didn't come out") + var/datum/action/cooldown/cyberware/mantis_lunge/press = locate() in housing.actions + TEST_ASSERT_NOTNULL(press, "The housing has no lunge") + + var/mob/living/carbon/human/bystander = make_person(spot(2, 2)) + TEST_ASSERT(press.Trigger(target = victim), "The lunge wouldn't start past someone standing in the way") + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(get_turf(lunger), spot(3, 2), "The player's lunge didn't pass over someone standing in the way") + TEST_ASSERT(victim.getBruteLoss() > 0, "The player's lunge didn't cut its target") + TEST_ASSERT_EQUAL(bystander.getBruteLoss(), 0, "The player's lunge cut whoever stood in the way") + bystander.forceMove(spot(2, 4)) + + // It follows its target through the wind-up + lunger.forceMove(spot(0, 2)) + victim.get_up(instant = TRUE) + var/brute_before = victim.getBruteLoss() + press.ResetCooldown() + TEST_ASSERT(press.Trigger(target = victim), "The lunge wouldn't start in the clear") + victim.forceMove(spot(4, 3)) + sleep(0.8 SECONDS) + TEST_ASSERT(lunger.Adjacent(victim), "The player's lunge didn't follow its target through the wind-up") + TEST_ASSERT(victim.getBruteLoss() > brute_before, "The player's lunge didn't cut a target who moved in the wind-up") + victim.forceMove(spot(4, 2)) + + lunger.forceMove(spot(0, 2)) + brute_before = victim.getBruteLoss() + var/obj/structure/window/fulltile/pane = allocate(/obj/structure/window/fulltile, spot(2, 2)) + press.ResetCooldown() + TEST_ASSERT(press.Trigger(target = victim), "The lunge wouldn't start at someone behind a window") + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(get_turf(lunger), spot(1, 2), "The player's lunge went through a window") + // <=, not ==: the earlier cut may heal a little meanwhile + TEST_ASSERT(victim.getBruteLoss() <= brute_before, "A lunge stopped by a window still cut its target") + qdel(pane) + +/// The bounty NPC's shown-line dash is a real run: someone who steps onto its line during the tell stops it short, and nobody is cut +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_npc_blocked + +/datum/unit_test/voidcrew_bounty_chrome/mantis_lunge_npc_blocked/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_mantis(spot(0, 2)) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/mantis_blades/blades = chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + var/datum/bounty_chrome_move/mantis_lunge/lunge = chrome.move_of(/datum/bounty_chrome_move/mantis_lunge) + blades.plan(criminal.ai_controller, hunter) + blades.plan(criminal.ai_controller, hunter) + lunge.opens_at = 0 + chrome.next_move_at = 0 + TEST_ASSERT(chrome.start_move(lunge, hunter), "The lunge's tell didn't start") + var/mob/living/carbon/human/bystander = make_person(spot(2, 2)) + sleep(1.6 SECONDS) + TEST_ASSERT_NULL(lunge.lunge_action(), "The housing's own Mantis Lunge wasn't used") + TEST_ASSERT_EQUAL(get_turf(criminal), spot(1, 2), "The NPC's dash went through someone standing on its line") + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "A dash stopped short still cut its target") + TEST_ASSERT_EQUAL(bystander.getBruteLoss(), 0, "A dash stopped short cut whoever stopped it") + +#ifdef BOUNTY_CHROME_RENDERS +/// Writes a Mantis criminal with its blades out, a Gorilla brawler and the tells' floor marks to data/bounty_chrome_renders/ +/datum/unit_test/voidcrew_bounty_chrome/melee_chrome_renders + +/datum/unit_test/voidcrew_bounty_chrome/melee_chrome_renders/Run() + var/mob/living/carbon/human/hunter = make_person(spot(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_mantis(spot(1, 2)) + var/datum/component/bounty_chrome/chrome = chrome_fight(criminal, hunter) + var/datum/bounty_chrome_move/mantis_blades/blades = chrome.move_of(/datum/bounty_chrome_move/mantis_blades) + blades.plan(criminal.ai_controller, hunter) + blades.plan(criminal.ai_controller, hunter) + for(var/facing in list(SOUTH, NORTH, EAST, WEST)) + fcopy(getFlatIcon(criminal, facing), "data/bounty_chrome_renders/mantis_blades_out_[dir2text(facing)].png") + var/mob/living/carbon/human/npc/bounty_criminal/gorilla = make_criminal(make_record(1, "normal", "brawler", null, list("gorilla")), spot(0, 0)) // BOUNTY_CHROME_GORILLA + gorilla.ai_controller?.set_ai_status(AI_STATUS_OFF) + for(var/facing in list(SOUTH, NORTH, EAST)) + fcopy(getFlatIcon(gorilla, facing), "data/bounty_chrome_renders/gorilla_brawler_[dir2text(facing)].png") + var/list/marks = list( + "mark_mantis_line" = new /obj/effect/temp_visual/bounty_boss_mark(spot(0, 4), 10 SECONDS, list(0.42, 0.72, 1, 0, 0, 0, 0, 0, 0)), // BOUNTY_MANTIS_MARK_MATRIX + "mark_mantis_end" = new /obj/effect/temp_visual/bounty_boss_mark(spot(1, 4), 10 SECONDS, list(0.42, 0.72, 1, 0, 0, 0, 0, 0, 0), "target_circle"), + "mark_gorilla_punch" = new /obj/effect/temp_visual/bounty_boss_mark(spot(2, 4), 10 SECONDS), + "mark_gorilla_grab" = new /obj/effect/temp_visual/bounty_boss_mark(spot(3, 4), 10 SECONDS, list(1, 0.54, 0.12, 0, 0, 0, 0, 0, 0), "target_circle"), // BOUNTY_GORILLA_MARK_MATRIX + ) + for(var/name in marks) + var/obj/effect/mark = marks[name] + fcopy(getFlatIcon(mark, SOUTH), "data/bounty_chrome_renders/[name].png") + qdel(mark) + qdel(gorilla) +#endif diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_piledriver.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_piledriver.dm new file mode 100644 index 00000000000..5caf16f3e32 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_piledriver.dm @@ -0,0 +1,344 @@ +/** + * Bounty hunting: the Meteor Piledriver on a criminal (C1), for + * voidcrew/modules/bounties/chrome/bounty_chrome_piledriver.dm. + * + * Fork defines are included after the tests, so a test uses the literal value with a comment naming the + * define. Criminals are real human NPCs with the player's leg frame in them; the leap, its shadow, the + * crush and the shockwave are the implant's. Their AI is off, and each test drives the chrome by hand. + * The test room is a 5x5 floor; turfs a test changes are put back when it ends. + * + * Renders: compile with -DBOUNTY_CHROME_RENDERS and the renders test writes the carrier's flat icons to + * data/bounty_chrome_renders/; the crouch's dip, glow and reticle are composited from them. + */ +/datum/unit_test/voidcrew_bounty_chrome_piledriver + abstract_type = /datum/unit_test/voidcrew_bounty_chrome_piledriver + /// Turfs a test changed, put back to plain floor when it ends + var/list/turf/changed_turfs = list() + +/datum/unit_test/voidcrew_bounty_chrome_piledriver/Destroy() + for(var/turf/changed as anything in changed_turfs) + changed.ChangeTurf(/turf/open/floor/iron) + changed_turfs = null + return ..() + +/// A record of `tier`, `archetype` and `style` or `kit`, carrying `chrome`, for a human +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/make_record(tier = 2, archetype = "normal", style = "brawler", kit, list/chrome) + var/datum/bounty_record/record = generate_bounty_record(tier, archetype, "planet", /datum/species/human) // BOUNTY_PLACEMENT_PLANET + record.tier = tier + record.archetype = archetype + record.style = archetype == "boss" ? null : style // BOUNTY_ARCHETYPE_BOSS + record.kit = kit + record.chrome = chrome + return record + +/// The criminal for `record` at `where`, its AI off, deleted with the test +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/make_criminal(datum/bounty_record/record, turf/where) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(record, where || run_loc_floor_bottom_left, null) + if(criminal) + allocated += criminal + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + return criminal + +/// A Wanted brawler with the Piledriver at `where` +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/make_leaper(turf/where) + return make_criminal(make_record(2, "normal", "brawler", null, list("piledriver")), where) // BOUNTY_TIER_WANTED, BOUNTY_CHROME_PILEDRIVER + +/// A person with a mind at `where`, deleted with the test +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/make_person(turf/where) + var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human/consistent, where || run_loc_floor_top_right) + person.mind_initialize() + return person + +/// A turf `dx`, `dy` from the bottom left of the test room +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +/// Changes `where` to `new_type`, to be put back when the test ends +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/change_turf(turf/where, new_type) + changed_turfs |= where + return where.ChangeTurf(new_type) + +/// `criminal`'s Piledriver move +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/move_of(mob/living/carbon/human/npc/criminal) + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + return chrome?.move_of(/datum/bounty_chrome_move/piledriver) + +/// `criminal`'s own Meteor Leap button +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/leap_action(mob/living/carbon/human/npc/criminal) + return bounty_chrome_action(criminal, /datum/action/cooldown/cyberware/piledriver_leap) + +/// Whether the implant's landing shadow is on `where` +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/shadow_on(turf/where) + return !isnull(locate(/obj/effect/temp_visual/cyberware_piledriver_shadow) in where) + +/// Whether the crouch's reticle (a boss floor mark) is on `where` +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/reticle_on(turf/where) + for(var/obj/effect/temp_visual/bounty_boss_mark/mark in where) + if(mark.icon_state == "target_circle") + return TRUE + return FALSE + +/// How many crouch reticles are anywhere in the test room +/datum/unit_test/voidcrew_bounty_chrome_piledriver/proc/reticles() + . = 0 + for(var/turf/room_turf as anything in block(spot(0, 0), spot(4, 4))) + for(var/obj/effect/temp_visual/bounty_boss_mark/mark in room_turf) + if(mark.icon_state == "target_circle") + .++ + +// ===== THE LEAP ===== + +/** + * A whole leap from the fight's planning: the crouch (standing still, sunk, glowing, a reticle on its + * target that follows them), then the implant's own leap onto where they stand when the crouch ends, + * its shadow, and its landing: the target crushed, a hunter in the ring knocked down, one outside it + * untouched. Never a companion's piece. + */ +/datum/unit_test/voidcrew_bounty_chrome_piledriver/leap + +/datum/unit_test/voidcrew_bounty_chrome_piledriver/leap/Run() + var/turf/start = spot(0, 0) + var/turf/aim = spot(3, 0) + var/turf/stepped_to = spot(3, 1) + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces["piledriver"] + TEST_ASSERT(!piece.companion, "Companions can roll the Piledriver") + var/mob/living/carbon/human/target = make_person(aim) + var/mob/living/carbon/human/ring_hunter = make_person(spot(4, 2)) + var/mob/living/carbon/human/outside_hunter = make_person(spot(0, 4)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_leaper(start) + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/piledriver) in criminal.organs, "The criminal has no Piledriver in it") + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/piledriver/move = move_of(criminal) + TEST_ASSERT_NOTNULL(move, "The Piledriver has no move") + TEST_ASSERT(move.tell_time >= 0.8 SECONDS, "The crouch is [move.tell_time / 10] s") // BOUNTY_CHROME_TELL_MIN + TEST_ASSERT(move.area_move, "The leap isn't held to the bystander rule") + TEST_ASSERT(criminal.ai_start_fight(target), "The criminal wouldn't fight") + // In the fight too (it attacked them, say): the shockwave may catch them + criminal.body_add_grudge(ring_hunter) + chrome.update_fight() + TEST_ASSERT(chrome.next_move_at - world.time <= 1.5 SECONDS, "The first leap waits [(chrome.next_move_at - world.time) / 10] s into the fight") // BOUNTY_CHROME_OPENING + chrome.next_move_at = 0 + var/datum/action/cooldown/cyberware/piledriver_leap/leap = leap_action(criminal) + TEST_ASSERT_NOTNULL(leap, "The Piledriver has no Meteor Leap") + + TEST_ASSERT(move.can_start(target), "It won't leap at a hunter three tiles off in the open") + TEST_ASSERT_EQUAL(chrome.plan(criminal.ai_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A ready leap didn't start") + TEST_ASSERT_EQUAL(chrome.telling, move, "The crouch isn't running") + TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "It doesn't stand still in the crouch") // BOUNTY_CHROME_TRAIT + TEST_ASSERT_NOTNULL(criminal.get_filter(move.tell_filter()), "The crouch doesn't glow") + TEST_ASSERT(criminal.pixel_z < criminal.base_pixel_z, "It doesn't sink into the crouch") + TEST_ASSERT(reticle_on(aim), "No reticle on its target in the crouch") + // Its target steps aside: the reticle follows + target.forceMove(stepped_to) + TEST_ASSERT(reticle_on(stepped_to), "The reticle didn't follow its target") + TEST_ASSERT_EQUAL(reticles(), 1, "The reticle was left behind or doubled") + sleep(0.6 SECONDS) + TEST_ASSERT(leap.next_use_time <= world.time, "It leapt before the crouch was over") + TEST_ASSERT_EQUAL(criminal.loc, start, "It moved in the crouch") + + sleep(0.5 SECONDS) + TEST_ASSERT(leap.next_use_time > world.time + 50 SECONDS, "The crouch ended with no leap (the implant's minute of cooldown didn't start)") + TEST_ASSERT(shadow_on(stepped_to), "The implant's shadow isn't where its target went") + TEST_ASSERT_EQUAL(reticles(), 0, "The reticle stayed on in the air") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The crouch's hold stayed on") + TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_IMMOBILIZED), "It isn't held by its own leap in the air") + TEST_ASSERT_EQUAL(criminal.loc, start, "It arrived before its time in the air was over") + TEST_ASSERT(target.getBruteLoss() == 0, "The target was hurt before the landing") + + sleep(1 SECONDS) + TEST_ASSERT_EQUAL(criminal.loc, stepped_to, "It didn't land on the shadow") + TEST_ASSERT(target.getBruteLoss() > 0 && target.IsParalyzed(), "The hunter under it wasn't crushed") + TEST_ASSERT(ring_hunter.IsKnockdown(), "A hunter in the ring wasn't knocked down") + TEST_ASSERT(outside_hunter.getBruteLoss() == 0 && !outside_hunter.IsKnockdown(), "A hunter outside the ring was caught") + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_IMMOBILIZED), "It is still held after landing") + TEST_ASSERT_EQUAL(criminal.pixel_z, criminal.base_pixel_z, "It is still up in the air, or still crouched") + TEST_ASSERT(!move.can_start(target), "It would leap again with the implant cooling down") + +/** + * Where it lands: never at someone too close; over a table; never through a wall; beside a target on + * lava, or off its leash; and in the air it comes down as the player's leap does, stunned or not. + */ +/datum/unit_test/voidcrew_bounty_chrome_piledriver/reach + +/datum/unit_test/voidcrew_bounty_chrome_piledriver/reach/Run() + var/turf/aim = spot(3, 0) + var/mob/living/carbon/human/target = make_person(aim) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_leaper(spot(0, 0)) + var/datum/bounty_chrome_move/piledriver/move = move_of(criminal) + TEST_ASSERT(criminal.ai_start_fight(target), "The criminal wouldn't fight") + TEST_ASSERT_EQUAL(move.landing_for(target), aim, "It wouldn't land on a hunter three tiles off in the open") + + target.forceMove(spot(2, 0)) + TEST_ASSERT(!move.can_start(target), "It would leap at a hunter two tiles off") // BOUNTY_PILEDRIVER_MIN_RANGE + target.forceMove(aim) + + var/obj/structure/table/table = allocate(/obj/structure/table, spot(2, 0)) + TEST_ASSERT_EQUAL(move.landing_for(target), aim, "A table between them stopped the leap") + qdel(table) + + // A target on a table: it lands beside them + table = allocate(/obj/structure/table, aim) + var/turf/off_table_landing = move.landing_for(target) + TEST_ASSERT(off_table_landing && off_table_landing != aim && get_dist(off_table_landing, aim) == 1, "With its target on a table it would land on the table, or not beside them") + qdel(table) + + for(var/dy in 0 to 4) + change_turf(spot(2, dy), /turf/closed/wall) + TEST_ASSERT_NULL(move.landing_for(target), "It would leap through a wall") + TEST_ASSERT(!move.can_start(target), "It would start a leap through a wall") + for(var/dy in 0 to 4) + change_turf(spot(2, dy), /turf/open/floor/iron) + + // Never onto lava: beside it instead + ADD_TRAIT(target, TRAIT_LAVA_IMMUNE, TRAIT_GENERIC) + change_turf(aim, /turf/open/lava/smooth) + var/turf/landing = move.landing_for(target) + TEST_ASSERT_NOTNULL(landing, "With its target on lava it found nowhere to land") + TEST_ASSERT(landing && !islava(landing) && get_dist(landing, aim) == 1, "It would land on lava, or not beside its target") + change_turf(aim, /turf/open/floor/iron) + REMOVE_TRAIT(target, TRAIT_LAVA_IMMUNE, TRAIT_GENERIC) + + // Never off its leash: its site ends a column short of its target + var/turf/corner = spot(0, 0) + criminal.site_bounds = list(corner.x, corner.y, corner.x + 2, corner.y + 4, corner.z) + landing = move.landing_for(target) + TEST_ASSERT(landing && criminal.leash_ok(landing), "It would land off its leash") + criminal.site_bounds = null + + // Shot or stunned in the air, it still comes down on the shadow, as a player's leap does + TEST_ASSERT(move.fire(target), "It didn't leap") + TEST_ASSERT(shadow_on(aim), "No shadow under its target") + criminal.Paralyze(2 SECONDS) + sleep(1 SECONDS) + TEST_ASSERT_EQUAL(criminal.loc, aim, "Stunned in the air, it didn't come down on the shadow") + TEST_ASSERT(target.getBruteLoss() > 0, "Its landing crushed nobody") + +/** + * Never onto anyone outside its fight, its own companion, or anyone down: it doesn't start, and someone + * stepping into the landing during the crouch calls it off with the pistons settling and nothing spent. + */ +/datum/unit_test/voidcrew_bounty_chrome_piledriver/bystanders + +/datum/unit_test/voidcrew_bounty_chrome_piledriver/bystanders/Run() + var/mob/living/carbon/human/target = make_person(spot(3, 0)) + var/mob/living/carbon/human/bystander = make_person(spot(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_leaper(spot(0, 0)) + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/piledriver/move = move_of(criminal) + var/datum/action/cooldown/cyberware/piledriver_leap/leap = leap_action(criminal) + TEST_ASSERT(criminal.ai_start_fight(target), "The criminal wouldn't fight") + chrome.update_fight() + chrome.next_move_at = 0 + TEST_ASSERT(!move.can_start(target), "It would leap with a bystander in the landing") + TEST_ASSERT_NULL(chrome.plan(criminal.ai_controller, 1), "It planned a leap onto a bystander") + bystander.forceMove(spot(0, 4)) + TEST_ASSERT(move.can_start(target), "With the bystander clear it won't leap") + + // A bystander walks in during the crouch: it calls the leap off + TEST_ASSERT(chrome.start_move(move, target), "The crouch didn't start") + bystander.forceMove(spot(4, 1)) + sleep(1.2 SECONDS) + TEST_ASSERT_EQUAL(criminal.loc, spot(0, 0), "It leapt onto a bystander who walked in") + TEST_ASSERT(leap.next_use_time <= world.time, "Calling the leap off spent the implant's cooldown") + TEST_ASSERT(!shadow_on(spot(3, 0)), "A called-off leap left a shadow") + TEST_ASSERT_EQUAL(reticles(), 0, "A called-off leap left its reticle") + TEST_ASSERT_EQUAL(criminal.pixel_z, criminal.base_pixel_z, "It is still crouched") + bystander.forceMove(spot(0, 4)) + + // Its own companion in the landing + var/list/buddies = criminal.spawn_companions(1, TRUE) + TEST_ASSERT(length(buddies), "No companion spawned") + allocated += buddies + var/mob/living/carbon/human/npc/bounty_companion/buddy = buddies[1] + buddy.ai_controller?.set_ai_status(AI_STATUS_OFF) + buddy.forceMove(spot(4, 1)) + TEST_ASSERT(!move.can_start(target), "It would leap onto its own companion") + buddy.forceMove(spot(1, 4)) + TEST_ASSERT(move.can_start(target), "With its companion clear it won't leap") + + // A hunter in its fight, down in the landing + var/mob/living/carbon/human/fallen_hunter = make_person(spot(4, 0)) + criminal.body_add_grudge(fallen_hunter) + TEST_ASSERT(move.can_start(target), "A hunter on its feet in its fight stops the leap") + fallen_hunter.setOxyLoss(fallen_hunter.health + 20) + TEST_ASSERT(fallen_hunter.stat != CONSCIOUS && fallen_hunter.stat != DEAD, "The downed hunter isn't down") + TEST_ASSERT(!move.can_start(target), "It would leap onto someone who is down") + +/// An EMP, a stun or crit in the crouch stops it: no leap, nothing spent, the reticle and the crouch gone; a stunned criminal starts none +/datum/unit_test/voidcrew_bounty_chrome_piledriver/interrupted + +/datum/unit_test/voidcrew_bounty_chrome_piledriver/interrupted/Run() + var/turf/start = spot(0, 0) + var/turf/aim = spot(3, 0) + var/mob/living/carbon/human/target = make_person(aim) + for(var/way in list("emp", "stunned", "downed")) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_leaper(start) + var/datum/component/bounty_chrome/chrome = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/piledriver/move = move_of(criminal) + var/datum/action/cooldown/cyberware/piledriver_leap/leap = leap_action(criminal) + TEST_ASSERT(criminal.ai_start_fight(target), "[way]: the criminal wouldn't fight") + chrome.update_fight() + TEST_ASSERT(chrome.start_move(move, target), "[way]: the crouch didn't start") + TEST_ASSERT(reticle_on(aim), "[way]: no reticle in the crouch") + switch(way) + if("emp") + criminal.emp_act(EMP_HEAVY) + if("stunned") + criminal.Paralyze(3 SECONDS) + if("downed") + criminal.setOxyLoss(criminal.health + 20) + TEST_ASSERT_NULL(chrome.telling, "[way]: the crouch kept running") + TEST_ASSERT_EQUAL(reticles(), 0, "[way]: the reticle stayed") + TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "[way]: the crouch's hold stayed on") + sleep(1.2 SECONDS) + TEST_ASSERT_EQUAL(criminal.loc, start, "[way]: it leapt anyway") + TEST_ASSERT(leap.next_use_time <= world.time, "[way]: the implant's cooldown was spent on a leap that never came") + TEST_ASSERT(!shadow_on(aim), "[way]: a shadow came down anyway") + TEST_ASSERT(target.getBruteLoss() == 0, "[way]: the target was hurt") + if(way == "emp") + TEST_ASSERT(!move.ready(), "The Piledriver is ready through its EMP reboot") + else + TEST_ASSERT(!move.can_start(target), "[way]: it would start a leap") + qdel(criminal) + +// ===== MINI-BOSSES ===== + +/// The Pyromaniac leaps through its ability rotation: the wind-up is the crouch, the effect the implant's own leap +/datum/unit_test/voidcrew_bounty_chrome_piledriver/boss + +/datum/unit_test/voidcrew_bounty_chrome_piledriver/boss/Run() + var/turf/aim = spot(3, 0) + var/mob/living/carbon/human/target = make_person(aim) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = make_criminal(make_record(3, "boss", null, "pyromaniac", list("piledriver")), spot(0, 0)) // BOUNTY_TIER_MOST_WANTED, BOUNTY_KIT_PYROMANIAC + TEST_ASSERT(istype(boss, /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac), "No Pyromaniac spawned") + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/piledriver) in boss.organs, "The Pyromaniac has no Piledriver in it") + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/wrapped in boss.boss_abilities) + if(istype(wrapped.move, /datum/bounty_chrome_move/piledriver)) + ability = wrapped + TEST_ASSERT_NOTNULL(ability, "The Pyromaniac's Piledriver isn't in its ability rotation") + TEST_ASSERT(ability.windup >= 0.8 SECONDS, "The Pyromaniac's crouch is [ability.windup / 10] s") // BOUNTY_CHROME_TELL_MIN + TEST_ASSERT(ability.worth_using(target), "The Pyromaniac won't leap at a hunter three tiles off") + TEST_ASSERT(ability.Trigger(target = target), "The Pyromaniac's leap wouldn't start") + TEST_ASSERT_EQUAL(boss.boss_busy, "windup", "The Pyromaniac isn't crouching") + TEST_ASSERT(reticle_on(aim), "The Pyromaniac's crouch has no reticle") + sleep(2.2 SECONDS) + TEST_ASSERT_EQUAL(boss.loc, aim, "The Pyromaniac didn't come down on its target") + TEST_ASSERT(target.getBruteLoss() > 0, "The Pyromaniac's landing crushed nobody") + TEST_ASSERT_EQUAL(reticles(), 0, "The Pyromaniac's reticle stayed") + +// ===== RENDERS ===== + +/// Not a check: with -DBOUNTY_CHROME_RENDERS, writes a Piledriver carrier's flat icons to data/bounty_chrome_renders/, for the crouch composite +/datum/unit_test/voidcrew_bounty_chrome_piledriver/renders + +/datum/unit_test/voidcrew_bounty_chrome_piledriver/renders/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_leaper(spot(1, 1)) + var/mob/living/carbon/human/target = make_person(spot(4, 1)) + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/piledriver) in criminal.organs, "The carrier has no Piledriver") + TEST_ASSERT_NOTNULL(target, "No one to leap at") +#ifdef BOUNTY_CHROME_RENDERS + for(var/facing in list(SOUTH, EAST)) + fcopy(getFlatIcon(criminal, facing), "data/bounty_chrome_renders/piledriver_carrier_[dir2text(facing)].png") + fcopy(getFlatIcon(target, WEST), "data/bounty_chrome_renders/piledriver_target_west.png") +#endif diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_redline.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_redline.dm new file mode 100644 index 00000000000..0bdf6ca2d04 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_chrome_redline.dm @@ -0,0 +1,168 @@ +/** + * Redline core on a bounty NPC (voidcrew/modules/bounties/chrome/bounty_chrome_redline.dm): the AI picks + * the moment and tells it, then everything is the player implant's (ware_legend.dm). Real human NPCs, + * real implants, real timers; the AI is switched off so the test drives the chrome. Fork defines are + * included after the tests, so literals carry a comment naming theirs. + */ + +/// A Wanted brawler with a Redline core in, fighting `hunter`, its AI off and its chrome ready to move. Returns the criminal. +/datum/unit_test/voidcrew_bounty_chrome/proc/redliner(mob/living/hunter, archetype = "normal", kit) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = make_criminal(make_record(2, archetype, "brawler", kit, list("redline"))) // BOUNTY_TIER_WANTED, BOUNTY_CHROME_REDLINE + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + if(hunter && archetype != "boss") // BOUNTY_ARCHETYPE_BOSS + criminal.ai_start_fight(hunter) + var/datum/component/bounty_chrome/chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + chrome_ai?.update_fight() + if(chrome_ai) + chrome_ai.next_move_at = 0 + return criminal + +/// Hurts `criminal` with brute until it is at or under three quarters of its health, on its feet +/datum/unit_test/voidcrew_bounty_chrome/proc/hurt_to_redline(mob/living/carbon/human/npc/bounty_criminal/criminal) + for(var/i in 1 to 10) + if(criminal.health <= criminal.maxHealth * 0.7) + break + criminal.adjustBruteLoss(10) + criminal.updatehealth() + +/// Hurt in a fight, it tells for a second (standing still, outlined), then the implant's own burn: stun immunity, physiology, the roar on the hunter, red eyes; after the implant's 12 seconds, the crash floors it in stamina crit +/datum/unit_test/voidcrew_bounty_chrome/redline_burn + +/datum/unit_test/voidcrew_bounty_chrome/redline_burn/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = redliner(hunter) + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/redline) in criminal.organs, "The criminal has no Redline core in it") + var/datum/component/bounty_chrome/chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/redline/move = chrome_ai?.move_of(/datum/bounty_chrome_move/redline) + TEST_ASSERT_NOTNULL(move, "A Redline carrier has no Redline move") + TEST_ASSERT(!move.can_start(hunter), "An unhurt criminal burns its Redline") + TEST_ASSERT_NULL(chrome_ai.plan(criminal.ai_controller, 1), "An unhurt criminal started a chrome move") + + hurt_to_redline(criminal) + TEST_ASSERT(criminal.stat == CONSCIOUS && criminal.health <= criminal.maxHealth * 0.75, "The criminal wasn't hurt to three quarters on its feet (health [criminal.health])") + TEST_ASSERT(move.can_start(hunter), "A hurt criminal in a fight won't burn its Redline") + var/brute_mod_before = criminal.physiology.brute_mod + TEST_ASSERT_EQUAL(chrome_ai.plan(criminal.ai_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "The Redline didn't start") + TEST_ASSERT_EQUAL(chrome_ai.telling, move, "The Redline's tell isn't running") + TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_chrome"), "The criminal doesn't stand still through the tell") // BOUNTY_CHROME_TRAIT + TEST_ASSERT_NOTNULL(criminal.get_filter(move.tell_filter()), "The tell has no outline") + sleep(0.7 SECONDS) + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "The burn started before the tell's 0.8 seconds were up") // BOUNTY_CHROME_TELL_MIN + sleep(0.5 SECONDS) + + // The implant's own window + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "The tell ended but the implant's burn didn't start") + TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_STUNIMMUNE), "The burn gives no stun immunity") + TEST_ASSERT(criminal.physiology.brute_mod < brute_mod_before * 0.61, "The burn didn't cut brute through the physiology ([brute_mod_before] to [criminal.physiology.brute_mod])") + TEST_ASSERT_NOTNULL(hunter.has_status_effect(/datum/status_effect/staggered), "The roar didn't stagger the hunter in the fight") + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/bounty_redline_eyes), "Its eyes didn't go red for the burn") + TEST_ASSERT_EQUAL(criminal.get_left_eye_color(), "#ff2a2a", "Its eyes aren't red through the burn") + TEST_ASSERT(!move.ready(), "The implant isn't cooling down after the burn") + TEST_ASSERT_NULL(criminal.get_filter(move.tell_filter()), "The tell's outline stayed on") + TEST_ASSERT_NOTNULL(criminal.get_filter("cyberware_redline_window"), "The burn has no red outline") + criminal.Paralyze(3 SECONDS) + TEST_ASSERT(!criminal.IsParalyzed(), "A stun landed in the burn") + + // The implant's 12 seconds from the end of the tell, then the crash + sleep(12.4 SECONDS) + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "The burn outlasted the implant's 12 seconds") + TEST_ASSERT_NULL(criminal.get_filter("cyberware_redline_window"), "The red outline outlasted the burn") + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_crash), "No crash after the burn") + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "The crash didn't floor it in stamina crit") + TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "The crash isn't a stunned capture") // BOUNTY_STATE_STUNNED + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_STUNIMMUNE), "Stun immunity outlasted the burn") + TEST_ASSERT_EQUAL(criminal.physiology.brute_mod, brute_mod_before, "The physiology didn't go back after the burn") + sleep(0.6 SECONDS) + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/bounty_redline_eyes), "Its eyes stayed red after the burn") + TEST_ASSERT_NOTEQUAL(criminal.get_left_eye_color(), "#ff2a2a", "Its eyes stayed red after the burn") + +/// Winded by stamina it burns too; with someone outside the fight in the roar's reach it doesn't start, and someone stepping in during the tell keeps the button unpressed; its own companion does neither, and the roar spares it +/datum/unit_test/voidcrew_bounty_chrome/redline_gate + +/datum/unit_test/voidcrew_bounty_chrome/redline_gate/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = redliner(hunter) + var/datum/component/bounty_chrome/chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/redline/move = chrome_ai.move_of(/datum/bounty_chrome_move/redline) + criminal.adjustStaminaLoss(60) + TEST_ASSERT(bounty_redline_hurt(criminal), "Winded to 60 stamina doesn't count") + TEST_ASSERT(move.can_start(hunter), "A winded criminal won't burn its Redline") + + // A bystander a few tiles off, in the roar's reach + var/mob/living/carbon/human/bystander = make_person(spot(1, 2)) + TEST_ASSERT(!move.can_start(hunter), "It burns its Redline with a bystander in the roar's reach") + bystander.forceMove(run_loc_floor_top_right) + var/far = get_dist(criminal, bystander) > 5 // BOUNTY_REDLINE_ROAR_RANGE + if(far) + TEST_ASSERT(move.can_start(hunter), "A bystander out of the roar's reach keeps the Redline shut") + + // Someone steps in during the tell: the button stays unpressed + TEST_ASSERT(chrome_ai.start_move(move, hunter), "The tell didn't start") + bystander.forceMove(spot(1, 2)) + sleep(1.2 SECONDS) + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "It roared at a bystander who stepped in during the tell") + TEST_ASSERT_NULL(bystander.has_status_effect(/datum/status_effect/staggered), "The bystander was staggered") + TEST_ASSERT(move.ready(), "The unpressed burn still went on cooldown") + + // Its own companion in the roar's reach doesn't hold it back, and the roar spares it + qdel(bystander) + var/datum/human_npc_order/order = bounty_spawn_companion(criminal, spot(1, 2), null, TRUE, bounty_test_company_member("brawler", null)) // BOUNTY_STYLE_BRAWLER + var/mob/living/carbon/human/npc/bounty_companion/buddy = order?.spawned_ref?.resolve() + qdel(order) + TEST_ASSERT_NOTNULL(buddy, "Test fixture: no companion was made") + allocated += buddy + buddy.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(move.can_start(hunter), "Its own companion in the roar's reach keeps the Redline shut") + TEST_ASSERT(chrome_ai.start_move(move, hunter), "The tell didn't start with its companion near") + sleep(1.2 SECONDS) + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "It didn't burn with only its companion near") + TEST_ASSERT_NULL(buddy.has_status_effect(/datum/status_effect/staggered), "The roar staggered its own companion") + +/// An EMP in the tell fires nothing; one in the burn drops it straight into the implant's crash and back on its cooldown +/datum/unit_test/voidcrew_bounty_chrome/redline_emp + +/datum/unit_test/voidcrew_bounty_chrome/redline_emp/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = redliner(hunter) + var/datum/component/bounty_chrome/chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/redline/move = chrome_ai.move_of(/datum/bounty_chrome_move/redline) + hurt_to_redline(criminal) + TEST_ASSERT(chrome_ai.start_move(move, hunter), "The tell didn't start") + criminal.emp_act(EMP_HEAVY) + TEST_ASSERT_NULL(chrome_ai.telling, "An EMP didn't cut the tell short") + sleep(1.2 SECONDS) + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "It burned through an EMP in the tell") + qdel(criminal) + + criminal = redliner(hunter) + chrome_ai = criminal.GetComponent(/datum/component/bounty_chrome) + move = chrome_ai.move_of(/datum/bounty_chrome_move/redline) + hurt_to_redline(criminal) + TEST_ASSERT(chrome_ai.start_move(move, hunter), "The second tell didn't start") + sleep(1.2 SECONDS) + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "The second burn didn't start") + criminal.emp_act(EMP_HEAVY) + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_window), "An EMP in the burn didn't end it") + TEST_ASSERT_NOTNULL(criminal.has_status_effect(/datum/status_effect/cyberware_redline_crash), "An EMP in the burn didn't crash it") + TEST_ASSERT(!move.ready(), "The Redline is ready again straight after an EMP crash") + sleep(0.6 SECONDS) + TEST_ASSERT_NULL(criminal.has_status_effect(/datum/status_effect/bounty_redline_eyes), "Its eyes stayed red after the EMP crash") + +/// A mini-boss with a Redline core uses it through its ability rotation, only once it is hurt +/datum/unit_test/voidcrew_bounty_chrome/redline_boss + +/datum/unit_test/voidcrew_bounty_chrome/redline_boss/Run() + var/mob/living/carbon/human/hunter = make_person(spot(2, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = redliner(null, "boss", "pyromaniac") // BOUNTY_KIT_PYROMANIAC + TEST_ASSERT(istype(boss), "No Pyromaniac spawned") + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/found in boss.boss_abilities) + if(istype(found.move, /datum/bounty_chrome_move/redline)) + ability = found + TEST_ASSERT_NOTNULL(ability, "The Pyromaniac's Redline isn't in its ability rotation") + boss.body_add_grudge(hunter) + boss.boss_turn_hostile(hunter) + TEST_ASSERT(!ability.worth_using(hunter), "An unhurt mini-boss reaches for its Redline") + hurt_to_redline(boss) + TEST_ASSERT(ability.worth_using(hunter), "A hurt mini-boss won't use its Redline") + TEST_ASSERT(ability.windup >= 0.8 SECONDS, "The mini-boss's Redline winds up for [ability.windup / 10] s") // BOUNTY_CHROME_TELL_MIN diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_companions_backup.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_companions_backup.dm new file mode 100644 index 00000000000..2a700ea4284 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_companions_backup.dm @@ -0,0 +1,372 @@ +/** + * Bounty hunting: companions back their criminal up (C4), for voidcrew/modules/bounties/bounty_companions.dm, + * bounty_placement.dm (the posting's company), bounty_posting.dm (the sighting) and bounty_styles.dm (the + * companions' strings and bursts). At most one of a criminal's company carries a gun; the posting rolls + * the company with its site, names it on the card, the notices and the warrant, and spawns that same + * company; companions get up before they draw, a beat after their criminal, fire pistol strings of three + * and SMG bursts of two; and now and then one carries a piece of real chrome, rarer than its criminal's. + * + * The tests drive the procs directly (a test world has no clients, so the AI is off), with the gun tests' + * helpers (voidcrew_bounty_guns.dm). Fork defines are included after the tests, so a test uses the + * literal value with a comment naming the define. + */ + +/// One companion of a company as bounty_roll_company() makes it: `style` (BOUNTY_STYLE_*) and `chrome` (keys, or null) +/proc/bounty_test_company_member(style, list/chrome) + return list("style" = style, "chrome" = chrome) // BOUNTY_COMPANY_STYLE, BOUNTY_COMPANY_CHROME + +/// The companion tests, in the bounty AI tests' room, with the gun tests' helpers +/datum/unit_test/voidcrew_bounty_companions + parent_type = /datum/unit_test/voidcrew_bounty_guns + abstract_type = /datum/unit_test/voidcrew_bounty_companions + +/// `leader`'s companion at `where`, made now as the posting's `member` would be (bounty_test_company_member()), its AI off +/datum/unit_test/voidcrew_bounty_companions/proc/make_companion(mob/living/carbon/human/npc/bounty_criminal/leader, turf/where, list/member) + var/datum/human_npc_order/order = bounty_spawn_companion(leader, where, null, TRUE, member) + var/mob/living/carbon/human/npc/bounty_companion/buddy = order?.spawned_ref?.resolve() + qdel(order) + TEST_ASSERT_NOTNULL(buddy, "Test fixture: no companion was made") + allocated += buddy + buddy.ai_controller.set_ai_status(AI_STATUS_OFF) + return buddy + +/// A hunter at `where` whom `buddy` and its criminal are out to get: on the criminal's grudge list, the companion's enemy and its target +/datum/unit_test/voidcrew_bounty_companions/proc/make_companion_target(mob/living/carbon/human/npc/bounty_companion/buddy, turf/where) + var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, where) + buddy.ai_leader()?.ai_add_grudge(hunter) + buddy.ai_mark_enemy(hunter) + buddy.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + return hunter + +/// The chrome organ types in `body` +/datum/unit_test/voidcrew_bounty_companions/proc/chrome_in(mob/living/carbon/body) + . = list() + for(var/obj/item/organ/organ in body.organs) + if(organ.GetComponent(/datum/component/cyberware)) + . += organ.type + +// ===== THE COMPANY ===== + +/** + * A criminal's company: never two guns, and the gun (if any) first; a companion's chrome is one piece at + * most, never Lazarus or the Piledriver, rolled for its own style, and only now and then. Companions a + * criminal spawns without a posting's company follow the same rule, and so does one more joining a + * criminal who already has an armed companion. + */ +/datum/unit_test/voidcrew_bounty_companions/rolls + +/datum/unit_test/voidcrew_bounty_companions/rolls/Run() + var/chromed = 0 + var/members = 0 + for(var/i in 1 to 300) + var/list/company = bounty_roll_company(2, 3) // BOUNTY_TIER_MOST_WANTED + TEST_ASSERT_EQUAL(length(company), 2, "Two companions rolled as [length(company)]") + var/guns = 0 + for(var/j in 1 to length(company)) + var/list/member = company[j] + var/style = member["style"] // BOUNTY_COMPANY_STYLE + TEST_ASSERT_NOTNULL(GLOB.bounty_styles[style], "A companion rolled the style [style]") + if(bounty_style_is_gun(style)) + guns++ + TEST_ASSERT_EQUAL(j, 1, "The armed companion isn't first in the company") + members++ + var/list/chrome = member["chrome"] // BOUNTY_COMPANY_CHROME + if(!length(chrome)) + continue + chromed++ + TEST_ASSERT_EQUAL(length(chrome), 1, "A companion rolled [length(chrome)] pieces of chrome") + TEST_ASSERT(!(chrome[1] in list("lazarus", "piledriver")), "A companion rolled [chrome[1]]") // BOUNTY_CHROME_LAZARUS, BOUNTY_CHROME_PILEDRIVER + var/datum/bounty_chrome_piece/piece = GLOB.bounty_chrome_pieces[chrome[1]] + TEST_ASSERT(piece.can_roll(3, "companion", style, null, list()), "A [style] companion rolled [chrome[1]], which doesn't suit it") // BOUNTY_CHROME_COMPANION + TEST_ASSERT(guns <= 1, "A company rolled [guns] guns") + // A Most Wanted criminal's companion: 60 / 3 percent (BOUNTY_CHROME_CHANCE_MOST_WANTED / BOUNTY_CHROME_COMPANION_DIVISOR) + var/percent = chromed * 100 / members + TEST_ASSERT(percent >= 12 && percent <= 28, "A Most Wanted criminal's companions carry chrome [percent]% of the time, not about 20%") + // A Petty criminal's never roll the chrome that is Wanted or worse + for(var/i in 1 to 300) + var/list/petty_company = bounty_roll_company(1, 1) // BOUNTY_TIER_PETTY + var/list/member = petty_company[1] + for(var/key in member["chrome"]) + TEST_ASSERT(!(key in list("cascade", "redline")), "A Petty criminal's companion rolled [key]") // BOUNTY_CHROME_CASCADE, BOUNTY_CHROME_REDLINE + // The unarmed roll never gives a gun + for(var/i in 1 to 200) + TEST_ASSERT(!bounty_style_is_gun(bounty_roll_companion_style(no_gun = TRUE)), "The unarmed roll gave a gun") + + // Spawned by the criminal without a company: still at most one gun + 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 + for(var/i in 1 to 6) + var/list/gang = criminal.spawn_companions(2, TRUE) + var/guns = 0 + for(var/mob/living/carbon/human/npc/bounty_companion/member as anything in gang) + if(bounty_style_is_gun(member.ai_style)) + guns++ + TEST_ASSERT(guns <= 1, "A criminal's own company rolled [guns] guns") + QDEL_LIST(gang) + // One more joining a criminal with an armed companion carries no gun of its own + var/mob/living/carbon/human/npc/bounty_companion/gunner = make_companion(criminal, tile(1, 1), bounty_test_company_member("smg")) // BOUNTY_STYLE_SMG + TEST_ASSERT(bounty_company_armed(criminal), "A criminal with an SMG companion has no armed company") + for(var/i in 1 to 6) + var/mob/living/carbon/human/npc/bounty_companion/late = make_companion(criminal, tile(3, 1)) + TEST_ASSERT(!bounty_style_is_gun(late.ai_style), "A second companion rolled a [late.ai_style] beside an armed one") + allocated -= late + qdel(late) + allocated -= gunner + qdel(gunner) + +/** + * The posting's company is who comes: their styles, the weapons they carry, and their chrome, put in their + * bodies as real organs and driven by the chrome subtree; a companion the posting rolled no chrome for has + * none, and none is rolled for it as it is dressed. + */ +/datum/unit_test/voidcrew_bounty_companions/chrome + +/datum/unit_test/voidcrew_bounty_companions/chrome/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(2, 2), "brawler", 2) // BOUNTY_STYLE_BRAWLER, BOUNTY_TIER_WANTED + var/list/company = list( + bounty_test_company_member("pistol", list("deadeye")), // BOUNTY_STYLE_PISTOL, BOUNTY_CHROME_DEADEYE + bounty_test_company_member("knife"), // BOUNTY_STYLE_KNIFE + ) + var/list/buddies = criminal.spawn_companions(2, TRUE, company) + allocated += buddies + TEST_ASSERT_EQUAL(length(buddies), 2, "The company didn't spawn") + var/mob/living/carbon/human/npc/bounty_companion/shooter = buddies[1] + var/mob/living/carbon/human/npc/bounty_companion/blade = buddies[2] + TEST_ASSERT_EQUAL(shooter.ai_style, "pistol", "The first companion isn't the company's pistol") + TEST_ASSERT_EQUAL(blade.ai_style, "knife", "The second companion isn't the company's knife") + TEST_ASSERT_EQUAL(shooter.ai_controller.blackboard["bb_bounty_style"], "pistol", "The pistol companion fights in another style") // BB_BOUNTY_STYLE + TEST_ASSERT_NOTNULL(carried(shooter, /obj/item/gun/ballistic/automatic/pistol/aps), "The pistol companion carries no Stechkin") + TEST_ASSERT_NOTNULL(carried(blade, /obj/item/knife), "The knife companion carries no knife") + + // The pistol companion's Deadeye is a real organ in its eyes, and its chrome subtree has it + TEST_ASSERT(/obj/item/organ/eyes/robotic/cyberware/deadeye in chrome_in(shooter), "The pistol companion has no Deadeye link in its body") + TEST_ASSERT(length(shooter.ai_chrome) == 1 && shooter.ai_chrome[1] == "deadeye", "The pistol companion's chrome isn't the company's") // BOUNTY_CHROME_DEADEYE + var/datum/component/bounty_chrome/chrome = shooter.GetComponent(/datum/component/bounty_chrome) + TEST_ASSERT_NOTNULL(chrome, "The chromed companion's AI doesn't know its chrome") + TEST_ASSERT("deadeye" in chrome.keys, "The chromed companion's AI doesn't drive its Deadeye") + TEST_ASSERT(!length(chrome_in(blade)), "A companion the company rolled no chrome for carries some") + TEST_ASSERT_NULL(blade.GetComponent(/datum/component/bounty_chrome), "An unchromed companion has the chrome AI") + + // The companion's tree: up first, then its chrome, then its weapon + var/list/subtrees = shooter.ai_controller.planning_subtrees + var/getting_up = subtrees.Find(locate(/datum/ai_planning_subtree/bounty_companion_getting_up) in subtrees) + var/chrome_at = subtrees.Find(locate(/datum/ai_planning_subtree/bounty_chrome) in subtrees) + var/arm_at = subtrees.Find(locate(/datum/ai_planning_subtree/bounty_arm) in subtrees) + var/retaliate_at = subtrees.Find(locate(/datum/ai_planning_subtree/target_retaliate/bounty) in subtrees) + TEST_ASSERT(retaliate_at && getting_up && chrome_at && arm_at, "The companion's tree is missing its targeting, getting up, chrome or arming") + TEST_ASSERT(retaliate_at < getting_up && getting_up < chrome_at && chrome_at < arm_at, "The companion's tree isn't targeting, getting up, chrome, then arming") + + // Their chrome dies with them: scrap, as on every human NPC + shooter.death() + TEST_ASSERT(!(/obj/item/organ/eyes/robotic/cyberware/deadeye in chrome_in(shooter)), "A dead companion's Deadeye still works") + +/** + * Joining a fight, a companion gets up first: for a second (BOUNTY_COMPANION_DRAW_DELAY) nothing but + * facing the hunter is planned, so no weapon comes out and no blow or shot goes; then the arm subtree + * draws its gun with its line, as a criminal's does. Out of the fight and back in, it gets up again. + */ +/datum/unit_test/voidcrew_bounty_companions/draw_delay + +/datum/unit_test/voidcrew_bounty_companions/draw_delay/Run() + 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 + criminal.ai_controller.set_ai_status(AI_STATUS_OFF) + var/mob/living/carbon/human/npc/bounty_companion/buddy = make_companion(criminal, tile(1, 2), bounty_test_company_member("pistol")) // BOUNTY_STYLE_PISTOL + var/mob/living/carbon/human/hunter = make_companion_target(buddy, tile(4, 2)) + var/datum/ai_controller/controller = buddy.ai_controller + var/list/subtrees = controller.planning_subtrees + var/datum/ai_planning_subtree/getting_up = locate(/datum/ai_planning_subtree/bounty_companion_getting_up) in subtrees + var/datum/ai_planning_subtree/arm = locate(/datum/ai_planning_subtree/bounty_arm) in subtrees + var/datum/ai_behavior/draw = GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_draw/bounty) + + // Out of a fight, nothing holds them + TEST_ASSERT(!getting_up.SelectBehaviors(controller, 0.1), "A companion out of a fight is held getting up") + + // Rallied: in the fight, at a run, and getting up for a second + var/joined_at = world.time + buddy.ai_join_fight(hunter) + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + TEST_ASSERT(buddy.ai_in_fight, "Rallied, the companion didn't join the fight") + TEST_ASSERT(buddy.ai_draw_at >= joined_at + 10, "The companion may draw less than a second after joining the fight") // BOUNTY_COMPANION_DRAW_DELAY + TEST_ASSERT_EQUAL(getting_up.SelectBehaviors(controller, 0.1), 1, "Just in the fight, the companion's planning goes past getting up") // SUBTREE_RETURN_FINISH_PLANNING + var/obj/item/gun/stechkin = carried(buddy, /obj/item/gun/ballistic/automatic/pistol/aps) + TEST_ASSERT(!buddy.is_holding(stechkin), "The companion's pistol came out the moment they joined the fight") + + // Up: the arm subtree draws the pistol, with its line, holding the first shot as a criminal's draw does + buddy.ai_draw_at = world.time + TEST_ASSERT(!getting_up.SelectBehaviors(controller, 0.1), "Up again, the companion is still held getting up") + controller.planned_behaviors.Cut() + TEST_ASSERT_EQUAL(arm.SelectBehaviors(controller, 0.1), 1, "Up, the companion doesn't reach for its gun") // SUBTREE_RETURN_FINISH_PLANNING + TEST_ASSERT(controller.planned_behaviors[draw], "Up, the companion's arming didn't plan the draw") + TEST_ASSERT_EQUAL(controller.blackboard["human_npc_draw_item"], stechkin, "The companion reached for something other than its pistol") // BB_HUMAN_NPC_DRAW_ITEM + controller.CancelActions() + TEST_ASSERT_EQUAL(draw_gun(buddy), stechkin, "The companion didn't draw its pistol") + TEST_ASSERT(controller.blackboard["bb_bounty_windup_until"] >= world.time + 6, "The companion's draw doesn't hold its first shot") // BB_BOUNTY_WINDUP_UNTIL, BOUNTY_DRAW_TIME + + // Out of the fight and back in: up first again + buddy.ai_leave_fight() + TEST_ASSERT(!buddy.ai_in_fight && !buddy.ai_draw_at, "Out of the fight, the companion is still getting up") + buddy.ai_join_fight(hunter) + TEST_ASSERT_EQUAL(getting_up.SelectBehaviors(controller, 0.1), 1, "Back in the fight, the companion didn't get up first") // SUBTREE_RETURN_FINISH_PLANNING + controller.CancelActions() + +/** + * A companion's gun is backup: its Stechkin fires strings of three (BOUNTY_COMPANION_PISTOL_STRING), then the + * criminal's pause, and its WT-550 bursts of two (BOUNTY_COMPANION_SMG_BURST); a criminal's stay six and four. + */ +/datum/unit_test/voidcrew_bounty_companions/backup_fire + +/datum/unit_test/voidcrew_bounty_companions/backup_fire/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(2, 4), "brawler") // BOUNTY_STYLE_BRAWLER + criminal.ai_controller.set_ai_status(AI_STATUS_OFF) + var/datum/bounty_style/pistol = GLOB.bounty_styles["pistol"] // BOUNTY_STYLE_PISTOL + var/datum/bounty_style/smg = GLOB.bounty_styles["smg"] // BOUNTY_STYLE_SMG + var/datum/bounty_style/revolver = GLOB.bounty_styles["revolver"] // BOUNTY_STYLE_REVOLVER + + // The pistol: three shots half a second apart, then two seconds to the next string + var/mob/living/carbon/human/npc/bounty_companion/gunner = make_companion(criminal, tile(0, 2), bounty_test_company_member("pistol")) + var/mob/living/carbon/human/hunter = make_companion_target(gunner, tile(4, 2)) + TEST_ASSERT_EQUAL(pistol.string_length(gunner), 3, "A companion's pistol strings aren't three") + TEST_ASSERT_EQUAL(pistol.string_length(criminal), 6, "A criminal's pistol strings aren't six") // BOUNTY_PISTOL_STRING_SHOTS + TEST_ASSERT_EQUAL(revolver.string_length(gunner), 0, "A companion's revolver fires in strings") + 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 + var/full = bounty_gun_live_rounds(stechkin) + TEST_ASSERT(full >= 7, "Test fixture: the companion's Stechkin holds only [full]") + for(var/shot in 1 to 6) + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), full - shot, "The companion's shot [shot] wasn't a single round") + var/wait = controller.blackboard["bb_bounty_next_shot"] - world.time // BB_BOUNTY_NEXT_SHOT + if(!(shot % 3)) + TEST_ASSERT_EQUAL(wait, 20, "After the companion's [shot]th shot, the next string isn't 2 seconds off") // BOUNTY_PISTOL_INTERVAL + BOUNTY_PISTOL_STRING_PAUSE + else + TEST_ASSERT_EQUAL(wait, 5, "The companion's shot [shot + 1] isn't half a second after shot [shot]") // BOUNTY_PISTOL_INTERVAL + next_pull(gunner, hunter) + if(shot == 3) + // The pause is waited out, not skipped: no new raise for the second string + 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 + shoot_stopped(gunner) + allocated -= gunner + qdel(gunner) + + // The SMG: bursts of two pulls + var/mob/living/carbon/human/npc/bounty_companion/sprayer = make_companion(criminal, tile(0, 1), bounty_test_company_member("smg")) + var/mob/living/carbon/human/mark = make_companion_target(sprayer, tile(4, 1)) + TEST_ASSERT_EQUAL(smg.burst_length(sprayer), 2, "A companion's SMG bursts aren't two") + TEST_ASSERT_EQUAL(smg.burst_length(criminal), 4, "A criminal's SMG bursts aren't four") // BOUNTY_SMG_BURST + TEST_ASSERT_EQUAL(pistol.burst_length(sprayer), 1, "A companion's pistol fires bursts") + var/obj/item/gun/ballistic/automatic/wt550/wt550 = sprayer.belt + TEST_ASSERT(istype(wt550), "Test fixture: the SMG companion has no WT-550 on its belt") + TEST_ASSERT(human_npc_take_in_hand(sprayer, wt550), "The companion's WT-550 can't be drawn") + var/datum/ai_controller/smg_ai = sprayer.ai_controller + var/rounds = start_burst(sprayer, mark, wt550) + TEST_ASSERT_EQUAL(smg_ai.blackboard["bb_bounty_burst_left"], 1, "A companion's burst doesn't have one pull left after the first") // BB_BOUNTY_BURST_LEFT + shoot_step(sprayer) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(wt550), rounds - 1, "The companion's second pull didn't fire") + TEST_ASSERT_NULL(smg_ai.blackboard["bb_bounty_burst_left"], "A companion's burst didn't end after two pulls") // BB_BOUNTY_BURST_LEFT + TEST_ASSERT_EQUAL(smg_ai.blackboard["bb_bounty_next_shot"], world.time + 5, "After a companion's burst, the next one isn't half a second off") // BOUNTY_SMG_INTERVAL + shoot_stopped(sprayer) + allocated -= sprayer + qdel(sprayer) + +// ===== THE POSTING'S COMPANY ===== + +/** + * The company is rolled with the posting's site and named on the sighting: the card, the hunt notice and + * the warrant say who they were seen with, at most one of them armed. Nobody comes with a meek criminal, + * a mini-boss or at a trader outpost, one at most aboard a pirate ship; the same company stays while the + * bounty is at a site, a new site rolls a new one, and that company is who spawns beside the criminal. + */ +/datum/unit_test/voidcrew_bounty_company_card + parent_type = /datum/unit_test/voidcrew_bounty_board + +/datum/unit_test/voidcrew_bounty_company_card/Run() + var/datum/criminal_bounty/posting = board_test_posting(archetype = "normal") // BOUNTY_ARCHETYPE_NORMAL + // What the sighting says + posting.board_company = list(bounty_test_company_member("brawler")) // BOUNTY_STYLE_* + TEST_ASSERT_EQUAL(posting.board_company_text(), "with a friend", "One unarmed companion") + posting.board_company = list(bounty_test_company_member("pistol")) + TEST_ASSERT_EQUAL(posting.board_company_text(), "with an armed friend", "One armed companion") + posting.board_company = list(bounty_test_company_member("knife"), bounty_test_company_member("club")) + TEST_ASSERT_EQUAL(posting.board_company_text(), "with two friends", "Two unarmed companions") + posting.board_company = list(bounty_test_company_member("smg"), bounty_test_company_member("bottle")) + TEST_ASSERT_EQUAL(posting.board_company_text(), "with two friends, one armed", "Two companions, one armed") + TEST_ASSERT_EQUAL(posting.board_sighting_text(), "[posting.board_place_text()] with two friends, one armed", "The sighting doesn't name the company after the place") + var/obj/structure/overmap/ship/board_test_listener/ship = board_test_listener() + var/list/entry = posting.board_ui_entry(ship, null) + TEST_ASSERT_EQUAL(entry["place"], posting.board_sighting_text(), "The card doesn't name the company") + TEST_ASSERT(findtext(posting.board_warrant_text(), "With two friends, one armed."), "The warrant doesn't name the company") + TEST_ASSERT_EQUAL(posting.hunt(ship), TRUE, "The ship could not hunt the bounty") + TEST_ASSERT(ship.board_test_heard("WANTED: now hunting [posting.record.name]. [posting.board_sighting_text()]."), "The hunt notice doesn't name the company") + // Relisting, the company isn't known + posting.board_relisting = TRUE + TEST_ASSERT_NULL(posting.board_company_text(), "A relisting bounty names its company") + posting.board_relisting = FALSE + posting.board_company = list() + TEST_ASSERT_NULL(posting.board_company_text(), "A criminal on their own is seen with someone") + TEST_ASSERT_EQUAL(posting.board_sighting_text(), posting.board_place_text(), "A criminal on their own isn't seen just where they are") + + // The roll for where they are: at most two, one aboard a pirate ship, none at a trader outpost or with another kind of criminal + for(var/i in 1 to 50) + var/list/rolled = posting.board_roll_company() + TEST_ASSERT(length(rolled) <= 2, "A planet criminal rolled [length(rolled)] companions") // BOUNTY_MAX_COMPANIONS + var/guns = 0 + for(var/list/member as anything in rolled) + if(bounty_style_is_gun(member["style"])) + guns++ + TEST_ASSERT(guns <= 1, "A posting's company rolled [guns] guns") + posting.placement_kind = "npc_ship" // BOUNTY_PLACEMENT_NPC_SHIP + for(var/i in 1 to 50) + TEST_ASSERT(length(posting.board_roll_company()) <= 1, "A criminal aboard a pirate ship rolled more than one companion") + posting.placement_kind = "trader_outpost" // BOUNTY_PLACEMENT_TRADER_OUTPOST + TEST_ASSERT(!length(posting.board_roll_company()), "A trader-outpost fugitive rolled companions") + posting.placement_kind = "planet" // BOUNTY_PLACEMENT_PLANET + var/datum/criminal_bounty/runner = board_test_posting() // a meek criminal + var/datum/criminal_bounty/heavy = board_test_posting(tier = 3, archetype = "boss") // BOUNTY_TIER_MOST_WANTED, BOUNTY_ARCHETYPE_BOSS + for(var/i in 1 to 20) + TEST_ASSERT(!length(runner.board_roll_company()), "A meek criminal rolled companions") + TEST_ASSERT(!length(heavy.board_roll_company()), "A mini-boss rolled companions") + TEST_ASSERT_NULL(runner.board_company_text(), "A meek criminal is seen with someone") + + // Kept at its site, and rolled again for a new one + var/obj/structure/overmap/ship/first_site = board_test_ship() + var/obj/structure/overmap/ship/second_site = board_test_ship() + posting.site_ref = WEAKREF(first_site) + var/list/kept = posting.board_company() + TEST_ASSERT(posting.board_company() == kept, "The company changed while the bounty stayed at its site") + posting.site_ref = WEAKREF(second_site) + TEST_ASSERT(posting.board_company() != kept, "A new site didn't roll a new company") + posting.site_ref = null + + // The company the posting rolled is who spawns, through the human NPC queue + var/datum/criminal_bounty/gang_posting = board_test_posting(archetype = "normal") // BOUNTY_ARCHETYPE_NORMAL + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(gang_posting.record, run_loc_floor_bottom_left, gang_posting) + TEST_ASSERT_NOTNULL(criminal, "Test fixture: no criminal") + allocated += criminal + criminal.ai_controller.set_ai_status(AI_STATUS_OFF) + gang_posting.criminal_ref = WEAKREF(criminal) + criminal.posting_ref = WEAKREF(gang_posting) + gang_posting.board_company = list(bounty_test_company_member("revolver", list("deadeye")), bounty_test_company_member("club")) // BOUNTY_STYLE_REVOLVER, BOUNTY_CHROME_DEADEYE, BOUNTY_STYLE_CLUB + gang_posting.board_spawn_companions(criminal) + // Queued for the human NPC queue: built here and now, as the queue would build them (a test room has no zone to wait for) + var/list/datum/human_npc_order/orders = list() + for(var/datum/human_npc_order/order as anything in SShuman_npcs.queue) + var/datum/npc_spawn_context/bounty_company/context = order.context + if(istype(context) && context.company_leader_ref?.resolve() == criminal) + orders += order + TEST_ASSERT_EQUAL(length(orders), 2, "The posting queued [length(orders)] companions, not its company of two") + for(var/datum/human_npc_order/order as anything in orders) + order.fulfil() + qdel(order) + var/list/buddies = criminal.ai_companions() + allocated += buddies + TEST_ASSERT_EQUAL(length(buddies), 2, "The posting's company didn't spawn") + var/list/styles = list() + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in buddies) + buddy.ai_controller.set_ai_status(AI_STATUS_OFF) + styles += buddy.ai_style + TEST_ASSERT(WEAKREF(buddy) in gang_posting.companions, "A spawned companion isn't on the posting's list") + var/has_deadeye = !!buddy.get_organ_by_type(/obj/item/organ/eyes/robotic/cyberware/deadeye) + TEST_ASSERT_EQUAL(has_deadeye, buddy.ai_style == "revolver", "The [buddy.ai_style] companion's chrome isn't the company's") + TEST_ASSERT(("revolver" in styles) && ("club" in styles), "The company spawned as [jointext(styles, ", ")], not the revolver and the club") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_cyberpsycho.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_cyberpsycho.dm new file mode 100644 index 00000000000..e768780547a --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_cyberpsycho.dm @@ -0,0 +1,423 @@ +/** + * The cyberpsycho (voidcrew/modules/bounties/chrome/bounty_cyberpsycho.dm): where it sits among the kits, + * its chrome (the real implants, every one that fits, nothing browned out), its rotation, its Redline phase + * two against damage and against stamina weapons, Lazarus, an EMP, death, and the Bounty Panel. + * + * Real human NPCs with the real implants in them; the tests read tg's own state. The AI is switched off, + * so the tests drive the boss's procs and nothing else happens in between; timers run as they would. Fork + * defines are included after the tests, so a test uses the literal value with a comment naming the define. + * The test room is 5x5. + * + * Renders: compile with -DBOUNTY_CHROME_RENDERS and the renders test writes flat icons to + * data/bounty_chrome_renders/ (cyberpsycho__.png). + */ +/datum/unit_test/voidcrew_bounty_cyberpsycho + abstract_type = /datum/unit_test/voidcrew_bounty_cyberpsycho + +/// The floor tile `dx`, `dy` from the room's bottom left +/datum/unit_test/voidcrew_bounty_cyberpsycho/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) + +/// A hunter at `where`: a human with a mind, as a player would be +/datum/unit_test/voidcrew_bounty_cyberpsycho/proc/hunter_at(turf/where) + var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, where) + hunter.mind_initialize() + return hunter + +/// A Most Wanted cyberpsycho's record, of `species` +/datum/unit_test/voidcrew_bounty_cyberpsycho/proc/psycho_record(species = /datum/species/human) + var/datum/bounty_record/record = generate_bounty_record(3, "boss", "planet", species) // BOUNTY_TIER_MOST_WANTED, BOUNTY_ARCHETYPE_BOSS, BOUNTY_PLACEMENT_PLANET + record.kit = "cyberpsycho" // BOUNTY_KIT_CYBERPSYCHO + record.chrome = null + return record + +/// A cyberpsycho at `where`, spawned as the board spawns one, its AI off; with `hunter`, turned on them (on its grudge list, in its posse, its target) +/datum/unit_test/voidcrew_bounty_cyberpsycho/proc/psycho_at(turf/where, mob/living/hunter) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = spawn_bounty_criminal(psycho_record(), where, null) + if(!psycho) + return null + allocated += psycho + psycho.ai_controller?.set_ai_status(AI_STATUS_OFF) + if(hunter) + psycho.body_add_grudge(hunter) + psycho.boss_turn_hostile(hunter) + psycho.ai_controller?.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + var/datum/component/bounty_chrome/chrome = psycho.GetComponent(/datum/component/bounty_chrome) + chrome?.update_fight() + return psycho + +/// The organ types of the chrome in `body` +/datum/unit_test/voidcrew_bounty_cyberpsycho/proc/chrome_in(mob/living/carbon/body) + . = list() + for(var/obj/item/organ/organ in body.organs) + if(organ.GetComponent(/datum/component/cyberware)) + . += organ.type + +/// Its ability running `move_type`, if it has one +/datum/unit_test/voidcrew_bounty_cyberpsycho/proc/ability_for(mob/living/carbon/human/npc/bounty_criminal/boss/boss, move_type) + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability in boss.boss_abilities) + if(istype(ability.move, move_type)) + return ability + return null + +/// Ready for another move straight away: no gap, no ability cooldowns, hands free to click +/datum/unit_test/voidcrew_bounty_cyberpsycho/proc/ready(mob/living/carbon/human/npc/bounty_criminal/boss/boss) + boss.boss_next_ability_at = 0 + boss.next_move = 0 + boss.next_click = 0 + for(var/datum/action/cooldown/ability as anything in boss.boss_abilities) + ability.next_use_time = 0 + +/// Puts out its blade, as its chrome does on a Life tick in its fight +/datum/unit_test/voidcrew_bounty_cyberpsycho/proc/blade_out(mob/living/carbon/human/npc/bounty_criminal/boss/boss, atom/target) + var/datum/component/bounty_chrome/chrome = boss.GetComponent(/datum/component/bounty_chrome) + var/datum/bounty_chrome_move/mantis_blades/blades = chrome?.move_of(/datum/bounty_chrome_move/mantis_blades) + blades?.on_tick(2, TRUE, target) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = locate() in boss.organs + return housing?.blade_extended() + +// ===== WHERE IT SITS ===== + +/** + * Where it sits: a kit like the others, the rarest; its record rolls no chrome on top (its kit is its + * chrome); its card's lines, its alias, the Bounty Panel's kit list and its prison riot move are a kit's. + */ +/datum/unit_test/voidcrew_bounty_cyberpsycho/kit + +/datum/unit_test/voidcrew_bounty_cyberpsycho/kit/Run() + var/list/counts = list() + for(var/i in 1 to 2000) + var/kit = bounty_roll_kit() + counts[kit] = (counts[kit] || 0) + 1 + TEST_ASSERT(counts["cyberpsycho"] > 0, "The cyberpsycho never rolled as a kit") + for(var/kit in list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy")) // BOUNTY_KIT_* + TEST_ASSERT(counts["cyberpsycho"] < counts[kit], "The cyberpsycho ([counts["cyberpsycho"]]) rolled as often as the [kit] ([counts[kit]])") + var/datum/bounty_record/record = psycho_record() + TEST_ASSERT_EQUAL(bounty_criminal_type(record, null), /mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho, "A cyberpsycho record spawns the wrong type") + TEST_ASSERT_EQUAL(bounty_boss_move_type(record), /datum/prison_boss_move/charge, "A caught cyberpsycho's riot move is [bounty_boss_move_type(record)]") + for(var/i in 1 to 100) + TEST_ASSERT_NULL(bounty_chrome_roll(3, "boss", null, "cyberpsycho", bounty_chrome_kit_organs("cyberpsycho")), "A cyberpsycho's record rolled chrome on top of its own") + var/list/lines = bounty_identity_strings("lines") + for(var/context in list("intro", "ability", "redline", "exhausted", "posse", "cover")) + TEST_ASSERT(length(lines["cyberpsycho_[context]"]?["any"]) >= 6, "The cyberpsycho has fewer than 6 [context] lines") + var/list/aliases = bounty_identity_strings("aliases") + TEST_ASSERT(length(aliases["cyberpsycho"]) >= 5, "The cyberpsycho has too few aliases") + var/datum/bounty_admin_panel/panel = allocate(/datum/bounty_admin_panel, null) + TEST_ASSERT_EQUAL(panel.kit_choices()["Cyberpsycho"], "cyberpsycho", "The Bounty Panel doesn't offer the cyberpsycho") + +// ===== ITS CHROME ===== + +/** + * Its chrome: the six real implants that fit one body, Cascade left out for Redline's operating-system slot, + * Mantis in the right arm and Gorilla in the left; the kit's chrome as the rolls know it; its load over a + * body's 20 with its Redline core carrying the Governor's 15 of capacity through the real hook, so nothing + * browns out. Its rotation is the burn, the lunge, the leap and the piston punch, each told for at least + * 0.8 s. It dresses to show the chrome, and seals up like any mini-boss in the void. + */ +/datum/unit_test/voidcrew_bounty_cyberpsycho/chrome + +/datum/unit_test/voidcrew_bounty_cyberpsycho/chrome/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = psycho_at(tile(2, 2)) + TEST_ASSERT(istype(psycho), "No cyberpsycho spawned") + TEST_ASSERT_EQUAL(psycho.boss_kit, "cyberpsycho", "The cyberpsycho has the kit [psycho.boss_kit]") + var/list/carried = chrome_in(psycho) + var/list/expected = list( + /obj/item/organ/cyberimp/cyberware/redline, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + /obj/item/organ/cyberimp/cyberware/gorilla_arms/left, + /obj/item/organ/cyberimp/cyberware/piledriver, + /obj/item/organ/cyberimp/cyberware/lazarus, + /obj/item/organ/eyes/robotic/cyberware/deadeye, + ) + TEST_ASSERT_EQUAL(length(carried), length(expected), "The cyberpsycho carries [length(carried)] pieces of chrome: [jointext(carried, ", ")]") + for(var/organ_type in expected) + TEST_ASSERT(organ_type in carried, "The cyberpsycho doesn't carry [organ_type]") + var/list/known = bounty_chrome_kit_organs("cyberpsycho") + TEST_ASSERT_EQUAL(length(known), length(carried), "The rolls know of [length(known)] of its pieces") + for(var/organ_type in known) + TEST_ASSERT(organ_type in carried, "The rolls fit around [organ_type], which the cyberpsycho doesn't carry") + TEST_ASSERT_NULL(locate(/obj/item/organ/cyberimp/cyberware/cascade) in psycho.organs, "The cyberpsycho has a Cascade lattice beside its Redline core") + TEST_ASSERT_NULL(psycho.record.chrome, "The cyberpsycho's record lists rolled chrome") + TEST_ASSERT_NULL(locate(/obj/item/organ/eyes) in get_turf(psycho), "The eyes it was born with lie on the floor") + + // The real capacity: 32 load in a body that holds 35, its Redline core carrying the extra + TEST_ASSERT_EQUAL(get_chrome_load(psycho), 32, "The cyberpsycho's chrome loads it [get_chrome_load(psycho)]") + TEST_ASSERT_EQUAL(get_chrome_capacity(psycho), 35, "The cyberpsycho's body holds [get_chrome_capacity(psycho)]") // CYBERWARE_BASE_CAPACITY + BOUNTY_PSYCHO_EXTRA_CAPACITY + var/obj/item/organ/core = locate(/obj/item/organ/cyberimp/cyberware/redline) in psycho.organs + var/datum/component/cyberware/core_ware = core?.GetComponent(/datum/component/cyberware) + TEST_ASSERT_EQUAL(core_ware?.capacity_bonus, 15, "Its Redline core doesn't carry the Governor's capacity") // BOUNTY_PSYCHO_EXTRA_CAPACITY + for(var/obj/item/organ/organ in psycho.organs) + var/datum/component/cyberware/ware = organ.GetComponent(/datum/component/cyberware) + if(!ware) + continue + TEST_ASSERT(!ware.browned_out, "The cyberpsycho's [organ] browned out") + TEST_ASSERT(ware.is_running(), "The cyberpsycho's [organ] isn't running") + + // Its chrome AI, and its rotation: four moves, all told + var/datum/component/bounty_chrome/chrome = psycho.GetComponent(/datum/component/bounty_chrome) + TEST_ASSERT_NOTNULL(chrome, "The cyberpsycho has no chrome AI") + for(var/key in list("redline", "mantis", "gorilla", "piledriver", "lazarus", "deadeye")) // BOUNTY_CHROME_* + TEST_ASSERT(key in chrome.keys, "The cyberpsycho's chrome AI doesn't know its [key]") + var/list/moves = list( + /datum/bounty_chrome_move/redline, + /datum/bounty_chrome_move/mantis_lunge, + /datum/bounty_chrome_move/piledriver, + /datum/bounty_chrome_move/gorilla_punch/psycho, + ) + TEST_ASSERT_EQUAL(length(psycho.boss_abilities), length(moves), "The cyberpsycho has [length(psycho.boss_abilities)] abilities, not its four moves") + for(var/move_type in moves) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/ability = ability_for(psycho, move_type) + TEST_ASSERT_NOTNULL(ability, "The cyberpsycho's [move_type] isn't in its rotation") + TEST_ASSERT(ability?.windup >= 0.8 SECONDS, "The cyberpsycho's [move_type] tells for [ability?.windup / 10] s") // BOUNTY_CHROME_TELL_MIN + TEST_ASSERT(!length(ability?.move?.tell_lines), "The cyberpsycho's [move_type] has its own lines besides the cyberpsycho's") + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/burn = ability_for(psycho, /datum/bounty_chrome_move/redline) + TEST_ASSERT(istype(burn?.move, /datum/bounty_chrome_move/redline/psycho), "Its Redline isn't its phase two: [burn?.move?.type]") + var/count = 0 + for(var/datum/bounty_chrome_move/redline/move in chrome.moves) + count++ + TEST_ASSERT_EQUAL(count, 1, "It has [count] Redline moves, not its own one") + + // Dressed to show it: shorts and boots, nothing on its arms or chest + TEST_ASSERT(psycho.bounty_dresses_to_show_chrome(), "The cyberpsycho dresses to hide its chrome") + TEST_ASSERT(istype(psycho.w_uniform, /obj/item/clothing/under/shorts), "The cyberpsycho wears [psycho.w_uniform] over its legs") + TEST_ASSERT_NULL(psycho.wear_suit, "The cyberpsycho wears [psycho.wear_suit] over its chrome") + TEST_ASSERT_NULL(psycho.gloves, "The cyberpsycho wears gloves over its arms") + TEST_ASSERT(psycho.boss_gear_text(), "The cyberpsycho has no gear line on examine") + // Its two stimulants and a bruise pack, as every mini-boss, where it can reach them; no bag over its spine rig + TEST_ASSERT_EQUAL(length(psycho.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen/stimpack)) - length(psycho.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen/stimpack/traitor)), 2, "The cyberpsycho doesn't carry its two stimulants") // BOUNTY_BOSS_STIMULANTS + // Its combat stimpack rides in a pocket, the bum bag being full (BOUNTY_BOSS_COMBAT_STIMULANT) + var/obj/item/combat_pen = locate(/obj/item/reagent_containers/hypospray/medipen/stimpack/traitor) in list(psycho.l_store, psycho.r_store) + TEST_ASSERT_NOTNULL(combat_pen, "The cyberpsycho has no combat stimpack in a pocket") + TEST_ASSERT_EQUAL(length(psycho.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen/stimpack/traitor)), 1, "The cyberpsycho doesn't carry one combat stimpack") + TEST_ASSERT(human_npc_gear_consumable(combat_pen), "The cyberpsycho's combat stimpack isn't issued to it") + TEST_ASSERT(length(psycho.get_all_contents_type(/obj/item/stack/medical/bruise_pack)), "The cyberpsycho carries nothing to patch itself up with") + TEST_ASSERT_NOTNULL(bounty_ai_find_injector(psycho, /obj/item/reagent_containers/hypospray/medipen/stimpack), "The cyberpsycho can't reach its stimulants") + TEST_ASSERT_NULL(psycho.back, "The cyberpsycho wears [psycho.back] over its spine rig") + // In the void, a civilian MODsuit: it wears no armour in good air either + var/list/gear = bounty_vacuum_gear(psycho) + TEST_ASSERT(length(gear) == 1 && gear[1] == /obj/item/mod/control/pre_equipped/bounty_boss/civilian, "The cyberpsycho's void suit isn't a civilian MODsuit: [jointext(gear, ", ")]") + + // Dead, its chrome burns out to scrap, all six pieces + var/turf/here = get_turf(psycho) + psycho.death() + TEST_ASSERT_EQUAL(length(chrome_in(psycho)), 0, "A dead cyberpsycho still carries working chrome") + var/scrap = 0 + for(var/obj/item/burnt_chrome/burnt in here) + scrap++ + TEST_ASSERT_EQUAL(scrap, 6, "A dead cyberpsycho's six implants left [scrap] pieces of scrap") + +// ===== ONE MOVE AT A TIME ===== + +/** + * The blade comes out of its right forearm in a fight and is its melee; its left hand, the Gorilla fist, + * stays empty, so it can punch through glass (C5). The piston punch is a told move: the arm's own punch + * lands only after the tell. While one move winds up, no other starts. + */ +/datum/unit_test/voidcrew_bounty_cyberpsycho/rotation + +/datum/unit_test/voidcrew_bounty_cyberpsycho/rotation/Run() + var/mob/living/carbon/human/hunter = hunter_at(tile(3, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = psycho_at(tile(2, 2), hunter) + TEST_ASSERT(istype(psycho), "No cyberpsycho spawned") + TEST_ASSERT(psycho.boss_hostile, "The cyberpsycho didn't turn on the hunter") + TEST_ASSERT(blade_out(psycho, hunter), "The cyberpsycho's blade didn't come out in its fight") + var/obj/item/blade = psycho.get_item_for_held_index(RIGHT_HANDS) + TEST_ASSERT(istype(blade, /obj/item/melee/energy/blade/hardlight/cyberware_mantis), "The blade isn't in its right hand: [blade]") + TEST_ASSERT_NULL(psycho.get_item_for_held_index(LEFT_HANDS), "Its Gorilla hand holds [psycho.get_item_for_held_index(LEFT_HANDS)]") + TEST_ASSERT_EQUAL(human_npc_held_melee_weapon(psycho), blade, "Its melee isn't its blade") + TEST_ASSERT(psycho.boss_has_gorilla_fist(), "It has no Gorilla fist free to punch through glass with") + + // The piston punch, through its rotation: the tell, then the arm's own punch + ready(psycho) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/punch = ability_for(psycho, /datum/bounty_chrome_move/gorilla_punch/psycho) + TEST_ASSERT(punch.worth_using(hunter), "The piston punch isn't worth using on a hunter beside it") + TEST_ASSERT(punch.Trigger(target = hunter), "The piston punch wouldn't start") + TEST_ASSERT_EQUAL(psycho.boss_busy, "windup", "The piston punch doesn't wind up") + TEST_ASSERT_NOTNULL(psycho.get_filter(punch.move.tell_filter()), "The piston punch's tell has no outline") + // One at a time: nothing else starts while it winds up + for(var/datum/action/cooldown/mob_cooldown/bounty_boss/ability as anything in psycho.boss_abilities) + ability.next_use_time = 0 + TEST_ASSERT_NULL(psycho.boss_choose_ability(hunter), "Another move would start while the piston punch winds up") + TEST_ASSERT_EQUAL(hunter.getBruteLoss(), 0, "The punch landed before its tell") + sleep(1 SECONDS) + TEST_ASSERT(hunter.getBruteLoss() >= 15, "The piston punch did [hunter.getBruteLoss()] brute, not the implant's") // CYBERWARE_GORILLA_PUNCH_DAMAGE + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = locate() in psycho.organs + TEST_ASSERT(!bounty_gorilla_loaded(arm), "The punch wasn't the Gorilla arm's own") + TEST_ASSERT_NULL(psycho.boss_busy, "Still busy after the punch") + TEST_ASSERT(world.time < psycho.boss_next_ability_at, "No gap after the punch before its next move") + +// ===== ITS PHASE TWO ===== + +/** + * A stamina weapon is answered with its Redline: one disabler bolt's worth and, a moment later, the burn's + * tell starts, cutting short whatever it was winding up. It doesn't wear out while its phase two is to + * come. After the tell, the implant's burn: stun-proof, so more stamina doesn't floor it, and still not worn + * out; then the crash floors it in stamina crit, the capture. Once: it never burns again. + */ +/datum/unit_test/voidcrew_bounty_cyberpsycho/burn_stamina + +/datum/unit_test/voidcrew_bounty_cyberpsycho/burn_stamina/Run() + var/mob/living/carbon/human/hunter = hunter_at(tile(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = psycho_at(tile(1, 2), hunter) + TEST_ASSERT(istype(psycho), "No cyberpsycho spawned") + TEST_ASSERT(blade_out(psycho, hunter), "The cyberpsycho's blade didn't come out") + ready(psycho) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/burn = ability_for(psycho, /datum/bounty_chrome_move/redline) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/lunge = ability_for(psycho, /datum/bounty_chrome_move/mantis_lunge) + TEST_ASSERT(!burn.worth_using(hunter), "An unhurt cyberpsycho reaches for its Redline") + // Winding up a lunge when the bolt lands + TEST_ASSERT(lunge.worth_using(hunter), "The lunge isn't worth using on a hunter three tiles off") + TEST_ASSERT(lunge.Trigger(target = hunter), "The lunge wouldn't start") + TEST_ASSERT_EQUAL(psycho.boss_winding(), lunge, "The lunge isn't winding up") + psycho.apply_damage(30, STAMINA) // a disabler bolt + TEST_ASSERT(!psycho.boss_is_worn_out(), "One bolt wore it out") + sleep(0.2 SECONDS) + TEST_ASSERT_EQUAL(psycho.boss_winding(), burn, "A stamina hit didn't start its Redline's tell") + TEST_ASSERT(!lunge.pending_serial, "The lunge it was winding up still goes") + psycho.adjustStaminaLoss(30) + TEST_ASSERT(!psycho.boss_is_worn_out(), "Winded with its phase two to come, it wears out instead of burning") + TEST_ASSERT_NULL(psycho.has_status_effect(/datum/status_effect/cyberware_redline_window), "The burn started before its tell was over") + sleep(1.1 SECONDS) + + // The implant's own burn + TEST_ASSERT_NOTNULL(psycho.has_status_effect(/datum/status_effect/cyberware_redline_window), "The tell ended but the implant's burn didn't start") + TEST_ASSERT(psycho.psycho_burned, "Its phase two isn't spent") + TEST_ASSERT(HAS_TRAIT(psycho, TRAIT_STUNIMMUNE), "The burn gives no stun immunity") + psycho.apply_damage(60, STAMINA) + TEST_ASSERT_NULL(psycho.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Stamina floored it in the burn") + TEST_ASSERT(!psycho.boss_is_worn_out(), "It wears out in the burn") + TEST_ASSERT(!burn.worth_using(hunter), "It would burn again while burning") + + // The crash: stamina crit, the capture + sleep(12.4 SECONDS) + TEST_ASSERT_NULL(psycho.has_status_effect(/datum/status_effect/cyberware_redline_window), "The burn outlasted the implant's 12 seconds") + TEST_ASSERT_NOTNULL(psycho.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "The crash didn't floor it in stamina crit") + TEST_ASSERT_EQUAL(psycho.capture_state(), "stunned", "The crash isn't a stunned capture") // BOUNTY_STATE_STUNNED + // Once a spawn: back on its feet and winded again, no second burn, and now it tires like any mini-boss + psycho.remove_status_effect(/datum/status_effect/incapacitating/stamcrit) + psycho.setStaminaLoss(70) + burn.next_use_time = 0 + TEST_ASSERT(!burn.worth_using(hunter), "It would burn its Redline a second time") + TEST_ASSERT(psycho.boss_is_worn_out(), "With its phase two spent, it doesn't tire") + +/** + * Damage sets it off too: hurt to three quarters of its health, it burns. Not with someone outside its + * fight in the roar's reach (the bystander gate). An EMP in the tell fires nothing and takes its core + * down, sparking; with its core down it tires like any mini-boss. + */ +/datum/unit_test/voidcrew_bounty_cyberpsycho/burn_hurt + +/datum/unit_test/voidcrew_bounty_cyberpsycho/burn_hurt/Run() + var/mob/living/carbon/human/hunter = hunter_at(tile(4, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = psycho_at(tile(1, 2), hunter) + TEST_ASSERT(istype(psycho), "No cyberpsycho spawned") + ready(psycho) + var/datum/action/cooldown/mob_cooldown/bounty_boss/chrome/burn = ability_for(psycho, /datum/bounty_chrome_move/redline) + // A bystander in the roar's reach keeps it shut + var/mob/living/carbon/human/bystander = hunter_at(tile(1, 4)) + psycho.adjustBruteLoss(30) + TEST_ASSERT(psycho.psycho_hurt_enough(), "Hurt to [psycho.health] doesn't count") + TEST_ASSERT(!burn.worth_using(hunter), "It burns with a bystander in the roar's reach") + qdel(bystander) + TEST_ASSERT(burn.worth_using(hunter), "Hurt to [psycho.health] in its fight, it won't burn") + // Its own companion beside it doesn't keep it shut: a crew of hunters brings those in (C0's gate would) + var/datum/human_npc_order/order = bounty_spawn_companion(psycho, tile(1, 3), null, TRUE, bounty_test_company_member("brawler", null)) // BOUNTY_STYLE_BRAWLER + var/mob/living/carbon/human/npc/bounty_companion/buddy = order?.spawned_ref?.resolve() + qdel(order) + TEST_ASSERT_NOTNULL(buddy, "Test fixture: no companion was made") + allocated += buddy + buddy.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(bounty_ai_same_gang(psycho, buddy), "Test fixture: the companion isn't on its side") + var/datum/bounty_chrome_move/redline/move = burn.move + TEST_ASSERT(!bounty_chrome_area_clear(psycho, move.area_turfs(hunter), hunter), "Test fixture: C0's gate lets the roar go over its own companion") + TEST_ASSERT(burn.worth_using(hunter), "Its own companion beside it keeps its phase two shut") + TEST_ASSERT_EQUAL(psycho.boss_choose_ability(hunter), burn, "Its rotation doesn't put its phase two first") + TEST_ASSERT(psycho.psycho_burn_now(), "The burn's tell didn't start") + TEST_ASSERT_EQUAL(psycho.boss_winding(), burn, "The burn isn't winding up") + + // An EMP in the tell: nothing fires, its chrome sparks and reboots, and now it tires + psycho.emp_act(EMP_HEAVY) + TEST_ASSERT_NULL(psycho.boss_winding(), "An EMP didn't cut the burn's tell short") + sleep(1.2 SECONDS) + TEST_ASSERT_NULL(psycho.has_status_effect(/datum/status_effect/cyberware_redline_window), "It burned through an EMP in the tell") + TEST_ASSERT(!psycho.psycho_burned, "An EMP'd tell spent its phase two") + TEST_ASSERT_NOTNULL(psycho.has_status_effect(/datum/status_effect/bounty_chrome_malfunction), "Its chrome doesn't spark after the EMP") + var/obj/item/organ/core = locate(/obj/item/organ/cyberimp/cyberware/redline) in psycho.organs + var/datum/component/cyberware/core_ware = core?.GetComponent(/datum/component/cyberware) + TEST_ASSERT(core_ware?.emp_down, "The EMP didn't take its core down") + TEST_ASSERT(!psycho.psycho_burn_pending(), "With its core down, its phase two still waits") + psycho.setStaminaLoss(70) + TEST_ASSERT(psycho.boss_is_worn_out(), "With its core down, it doesn't tire") + TEST_ASSERT_EQUAL(get_chrome_capacity(psycho), 35, "An EMP took its capacity away, browning its chrome out") // CYBERWARE_BASE_CAPACITY + BOUNTY_PSYCHO_EXTRA_CAPACITY + +// ===== LAZARUS ===== + +/// Beaten into crit, the node's own jolt stands it up after its charge; down again in the same fight, it stays down +/datum/unit_test/voidcrew_bounty_cyberpsycho/lazarus + +/datum/unit_test/voidcrew_bounty_cyberpsycho/lazarus/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = psycho_at(tile(2, 2)) + TEST_ASSERT(istype(psycho), "No cyberpsycho spawned") + var/obj/item/organ/cyberimp/cyberware/lazarus/node = locate() in psycho.organs + TEST_ASSERT_NOTNULL(node, "The cyberpsycho has no Lazarus node") + for(var/i in 1 to 30) + if(psycho.stat != CONSCIOUS) + break + psycho.adjustBruteLoss(10) + psycho.updatehealth() + TEST_ASSERT(psycho.is_downed(), "The beating didn't put it in crit (health [psycho.health])") + TEST_ASSERT(node.jolting, "Going into crit didn't start the node's charge") + sleep(1.3 SECONDS) + TEST_ASSERT_EQUAL(psycho.stat, CONSCIOUS, "The node didn't stand it up (health [psycho.health])") + for(var/i in 1 to 30) + if(psycho.stat != CONSCIOUS) + break + psycho.adjustBruteLoss(10) + psycho.updatehealth() + TEST_ASSERT(psycho.is_downed(), "The second beating didn't put it in crit") + sleep(1.3 SECONDS) + TEST_ASSERT(psycho.is_downed(), "It got up a second time in one fight") + +// ===== THE BOUNTY PANEL ===== + +/// The panel spawns one by its kit, and "All of it" is the cyberpsycho whatever archetype was picked +/datum/unit_test/voidcrew_bounty_cyberpsycho/admin + +/datum/unit_test/voidcrew_bounty_cyberpsycho/admin/Run() + var/mob/living/carbon/human/operator = allocate(/mob/living/carbon/human/consistent, tile(4, 4)) + var/datum/bounty_admin_panel/unit_test/panel = allocate(/datum/bounty_admin_panel/unit_test, operator) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/spawned = panel.admin_spawn_criminal(operator, 3, "boss", "cyberpsycho", null, tile(1, 1), "roll") // BOUNTY_ADMIN_CHROME_ROLL + allocated += spawned + TEST_ASSERT(istype(spawned), "The panel's cyberpsycho spawned as [spawned?.type]: [panel.error]") + TEST_ASSERT_EQUAL(length(chrome_in(spawned)), 6, "The panel's cyberpsycho carries [length(chrome_in(spawned))] pieces") + TEST_ASSERT_NULL(spawned?.record?.chrome, "Rolled as usual, the cyberpsycho rolled chrome on top of its own") + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/all = panel.admin_spawn_criminal(operator, 3, "normal", "brawler", null, tile(3, 1), "all") // BOUNTY_ADMIN_CHROME_ALL + allocated += all + TEST_ASSERT(istype(all), "All of it spawned [all?.type], not the cyberpsycho") + TEST_ASSERT_EQUAL(all?.record?.archetype, "boss", "All of it's record isn't a mini-boss's") // BOUNTY_ARCHETYPE_BOSS + TEST_ASSERT_NULL(all?.record?.style, "All of it kept a fighting style") + TEST_ASSERT_EQUAL(length(chrome_in(all)), 6, "All of it carries [length(chrome_in(all))] pieces") + TEST_ASSERT(!panel.said("didn't fit"), "The admin was told some of it didn't fit") + +// ===== RENDERS ===== + +/// Not a check: with -DBOUNTY_CHROME_RENDERS, writes the cyberpsycho as spawned and with its blade out, every way it faces +/datum/unit_test/voidcrew_bounty_cyberpsycho/renders + +/datum/unit_test/voidcrew_bounty_cyberpsycho/renders/Run() +#ifdef BOUNTY_CHROME_RENDERS + var/mob/living/carbon/human/hunter = hunter_at(tile(4, 4)) + for(var/datum/species/kind as anything in list(/datum/species/human, /datum/species/lizard, /datum/species/moth)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/cyberpsycho/psycho = spawn_bounty_criminal(psycho_record(kind), tile(2, 2), null) + allocated += psycho + psycho.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/name = "[initial(kind.id)]" + for(var/facing in list(SOUTH, EAST, NORTH, WEST)) + fcopy(getFlatIcon(psycho, facing, no_anim = TRUE), "data/bounty_chrome_renders/cyberpsycho_[name]_[dir2text(facing)].png") + psycho.body_add_grudge(hunter) + psycho.boss_turn_hostile(hunter) + blade_out(psycho, hunter) + for(var/facing in list(SOUTH, EAST, NORTH, WEST)) + fcopy(getFlatIcon(psycho, facing, no_anim = TRUE), "data/bounty_chrome_renders/cyberpsycho_[name]_blade_[dir2text(facing)].png") + qdel(psycho) +#endif diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm index 8bbbc927a63..b191be83929 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm @@ -10,7 +10,7 @@ /datum/unit_test/voidcrew_bounty_identity_records/Run() 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/kits = list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy", "cyberpsycho") // BOUNTY_KIT_* var/list/labels = bounty_feature_labels() // BOUNTY_TIER_*, BOUNTY_ARCHETYPE_*, BOUNTY_PLACEMENT_* for(var/tier in list(1, 2, 3)) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_pace.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_pace.dm new file mode 100644 index 00000000000..fbf89637f7c --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_pace.dm @@ -0,0 +1,183 @@ +/** + * Bounty hunting: a fighter's pace and its guns' reach (C4), for voidcrew/modules/bounties/bounty_ai.dm + * (bounty_ai_step(), the AI's walk) and bounty_styles.dm (the side-step, the back-off, the fire range). + * Criminals and companions are real human bodies that walk and run at a person's pace; the steps the AI + * takes by hand (out of a friend's line of fire, back from someone too close) come no sooner than a step + * of the body's own, and hold the AI's walk back as long. A gun fires at anyone it sees within 7 tiles + * while walking in to 5; the shotgun fires from as close as it walks in. + * + * The tests drive the behaviours directly, with the gun tests' helpers (voidcrew_bounty_guns.dm). Fork + * defines are included after the tests, so a test uses the literal value with a comment naming the define. + */ + +/// The pace tests, in the bounty AI tests' room, with the gun tests' helpers +/datum/unit_test/voidcrew_bounty_pace + parent_type = /datum/unit_test/voidcrew_bounty_guns + abstract_type = /datum/unit_test/voidcrew_bounty_pace + +/// `mover`'s own delay for a step in `direction`: what a player's step costs, longer on a diagonal +/datum/unit_test/voidcrew_bounty_pace/proc/step_delay(mob/living/mover, direction) + var/delay = max(mover.cached_multiplicative_slowdown, world.tick_lag) + return ISDIAGONALDIR(direction) ? delay * sqrt(2) : delay + +/** + * A gunman steps out of a friend's line of fire at a person's pace. The shooting runs ten times a second; + * a second step the same tick, or before the body's own move delay is up, is refused, and once the delay + * is up it steps again. + */ +/datum/unit_test/voidcrew_bounty_pace/sidestep + +/datum/unit_test/voidcrew_bounty_pace/sidestep/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunman = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 2), "pistol") // BOUNTY_STYLE_PISTOL + gunman.ai_controller.set_ai_status(AI_STATUS_OFF) + var/mob/living/carbon/human/target = make_target(gunman, tile(4, 2)) + draw_gun(gunman) + var/datum/ai_controller/controller = gunman.ai_controller + // A friend of theirs in the way + var/list/gang = gunman.spawn_companions(1, TRUE, list(list("style" = "brawler"))) // BOUNTY_COMPANY_STYLE, BOUNTY_STYLE_BRAWLER + TEST_ASSERT(length(gang), "Test fixture: no companion") + allocated += gang + var/mob/living/carbon/human/npc/bounty_companion/friend = gang[1] + friend.ai_controller.set_ai_status(AI_STATUS_OFF) + friend.forceMove(tile(2, 2)) + TEST_ASSERT(bounty_ai_line_blocked(gunman, target), "Test fixture: the friend isn't in the gunman's line of fire") + TEST_ASSERT(bounty_ai_step_ready(gunman), "Test fixture: the gunman can't step yet") + + // The first step aside comes at once + var/turf/start = get_turf(gunman) + shoot_step(gunman) + var/turf/first_step = get_turf(gunman) + TEST_ASSERT(first_step != start, "The gunman didn't step out of the friend's line of fire") + var/delay = step_delay(gunman, get_dir(start, first_step)) + TEST_ASSERT(controller.blackboard["bb_bounty_next_step_at"] >= world.time + delay - 0.01, "The gunman's next step by hand isn't a step's time away") // BB_BOUNTY_NEXT_STEP_AT + TEST_ASSERT(!bounty_ai_step_ready(gunman), "Right after a step, the gunman may step again") + + // The friend in the way again, the same tick: no second step + var/list/new_line = get_line(first_step, get_turf(target)) + TEST_ASSERT(length(new_line) >= 3, "Test fixture: the gunman stepped next to the hunter") + friend.forceMove(new_line[2]) + TEST_ASSERT(bounty_ai_line_blocked(gunman, target), "Test fixture: the friend isn't in the gunman's new line of fire") + for(var/i in 1 to 3) + shoot_step(gunman) + TEST_ASSERT_EQUAL(get_turf(gunman), first_step, "The gunman stepped twice in less than a step's time") + // The back-off waits for the body too + var/backstep_at = controller.blackboard["bb_bounty_backstep_at"] // BB_BOUNTY_BACKSTEP_AT + TEST_ASSERT(!bounty_ai_back_off(controller, gunman, target), "The gunman backed off in less than a step's time") + TEST_ASSERT_EQUAL(controller.blackboard["bb_bounty_backstep_at"], backstep_at, "A back-off refused for its pace still used up its turn") + + // Once a step's time is up, it steps aside again + controller.set_blackboard_key("bb_bounty_next_step_at", world.time) // BB_BOUNTY_NEXT_STEP_AT + shoot_step(gunman) + TEST_ASSERT(get_turf(gunman) != first_step, "Once a step's time was up, the gunman didn't step aside again") + shoot_stopped(gunman) + target.fully_heal(HEAL_ALL) + +/** + * The AI's walk and the steps by hand share the body's pace: a step of the walk holds the next step by + * hand back by the body's move delay, and a step by hand holds the walk back as long, so the two never + * add up to two steps in a step's time. A step that isn't paced (the meek's step onto a potted plant's + * tile) goes as before. + */ +/datum/unit_test/voidcrew_bounty_pace/walk + +/datum/unit_test/voidcrew_bounty_pace/walk/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/walker = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 1), "brawler") // BOUNTY_STYLE_BRAWLER + var/datum/ai_controller/controller = walker.ai_controller + controller.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(istype(controller.ai_movement, /datum/ai_movement/jps/bounty), "Test fixture: the criminal doesn't walk with the bounty movement") + + // A step of the walk: its next step by hand waits + var/datum/move_loop/fake_step = new /datum/move_loop(null, null, walker, 0, 0, controller) + walker.Move(tile(2, 1), EAST) + TEST_ASSERT_EQUAL(get_turf(walker), tile(2, 1), "Test fixture: the walker didn't step") + controller.ai_movement.post_move(fake_step, 1) // MOVELOOP_SUCCESS + qdel(fake_step) + TEST_ASSERT(!bounty_ai_step_ready(walker), "Right after a step of its walk, the criminal may step by hand") + TEST_ASSERT(controller.blackboard["bb_bounty_next_step_at"] >= world.time + step_delay(walker, EAST) - 0.01, "A step of the walk doesn't hold the next step by hand a step's time") // BB_BOUNTY_NEXT_STEP_AT + TEST_ASSERT(!bounty_ai_step(walker, tile(3, 1), paced = TRUE), "A paced step went right after a step of the walk") + TEST_ASSERT_EQUAL(get_turf(walker), tile(2, 1), "The refused step moved the criminal") + // An unpaced step goes, as it always did + TEST_ASSERT(bounty_ai_step(walker, tile(3, 1)), "An unpaced step was refused") + + // A step by hand holds the walk back + controller.set_blackboard_key("bb_bounty_next_step_at", world.time) // BB_BOUNTY_NEXT_STEP_AT + GLOB.move_manager.move(walker, NORTH, 1, 5 SECONDS, SSai_movement) + var/datum/move_loop/walk = GLOB.move_manager.processing_on(walker, SSai_movement) + TEST_ASSERT_NOTNULL(walk, "Test fixture: no walk on the AI's movement") + TEST_ASSERT(walk.timer < world.time + step_delay(walker, NORTH), "Test fixture: the walk's next step is already a step's time off") + TEST_ASSERT(bounty_ai_step(walker, tile(3, 2), paced = TRUE), "A paced step with the time up was refused") + var/held_for = walk.timer - world.time + GLOB.move_manager.stop_looping(walker, SSai_movement) + TEST_ASSERT(held_for >= step_delay(walker, NORTH) - 0.01, "After a step by hand, the walk's next step is only [held_for] away") + +/** + * A gun fires at anyone it can see within 7 tiles (BOUNTY_GUN_FIRE_RANGE) while it walks in to 5 + * (BOUNTY_PISTOL_RANGE), and never further; the shotgun fires only from as close as it walks in to + * (BOUNTY_SHOTGUN_RANGE), and the bottle thrower throws from its own distance. + */ +/datum/unit_test/voidcrew_bounty_pace/gun_range + var/datum/turf_reservation/range + +/datum/unit_test/voidcrew_bounty_pace/gun_range/Destroy() + QDEL_LIST(allocated) + QDEL_NULL(range) + return ..() + +/datum/unit_test/voidcrew_bounty_pace/gun_range/Run() + var/datum/ai_behavior/bounty_shoot/shooting = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_shoot) + TEST_ASSERT_EQUAL(shooting.fire_range, 7, "Guns don't fire out to 7 tiles") + TEST_ASSERT_EQUAL(shooting.required_distance, 5, "Guns don't walk in to 5 tiles") + var/datum/ai_behavior/bounty_shoot/close/shotgun_range = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_shoot/close) + TEST_ASSERT_EQUAL(shotgun_range.fire_range, shotgun_range.required_distance, "The shotgun fires from further off than it walks in to") + var/datum/ai_behavior/bounty_shoot/throw/bottle_range = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_shoot/throw) + TEST_ASSERT_EQUAL(bottle_range.fire_range, bottle_range.required_distance, "Bottles fly from further off than the thrower keeps") + + // A corridor long enough to shoot down + range = SSmapping.request_turf_block_reservation(12, 3, 1, null, /datum/turf_reservation, /turf/open/floor/iron) + TEST_ASSERT_NOTNULL(range, "Could not reserve a corridor") + var/turf/anchor = range.bottom_left_turfs[1] + var/area/testroom = GLOB.areas_by_type[/area/misc/testroom] + for(var/dx in 0 to 11) + for(var/dy in 0 to 2) + var/turf/tile = locate(anchor.x + dx, anchor.y + dy, anchor.z) + tile.change_area(tile.loc, testroom) + + // The pistol: a shot at 7 tiles, none at 8 + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunman = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, locate(anchor.x, anchor.y + 1, anchor.z), "pistol") // BOUNTY_STYLE_PISTOL + gunman.ai_controller.set_ai_status(AI_STATUS_OFF) + var/mob/living/carbon/human/target = make_target(gunman, locate(anchor.x + 7, anchor.y + 1, anchor.z)) + var/obj/item/gun/ballistic/stechkin = draw_gun(gunman) + var/datum/ai_controller/controller = gunman.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 + var/rounds = bounty_gun_live_rounds(stechkin) + shoot_step(gunman) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), rounds - 1, "The pistol didn't fire at someone 7 tiles off") + next_pull(gunman, target) + target.forceMove(locate(anchor.x + 8, anchor.y + 1, anchor.z)) + shoot_step(gunman) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), rounds - 1, "The pistol fired at someone 8 tiles off") + shoot_stopped(gunman) + + // The shotgun: nothing at 3 tiles, a blast at 2 + var/mob/living/carbon/human/npc/bounty_criminal/normal/blaster = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, locate(anchor.x, anchor.y + 2, anchor.z), "shotgun") // BOUNTY_STYLE_SHOTGUN + blaster.ai_controller.set_ai_status(AI_STATUS_OFF) + var/mob/living/carbon/human/mark = make_target(blaster, locate(anchor.x + 3, anchor.y + 2, anchor.z)) + var/obj/item/gun/ballistic/shotgun = draw_gun(blaster) + var/datum/ai_controller/shotgun_ai = blaster.ai_controller + var/shells = bounty_gun_live_rounds(shotgun) + for(var/i in 1 to 2) + shotgun_ai.set_blackboard_key("bb_bounty_next_shot", world.time) // BB_BOUNTY_NEXT_SHOT + shotgun_ai.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + shoot_step(blaster) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(shotgun), shells, "The shotgun fired at someone 3 tiles off") + mark.forceMove(locate(anchor.x + 2, anchor.y + 2, anchor.z)) + bounty_ai_clear_windup(shotgun_ai) + shotgun_ai.set_blackboard_key("bb_bounty_next_shot", world.time) // BB_BOUNTY_NEXT_SHOT + shoot_step(blaster) + shotgun_ai.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL: the pump done + shoot_step(blaster) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(shotgun), shells - 1, "The shotgun didn't fire at someone 2 tiles off") + shoot_stopped(blaster) + target.fully_heal(HEAL_ALL) + mark.fully_heal(HEAL_ALL) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm index f2aeb4bdc3c..7fa9c5017c1 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm @@ -43,6 +43,10 @@ /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 +/// Whether a mini-boss kit's `item` is in the armoured class: armoured, or energy armour of 30 or more (the Heavy's ablative coat and hood, C8) +/datum/unit_test/voidcrew_bounty_suits/proc/kit_armoured(obj/item/item) + return armoured(item) || (!isnull(item) && item.get_armor_rating(ENERGY) >= 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 @@ -54,6 +58,35 @@ 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") +/** + * Checks `npc` wears a running MODsuit of `suit_type` on its back, every piece deployed and sealed, and + * that none of it can become loot: the control unit, its pieces, core, cell and modules are locked to it + * and hidden from the strip menu, and what its storage holds is locked or a consumable it can reach. + */ +/datum/unit_test/voidcrew_bounty_suits/proc/check_modsuit(mob/living/carbon/human/npc/npc, suit_type, label) + var/obj/item/mod/control/suit = npc.back + TEST_ASSERT(istype(suit, suit_type), "[label] wears [suit?.type] on its back, not its MODsuit [suit_type]") + TEST_ASSERT(suit.active, "[label]'s MODsuit isn't running") + TEST_ASSERT(suit.get_charge() > 0, "[label]'s MODsuit has no charge") + TEST_ASSERT_EQUAL(suit.wearer, npc, "[label]'s MODsuit doesn't know its wearer") + for(var/obj/item/part as anything in suit.get_parts()) + TEST_ASSERT_EQUAL(part.loc, npc, "[label]'s [part] isn't deployed") + var/datum/mod_part/part_datum = suit.get_part_datum(part) + TEST_ASSERT(part_datum?.sealed, "[label]'s [part] isn't sealed") + TEST_ASSERT(istype(npc.wear_suit, /obj/item/clothing/suit/mod) && istype(npc.head, /obj/item/clothing/head/mod), "[label] isn't sealed in its MODsuit's chestplate and helmet") + var/list/pieces = suit.get_parts(all = TRUE) + suit.modules + suit.core + var/obj/item/mod/core/standard/core = suit.core + TEST_ASSERT(istype(core) && istype(core.cell, /obj/item/stock_parts/power_store/cell), "[label]'s MODsuit has no cell in its core") + pieces += core.cell + for(var/obj/item/piece as anything in pieces) + TEST_ASSERT(human_npc_gear_locked(piece), "[label]'s [piece] isn't locked to it") + TEST_ASSERT(HAS_TRAIT(piece, TRAIT_NO_STRIP), "[label]'s [piece] shows in the strip menu") + var/obj/item/mod/module/storage/pouch = locate() in suit.modules + TEST_ASSERT_NOTNULL(pouch, "[label]'s MODsuit has no storage") + for(var/obj/item/carried in pouch.contents) + TEST_ASSERT(human_npc_gear_locked(carried) || human_npc_gear_consumable(carried), "[label]'s [carried] in its MODsuit isn't locked or issued to it") + TEST_ASSERT(human_npc_can_draw(npc, carried), "[label] can't take its [carried] out of its MODsuit") + // ===== 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 @@ -91,26 +124,122 @@ 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 +/** + * Each mini-boss kit seals up in a running MODsuit of its own theme, of its own armour class: what protects + * it in good air protects it in vacuum about as well. What its bag holds rides in the suit's storage, where + * it reaches it, and none of the suit can be stripped or looted. + */ /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/list/suit_types = list( + "juggernaut" = /obj/item/mod/control/pre_equipped/bounty_boss/security, + "pyromaniac" = /obj/item/mod/control/pre_equipped/bounty_boss/atmospheric, + "demolitionist" = /obj/item/mod/control/pre_equipped/bounty_boss/engineering, + "ghost" = /obj/item/mod/control/pre_equipped/bounty_boss/civilian, + "heavy" = /obj/item/mod/control/pre_equipped/bounty_boss/magnate, + ) + for(var/kit in suit_types) // 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") + TEST_ASSERT_EQUAL(kit_armoured(in_vacuum.wear_suit), kit_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(kit_armoured(in_vacuum.head), kit_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 MODsuit 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") + TEST_ASSERT(length(gear) == 1 && gear[1] == suit_types[kit], "The [kit] was given [jointext(gear, ", ")] for vacuum") + check_modsuit(in_vacuum, suit_types[kit], "The [kit] at a space ruin") + // Everything its bag holds in good air, it carries in vacuum too + var/obj/item/bag = in_air.back + TEST_ASSERT(bag?.atom_storage, "Test fixture: the [kit] carries no bag in good air") + for(var/obj/item/packed as anything in bag.get_all_contents_type(/obj/item)) + if(packed == bag) + continue + TEST_ASSERT(length(in_vacuum.get_all_contents_type(packed.type)) >= length(bag.get_all_contents_type(packed.type)), "The [kit] left its [packed] behind for vacuum") + TEST_ASSERT_EQUAL(exact_count(in_vacuum, /obj/item/reagent_containers/hypospray/medipen/stimpack/traitor), 1, "The [kit] doesn't carry its combat stimpack in vacuum") // BOUNTY_BOSS_COMBAT_STIMULANT + // Paused while it is dormant, so its core doesn't run flat before anyone comes, and running again when it wakes + var/obj/item/mod/control/suit = in_vacuum.back + in_vacuum.npc_set_suit_heating(FALSE) + TEST_ASSERT(!(suit.datum_flags & DF_ISPROCESSING), "The [kit]'s MODsuit runs while it is dormant") + in_vacuum.npc_set_suit_heating(TRUE) + TEST_ASSERT(suit.datum_flags & DF_ISPROCESSING, "The [kit]'s MODsuit didn't start again when it woke") if(kit == "heavy") - TEST_ASSERT(istype(in_vacuum.head, /obj/item/clothing/head/helmet/swat), "The Heavy lost its SWAT helmet in vacuum") + // Its ablative coat and hood hold no pressure, and nothing goes over a MODsuit: out there it has the magnate suit's energy armour (C8) + TEST_ASSERT(istype(in_air.head, /obj/item/clothing/head/hooded/ablative), "The Heavy's ablative hood isn't up in good air") + TEST_ASSERT(in_vacuum.wear_suit.get_armor_rating(ENERGY) >= in_air.wear_suit.get_armor_rating(ENERGY), "The Heavy's MODsuit has less energy armour than its coat") + if(kit == "pyromaniac") + // Its gas mask and ID stay on under the suit, and its spare tanks are where it changes them from + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = in_vacuum + TEST_ASSERT(istype(pyro.wear_mask, /obj/item/clothing/mask/gas), "The Pyromaniac took its gas mask off for its MODsuit") + TEST_ASSERT(istype(pyro.wear_id, /obj/item/card/id), "The Pyromaniac has no ID in its MODsuit") + TEST_ASSERT(pyro.wear_suit.resistance_flags & FIRE_PROOF, "The Pyromaniac's MODsuit isn't fireproof") + TEST_ASSERT_NOTNULL(pyro.boss_spare_tank(), "The Pyromaniac can't reach a spare tank in its MODsuit") qdel(in_air) qdel(in_vacuum) +/// How many of exactly `item_type` (not its subtypes) `holder` carries +/datum/unit_test/voidcrew_bounty_suits/proc/exact_count(mob/living/holder, item_type) + . = 0 + for(var/obj/item/thing as anything in holder.get_all_contents_type(item_type)) + if(thing.type == item_type) + .++ + +/** + * A mini-boss's MODsuit never becomes loot: a core, cell or module forced out of it (the only way one + * leaves it on a body nobody can open) is gone by the next tick, and what spills from its storage is + * gone too, a consumable once it is in anyone's hands. A hunter suiting up a cuffed boss takes the whole + * MODsuit off with its helmet or chestplate, and it is gone, the gloves and boots it covered going back on. + */ +/datum/unit_test/voidcrew_bounty_suits/modsuit_loot + +/datum/unit_test/voidcrew_bounty_suits/modsuit_loot/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = new_criminal("boss", 3, "juggernaut", /obj/structure/overmap/space_ruin) // BOUNTY_TIER_MOST_WANTED, BOUNTY_KIT_JUGGERNAUT + TEST_ASSERT_NOTNULL(boss, "No Juggernaut was made") + var/obj/item/mod/control/suit = boss.back + TEST_ASSERT(istype(suit), "Test fixture: the Juggernaut wears no MODsuit") + var/turf/floor = get_turf(boss) + var/obj/item/mod/core/standard/core = suit.core + var/obj/item/cell = core.cell + var/obj/item/mod/module/storage/pouch = locate() in suit.modules + var/list/spilled = pouch.contents.Copy() + for(var/obj/item/piece as anything in list(cell, core, pouch)) + piece.forceMove(floor) + human_npc_gear_settle(piece) + TEST_ASSERT(QDELETED(piece), "A [piece] taken out of the Juggernaut's MODsuit is still about") + var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, get_step(floor, EAST)) + for(var/obj/item/thing as anything in spilled) + if(QDELETED(thing)) + continue + if(isturf(thing.loc) && human_npc_gear_consumable(thing)) + hunter.put_in_active_hand(thing) + human_npc_gear_settle(thing) + TEST_ASSERT(QDELETED(thing), "The [thing] from the Juggernaut's MODsuit storage became loot") + qdel(boss) + + // Suiting up a cuffed boss: its MODsuit comes off whole and is gone + boss = new_criminal("boss", 3, "juggernaut", /obj/structure/overmap/space_ruin) + suit = boss.back + var/list/parts = suit.get_parts(all = TRUE) + var/obj/item/chestplate = boss.wear_suit + TEST_ASSERT(chestplate in parts, "Test fixture: the Juggernaut's chestplate isn't its MODsuit's") + var/obj/item/clothing/suit/space/hunter_suit = allocate(/obj/item/clothing/suit/space) + hunter.put_in_active_hand(hunter_suit) + TEST_ASSERT_EQUAL(boss.suits_garment_offered(hunter, chestplate), hunter_suit, "A space suit in hand wasn't offered for the MODsuit's chestplate") + TEST_ASSERT(!boss.suits_swap_now(hunter, chestplate, hunter_suit), "A space suit went on a free boss") + TEST_ASSERT_EQUAL(boss.back, suit, "A free boss lost its MODsuit") + board_test_cuff(boss) + TEST_ASSERT(boss.suits_swap_now(hunter, chestplate, hunter_suit), "A space suit wouldn't go on a cuffed boss in a MODsuit") + TEST_ASSERT_EQUAL(boss.wear_suit, hunter_suit, "The hunter's suit isn't on the boss") + for(var/obj/item/part as anything in parts) + TEST_ASSERT(QDELETED(part), "The boss's [part] is still about after its MODsuit came off") + TEST_ASSERT_NULL(boss.back, "The boss still wears [boss.back] on its back") + TEST_ASSERT_NULL(boss.head, "The boss still wears [boss.head] after its MODsuit came off") + TEST_ASSERT(istype(boss.gloves, /obj/item/clothing/gloves/combat) && human_npc_gear_locked(boss.gloves), "The Juggernaut's own gloves didn't go back on") + TEST_ASSERT(istype(boss.shoes, /obj/item/clothing/shoes/jackboots) && human_npc_gear_locked(boss.shoes), "The Juggernaut's own boots didn't go back on") + TEST_ASSERT(!human_npc_gear_locked(hunter_suit), "The hunter's suit was locked to the boss") + // ===== SUITING UP A CATCH ===== /** diff --git a/voidcrew/modules/unit_tests/voidcrew_buyback_barnaby.dm b/voidcrew/modules/unit_tests/voidcrew_buyback_barnaby.dm new file mode 100644 index 00000000000..ce24c548ba5 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_buyback_barnaby.dm @@ -0,0 +1,123 @@ +/// Halcyon's ledgers (Barnaby, Fern, Pike, Roux): rare goods hit their own +/// entry and never the catch-all, and commons never hit a rare entry. +/datum/unit_test/voidcrew_buyback_halcyon + abstract_type = /datum/unit_test/voidcrew_buyback_halcyon + +/// Fern: prize plants clear a potency bar; under it they go to the farm stand. +/datum/unit_test/voidcrew_buyback_halcyon/fern/Run() + var/datum/shop_buyback/potting/produce/stand = allocate(/datum/shop_buyback/potting/produce) + var/datum/shop_buyback/potting/prize/omega_weed/omega = allocate(/datum/shop_buyback/potting/prize/omega_weed) + var/datum/shop_buyback/potting/prize/holymelon/melon_entry = allocate(/datum/shop_buyback/potting/prize/holymelon) + + var/obj/item/food/grown/cannabis/ultimate/weed = allocate(/obj/item/food/grown/cannabis/ultimate) + TEST_ASSERT_NOTNULL(weed.seed, "Omega weed spawned without a seed") + weed.seed.potency = 60 + TEST_ASSERT(omega.matches(weed), "Fern refused strong omega weed") + TEST_ASSERT(!stand.matches(weed), "Strong omega weed also sold at the farm stand") + weed.seed.potency = 20 + TEST_ASSERT(!omega.matches(weed), "Fern paid vouchers for weak omega weed") + TEST_ASSERT(stand.matches(weed), "Weak omega weed sells nowhere") + + var/obj/item/food/grown/holymelon/melon = allocate(/obj/item/food/grown/holymelon) + melon.seed.potency = 40 + TEST_ASSERT(melon_entry.matches(melon), "Fern refused a good holy melon") + TEST_ASSERT(!stand.matches(melon), "A good holy melon also sold at the farm stand") + + var/obj/item/food/grown/tomato/tomato = allocate(/obj/item/food/grown/tomato) + tomato.seed.potency = 100 + TEST_ASSERT(stand.matches(tomato), "The farm stand refused a tomato") + TEST_ASSERT(!claimed_by_buyback_family(tomato, /datum/shop_buyback/potting/prize), "A plain tomato hit a prize entry") + +/// Pike and Barnaby split the fish: trophies to Pike, everything else to the pot. +/datum/unit_test/voidcrew_buyback_halcyon/fish/Run() + var/datum/shop_buyback/general/fresh_catch/pot = allocate(/datum/shop_buyback/general/fresh_catch) + var/datum/shop_buyback/bait/nessie/nessie_entry = allocate(/datum/shop_buyback/bait/nessie) + var/datum/shop_buyback/bait/moonfish/moon_entry = allocate(/datum/shop_buyback/bait/moonfish) + var/datum/shop_buyback/bait/pike/pike_entry = allocate(/datum/shop_buyback/bait/pike) + var/datum/shop_buyback/bait/armored_pike/armored_entry = allocate(/datum/shop_buyback/bait/armored_pike) + + var/obj/item/fish/fryish/nessie/nessie = allocate(/obj/item/fish/fryish/nessie) + TEST_ASSERT(nessie_entry.matches(nessie), "Pike refused a nessie-fish") + TEST_ASSERT(!pot.matches(nessie), "A nessie-fish went in Barnaby's chowder") + + var/obj/item/fish/moonfish/moonfish = allocate(/obj/item/fish/moonfish) + var/obj/item/fish/moonfish/dwarf/dwarf = allocate(/obj/item/fish/moonfish/dwarf) + TEST_ASSERT(moon_entry.matches(moonfish), "Pike refused a moonfish") + TEST_ASSERT(!pot.matches(moonfish), "A moonfish went in Barnaby's chowder") + TEST_ASSERT(!moon_entry.matches(dwarf), "Pike took a dwarf moonfish as a trophy") + TEST_ASSERT(pot.matches(dwarf), "A dwarf moonfish sells nowhere") + + var/obj/item/fish/pike/armored/armored = allocate(/obj/item/fish/pike/armored) + TEST_ASSERT(armored_entry.matches(armored), "Pike refused an armored pike") + TEST_ASSERT(!pike_entry.matches(armored), "An armored pike also sold as a plain pike") + TEST_ASSERT(!pot.matches(armored), "An armored pike went in Barnaby's chowder") + + var/obj/item/fish/goldfish/goldfish = allocate(/obj/item/fish/goldfish) + TEST_ASSERT(pot.matches(goldfish), "Barnaby refused a goldfish") + TEST_ASSERT(!claimed_by_buyback_family(goldfish, /datum/shop_buyback/bait), "A goldfish hit a trophy entry") + +/// Roux: specials leave the catch-alls, and only real cooking counts. +/datum/unit_test/voidcrew_buyback_halcyon/diner/Run() + var/datum/shop_buyback/diner/home_cooking/wheel = allocate(/datum/shop_buyback/diner/home_cooking) + var/datum/shop_buyback/diner/whole_cake/cakes = allocate(/datum/shop_buyback/diner/whole_cake) + var/datum/shop_buyback/diner/donk_recall/recall = allocate(/datum/shop_buyback/diner/donk_recall) + var/datum/shop_buyback/diner/special/stuffed_legion/legion_entry = allocate(/datum/shop_buyback/diner/special/stuffed_legion) + var/datum/shop_buyback/diner/special/energy_cake/cake_entry = allocate(/datum/shop_buyback/diner/special/energy_cake) + var/datum/shop_buyback/diner/special/gondola_pocket/gondola_entry = allocate(/datum/shop_buyback/diner/special/gondola_pocket) + + var/obj/item/food/stuffedlegion/legion = allocate(/obj/item/food/stuffedlegion) + TEST_ASSERT(!legion_entry.matches(legion), "Roux paid for a stuffed legion nobody cooked") + ADD_TRAIT(legion, TRAIT_FOOD_CHEF_MADE, "unit_test") + TEST_ASSERT(legion_entry.matches(legion), "Roux refused a cooked stuffed legion") + TEST_ASSERT(!wheel.matches(legion), "A stuffed legion also sold as a home-cooked meal") + + var/obj/item/food/cake/birthday/energy/energy_cake = allocate(/obj/item/food/cake/birthday/energy) + ADD_TRAIT(energy_cake, TRAIT_FOOD_CHEF_MADE, "unit_test") + TEST_ASSERT(cake_entry.matches(energy_cake), "Roux refused an energy cake") + TEST_ASSERT(!cakes.matches(energy_cake), "An energy cake also sold as a plain whole cake") + + var/obj/item/food/donkpocket/warm/gondola/gondola = allocate(/obj/item/food/donkpocket/warm/gondola) + ADD_TRAIT(gondola, TRAIT_FOOD_CHEF_MADE, "unit_test") + TEST_ASSERT(gondola_entry.matches(gondola), "Roux refused a warm gondola pocket") + TEST_ASSERT(!recall.matches(gondola), "A gondola pocket also sold as a recalled donk-pocket") + + var/obj/item/food/burger/plain/burger = allocate(/obj/item/food/burger/plain) + ADD_TRAIT(burger, TRAIT_FOOD_CHEF_MADE, "unit_test") + TEST_ASSERT(wheel.matches(burger), "Roux refused a home-cooked burger") + TEST_ASSERT(!claimed_by_buyback_family(burger, /datum/shop_buyback/diner/special), "A plain burger hit a special") + +/// The convoy refills credit entries but never a voucher entry, at every trader. +/datum/unit_test/voidcrew_buyback_halcyon/voucher_demand/Run() + var/list/shop_types = list( + /datum/outpost_shop/black_market, + /datum/outpost_shop/vendor/dregs_bar, + /datum/outpost_shop/vendor/patchup_clinic, + /datum/outpost_shop/vendor/ripperdoc, + /datum/outpost_shop/general, + /datum/outpost_shop/vendor/potting_shed, + /datum/outpost_shop/vendor/bait_shop, + /datum/outpost_shop/vendor/diner, + /datum/outpost_shop/outfitter, + /datum/outpost_shop/vendor/skunkworks, + /datum/outpost_shop/vendor/suit_fitter, + ) + var/voucher_rows = 0 + for(var/shop_type in shop_types) + var/datum/outpost_shop/shop = allocate(shop_type) + var/list/rolled = list() + var/datum/shop_buyback/credit_entry + for(var/datum/shop_buyback/buyback as anything in shop.buybacks) + if(buyback.pay_vouchers > 0) + buyback.demand = max(0, buyback.demand - 1) + rolled[buyback] = buyback.demand + voucher_rows++ + else + credit_entry ||= buyback + if(credit_entry) + credit_entry.demand = 0 + shop.convoy_restock() + for(var/datum/shop_buyback/buyback as anything in rolled) + TEST_ASSERT_EQUAL(buyback.demand, rolled[buyback], "A convoy refilled [buyback.type] at [shop_type]") + if(credit_entry) + TEST_ASSERT(credit_entry.demand > 0, "A convoy stopped refilling credit buybacks at [shop_type]") + TEST_ASSERT(voucher_rows > 0, "No trader has a voucher buyback") diff --git a/voidcrew/modules/unit_tests/voidcrew_buyback_depot.dm b/voidcrew/modules/unit_tests/voidcrew_buyback_depot.dm new file mode 100644 index 00000000000..8c62ee67e36 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_buyback_depot.dm @@ -0,0 +1,162 @@ +// Quartermain Depot buybacks: rare goods reach their own rows and nothing else, +// commons stay on the plain rows. Fork defines compile after tests, so prices +// and colours are never read here, only which row matches what. + +/datum/unit_test/voidcrew_buyback_depot + abstract_type = /datum/unit_test/voidcrew_buyback_depot + +/// A seller to carry the goods: matching only takes loose, carried items. +/datum/unit_test/voidcrew_buyback_depot/proc/seller() + return allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + +/datum/unit_test/voidcrew_buyback_depot/sarge/Run() + var/mob/living/carbon/human/user = seller() + var/datum/shop_buyback/salvage = allocate(/datum/shop_buyback/outfitter/salvage_armor) + var/datum/shop_buyback/officer = allocate(/datum/shop_buyback/outfitter/listed/officer_armor) + var/datum/shop_buyback/military = allocate(/datum/shop_buyback/outfitter/listed/military_armor) + var/datum/shop_buyback/service = allocate(/datum/shop_buyback/outfitter/listed/service_arms) + var/datum/shop_buyback/heavy = allocate(/datum/shop_buyback/outfitter/listed/heavy_arms) + var/datum/shop_buyback/arms = allocate(/datum/shop_buyback/outfitter/listed/military_arms) + var/datum/shop_buyback/pieces = allocate(/datum/shop_buyback/outfitter/listed/collector_pieces) + + var/obj/item/marine = allocate(/obj/item/clothing/suit/armor/vest/marine, user) + TEST_ASSERT(military.matches(marine), "Military armor refused a marine vest") + TEST_ASSERT(!salvage.matches(marine), "Plain salvage also bought a marine vest") + TEST_ASSERT(!officer.matches(marine), "Officer's armor bought a marine vest") + + var/obj/item/plain_vest = allocate(/obj/item/clothing/suit/armor/vest, user) + TEST_ASSERT(salvage.matches(plain_vest), "Plain salvage refused a plain vest") + TEST_ASSERT(!military.matches(plain_vest), "Military armor bought a plain vest") + TEST_ASSERT(!officer.matches(plain_vest), "Officer's armor bought a plain vest") + + var/obj/item/hos_coat = allocate(/obj/item/clothing/suit/armor/hos, user) + TEST_ASSERT(officer.matches(hos_coat), "Officer's armor refused a commander's coat") + TEST_ASSERT(!salvage.matches(hos_coat), "Plain salvage also bought a commander's coat") + + // The ship's own kit sells as salvage only + var/obj/item/issued = allocate(/obj/item/clothing/suit/armor/vest/marine, user) + issued.buyback_hull_issue = TRUE + TEST_ASSERT(!military.matches(issued), "Military armor bought a hull's own marine vest") + TEST_ASSERT(salvage.matches(issued), "Plain salvage refused a hull's own marine vest") + + var/obj/item/saw = allocate(/obj/item/gun/ballistic/automatic/l6_saw/unrestricted, user) + TEST_ASSERT(arms.matches(saw), "Military arms refused an L6 SAW") + TEST_ASSERT(!heavy.matches(saw) && !service.matches(saw), "A cheaper row also bought an L6 SAW") + + var/obj/item/toy_saw = allocate(/obj/item/gun/ballistic/automatic/l6_saw/toy/unrestricted/riot, user) + TEST_ASSERT(!arms.matches(toy_saw), "Military arms bought a foam SAW") + + var/obj/item/laser = allocate(/obj/item/gun/energy/laser, user) + TEST_ASSERT(service.matches(laser), "Service arms refused a laser gun") + TEST_ASSERT(!heavy.matches(laser) && !arms.matches(laser) && !pieces.matches(laser), "A rare row bought a plain laser gun") + mark_trader_goods(laser) + TEST_ASSERT(!service.matches(laser), "Service arms bought back a shop laser") + + var/obj/item/practice = allocate(/obj/item/gun/energy/laser/practice, user) + TEST_ASSERT(!service.matches(practice), "Service arms bought a practice laser") + + var/obj/item/club = allocate(/obj/item/melee/cleaving_saw, user) + TEST_ASSERT(pieces.matches(club), "One-of-a-kind pieces refused the cleaving saw") + +/datum/unit_test/voidcrew_buyback_depot/boffin/Run() + var/mob/living/carbon/human/user = seller() + var/datum/shop_buyback/grey_row = allocate(/datum/shop_buyback/skunk/slime_extract) + var/datum/shop_buyback/rare_row = allocate(/datum/shop_buyback/skunk/slime_extract/rare) + var/datum/shop_buyback/rainbow_row = allocate(/datum/shop_buyback/skunk/slime_extract/rainbow) + var/datum/shop_buyback/cross_row = allocate(/datum/shop_buyback/skunk/crossbred) + var/datum/shop_buyback/rare_cross_row = allocate(/datum/shop_buyback/skunk/crossbred/rare) + + var/obj/item/slime_extract/grey = allocate(/obj/item/slime_extract/grey, user) + TEST_ASSERT(grey_row.matches(grey), "Boffin refused a grey extract") + TEST_ASSERT(!rainbow_row.matches(grey) && !rare_row.matches(grey), "A rare extract row bought a grey extract") + + var/obj/item/slime_extract/rainbow = allocate(/obj/item/slime_extract/rainbow, user) + TEST_ASSERT(rainbow_row.matches(rainbow), "Boffin refused a rainbow extract") + TEST_ASSERT(!grey_row.matches(rainbow) && !rare_row.matches(rainbow), "A cheaper row bought a rainbow extract") + rainbow.extract_uses = 0 + TEST_ASSERT(!rainbow_row.matches(rainbow), "Boffin bought a spent rainbow extract") + + var/obj/item/slimecross/stabilized/rainbow/stable_rainbow = allocate(/obj/item/slimecross/stabilized/rainbow, user) + TEST_ASSERT(rare_cross_row.matches(stable_rainbow), "Boffin refused a stabilized rainbow extract") + TEST_ASSERT(!cross_row.matches(stable_rainbow), "The common crossbreed row bought a rainbow crossbreed") + var/obj/item/slimecross/stabilized/grey/stable_grey = allocate(/obj/item/slimecross/stabilized/grey, user) + TEST_ASSERT(cross_row.matches(stable_grey), "Boffin refused a grey crossbreed") + TEST_ASSERT(!rare_cross_row.matches(stable_grey), "The rare crossbreed row bought a grey crossbreed") + + var/datum/shop_buyback/common_cores = allocate(/datum/shop_buyback/skunk/anomaly_core) + var/datum/shop_buyback/rare_cores = allocate(/datum/shop_buyback/skunk/anomaly_core/rare) + var/datum/shop_buyback/raw_rare = allocate(/datum/shop_buyback/skunk/anomaly_core/raw/rare) + + var/obj/item/vortex = allocate(/obj/item/assembly/signaler/anomaly/vortex, user) + TEST_ASSERT(rare_cores.matches(vortex), "Boffin refused a vortex core") + TEST_ASSERT(!common_cores.matches(vortex) && !raw_rare.matches(vortex), "Another core row bought a refined vortex core") + + var/obj/item/flux = allocate(/obj/item/assembly/signaler/anomaly/flux, user) + TEST_ASSERT(common_cores.matches(flux), "Boffin refused a flux core") + TEST_ASSERT(!rare_cores.matches(flux), "The rare core row bought a flux core") + + var/obj/item/raw_anomaly_core/vortex/raw = allocate(/obj/item/raw_anomaly_core/vortex, user) + TEST_ASSERT(raw_rare.matches(raw), "Boffin refused a raw vortex core") + TEST_ASSERT(!rare_cores.matches(raw), "The refined core row bought a raw core") + + // A core refined from a bought raw core is still shop stock + mark_trader_goods(raw) + var/obj/item/refined = raw.create_core(user) + allocated += refined + TEST_ASSERT(is_trader_good(refined), "Refining a bought raw core washed off the shop's stamp") + TEST_ASSERT(!rare_cores.matches(refined), "Boffin bought back a core refined from his own stock") + + // A core seated in a module stays put + var/obj/item/mod/module/anomaly_locked/antigrav/module = allocate(/obj/item/mod/module/anomaly_locked/antigrav, user) + var/obj/item/assembly/signaler/anomaly/grav/seated = allocate(/obj/item/assembly/signaler/anomaly/grav) + seated.forceMove(module) + module.core = seated + TEST_ASSERT(!common_cores.matches(seated), "Boffin pulled a core out of a module") + var/datum/shop_buyback/anomaly_modules = allocate(/datum/shop_buyback/fitter/anomaly_module) + TEST_ASSERT(anomaly_modules.matches(module), "Wick refused an anti-gravity module with its core") + +/datum/unit_test/voidcrew_buyback_depot/wick/Run() + var/mob/living/carbon/human/user = seller() + var/datum/shop_buyback/scrap = allocate(/datum/shop_buyback/fitter/scrap_control) + var/datum/shop_buyback/armored = allocate(/datum/shop_buyback/fitter/rare_suit/security) + var/datum/shop_buyback/syndicate = allocate(/datum/shop_buyback/fitter/rare_suit/syndicate) + var/datum/shop_buyback/elite = allocate(/datum/shop_buyback/fitter/rare_suit/elite) + + var/obj/item/mod/control/elite_suit = allocate(/obj/item/mod/control/pre_equipped/empty/elite, user) + TEST_ASSERT(elite.matches(elite_suit), "Wick refused an elite suit") + TEST_ASSERT(!scrap.matches(elite_suit), "The scrap row also bought an elite suit") + TEST_ASSERT(!syndicate.matches(elite_suit) && !armored.matches(elite_suit), "Another suit row bought an elite suit") + + var/obj/item/mod/control/civilian = allocate(/obj/item/mod/control/pre_equipped/civilian, user) + TEST_ASSERT(!scrap.matches(civilian), "The scrap row bought a civilian suit") + TEST_ASSERT(!elite.matches(civilian) && !armored.matches(civilian) && !syndicate.matches(civilian), "Another suit row bought a civilian suit") + var/datum/shop_buyback/civilian_row = allocate(/datum/shop_buyback/fitter/rare_suit/civilian) + TEST_ASSERT(civilian_row.matches(civilian), "Wick refused a civilian suit") + TEST_ASSERT(!civilian_row.matches(elite_suit), "The civilian row bought an elite suit") + // Every theme row must list at least one theme, and no theme may sit on two rows + var/list/seen = list() + for(var/row_type in subtypesof(/datum/shop_buyback/fitter/rare_suit)) + var/datum/shop_buyback/fitter/rare_suit/row = allocate(row_type) + TEST_ASSERT(length(row.theme_types), "[row_type] lists no theme") + for(var/theme in row.theme_types) + TEST_ASSERT(!seen[theme], "[theme] is on two of Wick's suit rows") + seen[theme] = TRUE + + // The hull's own elite suit only sells as scrap + var/obj/item/mod/control/issued = allocate(/obj/item/mod/control/pre_equipped/empty/elite, user) + issued.buyback_hull_issue = TRUE + TEST_ASSERT(!elite.matches(issued), "Wick paid vouchers for a hull's own elite suit") + TEST_ASSERT(scrap.matches(issued), "The scrap row refused a hull's own elite suit") + + // A suit built around a shop core is scrap nowhere + var/obj/item/mod/control/syndie = allocate(/obj/item/mod/control/pre_equipped/empty/syndicate, user) + TEST_ASSERT(syndicate.matches(syndie), "Wick refused a syndicate suit") + mark_trader_goods(syndie.core) + TEST_ASSERT(!syndicate.matches(syndie), "Wick paid vouchers for a suit around a shop core") + TEST_ASSERT(!scrap.matches(syndie), "The scrap row bought a suit around a shop core") + + var/datum/shop_buyback/rare_modules = allocate(/datum/shop_buyback/fitter/rare_module) + var/obj/item/magboots = allocate(/obj/item/mod/module/magboot/advanced, user) + TEST_ASSERT(rare_modules.matches(magboots), "Wick refused advanced magboots") + var/obj/item/plain_magboots = allocate(/obj/item/mod/module/magboot, user) + TEST_ASSERT(!rare_modules.matches(plain_magboots), "Wick bought printable magboots as a rare module") diff --git a/voidcrew/modules/unit_tests/voidcrew_buyback_vex.dm b/voidcrew/modules/unit_tests/voidcrew_buyback_vex.dm new file mode 100644 index 00000000000..76cb05b12e1 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_buyback_vex.dm @@ -0,0 +1,116 @@ +// Buyback ledgers for Dram, Sawbones and Splice: each rare good lands on its +// rare line and never on the cheap one, and a common good never reaches the +// rare line. Fork defines compile after tests, so trait names are literals. + +/datum/unit_test/voidcrew_buyback_vex_drinks + +/datum/unit_test/voidcrew_buyback_vex_drinks/proc/pour(drink, amount, filler_amount = 0) + var/obj/item/reagent_containers/cup/glass/drinkingglass/glass = allocate(/obj/item/reagent_containers/cup/glass/drinkingglass) + glass.reagents.add_reagent(drink, amount) + if(filler_amount) + glass.reagents.add_reagent(/datum/reagent/water, filler_amount) + return glass + +/datum/unit_test/voidcrew_buyback_vex_drinks/Run() + var/datum/shop_buyback/juice = allocate(/datum/shop_buyback/dregs/cocktail/the_juice) + var/datum/shop_buyback/coffee = allocate(/datum/shop_buyback/dregs/cocktail/hot_ice_coffee) + var/datum/shop_buyback/house = allocate(/datum/shop_buyback/dregs/cocktail/house) + var/datum/shop_buyback/fancy = allocate(/datum/shop_buyback/dregs/cocktail/fancy) + + var/obj/item/juice_glass = pour(/datum/reagent/consumable/ethanol/the_juice, 50) + TEST_ASSERT(juice.matches(juice_glass), "A full glass of The Juice missed its line") + TEST_ASSERT(!house.matches(juice_glass) && !fancy.matches(juice_glass), "The Juice also sold on a credit line") + + var/obj/item/coffee_glass = pour(/datum/reagent/consumable/hot_ice_coffee, 40) + TEST_ASSERT(coffee.matches(coffee_glass), "Hot Ice Coffee missed its line") + TEST_ASSERT(!house.matches(coffee_glass) && !juice.matches(coffee_glass), "Hot Ice Coffee sold on another line") + + var/obj/item/watered = pour(/datum/reagent/consumable/ethanol/the_juice, 20, 30) + TEST_ASSERT(!juice.matches(watered), "Watered-down Juice sold as The Juice") + var/obj/item/splash = pour(/datum/reagent/consumable/ethanol/the_juice, 10) + TEST_ASSERT(!juice.matches(splash), "A splash of The Juice sold as a full glass") + + var/obj/item/blaster = pour(/datum/reagent/consumable/ethanol/gargle_blaster, 50) + TEST_ASSERT(house.matches(blaster), "A Gargle Blaster missed the house cocktail line") + TEST_ASSERT(!juice.matches(blaster) && !coffee.matches(blaster) && !fancy.matches(blaster), "A house cocktail reached a rarer line") + + var/obj/item/neuro = pour(/datum/reagent/consumable/ethanol/neurotoxin, 50) + TEST_ASSERT(fancy.matches(neuro) && !house.matches(neuro), "Neurotoxin landed on the wrong line") + + var/obj/item/bottle = allocate(/obj/item/reagent_containers/cup/glass/bottle/kong) + TEST_ASSERT(!house.matches(bottle), "A bottle sold as a cocktail") + +/datum/unit_test/voidcrew_buyback_vex_organs + +/datum/unit_test/voidcrew_buyback_vex_organs/Run() + var/datum/shop_buyback/donor_heart = allocate(/datum/shop_buyback/clinic/heart) + var/datum/shop_buyback/donor_lungs = allocate(/datum/shop_buyback/clinic/lungs) + var/datum/shop_buyback/species = allocate(/datum/shop_buyback/clinic_exotic/species) + var/datum/shop_buyback/voltaic = allocate(/datum/shop_buyback/clinic_exotic/voltaic_heart) + var/datum/shop_buyback/meridian = allocate(/datum/shop_buyback/clinic_exotic/meridian_heart) + + var/obj/item/organ/heart/ethereal/crystal = allocate(/obj/item/organ/heart/ethereal) + TEST_ASSERT(species.matches(crystal), "An ethereal heart missed the off-world line") + TEST_ASSERT(!donor_heart.matches(crystal), "An ethereal heart also sold as a plain donor heart") + var/obj/item/organ/lungs/plasmaman/bone_lungs = allocate(/obj/item/organ/lungs/plasmaman) + TEST_ASSERT(species.matches(bone_lungs) && !donor_lungs.matches(bone_lungs), "Plasmaman lungs landed on the wrong line") + + var/obj/item/organ/heart/plain = allocate(/obj/item/organ/heart) + TEST_ASSERT(donor_heart.matches(plain), "A plain heart missed the donor line") + TEST_ASSERT(!species.matches(plain) && !voltaic.matches(plain) && !meridian.matches(plain), "A plain heart reached an exotic line") + + var/obj/item/organ/tongue/lizard/printed = allocate(/obj/item/organ/tongue/lizard) + ADD_TRAIT(printed, "printed_organ", INNATE_TRAIT) + TEST_ASSERT(!species.matches(printed), "A limbgrower lizard tongue sold as a donor organ") + + var/obj/item/organ/heart/cybernetic/anomalock/empty = allocate(/obj/item/organ/heart/cybernetic/anomalock) + TEST_ASSERT(!voltaic.matches(empty), "A coreless voltaic shell sold as a cored heart") + var/obj/item/organ/heart/cybernetic/anomalock/prebuilt/cored = allocate(/obj/item/organ/heart/cybernetic/anomalock/prebuilt) + TEST_ASSERT(voltaic.matches(cored), "A cored voltaic heart missed its line") + TEST_ASSERT(!donor_heart.matches(cored), "A voltaic heart sold as a donor heart") + + var/obj/item/organ/heart/cybernetic/meridian/found = allocate(/obj/item/organ/heart/cybernetic/meridian) + TEST_ASSERT(meridian.matches(found) && !donor_heart.matches(found) && !voltaic.matches(found), "The Meridian heart landed on the wrong line") + +/datum/unit_test/voidcrew_buyback_vex_chrome + +/datum/unit_test/voidcrew_buyback_vex_chrome/Run() + var/datum/shop_buyback/fitted = allocate(/datum/shop_buyback/found_chrome/fitted) + var/datum/shop_buyback/pro = allocate(/datum/shop_buyback/found_chrome/pro) + var/datum/shop_buyback/military = allocate(/datum/shop_buyback/found_chrome/military) + var/datum/shop_buyback/legend = allocate(/datum/shop_buyback/found_chrome/legend) + + var/obj/item/organ/ronin = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin) + TEST_ASSERT(military.matches(ronin), "A found Ronin arm missed the military line") + TEST_ASSERT(!pro.matches(ronin) && !fitted.matches(ronin) && !legend.matches(ronin), "A Ronin arm sold on a cheaper line") + + var/obj/item/organ/blade = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left) + TEST_ASSERT(pro.matches(blade) && !military.matches(blade), "A single scorch blade landed on the wrong line") + + var/obj/item/organ/pick = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/icepick) + TEST_ASSERT(fitted.matches(pick) && !pro.matches(pick), "A found Icepick landed on the wrong line") + + var/obj/item/organ/bought = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin) + mark_trader_goods(bought) + TEST_ASSERT(!military.matches(bought), "Splice paid vouchers for shop stock") + + var/obj/item/organ/printed = allocate(/obj/item/organ/eyes/robotic/thermals) + for(var/datum/shop_buyback/band as anything in list(fitted, pro, military, legend)) + TEST_ASSERT(!band.matches(printed), "Lathe-printed thermal eyes sold as chrome on [band.type]") + + // Every installable piece fits at most one row on each ripperdoc's ledger, + // found or bought, and Ratchet never pays vouchers. + var/list/all_ware = list() + for(var/ware_type in subtypesof(/obj/item/organ/cyberimp/cyberware) + subtypesof(/obj/item/organ/eyes/robotic/cyberware) + subtypesof(/obj/item/organ/cyberimp/arm/toolkit/cyberware)) + all_ware += allocate(ware_type) + for(var/shop_type in list(/datum/outpost_shop/vendor/ripperdoc, /datum/outpost_shop/vendor/street_doc)) + var/datum/outpost_shop/shop = allocate(shop_type) + for(var/datum/shop_buyback/row as anything in shop.buybacks) + if(shop_type == /datum/outpost_shop/vendor/street_doc) + TEST_ASSERT(!row.pay_vouchers, "[row.type] at the street doc pays vouchers") + for(var/obj/item/organ/found as anything in all_ware) + var/list/hits = list() + for(var/datum/shop_buyback/row as anything in shop.buybacks) + if(row.matches(found)) + hits += row.type + TEST_ASSERT(length(hits) <= 1, "[found.type] fits [length(hits)] rows at [shop_type]: [jointext(hits, ", ")]") diff --git a/voidcrew/modules/unit_tests/voidcrew_chrome_wheel.dm b/voidcrew/modules/unit_tests/voidcrew_chrome_wheel.dm new file mode 100644 index 00000000000..6bfa89cfb4a --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_chrome_wheel.dm @@ -0,0 +1,473 @@ +/** + * # Chrome wheel + * + * The wheel (voidcrew/modules/cyberware/chrome_wheel.dm) fires the bearer's + * own chrome abilities, so these tests hold it to that: it collects exactly the + * abilities installed chrome grants (never a printable tg implant's), sockets + * them on the ring by body part without one socket moving another, points at + * the right chip by bearing, and fires the pick through Trigger() with the + * ability's own cooldown, offline and arm-toggle behaviour. No client exists + * here, so the wheel never goes on a screen; opening it must fail quietly, and + * building its pieces must still work. Chrome abilities have no HUD button of + * their own; one Chrome button stands in for them (chrome_hud.dm), and Arm + * chrome deploys every arm at once (chrome_wheel_arms.dm). + * + * NOTE: unit-test files compile before voidcrew/_DEFINES/, so fork defines are + * written as literals: CHROME_WHEEL_RADIUS 100, CHROME_WHEEL_STEP 14.5, + * CHROME_WHEEL_ROW_GAP 26, CHROME_WHEEL_CENTRE_Y 2, CHROME_WHEEL_DEADZONE 34, + * CHROME_WHEEL_SOCKET_OS "os", CHROME_WHEEL_SOCKET_RIGHT_ARM "r_arm", + * ORGAN_SLOT_CYBERWARE_OS "cyberware_os" and ORGAN_SLOT_CYBERWARE_HANDS + * "cyberware_hands". + */ + +/obj/item/organ/cyberimp/cyberware/test_wheel_pulse + name = "test wheel chrome" + zone = BODY_ZONE_CHEST + slot = "voidcrew_test_chrome_wheel" + chrome_load = 1 + actions_types = list(/datum/action/cooldown/cyberware/test_wheel) + +/obj/item/organ/cyberimp/cyberware/test_wheel_os + name = "test wheel OS" + zone = BODY_ZONE_CHEST + slot = "cyberware_os" // ORGAN_SLOT_CYBERWARE_OS + chrome_load = 1 + actions_types = list(/datum/action/cooldown/cyberware/test_wheel/os) + +/obj/item/organ/cyberimp/cyberware/test_wheel_hand + name = "test wheel grips" + zone = BODY_ZONE_R_ARM + slot = "cyberware_hands" // ORGAN_SLOT_CYBERWARE_HANDS + chrome_load = 1 + actions_types = list(/datum/action/cooldown/cyberware/test_wheel/hand) + +/// Counts its firings, and offers two sub-options whose use it records. +/datum/action/cooldown/cyberware/test_wheel + name = "Test Wheel Pulse" + cooldown_time = 10 SECONDS + var/fired = 0 + var/list/options_used = list() + +/datum/action/cooldown/cyberware/test_wheel/Activate(atom/target) + fired++ + StartCooldown() + return TRUE + +/datum/action/cooldown/cyberware/test_wheel/chrome_wheel_options(mob/living/carbon/bearer) + return list( + new /datum/chrome_wheel_option("alpha", "Alpha"), + new /datum/chrome_wheel_option("beta", "Beta"), + ) + +/datum/action/cooldown/cyberware/test_wheel/use_chrome_wheel_option(mob/living/carbon/bearer, option_id) + options_used += option_id + return TRUE + +/datum/action/cooldown/cyberware/test_wheel/os + name = "Test Wheel Burn" + +/datum/action/cooldown/cyberware/test_wheel/os/chrome_wheel_options(mob/living/carbon/bearer) + return null + +/datum/action/cooldown/cyberware/test_wheel/hand + name = "Test Wheel Grip" + +/datum/action/cooldown/cyberware/test_wheel/hand/chrome_wheel_options(mob/living/carbon/bearer) + return null + +/// Collection, region layout, its stability, display names and pointing. +/datum/unit_test/voidcrew_chrome_wheel_layout + +/datum/unit_test/voidcrew_chrome_wheel_layout/Run() + var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/test_wheel_pulse/pulse_ware = allocate(/obj/item/organ/cyberimp/cyberware/test_wheel_pulse) + TEST_ASSERT(pulse_ware.Insert(lab_rat, special = TRUE), "Test chrome staging insert was refused") + var/obj/item/organ/cyberimp/cyberware/test_wheel_os/os_ware = allocate(/obj/item/organ/cyberimp/cyberware/test_wheel_os) + TEST_ASSERT(os_ware.Insert(lab_rat, special = TRUE), "Test OS staging insert was refused") + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left/left_mantis = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left) + TEST_ASSERT(left_mantis.Insert(lab_rat, special = TRUE), "Left Mantis staging insert was refused") + var/obj/item/organ/cyberimp/arm/toolkit/toolset/printable = allocate(/obj/item/organ/cyberimp/arm/toolkit/toolset) + TEST_ASSERT(printable.Insert(lab_rat, special = TRUE), "Toolset implant staging insert was refused") + + var/datum/action/pulse = locate(/datum/action/cooldown/cyberware/test_wheel) in pulse_ware.actions + var/datum/action/burn = locate(/datum/action/cooldown/cyberware/test_wheel/os) in os_ware.actions + var/datum/action/blade = locate(/datum/action/item_action/organ_action/toggle) in left_mantis.actions + var/datum/action/lunge = locate(/datum/action/cooldown/cyberware/mantis_lunge) in left_mantis.actions + var/datum/action/toolset_toggle = locate(/datum/action/item_action/organ_action/toggle) in printable.actions + TEST_ASSERT(pulse && burn && blade && lunge && toolset_toggle, "A staged organ is missing its button") + + var/datum/component/chrome_wheel/wheel = lab_rat.GetComponent(/datum/component/chrome_wheel) + var/datum/action/arms = wheel?.arm_action + TEST_ASSERT_NOTNULL(arms, "Arm hardware went in and the body got no Arm chrome") + + var/list/abilities = get_chrome_wheel_actions(lab_rat) + TEST_ASSERT_EQUAL(length(abilities), 5, "The wheel should hold the four abilities installed chrome grants, and Arm chrome") + TEST_ASSERT((pulse in abilities) && (burn in abilities) && (blade in abilities) && (lunge in abilities), "An installed chrome ability is missing from the wheel") + TEST_ASSERT(arms in abilities, "Arm chrome is not on the wheel") + TEST_ASSERT(!(toolset_toggle in abilities), "A printable tg implant's button made it onto the chrome wheel") + TEST_ASSERT_EQUAL(get_os_chrome_action(lab_rat), burn, "Use OS chrome does not find the OS-slot ware's ability") + + // Sockets run round the ring 14.5 degrees apart at radius 100, from a + // centre 2 px above the view's. The OS starts its arc right of the head. + var/list/positions = chrome_wheel_layout(abilities) + TEST_ASSERT_EQUAL(point_text(positions[burn]), "73,70", "The OS ability is not first on its arc, up and right of the body") + TEST_ASSERT_EQUAL(point_text(positions[pulse]), "88,50", "Other chest chrome should follow the OS one step round its arc") + TEST_ASSERT_EQUAL(point_text(positions[blade]), "-99,14", "Left arm chrome is not on the left of the ring") + TEST_ASSERT_EQUAL(point_text(positions[lunge]), "-99,-11", "A left arm's second ability should sit one step further round its arc") + // Arm chrome holds the top of the right arm's arc, by the torso, whatever the right arm carries. + TEST_ASSERT_EQUAL(point_text(positions[arms]), "99,14", "Arm chrome is not at the top of the right arm's arc") + + // Socket independence: new right-arm chrome takes the right side and moves + // nothing on the left, and a missing OS leaves its place empty. + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right_mantis = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + TEST_ASSERT(right_mantis.Insert(lab_rat, special = TRUE), "Right Mantis staging insert was refused") + var/datum/action/right_blade = locate(/datum/action/item_action/organ_action/toggle) in right_mantis.actions + os_ware.Remove(lab_rat, special = TRUE) + abilities = get_chrome_wheel_actions(lab_rat) + positions = chrome_wheel_layout(abilities) + TEST_ASSERT_EQUAL(point_text(positions[right_blade]), "99,-11", "Right arm chrome should start on the right of the ring, below Arm chrome") + TEST_ASSERT_EQUAL(point_text(positions[arms]), "99,14", "Right arm chrome moved Arm chrome") + TEST_ASSERT_EQUAL(point_text(positions[blade]), "-99,14", "Adding right-arm chrome moved the left arm's chip") + TEST_ASSERT_EQUAL(point_text(positions[pulse]), "88,50", "Removing the OS moved other chest chrome into its place") + + // Hand chrome follows its arm's own chrome round the arm's arc. + var/obj/item/organ/cyberimp/cyberware/test_wheel_hand/grips = allocate(/obj/item/organ/cyberimp/cyberware/test_wheel_hand) + TEST_ASSERT(grips.Insert(lab_rat, special = TRUE), "Test hand chrome staging insert was refused") + var/datum/action/grip = locate(/datum/action/cooldown/cyberware/test_wheel/hand) in grips.actions + TEST_ASSERT_NOTNULL(grip, "The test hand chrome is missing its button") + abilities = get_chrome_wheel_actions(lab_rat) + var/list/placements = chrome_wheel_placements(abilities) + var/list/grip_place = placements[grip] + TEST_ASSERT_EQUAL(grip_place?["socket"], "r_arm", "Hand chrome is not in its arm's socket") + TEST_ASSERT_EQUAL(grip_place?["index"], 4, "Hand chrome should come after Arm chrome and both of the right Mantis housing's chips") + TEST_ASSERT(grip_place?["hand"], "Hand chrome was not marked as hand chrome") + positions = chrome_wheel_layout(abilities) + TEST_ASSERT_EQUAL(point_text(positions[right_blade]), "99,-11", "Hand chrome pushed its arm's own chrome along") + + // A full arc starts a row further out at the same bearing. + TEST_ASSERT_EQUAL(point_text(chrome_wheel_position("os", 3)), "92,88", "The OS arc's third chip did not start a second row outside the first") + + // Chips are called by what they do, not by their button's full name. + var/list/names = chrome_wheel_names(abilities) + TEST_ASSERT_EQUAL(names[blade], "Mantis Blade", "A Mantis housing's deploy chip should read as the blade, without its housing or side") + TEST_ASSERT_EQUAL(names[lunge], "Mantis Lunge", "An ability with its own name was renamed") + TEST_ASSERT_EQUAL(chrome_wheel_ware_name(lunge), "Mantis Blade housing (left)", "The readout should name the chrome an ability lives in") + TEST_ASSERT_EQUAL(names[arms], "Arm chrome", "Arm chrome's chip is misnamed") + + // Pointing. Points: 1 pulse (88,50), 2 blade (-99,14), 3 lunge (-99,-11), + // 4 right blade (99,-11), 5 grip (80,-57). + var/list/points = list(positions[pulse], positions[blade], positions[lunge], positions[right_blade], positions[grip]) + TEST_ASSERT_EQUAL(chrome_wheel_pick(5, 5, points), 0, "The middle of the body pointed at a chip") + TEST_ASSERT_EQUAL(chrome_wheel_pick(20, 20, points), 0, "A point inside the body pointed at a chip") + TEST_ASSERT_EQUAL(chrome_wheel_pick(87, 51, points), 1, "The mouse on a chip did not point at it") + TEST_ASSERT_EQUAL(chrome_wheel_pick(-300, 4, points), 2, "A flick far out to the left did not point at the left arm's nearest chip by bearing") + TEST_ASSERT_EQUAL(chrome_wheel_pick(-40, -6, points), 3, "A short move between the body and the ring did not point at the chip on its bearing") + TEST_ASSERT_EQUAL(chrome_wheel_pick(0, -300, points), 0, "A flick into the empty legs arc pointed at something") + // A second-row chip answers the mouse right on it, never a bearing. + var/list/rows = list(list(73, 70), list(92, 88)) + TEST_ASSERT_EQUAL(chrome_wheel_pick(184, 176, rows, list(TRUE, FALSE)), 1, "A flick out along a socket's bearing picked its second row over its first") + TEST_ASSERT_EQUAL(chrome_wheel_pick(93, 87, rows, list(TRUE, FALSE)), 2, "The mouse on a second-row chip did not point at it") + + TEST_ASSERT_EQUAL(chrome_wheel_raw_key("ShiftV"), "V", "A Shift bind's key was not found") + TEST_ASSERT_EQUAL(chrome_wheel_raw_key("CtrlShiftV"), "V", "A two-modifier bind's key was not found") + TEST_ASSERT_EQUAL(chrome_wheel_raw_key("Space"), "Space", "A plain key was mangled") + TEST_ASSERT_EQUAL(chrome_wheel_raw_key("Alt"), "Alt", "A bare modifier bind lost its key") + +/datum/unit_test/voidcrew_chrome_wheel_layout/proc/point_text(list/point) + return length(point) == 2 ? "[point[1]],[point[2]]" : "none" + +/// Selection and firing: the pick goes through the button's own Trigger(). +/datum/unit_test/voidcrew_chrome_wheel_fire + +/datum/unit_test/voidcrew_chrome_wheel_fire/Run() + var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human/consistent) + TEST_ASSERT_NULL(get_chrome_wheel(lab_rat), "A body with no chrome grew a chrome wheel") + var/obj/item/organ/cyberimp/cyberware/test_wheel_pulse/pulse_ware = allocate(/obj/item/organ/cyberimp/cyberware/test_wheel_pulse) + TEST_ASSERT(pulse_ware.Insert(lab_rat, special = TRUE), "Test chrome staging insert was refused") + var/obj/item/organ/cyberimp/cyberware/test_wheel_os/os_ware = allocate(/obj/item/organ/cyberimp/cyberware/test_wheel_os) + TEST_ASSERT(os_ware.Insert(lab_rat, special = TRUE), "Test OS staging insert was refused") + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left/mantis = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left) + TEST_ASSERT(mantis.Insert(lab_rat, special = TRUE), "Mantis staging insert was refused") + + var/datum/action/cooldown/cyberware/test_wheel/pulse = locate(/datum/action/cooldown/cyberware/test_wheel) in pulse_ware.actions + var/datum/action/cooldown/cyberware/test_wheel/burn = locate(/datum/action/cooldown/cyberware/test_wheel/os) in os_ware.actions + var/datum/action/blade = locate(/datum/action/item_action/organ_action/toggle) in mantis.actions + var/datum/action/lunge = locate(/datum/action/cooldown/cyberware/mantis_lunge) in mantis.actions + + var/datum/component/chrome_wheel/wheel = get_chrome_wheel(lab_rat) + TEST_ASSERT_NOTNULL(wheel, "A chromed body got no wheel") + + // No client: the wheel key has nothing to draw on and must do nothing. + wheel.wheel_key_down() + TEST_ASSERT(!wheel.is_open(), "The wheel opened with no client to draw on") + wheel.wheel_key_up() + + // Its pieces build without a screen to go on: one chip per ability, and + // pointing, picking and teardown work on them. + wheel.build_wheel(get_chrome_wheel_actions(lab_rat)) + TEST_ASSERT_EQUAL(length(wheel.chips), 5, "The built wheel should have one chip per chrome ability, Arm chrome included") + var/atom/movable/screen/chrome_wheel/chip/first_chip = wheel.chips[1] + wheel.set_highlight(first_chip) + TEST_ASSERT_EQUAL(first_chip.size, 26, "The chip pointed at did not grow") + wheel.select_chip(first_chip, quiet = TRUE) + TEST_ASSERT_EQUAL(wheel.get_selected_ability(), first_chip.ability_ref.resolve(), "Picking a chip did not pick its ability") + TEST_ASSERT_EQUAL(length(first_chip.brackets), 4, "The picked chip did not get its lock brackets") + wheel.close_wheel() + TEST_ASSERT_NULL(wheel.chips, "Closing the wheel left its chips behind") + + wheel.select(pulse) + TEST_ASSERT(wheel.use_selected(), "Use chrome refused a ready pick") + TEST_ASSERT_EQUAL(pulse.fired, 1, "Use chrome did not fire the picked ability") + + // The cooldown is the button's own. + lab_rat.next_click = 0 + wheel.use_selected() + TEST_ASSERT_EQUAL(pulse.fired, 1, "The wheel fired an ability through its cooldown") + + // Offline chrome stays dark through the wheel, and keeps its pick. + pulse.ResetCooldown() + var/datum/component/cyberware/chrome = pulse_ware.GetComponent(/datum/component/cyberware) + chrome.start_emp_reboot(EMP_HEAVY) + lab_rat.next_click = 0 + wheel.use_selected() + TEST_ASSERT_EQUAL(pulse.fired, 1, "EMP-scrambled chrome fired from the wheel") + TEST_ASSERT_EQUAL(wheel.get_selected_ability(), pulse, "Going offline dropped the pick. It should only go dark") + chrome.tune_up() + lab_rat.next_click = 0 + wheel.use_selected() + TEST_ASSERT_EQUAL(pulse.fired, 2, "Chrome back online did not fire from the wheel") + + // Use OS chrome fires the OS and leaves the pick alone. + lab_rat.next_click = 0 + TEST_ASSERT(wheel.use_os(), "Use OS chrome refused") + TEST_ASSERT_EQUAL(burn.fired, 1, "Use OS chrome did not fire the OS ability") + TEST_ASSERT_EQUAL(pulse.fired, 2, "Use OS chrome fired the picked ability") + TEST_ASSERT_EQUAL(wheel.get_selected_ability(), pulse, "Use OS chrome changed the pick") + + // Arm hardware toggles like its button: out, then back in. + wheel.select(blade) + lab_rat.next_click = 0 + wheel.use_selected() + TEST_ASSERT(mantis.active_item && !(mantis.active_item in mantis), "Using the picked Mantis housing did not deploy the blade") + lab_rat.next_click = 0 + wheel.use_selected() + TEST_ASSERT(!mantis.active_item || (mantis.active_item in mantis), "Using the picked Mantis housing again did not retract the blade") + + // A picked sub-option fires through the ability's option hook instead of Trigger(). + pulse.ResetCooldown() + wheel.select(pulse, "beta") + lab_rat.next_click = 0 + wheel.use_selected() + TEST_ASSERT("beta" in pulse.options_used, "A picked sub-option was not handed to its ability") + TEST_ASSERT_EQUAL(pulse.fired, 2, "Using a sub-option also fired the ability itself") + + // A pick the ability no longer offers is dropped, not fired. + wheel.select(pulse, "gamma") + lab_rat.next_click = 0 + TEST_ASSERT(!wheel.use_selected(), "A sub-option the ability no longer offers was fired") + TEST_ASSERT_NULL(wheel.get_selected_ability(), "A sub-option the ability no longer offers stayed picked") + + // Chrome pulled between the pick and the use: nothing fires and the pick goes. + wheel.select(lunge) + mantis.Remove(lab_rat, special = TRUE) + lab_rat.next_click = 0 + TEST_ASSERT(!wheel.use_selected(), "An ability fired after its chrome was removed") + TEST_ASSERT_NULL(wheel.get_selected_ability(), "Removed chrome stayed picked") + TEST_ASSERT(!wheel.is_open(), "With no client, a missing pick opened the wheel") + +/** + * Chrome abilities get no HUD button of their own and still fire from the + * wheel; one Chrome button stands in for them while the body has chrome, shows + * the pick, and fires a chip clicked on a wheel it opened. A printable tg + * implant keeps its own button. + */ +/datum/unit_test/voidcrew_chrome_hud + +/datum/unit_test/voidcrew_chrome_hud/Run() + var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/arm/toolkit/toolset/printable = allocate(/obj/item/organ/cyberimp/arm/toolkit/toolset) + TEST_ASSERT(printable.Insert(lab_rat, special = TRUE), "Toolset implant staging insert was refused") + var/datum/action/toolset_toggle = locate(/datum/action/item_action/organ_action/toggle) in printable.actions + TEST_ASSERT(toolset_toggle in lab_rat.actions, "Test fixture: the printable implant's button is not on the body") + TEST_ASSERT_NULL(lab_rat.GetComponent(/datum/component/chrome_wheel), "A body with no chrome grew a chrome wheel") + + var/obj/item/organ/cyberimp/cyberware/test_wheel_pulse/pulse_ware = allocate(/obj/item/organ/cyberimp/cyberware/test_wheel_pulse) + TEST_ASSERT(pulse_ware.Insert(lab_rat, special = TRUE), "Test chrome staging insert was refused") + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left/mantis = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left) + TEST_ASSERT(mantis.Insert(lab_rat, special = TRUE), "Mantis staging insert was refused") + var/datum/action/cooldown/cyberware/test_wheel/pulse = locate(/datum/action/cooldown/cyberware/test_wheel) in pulse_ware.actions + var/datum/action/blade = locate(/datum/action/item_action/organ_action/toggle) in mantis.actions + var/datum/action/lunge = locate(/datum/action/cooldown/cyberware/mantis_lunge) in mantis.actions + + // Granted, but no button: never in the body's actions, which the HUD builds buttons from. + for(var/datum/action/ability as anything in list(pulse, blade, lunge)) + TEST_ASSERT_EQUAL(ability.owner, lab_rat, "[ability.name] was not granted to its bearer") + TEST_ASSERT(!(ability in lab_rat.actions), "[ability.name] joined the body's actions and would get a HUD button") + TEST_ASSERT(toolset_toggle in lab_rat.actions, "A printable tg implant lost its button") + + // The Chrome button came with the first chrome ability. + var/datum/component/chrome_wheel/wheel = lab_rat.GetComponent(/datum/component/chrome_wheel) + TEST_ASSERT_NOTNULL(wheel, "Chrome went in and no chrome wheel was made") + var/datum/action/chrome_button/chrome_button = wheel.hud_button + TEST_ASSERT_NOTNULL(chrome_button, "Chrome went in and no Chrome button was made") + TEST_ASSERT(chrome_button in lab_rat.actions, "The Chrome button is not on the body") + var/datum/action/chrome_arms/arms = wheel.arm_action + TEST_ASSERT(arms && !(arms in lab_rat.actions), "Arm chrome is missing, or has a button of its own") + + // The HUD builds buttons from the body's actions; a chrome ability never asks for one. + TEST_ASSERT(pulse.is_chrome_ability() && blade.is_chrome_ability() && arms.is_chrome_ability(), "Chrome abilities are not recognised as chrome") + TEST_ASSERT(!toolset_toggle.is_chrome_ability(), "A printable tg implant's button was taken for chrome") + TEST_ASSERT(!chrome_button.is_chrome_ability(), "The Chrome button hid itself") + + // Chips still wear the ability's own button look without a button on any screen. + var/mutable_appearance/blade_look = chrome_wheel_ability_look(blade) + TEST_ASSERT(length(blade_look.overlays), "A chip lost its item overlay without the ability's button") + var/mutable_appearance/pulse_look = chrome_wheel_ability_look(pulse) + TEST_ASSERT_EQUAL(pulse_look.icon_state, pulse.button_icon_state, "A chip lost its ability's icon without the ability's button") + + // No pick: the Chrome button shows the wheel. A pick: its look in the frame. + var/list/look = chrome_button_look(chrome_button) + TEST_ASSERT_EQUAL(look["icon_state"], "chrome", "The Chrome button with no pick does not show the chrome icon") + TEST_ASSERT_EQUAL(look["laid"], 0, "The Chrome button with no pick shows a pick") + wheel.select(pulse) + look = chrome_button_look(chrome_button) + TEST_ASSERT_EQUAL(look["laid"], 2, "The Chrome button does not show the pick in its frame") + TEST_ASSERT(!look["icon"], "The Chrome button shows the chrome icon under its pick") + + // The pick fires from the wheel through its own Trigger(), and the button shows its cooldown. + lab_rat.next_click = 0 + TEST_ASSERT(wheel.use_selected(), "Use chrome refused a ready pick") + TEST_ASSERT_EQUAL(pulse.fired, 1, "A chrome ability with no button did not fire from the wheel") + look = chrome_button_look(chrome_button) + TEST_ASSERT(length(look["maptext"]), "The Chrome button does not count down its pick's cooldown") + TEST_ASSERT_EQUAL(look["color"], rgb(128, 0, 0), "The Chrome button is not red while its pick cools down") + pulse.ResetCooldown() + look = chrome_button_look(chrome_button) + TEST_ASSERT(!length(look["maptext"]), "The Chrome button kept counting down after the cooldown ended") + + // Offline: red, like the pick's own button would be. + var/datum/component/cyberware/pulse_chrome = pulse_ware.GetComponent(/datum/component/cyberware) + pulse_chrome.start_emp_reboot(EMP_HEAVY) + look = chrome_button_look(chrome_button) + TEST_ASSERT_EQUAL(look["color"], rgb(128, 0, 0), "The Chrome button is not red while its pick is offline") + pulse_chrome.tune_up() + look = chrome_button_look(chrome_button) + TEST_ASSERT_NOTEQUAL(look["color"], rgb(128, 0, 0), "The Chrome button stayed red after its pick came back") + + // A click on the button reaches the wheel. Opening it needs a client, so here it stays shut. + TEST_ASSERT(chrome_button.Trigger(lab_rat), "The Chrome button refused its own bearer") + TEST_ASSERT(!wheel.is_open(), "The wheel opened with no client to draw on") + + // A wheel the Chrome button opened fires the chip clicked as well as picking it. + pulse.ResetCooldown() + wheel.build_wheel(get_chrome_wheel_actions(lab_rat)) + wheel.fire_on_pick = TRUE + var/atom/movable/screen/chrome_wheel/chip/pulse_chip + for(var/atom/movable/screen/chrome_wheel/chip/chip as anything in wheel.chips) + if(chip.ability_ref?.resolve() == pulse) + pulse_chip = chip + TEST_ASSERT_NOTNULL(pulse_chip, "The built wheel has no chip for the test ability") + lab_rat.next_click = 0 + wheel.choose(pulse_chip) + TEST_ASSERT_EQUAL(pulse.fired, 2, "A chip clicked on a wheel the Chrome button opened was not fired") + TEST_ASSERT(!wheel.fire_on_pick, "Closing the wheel left it firing picks") + + // The last chrome out takes the Chrome button with it; the printable implant keeps its own. + pulse_ware.Remove(lab_rat, special = TRUE) + TEST_ASSERT_NOTNULL(wheel.hud_button, "The Chrome button went while chrome was still in") + mantis.Remove(lab_rat, special = TRUE) + TEST_ASSERT_NULL(wheel.hud_button, "The Chrome button outlived the body's last chrome") + TEST_ASSERT_NULL(wheel.arm_action, "Arm chrome outlived the body's last arm hardware") + TEST_ASSERT(!(chrome_button in lab_rat.actions), "The Chrome button stayed on the body") + TEST_ASSERT(toolset_toggle in lab_rat.actions, "The printable implant lost its button along with the chrome") + +/// What a Chrome button drawn now looks like: built off any screen, read, and thrown away. +/datum/unit_test/voidcrew_chrome_hud/proc/chrome_button_look(datum/action/chrome_button/chrome_button) + var/atom/movable/screen/movable/action_button/button = chrome_button.create_button() + . = list( + "icon" = button.icon, + "icon_state" = button.icon_state, + "laid" = length(button.chrome_overlays), + "maptext" = button.maptext, + "color" = button.color, + ) + qdel(button) + +/** + * Arm chrome: both Mantis blades come out together and every arm goes back in + * if any is out; an EMP'd arm and an arm whose hand is full stay put; Deploy + * arm chrome sits on a key no other default bind uses. + */ +/datum/unit_test/voidcrew_chrome_arms + +/datum/unit_test/voidcrew_chrome_arms/Run() + var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/arm/toolkit/toolset/printable = allocate(/obj/item/organ/cyberimp/arm/toolkit/toolset) + TEST_ASSERT(printable.Insert(lab_rat, special = TRUE), "Toolset implant staging insert was refused") + TEST_ASSERT_NULL(lab_rat.GetComponent(/datum/component/chrome_wheel), "A printable tg arm implant made a chrome wheel") + + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left/left_blade = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left) + TEST_ASSERT(left_blade.Insert(lab_rat, special = TRUE), "Left Mantis staging insert was refused") + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right_blade = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + TEST_ASSERT(right_blade.Insert(lab_rat, special = TRUE), "Right Mantis staging insert was refused") + var/datum/component/chrome_wheel/wheel = lab_rat.GetComponent(/datum/component/chrome_wheel) + TEST_ASSERT_NOTNULL(wheel?.arm_action, "Two Mantis housings went in and the body got no Arm chrome") + var/list/housings = get_chrome_arm_housings(lab_rat) + TEST_ASSERT_EQUAL(length(housings), 2, "Arm chrome should count both housings") + TEST_ASSERT(!(printable in housings), "Arm chrome counted a printable tg implant") + + // Out together. + lab_rat.next_click = 0 + TEST_ASSERT(wheel.use_arms(), "Deploy arm chrome refused") + TEST_ASSERT(left_blade.blade_extended() && right_blade.blade_extended(), "Arm chrome did not deploy both Mantis blades together") + TEST_ASSERT(chrome_wheel_ability_active(wheel.arm_action, lab_rat), "The wheel does not show Arm chrome as out") + + // Any out: all in. + right_blade.Retract() + TEST_ASSERT(left_blade.blade_extended() && !right_blade.blade_extended(), "Test fixture: stowing one blade by hand failed") + lab_rat.next_click = 0 + wheel.use_arms() + TEST_ASSERT(!left_blade.blade_extended() && !right_blade.blade_extended(), "Arm chrome with one blade out did not stow everything") + + // An EMP'd arm stays in; the other still comes out. + var/datum/component/cyberware/right_chrome = right_blade.GetComponent(/datum/component/cyberware) + right_chrome.start_emp_reboot(EMP_HEAVY) + lab_rat.next_click = 0 + wheel.use_arms() + TEST_ASSERT(left_blade.blade_extended(), "An EMP'd arm kept the working one from deploying") + TEST_ASSERT(!right_blade.blade_extended(), "Arm chrome deployed an EMP'd arm") + lab_rat.next_click = 0 + wheel.use_arms() + TEST_ASSERT(!left_blade.blade_extended(), "Arm chrome did not stow the deployed arm") + right_chrome.tune_up() + + // A full hand keeps its item, and that arm stays in. + var/obj/item/held = allocate(/obj/item/screwdriver) + TEST_ASSERT(lab_rat.put_in_l_hand(held), "Test fixture: the left hand would not take a screwdriver") + lab_rat.next_click = 0 + wheel.use_arms() + TEST_ASSERT(right_blade.blade_extended(), "A full left hand kept the right blade in") + TEST_ASSERT(!left_blade.blade_extended(), "Arm chrome deployed into a full hand") + TEST_ASSERT(lab_rat.is_holding(held), "Arm chrome dropped what the hand held") + lab_rat.next_click = 0 + wheel.use_arms() + TEST_ASSERT(!right_blade.blade_extended(), "Arm chrome did not stow the right blade") + + // Each housing keeps its own chip for single-arm use. + var/datum/action/left_toggle = locate(/datum/action/item_action/organ_action/toggle) in left_blade.actions + TEST_ASSERT(left_toggle in get_chrome_wheel_actions(lab_rat), "A housing's own deploy chip left the wheel") + + // Arm hardware out: Arm chrome goes with the last of it. + left_blade.Remove(lab_rat, special = TRUE) + TEST_ASSERT_NOTNULL(wheel.arm_action, "Arm chrome went with arm hardware still in") + right_blade.Remove(lab_rat, special = TRUE) + TEST_ASSERT_NULL(wheel.arm_action, "Arm chrome stayed with no arm hardware") + + // Deploy arm chrome: a default key no other bind sits on. + var/datum/keybinding/deploy_bind = GLOB.keybindings_by_name["deploy_arm_chrome"] + TEST_ASSERT_NOTNULL(deploy_bind, "There is no Deploy arm chrome keybind") + for(var/default_key in deploy_bind.hotkey_keys) + for(var/bind_name in GLOB.keybindings_by_name) + var/datum/keybinding/other = GLOB.keybindings_by_name[bind_name] + if(other != deploy_bind && (default_key in other.hotkey_keys)) + TEST_FAIL("Deploy arm chrome's default key [default_key] is also [other.full_name]'s") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware.dm index 35b2f28ea1d..93e4f6b7c29 100644 --- a/voidcrew/modules/unit_tests/voidcrew_cyberware.dm +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware.dm @@ -158,7 +158,14 @@ /datum/unit_test/voidcrew_cyberware_arm_slots /datum/unit_test/voidcrew_cyberware_arm_slots/Run() - var/list/exempt = list(/obj/item/organ/cyberimp/cyberware/gecko) + // The other two palm and wrist pieces share the hands slot with it (ware_street_passives.dm), + // and the chrome wheel tests' hand fixture stands in for them (voidcrew_chrome_wheel.dm). + var/list/exempt = list( + /obj/item/organ/cyberimp/cyberware/gecko, + /obj/item/organ/cyberimp/cyberware/medic_palms, + /obj/item/organ/cyberimp/cyberware/cuffer_wrists, + /obj/item/organ/cyberimp/cyberware/test_wheel_hand, + ) var/list/arm_ware = typesof(/obj/item/organ/cyberimp/cyberware) + typesof(/obj/item/organ/cyberimp/arm/toolkit/cyberware) for(var/organ_path in arm_ware) if(organ_path in exempt) @@ -170,6 +177,51 @@ if(BODY_ZONE_L_ARM) TEST_ASSERT_EQUAL(initial(ware.slot), ORGAN_SLOT_LEFT_ARM_AUG, "[organ_path] is left-arm chrome off the arm hardware slot. It would stack with blades/launchers on the same arm") +/// The Widowline Arc: same slot as the Widowline it steps up from, a heavier +/// load, and a wire whose shock lands through insulated gloves, skips the +/// shock-immune, hits robots harder, and shorts a turret once per recharge. +/datum/unit_test/voidcrew_cyberware_widowline_arc + +/datum/unit_test/voidcrew_cyberware_widowline_arc/Run() + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/plain = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live/arc = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live) + TEST_ASSERT_EQUAL(arc.slot, plain.slot, "The Arc housing isn't in the Widowline's slot, so the two would stack") + TEST_ASSERT(arc.chrome_load > plain.chrome_load, "The Arc housing is no heavier than the plain Widowline") + var/obj/item/melee/cyberware_monowire/live/wire = locate() in arc + TEST_ASSERT(wire, "The Arc housing didn't build its live wire") + + var/turf/start = run_loc_floor_bottom_left + var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human/consistent, start) + var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent, get_step(start, EAST)) + TEST_ASSERT(wire.discharge_into_mob(victim, user), "The shock didn't land on a plain human") + TEST_ASSERT(victim.getFireLoss() > 0, "The shock left no burn") + TEST_ASSERT(victim.has_status_effect(/datum/status_effect/staggered), "The shock left no stagger") + + var/mob/living/carbon/human/gloved = allocate(/mob/living/carbon/human/consistent, get_step(start, EAST)) + var/obj/item/clothing/gloves/color/yellow/insulated = allocate(/obj/item/clothing/gloves/color/yellow) + gloved.equip_to_slot_if_possible(insulated, ITEM_SLOT_GLOVES, qdel_on_fail = FALSE, disable_warning = TRUE) + TEST_ASSERT_EQUAL(gloved.gloves, insulated, "Insulated gloves fixture failed to equip") + TEST_ASSERT(wire.discharge_into_mob(gloved, user), "Insulated gloves stopped the shock") + + var/mob/living/carbon/human/immune = allocate(/mob/living/carbon/human/consistent, get_step(start, EAST)) + ADD_TRAIT(immune, TRAIT_SHOCKIMMUNE, TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT(!wire.discharge_into_mob(immune, user), "A shock-immune target was shocked") + TEST_ASSERT_EQUAL(immune.getFireLoss(), 0, "A shock-immune target took burn") + TEST_ASSERT(!immune.has_status_effect(/datum/status_effect/staggered), "A shock-immune target was staggered") + + // Any robotic biotype takes the robot bonus, not just silicons. + var/mob/living/basic/pet/dog/corgi/robot = allocate(/mob/living/basic/pet/dog/corgi, get_step(start, EAST)) + robot.mob_biotypes = MOB_ROBOTIC + TEST_ASSERT(wire.discharge_into_mob(robot, user), "The robot bonus didn't land on a robotic mob") + TEST_ASSERT(robot.health < robot.maxHealth, "The robot bonus did no damage") + + var/obj/machinery/porta_turret/turret = allocate(/obj/machinery/porta_turret, get_step(start, NORTH)) + TEST_ASSERT(wire.discharge_into_machine(turret, user), "The wire didn't short a porta-turret") + TEST_ASSERT(!COOLDOWN_FINISHED(turret, disabled_time), "A shorted porta-turret isn't disabled") + var/obj/machinery/porta_turret/second_turret = allocate(/obj/machinery/porta_turret, get_step(start, NORTH)) + TEST_ASSERT(!wire.discharge_into_machine(second_turret, user), "The wire shorted a second machine before it recharged") + TEST_ASSERT(COOLDOWN_FINISHED(second_turret, disabled_time), "A turret was disabled with the wire recharging") + /// (f) Chrome read: the optics' scan resolves installed hardware by name at /// itemized resolution, rates parlor chrome by tier and everything else /// UNRATED, counts either way, and NEVER resolves anything flagged @@ -203,7 +255,7 @@ // printable augments unrated, and skips what it can't see. var/itemized = jointext(cyberware_scan_readout(lab_rat, 2), "\n") TEST_ASSERT(findtext(itemized, uppertext(optics.name)), "An itemized chrome read didn't name the installed optics: [itemized]") - TEST_ASSERT(findtext(itemized, "T1"), "An itemized chrome read didn't rate the tier 1 optics: [itemized]") + TEST_ASSERT(findtext(itemized, "STREET"), "An itemized chrome read didn't rate the street-grade optics: [itemized]") TEST_ASSERT(findtext(itemized, "UNRATED"), "An itemized chrome read rated a printable augment as parlor chrome: [itemized]") TEST_ASSERT(!findtext(itemized, uppertext(stash.name)), "An itemized chrome read named the ORGAN_HIDDEN Cargo Cavity: [itemized]") TEST_ASSERT(findtext(itemized, "SIGNATURES 2"), "An itemized chrome read miscounted the visible signatures: [itemized]") @@ -214,6 +266,165 @@ TEST_ASSERT(findtext(silhouette, "SIGNATURES 2"), "A silhouette chrome read didn't report the signature count: [silhouette]") TEST_ASSERT_EQUAL(initial(optics.chrome_scan_resolution), 1, "The street-tier Nightshade isn't set to silhouette resolution") +/// (f2) Chrome read overlay: the report it draws, and the readout's life. +/// Every reader here is clientless, so this proves the data and the teardown, +/// never how the client draws it. +/// Literals: resolution 1 = CYBERWARE_SCAN_SILHOUETTE, 2 = _ITEMIZED; tier 1 = +/// CYBERWARE_TIER_1; "#8fa1a8" is the unrated colour; "cyber_camo" is +/// TRAIT_CYBER_CAMO; looks are the overlay's own "itemized", "silhouette", +/// "scatter" and "clean". +/datum/unit_test/voidcrew_cyberware_scan_overlay + +/datum/unit_test/voidcrew_cyberware_scan_overlay/Run() + var/mob/living/carbon/human/reader = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = allocate(/obj/item/organ/eyes/robotic/cyberware/deadeye) + TEST_ASSERT(optics.Insert(reader, special = TRUE), "Deadeye staging insert was refused") + var/datum/action/cooldown/cyberware/chrome_read/read = locate() in optics.actions + TEST_ASSERT_NOTNULL(read, "The Deadeye link lost its chrome read") + TEST_ASSERT(!reader.is_blind(), "Test fixture: the staged optics left the reader blind") + + // The subject: a hidden stash, a printable augment, and a weave knocked offline. + var/mob/living/carbon/human/subject = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/cargo_cavity/stash = allocate(/obj/item/organ/cyberimp/cyberware/cargo_cavity) + TEST_ASSERT(stash.Insert(subject, special = TRUE), "Cargo Cavity staging insert was refused") + var/obj/item/organ/cyberimp/chest/reviver/printable = allocate(/obj/item/organ/cyberimp/chest/reviver) + TEST_ASSERT(printable.Insert(subject, special = TRUE), "Reviver implant staging insert was refused") + var/obj/item/organ/cyberimp/cyberware/dermal_mesh/weave = allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh) + TEST_ASSERT(weave.Insert(subject, special = TRUE), "Dermal Mesh staging insert was refused") + var/datum/component/cyberware/weave_chrome = weave.GetComponent(/datum/component/cyberware) + weave_chrome.start_emp_reboot() + TEST_ASSERT(weave.organ_flags & ORGAN_FAILING, "Test fixture: an EMP didn't knock the weave offline") + + // The report: one entry per visible signature, nothing hidden, the + // printable augment unrated and grey, the EMP'd weave offline. + var/list/report = cyberware_scan_report(subject, 2) + TEST_ASSERT_EQUAL(report["count"], 2, "The report miscounted the visible hardware") + TEST_ASSERT_EQUAL(length(report["entries"]), length(cyberware_scannable_hardware(subject)), "The report's entries don't match the scannable hardware") + var/list/reviver_entry + var/list/weave_entry + for(var/list/entry as anything in report["entries"]) + TEST_ASSERT(entry["name"] != stash.name, "The report listed the ORGAN_HIDDEN Cargo Cavity") + if(entry["name"] == printable.name) + reviver_entry = entry + if(entry["name"] == weave.name) + weave_entry = entry + TEST_ASSERT_NOTNULL(reviver_entry, "The report dropped the printable reviver") + TEST_ASSERT(!reviver_entry["rated"], "The report rated a printable augment as parlor chrome") + TEST_ASSERT_EQUAL(reviver_entry["color"], "#8fa1a8", "An unrated augment didn't get the unrated colour") + TEST_ASSERT_NOTNULL(weave_entry, "The report dropped the Dermal Mesh") + TEST_ASSERT(weave_entry["offline"], "An EMP'd weave didn't read as offline") + TEST_ASSERT_EQUAL(weave_entry["tier"], 1, "The weave lost its tier") + TEST_ASSERT_EQUAL(weave_entry["label"], "Dermal Mesh weave", "The label kept the name's formatting macro") + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/blade = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + TEST_ASSERT_EQUAL(cyberware_scan_label(blade), "Mantis Blade housing", "A paired arm piece kept its side in the label") + + // Silhouette resolution counts the same signatures and resolves none of them. + var/list/blurred = cyberware_scan_report(subject, 1) + TEST_ASSERT_EQUAL(length(blurred["entries"]), 2, "A silhouette report miscounted") + for(var/list/entry as anything in blurred["entries"]) + TEST_ASSERT(isnull(entry["label"]) && isnull(entry["icon"]), "A silhouette report named or pictured a piece it shouldn't resolve") + + // A read draws a readout: one socket and one name line per entry, every + // image hung off the subject (never through walls) and deaf to clicks. + TEST_ASSERT(read.PreActivate(subject), "The chrome read didn't run on a subject in reach") + var/datum/chrome_readout/first = read.current_readout + TEST_ASSERT_NOTNULL(first, "A read left no readout on the action") + TEST_ASSERT_EQUAL(first.mode, "itemized", "Deadeye optics drew the wrong look") + TEST_ASSERT_EQUAL(length(first.sockets), 2, "The readout drew the wrong number of sockets") + TEST_ASSERT_EQUAL(length(first.name_lines), 2, "The readout drew the wrong number of names") + TEST_ASSERT_NULL(first.shown_to, "A clientless reader was handed images") + for(var/image/drawn as anything in first.images) + TEST_ASSERT_EQUAL(drawn.loc, subject, "A readout image hangs off something other than the subject") + TEST_ASSERT_EQUAL(drawn.mouse_opacity, MOUSE_OPACITY_TRANSPARENT, "A readout image takes clicks meant for the floor") + + // A new read replaces the old one. + read.ResetCooldown() + TEST_ASSERT(read.PreActivate(subject), "A second read didn't run") + TEST_ASSERT(QDELETED(first), "A second read left the first readout up") + var/datum/chrome_readout/readout = read.current_readout + TEST_ASSERT(readout && readout != first, "A second read didn't draw a new readout") + + // Each way it ends early. + SEND_SIGNAL(reader, COMSIG_MOB_LOGOUT) + TEST_ASSERT(QDELETED(readout), "The readout outlived its reader logging out") + TEST_ASSERT_NULL(read.current_readout, "The action held on to a readout that had ended") + + read.PreActivate(subject) + readout = read.current_readout + SEND_SIGNAL(subject, COMSIG_MOVABLE_Z_CHANGED, null, null, TRUE) + TEST_ASSERT(QDELETED(readout), "The readout outlived its subject changing z") + + read.PreActivate(subject) + readout = read.current_readout + optics.Remove(reader, special = TRUE) + TEST_ASSERT(QDELETED(readout), "The readout outlived the optics that drew it") + TEST_ASSERT(optics.Insert(reader, special = TRUE), "The optics wouldn't go back in") + + var/mob/living/carbon/human/doomed = allocate(/mob/living/carbon/human/consistent) + TEST_ASSERT(read.PreActivate(doomed), "The chrome read didn't run on a bare body") + readout = read.current_readout + TEST_ASSERT_EQUAL(readout.mode, "clean", "A body with no hardware drew the wrong look") + TEST_ASSERT_EQUAL(length(readout.sockets), 0, "A body with no hardware drew sockets") + qdel(doomed) + TEST_ASSERT(QDELETED(readout), "The readout outlived its subject") + + // Ghostskin: the lock breaks. No sockets, no names, and it stays on the + // turf where the lock was tried instead of following the subject. + ADD_TRAIT(subject, "cyber_camo", "chrome_read_overlay_test") + TEST_ASSERT(read.PreActivate(subject), "The chrome read didn't run on a camouflaged subject") + readout = read.current_readout + TEST_ASSERT_EQUAL(readout.mode, "scatter", "Ghostskin didn't scatter the readout") + TEST_ASSERT_EQUAL(length(readout.sockets), 0, "A scattered readout drew sockets") + TEST_ASSERT_EQUAL(length(readout.name_lines), 0, "A scattered readout named hardware") + for(var/image/drawn as anything in readout.images) + TEST_ASSERT_EQUAL(drawn.loc, get_turf(subject), "A scattered readout image follows the camouflaged subject") + REMOVE_TRAIT(subject, "cyber_camo", "chrome_read_overlay_test") + + // Street optics: a socket per signature, and not one name. + var/mob/living/carbon/human/street_reader = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/eyes/robotic/cyberware/nightshade/street_optics = allocate(/obj/item/organ/eyes/robotic/cyberware/nightshade) + TEST_ASSERT(street_optics.Insert(street_reader, special = TRUE), "Nightshade staging insert was refused") + var/datum/action/cooldown/cyberware/chrome_read/street_read = locate() in street_optics.actions + TEST_ASSERT(street_read.PreActivate(subject), "The street read didn't run") + readout = street_read.current_readout + TEST_ASSERT_EQUAL(readout.mode, "silhouette", "Nightshade optics drew the wrong look") + TEST_ASSERT_EQUAL(length(readout.sockets), 2, "A silhouette readout didn't draw a socket per signature") + TEST_ASSERT_EQUAL(length(readout.name_lines), 0, "A silhouette readout named hardware") + +/// Camo line: the street weave fades its bearer but never takes the +/// cyber_camo trait (NPC targeting and chrome reads key on it, so it fools +/// players only), while the full Ghostskin keeps both. They share the skin +/// slot, so the upgrade evicts the street weave and drops its field. +/// Literals: trait is TRAIT_CYBER_CAMO ("cyber_camo"), alphas are 60 street +/// and 40 full, times are in deciseconds (70 = 7 s), tier 2 = CYBERWARE_TIER_2. +/datum/unit_test/voidcrew_cyberware_camo_line + +/datum/unit_test/voidcrew_cyberware_camo_line/Run() + var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/ghostskin/street/street = allocate(/obj/item/organ/cyberimp/cyberware/ghostskin/street) + TEST_ASSERT_EQUAL(street.chrome_load, 2, "The street camo weave's load drifted") + TEST_ASSERT_EQUAL(street.tier, 2, "The street camo weave left tier 2") + TEST_ASSERT_EQUAL(street.field_duration, 70, "The street camo weave's field duration drifted") + TEST_ASSERT(!street.hides_from_mobs, "The street camo weave hides its bearer from mobs") + TEST_ASSERT(street.Insert(lab_rat, special = TRUE), "Street weave staging insert was refused") + street.engage_camo(lab_rat) + TEST_ASSERT(street.camo_active, "The street weave's field never came up") + TEST_ASSERT_EQUAL(lab_rat.alpha, 60, "The street weave faded its bearer to the wrong alpha") + TEST_ASSERT(!HAS_TRAIT(lab_rat, "cyber_camo"), "The street weave granted the mob-hiding camo trait") + + // The full weave is unchanged: trait, alpha 40, ten seconds. + var/obj/item/organ/cyberimp/cyberware/ghostskin/full = allocate(/obj/item/organ/cyberimp/cyberware/ghostskin) + TEST_ASSERT(full.Insert(lab_rat, special = TRUE), "Ghostskin staging insert was refused") + TEST_ASSERT(!street.camo_active, "Evicting the street weave left its field up") + TEST_ASSERT(!HAS_TRAIT(lab_rat, "cyber_camo"), "Nothing should hold the camo trait between fields") + TEST_ASSERT_EQUAL(full.field_duration, 100, "Ghostskin's field duration drifted") + TEST_ASSERT(full.hides_from_mobs, "Ghostskin stopped hiding its bearer from mobs") + full.engage_camo(lab_rat) + TEST_ASSERT(HAS_TRAIT(lab_rat, "cyber_camo"), "Ghostskin stopped granting the camo trait") + TEST_ASSERT_EQUAL(lab_rat.alpha, 40, "Ghostskin faded its bearer to the wrong alpha") + full.break_camo(lab_rat, silent = TRUE) + TEST_ASSERT(!HAS_TRAIT(lab_rat, "cyber_camo"), "Ghostskin left the camo trait behind when its field dropped") + /// (e) Second Wind Bladder: blocks suffocation while reserve lasts, runs /// dry, and refills in breathable air. /// @@ -259,6 +470,60 @@ TEST_ASSERT(!bladder.engaged, "Second Wind stayed engaged in breathable air") vacuum.ChangeTurf(floor_type) +/// A player's Redline burn wears a red outline for the whole window, and it goes out when the bearer dies +/datum/unit_test/voidcrew_cyberware_redline_outline + +/datum/unit_test/voidcrew_cyberware_redline_outline/Run() + var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/redline/core = allocate(/obj/item/organ/cyberimp/cyberware/redline) + TEST_ASSERT(core.Insert(lab_rat, special = TRUE), "Redline staging insert was refused") + var/datum/action/cooldown/cyberware/redline_burn/burn = locate() in core.actions // chrome abilities never join mob.actions (chrome_hud.dm) + TEST_ASSERT_NOTNULL(burn, "The Redline core gave no burn action") + burn.Trigger() + TEST_ASSERT_NOTNULL(lab_rat.has_status_effect(/datum/status_effect/cyberware_redline_window), "Pressing the burn opened no window") + TEST_ASSERT_NOTNULL(lab_rat.get_filter("cyberware_redline_window"), "A player's burn has no red outline") + lab_rat.death() + TEST_ASSERT_NULL(lab_rat.get_filter("cyberware_redline_window"), "The red outline stayed on a dead bearer") + lab_rat.remove_status_effect(/datum/status_effect/cyberware_redline_window) + TEST_ASSERT_NULL(lab_rat.get_filter("cyberware_redline_window"), "The red outline outlasted the window") + +/// Splice buys burnt-out chrome as scrap, for less than the cheapest piece he sells for credits +/datum/unit_test/voidcrew_cyberware_burnt_chrome_sale + +/datum/unit_test/voidcrew_cyberware_burnt_chrome_sale/Run() + var/mob/living/carbon/human/seller = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/card/id/id = allocate(/obj/item/card/id) + var/datum/bank_account/account = allocate(/datum/bank_account, "Burnt chrome test", null, 1, FALSE) + id.registered_account = account + TEST_ASSERT(seller.put_in_hands(id), "The seller could not hold their ID") + var/datum/shop_buyback/burnt_chrome/ledger = allocate(/datum/shop_buyback/burnt_chrome) + ledger.demand = 2 + var/datum/outpost_shop/vendor/ripperdoc/splice = allocate(/datum/outpost_shop/vendor/ripperdoc) + var/takes_burnt = FALSE + for(var/datum/shop_buyback/intake as anything in splice.buybacks) + if(intake.type == ledger.type) + takes_burnt = TRUE + TEST_ASSERT(takes_burnt, "Splice doesn't take burnt-out chrome") + var/datum/outpost_shop/vendor/street_doc/ratchet = allocate(/datum/outpost_shop/vendor/street_doc) + var/ratchet_takes_burnt = FALSE + for(var/datum/shop_buyback/intake as anything in ratchet.buybacks) + if(istype(intake, /datum/shop_buyback/burnt_chrome)) + ratchet_takes_burnt = TRUE + TEST_ASSERT(ratchet_takes_burnt, "Ratchet doesn't take burnt-out chrome") + for(var/datum/shop_sku/sku as anything in subtypesof(/datum/shop_sku/ripperdoc)) + var/price = initial(sku.price_credits) + if(price > 0) + TEST_ASSERT(ledger.pay_credits * 4 < price, "Burnt-out chrome pays [ledger.pay_credits], near [sku]'s [price] credit price") + + var/obj/item/organ/cyberimp/cyberware/scrapper/knuckles = allocate(/obj/item/organ/cyberimp/cyberware/scrapper, run_loc_floor_bottom_left) + var/obj/item/burnt_chrome/husk = allocate(/obj/item/burnt_chrome, run_loc_floor_bottom_left, knuckles) + TEST_ASSERT(seller.put_in_hands(husk), "The seller could not hold the burnt-out chrome") + var/balance = account.account_balance + TEST_ASSERT(ledger.try_sell(seller, null, TRUE), "Splice refused burnt-out chrome") + TEST_ASSERT(QDELETED(husk), "The sold burnt-out chrome wasn't taken") + TEST_ASSERT_EQUAL(account.account_balance, balance + ledger.pay_credits, "Burnt-out chrome paid the wrong amount") + TEST_ASSERT_EQUAL(ledger.demand, 1, "The sale used no demand") + /// (g) The Chrome Cradle console: every reachable piece files into exactly one /// rack group, and the highlight projects its own swap before anything commits. /// The interface reads all of this straight out of ui_data(), so a silent @@ -336,6 +601,49 @@ TEST_ASSERT(paired["vouchers"] > 0, "[half] indexed with no voucher price") TEST_ASSERT(paired["paired"], "[half] came out of a pair case without the paired flag") +/// (h2) Ratchet, the street doc at Quartermain: credit sales only, every piece +/// he sells has a cradle quote that matches his shelf, his ledger never pays +/// vouchers, and on the map he stands in view of his own cradle, so the install +/// patter (play_ripperdoc_bark) comes out of his mouth. +/datum/unit_test/voidcrew_street_doc + +/datum/unit_test/voidcrew_street_doc/Run() + build_cyberware_price_index() + var/datum/outpost_shop/vendor/street_doc/shop = allocate(/datum/outpost_shop/vendor/street_doc) + TEST_ASSERT(length(shop.skus), "The street doc has nothing on his shelf") + for(var/datum/shop_sku/sku as anything in shop.skus) + TEST_ASSERT(istype(sku, /datum/shop_sku/ripperdoc), "[sku.type] at the street doc is not ripperdoc stock, so the cradle never quotes it") + TEST_ASSERT(sku.price_credits > 0 && !sku.price_vouchers, "[sku.type] at the street doc is not a credit sale") + if(!ispath(sku.item_path, /obj/item/organ)) + continue + var/list/quote = GLOB.cyberware_price_index[sku.item_path] + TEST_ASSERT(!isnull(quote), "The cradle has no price for [sku.item_path], which the street doc sells") + if(quote) + TEST_ASSERT_EQUAL(quote["credits"], sku.price_credits, "The cradle quotes [sku.item_path] differently from the street doc's shelf") + TEST_ASSERT(length(shop.buybacks), "The street doc buys nothing back") + for(var/datum/shop_buyback/buyback as anything in shop.buybacks) + TEST_ASSERT(buyback.pay_credits > 0 && !buyback.pay_vouchers, "[buyback.type] at the street doc pays vouchers for chrome a ship can buy") + + var/obj/structure/overmap/trader_outpost/outpost = allocate(/obj/structure/overmap/trader_outpost/outfitter) + TEST_ASSERT(outpost.load_level(), "Quartermain's interior failed to load") + var/turf/bottom_left = outpost.template_bottom_left + var/turf/top_right = locate(bottom_left.x + outpost.outpost_template.width - 1, bottom_left.y + outpost.outpost_template.height - 1, bottom_left.z) + var/list/docs = list() + var/list/cradles = list() + for(var/turf/interior as anything in block(bottom_left, top_right)) + for(var/mob/living/basic/outpost_trader/ripperdoc/street_doc/doc in interior) + docs += doc + for(var/obj/machinery/chrome_cradle/cradle in interior) + cradles += cradle + TEST_ASSERT_EQUAL(length(docs), 1, "Quartermain has [length(docs)] street docs, not one") + TEST_ASSERT_EQUAL(length(cradles), 1, "Quartermain has [length(cradles)] chrome cradles, not one") + var/mob/living/basic/outpost_trader/ripperdoc/street_doc/ratchet = docs[1] + var/obj/machinery/chrome_cradle/rig = cradles[1] + TEST_ASSERT(istype(ratchet.shop, /datum/outpost_shop/vendor/street_doc), "The street doc is not running his own counter") + TEST_ASSERT(ratchet in view(7, rig), "The street doc can't see his cradle, so installs there run without him") + TEST_ASSERT_EQUAL(get_trader_outpost_for_turf(get_turf(rig)), outpost, "Quartermain's cradle does not know which outpost it is in") + qdel(outpost) + /// Recheck the complete final installation after the delay, before touching incumbents. /datum/unit_test/voidcrew_cradle_installed_capacity @@ -541,8 +849,9 @@ // the cursor and needs a client, so it is deliberately not what we call. var/obj/item/organ/eyes/robotic/cyberware/nightshade/optics = allocate(/obj/item/organ/eyes/robotic/cyberware/nightshade) TEST_ASSERT(optics.Insert(lab_rat, special = TRUE), "Nightshade staging insert was refused") - var/datum/action/cooldown/cyberware/chrome_read/read = locate(/datum/action/cooldown/cyberware/chrome_read) in lab_rat.actions - TEST_ASSERT(!isnull(read), "The optics never granted their chrome read action to the body") + // Chrome abilities have no HUD button, so they never join lab_rat.actions (chrome_hud.dm). + var/datum/action/cooldown/cyberware/chrome_read/read = locate(/datum/action/cooldown/cyberware/chrome_read) in optics.actions + TEST_ASSERT(read?.owner == lab_rat, "The optics never granted their chrome read action to the body") TEST_ASSERT(!lab_rat.is_blind(), "Test fixture: the staged optics left the body blind, so the read could never run") var/before = ink.pulse_count @@ -887,6 +1196,60 @@ TEST_ASSERT(governor.Insert(patient, TRUE), "Governor couldn't replace an OS") TEST_ASSERT(!cascade.owner && governor.owner == patient, "Chest OS hardware stacked") +/// The Governor line: each rung gives its own headroom at no load in the shared +/// OS slot, and swapping down never leaves the body quietly over its new ceiling. +/datum/unit_test/voidcrew_governor_line + +/datum/unit_test/voidcrew_governor_line/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/governor_delete/delete = allocate(/obj/item/organ/cyberimp/cyberware/governor_delete) + var/obj/item/organ/cyberimp/cyberware/governor_delete/milspec/bypass = allocate(/obj/item/organ/cyberimp/cyberware/governor_delete/milspec) + var/obj/item/organ/cyberimp/cyberware/governor_delete/street/patch = allocate(/obj/item/organ/cyberimp/cyberware/governor_delete/street) + // ware, bonus, tier (the defines aren't visible from here: CYBERWARE_TIER_2/3/4) + var/list/rungs = list( + list(patch, 5, 2), + list(bypass, 10, 3), + list(delete, 15, 4), + ) + for(var/list/rung as anything in rungs) + var/obj/item/organ/cyberimp/cyberware/ware = rung[1] + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + TEST_ASSERT_EQUAL(ware.slot, delete.slot, "[ware.type] isn't in the Governor's OS slot") + TEST_ASSERT_EQUAL(chrome.chrome_load, 0, "[ware.type] costs load, a Governor never does") + TEST_ASSERT_EQUAL(chrome.capacity_bonus, rung[2], "[ware.type] has the wrong capacity bonus") + TEST_ASSERT_EQUAL(chrome.tier, rung[3], "[ware.type] has the wrong tier") + TEST_ASSERT(ware.Insert(patient, TRUE), "[ware.type] fixture failed to install") + TEST_ASSERT_EQUAL(get_chrome_capacity(patient), 20 + rung[2], "[ware.type] gave the wrong capacity") + TEST_ASSERT_EQUAL(get_chrome_load(patient), 0, "[ware.type] put load on the body") + // Only the last rung is left in the slot: each install evicted the one before. + TEST_ASSERT(delete.owner == patient && !bypass.owner && !patch.owner, "Governor rungs stacked in the OS slot") + + // Swapping down is gated, not trapped: at a load the lower rung can't hold, the + // swap is refused with the incumbent still online. + var/obj/item/organ/cyberimp/cyberware/test_full_body/bulk = allocate(/obj/item/organ/cyberimp/cyberware/test_full_body) + var/obj/item/organ/cyberimp/cyberware/test_heavy/heavy = allocate(/obj/item/organ/cyberimp/cyberware/test_heavy) + bulk.Insert(patient, TRUE) + heavy.Insert(patient, TRUE) + TEST_ASSERT_EQUAL(get_chrome_load(patient), 35, "Governor line fixture load is wrong") + TEST_ASSERT(!cyberware_insert_check(bypass, patient, TRUE), "35 load fit under the Bypass's 30") + TEST_ASSERT(!cyberware_insert_check(patch, patient, TRUE), "35 load fit under the Patch's 25") + TEST_ASSERT(delete.owner == patient && !(delete.organ_flags & ORGAN_FAILING), "A refused downgrade disturbed the incumbent Governor") + heavy.Remove(patient, TRUE) + TEST_ASSERT(cyberware_insert_check(patch, patient, TRUE), "20 load didn't fit under the Patch's 25") + TEST_ASSERT(cyberware_insert_check(bypass, patient, TRUE), "20 load didn't fit under the Bypass's 30") + heavy.Insert(patient, TRUE) + + // Pulling the Governor is never blocked: everything browns out, and the + // smaller one that goes back in only lifts it once load fits. + var/datum/component/cyberware/bulk_chrome = bulk.GetComponent(/datum/component/cyberware) + TEST_ASSERT(bulk_chrome.is_running(), "35 of 35 browned out") + delete.Remove(patient, TRUE) + TEST_ASSERT(!bulk_chrome.is_running(), "Losing the Governor didn't brown out the over-capacity chrome") + TEST_ASSERT(patch.Insert(patient, TRUE), "The Patch couldn't go in over capacity with special") + TEST_ASSERT(!bulk_chrome.is_running(), "35 load stayed up under the Patch's 25") + heavy.Remove(patient, TRUE) + TEST_ASSERT(bulk_chrome.is_running(), "20 load stayed browned out under the Patch's 25") + /// Every approved exception is checked independently of the table under test. /datum/unit_test/voidcrew_nanite_capacity_costs @@ -1030,6 +1393,62 @@ TEST_ASSERT_EQUAL(get_chrome_load(patient), 16, "Deleting nanites retained installed program costs") TEST_ASSERT_EQUAL(patient.physiology.armor.get_rating(MELEE), bare_armor, "Deleting recovered nanites retained their armor") +/// The Berserk line: street and milspec cores share the Redline's OS slot and +/// retune its one burn through vars, and the Redline core itself is unchanged. +/datum/unit_test/voidcrew_berserk_line + +/datum/unit_test/voidcrew_berserk_line/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/redline/core = allocate(/obj/item/organ/cyberimp/cyberware/redline) + TEST_ASSERT_EQUAL(core.burn_window, 12 SECONDS, "Redline core's window moved") + TEST_ASSERT_EQUAL(core.burn_damage_mult, 0.6, "Redline core's damage multiplier moved") + TEST_ASSERT_EQUAL(core.burn_melee_bonus, 8, "Redline core's punch bonus moved") + TEST_ASSERT(core.burn_stun_immune, "Redline core lost its stun immunity") + TEST_ASSERT_EQUAL(core.burn_roar_range, 5, "Redline core's roar moved") + TEST_ASSERT_EQUAL(core.burn_crash, 5 SECONDS, "Redline core's crash moved") + TEST_ASSERT_EQUAL(core.burn_cooldown, 90 SECONDS, "Redline core's cooldown moved") + TEST_ASSERT_EQUAL(core.chrome_load, 10, "Redline core's load moved") + for(var/model_type in list(/obj/item/organ/cyberimp/cyberware/redline/street, /obj/item/organ/cyberimp/cyberware/redline/milspec)) + var/obj/item/organ/cyberimp/cyberware/redline/model = allocate(model_type) + TEST_ASSERT_EQUAL(model.slot, core.slot, "[model_type] doesn't share the Redline's OS slot") + TEST_ASSERT(model.chrome_load < core.chrome_load, "[model_type] doesn't cost less load than the Redline core") + TEST_ASSERT(model.tier < core.tier, "[model_type] isn't a lower tier than the Redline core") + // The street core cycles as fast as the Redline (final balance pass); no model cycles faster. + TEST_ASSERT(model.burn_window < core.burn_window && model.burn_cooldown >= core.burn_cooldown, "[model_type] isn't a shorter burn, no faster, than the Redline core") + TEST_ASSERT(model.icon_state != core.icon_state && model.aug_overlay != core.aug_overlay, "[model_type] reuses the Redline core's sprite states") + var/obj/item/organ/cyberimp/cyberware/redline/street/street = allocate(/obj/item/organ/cyberimp/cyberware/redline/street) + var/obj/item/organ/cyberimp/cyberware/redline/milspec/milspec = allocate(/obj/item/organ/cyberimp/cyberware/redline/milspec) + for(var/obj/item/organ/cyberimp/cyberware/redline/model as anything in list(street, milspec)) + var/datum/action/cooldown/cyberware/redline_burn/burn = locate() in model.actions + TEST_ASSERT_NOTNULL(burn, "[model.type] has no Redline Burn button") + TEST_ASSERT_EQUAL(burn.cooldown_time, model.burn_cooldown, "[model.type]'s button doesn't use the core's cooldown") + // The street burn: no stun immunity, its own damage cut, window and crash length. + patient.apply_status_effect(/datum/status_effect/cyberware_redline_window, street) + var/datum/status_effect/cyberware_redline_window/window = patient.has_status_effect(/datum/status_effect/cyberware_redline_window) + TEST_ASSERT_NOTNULL(window, "The street core didn't open a burn window") + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_STUNIMMUNE), "The street burn granted stun immunity") + TEST_ASSERT_EQUAL(patient.physiology.brute_mod, 0.8, "The street burn didn't cut brute by its own multiplier") + TEST_ASSERT_EQUAL(window.duration - world.time, street.burn_window, "The street burn ignored its window length") + patient.remove_status_effect(/datum/status_effect/cyberware_redline_window) + TEST_ASSERT_EQUAL(patient.physiology.brute_mod, 1, "The street burn left a damage multiplier behind") + var/datum/status_effect/cyberware_redline_crash/crash = patient.has_status_effect(/datum/status_effect/cyberware_redline_crash) + TEST_ASSERT_NOTNULL(crash, "The street burn didn't roll into a crash") + TEST_ASSERT(crash.duration - world.time <= street.burn_crash && crash.duration - world.time > street.burn_crash - 1 SECONDS, "The street crash ignored its length") + patient.remove_status_effect(/datum/status_effect/cyberware_redline_crash) + // The milspec burn holds stuns off, and drops them cleanly. + patient.apply_status_effect(/datum/status_effect/cyberware_redline_window, milspec) + TEST_ASSERT(HAS_TRAIT(patient, TRAIT_STUNIMMUNE), "The milspec burn didn't grant stun immunity") + TEST_ASSERT_EQUAL(patient.physiology.brute_mod, 0.7, "The milspec burn didn't cut brute by its own multiplier") + patient.remove_status_effect(/datum/status_effect/cyberware_redline_window) + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_STUNIMMUNE), "The milspec burn kept stun immunity after it ended") + TEST_ASSERT_EQUAL(patient.physiology.brute_mod, 1, "The milspec burn left a damage multiplier behind") + patient.remove_status_effect(/datum/status_effect/cyberware_redline_crash) + // With no core named the window runs the Redline core's own numbers. + patient.apply_status_effect(/datum/status_effect/cyberware_redline_window) + TEST_ASSERT_EQUAL(patient.physiology.brute_mod, 0.6, "A bare burn window didn't use the Redline core's numbers") + patient.remove_status_effect(/datum/status_effect/cyberware_redline_window) + patient.remove_status_effect(/datum/status_effect/cyberware_redline_crash) + /datum/unit_test/voidcrew_cyberware_running_gates /datum/unit_test/voidcrew_cyberware_running_gates/Run() @@ -1127,3 +1546,228 @@ node.Remove(patient, TRUE) node.Insert(patient, TRUE) TEST_ASSERT_EQUAL(node.jolt_cooldown, ready_at, "Removal/reinstall reset Lazarus cooldown") + +/// The Cascade line: the street and service models share the lattice's OS slot, +/// carry their own numbers onto the window and crash, and the original lattice +/// keeps every one of its. +/datum/unit_test/voidcrew_cascade_line + +/datum/unit_test/voidcrew_cascade_line/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = allocate(/obj/item/organ/cyberimp/cyberware/cascade) + var/obj/item/organ/cyberimp/cyberware/cascade/street/street = allocate(/obj/item/organ/cyberimp/cyberware/cascade/street) + var/obj/item/organ/cyberimp/cyberware/cascade/milspec/milspec = allocate(/obj/item/organ/cyberimp/cyberware/cascade/milspec) + TEST_ASSERT_EQUAL(street.slot, lattice.slot, "The street rig isn't in the lattice's OS slot") + TEST_ASSERT_EQUAL(milspec.slot, lattice.slot, "The service lattice isn't in the lattice's OS slot") + TEST_ASSERT(street.chrome_load < milspec.chrome_load && milspec.chrome_load < lattice.chrome_load, "The Cascade line's loads don't climb") + TEST_ASSERT(street.Insert(patient, TRUE), "Street fixture failed") + TEST_ASSERT(milspec.Insert(patient, TRUE), "Service fixture failed") + TEST_ASSERT(!street.owner && milspec.owner == patient, "Two Cascade models shared the OS slot") + + // The original lattice runs on its original numbers. + patient.apply_status_effect(/datum/status_effect/cyberware_cascade_window, lattice) + var/datum/status_effect/cyberware_cascade_window/window = patient.has_status_effect(/datum/status_effect/cyberware_cascade_window) + TEST_ASSERT_NOTNULL(window, "The lattice didn't open a window") + TEST_ASSERT_EQUAL(window.dodge_chance, 60, "The lattice window lost its dodge") + TEST_ASSERT_EQUAL(window.nextmove_modifier(), 0.5, "The lattice window lost its melee boost") + TEST_ASSERT_EQUAL(window.duration, world.time + 8 SECONDS, "The lattice window lost its length") + TEST_ASSERT(patient.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_cascade), "The lattice window lost its gait") + patient.remove_status_effect(/datum/status_effect/cyberware_cascade_window) + var/datum/status_effect/cyberware_cascade_crash/crash = patient.has_status_effect(/datum/status_effect/cyberware_cascade_crash) + TEST_ASSERT_NOTNULL(crash, "The lattice window ended without a crash") + TEST_ASSERT_EQUAL(crash.duration, world.time + 6 SECONDS, "The lattice crash lost its length") + TEST_ASSERT_EQUAL(patient.getStaminaLoss(), 80, "The lattice crash lost its stamina dump") + patient.remove_status_effect(/datum/status_effect/cyberware_cascade_crash) + patient.setStaminaLoss(0) + + // The street rig runs on its own. + patient.apply_status_effect(/datum/status_effect/cyberware_cascade_window, street) + window = patient.has_status_effect(/datum/status_effect/cyberware_cascade_window) + TEST_ASSERT_NOTNULL(window, "The street rig didn't open a window") + TEST_ASSERT_EQUAL(window.dodge_chance, 30, "The street window kept the wrong dodge") + TEST_ASSERT_EQUAL(window.nextmove_modifier(), 0.75, "The street window kept the wrong melee boost") + TEST_ASSERT_EQUAL(window.duration, world.time + 6 SECONDS, "The street window kept the wrong length") + TEST_ASSERT(patient.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_cascade/street), "The street window lost its gait") + TEST_ASSERT(!patient.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_cascade), "The street window kept the lattice's gait") + patient.remove_status_effect(/datum/status_effect/cyberware_cascade_window) + TEST_ASSERT(!patient.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_cascade/street), "The street gait outlived its window") + crash = patient.has_status_effect(/datum/status_effect/cyberware_cascade_crash) + TEST_ASSERT_NOTNULL(crash, "The street window ended without a crash") + TEST_ASSERT_EQUAL(crash.duration, world.time + 8 SECONDS, "The street crash kept the wrong length") + TEST_ASSERT_EQUAL(crash.crash_stamina, 90, "The street crash kept the wrong stamina dump") + TEST_ASSERT_EQUAL(patient.getStaminaLoss(), 90, "The street crash didn't dump its stamina") + TEST_ASSERT(!HAS_TRAIT_FROM(patient, TRAIT_INCAPACITATED, STAMINA), "The street crash floored its user") + patient.remove_status_effect(/datum/status_effect/cyberware_cascade_crash) + + // What Splice quotes for the two lesser models. + build_cyberware_price_index() + var/list/street_price = GLOB.cyberware_price_index[street.type] + var/list/milspec_price = GLOB.cyberware_price_index[milspec.type] + TEST_ASSERT(street_price && street_price["credits"] > 0 && !street_price["vouchers"], "The street rig isn't a credit-priced SKU") + TEST_ASSERT(milspec_price && milspec_price["vouchers"] > 0, "The service lattice isn't a voucher-priced SKU") + +/// A reflex window dodges blows through tg's own check_block(): a dodged knife +/// is a real miss that deals nothing. It never dodges once the bearer is down, +/// never a grab, and never in the crash. The window also raises the crit roll +/// of the bearer's own hits on a standing target, and only during the window. +/datum/unit_test/voidcrew_cascade_blow_dodge + +/datum/unit_test/voidcrew_cascade_blow_dodge/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/attacker = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = allocate(/obj/item/organ/cyberimp/cyberware/cascade) + var/obj/item/organ/cyberimp/cyberware/cascade/milspec/milspec = allocate(/obj/item/organ/cyberimp/cyberware/cascade/milspec) + var/obj/item/organ/cyberimp/cyberware/cascade/street/street = allocate(/obj/item/organ/cyberimp/cyberware/cascade/street) + var/obj/item/knife/kitchen/knife = allocate(/obj/item/knife/kitchen) + TEST_ASSERT(attacker.put_in_active_hand(knife), "Attacker fixture failed") + attacker.set_combat_mode(TRUE) + attacker.zone_selected = BODY_ZONE_CHEST + + TEST_ASSERT_EQUAL(street.window_dodge, 30, "The street rig dodges at the wrong chance") + TEST_ASSERT_EQUAL(milspec.window_dodge, 45, "The service lattice dodges at the wrong chance") + TEST_ASSERT_EQUAL(lattice.window_dodge, 60, "The lattice dodges at the wrong chance") + TEST_ASSERT(street.window_crit_bonus < milspec.window_crit_bonus && milspec.window_crit_bonus < lattice.window_crit_bonus, "The crit bonus doesn't climb the Cascade line") + + TEST_ASSERT_EQUAL(attacker.hv_crit_attacker_bonus(patient), 0, "A crit bonus with no window open") + attacker.apply_status_effect(/datum/status_effect/cyberware_cascade_window, lattice) + TEST_ASSERT_EQUAL(attacker.hv_crit_attacker_bonus(patient), lattice.window_crit_bonus, "The window didn't raise its bearer's crit roll") + patient.Knockdown(2 SECONDS) + TEST_ASSERT_EQUAL(attacker.hv_crit_attacker_bonus(patient), 0, "The window's crit bonus reached a helpless victim") + patient.SetKnockdown(0) + patient.set_body_position(STANDING_UP) + attacker.remove_status_effect(/datum/status_effect/cyberware_cascade_window) + TEST_ASSERT_EQUAL(attacker.hv_crit_attacker_bonus(patient), 0, "The crit bonus outlived the window") + attacker.remove_status_effect(/datum/status_effect/cyberware_cascade_crash) + attacker.setStaminaLoss(0) + + // The window, forced to always dodge. + patient.apply_status_effect(/datum/status_effect/cyberware_cascade_window, lattice) + var/datum/status_effect/cyberware_cascade_window/window = patient.has_status_effect(/datum/status_effect/cyberware_cascade_window) + TEST_ASSERT_NOTNULL(window, "The lattice didn't open a window") + window.dodge_chance = 100 + TEST_ASSERT_EQUAL(patient.check_block(knife, knife.force, "the [knife]", MELEE_ATTACK), SUCCESSFUL_BLOCK, "The window didn't dodge a knife") + patient.attacked_by(knife, attacker) + TEST_ASSERT_EQUAL(patient.getBruteLoss(), 0, "A dodged knife still cut") + TEST_ASSERT_EQUAL(patient.check_block(attacker, 0, "[attacker]'s grab", UNARMED_ATTACK), FAILED_BLOCK, "The window dodged a grab") + TEST_ASSERT_EQUAL(patient.check_block(knife, knife.force, "the [knife]", PROJECTILE_ATTACK), FAILED_BLOCK, "The blow dodge took a projectile check") + patient.Knockdown(2 SECONDS) + TEST_ASSERT_EQUAL(patient.check_block(knife, knife.force, "the [knife]", MELEE_ATTACK), FAILED_BLOCK, "The window dodged a blow while knocked down") + patient.SetKnockdown(0) + patient.set_body_position(STANDING_UP) + patient.Stun(2 SECONDS) + TEST_ASSERT_EQUAL(patient.check_block(knife, knife.force, "the [knife]", MELEE_ATTACK), FAILED_BLOCK, "The window dodged a blow while stunned") + patient.SetStun(0) + + // The crash dodges nothing. + patient.remove_status_effect(/datum/status_effect/cyberware_cascade_window) + TEST_ASSERT_NOTNULL(patient.has_status_effect(/datum/status_effect/cyberware_cascade_crash), "The window ended without a crash") + TEST_ASSERT_NULL(patient.GetComponent(/datum/component/cyberware_dodge), "The crash kept a dodge source") + for(var/i in 1 to 10) + TEST_ASSERT_EQUAL(patient.check_block(knife, knife.force, "the [knife]", MELEE_ATTACK), FAILED_BLOCK, "The crash dodged a blow") + patient.attacked_by(knife, attacker) + TEST_ASSERT(patient.getBruteLoss() > 0, "A knife in the crash dealt nothing") + +/// The ripperdoc trade-in, the one ledger that takes chrome bought over a +/// counter. No entry may pay more than half the cheapest shelf price of the +/// piece (a special takes at most 30% off, so a bought piece always sells back +/// at a loss), none may buy back a piece any shop sells for vouchers, and none +/// may reach into the seller's body. Every other ledger and the cargo shuttle +/// still refuse the same piece once it is pulled. +/datum/unit_test/voidcrew_ripperdoc_resale + +/datum/unit_test/voidcrew_ripperdoc_resale/Run() + // Every installable piece any shelf sells: its lowest credit price for one + // piece, and whether any shelf asks vouchers for it. + var/list/lowest_credits = list() + var/list/voucher_sold = list() + for(var/datum/shop_sku/sku_type as anything in subtypesof(/datum/shop_sku)) + var/item_path = initial(sku_type.item_path) + var/list/pieces = list() + if(ispath(item_path, /obj/item/organ)) + pieces += item_path + else if(ispath(item_path, /obj/item/cyberware_pair_case) || ispath(item_path, /obj/item/storage/case/cyberware)) + // A cased set sells every piece inside it for the one price. + var/obj/item/sample = new item_path(null) + for(var/obj/item/organ/held in sample.contents) + pieces += held.type + for(var/atom/movable/packed as anything in sample.contents.Copy()) + qdel(packed) + qdel(sample) + if(!length(pieces)) + continue + var/credits = initial(sku_type.price_credits) + for(var/piece in pieces) + if(initial(sku_type.price_vouchers) > 0) + voucher_sold[piece] = TRUE + if(credits > 0) + var/each = credits / length(pieces) + lowest_credits[piece] = isnull(lowest_credits[piece]) ? each : min(lowest_credits[piece], each) + + var/list/ledger_types = typesof(/datum/shop_buyback/ripperdoc) - /datum/shop_buyback/ripperdoc + TEST_ASSERT(length(ledger_types), "There is no ripperdoc trade-in") + for(var/buyback_type in ledger_types) + var/datum/shop_buyback/ledger = allocate(buyback_type) + TEST_ASSERT(ledger.takes_shop_stock(), "[buyback_type] refuses chrome bought at a counter") + TEST_ASSERT(ledger.pay_credits > 0 && !ledger.pay_vouchers, "[buyback_type] does not pay in credits alone") + var/matched = 0 + for(var/piece in lowest_credits | voucher_sold) + if(ledger.match_subtypes ? !ispath(piece, ledger.item_path) : piece != ledger.item_path) + continue + matched++ + TEST_ASSERT(!voucher_sold[piece], "[buyback_type] buys back [piece], which a shop sells for vouchers") + var/lowest = lowest_credits[piece] + if(isnull(lowest)) + continue + TEST_ASSERT(ledger.pay_credits * 2 <= lowest, "[buyback_type] pays [ledger.pay_credits] cr for [piece], more than half its lowest shelf price ([lowest] cr)") + // The deepest special (shop.dm roll_special, 30% off) still loses money. + TEST_ASSERT(ledger.pay_credits < max(5, round(lowest * 70 / 100, 5)), "[buyback_type] pays more for [piece] than it costs on special") + TEST_ASSERT(matched, "[buyback_type] buys back a piece no shelf sells") + + // One street core, bought, installed, pulled and sold back. + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/card/id/id = allocate(/obj/item/card/id) + id.registered_account = allocate(/datum/bank_account, "Ripperdoc resale test", null, 1, FALSE) + patient.put_in_active_hand(id) + var/datum/bank_account/account = id.registered_account + var/datum/shop_sku/sku = allocate(/datum/shop_sku/ripperdoc/redline_street) + var/obj/item/organ/cyberimp/cyberware/redline/street/core = sku.dispense(patient, null) + TEST_ASSERT(istype(core), "The street core's shelf handed over [core]") + TEST_ASSERT(is_trader_good(core), "Chrome bought at the counter came without the shop mark") + patient.dropItemToGround(core) + TEST_ASSERT(core.Insert(patient, special = TRUE), "The bought core would not install") + + var/datum/shop_buyback/splice = allocate(/datum/shop_buyback/ripperdoc/redline_street) + var/datum/shop_buyback/ratchet = allocate(/datum/shop_buyback/ripperdoc/redline_street/street_doc) + splice.demand = 2 + var/balance = account.account_balance + TEST_ASSERT_EQUAL(splice.count_carried_units(patient), 0, "The trade-in offered to buy a core still installed in its owner") + TEST_ASSERT(!splice.try_sell(patient, null), "The trade-in bought a core out of a living chest") + TEST_ASSERT(!QDELETED(core) && core.owner == patient, "A trade-in took chrome out of its owner") + TEST_ASSERT_EQUAL(account.account_balance, balance, "A refused trade-in paid out") + + core.Remove(patient, special = TRUE) + patient.put_in_hands(core) + TEST_ASSERT(is_trader_good(core), "Pulling the core wiped its shop mark") + + // Nobody else buys it: a plain ledger for this exact piece, every other + // ledger in the game, or the cargo shuttle. + var/datum/shop_buyback/any_ledger = allocate(/datum/shop_buyback) + any_ledger.item_path = core.type + any_ledger.pay_credits = 10 + TEST_ASSERT(!any_ledger.matches(core), "A plain ledger for this very core bought it") + for(var/buyback_type in subtypesof(/datum/shop_buyback)) + if(ispath(buyback_type, /datum/shop_buyback/ripperdoc)) + continue + var/datum/shop_buyback/other = allocate(buyback_type) + if(other.item_path) + TEST_ASSERT(!other.matches(core), "[buyback_type] bought back chrome sold at a counter") + var/datum/export/export = allocate(/datum/export) + export.export_types = typecacheof(list(core.type)) + TEST_ASSERT(!export.applies_to(core), "Cargo would export chrome sold at a counter") + + // Both ripperdocs take it, at half list. + TEST_ASSERT(ratchet.matches(core), "The street doc won't take back chrome a ripperdoc sold") + TEST_ASSERT(splice.try_sell(patient, null), "Splice won't take back chrome a ripperdoc sold") + TEST_ASSERT(QDELETED(core), "The sold core stayed with the seller") + TEST_ASSERT_EQUAL(account.account_balance, balance + splice.pay_credits, "The trade-in paid the wrong amount") + TEST_ASSERT_EQUAL(splice.pay_credits * 2, sku.price_credits, "The street core does not sell back at half list") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_anim.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_anim.dm new file mode 100644 index 00000000000..2ea0ee36e39 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_anim.dm @@ -0,0 +1,243 @@ +/** + * # Chrome animations + * + * The animations only draw, but they leave things on a body while they play: + * holders in vis_contents, filters, worn looks and pending frames. These check + * that each animation puts them on and that they come off again when it is cut + * short: the blade stowed, the chrome pulled, the field broken, the bearer dead. + * + * Unit-test files compile before voidcrew/_DEFINES/ and the module's own + * defines are local, so looks and filter names are literals here. + */ + +/// TRUE if any chrome animation holder is still drawn on [bearer]. +/proc/voidcrew_test_has_chrome_anim(atom/movable/bearer) + return !!(locate(/obj/effect/abstract/cyberware_anim) in bearer.vis_contents) + +/// Mantis: the swing rides the bearer, the fold replaces the unfold, and +/// pulling the housing takes the swing and the folded-housing wait with it. +/datum/unit_test/voidcrew_cyberware_anim_blade + +/datum/unit_test/voidcrew_cyberware_anim_blade/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + TEST_ASSERT(housing.Insert(bearer, special = TRUE), "Test fixture: Mantis housing insert refused") + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = housing.contents[1] + + housing.Extend(blade) + TEST_ASSERT(bearer.is_holding(blade), "Test fixture: the blade never reached a hand") + var/obj/effect/abstract/cyberware_anim/unfold = housing.blade_anim() + TEST_ASSERT(unfold && (unfold in bearer.vis_contents), "The blade swing didn't play on the bearer") + TEST_ASSERT_EQUAL(unfold.icon_state, "mantis_unfold_right", "The right housing played the wrong swing") + TEST_ASSERT(blade.inhand_hidden_until > world.time, "The held blade draws before the swing has played") + + housing.Retract() + TEST_ASSERT(QDELETED(unfold), "Stowing the blade left the unfold swing playing") + var/obj/effect/abstract/cyberware_anim/fold = housing.blade_anim() + TEST_ASSERT(fold && (fold in bearer.vis_contents), "The blade didn't fold back in") + TEST_ASSERT_EQUAL(fold.icon_state, "mantis_fold_right", "The right housing folded the wrong swing") + TEST_ASSERT_EQUAL(housing.cyberware_worn_look(), "fold", "The folded housing draws over the fold swing") + TEST_ASSERT(findtext(bearer.icon_render_keys[BODY_ZONE_R_ARM], "fold"), "The arm wasn't redrawn for the fold") + + // A blade knocked out of the hand is stowed without a fold. + housing.Extend(blade) + bearer.dropItemToGround(blade, force = TRUE) + housing.Retract() + TEST_ASSERT(isnull(housing.cyberware_worn_look()), "A blade stowed off the floor hid the housing for a fold") + + housing.Extend(blade) + var/obj/effect/abstract/cyberware_anim/last_swing = housing.blade_anim() + TEST_ASSERT(last_swing, "Test fixture: the last swing never played") + housing.Remove(bearer, special = TRUE) + TEST_ASSERT(QDELETED(last_swing) && isnull(housing.blade_anim_ref), "Pulling the housing left its swing") + TEST_ASSERT(!voidcrew_test_has_chrome_anim(bearer), "Pulling the housing left a swing drawn on the body") + TEST_ASSERT(!housing.fold_hide_until && !housing.fold_timer, "Pulling the housing left the folded housing waiting") + TEST_ASSERT(!blade.inhand_hidden_until, "A pulled housing's blade stays hidden in its next hand") + +/// Mantis: a pose taken while the blade is still unfolding (the charge's crouch) stops the unfold, so its +/// guard never draws over the new pose, and the held blade shows at once in it. +/datum/unit_test/voidcrew_cyberware_anim_unfold_handoff + +/datum/unit_test/voidcrew_cyberware_anim_unfold_handoff/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + TEST_ASSERT(housing.Insert(bearer, special = TRUE), "Test fixture: Mantis housing insert refused") + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = housing.contents[1] + housing.Extend(blade) + var/obj/effect/abstract/cyberware_anim/unfold = housing.blade_anim() + TEST_ASSERT(unfold, "Test fixture: the unfold never played") + + blade.set_mantis_pose("coil") + TEST_ASSERT(QDELETED(unfold), "The unfold kept drawing its guard over the coiled blade") + TEST_ASSERT(!blade.inhand_hidden_until, "The coiled blade stayed hidden after the unfold stopped") + +/// Ghostskin: the field flickers in to plain field alpha with nothing else on +/// the bearer, and every way out (run out, switched off, knocked down, pulled, +/// dead) ends at full view, back where the body started, with nothing left on it. +/datum/unit_test/voidcrew_cyberware_anim_cloak + +/datum/unit_test/voidcrew_cyberware_anim_cloak/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = allocate(/obj/item/organ/cyberimp/cyberware/ghostskin) + TEST_ASSERT(weave.Insert(bearer, special = TRUE), "Test fixture: Ghostskin insert refused") + var/filters_before = length(bearer.filter_data) + var/rest_w = bearer.pixel_w + + weave.engage_camo(bearer) + TEST_ASSERT_EQUAL(bearer.alpha, 40, "The flicker doesn't end at the field's alpha") + TEST_ASSERT_EQUAL(bearer.pixel_w, rest_w, "The flicker's jumps don't add up to nothing") + TEST_ASSERT(weave.cloak_enter_until > world.time, "Nothing keeps a step from cutting the flicker short") + TEST_ASSERT_EQUAL(length(bearer.filter_data), filters_before, "The field put a filter on its bearer") + TEST_ASSERT(!voidcrew_test_has_chrome_anim(bearer), "The field put a drawing on its bearer") + weave.cloak_enter_until = 0 + weave.on_camo_move(bearer) + TEST_ASSERT_EQUAL(bearer.alpha, 40, "Moving under the field left the bearer brighter") + + // Run out: the gentle way back. + weave.on_field_expired() + TEST_ASSERT(!weave.camo_active, "Test fixture: the field didn't run out") + TEST_ASSERT_EQUAL(bearer.alpha, 255, "A field that ran out left its bearer faded") + TEST_ASSERT_EQUAL(bearer.pixel_w, rest_w, "The way back out left the body off to one side") + + // Knocked down: the sharp way back. + weave.engage_camo(bearer) + weave.break_camo(bearer, reason = "test") + TEST_ASSERT_EQUAL(bearer.alpha, 255, "A knocked-down field left its bearer faded") + TEST_ASSERT_EQUAL(bearer.pixel_w, rest_w, "The knock left the body off to one side") + TEST_ASSERT_EQUAL(length(bearer.filter_data), filters_before, "A broken field left a filter behind") + TEST_ASSERT(!voidcrew_test_has_chrome_anim(bearer), "A broken field left a drawing behind") + + // Switched off by hand. + var/datum/action/cooldown/cyberware/ghostskin_cloak/button = locate() in weave.actions + weave.engage_camo(bearer) + button.Activate(bearer) + TEST_ASSERT(!weave.camo_active, "Test fixture: the button didn't drop the field") + TEST_ASSERT_EQUAL(bearer.alpha, 255, "A field switched off left its bearer faded") + + // Pulled mid-flicker, and dead mid-field. + weave.engage_camo(bearer) + weave.Remove(bearer, special = TRUE) + TEST_ASSERT_EQUAL(bearer.alpha, 255, "A weave pulled mid-flicker left its bearer faded") + TEST_ASSERT_EQUAL(bearer.pixel_w, rest_w, "A weave pulled mid-flicker left the body off to one side") + TEST_ASSERT(!weave.cloak_enter_until, "A pulled weave still holds off the moving flash") + + var/mob/living/carbon/human/doomed = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/ghostskin/street/rag = allocate(/obj/item/organ/cyberimp/cyberware/ghostskin/street) + TEST_ASSERT(rag.Insert(doomed, special = TRUE), "Test fixture: Flickerskin insert refused") + var/doomed_filters = length(doomed.filter_data) + rag.engage_camo(doomed) + TEST_ASSERT_EQUAL(doomed.alpha, 60, "Flickerskin doesn't flicker down to its own alpha") + doomed.death() + TEST_ASSERT(!rag.camo_active, "Test fixture: death didn't drop the field") + TEST_ASSERT_EQUAL(doomed.alpha, 255, "Death left the body faded") + TEST_ASSERT(length(doomed.filter_data) <= doomed_filters, "Death left a filter on the body") + +/// Cascade: the window lights the spine, the crash kills it, the crash ending +/// puts the plain lattice back, and a lattice pulled mid-window leaves no frames. +/datum/unit_test/voidcrew_cyberware_anim_cascade + +/datum/unit_test/voidcrew_cyberware_anim_cascade/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = allocate(/obj/item/organ/cyberimp/cyberware/cascade) + TEST_ASSERT(lattice.Insert(bearer, special = TRUE), "Test fixture: Cascade insert refused") + + bearer.apply_status_effect(/datum/status_effect/cyberware_cascade_window, lattice) + TEST_ASSERT_EQUAL(lattice.node_look, "boot1", "The spine didn't start lighting when the window opened") + TEST_ASSERT(lattice.node_timer, "The spine lit one node and stopped") + TEST_ASSERT(lattice.ring_timer, "No ring is coming") + TEST_ASSERT(findtext(bearer.icon_render_keys[BODY_ZONE_CHEST], "boot1"), "The chest wasn't redrawn for the node frame") + var/list/images = lattice.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_CHEST)) + var/found_nodes = FALSE + for(var/image/part as anything in images) + if(part.icon_state == "cascade_boot1") + found_nodes = TRUE + // CYBERWARE_SPINE_SHINE_LAYER; the chrome itself sits at CYBERWARE_WORN_LAYER, 27.6. Both are defined after the tests. + TEST_ASSERT_EQUAL(part.layer, -13.7, "Lit nodes don't shine through what is worn on the back") + TEST_ASSERT(found_nodes, "The node frame isn't drawn over the lattice") + // A dying frame is split: what still glows shines through, the dead nodes stay under the clothes. + lattice.node_look = "crash3" + var/found_lit = FALSE + var/found_dark = FALSE + for(var/image/part as anything in lattice.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_CHEST))) + if(part.icon_state == "cascade_crash3_lit" && part.layer == -13.7) + found_lit = TRUE + if(part.icon_state == "cascade_crash3_dark" && part.layer == -27.6) + found_dark = TRUE + TEST_ASSERT(found_lit, "The nodes still lit in a dying frame don't shine through") + TEST_ASSERT(found_dark, "The dead nodes of a dying frame aren't under the clothes") + lattice.node_look = "dead" + for(var/image/part as anything in lattice.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_CHEST))) + TEST_ASSERT(part.layer != -13.7, "A dead spine still draws over what is worn on the back") + lattice.node_look = "boot1" + + bearer.remove_status_effect(/datum/status_effect/cyberware_cascade_window) + TEST_ASSERT(bearer.has_status_effect(/datum/status_effect/cyberware_cascade_crash), "Test fixture: no crash after the window") + TEST_ASSERT_EQUAL(lattice.node_look, "crash1", "The spine didn't start dying with the crash") + TEST_ASSERT(!lattice.ring_timer, "The ring rolls out after the window closed") + + bearer.remove_status_effect(/datum/status_effect/cyberware_cascade_crash) + TEST_ASSERT_NULL(lattice.node_look, "The crash ended on a node frame") + TEST_ASSERT(!lattice.node_timer, "Node frames keep playing after the crash") + + bearer.apply_status_effect(/datum/status_effect/cyberware_cascade_window, lattice) + lattice.Remove(bearer, special = TRUE) + TEST_ASSERT_NULL(lattice.node_look, "A lattice pulled mid-window kept its node frame") + TEST_ASSERT(!lattice.node_timer && !lattice.ring_timer, "A lattice pulled mid-window kept playing") + +/// EMP: every worn piece gets the static look and joins one show; the show +/// ends with its bearer, and the reboot and a tune-up both clear the look. +/datum/unit_test/voidcrew_cyberware_anim_emp + +/datum/unit_test/voidcrew_cyberware_anim_emp/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = allocate(/obj/item/organ/cyberimp/cyberware/cascade) + TEST_ASSERT(arm.Insert(bearer, special = TRUE), "Test fixture: Gorilla Arms insert refused") + TEST_ASSERT(lattice.Insert(bearer, special = TRUE), "Test fixture: Cascade insert refused") + var/datum/component/cyberware/arm_chrome = arm.GetComponent(/datum/component/cyberware) + var/datum/component/cyberware/spine_chrome = lattice.GetComponent(/datum/component/cyberware) + + arm_chrome.start_emp_reboot() + spine_chrome.start_emp_reboot() + var/datum/component/chrome_emp_show/show = bearer.GetComponent(/datum/component/chrome_emp_show) + TEST_ASSERT(show, "An EMP on worn chrome put on no show") + TEST_ASSERT_EQUAL(length(show.crackling), 2, "Two pieces hit on one tick aren't one burst") + TEST_ASSERT_EQUAL(arm.cyberware_worn_look(), "static", "An EMP'd piece doesn't fill with static") + var/list/images = arm.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_R_ARM)) + var/image/plate = images[1] + TEST_ASSERT(plate.appearance_flags & KEEP_TOGETHER, "The static isn't clipped to the piece") + + bearer.death() + TEST_ASSERT(QDELETED(show), "The EMP show outlived its bearer") + TEST_ASSERT(!voidcrew_test_has_chrome_anim(bearer), "Arcs or sparks stayed on a dead bearer") + TEST_ASSERT_EQUAL(arm.cyberware_worn_look(), "dark", "Dead, the EMP'd chrome isn't drawn dark") + images = arm.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_R_ARM)) + plate = images[1] + TEST_ASSERT(islist(plate.color), "A dark piece isn't drawn dark") + + arm_chrome.finish_emp_reboot() + TEST_ASSERT_NULL(arm.cyberware_worn_look(), "A rebooted piece kept a look") + spine_chrome.tune_up() + TEST_ASSERT_NULL(lattice.cyberware_worn_look(), "A tuned-up piece kept a look") + + // Pulled while crackling: the piece drops its look, the show carries on without it. + var/mob/living/carbon/human/next_bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/left/left_arm = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/left) + TEST_ASSERT(left_arm.Insert(next_bearer, special = TRUE), "Test fixture: left Gorilla Arms insert refused") + var/datum/component/cyberware/left_chrome = left_arm.GetComponent(/datum/component/cyberware) + left_chrome.start_emp_reboot() + TEST_ASSERT(next_bearer.GetComponent(/datum/component/chrome_emp_show), "Test fixture: no show on the second bearer") + left_arm.Remove(next_bearer, special = TRUE) + TEST_ASSERT_NULL(left_chrome.emp_look, "A piece pulled mid-EMP kept its static") + +/// Skin plating is skin: it draws under the clothes with stock augments, while the rest of the chrome stays over +/// the jumpsuit. +/datum/unit_test/voidcrew_cyberware_anim_skin_plating + +/datum/unit_test/voidcrew_cyberware_anim_skin_plating/Run() + for(var/plating_type in list(/obj/item/organ/cyberimp/cyberware/slabskin, /obj/item/organ/cyberimp/cyberware/dermal_mesh, /obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave)) + var/obj/item/organ/cyberimp/cyberware/plating = allocate(plating_type) + TEST_ASSERT_EQUAL(plating.bodypart_aug.bitflag_to_layer(EXTERNAL_ADJACENT), -BODY_ADJ_LAYER, "[plating_type] draws over clothes") + // CYBERWARE_WORN_LAYER, which is defined after the tests. + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = allocate(/obj/item/organ/cyberimp/cyberware/cascade) + TEST_ASSERT_EQUAL(lattice.bodypart_aug.bitflag_to_layer(EXTERNAL_ADJACENT), -27.6, "The spine rig dropped under the jumpsuit") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_anim2.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_anim2.dm new file mode 100644 index 00000000000..565b12c7a1f --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_anim2.dm @@ -0,0 +1,351 @@ +/** + * # Chrome animations, second batch + * + * Like the first batch's tests: each animation puts its holders, filters, + * looks and timers on, and they come off again when it ends or is cut short + * (the chrome pulled, the bearer dead, the sequence cancelled). + * + * Unit-test files compile before voidcrew/_DEFINES/ and the module's own + * defines are local, so looks, states and filter names are literals here. + */ + +/// TRUE if a chrome animation holder playing [state] is drawn on [bearer]. +/proc/voidcrew_test_anim_state(atom/movable/bearer, state) + for(var/obj/effect/abstract/cyberware_anim/holder in bearer.vis_contents) + if(holder.icon_state == state) + return TRUE + return FALSE + +/// Redline: the window lights the nodes and the halo, the crash cools them and +/// slumps the body, and the end, a death or a pulled core leaves nothing behind. +/datum/unit_test/voidcrew_cyberware_anim2_redline + +/datum/unit_test/voidcrew_cyberware_anim2_redline/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/redline/core = allocate(/obj/item/organ/cyberimp/cyberware/redline) + TEST_ASSERT(core.Insert(bearer, special = TRUE), "Test fixture: Redline insert refused") + + bearer.apply_status_effect(/datum/status_effect/cyberware_redline_window, core) + TEST_ASSERT_EQUAL(core.burn_look, "flash", "The nodes didn't flash when the burn kicked in") + TEST_ASSERT(core.burn_look_timer, "The nodes flashed and never ran red") + TEST_ASSERT(findtext(bearer.icon_render_keys[BODY_ZONE_CHEST], "flash"), "The chest wasn't redrawn for the flash") + TEST_ASSERT(bearer.get_filter("cyberware_redline_window"), "The burn has no red outline") + TEST_ASSERT(core.burn_light_ref?.resolve(), "The burn throws no light") + TEST_ASSERT((locate(/obj/effect/temp_visual/circle_wave/cyberware_roar) in get_turf(bearer)), "The roar rolled no ring") + core.set_burn_look("hot") + var/found_nodes = FALSE + var/found_eyes = FALSE + for(var/image/part as anything in core.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_CHEST))) + if(part.icon_state == "redline_hot") + found_nodes = TRUE + TEST_ASSERT_EQUAL(part.layer, -13.7, "Red-hot nodes don't shine through what is worn on the back") + if(part.icon_state == "eyes_l") + found_eyes = TRUE + TEST_ASSERT(found_nodes, "The red-hot nodes aren't drawn over the core") + TEST_ASSERT(found_eyes, "The eyes don't flood red") + + bearer.remove_status_effect(/datum/status_effect/cyberware_redline_window) + TEST_ASSERT(bearer.has_status_effect(/datum/status_effect/cyberware_redline_crash), "Test fixture: no crash after the window") + TEST_ASSERT_EQUAL(core.burn_look, "surge", "The spine doesn't run white as the crash begins") + var/found_spine = FALSE + for(var/image/part as anything in core.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_CHEST))) + if(part.icon_state == "redline_surge") + found_spine = TRUE + TEST_ASSERT(found_spine, "The white spine isn't drawn over the core") + TEST_ASSERT(core.burn_look_timer, "The charge never leaves the spine") + TEST_ASSERT(!bearer.get_filter("cyberware_redline_window"), "The red outline outlived the window") + TEST_ASSERT(bearer.get_filter("cyberware_redline_gutter"), "The outline goes out without a stutter") + // Its stutters by hand. Each is stored, so anything that rebuilds the body's filters meanwhile can't relight it. + core.gutter_burn(WEAKREF(bearer), 1) + TEST_ASSERT_EQUAL(bearer.filter_data["cyberware_redline_gutter"]["color"], "#ff2a2a00", "The guttering outline doesn't go out between stutters") + core.gutter_burn(WEAKREF(bearer), 5) + TEST_ASSERT(!bearer.get_filter("cyberware_redline_gutter"), "The outline never finishes guttering out") + TEST_ASSERT(!core.burn_light_ref?.resolve(), "The red light outlived the window") + TEST_ASSERT(bearer.get_filter("cyberware_redline_sag"), "The crash doesn't slump the body") + // The charge leaves the spine: the nodes cool, the eyes dim, and arcs crawl out across the deck under the body. + core.ground_burn() + TEST_ASSERT_EQUAL(core.burn_look, "cool1", "The nodes didn't start cooling once the charge left them") + var/obj/effect/temp_visual/cyberware_redline_ground/arcs = locate() in get_turf(bearer) + TEST_ASSERT_NOTNULL(arcs, "The charge never earths through the deck") + TEST_ASSERT_EQUAL(PLANE_TO_TRUE(arcs.plane), FLOOR_PLANE, "The arcs on the deck draw over the people standing on it") + TEST_ASSERT_EQUAL(arcs.pixel_y, 0, "The arcs on the deck sort a row forward of their own tile") + TEST_ASSERT(icon_exists(arcs.icon, arcs.icon_state), "The arcs on the deck have no picture") + var/found_dying_eyes = FALSE + for(var/image/part as anything in core.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_CHEST))) + if(part.icon_state == "eyes_l") + found_dying_eyes = TRUE + TEST_ASSERT(found_dying_eyes, "The red goes out of the eyes at once, with no dying flicker") + + bearer.remove_status_effect(/datum/status_effect/cyberware_redline_crash) + TEST_ASSERT_NULL(core.burn_look, "The nodes kept a look after the crash") + // A living body eases up out of the slump, and the filter comes off once it is flat. + TEST_ASSERT_EQUAL(bearer.filter_data?["cyberware_redline_sag"]?["size"], 0, "The body doesn't straighten up when the crash ends") + cyberware_redline_straightened(WEAKREF(bearer)) + TEST_ASSERT(!bearer.get_filter("cyberware_redline_sag"), "The slump outlived the crash") + TEST_ASSERT(!bearer.get_filter("cyberware_redline_gutter"), "The outline's last stutter outlived the crash") + TEST_ASSERT(!core.burn_look_timer, "Node looks keep coming after the crash") + + // Dead mid-burn: the picture goes at once, though the window runs on. + bearer.apply_status_effect(/datum/status_effect/cyberware_redline_window, core) + bearer.death() + TEST_ASSERT_NULL(core.burn_look, "A dead body kept its red-hot nodes") + TEST_ASSERT(!bearer.get_filter("cyberware_redline_window"), "A dead body kept the red outline") + TEST_ASSERT(!core.burn_light_ref?.resolve(), "A dead body kept the red light") + + // Pulled mid-crash: nothing stays on the old bearer. + var/mob/living/carbon/human/next_bearer = allocate(/mob/living/carbon/human/consistent) + core.Remove(bearer, special = TRUE) + TEST_ASSERT(core.Insert(next_bearer, special = TRUE), "Test fixture: Redline reinsert refused") + next_bearer.apply_status_effect(/datum/status_effect/cyberware_redline_window, core) + next_bearer.remove_status_effect(/datum/status_effect/cyberware_redline_window) + core.Remove(next_bearer, special = TRUE) + TEST_ASSERT_NULL(core.burn_look, "A pulled core kept its node look") + TEST_ASSERT(!next_bearer.get_filter("cyberware_redline_sag"), "A pulled core left the slump") + TEST_ASSERT(!next_bearer.get_filter("cyberware_redline_gutter"), "A pulled core left the outline stuttering") + TEST_ASSERT(!core.burn_look_timer, "A pulled core still earths its charge") + +/// Lazarus: crit starts the charge, death or a pulled node ends it, and the +/// jolt flashes, bursts and springs the patient without leaving anything on. +/datum/unit_test/voidcrew_cyberware_anim2_lazarus + +/datum/unit_test/voidcrew_cyberware_anim2_lazarus/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/lazarus/node = allocate(/obj/item/organ/cyberimp/cyberware/lazarus) + TEST_ASSERT(node.Insert(patient, special = TRUE), "Test fixture: Lazarus insert refused") + + patient.adjustBruteLoss(120) + TEST_ASSERT(patient.stat == SOFT_CRIT || patient.stat == HARD_CRIT, "Test fixture: the patient isn't in crit") + TEST_ASSERT(node.jolting, "Test fixture: crit didn't start the windup") + TEST_ASSERT(voidcrew_test_anim_state(patient, "lazarus_charge"), "The windup has no charge glow") + TEST_ASSERT(voidcrew_test_anim_state(patient, "lazarus_arcs"), "The windup has no arcs") + TEST_ASSERT(patient.get_filter("cyberware_lazarus_charge"), "The windup doesn't light the body") + + node.jolt(node.jolt_generation, WEAKREF(patient)) + TEST_ASSERT(patient.stat != DEAD, "Test fixture: the jolt didn't take") + TEST_ASSERT(!voidcrew_test_anim_state(patient, "lazarus_charge"), "The charge glow outlived the jolt") + TEST_ASSERT(!patient.get_filter("cyberware_lazarus_charge"), "The charge's halo outlived the jolt") + TEST_ASSERT(voidcrew_test_anim_state(patient, "lazarus_jolt"), "The jolt has no burst") + TEST_ASSERT(patient.get_filter("cyberware_flash"), "The jolt has no flash") + TEST_ASSERT_EQUAL(patient.has_offset("cyberware_lazarus_spring", PIXEL_Z_OFFSET), 3, "The jolt doesn't spring the patient up") + + // Dead during the windup: the charge dies with them. + var/mob/living/carbon/human/doomed = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/lazarus/second_node = allocate(/obj/item/organ/cyberimp/cyberware/lazarus) + TEST_ASSERT(second_node.Insert(doomed, special = TRUE), "Test fixture: second Lazarus insert refused") + second_node.play_charge_fx(doomed, 1 SECONDS) + doomed.death() + TEST_ASSERT(!(locate(/obj/effect/abstract/cyberware_anim) in doomed.vis_contents), "The charge played on a corpse") + TEST_ASSERT(!doomed.get_filter("cyberware_lazarus_charge"), "The charge's halo stayed on a corpse") + + // Pulled during the windup. + var/mob/living/carbon/human/donor = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/lazarus/third_node = allocate(/obj/item/organ/cyberimp/cyberware/lazarus) + TEST_ASSERT(third_node.Insert(donor, special = TRUE), "Test fixture: third Lazarus insert refused") + third_node.play_charge_fx(donor, 1 SECONDS) + third_node.Remove(donor, special = TRUE) + TEST_ASSERT(!(locate(/obj/effect/abstract/cyberware_anim) in donor.vis_contents), "A pulled node left its charge") + TEST_ASSERT(!donor.get_filter("cyberware_lazarus_charge"), "A pulled node left the charge's halo") + +/// Leaps: take-off carries the drawing over to the landing and only the drawing, drawn over whoever stands on its +/// row; the fall brings it down as the landing is due; touchdown gives it back without a glide; a leap up or down +/// the screen moves its place in the front-to-back order with it; a leap that never lands is put down anyway. +/datum/unit_test/voidcrew_cyberware_anim2_leap + +/datum/unit_test/voidcrew_cyberware_anim2_leap/Run() + var/turf/start = run_loc_floor_bottom_left + var/turf/landing = locate(start.x + 2, start.y, start.z) + TEST_ASSERT(landing && landing.x <= run_loc_floor_top_right.x, "Test fixture: the test room is too narrow for a two-tile leap") + var/mob/living/carbon/human/jumper = allocate(/mob/living/carbon/human/consistent, start) + + var/ground_layer = jumper.layer + cyberware_leap_takeoff_fx(jumper, start, landing, 0.2 SECONDS, 20, 26) + TEST_ASSERT_EQUAL(jumper.loc, start, "The take-off moved the body") + TEST_ASSERT_EQUAL(jumper.pixel_w, 64, "The leap's drawing doesn't end over the landing") + TEST_ASSERT_EQUAL(jumper.pixel_z, 26, "The leap's drawing doesn't rise") + cyberware_leap_fall_fx(WEAKREF(jumper), 0.1 SECONDS) + TEST_ASSERT_EQUAL(jumper.pixel_z, 0, "The leap's drawing isn't down on the floor when its landing is due") + TEST_ASSERT(jumper.layer > ground_layer, "A leaping body doesn't draw over the people on its row") + TEST_ASSERT((locate(/obj/effect/temp_visual/cyberware_leap_shadow) in start), "The leap has no floor shadow") + TEST_ASSERT(jumper.cyberware_leap_until, "Nothing watches for a leap that never lands") + + cyberware_leap_touchdown_fx(jumper) + TEST_ASSERT_EQUAL(jumper.pixel_w, 0, "The landing left the drawing to one side") + TEST_ASSERT_EQUAL(jumper.pixel_z, 0, "The landing left the drawing in the air") + TEST_ASSERT_EQUAL(jumper.layer, ground_layer, "The landing left the body drawn over everyone") + TEST_ASSERT_EQUAL(jumper.animate_movement, NO_STEPS, "The move onto the landing tile would glide after the arc") + cyberware_leap_steps_back(WEAKREF(jumper)) + TEST_ASSERT_EQUAL(jumper.animate_movement, SLIDE_STEPS, "A landed body's steps never glide again") + TEST_ASSERT(!jumper.cyberware_leap_until, "A landed leap is still watched") + + // One tile arcs like any other: the landing never glides, so there is nothing to hide by hopping in place. + cyberware_leap_takeoff_fx(jumper, start, get_step(start, EAST), 0.2 SECONDS, 20, 26) + TEST_ASSERT_EQUAL(jumper.pixel_w, 32, "A one-tile leap doesn't travel") + cyberware_leap_touchdown_fx(jumper) + + // Up the screen the run is pixel_y, so the body's place in the front-to-back order goes with it. + cyberware_leap_takeoff_fx(jumper, start, get_step(start, NORTH), 0.2 SECONDS, 20, 26) + TEST_ASSERT_EQUAL(jumper.pixel_y, 32, "A leap up the screen keeps its launch row's place in the draw order") + cyberware_leap_touchdown_fx(jumper) + TEST_ASSERT_EQUAL(jumper.pixel_y, 0, "The landing left the drawing up the screen") + + // The pistons pulled mid-air: no landing ever runs, the failsafe puts the body down. + cyberware_leap_takeoff_fx(jumper, start, landing, 0.2 SECONDS, 20, 26) + jumper.cyberware_leap_until = world.time + cyberware_leap_failsafe(WEAKREF(jumper)) + TEST_ASSERT_EQUAL(jumper.pixel_w, 0, "A leap that never landed stayed to one side") + TEST_ASSERT_EQUAL(jumper.pixel_z, 0, "A leap that never landed stayed in the air") + TEST_ASSERT_EQUAL(jumper.layer, ground_layer, "A leap that never landed stayed drawn over everyone") + + // The real button, end to end. + var/obj/item/organ/cyberimp/cyberware/hopper/pistons = allocate(/obj/item/organ/cyberimp/cyberware/hopper) + TEST_ASSERT(pistons.Insert(jumper, special = TRUE), "Test fixture: Hopper insert refused") + var/datum/action/cooldown/cyberware/hopper_leap/action = locate() in pistons.actions + TEST_ASSERT(action.Activate(landing), "Test fixture: the leap refused a clear two-tile jump") + TEST_ASSERT_EQUAL(jumper.loc, start, "The leap moved the body before it landed") + TEST_ASSERT_EQUAL(jumper.pixel_w, 64, "The Hopper's arc doesn't travel") + action.land(landing) + TEST_ASSERT_EQUAL(jumper.loc, landing, "The leap landed somewhere else") + TEST_ASSERT_EQUAL(jumper.pixel_w, 0, "The Hopper landed off to one side") + TEST_ASSERT_EQUAL(jumper.pixel_z, 0, "The Hopper landed in the air") + TEST_ASSERT_EQUAL(jumper.layer, ground_layer, "The Hopper landed still drawn over everyone") + + // The Piledriver's impact cracks the floor and leaves it alone afterwards. + cyberware_piledriver_impact_fx(landing, 2) + var/obj/effect/temp_visual/cyberware_impact_cracks/cracks = locate() in landing + TEST_ASSERT(cracks, "The impact left no cracks") + TEST_ASSERT(cracks.timerid, "The cracks never clean themselves up") + +/// Brownout: worn chrome stutters together and the show leaves no looks behind, +/// on its own, on recovery and on death. +/datum/unit_test/voidcrew_cyberware_anim2_brownout + +/datum/unit_test/voidcrew_cyberware_anim2_brownout/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = allocate(/obj/item/organ/cyberimp/cyberware/cascade) + var/obj/item/organ/cyberimp/cyberware/test_heavy/heavy = allocate(/obj/item/organ/cyberimp/cyberware/test_heavy) + var/obj/item/organ/cyberimp/cyberware/test_overflow/overflow = allocate(/obj/item/organ/cyberimp/cyberware/test_overflow) + TEST_ASSERT(lattice.Insert(bearer, special = TRUE), "Test fixture: Cascade insert refused") + var/datum/component/cyberware/chrome = lattice.GetComponent(/datum/component/cyberware) + + // At rest the lattice breathes: its LEDs replace the still glow. + var/found_led = FALSE + var/found_still = FALSE + for(var/image/part as anything in lattice.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, bearer.get_bodypart(BODY_ZONE_CHEST))) + if(part.icon_state == "cascade_led" || part.icon_state == "cascade_led_e") + found_led = TRUE + if(part.icon_state == "cascade_e") + found_still = TRUE + TEST_ASSERT(found_led, "The lattice's LEDs don't breathe") + TEST_ASSERT(!found_still, "The still glow is drawn under the breathing one") + + TEST_ASSERT(heavy.Insert(bearer, special = TRUE), "Test fixture: heavy insert refused") + if(!chrome.browned_out) + TEST_ASSERT(overflow.Insert(bearer, special = TRUE), "Test fixture: overflow insert refused") + TEST_ASSERT(chrome.browned_out, "Test fixture: the body didn't brown out") + var/datum/component/chrome_brownout_show/show = bearer.GetComponent(/datum/component/chrome_brownout_show) + TEST_ASSERT(show, "A brownout put on no show") + TEST_ASSERT_EQUAL(lattice.cyberware_worn_look(), "warm", "The brownout didn't start with the warm stutter") + TEST_ASSERT(show.step_timer, "The stutter stopped on its first frame") + while(length(show.steps)) + show.advance() + show.advance() + TEST_ASSERT(QDELETED(show), "The brownout show didn't end") + TEST_ASSERT_NULL(chrome.brownout_look, "The finished show left a look") + TEST_ASSERT_EQUAL(lattice.cyberware_worn_look(), "brown", "Browned-out chrome isn't drawn browned out") + + // Back under: the stutter back on, then plain. + if(overflow.owner) + overflow.Remove(bearer, special = TRUE) + heavy.Remove(bearer, special = TRUE) + TEST_ASSERT(!chrome.browned_out, "Test fixture: the brownout didn't clear") + show = bearer.GetComponent(/datum/component/chrome_brownout_show) + TEST_ASSERT(show, "Coming back up played no stutter") + TEST_ASSERT_EQUAL(lattice.cyberware_worn_look(), "brown", "The way back up didn't start dark") + + // Dead mid-stutter: the show ends and the looks go with it. + bearer.death() + TEST_ASSERT(QDELETED(show), "The brownout show outlived its bearer") + TEST_ASSERT_NULL(chrome.brownout_look, "Death left a stutter look") + TEST_ASSERT_NULL(lattice.cyberware_worn_look(), "Recovered chrome isn't drawn plain") + +/// Chrome cradle: the rig follows the install's beats and pulls back and parks +/// when the sequence is cancelled, with nothing left in the gripper. +/datum/unit_test/voidcrew_cyberware_anim2_cradle + +/datum/unit_test/voidcrew_cyberware_anim2_cradle/Run() + var/obj/machinery/chrome_cradle/cradle = allocate(/obj/machinery/chrome_cradle) + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent, get_turf(cradle)) + TEST_ASSERT(cradle.buckle_mob(patient, force = TRUE, check_loc = FALSE), "Test fixture: couldn't buckle the patient") + var/obj/item/organ/cyberimp/cyberware/redline/street/ware = allocate(/obj/item/organ/cyberimp/cyberware/redline/street) + ware.forceMove(cradle) + + cradle.begin_install(ware) + TEST_ASSERT(cradle.busy, "Test fixture: the install didn't start") + TEST_ASSERT_EQUAL(cradle.rig_phase, "arms_down", "The arms didn't come down on the first beat") + TEST_ASSERT(voidcrew_test_anim_state(cradle, "rig_arms_down"), "The rig isn't drawn coming down") + cradle.run_sequence_stage() + TEST_ASSERT_EQUAL(cradle.rig_phase, "grip_down", "The gripper didn't come down on the second beat") + var/obj/effect/abstract/cyberware_anim/carried = cradle.rig_ware_ref?.resolve() + TEST_ASSERT(carried && carried.icon_state == ware.icon_state, "The gripper isn't carrying the ware") + TEST_ASSERT(!voidcrew_test_anim_state(cradle, "rig_arms_down"), "The last move's rig stayed drawn") + cradle.run_sequence_stage(TRUE) + TEST_ASSERT_EQUAL(cradle.rig_phase, "press", "The gripper didn't press on the third beat") + + cradle.cancel_sequence() + TEST_ASSERT_EQUAL(cradle.rig_phase, "retract", "A cancelled install left the rig down") + TEST_ASSERT(QDELETED(carried), "A cancelled install left the ware in the gripper") + TEST_ASSERT(cradle.rig_park_timer, "The rig never parks") + cradle.park_rig() + TEST_ASSERT_NULL(cradle.rig_phase, "The parked rig still has a move") + TEST_ASSERT(!(locate(/obj/effect/abstract/cyberware_anim) in cradle.vis_contents), "The parked rig left a drawing") + cradle.unbuckle_mob(patient, force = TRUE) + +/// Impacts: a chrome weapon's hit plays its impact over the target in place of +/// tg's flying item, upright, turned to the attacker's side, and it goes away. +/datum/unit_test/voidcrew_cyberware_anim2_impact + +/datum/unit_test/voidcrew_cyberware_anim2_impact/Run() + var/turf/start = run_loc_floor_bottom_left + var/mob/living/carbon/human/west = allocate(/mob/living/carbon/human/consistent, start) + var/mob/living/carbon/human/east = allocate(/mob/living/carbon/human/consistent, get_step(start, EAST)) + + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = allocate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis) + blade.animate_attack(west, east) + var/obj/effect/abstract/cyberware_anim/impact = locate() in east.vis_contents + TEST_ASSERT(impact, "A Mantis hit drew no impact over its target") + TEST_ASSERT_EQUAL(impact.icon_state, "impact_mantis", "A Mantis hit drew the wrong impact") + TEST_ASSERT(impact.appearance_flags & RESET_TRANSFORM, "The impact turns with a lying target") + TEST_ASSERT_EQUAL(impact.transform.a, 1, "A blow from the west was mirrored") + TEST_ASSERT(length(impact.overlays), "The Mantis impact doesn't glow") + qdel(impact) + + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street/shiv = allocate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street) + shiv.animate_attack(east, west) + impact = locate() in west.vis_contents + TEST_ASSERT(impact && impact.icon_state == "impact_shiv", "A Shiv hit drew the wrong impact") + TEST_ASSERT_EQUAL(impact.transform.a, -1, "A blow from the east wasn't mirrored") + TEST_ASSERT(!length(impact.overlays), "The Shiv's steel impact glows") + qdel(impact) + + // The wire's lash from the hand is its picture: nothing goes over the target, not even tg's flying spool. + for(var/wire_type in list(/obj/item/melee/cyberware_monowire, /obj/item/melee/cyberware_monowire/live)) + var/obj/item/melee/cyberware_monowire/wire = allocate(wire_type) + wire.animate_attack(west, east) + TEST_ASSERT(!(locate(/obj/effect/abstract/cyberware_anim) in east.vis_contents), "[wire_type] drew an impact over its target") + TEST_ASSERT(!(locate(/atom/movable/flick_visual) in east.vis_contents), "[wire_type] drew tg's flying spool") + + // Its shock is a small crackle where the wire touched: never a bolt from the wielder, nor sparks thrown about. + var/obj/item/melee/cyberware_monowire/live/arc = allocate(/obj/item/melee/cyberware_monowire/live) + arc.arc_visuals(east, west) + TEST_ASSERT(locate(/obj/effect/temp_visual/cyberware_arc_crackle) in get_turf(east), "The Arc's shock drew no crackle where it touched") + TEST_ASSERT(!(locate(/obj/effect/ebeam) in get_turf(west)), "The Arc's shock drew a beam from the wielder") + TEST_ASSERT(!(locate(/obj/effect/particle_effect/sparks) in range(1, east)), "The Arc's shock threw sparks") + + // A Scorch cut throws embers but draws nothing over the blade's own slash. + cyberware_scorch_trail_fx(west, east) + var/obj/effect/temp_visual/cyberware_scorch_embers/embers = locate() in get_turf(east) + TEST_ASSERT(embers?.particles, "A Scorch cut threw no embers") + TEST_ASSERT_EQUAL(embers.icon_state, "nothing", "A Scorch cut drew a picture over the blade's impact") + + // Nothing to draw on a wall or a floor: those keep tg's own. + TEST_ASSERT_NULL(cyberware_play_impact(west, get_turf(east), "impact_mantis"), "An impact was drawn on a turf") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_camo.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_camo.dm new file mode 100644 index 00000000000..d6f979fb5e5 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_camo.dm @@ -0,0 +1,279 @@ +/** + * Cyberware phase 2: optical camo hides its bearer from more than basic mobs. + * + * The Ghostskin weave (and anything else that grants TRAIT_CYBER_CAMO) is also invisible to + * human NPCs (their targeting strategy, pirate crews included), simple_animal hostiles, every + * porta_turret, the outpost experiment forms and the club's people, beyond + * CYBERWARE_CAMO_SPOT_RANGE, except to megafauna, elites and bosses (human NPCs of boss rank). + * The street Flickerskin grants no trait, so none of this applies to it. voidcrew/modules/ + * cyberware/cyberware_stealth.dm owns the helper and most of the hooks. + * + * Literals (unit tests are included before the fork's defines): the trait is TRAIT_CYBER_CAMO + * ("cyber_camo"); the spot range is CYBERWARE_CAMO_SPOT_RANGE (2); HUMAN_NPC_RANK_BOSS is 2. + * The test room is 5x5, so the far corner is 4 tiles from the near one. Every mob and turret here + * is clientless and every human NPC has its AI switched off: this proves the targeting gates, not + * how an AI walks. + */ + +/// Shared helpers; not a test itself +/datum/unit_test/voidcrew_cyberware_camo + abstract_type = /datum/unit_test/voidcrew_cyberware_camo + +/// The floor `dx`, `dy` tiles from the test room's bottom-left corner +/datum/unit_test/voidcrew_cyberware_camo/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +/// A human wearing `weave_type` with its field up +/datum/unit_test/voidcrew_cyberware_camo/proc/cloaked_human(weave_type, turf/where) + var/mob/living/carbon/human/consistent/bearer = allocate(/mob/living/carbon/human/consistent, where) + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = allocate(weave_type) + TEST_ASSERT(weave.Insert(bearer, special = TRUE), "[weave_type] staging insert was refused") + weave.engage_camo(bearer) + TEST_ASSERT(weave.camo_active, "[weave_type] never raised its field") + return bearer + +/// A human NPC of `npc_type` at `where`, built the way the spawn queue builds one, with its AI off +/datum/unit_test/voidcrew_cyberware_camo/proc/human_npc(npc_type, turf/where) + var/datum/human_npc_order/order = spawn_human_npc(npc_type, where, immediate = TRUE) + var/mob/living/carbon/human/npc/npc = order?.spawned_ref?.resolve() + TEST_ASSERT_NOTNULL(npc, "[npc_type] wasn't built") + allocated += npc + npc.ai_controller?.set_ai_status(AI_STATUS_OFF) + return npc + +/// The helper itself: range, trait, null viewer, non-living target, and who sees through +/datum/unit_test/voidcrew_cyberware_camo/helper + +/datum/unit_test/voidcrew_cyberware_camo/helper/Run() + var/mob/living/carbon/human/consistent/bearer = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + var/mob/living/simple_animal/hostile/megafauna/boss = allocate(/mob/living/simple_animal/hostile/megafauna, spot(0, 0)) + var/mob/living/basic/bystander = allocate(/mob/living/basic, spot(0, 0)) + TEST_ASSERT(!cyberware_camo_hides(bearer, bystander), "A bearer with no field was hidden") + + ADD_TRAIT(bearer, "cyber_camo", "camo_helper_test") + TEST_ASSERT(cyberware_camo_hides(bearer, bystander), "A camo'd bearer, 4 tiles off, was not hidden") + TEST_ASSERT(cyberware_camo_hides(bearer, null), "A camo'd bearer was not hidden from nobody in particular") + TEST_ASSERT(!cyberware_camo_hides(bearer, boss), "A megafauna was fooled by camo") + TEST_ASSERT(!cyberware_camo_hides(null, bystander), "A null target was hidden") + TEST_ASSERT(!cyberware_camo_hides(allocate(/obj/item), bystander), "An object was hidden") + + // The spot range is inclusive: 3 tiles hides, 2 does not. + bearer.forceMove(spot(3, 0)) + TEST_ASSERT(cyberware_camo_hides(bearer, bystander), "A camo'd bearer 3 tiles off was spotted") + bearer.forceMove(spot(2, 0)) + TEST_ASSERT(!cyberware_camo_hides(bearer, bystander), "A camo'd bearer 2 tiles off stayed hidden") + bearer.forceMove(spot(1, 1)) + TEST_ASSERT(!cyberware_camo_hides(bearer, bystander), "A camo'd bearer 1 tile off stayed hidden") + REMOVE_TRAIT(bearer, "cyber_camo", "camo_helper_test") + + // Everything in the list sees through it, and so do its subtypes. + var/static/list/piercing = list( + /mob/living/simple_animal/hostile/megafauna/bubblegum, + /mob/living/simple_animal/hostile/asteroid/elite/herald, + /mob/living/basic/boss/thing, + /mob/living/basic/lich, + /mob/living/basic/hoarfrost_matriarch, + /mob/living/basic/trooper/pirate/faction/boss, + /mob/living/basic/bounty_lair_boss/mafia_mech, + /mob/living/basic/outpost_experiment/horror, + /mob/living/basic/alien/queen/large/derelict, + /mob/living/basic/vestige_oracle, + /mob/living/basic/vestige_mutant, + /mob/living/basic/vestige_warframe, + ) + for(var/seer_type in piercing) + TEST_ASSERT(is_type_in_typecache(seer_type, GLOB.cyberware_camo_piercing_types), "[seer_type] is fooled by camo") + var/static/list/fooled = list( + /mob/living/simple_animal/hostile/asteroid/old_demon, + /mob/living/simple_animal/hostile/asteroid/polarbear, + /mob/living/carbon/human/npc, + ) + for(var/fooled_type in fooled) + TEST_ASSERT(!is_type_in_typecache(fooled_type, GLOB.cyberware_camo_piercing_types), "[fooled_type] sees through camo and shouldn't") + + // Bosses that are people see through it by rank, not by type: every human NPC boss is rank 2. + var/static/list/human_bosses = list( + /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/irs/boss, + /mob/living/carbon/human/npc/faction_pirate/medieval/boss, + /mob/living/carbon/human/npc/faction_pirate/nt_customs/director, + /mob/living/carbon/human/npc/bounty_criminal/boss/ghost, + /mob/living/carbon/human/npc/bounty_criminal/kingpin, + /mob/living/carbon/human/npc/bounty_mafia/don, + ) + for(var/mob/living/carbon/human/npc/boss_type as anything in human_bosses) + TEST_ASSERT_EQUAL(initial(boss_type.npc_rank), 2, "[boss_type] isn't boss rank, so camo fools it") + var/static/list/human_regulars = list( + /mob/living/carbon/human/npc/faction_pirate/silverscale/captain, + /mob/living/carbon/human/npc/faction_pirate/grey/ranged, + /mob/living/carbon/human/npc/bounty_mafia/pistol, + /mob/living/carbon/human/npc/bounty_mafia/lieutenant, + ) + for(var/mob/living/carbon/human/npc/regular_type as anything in human_regulars) + TEST_ASSERT(initial(regular_type.npc_rank) < 2, "[regular_type] is boss rank and sees through camo") + +/// Simple animal hostiles: fooled beyond range, not by megafauna, not by the street weave, and +/// whoever strikes from under the field is seen again. (The hermits are people now, so a polar +/// bear stands in for them.) +/datum/unit_test/voidcrew_cyberware_camo/hostiles + +/datum/unit_test/voidcrew_cyberware_camo/hostiles/Run() + var/mob/living/simple_animal/hostile/asteroid/polarbear/bear = allocate(/mob/living/simple_animal/hostile/asteroid/polarbear, spot(0, 0)) + var/mob/living/simple_animal/hostile/megafauna/boss = allocate(/mob/living/simple_animal/hostile/megafauna, spot(0, 1)) + var/mob/living/carbon/human/consistent/plain = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + TEST_ASSERT(bear.CanAttack(plain), "Fixture: the bear won't pick a plain human to begin with") + TEST_ASSERT(boss.CanAttack(plain), "Fixture: the megafauna won't pick a plain human to begin with") + + var/mob/living/carbon/human/consistent/ghost = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin, spot(4, 4)) + TEST_ASSERT(!bear.CanAttack(ghost), "A bear picked a camo'd human 4 tiles off") + TEST_ASSERT(boss.CanAttack(ghost), "A megafauna was fooled by a camo'd human") + ghost.forceMove(spot(0, 2)) + TEST_ASSERT(bear.CanAttack(ghost), "A bear missed a camo'd human 2 tiles off") + ghost.forceMove(spot(4, 4)) + TEST_ASSERT(!bear.CanAttack(ghost), "A bear that lost sight of a camo'd human picked them up again") + + // A hostile already chasing loses the target the moment the field goes up: FindTarget and + // MoveToTarget both ask CanAttack(). + bear.target = ghost + TEST_ASSERT(!bear.CanAttack(bear.target), "A bear kept chasing a human who cloaked") + bear.target = null + + // Striking from under the field drops it, so retaliation still lands. + SEND_SIGNAL(ghost, COMSIG_MOB_FIRED_GUN) + TEST_ASSERT(!HAS_TRAIT(ghost, "cyber_camo"), "Firing a gun didn't drop the field") + TEST_ASSERT(bear.CanAttack(ghost), "A bear couldn't retaliate against someone who fired from under the field") + + // Throwing from under the field drops it too: a thrown brick is an attack like any other. + var/mob/living/carbon/human/consistent/pitcher = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin, spot(4, 4)) + TEST_ASSERT(HAS_TRAIT(pitcher, "cyber_camo"), "Fixture: the second Ghostskin bearer isn't camo'd") + SEND_SIGNAL(pitcher, COMSIG_MOB_THROW, spot(0, 0)) + TEST_ASSERT(!HAS_TRAIT(pitcher, "cyber_camo"), "Throwing didn't drop the field") + + // A weave knocked into a reboot drops its field too. + var/mob/living/carbon/human/consistent/glitched = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin, spot(4, 4)) + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = locate() in glitched.organs + var/datum/component/cyberware/chrome = weave?.GetComponent(/datum/component/cyberware) + TEST_ASSERT_NOTNULL(chrome, "Fixture: the Ghostskin has no chrome component") + chrome.start_emp_reboot(EMP_HEAVY) + TEST_ASSERT(!weave.camo_active, "A rebooting weave kept its field up") + TEST_ASSERT(!HAS_TRAIT(glitched, "cyber_camo"), "A rebooting weave left its bearer hidden from mobs") + + // The street weave never grants the trait, so nothing here hides it. + var/mob/living/carbon/human/consistent/flicker = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin/street, spot(4, 4)) + TEST_ASSERT(!HAS_TRAIT(flicker, "cyber_camo"), "The Flickerskin granted the camo trait") + TEST_ASSERT(bear.CanAttack(flicker), "A bear was fooled by the Flickerskin") + TEST_ASSERT(boss.CanAttack(flicker), "A megafauna was fooled by the Flickerskin") + +/// Every turret type that can be handed a camo'd human drops them from the list it shoots at. +/// tryToShootAt() returns 1 once it has settled on a target, and nothing when it has none. +/datum/unit_test/voidcrew_cyberware_camo/turrets + +/datum/unit_test/voidcrew_cyberware_camo/turrets/Run() + var/mob/living/carbon/human/consistent/ghost = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin, spot(4, 4)) + var/mob/living/carbon/human/consistent/flicker = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin/street, spot(4, 3)) + var/mob/living/carbon/human/consistent/plain = allocate(/mob/living/carbon/human/consistent, spot(3, 4)) + + var/static/list/turret_types = list( + /obj/machinery/porta_turret, + /obj/machinery/porta_turret/ai, + /obj/machinery/porta_turret/ruin, + /obj/machinery/porta_turret/syndicate, + /obj/machinery/porta_turret/outpost, + /obj/machinery/porta_turret/ship_defense, + ) + for(var/turret_type in turret_types) + var/obj/machinery/porta_turret/turret = allocate(turret_type, spot(0, 0)) + // Unanchored, popUp() and shootAt() are no-ops: the test asks who it picks, not to be shot at. + turret.anchored = FALSE + TEST_ASSERT(turret.tryToShootAt(list(plain)), "[turret_type] skipped a plain human") + TEST_ASSERT(!turret.tryToShootAt(list(ghost)), "[turret_type] picked a camo'd human 4 tiles off") + TEST_ASSERT(turret.tryToShootAt(list(flicker)), "[turret_type] skipped a Flickerskin bearer") + // Camo only takes the hidden one out of a mixed list. + TEST_ASSERT(turret.tryToShootAt(list(ghost, plain)), "[turret_type] gave up on a list with a plain human in it") + // Inside the spot range they are seen. + ghost.forceMove(spot(0, 2)) + TEST_ASSERT(turret.tryToShootAt(list(ghost)), "[turret_type] missed a camo'd human 2 tiles off") + ghost.forceMove(spot(4, 4)) + +/// Human NPCs: tg's basic targeting through the human NPC strategy, which pirate crews and boarders, +/// ruin troopers and the club's people all run on. A regular NPC is fooled beyond range; a boss +/// (by rank) is not; the street weave fools nobody. +/datum/unit_test/voidcrew_cyberware_camo/human_npcs + +/datum/unit_test/voidcrew_cyberware_camo/human_npcs/Run() + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(/datum/targeting_strategy/basic/human_npc) + TEST_ASSERT_NOTNULL(strategy, "The human NPC targeting strategy is gone") + var/mob/living/carbon/human/npc/gunner = human_npc(/mob/living/carbon/human/npc/faction_pirate/grey/ranged, spot(0, 0)) + var/mob/living/carbon/human/npc/boss = human_npc(/mob/living/carbon/human/npc/faction_pirate/grey/boss, spot(0, 1)) + var/mob/living/carbon/human/npc/director = human_npc(/mob/living/carbon/human/npc/faction_pirate/nt_customs/director, spot(1, 0)) + TEST_ASSERT_EQUAL(gunner.ai_controller?.blackboard[BB_TARGETING_STRATEGY], /datum/targeting_strategy/basic/human_npc, "A pirate gunner doesn't target through the human NPC strategy") + + var/mob/living/carbon/human/consistent/plain = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + TEST_ASSERT(strategy.can_attack(gunner, plain), "Fixture: a pirate gunner won't target a plain human to begin with") + TEST_ASSERT(strategy.can_attack(boss, plain), "Fixture: a pirate boss won't target a plain human to begin with") + + var/mob/living/carbon/human/consistent/ghost = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin, spot(4, 4)) + TEST_ASSERT(!strategy.can_attack(gunner, ghost), "A pirate gunner targeted a camo'd human 4 tiles off") + TEST_ASSERT(cyberware_camo_hides(ghost, gunner), "Camo didn't hide its bearer from a pirate gunner") + TEST_ASSERT(strategy.can_attack(boss, ghost), "A pirate boss was fooled by camo") + TEST_ASSERT(!cyberware_camo_hides(ghost, director), "The NT patrol's director was fooled by camo") + ghost.forceMove(spot(2, 0)) + TEST_ASSERT(strategy.can_attack(gunner, ghost), "A pirate gunner missed a camo'd human 2 tiles off") + ghost.forceMove(spot(4, 4)) + + var/mob/living/carbon/human/consistent/flicker = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin/street, spot(4, 3)) + TEST_ASSERT(strategy.can_attack(gunner, flicker), "A pirate gunner was fooled by the Flickerskin") + +/// The experiment forms' own strategy (it never calls the basic one): a serum-turned body picks a +/// plain person, not a camo'd one beyond range. +/datum/unit_test/voidcrew_cyberware_camo/experiments + +/datum/unit_test/voidcrew_cyberware_camo/experiments/Run() + var/mob/living/carbon/human/consistent/creature = allocate(/mob/living/carbon/human/consistent, spot(0, 0)) + var/datum/component/outpost_experiment_form/form = outpost_experiment_turn(creature, "hulk", null, null) + TEST_ASSERT_NOTNULL(form, "The hulk serum didn't take on a test body") + creature.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(/datum/targeting_strategy/outpost_experiment_form) + TEST_ASSERT_NOTNULL(strategy, "The experiment forms' targeting strategy is gone") + + var/mob/living/carbon/human/consistent/plain = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + TEST_ASSERT(strategy.can_attack(creature, plain), "Fixture: an experiment won't target a plain human to begin with") + + var/mob/living/carbon/human/consistent/ghost = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin, spot(4, 4)) + TEST_ASSERT(!strategy.can_attack(creature, ghost), "An experiment targeted a camo'd human 4 tiles off") + TEST_ASSERT(!form.can_target(ghost), "An experiment would pick a camo'd human 4 tiles off") + ghost.forceMove(spot(2, 0)) + TEST_ASSERT(strategy.can_attack(creature, ghost), "An experiment missed a camo'd human 2 tiles off") + ghost.forceMove(spot(4, 4)) + + var/mob/living/carbon/human/consistent/flicker = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin/street, spot(4, 3)) + TEST_ASSERT(strategy.can_attack(creature, flicker), "An experiment was fooled by the Flickerskin") + +/// The club's people: the scripted pick, mafia_target_ok(), skips a camo'd hunter beyond range, +/// and the don, a boss, sees through it. +/datum/unit_test/voidcrew_cyberware_camo/mobsters + +/datum/unit_test/voidcrew_cyberware_camo/mobsters/Run() + var/mob/living/carbon/human/npc/bounty_mafia/pistol/gunman = allocate(/mob/living/carbon/human/npc/bounty_mafia/pistol, spot(0, 0)) + gunman.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/mob/living/carbon/human/npc/bounty_mafia/don/don = allocate(/mob/living/carbon/human/npc/bounty_mafia/don, spot(0, 1)) + don.ai_controller?.set_ai_status(AI_STATUS_OFF) + var/mob/living/carbon/human/consistent/plain = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + plain.mind_initialize() + TEST_ASSERT(gunman.mafia_target_ok(plain), "Fixture: a goon won't go after a plain hunter to begin with") + + var/mob/living/carbon/human/consistent/ghost = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin, spot(4, 4)) + ghost.mind_initialize() + TEST_ASSERT(!gunman.mafia_target_ok(ghost), "A goon went after a camo'd hunter 4 tiles off") + TEST_ASSERT(!cyberware_camo_hides(ghost, don), "The don was fooled by camo") + ghost.forceMove(spot(0, 2)) + TEST_ASSERT(gunman.mafia_target_ok(ghost), "A goon missed a camo'd hunter 2 tiles off") + ghost.forceMove(spot(4, 4)) + + var/mob/living/carbon/human/consistent/flicker = cloaked_human(/obj/item/organ/cyberimp/cyberware/ghostskin/street, spot(4, 3)) + flicker.mind_initialize() + TEST_ASSERT(gunman.mafia_target_ok(flicker), "A goon was fooled by the Flickerskin") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_deflect.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_deflect.dm new file mode 100644 index 00000000000..696e4b85e95 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_deflect.dm @@ -0,0 +1,72 @@ +/// The dermal ladder turns bullets from the front: a real glance that leaves +/// the bearer unhurt and keeps the round flying on a new heading, costs a +/// little stamina, never touches lasers or shots into the back, switches off +/// with the chrome, and never lifts dodge plus deflect past the shared cap. +/datum/unit_test/voidcrew_cyberware_deflect + +/datum/unit_test/voidcrew_cyberware_deflect/Run() + var/obj/item/organ/cyberimp/cyberware/dermal_mesh/mesh = allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh) + var/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave/hardweave = allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave) + var/obj/item/organ/cyberimp/cyberware/slabskin/slab = allocate(/obj/item/organ/cyberimp/cyberware/slabskin) + TEST_ASSERT_EQUAL(mesh.deflect_chance, 15, "Dermal Mesh deflects at the wrong chance") + TEST_ASSERT_EQUAL(hardweave.deflect_chance, 30, "Hardweave deflects at the wrong chance") + TEST_ASSERT_EQUAL(slab.deflect_chance, 45, "Slabskin deflects at the wrong chance") + + // The cap: dodge + (1 - dodge) * deflect never passes 60%. + TEST_ASSERT_EQUAL(cyberware_deflect_cap(0), 60, "The deflect cap is wrong with no dodge") + TEST_ASSERT_EQUAL(cyberware_deflect_cap(60), 0, "A full-cap dodge still left room to deflect") + for(var/dodge in list(0, 15, 30, 45, 59)) + var/deflect = min(slab.deflect_chance, cyberware_deflect_cap(dodge)) + var/combined = dodge + (100 - dodge) * deflect / 100 + TEST_ASSERT(combined <= 60.001, "Dodge [dodge] plus deflect stops [combined]% of shots") + + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/shooter = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + TEST_ASSERT(slab.Insert(patient, TRUE), "Slabskin fixture failed") + var/datum/component/cyberware_dodge/arbiter = patient.GetComponent(/datum/component/cyberware_dodge) + TEST_ASSERT_NOTNULL(arbiter, "Slabskin didn't register a deflect source") + // Force every glance: a 100% plate under a lifted cap. The cap itself is checked above. + slab.deflect_chance = 100 + arbiter.avoid_cap = 100 + patient.setDir(SOUTH) + + // A bullet from the front (travelling north into a bearer facing south) glances off. + var/obj/projectile/bullet/c9mm/front = make_shot(/obj/projectile/bullet/c9mm, shooter, 0) + var/front_damage = front.damage + TEST_ASSERT_EQUAL(patient.bullet_act(front, BODY_ZONE_CHEST), BULLET_ACT_FORCE_PIERCE, "A bullet from the front didn't glance off") + TEST_ASSERT_EQUAL(patient.getBruteLoss(), 0, "A glanced bullet still hurt") + TEST_ASSERT(front.angle != 0, "The glanced bullet kept its heading") + TEST_ASSERT(front.damage < front_damage, "The glanced bullet lost no energy") + TEST_ASSERT(patient.getStaminaLoss() > 0, "A glance cost no stamina") + + // Every buckshot pellet is a bullet of its own and rolls on its own. + var/obj/projectile/bullet/pellet/shotgun_buckshot/pellet = make_shot(/obj/projectile/bullet/pellet/shotgun_buckshot, shooter, 0) + TEST_ASSERT_EQUAL(patient.bullet_act(pellet, BODY_ZONE_CHEST), BULLET_ACT_FORCE_PIERCE, "A buckshot pellet didn't glance off") + + // A bullet into the back always lands. + var/obj/projectile/bullet/c9mm/back = make_shot(/obj/projectile/bullet/c9mm, shooter, 180) + TEST_ASSERT_NOTEQUAL(patient.bullet_act(back, BODY_ZONE_CHEST), BULLET_ACT_FORCE_PIERCE, "A bullet into the back glanced off") + TEST_ASSERT(patient.getBruteLoss() > 0, "A bullet into the back did nothing") + + // Lasers are never deflected. + var/obj/projectile/beam/laser/laser = make_shot(/obj/projectile/beam/laser, shooter, 0) + TEST_ASSERT_NOTEQUAL(patient.bullet_act(laser, BODY_ZONE_CHEST), BULLET_ACT_FORCE_PIERCE, "A laser glanced off the plate") + TEST_ASSERT(patient.getFireLoss() > 0, "The laser did nothing") + + // A failing plate deflects nothing. + slab.organ_flags |= ORGAN_FAILING + var/obj/projectile/bullet/c9mm/failing = make_shot(/obj/projectile/bullet/c9mm, shooter, 0) + TEST_ASSERT_NOTEQUAL(patient.bullet_act(failing, BODY_ZONE_CHEST), BULLET_ACT_FORCE_PIERCE, "A failing plate still deflected") + slab.organ_flags &= ~ORGAN_FAILING + + // Taking the plate out takes the deflect with it. + slab.Remove(patient) + TEST_ASSERT_NULL(patient.GetComponent(/datum/component/cyberware_dodge), "The deflect source outlived the plate") + +/// A hostile shot from the shooter, heading at the given angle, ready for bullet_act(). +/datum/unit_test/voidcrew_cyberware_deflect/proc/make_shot(shot_type, mob/living/shooter, heading) + var/obj/projectile/shot = allocate(shot_type) + shot.firer = shooter + shot.def_zone = BODY_ZONE_CHEST + shot.set_angle(heading) + return shot diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_final.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_final.dm new file mode 100644 index 00000000000..ce0335f3c5b --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_final.dm @@ -0,0 +1,175 @@ +/** + * # Cyberware: the final pass + * + * The fixes and owner-call defaults from the phase 2 code and balance reviews: + * an armed chrome ability takes the click it refuses and drops its aim, Ghostskin drops on every + * kind of hit, the chrome wheel's zoom and stale chips, the full credit trade-in + * shelf (owner D7), and pirate bosses seeing through camo. + * + * NOTE: the CI build (CIBUILDING) sits at a DM compiler limit on unique + * identifiers. A new local or type name anywhere can fail the compile with + * ": invalid variable" on a var/static in some unrelated file. So these + * tests reuse names the codebase already has, and live under one parent. + * + * Unit-test files compile before voidcrew/_DEFINES/, so fork defines are + * literals here: "cyber_camo" is TRAIT_CYBER_CAMO. + */ +/datum/unit_test/voidcrew_cyberware_final + abstract_type = /datum/unit_test/voidcrew_cyberware_final + +/// A click on an armed chrome ability is the chrome's: a refused one never falls +/// through to the held gun, and it drops the aim with the cooldown untouched. A +/// right-click, a stun, or waiting too long drops it too, and so does chrome that +/// went dark while armed. Chrome has no button to click it off, so nothing may +/// leave it armed and eating clicks. +/datum/unit_test/voidcrew_cyberware_final/click/Run() + var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/icepick/optics = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/icepick) + TEST_ASSERT(optics.Insert(user, special = TRUE), "Icepick staging insert was refused") + var/datum/action/cooldown/cyberware/icepick/suppress/action = locate() in optics.actions + TEST_ASSERT_NOTNULL(action, "The Icepick granted no Suppress") + TEST_ASSERT(action.IsAvailable(), "Test fixture: Suppress can't be used") + var/obj/item/gun/ballistic/automatic/pistol/gun = allocate(/obj/item/gun/ballistic/automatic/pistol) + TEST_ASSERT(user.put_in_active_hand(gun), "Test fixture: the user couldn't hold the pistol") + var/ammo = gun.get_ammo() + TEST_ASSERT(ammo > 0, "Test fixture: the pistol spawned empty") + var/turf/target = get_step(get_step(run_loc_floor_bottom_left, EAST), EAST) + + // A floor tile has no port for the spike. + action.set_click_ability(user) + TEST_ASSERT_EQUAL(user.click_intercept, action, "Test fixture: Suppress did not arm") + user.next_click = 0 + user.next_move = 0 + user.ClickOn(target, "left=1") + TEST_ASSERT_EQUAL(gun.get_ammo(), ammo, "A refused chrome click fired the held gun") + TEST_ASSERT(user.click_intercept != action, "A click on a floor tile left the Icepick armed") + TEST_ASSERT(action.next_use_time <= world.time, "A refused spike started the cooldown") + TEST_ASSERT(!user.check_click_intercept("left=1", target), "A disarmed ability still took a click") + + // Right-click drops the aim without trying. + action.set_click_ability(user) + TEST_ASSERT(user.check_click_intercept("right=1", target), "A right-click on an armed ability fell through") + TEST_ASSERT(user.click_intercept != action, "A right-click left the Icepick armed") + + // Armed and left waiting. + action.set_click_ability(user) + action.on_timeout() + TEST_ASSERT(user.click_intercept != action, "An aim left waiting never dropped") + + // Stunned while armed. + action.set_click_ability(user) + user.Stun(2 SECONDS) + TEST_ASSERT(user.click_intercept != action, "A stun left the Icepick armed") + user.SetStun(0) + TEST_ASSERT(action.IsAvailable(), "Test fixture: Suppress stayed down after the stun") + + // Chrome that went dark while armed takes the click once and disarms. + action.set_click_ability(user) + var/datum/component/cyberware/chrome = optics.GetComponent(/datum/component/cyberware) + chrome.start_emp_reboot(EMP_HEAVY) + TEST_ASSERT(!chrome.is_running(), "Test fixture: the Icepick stayed up through a reboot") + TEST_ASSERT(user.check_click_intercept("left=1", target), "An armed ability that went dark let the click through") + TEST_ASSERT(user.click_intercept != action, "An armed ability that went dark stayed armed") + TEST_ASSERT(!user.check_click_intercept("left=1", target), "A disarmed ability still took a click") + +/// Being mauled by an animal, a mob, a mech or a xeno drops the Ghostskin field, +/// and so does a real shock. A hallucinated or fully insulated one doesn't. And +/// every faction's pirate boss sees through camo, the NT patrol's included. +/datum/unit_test/voidcrew_cyberware_final/camo/Run() + var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = allocate(/obj/item/organ/cyberimp/cyberware/ghostskin) + TEST_ASSERT(weave.Insert(user, special = TRUE), "Ghostskin staging insert was refused") + var/mob/living/basic/mouse/mouse = allocate(/mob/living/basic/mouse, get_step(run_loc_floor_bottom_left, EAST)) + + for(var/signal in list(COMSIG_ATOM_ATTACK_ANIMAL, COMSIG_ATOM_ATTACK_BASIC_MOB, COMSIG_ATOM_ATTACK_MECH, COMSIG_MOB_ATTACK_ALIEN)) + weave.engage_camo(user) + TEST_ASSERT(weave.camo_active, "Test fixture: the field did not come up before [signal]") + SEND_SIGNAL(user, signal, mouse) + TEST_ASSERT(!weave.camo_active, "[signal] left the Ghostskin field up") + TEST_ASSERT(!HAS_TRAIT(user, "cyber_camo"), "[signal] dropped the field but left the camo trait") + + weave.engage_camo(user) + user.electrocute_act(10, mouse, 1, SHOCK_ILLUSION) + TEST_ASSERT(weave.camo_active, "A hallucinated shock dropped the field") + user.electrocute_act(10, mouse, 0) + TEST_ASSERT(weave.camo_active, "A shock the gloves fully insulated dropped the field") + user.electrocute_act(10, mouse, 1) + TEST_ASSERT(!weave.camo_active, "A real shock left the field up") + + TEST_ASSERT(GLOB.cyberware_camo_piercing_types[/mob/living/basic/trooper/pirate/faction/boss], "A pirate boss doesn't see through camo") + // The NT patrol's boss is a person now: it sees through camo by rank (HUMAN_NPC_RANK_BOSS is 2). + var/mob/living/carbon/human/npc/director_type = /mob/living/carbon/human/npc/faction_pirate/nt_customs/director + TEST_ASSERT_EQUAL(initial(director_type.npc_rank), 2, "The NT patrol's boss doesn't see through camo") + +/// The wheel shows the zoom as on while zoomed, and a chip whose chrome was +/// cut out while the wheel was held open can't be picked. +/datum/unit_test/voidcrew_cyberware_final/wheel/Run() + var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/eyes/robotic/cyberware/spyglass/optics = allocate(/obj/item/organ/eyes/robotic/cyberware/spyglass) + TEST_ASSERT(optics.Insert(user, special = TRUE), "Spyglass staging insert was refused") + var/datum/action/cooldown/cyberware/optics_zoom/zoom = locate() in optics.actions + TEST_ASSERT_NOTNULL(zoom, "The optics granted no zoom") + TEST_ASSERT(!chrome_wheel_ability_active(zoom, user), "The wheel shows an idle zoom as on") + optics.engage_zoom(user) + TEST_ASSERT(optics.is_zoomed(), "Test fixture: the zoom didn't engage") + TEST_ASSERT(chrome_wheel_ability_active(zoom, user), "The wheel doesn't show the zoom as on while zoomed") + optics.stop_zoom(user) + TEST_ASSERT(!chrome_wheel_ability_active(zoom, user), "The wheel still shows the zoom as on after it ended") + + var/obj/item/organ/cyberimp/cyberware/hopper/pistons = allocate(/obj/item/organ/cyberimp/cyberware/hopper) + TEST_ASSERT(pistons.Insert(user, special = TRUE), "Hopper staging insert was refused") + var/datum/action/cooldown/cyberware/hopper_leap/action = locate() in pistons.actions + TEST_ASSERT_NOTNULL(action, "The Hopper granted no leap") + var/datum/component/chrome_wheel/wheel = get_chrome_wheel(user) + TEST_ASSERT_NOTNULL(wheel, "A chromed body got no wheel") + wheel.build_wheel(get_chrome_wheel_actions(user)) + var/atom/movable/screen/chrome_wheel/chip/found + for(var/atom/movable/screen/chrome_wheel/chip/chip as anything in wheel.chips) + if(chip.ability_ref?.resolve() == action) + found = chip + TEST_ASSERT_NOTNULL(found, "The built wheel has no chip for the leap") + pistons.Remove(user, special = TRUE) + TEST_ASSERT(!wheel.select_chip(found, quiet = TRUE), "A chip was picked after its chrome came out") + TEST_ASSERT_NULL(wheel.get_selected_ability(), "The wheel kept a pick for chrome that came out") + wheel.close_wheel() + +/// Owner D7: every piece a ripperdoc sells for credits comes back at half list, +/// credits only, at both ripperdocs, even where Ratchet doesn't sell it. +/datum/unit_test/voidcrew_cyberware_final/ledger/Run() + var/datum/outpost_shop/vendor/ripperdoc/splice = allocate(/datum/outpost_shop/vendor/ripperdoc) + var/datum/outpost_shop/vendor/street_doc/ratchet = allocate(/datum/outpost_shop/vendor/street_doc) + // Each credit-only piece on Splice's shelf: what one piece of it costs. + var/list/prices = list() + for(var/datum/shop_sku/sku_type as anything in splice.sku_types) + if(initial(sku_type.price_credits) <= 0 || initial(sku_type.price_vouchers) > 0) + continue + var/item_path = initial(sku_type.item_path) + var/list/pieces = list() + if(ispath(item_path, /obj/item/organ)) + pieces += item_path + else if(ispath(item_path, /obj/item/cyberware_pair_case) || ispath(item_path, /obj/item/storage/case/cyberware)) + var/obj/item/sample = new item_path(null) + for(var/obj/item/organ/held in sample.contents) + pieces += held.type + for(var/atom/movable/packed as anything in sample.contents.Copy()) + qdel(packed) + qdel(sample) + for(var/piece in pieces) + prices[piece] = initial(sku_type.price_credits) / length(pieces) + TEST_ASSERT(length(prices) >= 40, "Splice's credit shelf looks empty ([length(prices)] pieces)") + + for(var/datum/outpost_shop/shop as anything in list(splice, ratchet)) + for(var/piece in prices) + var/datum/shop_buyback/found + for(var/datum/shop_buyback/buyback_type as anything in shop.buyback_types) + var/path = initial(buyback_type.item_path) + if(initial(buyback_type.match_subtypes) ? ispath(piece, path) : piece == path) + found = buyback_type + break + if(!found) + TEST_FAIL("[shop.type] has no trade-in for [piece], which Splice sells for credits") + continue + if(initial(found.pay_credits) * 2 != prices[piece]) + TEST_FAIL("[found] pays [initial(found.pay_credits)] cr for [piece], not half its [prices[piece]] cr list") + if(initial(found.pay_vouchers)) + TEST_FAIL("[found] pays vouchers") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_kit.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_kit.dm new file mode 100644 index 00000000000..193ee516d54 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_kit.dm @@ -0,0 +1,79 @@ +/** + * # Chrome test kit (voidcrew/modules/admin/chrome_test_kit.dm) + * + * The verb itself needs a client and a menu, so these tests hold the parts under it: every + * ready-made build is made of real chrome, fits one body without evicting itself, comes out + * running, and what does not fit is handed back rather than lost; a body missing a limb is + * not forced to take chrome for it; "everything" really is the whole shelf. + */ + +/datum/unit_test/voidcrew_cyberware_kit_loadouts + +/datum/unit_test/voidcrew_cyberware_kit_loadouts/Run() + TEST_ASSERT(length(GLOB.chrome_test_loadouts) >= 3, "The kit offers only [length(GLOB.chrome_test_loadouts)] builds") + for(var/loadout_name in GLOB.chrome_test_loadouts) + var/list/ware_types = GLOB.chrome_test_loadouts[loadout_name] + TEST_ASSERT(length(ware_types), "The [loadout_name] build is empty") + // No two pieces of a build may want the same slot, or one would evict the other. + var/list/slots = list() + for(var/ware_type in ware_types) + TEST_ASSERT(ispath(ware_type, /obj/item/organ), "[loadout_name]: [ware_type] is not an organ") + var/obj/item/organ/example = ware_type + var/slot_name = initial(example.slot) + TEST_ASSERT(!slots[slot_name], "[loadout_name]: [ware_type] and [slots[slot_name]] share the slot [slot_name]") + slots[slot_name] = "[ware_type]" + var/mob/living/carbon/human/body = allocate(/mob/living/carbon/human/consistent) + var/list/report = list() + var/list/left_over = chrome_kit_install(body, ware_types, report) + for(var/obj/item/organ/spare as anything in left_over) + TEST_ASSERT(!QDELETED(spare) && !spare.owner, "[loadout_name]: a piece left over is deleted or still owned") + qdel(spare) + TEST_ASSERT_EQUAL(length(get_installed_cyberware(body)) + length(left_over), length(ware_types), "[loadout_name]: pieces went missing between the list and the body") + TEST_ASSERT(get_chrome_load(body) <= get_chrome_capacity(body), "[loadout_name]: the kit left the body over capacity ([get_chrome_load(body)] of [get_chrome_capacity(body)])") + for(var/obj/item/organ/ware as anything in get_installed_cyberware(body)) + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + TEST_ASSERT(chrome.is_running(), "[loadout_name]: [ware.type] came out of the kit dark") + // The first piece listed is the one the build is named for; it must always make it. + var/first_type = ware_types[1] + TEST_ASSERT(locate(first_type) in body.organs, "[loadout_name]: its first piece, [first_type], did not install") + +/// A body with no left arm takes the right-arm pieces and hands the left-arm ones back. +/datum/unit_test/voidcrew_cyberware_kit_limbs + +/datum/unit_test/voidcrew_cyberware_kit_limbs/Run() + var/mob/living/carbon/human/body = allocate(/mob/living/carbon/human/consistent) + var/obj/item/bodypart/arm = body.get_bodypart(BODY_ZONE_L_ARM) + arm.drop_limb() + qdel(arm) + var/list/report = list() + var/list/left_over = chrome_kit_install(body, list( + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left, + ), report) + TEST_ASSERT_EQUAL(length(left_over), 1, "The left housing should have been handed back, got [length(left_over)] pieces") + var/obj/item/organ/handed_back = left_over[1] + TEST_ASSERT(istype(handed_back, /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left), "The wrong piece was handed back: [handed_back.type]") + TEST_ASSERT(!handed_back.owner && isturf(handed_back.loc), "The handed-back housing is not loose on the floor") + TEST_ASSERT_EQUAL(length(report), 1, "The kit should name the piece it left out, got [length(report)] lines") + TEST_ASSERT(findtext(report[1], "no limb"), "The kit did not say it was the missing limb: [report[1]]") + TEST_ASSERT_EQUAL(length(get_installed_cyberware(body)), 1, "The right housing did not install on its own") + qdel(handed_back) + +/// The "everything" crate covers every organ any ripperdoc shelf sells, once. +/datum/unit_test/voidcrew_cyberware_kit_everything + +/datum/unit_test/voidcrew_cyberware_kit_everything/Run() + var/list/everything = chrome_kit_everything_types() + TEST_ASSERT(length(everything) > 40, "The everything crate holds only [length(everything)] kinds") + for(var/datum/shop_sku/sku_type as anything in subtypesof(/datum/shop_sku/ripperdoc)) + var/item_path = initial(sku_type.item_path) + if(ispath(item_path, /obj/item/organ) || ispath(item_path, /obj/item/cyberware_pair_case) || ispath(item_path, /obj/item/storage/case/cyberware)) + TEST_ASSERT(item_path in everything, "The everything crate is missing [item_path], which [sku_type] sells") + TEST_ASSERT(/obj/item/organ/cyberimp/cyberware/piledriver in everything, "The everything crate is missing the Piledriver, which no shelf sells") + // Built the way the verb builds it, the crate's contents are loose, real chrome. + var/list/made = list() + for(var/ware_type in everything) + made += allocate(ware_type) + var/obj/structure/closet/crate/crate = chrome_kit_crate(run_loc_floor_bottom_left, made, "test crate") + allocated += crate + TEST_ASSERT_EQUAL(length(crate.contents), length(everything), "The crate lost items on the way in") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_mantis.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_mantis.dm new file mode 100644 index 00000000000..df1703dde96 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_mantis.dm @@ -0,0 +1,159 @@ +/** + * # Mantis Blades line (Shiv and Scorch models) + * + * The street model has no lunge, the fire model keeps the parent's lunge and + * adds fire, a cut lights the target and never the wielder, and the pair + * cases quote prices through the cradle's index. Unit-test files compile before + * voidcrew/_DEFINES/, so the numbers below are literals. + */ +/datum/unit_test/voidcrew_cyberware_mantis_line + +/datum/unit_test/voidcrew_cyberware_mantis_line/Run() + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/parent = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/street = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/scorch = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch) + + // The parent keeps its numbers: the defines became vars with the same values. + TEST_ASSERT_EQUAL(parent.lunge_range, 5, "Mantis lunge range changed") + TEST_ASSERT_EQUAL(parent.lunge_bonus, 10, "Mantis lunge bonus changed") + TEST_ASSERT_EQUAL(parent.lunge_fire_stacks, 0, "The plain Mantis lunge sets people on fire") + + // Item Initialize() turns actions_types into granted actions and nulls the list. + TEST_ASSERT(!(locate(/datum/action/cooldown/cyberware/mantis_lunge) in (street.actions || list())), "Shiv Blades got a lunge") + TEST_ASSERT(locate(/datum/action/cooldown/cyberware/mantis_lunge) in (scorch.actions || list()), "Scorch Blades lost the lunge") + TEST_ASSERT_EQUAL(scorch.lunge_fire_stacks, 4, "Scorch lunge fire is not 4 stacks") + + // Same slot as the parent, so the line evicts itself. + TEST_ASSERT_EQUAL(street.slot, parent.slot, "Shiv housing is not in the Mantis arm slot") + TEST_ASSERT_EQUAL(scorch.slot, parent.slot, "Scorch housing is not in the Mantis arm slot") + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/left/street_left = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/left) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left/scorch_left = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left) + TEST_ASSERT_EQUAL(street_left.slot, ORGAN_SLOT_LEFT_ARM_AUG, "Left Shiv housing is not in the left arm slot") + TEST_ASSERT_EQUAL(scorch_left.slot, ORGAN_SLOT_LEFT_ARM_AUG, "Left Scorch housing is not in the left arm slot") + + // The weaker blade. + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street/street_blade = allocate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis/street) + TEST_ASSERT_EQUAL(street_blade.force, 14, "Shiv blade force is not 14") + + // Cases carry a matched pair of the right model. + var/obj/item/cyberware_pair_case/mantis_street/street_case = allocate(/obj/item/cyberware_pair_case/mantis_street) + var/obj/item/cyberware_pair_case/mantis_scorch/scorch_case = allocate(/obj/item/cyberware_pair_case/mantis_scorch) + TEST_ASSERT_EQUAL(length(street_case.contents), 2, "Shiv case isn't a pair") + TEST_ASSERT_EQUAL(length(scorch_case.contents), 2, "Scorch case isn't a pair") + TEST_ASSERT(locate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street/left) in street_case.contents, "Shiv case has no left housing") + TEST_ASSERT(locate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch/left) in scorch_case.contents, "Scorch case has no left housing") + + // Both halves of each case quote the case's price at the cradle. + build_cyberware_price_index() + var/list/street_price = get_cyberware_price(street) + var/list/scorch_price = get_cyberware_price(scorch_left) + TEST_ASSERT(street_price && street_price["credits"] > 0 && street_price["paired"], "Shiv Blades quote no credit price as a pair") + TEST_ASSERT(scorch_price && scorch_price["vouchers"] > 0 && scorch_price["paired"], "Scorch Blades quote no voucher price as a pair") + +/// A cut with the Scorch blade lights the target and never the one holding it, +/// and a corpse is left alone. +/datum/unit_test/voidcrew_cyberware_mantis_scorch + +/datum/unit_test/voidcrew_cyberware_mantis_scorch/Run() + var/mob/living/carbon/human/wielder = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch/blade = allocate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch) + wielder.put_in_active_hand(blade) + blade.attack(victim, wielder, list(), list()) + TEST_ASSERT(victim.fire_stacks >= 2, "A scorch cut left no fire stacks on the target") + TEST_ASSERT(victim.on_fire, "A scorch cut didn't light the target") + TEST_ASSERT(!wielder.on_fire && wielder.fire_stacks <= 0, "A scorch cut put fire on the wielder") + + // A swing that never lands burns nothing: a pacifist's pulled swing returns + // the same FALSE as a cut, so only a cut that reached afterattack() counts. + var/mob/living/carbon/human/spared = allocate(/mob/living/carbon/human/consistent) + ADD_TRAIT(wielder, TRAIT_PACIFISM, TRAIT_SOURCE_UNIT_TESTS) + blade.attack(spared, wielder, list(), list()) + REMOVE_TRAIT(wielder, TRAIT_PACIFISM, TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT(!spared.on_fire && spared.fire_stacks <= 0, "A pacifist's pulled scorch swing set the target alight") + + var/mob/living/carbon/human/corpse = allocate(/mob/living/carbon/human/consistent) + corpse.stat = DEAD + TEST_ASSERT(!cyberware_scorch_target(corpse, 4), "A corpse was set alight") + TEST_ASSERT(!corpse.on_fire, "A corpse is burning") + +/// The worn housing sprite shows the blade folded in, so each arm's housing +/// hides while that arm's blade is out and comes back when the blade is stowed, +/// knocked out of the hand, the chrome is EMP'd, or the housing is pulled. +/datum/unit_test/voidcrew_cyberware_mantis_stowed_overlay + +/datum/unit_test/voidcrew_cyberware_mantis_stowed_overlay/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left/left = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left) + TEST_ASSERT(right.Insert(bearer, special = TRUE), "Test fixture: right housing insert refused") + TEST_ASSERT(left.Insert(bearer, special = TRUE), "Test fixture: left housing insert refused") + var/obj/item/bodypart/right_arm = bearer.get_bodypart(BODY_ZONE_R_ARM) + var/obj/item/bodypart/left_arm = bearer.get_bodypart(BODY_ZONE_L_ARM) + var/obj/item/blade = right.contents[1] + TEST_ASSERT(right.bodypart_aug in right_arm.bodypart_overlays, "Test fixture: the right housing has no worn overlay on the arm") + TEST_ASSERT(stowed_drawn(bearer, right_arm, right), "A stowed housing isn't drawn") + + right.Extend(blade) + TEST_ASSERT(bearer.is_holding(blade), "Test fixture: the blade never reached a hand") + TEST_ASSERT(!stowed_drawn(bearer, right_arm, right), "The folded housing still draws with its blade out") + TEST_ASSERT(stowed_drawn(bearer, left_arm, left), "Deploying the right blade hid the left housing") + + right.Retract() + TEST_ASSERT(stowed_drawn(bearer, right_arm, right), "The housing didn't come back when the blade was stowed") + + right.Extend(blade) + bearer.dropItemToGround(blade, force = TRUE) + TEST_ASSERT(stowed_drawn(bearer, right_arm, right), "The housing stayed hidden after the blade left the hand") + right.Retract() + TEST_ASSERT(blade.loc == right, "Test fixture: the dropped blade never went back into the housing") + + var/datum/component/cyberware/chrome = right.GetComponent(/datum/component/cyberware) + right.Extend(blade) + chrome.start_emp_reboot() + TEST_ASSERT(blade.loc == right, "Test fixture: the EMP didn't stow the blade") + TEST_ASSERT(stowed_drawn(bearer, right_arm, right), "The housing stayed hidden after an EMP stowed the blade") + chrome.tune_up() + + right.Extend(blade) + right.Remove(bearer, special = TRUE) + TEST_ASSERT(!(right.bodypart_aug in right_arm.bodypart_overlays), "A pulled housing left its overlay on the arm") + // A fresh body: tg's arm implants never drop their bearer signals on removal, + // so going back into the same body trips a double-registration warning. + var/mob/living/carbon/human/next_bearer = allocate(/mob/living/carbon/human/consistent) + TEST_ASSERT(right.Insert(next_bearer, special = TRUE), "Test fixture: installing the pulled housing was refused") + TEST_ASSERT(stowed_drawn(next_bearer, next_bearer.get_bodypart(BODY_ZONE_R_ARM), right), "A housing pulled with its blade out doesn't draw in its next body") + +/// TRUE when the housing's worn overlay is both allowed to draw and present in the +/// arm's last render key, so a missed redraw fails as well as a wrong check. +/datum/unit_test/voidcrew_cyberware_mantis_stowed_overlay/proc/stowed_drawn(mob/living/carbon/human/bearer, obj/item/bodypart/arm, obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing) + var/drawable = housing.bodypart_aug.can_draw_on_bodypart(arm) + var/in_key = !!findtext(bearer.icon_render_keys[arm.body_zone], housing.get_overlay_state()) + TEST_ASSERT_EQUAL(drawable, in_key, "[housing] can_draw_on_bodypart() and the arm's render key disagree, the arm was not redrawn") + return drawable + +/// Worn chrome with a glow (Cascade, Redline) must not black the glow out with +/// its own emissive blocker: the glow comes after every blocker the overlay makes. +/datum/unit_test/voidcrew_cyberware_worn_glow + +/datum/unit_test/voidcrew_cyberware_worn_glow/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/cascade/lattice = allocate(/obj/item/organ/cyberimp/cyberware/cascade) + TEST_ASSERT(lattice.Insert(bearer, special = TRUE), "Test fixture: Cascade insert refused") + var/obj/item/bodypart/chest = bearer.get_bodypart(BODY_ZONE_CHEST) + var/list/images = lattice.bodypart_aug.get_overlay(EXTERNAL_ADJACENT, chest) + var/glow_at = 0 + var/last_blocker_at = 0 + for(var/i in 1 to length(images)) + var/mutable_appearance/part = images[i] + if(PLANE_TO_TRUE(part.plane) != EMISSIVE_PLANE) + continue + // The emissive matrix puts its glow in the constant row; a blocker's constant row is all zero. + var/list/matrix = part.color + if(islist(matrix) && length(matrix) >= 20 && (matrix[17] || matrix[18] || matrix[19])) + glow_at = i + else + last_blocker_at = i + TEST_ASSERT(glow_at, "The Cascade worn overlay has no glow") + TEST_ASSERT(last_blocker_at, "The Cascade worn overlay has no emissive blocker") + TEST_ASSERT(glow_at > last_blocker_at, "An emissive blocker sits on top of the Cascade glow") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_matrix.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_matrix.dm new file mode 100644 index 00000000000..e9a5ad6f03b --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_matrix.dm @@ -0,0 +1,775 @@ +/** + * # Chrome interaction matrix + * + * Every piece of chrome against the things that happen to a body: an EMP, a brownout, death + * and revival, a gib or a dusting, a lost limb, a pacifist trait, a stun or a ride in a mech. + * The tests walk the whole roster (every non-fixture subtype of the three chrome organ bases), + * so a new ware is covered the day it is added. What each column promises is in the test that + * checks it. The same walk writes one line per ware and condition to data/matrix_observed.txt, + * which is where the written matrix (kept with the cyberware notes) is built from. + * + * Unit-test files compile before voidcrew/_DEFINES/, so the fork defines this file needs are + * restated below under MATRIX_ names. + */ + +/// TRAIT_CYBER_CAMO and TRAIT_CYBER_ZOOMED. +#define MATRIX_TRAIT_CAMO "cyber_camo" +#define MATRIX_TRAIT_ZOOMED "cyber_zoomed" +/// ORGAN_SLOT_CYBERWARE_SKIN, the Ghostskin slot. +#define MATRIX_SLOT_SKIN "cyberware_skin" + +/// Every chrome typepath the matrix and the soak walk: each non-fixture subtype of the three +/// chrome organ bases that has a body zone and a slot. +/proc/voidcrew_cyberware_pool() + var/static/list/pool + if(pool) + return pool + pool = list() + for(var/base in list(/obj/item/organ/cyberimp/cyberware, /obj/item/organ/eyes/robotic/cyberware, /obj/item/organ/cyberimp/arm/toolkit/cyberware)) + for(var/ware_type in subtypesof(base)) + var/path_text = "[ware_type]" + // Fixtures tests define (test_, the ballast pieces, voidcrew_*_test). + if(findtext(path_text, "/test_") || findtext(path_text, "ballast") || findtext(path_text, "_test")) + continue + var/obj/item/organ/example = ware_type + if(!initial(example.zone) || !initial(example.slot)) + continue + pool += ware_type + return pool + +/// What a body looks like to the passive layer: physiology numbers and armour, movement and +/// action speed modifiers. Equal before a ware goes in and while it is dark. +/proc/voidcrew_cyberware_passive_state(mob/living/carbon/human/body) + var/list/state = list() + for(var/var_name in body.physiology.vars) + var/value = body.physiology.vars[var_name] + if(isnum(value)) + state["physiology [var_name]"] = value + for(var/rating in ARMOR_LIST_ALL()) + state["armor [rating]"] = body.physiology.armor.get_rating(rating) + // Damage, lying down and mood come and go on their own; they are not what the chrome put there + // (a Redline crash dumps enough stamina to put its bearer on the floor). + var/list/speed = list() + for(var/modifier in body.movespeed_modification) + if(!findtext("[modifier]", "damage_slowdown") && !findtext("[modifier]", "carbon_crawling")) + speed += "[modifier]" + state["movespeed"] = speed.Join(",") + var/list/action_speed = list() + for(var/modifier in body.actionspeed_modification) + if(!findtext("[modifier]", "sanity_component")) + action_speed += "[modifier]" + state["actionspeed"] = action_speed.Join(",") + return state + +/// Every trait a ware itself is holding on its bearer. +/proc/voidcrew_cyberware_held_traits(mob/living/carbon/human/body, obj/item/organ/ware) + var/list/held = list() + var/ware_ref = REF(ware) + for(var/trait in body._status_traits) + if(ware_ref in body._status_traits[trait]) + held += "[trait]" + return held + +/// The differences between two passive states, as lines. +/proc/voidcrew_cyberware_state_diff(list/before, list/after) + var/list/differences = list() + for(var/key in before) + if(before[key] != after[key]) + differences += "[key] [before[key]] -> [after[key]]" + for(var/key in after) + if(isnull(before[key])) + differences += "[key] gained [after[key]]" + return differences + +/// Chrome-side datums still registered on a body they no longer belong to. Empty when the +/// body's signal table holds only what its current chrome put there. +/proc/voidcrew_cyberware_stale_listeners(mob/living/carbon/human/body) + var/list/stale = list() + for(var/signal in body._listen_lookup) + var/looked_up = body._listen_lookup[signal] + var/list/listeners = islist(looked_up) ? looked_up : list(looked_up) + for(var/datum/listener as anything in listeners) + if(QDELETED(listener)) + stale += "[signal]: deleted [listener.type]" + else if(isorgan(listener)) + var/obj/item/organ/organ = listener + if(organ.owner != body) + stale += "[signal]: [organ.type] (not installed)" + else if(istype(listener, /datum/component/cyberware)) + var/datum/component/cyberware/chrome = listener + var/obj/item/organ/parent_ware = chrome.parent + if(parent_ware?.owner != body) + stale += "[signal]: cyberware component of [parent_ware?.type] (not installed)" + else if(istype(listener, /datum/action)) + var/datum/action/ability = listener + if(ability.owner != body) + stale += "[signal]: action [ability.type] (not owned)" + else if(istype(listener, /datum/status_effect)) + var/datum/status_effect/effect = listener + if(effect.owner != body) + stale += "[signal]: status [effect.type] (not applied)" + return stale + +/// Pulled and held by the matrix tests: a heavy ballast piece that pushes any body past its +/// capacity (sized per body when it goes in). Separate from the soak's, so the two files +/// stand alone. +/obj/item/organ/cyberimp/cyberware/matrix_ballast + name = "matrix ballast" + zone = BODY_ZONE_CHEST + slot = "voidcrew_matrix_ballast" + chrome_load = 25 + +/datum/unit_test/voidcrew_cyberware_matrix + abstract_type = /datum/unit_test/voidcrew_cyberware_matrix + /// Which column of the matrix this test is. + var/column = "?" + /// Lines for data/matrix_observed.txt. + var/list/observed = list() + +/datum/unit_test/voidcrew_cyberware_matrix/Destroy() + if(length(observed)) + var/text = "[observed.Join("\n")]\n" + text2file(text, "data/matrix_observed.txt") + return ..() + +/// One cell: this ware, this condition, what happened. +/datum/unit_test/voidcrew_cyberware_matrix/proc/cell(ware_type, result) + observed += "[column]\t[ware_type]\t[result]" + +/// A fresh body with one ware special-inserted, or null when this ware has no home on it. +/datum/unit_test/voidcrew_cyberware_matrix/proc/fit(ware_type, list/out_ware) + var/mob/living/carbon/human/body = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/ware = allocate(ware_type) + if(!body.get_bodypart(deprecise_zone(ware.zone)) || !ware.Insert(body, special = TRUE)) + qdel(ware) + qdel(body) + return null + out_ware += ware + return body + +/// The cooldown buttons of a ware, reset so only the chrome can stand in the way. +/datum/unit_test/voidcrew_cyberware_matrix/proc/buttons(obj/item/organ/ware) + var/list/found = list() + for(var/datum/action/cooldown/cyberware/ability in ware.actions) + ability.next_use_time = 0 + found += ability + return found + +/// The deployable of an arm piece, if it has one. +/datum/unit_test/voidcrew_cyberware_matrix/proc/arm_item(obj/item/organ/ware) + if(!istype(ware, /obj/item/organ/cyberimp/arm/toolkit/cyberware)) + return null + return locate(/obj/item) in ware.contents + +/// EMP: a pulse takes the whole ware dark and takes every passive with it, and the +/// repair brings it all back exactly as it was. Repeated, so a non-idempotent passive that +/// stacks on every reboot shows. +/datum/unit_test/voidcrew_cyberware_matrix/emp + column = "emp" + +/datum/unit_test/voidcrew_cyberware_matrix/emp/Run() + var/mob/living/carbon/human/bare = allocate(/mob/living/carbon/human/consistent) + var/list/bare_state = voidcrew_cyberware_passive_state(bare) + for(var/ware_type in voidcrew_cyberware_pool()) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + cell(ware_type, "no home on a plain body") + continue + var/obj/item/organ/ware = wares[1] + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + TEST_ASSERT_NOTNULL(chrome, "[ware_type] carries no cyberware component") + var/list/lit_state = voidcrew_cyberware_passive_state(body) + var/list/problems = list() + var/list/cooldowns = buttons(ware) + var/list/ready_before = list() + for(var/datum/action/cooldown/cyberware/ability as anything in cooldowns) + if(ability.IsAvailable()) + ready_before += ability + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(arm_thing) + arm_ware.Extend(arm_thing) + var/obj/item/organ/eyes/robotic/cyberware/optics = ware + if(istype(optics)) + optics.engage_zoom(body) + for(var/cycle in 1 to 3) + body.emp_act(EMP_HEAVY) + if(!chrome.emp_down || chrome.is_running() || !(ware.organ_flags & ORGAN_FAILING)) + problems += "a pulse left it running (emp_down [chrome.emp_down], flags [ware.organ_flags])" + if(chrome.passives_online) + problems += "passives stayed on through the pulse" + // One heartbeat: the readout-style passives settle on the organ's own tick. + ware.on_life(2, 1) + var/list/held = voidcrew_cyberware_held_traits(body, ware) + if(length(held)) + problems += "held traits through the pulse: [english_list(held)]" + var/list/leaks = voidcrew_cyberware_state_diff(bare_state, voidcrew_cyberware_passive_state(body)) + if(length(leaks)) + problems += "the passive layer is not bare while dark: [english_list(leaks)]" + for(var/datum/action/cooldown/cyberware/ability as anything in ready_before) + if(ability.IsAvailable()) + problems += "[ability.type] still available while dark" + if(arm_thing && arm_ware.active_item) + problems += "the arm weapon stayed out through the pulse" + if(istype(optics) && optics.is_zoomed()) + problems += "the zoom stayed on through the pulse" + chrome.tune_up() + if(!chrome.is_running() || !chrome.passives_online) + problems += "a tune-up did not bring it back (running [chrome.is_running()], passives [chrome.passives_online])" + var/list/restored = voidcrew_cyberware_state_diff(lit_state, voidcrew_cyberware_passive_state(body)) + if(length(restored)) + problems += "reboot number [cycle] did not restore the body exactly: [english_list(restored)]" + if(arm_thing) + arm_ware.Extend(arm_thing) + if(istype(optics)) + optics.engage_zoom(body) + if(length(problems)) + cell(ware_type, "FAIL: [problems[1]]") + TEST_FAIL("[ware_type]: [english_list(problems)]") + else + cell(ware_type, "ok") + qdel(body) + +/// Brownout: a body past its capacity takes every piece dark with the same bare passive +/// layer, and recovers when the load drops. +/datum/unit_test/voidcrew_cyberware_matrix/brownout + column = "brownout" + +/datum/unit_test/voidcrew_cyberware_matrix/brownout/Run() + var/mob/living/carbon/human/bare = allocate(/mob/living/carbon/human/consistent) + var/list/bare_state = voidcrew_cyberware_passive_state(bare) + for(var/ware_type in voidcrew_cyberware_pool()) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + cell(ware_type, "no home on a plain body") + continue + var/obj/item/organ/ware = wares[1] + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + var/list/lit_state = voidcrew_cyberware_passive_state(body) + var/list/problems = list() + var/list/cooldowns = buttons(ware) + var/list/ready_before = list() + for(var/datum/action/cooldown/cyberware/ability as anything in cooldowns) + if(ability.IsAvailable()) + ready_before += ability + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(arm_thing) + arm_ware.Extend(arm_thing) + var/obj/item/organ/eyes/robotic/cyberware/optics = ware + if(istype(optics)) + optics.engage_zoom(body) + var/obj/item/organ/cyberimp/cyberware/matrix_ballast/ballast = allocate(/obj/item/organ/cyberimp/cyberware/matrix_ballast) + var/datum/component/cyberware/ballast_chrome = ballast.GetComponent(/datum/component/cyberware) + ballast_chrome.chrome_load = get_chrome_capacity(body) + 5 + ballast.Insert(body, special = TRUE) + if(!chrome.browned_out || chrome.is_running() || !(ware.organ_flags & ORGAN_FAILING)) + problems += "an overloaded body left it running (browned_out [chrome.browned_out])" + if(chrome.passives_online) + problems += "passives stayed on through the brownout" + ware.on_life(2, 1) + var/list/held = voidcrew_cyberware_held_traits(body, ware) + if(length(held)) + problems += "held traits through the brownout: [english_list(held)]" + var/list/leaks = voidcrew_cyberware_state_diff(bare_state, voidcrew_cyberware_passive_state(body)) + // The ballast is a ware too, so its own (empty) layer is part of the picture. + if(length(leaks)) + problems += "the passive layer is not bare while browned out: [english_list(leaks)]" + for(var/datum/action/cooldown/cyberware/ability as anything in ready_before) + if(ability.IsAvailable()) + problems += "[ability.type] still available while browned out" + if(arm_thing && arm_ware.active_item) + problems += "the arm weapon stayed out through the brownout" + if(istype(optics) && optics.is_zoomed()) + problems += "the zoom stayed on through the brownout" + ballast.Remove(body, special = TRUE) + if(!chrome.is_running() || !chrome.passives_online) + problems += "easing the load did not bring it back (running [chrome.is_running()], passives [chrome.passives_online])" + var/list/restored = voidcrew_cyberware_state_diff(lit_state, voidcrew_cyberware_passive_state(body)) + if(length(restored)) + problems += "easing the load did not restore the body exactly: [english_list(restored)]" + if(length(problems)) + cell(ware_type, "FAIL: [problems[1]]") + TEST_FAIL("[ware_type]: [english_list(problems)]") + else + cell(ware_type, "ok") + qdel(body) + +/// Death and revival: the buttons go dark with the body, and a revived body gets the same +/// passive layer back, however many times it dies. +/datum/unit_test/voidcrew_cyberware_matrix/death + column = "death/revive" + +/datum/unit_test/voidcrew_cyberware_matrix/death/Run() + for(var/ware_type in voidcrew_cyberware_pool()) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + cell(ware_type, "no home on a plain body") + continue + var/obj/item/organ/ware = wares[1] + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + var/list/lit_state = voidcrew_cyberware_passive_state(body) + var/list/lit_traits = voidcrew_cyberware_held_traits(body, ware) + var/list/problems = list() + var/list/cooldowns = buttons(ware) + var/list/ready_before = list() + for(var/datum/action/cooldown/cyberware/ability as anything in cooldowns) + if(ability.IsAvailable()) + ready_before += ability + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + var/obj/item/organ/eyes/robotic/cyberware/optics = ware + for(var/cycle in 1 to 2) + if(arm_thing) + arm_ware.Extend(arm_thing) + if(istype(optics)) + optics.engage_zoom(body) + body.death() + if(ware.owner != body) + problems += "death took it out of the body" + for(var/datum/action/cooldown/cyberware/ability as anything in ready_before) + if(ability.IsAvailable()) + problems += "[ability.type] still available on a dead body" + if(istype(optics) && optics.is_zoomed()) + problems += "the zoom stayed on through death" + body.revive(ADMIN_HEAL_ALL) + if(body.stat == DEAD) + problems += "the fixture would not revive" + break + // Healing refreshes organs, which can clear the shared failing bit; the next tick puts it right. + chrome.update_failing() + if(!chrome.is_running() || chrome.passives_online != !!chrome.is_running()) + problems += "revival left it out of step (running [chrome.is_running()], passives [chrome.passives_online])" + var/list/restored = voidcrew_cyberware_state_diff(lit_state, voidcrew_cyberware_passive_state(body)) + if(length(restored)) + problems += "death number [cycle] changed the passive layer: [english_list(restored)]" + var/list/held_now = voidcrew_cyberware_held_traits(body, ware) + if(length(held_now) != length(lit_traits) || length(held_now ^ lit_traits)) + problems += "death number [cycle] changed the traits it holds" + if(length(problems)) + cell(ware_type, "FAIL: [problems[1]]") + TEST_FAIL("[ware_type]: [english_list(problems)]") + else + cell(ware_type, "ok") + qdel(body) + +/// Gibbing and dusting: the chrome comes out whole on the floor. +/datum/unit_test/voidcrew_cyberware_matrix/gib + column = "gib/dust" + +/datum/unit_test/voidcrew_cyberware_matrix/gib/Run() + for(var/ware_type in voidcrew_cyberware_pool()) + for(var/dusting in list(FALSE, TRUE)) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + if(!dusting) + cell(ware_type, "no home on a plain body") + continue + var/obj/item/organ/ware = wares[1] + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(arm_thing) + arm_ware.Extend(arm_thing) + if(dusting) + body.dust() + else + body.gib() + var/problem + if(QDELETED(ware)) + problem = "[dusting ? "dusting" : "gibbing"] destroyed it" + else if(ware.owner) + problem = "it is still owned by the corpse" + else if(!isturf(ware.loc)) + problem = "it ended up in [ware.loc ? ware.loc.type : "nullspace"], not on the floor" + else if(arm_thing && (QDELETED(arm_thing) || arm_thing.loc != ware)) + problem = "its deployed weapon did not go back into it" + cell(ware_type, "[dusting ? "dust" : "gib"]: [problem ? "FAIL: [problem]" : "ok"]") + if(problem) + TEST_FAIL("[ware_type]: [problem]") + +/// Limbs: a limb that is gone cannot take its chrome, and chrome in a limb that goes is let go +/// cleanly with every passive. +/datum/unit_test/voidcrew_cyberware_matrix/limb + column = "missing limb" + +/datum/unit_test/voidcrew_cyberware_matrix/limb/Run() + for(var/ware_type in voidcrew_cyberware_pool()) + var/obj/item/organ/example = ware_type + var/zone = initial(example.zone) + if(!(zone in list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG))) + cell(ware_type, "n/a (not in a limb)") + continue + // A body with no such limb is offered the chrome the real way. + var/mob/living/carbon/human/maimed = allocate(/mob/living/carbon/human/consistent) + var/obj/item/bodypart/gone = maimed.get_bodypart(zone) + gone.drop_limb() + qdel(gone) + var/obj/item/organ/offered = allocate(ware_type) + var/datum/component/cyberware/offered_chrome = offered.GetComponent(/datum/component/cyberware) + offered_chrome.grant_install_context(maimed) + var/list/problems = list() + var/took = offered.Insert(maimed) + if(took) + problems += "it installed into a body with no [zone]" + if(offered.owner || (offered in maimed.organs)) + problems += "a refused install still left it on the body" + if(QDELETED(offered)) + problems += "a refused install destroyed it" + else if(!isturf(offered.loc)) + problems += "a refused install left it in [offered.loc ? offered.loc.type : "nullspace"]" + if(get_chrome_load(maimed) != 0) + problems += "the maimed body carries load [get_chrome_load(maimed)] for chrome it does not hold" + // Chrome in a limb that is then lost. + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(body) + var/obj/item/organ/ware = wares[1] + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(arm_thing) + arm_ware.Extend(arm_thing) + var/obj/item/bodypart/limb = body.get_bodypart(zone) + limb.dismember() + if(ware.owner) + problems += "it stayed owned by a body that lost the limb" + if(length(voidcrew_cyberware_held_traits(body, ware))) + problems += "it still held traits on a body that lost the limb" + if(get_chrome_load(body) != 0) + problems += "the body kept load [get_chrome_load(body)] after the limb went" + if(arm_thing && !QDELETED(arm_thing) && arm_thing.loc == body) + problems += "the deployed weapon stayed in the hand of a body that lost the arm" + qdel(limb) + if(QDELETED(ware)) + problems += "burning up the limb destroyed it" + qdel(body) + if(length(problems)) + cell(ware_type, "FAIL: [problems[1]]") + TEST_FAIL("[ware_type]: [english_list(problems)]") + else + cell(ware_type, "ok") + qdel(maimed) + +/// Pacifists: a body that cannot hurt anyone cannot hurt anyone with chrome either. Every +/// ware gets the usual ways to hurt: a punch or swing at an adjacent body, then each of its +/// buttons pointed at that body, then a few seconds for any leap to land. +/datum/unit_test/voidcrew_cyberware_matrix/pacifist + column = "pacifist" + +/datum/unit_test/voidcrew_cyberware_matrix/pacifist/Run() + for(var/ware_type in voidcrew_cyberware_pool()) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + cell(ware_type, "no home on a plain body") + continue + var/obj/item/organ/ware = wares[1] + // A second window, so the click lands: the victim stands beside the body. + var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent, get_step(body, EAST)) + ADD_TRAIT(body, TRAIT_PACIFISM, TRAIT_SOURCE_UNIT_TESTS) + body.set_combat_mode(TRUE) + body.face_atom(victim) + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(arm_thing) + arm_ware.Extend(arm_thing) + click_wrapper(body, victim) + var/launched = FALSE + for(var/datum/action/cooldown/cyberware/ability as anything in buttons(ware)) + ability.Trigger(body, NONE, victim) + if(ability.next_use_time > world.time) + launched = TRUE + click_wrapper(body, victim) + if(launched) + sleep(3 SECONDS) + var/harm = victim.getBruteLoss() + victim.getFireLoss() + victim.getToxLoss() + victim.getOxyLoss() + victim.getStaminaLoss() + var/knocked = victim.IsKnockdown() || victim.IsParalyzed() || victim.IsStun() + if(harm > 0 || knocked) + cell(ware_type, "FAIL: hurt someone while a pacifist ([harm] damage[knocked ? ", knocked down" : ""])") + TEST_FAIL("[ware_type]: a pacifist hurt a bystander with it ([harm] damage[knocked ? ", knocked down" : ""])") + else + cell(ware_type, "ok") + qdel(victim) + qdel(body) + +/// Moving and striking buttons refuse a body that is stunned, paralysed, immobilised or +/// riding a mech, and still work for a healthy one. Only the buttons that carry the bearer +/// across the floor or into a blow are walked: the rest are covered by the other columns. +/datum/unit_test/voidcrew_cyberware_matrix/incapacitated + column = "stunned/mech" + +/datum/unit_test/voidcrew_cyberware_matrix/incapacitated/Run() + var/static/list/movers = list( + /datum/action/cooldown/cyberware/hopper_leap, + /datum/action/cooldown/cyberware/piledriver_leap, + /datum/action/cooldown/cyberware/mantis_lunge, + /datum/action/cooldown/cyberware/skyhook, + ) + for(var/ware_type in voidcrew_cyberware_pool()) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + continue + var/obj/item/organ/ware = wares[1] + var/list/walked = list() + for(var/datum/action/cooldown/cyberware/ability as anything in buttons(ware)) + for(var/mover_type in movers) + if(istype(ability, mover_type)) + walked += ability + if(!length(walked)) + qdel(body) + continue + var/turf/start = get_turf(body) + var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent, locate(start.x, start.y + 2, start.z)) + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + var/turf/landing = locate(start.x + 3, start.y, start.z) + var/turf/far_wall = locate(start.x, start.y + 5, start.z) + for(var/datum/action/cooldown/cyberware/ability as anything in walked) + var/list/results = list() + for(var/condition in list("healthy", "stunned", "paralyzed", "immobilized", "cuffed", "in a mech")) + body.forceMove(start) + body.SetStun(0) + body.SetParalyzed(0) + body.SetImmobilized(0) + body.set_handcuffed(null) + // The blade comes out while the body is still well. + if(arm_thing && !arm_ware.active_item) + arm_ware.Extend(arm_thing) + var/obj/vehicle/sealed/mecha/ripley/mech + switch(condition) + if("stunned") + body.Stun(30 SECONDS) + if("paralyzed") + body.Paralyze(30 SECONDS) + if("immobilized") + body.Immobilize(30 SECONDS) + if("cuffed") + body.set_handcuffed(new /obj/item/restraints/handcuffs(body)) + if("in a mech") + mech = new /obj/vehicle/sealed/mecha/ripley(start) + mech.mob_enter(body, silent = TRUE) + ability.next_use_time = 0 + ability.Trigger(body, NONE, victim) + var/fired = ability.next_use_time > world.time + if(!fired) + ability.next_use_time = 0 + ability.Trigger(body, NONE, landing) + fired = ability.next_use_time > world.time + if(!fired) + // The winch wants a wall: the far side of the room. + ability.next_use_time = 0 + ability.Trigger(body, NONE, far_wall) + fired = ability.next_use_time > world.time + results[condition] = fired + if(fired) + sleep(2 SECONDS) + if(mech) + mech.mob_exit(body, silent = TRUE) + qdel(mech) + body.SetStun(0) + body.SetParalyzed(0) + body.SetImmobilized(0) + body.set_handcuffed(null) + var/list/line = list() + for(var/condition in results) + line += "[condition] [results[condition] ? "fires" : "refuses"]" + if(!results["healthy"]) + // The fixture could not aim it; say so rather than pass quietly. + cell("[ware_type] / [ability.type]", "inconclusive, did not fire for a healthy body") + continue + cell("[ware_type] / [ability.type]", english_list(line)) + for(var/condition in list("stunned", "paralyzed", "immobilized", "in a mech")) + if(results[condition]) + TEST_FAIL("[ware_type] / [ability.type] fired for a body that is [condition]") + qdel(victim) + qdel(body) + +/// A button aimed at its own bearer. Click abilities get clicked on yourself, and every one has +/// to take it without a runtime and without leaving the bearer worse for it than a refusal +/// would. (The Angler's barb used to run a line from the bearer to the bearer.) +/datum/unit_test/voidcrew_cyberware_matrix/self_click + column = "self click" + +/datum/unit_test/voidcrew_cyberware_matrix/self_click/Run() + for(var/ware_type in voidcrew_cyberware_pool()) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + continue + var/obj/item/organ/ware = wares[1] + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(arm_thing) + arm_ware.Extend(arm_thing) + var/turf/before = get_turf(body) + for(var/datum/action/cooldown/cyberware/ability as anything in buttons(ware)) + ability.Trigger(body, NONE, body) + // Whatever it did, it did not carry the bearer off or take the bearer apart. + TEST_ASSERT(!QDELETED(body) && body.stat != DEAD, "[ware_type] / [ability.type] aimed at its own bearer killed or deleted them") + if(ware_type in list(/obj/item/organ/cyberimp/arm/toolkit/cyberware/angler)) + TEST_ASSERT_EQUAL(get_turf(body), before, "The Angler's barb moved a bearer who fired it at themselves") + cell(ware_type, "self click: ok") + sleep(1) + qdel(body) + +/// Taking a ware out, either way, leaves nothing of it listening to the body it left. +/datum/unit_test/voidcrew_cyberware_matrix/listeners + column = "removal" + +/datum/unit_test/voidcrew_cyberware_matrix/listeners/Run() + var/list/bare_state = voidcrew_cyberware_passive_state(allocate(/mob/living/carbon/human/consistent)) + for(var/ware_type in voidcrew_cyberware_pool()) + for(var/quick in list(FALSE, TRUE)) + var/list/wares = list() + var/mob/living/carbon/human/body = fit(ware_type, wares) + if(!body) + if(!quick) + cell(ware_type, "no home on a plain body") + continue + var/obj/item/organ/ware = wares[1] + var/obj/item/arm_thing = arm_item(ware) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(arm_thing) + arm_ware.Extend(arm_thing) + for(var/datum/action/cooldown/cyberware/ability as anything in buttons(ware)) + ability.Trigger(body, NONE, body) + var/list/problems = list() + ware.Remove(body, special = quick) + var/list/stale = voidcrew_cyberware_stale_listeners(body) + if(length(stale)) + problems += "left listening to the body it was pulled from: [english_list(stale)]" + if(length(voidcrew_cyberware_held_traits(body, ware))) + problems += "left traits on the body it was pulled from" + if(length(body.actions)) + problems += "left [length(body.actions)] buttons on the body it was pulled from" + if(arm_thing && arm_ware.active_item) + problems += "still holds its deployed weapon after removal" + if(body.click_intercept) + problems += "left a targeting mode on the body it was pulled from" + var/list/leaks = voidcrew_cyberware_state_diff(bare_state, voidcrew_cyberware_passive_state(body)) + if(length(leaks)) + problems += "left the body changed: [english_list(leaks)]" + cell(ware_type, "[quick ? "quick" : "normal"] removal: [length(problems) ? "FAIL: [problems[1]]" : "ok"]") + if(length(problems)) + TEST_FAIL("[ware_type] ([quick ? "quick" : "normal"] removal): [english_list(problems)]") + qdel(ware) + qdel(body) + +/// Ship saves: a hull checkpoint rebuilds machinery and structures and wipes every loose item, +/// so chrome lying about on a ship is cleared like any other stock and bodies are never +/// kept. The one fitting is the cradle, which a saved ship must never rebuild. +/datum/unit_test/voidcrew_cyberware_matrix/ship_save + column = "ship save" + +/datum/unit_test/voidcrew_cyberware_matrix/ship_save/Run() + var/obj/machinery/chrome_cradle/cradle = allocate(/obj/machinery/chrome_cradle) + TEST_ASSERT(!outpost_checkpoint_saves(cradle), "A ship checkpoint would keep a chrome cradle") + TEST_ASSERT_NULL(cradle.checkpoint_type(), "A chrome cradle has a type to be rebuilt as") + cell("/obj/machinery/chrome_cradle", "not saved by a checkpoint") + // Every chrome organ is a plain item, which the clear-out takes, and none of them is a + // machine or a structure that the checkpoint would keep as a fitting. + for(var/ware_type in voidcrew_cyberware_pool()) + TEST_ASSERT(ispath(ware_type, /obj/item/organ), "[ware_type] is not an organ item") + TEST_ASSERT(!ispath(ware_type, /obj/machinery) && !ispath(ware_type, /obj/structure), "[ware_type] is a machine or structure") + cell("every ware", "organ items: cleared with the loose stock, never kept") + +/// The camo weave's own columns: what ends it. +/datum/unit_test/voidcrew_cyberware_matrix/camo + column = "camo" + +/datum/unit_test/voidcrew_cyberware_matrix/camo/Run() + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave + for(var/weave_type in list(/obj/item/organ/cyberimp/cyberware/ghostskin, /obj/item/organ/cyberimp/cyberware/ghostskin/street)) + for(var/condition in list("emp", "brownout", "death", "stun", "paralyze", "cuffs", "mech", "zoom", "gib")) + var/mob/living/carbon/human/body = allocate(/mob/living/carbon/human/consistent) + weave = allocate(weave_type) + weave.Insert(body, special = TRUE) + weave.engage_camo(body) + var/engaged = HAS_TRAIT(body, MATRIX_TRAIT_CAMO) + var/obj/vehicle/sealed/mecha/ripley/mech + switch(condition) + if("emp") + body.emp_act(EMP_HEAVY) + if("brownout") + var/obj/item/organ/cyberimp/cyberware/matrix_ballast/ballast = allocate(/obj/item/organ/cyberimp/cyberware/matrix_ballast) + ballast.Insert(body, special = TRUE) + if("death") + body.death() + if("stun") + body.Stun(5 SECONDS) + if("paralyze") + body.Paralyze(5 SECONDS) + if("cuffs") + body.set_handcuffed(new /obj/item/restraints/handcuffs(body)) + if("mech") + mech = new /obj/vehicle/sealed/mecha/ripley(get_turf(body)) + mech.mob_enter(body, silent = TRUE) + if("zoom") + var/obj/item/organ/eyes/robotic/cyberware/spyglass/eyes = allocate(/obj/item/organ/eyes/robotic/cyberware/spyglass) + eyes.Insert(body, special = TRUE) + eyes.engage_zoom(body) + if("gib") + body.gib() + var/still = HAS_TRAIT(body, MATRIX_TRAIT_CAMO) + cell("[weave_type]", "[condition]: camo [engaged ? "was on" : "never came on"], then [still ? "stayed on" : "dropped"]") + if(weave_type == /obj/item/organ/cyberimp/cyberware/ghostskin) + TEST_ASSERT(engaged, "Ghostskin would not engage on a healthy body") + // Hard stops: a dark weave, a dead wearer, a stripped body. + if(condition in list("emp", "brownout", "death", "gib")) + TEST_ASSERT(!still, "Ghostskin stayed engaged through [condition]") + else + TEST_ASSERT(!engaged, "the street weave grants camo it should not") + if(mech) + mech.mob_exit(body, silent = TRUE) + qdel(mech) + qdel(body) + qdel(weave) + +/// Doing harm from inside the field drops it, whichever ware does the harm: a punch from a +/// fist that skips the ordinary attack chain, a lunge, a landing. +/datum/unit_test/voidcrew_cyberware_matrix/camo_harm + column = "camo (harm)" + +/datum/unit_test/voidcrew_cyberware_matrix/camo_harm/Run() + for(var/ware_type in list( + /obj/item/organ/cyberimp/cyberware/gorilla_arms, + /obj/item/organ/cyberimp/cyberware/gorilla_arms/street, + /obj/item/organ/cyberimp/cyberware/scrapper, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + /obj/item/organ/cyberimp/cyberware/piledriver, + )) + var/mob/living/carbon/human/body = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent, get_step(body, EAST)) + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = allocate(/obj/item/organ/cyberimp/cyberware/ghostskin) + weave.Insert(body, special = TRUE) + var/obj/item/organ/ware = allocate(ware_type) + TEST_ASSERT(ware.Insert(body, special = TRUE), "[ware_type] would not install beside the weave") + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm_ware = ware + if(istype(arm_ware)) + var/obj/item/blade = locate(/obj/item) in arm_ware.contents + arm_ware.Extend(blade) + body.set_combat_mode(TRUE) + body.face_atom(victim) + weave.engage_camo(body) + TEST_ASSERT(HAS_TRAIT(body, MATRIX_TRAIT_CAMO), "Ghostskin would not engage for [ware_type]") + if(ispath(ware_type, /obj/item/organ/cyberimp/cyberware/piledriver) || istype(arm_ware)) + for(var/datum/action/cooldown/cyberware/ability as anything in buttons(ware)) + ability.Trigger(body, NONE, victim) + else + click_wrapper(body, victim) + var/dropped = !HAS_TRAIT(body, MATRIX_TRAIT_CAMO) + cell("[ware_type]", "camo [dropped ? "dropped" : "stayed up"] when it hurt someone") + if(!dropped) + TEST_FAIL("[ware_type]: the field stayed up while the bearer attacked") + if(ispath(ware_type, /obj/item/organ/cyberimp/cyberware/piledriver) || istype(arm_ware)) + sleep(3 SECONDS) + qdel(body) + qdel(victim) + +#undef MATRIX_TRAIT_CAMO +#undef MATRIX_TRAIT_ZOOMED +#undef MATRIX_SLOT_SKIN diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_models_a.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_models_a.dm new file mode 100644 index 00000000000..25fcd42f6c7 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_models_a.dm @@ -0,0 +1,391 @@ +/** + * # Cyberware models, part A + * + * The Spring calves and Vaulter pistons (Hopper), Brawler myomers (Gorilla Arms), + * Tinker's fingers (Fixer's Fingers), Deepcore drill fist (Rockjaw) and Holdout + * housing (Popup Ronin). Each parent keeps its numbers (the defines became vars + * with the same values), each model shares the parent's slot, and the shelf and + * ledger entries pay what the plan says. Unit-test files compile before + * voidcrew/_DEFINES/, so tiers, slots and zone permissions below are literals: + * tier 1/2/3 are the CYBERWARE_TIER_* values, zone permission 0/1/2 are + * public/yellow/advanced. + */ + +/// The Hopper line: the parent leaps four tiles on an eight second clock with no +/// traits and no fall handler, the Spring calves leap three on fourteen seconds, +/// the Vaulter five on six and carry the Shock Coils' soft landing and dry footing. +/datum/unit_test/voidcrew_cyberware_models_a_hopper + +/datum/unit_test/voidcrew_cyberware_models_a_hopper/Run() + var/obj/item/organ/cyberimp/cyberware/hopper/parent = allocate(/obj/item/organ/cyberimp/cyberware/hopper) + var/obj/item/organ/cyberimp/cyberware/hopper/street/street = allocate(/obj/item/organ/cyberimp/cyberware/hopper/street) + var/obj/item/organ/cyberimp/cyberware/hopper/milspec/milspec = allocate(/obj/item/organ/cyberimp/cyberware/hopper/milspec) + var/obj/item/organ/cyberimp/cyberware/shock_coils/coils = allocate(/obj/item/organ/cyberimp/cyberware/shock_coils) + + // The parent keeps its numbers. + TEST_ASSERT_EQUAL(parent.leap_range, 4, "The Hopper's leap range changed") + TEST_ASSERT_EQUAL(parent.leap_cooldown, 8 SECONDS, "The Hopper's leap cooldown changed") + TEST_ASSERT_EQUAL(parent.chrome_load, 3, "The Hopper's load changed") + TEST_ASSERT_EQUAL(parent.tier, 2, "The Hopper's tier changed") + TEST_ASSERT_NULL(parent.leap_action_desc, "The Hopper's button text is overridden") + TEST_ASSERT(!length(parent.organ_traits), "The Hopper grew a passive trait") + + // The models. + TEST_ASSERT_EQUAL(street.leap_range, 3, "Spring calves don't leap three tiles") + TEST_ASSERT_EQUAL(street.leap_cooldown, 14 SECONDS, "Spring calves' clock isn't fourteen seconds") + TEST_ASSERT_EQUAL(street.chrome_load, 2, "Spring calves' load isn't 2") + TEST_ASSERT_EQUAL(street.tier, 1, "Spring calves aren't tier 1") + TEST_ASSERT(!length(street.organ_traits), "Spring calves got dry footing") + TEST_ASSERT_EQUAL(milspec.leap_range, 5, "Vaulter pistons don't leap five tiles") + TEST_ASSERT_EQUAL(milspec.leap_cooldown, 6 SECONDS, "Vaulter pistons' clock isn't six seconds") + TEST_ASSERT_EQUAL(milspec.chrome_load, 4, "Vaulter pistons' load isn't 4") + TEST_ASSERT_EQUAL(milspec.tier, 3, "Vaulter pistons aren't tier 3") + TEST_ASSERT(TRAIT_NO_SLIP_WATER in milspec.organ_traits, "Vaulter pistons don't keep dry footing") + TEST_ASSERT(street.chrome_load < parent.chrome_load && parent.chrome_load < milspec.chrome_load, "The leg line's loads don't climb") + + // Same slot as the Coils and the parent: the leg ladder evicts itself. + TEST_ASSERT_EQUAL(street.slot, coils.slot, "Spring calves aren't in the leg slot") + TEST_ASSERT_EQUAL(milspec.slot, coils.slot, "Vaulter pistons aren't in the leg slot") + TEST_ASSERT_EQUAL(parent.slot, coils.slot, "The Hopper left the leg slot") + + // Each button takes its cooldown and its text from the pistons it belongs to. + var/datum/action/cooldown/cyberware/hopper_leap/parent_button = locate() in parent.actions + var/datum/action/cooldown/cyberware/hopper_leap/street_button = locate() in street.actions + var/datum/action/cooldown/cyberware/hopper_leap/milspec_button = locate() in milspec.actions + TEST_ASSERT_NOTNULL(parent_button, "The Hopper lost its leap button") + TEST_ASSERT_NOTNULL(street_button, "Spring calves have no leap button") + TEST_ASSERT_NOTNULL(milspec_button, "Vaulter pistons have no leap button") + TEST_ASSERT_EQUAL(parent_button.cooldown_time, 8 SECONDS, "The Hopper's button changed its clock") + TEST_ASSERT(findtext(parent_button.desc, "four tiles"), "The Hopper's button changed its text") + TEST_ASSERT_EQUAL(street_button.cooldown_time, 14 SECONDS, "Spring calves' button kept the wrong clock") + TEST_ASSERT(findtext(street_button.desc, "three tiles"), "Spring calves' button kept the wrong text") + TEST_ASSERT_EQUAL(milspec_button.cooldown_time, 6 SECONDS, "Vaulter pistons' button kept the wrong clock") + TEST_ASSERT(findtext(milspec_button.desc, "five tiles"), "Vaulter pistons' button kept the wrong text") + + // The reach follows the pistons. The arena is five tiles square, so the far + // corner is four tiles from the near one. + var/turf/start = run_loc_floor_bottom_left + var/turf/three_away = locate(start.x + 3, start.y, start.z) + var/turf/four_away = locate(start.x + 4, start.y, start.z) + TEST_ASSERT(isfloorturf(three_away) && isfloorturf(four_away), "The test arena is smaller than the leap test needs") + + var/mob/living/carbon/human/hopper_wearer = allocate(/mob/living/carbon/human/consistent, start) + TEST_ASSERT(parent.Insert(hopper_wearer, special = TRUE), "The Hopper wouldn't go in") + TEST_ASSERT(parent_button.Activate(four_away), "The Hopper wouldn't leap four tiles") + TEST_ASSERT_EQUAL(parent_button.next_use_time, world.time + 8 SECONDS, "The Hopper's leap started the wrong clock") + + var/mob/living/carbon/human/spring_wearer = allocate(/mob/living/carbon/human/consistent, start) + TEST_ASSERT(street.Insert(spring_wearer, special = TRUE), "Spring calves wouldn't go in") + TEST_ASSERT(!street_button.Activate(four_away), "Spring calves leapt four tiles") + TEST_ASSERT(street_button.IsAvailable(), "A refused leap started Spring calves' clock") + TEST_ASSERT(street_button.Activate(three_away), "Spring calves wouldn't leap three tiles") + TEST_ASSERT_EQUAL(street_button.next_use_time, world.time + 14 SECONDS, "Spring calves' leap started the wrong clock") + + // Dry footing and the soft landing belong to the Vaulter alone. + var/mob/living/carbon/human/vault_wearer = allocate(/mob/living/carbon/human/consistent, start) + TEST_ASSERT(milspec.Insert(vault_wearer, special = TRUE), "Vaulter pistons wouldn't go in") + TEST_ASSERT(HAS_TRAIT(vault_wearer, TRAIT_NO_SLIP_WATER), "Vaulter pistons gave no dry footing") + var/landing = SEND_SIGNAL(vault_wearer, COMSIG_LIVING_Z_IMPACT, 1, start) + TEST_ASSERT(landing & ZIMPACT_CANCEL_DAMAGE, "Vaulter pistons didn't soften a fall") + milspec.organ_flags |= ORGAN_FAILING + landing = SEND_SIGNAL(vault_wearer, COMSIG_LIVING_Z_IMPACT, 1, start) + TEST_ASSERT(!(landing & ZIMPACT_CANCEL_DAMAGE), "Browned-out Vaulter pistons still softened a fall") + milspec.organ_flags &= ~ORGAN_FAILING + milspec.Remove(vault_wearer, special = TRUE) + TEST_ASSERT(!HAS_TRAIT(vault_wearer, TRAIT_NO_SLIP_WATER), "Dry footing outlived the Vaulter pistons") + landing = SEND_SIGNAL(vault_wearer, COMSIG_LIVING_Z_IMPACT, 1, start) + TEST_ASSERT(!(landing & ZIMPACT_CANCEL_DAMAGE), "A fall was softened with the Vaulter pistons gone") + + // The Hopper and the Spring calves never had either. + TEST_ASSERT(!HAS_TRAIT(hopper_wearer, TRAIT_NO_SLIP_WATER), "The Hopper got dry footing") + TEST_ASSERT(!(SEND_SIGNAL(hopper_wearer, COMSIG_LIVING_Z_IMPACT, 1, start) & ZIMPACT_CANCEL_DAMAGE), "The Hopper softened a fall") + TEST_ASSERT(!HAS_TRAIT(spring_wearer, TRAIT_NO_SLIP_WATER), "Spring calves got dry footing") + TEST_ASSERT(!(SEND_SIGNAL(spring_wearer, COMSIG_LIVING_Z_IMPACT, 1, start) & ZIMPACT_CANCEL_DAMAGE), "Spring calves softened a fall") + +/// The Gorilla line: the parent keeps every number and the door-pry bonus. The +/// Brawler myomers punch lighter and slower, smash lighter, hurl nobody, and +/// sync into their own bonus, never the Gorilla's: one beside a real Gorilla arm +/// syncs nothing. The case holds a pair. +/datum/unit_test/voidcrew_cyberware_models_a_gorilla + +/datum/unit_test/voidcrew_cyberware_models_a_gorilla/Run() + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/real_right = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/left/real_left = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/left) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/brawler_right = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left/brawler_left = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left) + + // The parent keeps its numbers. + TEST_ASSERT_EQUAL(real_right.punch_damage, 20, "Gorilla punch damage changed") + TEST_ASSERT_EQUAL(real_right.structure_damage, 40, "Gorilla structure damage changed") + TEST_ASSERT_EQUAL(real_right.punch_cooldown_time, 4 SECONDS, "Gorilla punch cooldown changed") + TEST_ASSERT_EQUAL(real_right.smash_cooldown_time, 1 SECONDS, "Gorilla smash cooldown changed") + TEST_ASSERT_EQUAL(real_right.hurl_range, 4, "Gorilla hurl range changed") + TEST_ASSERT(real_right.pries_doors, "Gorilla Arms stopped prying doors") + TEST_ASSERT_EQUAL(real_right.chrome_load, 3, "Gorilla load changed") + TEST_ASSERT_EQUAL(real_right.tier, 3, "Gorilla tier changed") + + // The model. + TEST_ASSERT_EQUAL(brawler_right.punch_damage, 14, "Brawler punch isn't 14") + TEST_ASSERT_EQUAL(brawler_right.structure_damage, 32, "Brawler smash isn't 32") // BRAWLER_STRUCTURE_DAMAGE + TEST_ASSERT_EQUAL(brawler_right.punch_cooldown_time, 5 SECONDS, "Brawler punch clock isn't five seconds") + TEST_ASSERT_EQUAL(brawler_right.smash_cooldown_time, 1.5 SECONDS, "Brawler smash clock isn't a second and a half") + TEST_ASSERT(brawler_right.hurl_range <= 0, "Brawler myomers can hurl a grabbed victim") + TEST_ASSERT_EQUAL(brawler_right.pair_bonus, /datum/status_effect/organ_set_bonus/cyberware_brawler, "Brawler myomers don't sync into their own bonus") + TEST_ASSERT(!brawler_right.heavy_moves, "Brawler myomers have the Gorilla's heavy moves") + TEST_ASSERT_EQUAL(brawler_right.chrome_load, 2, "Brawler load isn't 2 per arm") + TEST_ASSERT_EQUAL(brawler_right.tier, 2, "Brawler myomers aren't tier 2") + TEST_ASSERT_EQUAL(brawler_left.chrome_load, 2, "Left Brawler load isn't 2") + TEST_ASSERT_EQUAL(brawler_right.slot, real_right.slot, "Right Brawler myomers aren't in the right arm slot") + TEST_ASSERT_EQUAL(brawler_left.slot, real_left.slot, "Left Brawler myomers aren't in the left arm slot") + TEST_ASSERT_EQUAL(brawler_left.zone, BODY_ZONE_L_ARM, "Left Brawler myomers aren't left-arm chrome") + + // The case holds one of each side. + var/obj/item/cyberware_pair_case/gorilla_arms/street/brawler_case = allocate(/obj/item/cyberware_pair_case/gorilla_arms/street) + TEST_ASSERT_EQUAL(length(brawler_case.contents), 2, "The Brawler case isn't a pair") + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street) in brawler_case.contents, "The Brawler case has no right arm") + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left) in brawler_case.contents, "The Brawler case has no left arm") + var/obj/item/cyberware_pair_case/gorilla_arms/real_case = allocate(/obj/item/cyberware_pair_case/gorilla_arms) + TEST_ASSERT(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/left) in real_case.contents, "The Gorilla case lost its left arm") + TEST_ASSERT(!(locate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street) in real_case.contents), "The Gorilla case holds Brawler myomers") + + // A real pair pries doors; a Brawler pair syncs into its own bonus; a mixed pair syncs into neither. + var/mob/living/carbon/human/real_pair = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + TEST_ASSERT(real_right.Insert(real_pair, special = TRUE), "The right Gorilla arm wouldn't go in") + TEST_ASSERT(real_left.Insert(real_pair, special = TRUE), "The left Gorilla arm wouldn't go in") + var/datum/status_effect/organ_set_bonus/pair_bonus = real_pair.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_gorilla) + TEST_ASSERT_NOTNULL(pair_bonus, "A Gorilla pair has no set bonus") + TEST_ASSERT(pair_bonus.bonus_active, "A Gorilla pair doesn't pry doors") + + var/mob/living/carbon/human/brawler_pair = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/pair_right = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left/pair_left = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left) + TEST_ASSERT(pair_right.Insert(brawler_pair, special = TRUE), "The right Brawler arm wouldn't go in") + TEST_ASSERT(pair_left.Insert(brawler_pair, special = TRUE), "The left Brawler arm wouldn't go in") + TEST_ASSERT_NULL(brawler_pair.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_gorilla), "A Brawler pair got the Gorilla's set bonus") + var/datum/status_effect/organ_set_bonus/brawler_bonus = brawler_pair.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_brawler) + TEST_ASSERT(brawler_bonus?.bonus_active, "A Brawler pair didn't sync") + + var/mob/living/carbon/human/mixed_pair = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/mixed_real = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left/mixed_street = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left) + TEST_ASSERT(mixed_real.Insert(mixed_pair, special = TRUE), "The real arm wouldn't go in beside a Brawler arm") + TEST_ASSERT(mixed_street.Insert(mixed_pair, special = TRUE), "The Brawler arm wouldn't go in beside a real arm") + var/datum/status_effect/organ_set_bonus/mixed_bonus = mixed_pair.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_gorilla) + TEST_ASSERT(!mixed_bonus?.bonus_active, "A real Gorilla arm and a Brawler arm pry doors") + var/datum/status_effect/organ_set_bonus/mixed_brawler = mixed_pair.has_status_effect(/datum/status_effect/organ_set_bonus/cyberware_brawler) + TEST_ASSERT(!mixed_brawler?.bonus_active, "A real Gorilla arm and a Brawler arm synced as Brawlers") + + // A punch lands for the model's damage and starts the model's clock. + var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/mob/living/carbon/human/puncher = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left/punch_arm = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left) + TEST_ASSERT(punch_arm.Insert(puncher, special = TRUE), "The punching arm wouldn't go in") + puncher.set_combat_mode(TRUE) + puncher.swap_hand(1) + TEST_ASSERT_EQUAL(puncher.get_active_hand()?.body_zone, BODY_ZONE_L_ARM, "The test puncher isn't swinging with the left arm") + var/hurt_before = victim.getBruteLoss() + TEST_ASSERT_EQUAL(punch_arm.on_punch(puncher, victim, TRUE, null), COMPONENT_CANCEL_ATTACK_CHAIN, "The Brawler arm didn't take the punch") + TEST_ASSERT_EQUAL(COOLDOWN_TIMELEFT(punch_arm, slam_cooldown), 5 SECONDS, "A Brawler punch didn't start the five second clock") + // The fist lands when it gets there: 0.1 s (GORILLA_THRUST_LANDS) + sleep(0.3 SECONDS) + TEST_ASSERT_EQUAL(victim.getBruteLoss() - hurt_before, 14, "A Brawler punch didn't land 14") + TEST_ASSERT_NOTEQUAL(punch_arm.on_punch(puncher, victim, TRUE, null), COMPONENT_CANCEL_ATTACK_CHAIN, "A Brawler arm punched again on its clock") + +/// Tinker's fingers: the Fixer's three tools and a weaker servo speed-up under +/// its own key, so it never replaces the Fixer's. +/datum/unit_test/voidcrew_cyberware_models_a_fixers + +/datum/unit_test/voidcrew_cyberware_models_a_fixers/Run() + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/parent = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street/street = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street) + + TEST_ASSERT_EQUAL(parent.speed_modifier, /datum/actionspeed_modifier/cyberware_fixers, "The Fixer's speed-up changed") + TEST_ASSERT_EQUAL(get_cached_actionspeed_modifier(parent.speed_modifier).multiplicative_slowdown, -0.25, "The Fixer's speed-up isn't a quarter") + TEST_ASSERT_EQUAL(parent.chrome_load, 2, "The Fixer's load changed") + TEST_ASSERT_EQUAL(parent.tier, 1, "The Fixer's tier changed") + + TEST_ASSERT_EQUAL(street.speed_modifier, /datum/actionspeed_modifier/cyberware_fixers/street, "Tinker's fingers use the wrong speed-up") + TEST_ASSERT_EQUAL(get_cached_actionspeed_modifier(street.speed_modifier).multiplicative_slowdown, -0.1, "Tinker's speed-up isn't a tenth") + TEST_ASSERT_EQUAL(street.chrome_load, 1, "Tinker's load isn't 1") + TEST_ASSERT_EQUAL(street.tier, 1, "Tinker's fingers aren't tier 1") + TEST_ASSERT_EQUAL(street.slot, parent.slot, "Tinker's fingers aren't in the Fixer's arm slot") + TEST_ASSERT(street.speed_modifier != parent.speed_modifier, "Tinker's fingers would replace the Fixer's speed-up") + TEST_ASSERT_EQUAL(length(street.items_to_create), length(parent.items_to_create), "Tinker's fingers carry a different number of tools") + for(var/tool_path in parent.items_to_create) + TEST_ASSERT(tool_path in street.items_to_create, "Tinker's fingers lost [tool_path]") + + // The speed-up rides the running ware: on with the fingers in, off with them out. + var/mob/living/carbon/human/tinker = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + TEST_ASSERT(street.Insert(tinker, special = TRUE), "Tinker's fingers wouldn't go in") + TEST_ASSERT(tinker.has_actionspeed_modifier(street.speed_modifier), "Tinker's fingers gave no speed-up") + TEST_ASSERT(!tinker.has_actionspeed_modifier(parent.speed_modifier), "Tinker's fingers gave the Fixer's speed-up") + street.Remove(tinker, special = TRUE) + TEST_ASSERT(!tinker.has_actionspeed_modifier(street.speed_modifier), "The speed-up outlived Tinker's fingers") + + var/mob/living/carbon/human/fixer = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + TEST_ASSERT(parent.Insert(fixer, special = TRUE), "The Fixer's Fingers wouldn't go in") + TEST_ASSERT(fixer.has_actionspeed_modifier(parent.speed_modifier), "The Fixer's Fingers gave no speed-up") + TEST_ASSERT(!fixer.has_actionspeed_modifier(street.speed_modifier), "The Fixer's Fingers gave Tinker's speed-up") + +/// The Deepcore: a heavier drill on the Rockjaw's hopper and buttons. +/datum/unit_test/voidcrew_cyberware_models_a_deepcore + +/datum/unit_test/voidcrew_cyberware_models_a_deepcore/Run() + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/parent = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore/deepcore = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore) + TEST_ASSERT_EQUAL(parent.chrome_load, 2, "The Rockjaw's load changed") + TEST_ASSERT_EQUAL(parent.tier, 1, "The Rockjaw's tier changed") + TEST_ASSERT_EQUAL(deepcore.chrome_load, 3, "The Deepcore's load isn't 3") + TEST_ASSERT_EQUAL(deepcore.tier, 2, "The Deepcore isn't tier 2") + TEST_ASSERT_EQUAL(deepcore.slot, parent.slot, "The Deepcore isn't in the Rockjaw's arm slot") + + var/obj/item/pickaxe/drill/cyberware/rockjaw_drill = locate(/obj/item/pickaxe/drill/cyberware) in parent + var/obj/item/pickaxe/drill/cyberware/deepcore/deepcore_drill = locate(/obj/item/pickaxe/drill/cyberware/deepcore) in deepcore + TEST_ASSERT_NOTNULL(rockjaw_drill, "The Rockjaw has no drill") + TEST_ASSERT_EQUAL(rockjaw_drill.type, /obj/item/pickaxe/drill/cyberware, "The Rockjaw carries a different drill") + TEST_ASSERT_EQUAL(rockjaw_drill.toolspeed, 0.5, "The Rockjaw's drill changed speed") + TEST_ASSERT_NOTNULL(deepcore_drill, "The Deepcore has no Deepcore drill") + TEST_ASSERT_EQUAL(deepcore_drill.toolspeed, 0.3, "The Deepcore drill isn't 0.3") + var/obj/item/pickaxe/drill/diamonddrill/diamond = allocate(/obj/item/pickaxe/drill/diamonddrill) + TEST_ASSERT(deepcore_drill.toolspeed > diamond.toolspeed, "The Deepcore drill is faster than a diamond drill") + TEST_ASSERT(deepcore_drill.toolspeed < rockjaw_drill.toolspeed, "The Deepcore drill isn't faster than the Rockjaw's") + + // The hopper button comes along. + TEST_ASSERT(locate(/datum/action/item_action/organ_action/rockjaw_hopper) in deepcore.actions, "The Deepcore lost the ore hopper button") + +/// The Holdout: six rounds of ordinary .38 in a folding arm revolver, thumbed in +/// by hand a round at a time, and the housing shows when someone looks at the arm. +/datum/unit_test/voidcrew_cyberware_models_a_holdout + +/datum/unit_test/voidcrew_cyberware_models_a_holdout/Run() + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/ronin = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout/holdout = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout) + + // The parent is untouched. + TEST_ASSERT_EQUAL(ronin.chrome_load, 5, "The Ronin's load changed") + TEST_ASSERT_EQUAL(ronin.tier, 3, "The Ronin's tier changed") + TEST_ASSERT(/obj/item/gun/ballistic/automatic/cyberware_ronin in ronin.items_to_create, "The Ronin lost its machine pistol") + + TEST_ASSERT_EQUAL(holdout.chrome_load, 3, "The Holdout's load isn't 3") + TEST_ASSERT_EQUAL(holdout.tier, 2, "The Holdout isn't tier 2") + TEST_ASSERT_EQUAL(holdout.slot, ronin.slot, "The Holdout isn't in the Ronin's arm slot") + TEST_ASSERT_EQUAL(holdout.zone, ronin.zone, "The Holdout isn't in the Ronin's arm zone") + TEST_ASSERT_EQUAL(length(holdout.items_to_create), 1, "The Holdout carries more than the one revolver") + TEST_ASSERT(!(/obj/item/gun/ballistic/automatic/cyberware_ronin in holdout.items_to_create), "The Holdout carries the Ronin's machine pistol") + + // A loaded six-shot .38 with a slow trigger. + var/obj/item/gun/ballistic/revolver/cyberware_holdout/gun = locate() in holdout + TEST_ASSERT_NOTNULL(gun, "The Holdout housing holds no revolver") + TEST_ASSERT_EQUAL(gun.magazine.max_ammo, 6, "The Holdout's cylinder isn't six chambers") + TEST_ASSERT_EQUAL(gun.magazine.caliber, CALIBER_38, "The Holdout doesn't take .38") + TEST_ASSERT_EQUAL(gun.get_ammo(FALSE, FALSE), 6, "The Holdout doesn't leave the shop loaded") + TEST_ASSERT_EQUAL(gun.fire_delay, 0.4 SECONDS, "The Holdout's trigger isn't 0.4 seconds") + TEST_ASSERT(!gun.magazine.multiload, "The Holdout's cylinder loads a speedloader at once") + + // The cylinder takes a speedloader a round at a time. An ordinary revolver + // cylinder takes all it has room for. + var/mob/living/carbon/human/loader = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/ammo_box/magazine/internal/cylinder/rev38/cyberware_holdout/cylinder = allocate(/obj/item/ammo_box/magazine/internal/cylinder/rev38/cyberware_holdout) + var/obj/item/ammo_box/magazine/internal/cylinder/rev38/detective_cylinder = allocate(/obj/item/ammo_box/magazine/internal/cylinder/rev38) + for(var/obj/item/ammo_box/magazine/internal/cylinder/rev38/emptied as anything in list(cylinder, detective_cylinder)) + // ammo_list() spawns the cylinder's lazy rounds, so there is something to remove. + for(var/obj/item/ammo_casing/round in emptied.ammo_list()) + qdel(round) + TEST_ASSERT_EQUAL(emptied.ammo_count(FALSE), 0, "A test cylinder didn't empty") + var/obj/item/ammo_box/c38/speedloader = allocate(/obj/item/ammo_box/c38) + var/obj/item/ammo_box/c38/second_speedloader = allocate(/obj/item/ammo_box/c38) + TEST_ASSERT_EQUAL(cylinder.attackby(speedloader, loader, null, TRUE), 1, "The Holdout cylinder took more than a round from a speedloader") + TEST_ASSERT_EQUAL(detective_cylinder.attackby(second_speedloader, loader, null, TRUE), 6, "An ordinary .38 cylinder stopped taking a whole speedloader") + + // A full cylinder has no room, a spent chamber or an empty one has. + TEST_ASSERT(!gun.cylinder_has_room(), "A full Holdout cylinder claims room") + var/list/rounds = gun.magazine.ammo_list() + var/obj/item/ammo_casing/first_round = rounds[1] + QDEL_NULL(first_round.loaded_projectile) + TEST_ASSERT(gun.cylinder_has_room(), "A spent chamber doesn't count as room") + // A full cylinder is refused outright, with no wait. + var/obj/item/gun/ballistic/revolver/cyberware_holdout/full_gun = allocate(/obj/item/gun/ballistic/revolver/cyberware_holdout) + TEST_ASSERT(!full_gun.load_gun(speedloader, loader), "A full Holdout cylinder took another round") + TEST_ASSERT_EQUAL(full_gun.get_ammo(FALSE, FALSE), 6, "Refusing a round cost the Holdout one") + + // The housing shows when someone looks at the bearer, and stops when it is gone. + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/mob/living/carbon/human/onlooker = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/list/before_lines = list() + SEND_SIGNAL(bearer, COMSIG_ATOM_EXAMINE, onlooker, before_lines) + TEST_ASSERT(!findtext(jointext(before_lines, " "), "revolver housing"), "A body with no Holdout shows a revolver housing") + TEST_ASSERT(holdout.Insert(bearer, special = TRUE), "The Holdout housing wouldn't go in") + var/list/lines = list() + SEND_SIGNAL(bearer, COMSIG_ATOM_EXAMINE, onlooker, lines) + TEST_ASSERT(findtext(jointext(lines, " "), "revolver housing"), "Looking at the bearer doesn't show the Holdout housing") + holdout.Remove(bearer, special = TRUE) + var/list/after_lines = list() + SEND_SIGNAL(bearer, COMSIG_ATOM_EXAMINE, onlooker, after_lines) + TEST_ASSERT(!findtext(jointext(after_lines, " "), "revolver housing"), "The housing still shows after it was pulled") + +/// What the shelf asks and what the ledger pays, per the plan. Every ledger +/// entry is half the shelf price of the piece, credits only, and takes both +/// ripperdocs' wording. The Vaulter is voucher chrome and has no entry. +/datum/unit_test/voidcrew_cyberware_models_a_shelf + +/datum/unit_test/voidcrew_cyberware_models_a_shelf/Run() + // SKU, what it sells, credits, vouchers, zone permission (0 public, 1 yellow, 2 advanced), pieces per sale + var/list/shelf = list( + list(/datum/shop_sku/ripperdoc/hopper_street, /obj/item/organ/cyberimp/cyberware/hopper/street, 1800, 0, 1, 1), + list(/datum/shop_sku/ripperdoc/hopper_milspec, /obj/item/organ/cyberimp/cyberware/hopper/milspec, 0, 3, 2, 1), + list(/datum/shop_sku/ripperdoc/gorilla_street, /obj/item/cyberware_pair_case/gorilla_arms/street, 2000, 0, 1, 2), + list(/datum/shop_sku/ripperdoc/fixers_street, /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street, 700, 0, 0, 1), + list(/datum/shop_sku/ripperdoc/rockjaw_deepcore, /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore, 2400, 0, 0, 1), + list(/datum/shop_sku/ripperdoc/ronin_holdout, /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout, 2400, 0, 1, 1), + ) + build_cyberware_price_index() + for(var/list/row as anything in shelf) + var/datum/shop_sku/sku = allocate(row[1]) + TEST_ASSERT_EQUAL(sku.item_path, row[2], "[row[1]] sells the wrong item") + TEST_ASSERT_EQUAL(sku.price_credits, row[3], "[row[1]] asks the wrong credits") + TEST_ASSERT_EQUAL(sku.price_vouchers, row[4], "[row[1]] asks the wrong vouchers") + TEST_ASSERT_EQUAL(sku.zone_permission, row[5], "[row[1]] sits at the wrong reputation") + TEST_ASSERT(sku.price_credits <= 0 || sku.category == "Street Chrome", "[row[1]] is credit chrome off the street shelf") + TEST_ASSERT(sku.price_vouchers <= 0 || sku.category == "Military Chrome", "[row[1]] is voucher chrome off the military shelf") + if(row[1] == /datum/shop_sku/ripperdoc/ronin_holdout || row[1] == /datum/shop_sku/ripperdoc/gorilla_street) + TEST_ASSERT(sku.fixed_price && !sku.contract_reward, "[row[1]] can be discounted or handed out as a contract reward") + + // What the cradle quotes for the pieces. A pair quotes the whole case on each half. + var/list/quote = GLOB.cyberware_price_index[/obj/item/organ/cyberimp/cyberware/hopper/street] + TEST_ASSERT(quote && quote["credits"] == 1800 && !quote["vouchers"], "Spring calves quote the wrong price") + quote = GLOB.cyberware_price_index[/obj/item/organ/cyberimp/cyberware/hopper/milspec] + TEST_ASSERT(quote && quote["vouchers"] == 3 && !quote["credits"], "Vaulter pistons quote the wrong price") + for(var/pair_half in list(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street, /obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left)) + quote = GLOB.cyberware_price_index[pair_half] + TEST_ASSERT(quote && quote["credits"] == 2000 && quote["paired"], "[pair_half] doesn't quote the pair's price") + quote = GLOB.cyberware_price_index[/obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout] + TEST_ASSERT(quote && quote["credits"] == 2400, "The Holdout quotes the wrong price") + + // Ledger: half the shelf price of one piece, credits only, either side of a pair. + var/list/ledgers = list( + list(/datum/shop_buyback/ripperdoc/hopper_street, /datum/shop_buyback/ripperdoc/hopper_street/street_doc, /obj/item/organ/cyberimp/cyberware/hopper/street, 900), + list(/datum/shop_buyback/ripperdoc/gorilla_street, /datum/shop_buyback/ripperdoc/gorilla_street/street_doc, /obj/item/organ/cyberimp/cyberware/gorilla_arms/street, 500), + list(/datum/shop_buyback/ripperdoc/fixers_street, /datum/shop_buyback/ripperdoc/fixers_street/street_doc, /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers/street, 350), + list(/datum/shop_buyback/ripperdoc/ronin_holdout, /datum/shop_buyback/ripperdoc/ronin_holdout/street_doc, /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout, 1200), + list(/datum/shop_buyback/ripperdoc/rockjaw_deepcore, /datum/shop_buyback/ripperdoc/rockjaw_deepcore/street_doc, /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw/deepcore, 1200), + ) + for(var/list/row as anything in ledgers) + for(var/ledger_index in 1 to 2) + var/datum/shop_buyback/ledger = allocate(row[ledger_index]) + TEST_ASSERT_EQUAL(ledger.item_path, row[3], "[row[ledger_index]] buys the wrong piece") + TEST_ASSERT_EQUAL(ledger.pay_credits, row[4], "[row[ledger_index]] pays the wrong credits") + TEST_ASSERT(!ledger.pay_vouchers, "[row[ledger_index]] pays vouchers") + TEST_ASSERT(ledger.takes_shop_stock(), "[row[ledger_index]] refuses chrome bought at a counter") + + // Either side of a Brawler pair is taken, and nothing else of the Gorilla line. + var/datum/shop_buyback/brawler_ledger = allocate(/datum/shop_buyback/ripperdoc/gorilla_street) + TEST_ASSERT(brawler_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street)), "The ledger won't take a right Brawler arm") + TEST_ASSERT(brawler_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left)), "The ledger won't take a left Brawler arm") + TEST_ASSERT(!brawler_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms)), "The Brawler ledger takes a real Gorilla arm") + var/datum/shop_buyback/spring_ledger = allocate(/datum/shop_buyback/ripperdoc/hopper_street) + TEST_ASSERT(!spring_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/hopper)), "The Spring calves ledger takes a Hopper") + TEST_ASSERT(!spring_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/hopper/milspec)), "The Spring calves ledger takes Vaulter pistons") + var/datum/shop_buyback/tinker_ledger = allocate(/datum/shop_buyback/ripperdoc/fixers_street) + TEST_ASSERT(!tinker_ledger.matches(allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers)), "The Tinker's ledger takes the Fixer's Fingers") + var/datum/shop_buyback/deepcore_ledger = allocate(/datum/shop_buyback/ripperdoc/rockjaw_deepcore) + TEST_ASSERT(!deepcore_ledger.matches(allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw)), "The Deepcore ledger takes a plain Rockjaw") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_models_b.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_models_b.dm new file mode 100644 index 00000000000..a6f07ffc9b1 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_models_b.dm @@ -0,0 +1,404 @@ +/** + * # Cyberware models, set B + * + * Hardweave plating, the Strut frame, the Deep-lung bladder, the Heat-sink and + * Frostline linings, the Twitchwire and Weaver shunt, and the Thumper ear + * (voidcrew/modules/cyberware/ware_models_b.dm). Each model has to share its + * parent's slot, keep its own numbers, and leave the parent's numbers exactly + * as they were. + * + * Unit-test files compile before voidcrew/_DEFINES/, so the fork's defines are + * written as literals below: CYBERWARE_TIER_1/2/3 are 1/2/3, and the + * unbreakable-bones trait is "cyberware_unbreakable_bones". + */ + +/// Every model sits in its parent's slot with the planned load and tier, a +/// state of its own, and a description without a number in it. +/datum/unit_test/voidcrew_cyberware_models_b_slots + +/datum/unit_test/voidcrew_cyberware_models_b_slots/Run() + // model, parent, load, tier + var/list/models = list( + list(/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave, /obj/item/organ/cyberimp/cyberware/dermal_mesh, 3, 2), + list(/obj/item/organ/cyberimp/cyberware/atlas/street, /obj/item/organ/cyberimp/cyberware/atlas, 2, 2), + list(/obj/item/organ/cyberimp/cyberware/second_wind/deep, /obj/item/organ/cyberimp/cyberware/second_wind, 2, 2), + list(/obj/item/organ/cyberimp/cyberware/coolant/street, /obj/item/organ/cyberimp/cyberware/coolant, 1, 1), + list(/obj/item/organ/cyberimp/cyberware/frostline, /obj/item/organ/cyberimp/cyberware/coolant, 1, 1), + list(/obj/item/organ/cyberimp/cyberware/slipwire/street, /obj/item/organ/cyberimp/cyberware/slipwire, 2, 1), + list(/obj/item/organ/cyberimp/cyberware/slipwire/milspec, /obj/item/organ/cyberimp/cyberware/slipwire, 5, 3), + list(/obj/item/organ/cyberimp/cyberware/doppler/street, /obj/item/organ/cyberimp/cyberware/doppler, 1, 1), + ) + for(var/list/row as anything in models) + var/obj/item/organ/cyberimp/cyberware/ware = allocate(row[1]) + var/obj/item/organ/cyberimp/cyberware/parent = allocate(row[2]) + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + TEST_ASSERT_NOTNULL(chrome, "[ware.type] has no cyberware component") + TEST_ASSERT_EQUAL(ware.slot, parent.slot, "[ware.type] is not in [parent.type]'s slot, so the two would stack") + TEST_ASSERT_EQUAL(ware.zone, parent.zone, "[ware.type] is in a different body zone from [parent.type]") + TEST_ASSERT_EQUAL(chrome.chrome_load, row[3], "[ware.type] has the wrong chrome load") + TEST_ASSERT_EQUAL(chrome.tier, row[4], "[ware.type] has the wrong tier") + TEST_ASSERT(!findtext(ware.desc, regex("\[0-9]")), "[ware.type]'s description has a number in it") + TEST_ASSERT(!findtext(ware.desc, "tier") && !findtext(ware.desc, "load"), "[ware.type]'s description talks about game rules") + if(ware.type != /obj/item/organ/cyberimp/cyberware/frostline) + TEST_ASSERT(ware.icon_state != parent.icon_state, "[ware.type] reuses its parent's item state") + // Where the parent has a worn look, the model has its own. + if(parent.aug_overlay) + TEST_ASSERT(ware.aug_overlay && ware.aug_overlay != parent.aug_overlay, "[ware.type] wears its parent's overlay") + + // The seal slot is one slot with five choices: whichever went in last is + // the only one left. + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/list/seal_ware = list( + /obj/item/organ/cyberimp/cyberware/second_wind, + /obj/item/organ/cyberimp/cyberware/second_wind/deep, + /obj/item/organ/cyberimp/cyberware/coolant/street, + /obj/item/organ/cyberimp/cyberware/frostline, + /obj/item/organ/cyberimp/cyberware/coolant, + ) + var/list/placed = list() + for(var/seal_path in seal_ware) + var/obj/item/organ/cyberimp/cyberware/seal = allocate(seal_path) + TEST_ASSERT(seal.Insert(patient, special = TRUE), "[seal_path] staging insert was refused") + TEST_ASSERT_EQUAL(patient.get_organ_slot(seal.slot), seal, "[seal_path] did not take the seal slot") + for(var/obj/item/organ/earlier as anything in placed) + TEST_ASSERT(earlier.owner != patient, "[earlier.type] stayed in the seal slot beside [seal_path]") + placed += seal + +/// The parents run on the numbers they had before the vars existed. +/datum/unit_test/voidcrew_cyberware_models_b_parents + +/datum/unit_test/voidcrew_cyberware_models_b_parents/Run() + var/obj/item/organ/cyberimp/cyberware/second_wind/bladder = allocate(/obj/item/organ/cyberimp/cyberware/second_wind) + TEST_ASSERT_EQUAL(bladder.reserve, 180 SECONDS, "Second Wind's reserve changed") + TEST_ASSERT_EQUAL(bladder.max_reserve, 180 SECONDS, "Second Wind's cap changed") + TEST_ASSERT_EQUAL(bladder.refill_rate, 16 SECONDS, "Second Wind's refill changed") + + var/obj/item/organ/cyberimp/cyberware/coolant/loops = allocate(/obj/item/organ/cyberimp/cyberware/coolant) + TEST_ASSERT_EQUAL(loops.burn_mult, 0.5, "Coolant Loops stopped halving burns") + + var/obj/item/organ/cyberimp/cyberware/slipwire/slipwire = allocate(/obj/item/organ/cyberimp/cyberware/slipwire) + TEST_ASSERT_EQUAL(slipwire.dodge_chance, 15, "Slipwire's dodge changed") + TEST_ASSERT_EQUAL(slipwire.gait_modifier, /datum/movespeed_modifier/cyberware_slipwire, "Slipwire's gait changed") + TEST_ASSERT(!findtext(slipwire.desc, "seven") && !findtext(slipwire.desc, regex("\[0-9]")), "Slipwire's description still quotes its odds") + + var/obj/item/organ/cyberimp/cyberware/doppler/doppler = allocate(/obj/item/organ/cyberimp/cyberware/doppler) + TEST_ASSERT_EQUAL(doppler.sonar_range, 9, "Heartbeat Doppler's range changed") + TEST_ASSERT_EQUAL(doppler.contact_fade, 4 SECONDS, "Heartbeat Doppler's fade changed") + TEST_ASSERT_EQUAL(doppler.ping_volume_bonus, 0, "Heartbeat Doppler's ping got louder") + + var/obj/item/organ/cyberimp/cyberware/atlas/atlas = allocate(/obj/item/organ/cyberimp/cyberware/atlas) + TEST_ASSERT_EQUAL(atlas.throw_range_bonus, 2, "Atlas Frame's throw range changed") + TEST_ASSERT_EQUAL(atlas.throw_speed_bonus, 1, "Atlas Frame's throw speed changed") + TEST_ASSERT(atlas.resists_knockback, "Atlas Frame stopped resisting knockback") + // The text pass cut the examine line that explained the frame's rules. + TEST_ASSERT_NULL(atlas.frame_examine, "Atlas Frame's examine explains its rules again") + TEST_ASSERT(TRAIT_NODISMEMBER in atlas.organ_traits, "Atlas Frame stopped holding limbs on") + TEST_ASSERT("cyberware_unbreakable_bones" in atlas.organ_traits, "Atlas Frame stopped holding bones together") + + var/obj/item/organ/cyberimp/cyberware/dermal_mesh/mesh = allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh) + TEST_ASSERT_EQUAL(mesh.mesh_armor, /datum/armor/cyberware_dermal_mesh, "Dermal Mesh's plating changed") + +/// Hardweave sits between the Mesh and the Slabskin Plate, and swapping it for +/// the Mesh hands back exactly the difference. +/datum/unit_test/voidcrew_cyberware_models_b_hardweave + +/datum/unit_test/voidcrew_cyberware_models_b_hardweave/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave/hardweave = allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave) + var/obj/item/organ/cyberimp/cyberware/dermal_mesh/mesh = allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh) + // melee, bullet, laser, energy, wound + var/list/ratings = list(MELEE, BULLET, LASER, ENERGY, WOUND) + var/list/bare = list() + for(var/rating in ratings) + bare[rating] = patient.physiology.armor.get_rating(rating) + + TEST_ASSERT(hardweave.Insert(patient, special = TRUE), "Hardweave staging insert was refused") + var/list/hardweave_plus = list(20, 20, 15, 10, 10) + for(var/index in 1 to length(ratings)) + var/rating = ratings[index] + TEST_ASSERT_EQUAL(patient.physiology.armor.get_rating(rating), bare[rating] + hardweave_plus[index], "Hardweave gave the wrong [rating] armour") + + TEST_ASSERT(mesh.Insert(patient, special = TRUE), "Dermal Mesh staging insert was refused") + TEST_ASSERT(!hardweave.owner, "Hardweave stayed in the dermal slot beside the Mesh") + var/list/mesh_plus = list(15, 15, 10, 0, 5) + for(var/index in 1 to length(ratings)) + var/rating = ratings[index] + TEST_ASSERT_EQUAL(patient.physiology.armor.get_rating(rating), bare[rating] + mesh_plus[index], "Swapping Hardweave for the Mesh left the wrong [rating] armour") + + TEST_ASSERT(hardweave.Insert(patient, special = TRUE), "Hardweave second staging insert was refused") + patient.emp_act(EMP_HEAVY) + TEST_ASSERT(hardweave.organ_flags & ORGAN_FAILING, "An EMP never reached Hardweave") + for(var/rating in ratings) + TEST_ASSERT_EQUAL(patient.physiology.armor.get_rating(rating), bare[rating], "EMP-scrambled Hardweave kept armouring its bearer") + var/datum/component/cyberware/chrome = hardweave.GetComponent(/datum/component/cyberware) + chrome.tune_up() + TEST_ASSERT_EQUAL(patient.physiology.armor.get_rating(MELEE), bare[MELEE] + 20, "A tune-up did not hand Hardweave's plating back") + hardweave.Remove(patient, special = TRUE) + TEST_ASSERT_EQUAL(patient.physiology.armor.get_rating(MELEE), bare[MELEE], "Pulling Hardweave left plating on the body") + +/// The Strut frame holds bones and nothing else; the Atlas it undercuts still +/// holds limbs on and still throws and shrugs like a frame. +/datum/unit_test/voidcrew_cyberware_models_b_strut + +/datum/unit_test/voidcrew_cyberware_models_b_strut/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/atlas/street/strut = allocate(/obj/item/organ/cyberimp/cyberware/atlas/street) + var/obj/item/organ/cyberimp/cyberware/atlas/atlas = allocate(/obj/item/organ/cyberimp/cyberware/atlas) + + TEST_ASSERT(strut.Insert(patient, special = TRUE), "Strut frame staging insert was refused") + TEST_ASSERT(HAS_TRAIT(patient, "cyberware_unbreakable_bones"), "The Strut frame did not keep the bones together") + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_NODISMEMBER), "The Strut frame keeps limbs on") + TEST_ASSERT_NULL(strut._signal_procs?[patient]?[COMSIG_MOB_THROW], "The Strut frame is boosting throws") + TEST_ASSERT_NULL(strut._signal_procs?[patient]?[COMSIG_MOVABLE_PRE_THROW], "The Strut frame is resisting knockback") + var/examined = jointext(strut.examine(patient), " ") + TEST_ASSERT(!findtext(examined, "no losing a limb"), "The Strut frame examine still promises limbs stay on") + + // The Atlas replaces it and gets everything back. + TEST_ASSERT(atlas.Insert(patient, special = TRUE), "Atlas staging insert was refused") + TEST_ASSERT(!strut.owner, "The Strut frame stayed in the frame slot beside the Atlas") + TEST_ASSERT(HAS_TRAIT(patient, "cyberware_unbreakable_bones"), "The Atlas lost its bones") + TEST_ASSERT(HAS_TRAIT(patient, TRAIT_NODISMEMBER), "The Atlas lost its limbs") + TEST_ASSERT_NOTNULL(atlas._signal_procs?[patient]?[COMSIG_MOB_THROW], "The Atlas stopped boosting throws") + TEST_ASSERT_NOTNULL(atlas._signal_procs?[patient]?[COMSIG_MOVABLE_PRE_THROW], "The Atlas stopped resisting knockback") + + // And the Atlas still does the arithmetic it did. + var/list/thrown = list(null, 8, 1, patient) + atlas.boost_throw(null, thrown) + TEST_ASSERT_EQUAL(thrown[2], 10, "The Atlas added the wrong range to a throw") + TEST_ASSERT_EQUAL(thrown[3], 2, "The Atlas added the wrong speed to a throw") + var/list/shoved = list(null, 8, 1, null) + atlas.on_owner_thrown(patient, shoved) + TEST_ASSERT_EQUAL(shoved[2], 4, "The Atlas stopped halving knockback") + + atlas.Remove(patient, special = TRUE) + TEST_ASSERT(!HAS_TRAIT(patient, "cyberware_unbreakable_bones") && !HAS_TRAIT(patient, TRAIT_NODISMEMBER), "Pulling the Atlas left traits on the body") + +/// Deep-lung, Heat-sink and Frostline. +/datum/unit_test/voidcrew_cyberware_models_b_seal + +/datum/unit_test/voidcrew_cyberware_models_b_seal/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + + // Deep-lung: a bigger bladder that refills faster, otherwise a Second Wind. + var/obj/item/organ/cyberimp/cyberware/second_wind/deep/deep = allocate(/obj/item/organ/cyberimp/cyberware/second_wind/deep) + TEST_ASSERT_EQUAL(deep.max_reserve, 360 SECONDS, "The Deep-lung bladder holds the wrong amount") + TEST_ASSERT_EQUAL(deep.reserve, deep.max_reserve, "The Deep-lung bladder starts partly empty") + TEST_ASSERT_EQUAL(deep.refill_rate, 24 SECONDS, "The Deep-lung bladder refills at the wrong rate") + TEST_ASSERT(deep.Insert(patient, special = TRUE), "Deep-lung staging insert was refused") + deep.reserve = 0 + patient.forceMove(run_loc_floor_bottom_left) + patient.breathe(2, 1) + TEST_ASSERT_EQUAL(deep.reserve, 24 SECONDS, "A breath of good air refilled the wrong amount of Deep-lung reserve") + deep.reserve = deep.max_reserve - 10 + patient.breathe(2, 1) + TEST_ASSERT_EQUAL(deep.reserve, deep.max_reserve, "The Deep-lung bladder refilled past its cap") + deep.Remove(patient, special = TRUE) + + // Heat-sink: the heat half of the loops, no burn halving. + var/obj/item/organ/cyberimp/cyberware/coolant/street/sink = allocate(/obj/item/organ/cyberimp/cyberware/coolant/street) + var/obj/item/organ/cyberimp/cyberware/coolant/loops = allocate(/obj/item/organ/cyberimp/cyberware/coolant) + var/bare_burn = patient.physiology.burn_mod + TEST_ASSERT(sink.Insert(patient, special = TRUE), "Heat-sink staging insert was refused") + TEST_ASSERT(HAS_TRAIT(patient, TRAIT_RESISTHEAT), "The Heat-sink lining does not turn heat away") + TEST_ASSERT_EQUAL(patient.physiology.burn_mod, bare_burn, "The Heat-sink lining halves burns") + TEST_ASSERT(!sink.coolant_mod_applied, "The Heat-sink lining thinks it applied a burn mod") + patient.adjust_fire_stacks(5) + var/lit_stacks = patient.fire_stacks + TEST_ASSERT(lit_stacks > 0, "Test fixture: the patient took no fire stacks") + sink.on_life(1, 1) + TEST_ASSERT(patient.fire_stacks < lit_stacks, "The Heat-sink lining does not scrub fire") + patient.set_fire_stacks(0) + + TEST_ASSERT(loops.Insert(patient, special = TRUE), "Coolant Loops staging insert was refused") + TEST_ASSERT(!sink.owner, "The Heat-sink lining stayed in the seal slot beside the loops") + TEST_ASSERT_EQUAL(patient.physiology.burn_mod, bare_burn * 0.5, "Coolant Loops stopped halving burns") + TEST_ASSERT(sink.Insert(patient, special = TRUE), "Heat-sink second staging insert was refused") + TEST_ASSERT_EQUAL(patient.physiology.burn_mod, bare_burn, "Swapping the loops for the Heat-sink left a burn mod on the body") + sink.Remove(patient, special = TRUE) + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_RESISTHEAT), "Pulling the Heat-sink left heat immunity on the body") + + // Frostline: the cold stops hurting and nothing else changes. + var/obj/item/organ/cyberimp/cyberware/frostline/frost = allocate(/obj/item/organ/cyberimp/cyberware/frostline) + TEST_ASSERT(frost.Insert(patient, special = TRUE), "Frostline staging insert was refused") + TEST_ASSERT(HAS_TRAIT(patient, TRAIT_RESISTCOLD), "Frostline does not turn the cold away") + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_RESISTHEAT), "Frostline turns the heat away too") + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_NOBREATH) && !HAS_TRAIT(patient, TRAIT_RESISTLOWPRESSURE), "Frostline does more than the cold") + TEST_ASSERT_EQUAL(patient.physiology.burn_mod, bare_burn, "Frostline changed how burns land") + patient.emp_act(EMP_HEAVY) + TEST_ASSERT(frost.organ_flags & ORGAN_FAILING, "An EMP never reached the Frostline lining") + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_RESISTCOLD), "An EMP-scrambled Frostline lining kept the cold off") + var/datum/component/cyberware/chrome = frost.GetComponent(/datum/component/cyberware) + chrome.tune_up() + TEST_ASSERT(HAS_TRAIT(patient, TRAIT_RESISTCOLD), "A tune-up did not bring the Frostline lining back") + frost.Remove(patient, special = TRUE) + TEST_ASSERT(!HAS_TRAIT(patient, TRAIT_RESISTCOLD), "Pulling the Frostline lining left cold resistance on the body") + +/// A fixed dodge for the arbiter tests. +/datum/unit_test/voidcrew_cyberware_models_b_slipwire + /// Stand-in for a Cascade window's source. + var/test_source_chance = 40 + +/datum/unit_test/voidcrew_cyberware_models_b_slipwire/proc/fixed_chance() + return test_source_chance + +/// Twitchwire and the Weaver shunt dodge through the shared arbiter and bring +/// their own gait; the Slipwire between them keeps its own. +/datum/unit_test/voidcrew_cyberware_models_b_slipwire/Run() + var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/slipwire/slipwire = allocate(/obj/item/organ/cyberimp/cyberware/slipwire) + var/obj/item/organ/cyberimp/cyberware/slipwire/street/twitch = allocate(/obj/item/organ/cyberimp/cyberware/slipwire/street) + var/obj/item/organ/cyberimp/cyberware/slipwire/milspec/weaver = allocate(/obj/item/organ/cyberimp/cyberware/slipwire/milspec) + + // ware, dodge chance, gait modifier (null for none) + var/list/rungs = list( + list(twitch, 8, null), + list(slipwire, 15, /datum/movespeed_modifier/cyberware_slipwire), + list(weaver, 20, /datum/movespeed_modifier/cyberware_slipwire/weaver), + ) + var/list/every_gait = list(/datum/movespeed_modifier/cyberware_slipwire, /datum/movespeed_modifier/cyberware_slipwire/weaver) + for(var/list/rung as anything in rungs) + var/obj/item/organ/cyberimp/cyberware/slipwire/ware = rung[1] + TEST_ASSERT(ware.Insert(patient, special = TRUE), "[ware.type] staging insert was refused") + var/datum/component/cyberware_dodge/arbiter = patient.GetComponent(/datum/component/cyberware_dodge) + TEST_ASSERT_NOTNULL(arbiter, "[ware.type] never reached the shared dodge arbiter") + TEST_ASSERT_EQUAL(length(arbiter.dodge_sources), 1, "[ware.type] left [length(arbiter.dodge_sources)] dodge sources, the ladder stacked") + var/datum/callback/source = arbiter.dodge_sources[REF(ware)] + TEST_ASSERT_NOTNULL(source, "[ware.type] registered no dodge source of its own") + TEST_ASSERT_EQUAL(source.Invoke(), rung[2], "[ware.type] dodges at the wrong chance") + for(var/gait in every_gait) + TEST_ASSERT_EQUAL(!!patient.has_movespeed_modifier(gait), (gait == rung[3]) ? 1 : 0, "[ware.type] has the wrong gait") + + // A scrambled ware dodges nothing and runs no faster. + patient.emp_act(EMP_HEAVY) + var/datum/component/cyberware_dodge/scrambled = patient.GetComponent(/datum/component/cyberware_dodge) + var/datum/callback/scrambled_source = scrambled.dodge_sources[REF(weaver)] + TEST_ASSERT_EQUAL(scrambled_source.Invoke(), 0, "An EMP-scrambled Weaver shunt still dodges") + TEST_ASSERT(!patient.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_slipwire/weaver), "An EMP-scrambled Weaver shunt still runs fast") + var/datum/component/cyberware/chrome = weaver.GetComponent(/datum/component/cyberware) + chrome.tune_up() + TEST_ASSERT(patient.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_slipwire/weaver), "A tune-up did not give the Weaver shunt its gait back") + + // Another source (a Cascade window is one) shares the arbiter by its own + // key. The arbiter rolls the highest of them, so both stay registered + // and neither is summed into the other. + var/datum/component/cyberware_dodge/shared = patient.GetComponent(/datum/component/cyberware_dodge) + cyberware_register_dodge_source(patient, "voidcrew_test_window", CALLBACK(src, PROC_REF(fixed_chance))) + TEST_ASSERT_EQUAL(length(shared.dodge_sources), 2, "A second dodge source did not share the arbiter") + var/best = 0 + for(var/key in shared.dodge_sources) + var/datum/callback/chance_callback = shared.dodge_sources[key] + best = max(best, chance_callback.Invoke()) + TEST_ASSERT_EQUAL(best, 40, "The Weaver shunt raised a Cascade window's dodge") + cyberware_unregister_dodge_source(patient, "voidcrew_test_window") + + weaver.Remove(patient, special = TRUE) + TEST_ASSERT_NULL(patient.GetComponent(/datum/component/cyberware_dodge), "Pulling the last dodge ware left the arbiter behind") + TEST_ASSERT(!patient.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_slipwire/weaver), "Pulling the Weaver shunt left its gait on the body") + +/// The Thumper ear: shorter reach, shorter fade, louder ping; the Heartbeat +/// Doppler it undercuts keeps its own. +/datum/unit_test/voidcrew_cyberware_models_b_doppler + +/datum/unit_test/voidcrew_cyberware_models_b_doppler/Run() + var/obj/item/organ/cyberimp/cyberware/doppler/street/thumper = allocate(/obj/item/organ/cyberimp/cyberware/doppler/street) + TEST_ASSERT_EQUAL(thumper.sonar_range, 5, "The Thumper ear reaches the wrong distance") + TEST_ASSERT_EQUAL(thumper.contact_fade, 3 SECONDS, "The Thumper ear fades contacts at the wrong rate") + TEST_ASSERT_EQUAL(thumper.ping_volume_bonus, 10, "The Thumper ear is not louder") + + // The range var is what the sweep reads: a contact across the test room is + // in reach, and not once the reach is cut below the distance. + var/mob/living/carbon/human/listener = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/mob/living/carbon/human/contact = allocate(/mob/living/carbon/human/consistent, run_loc_floor_top_right) + var/distance = get_dist(listener, contact) + TEST_ASSERT(distance >= 2 && distance <= 5, "Test fixture: the room is [distance] tiles across, not between 2 and 5") + TEST_ASSERT(thumper.Insert(listener, special = TRUE), "Thumper staging insert was refused") + thumper.start_sonar() + TEST_ASSERT(thumper.watched[contact], "The Thumper ear did not hear a contact [distance] tiles away") + thumper.stop_sonar(listener) + thumper.sonar_range = distance - 1 + thumper.start_sonar() + TEST_ASSERT(!thumper.watched[contact], "The Thumper ear heard a contact beyond its reach") + thumper.stop_sonar(listener) + TEST_ASSERT(!length(thumper.watched) && !length(thumper.contacts), "Stopping the Thumper ear left contacts behind") + thumper.Remove(listener, special = TRUE) + + // The parent still reaches the full nine. + var/obj/item/organ/cyberimp/cyberware/doppler/doppler = allocate(/obj/item/organ/cyberimp/cyberware/doppler) + TEST_ASSERT(doppler.Insert(listener, special = TRUE), "Doppler staging insert was refused") + TEST_ASSERT(!thumper.owner, "The Thumper ear stayed in the ear slot beside the Doppler") + doppler.start_sonar() + TEST_ASSERT(doppler.watched[contact], "The Heartbeat Doppler lost a contact it used to hear") + doppler.stop_sonar(listener) + +/// What the shelf and the trade-in say: the cradle quotes a price, the +/// planned price and permission, and a trade-in that pays half the shelf price. +/datum/unit_test/voidcrew_cyberware_models_b_shop + +/datum/unit_test/voidcrew_cyberware_models_b_shop/Run() + build_cyberware_price_index() + // sku, item, credits, vouchers, permission reference + var/list/skus = list( + list(/datum/shop_sku/ripperdoc/hardweave, /obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave, 3000, 0, /datum/shop_sku/ripperdoc/dermal_mesh), + list(/datum/shop_sku/ripperdoc/atlas_street, /obj/item/organ/cyberimp/cyberware/atlas/street, 1500, 0, /datum/shop_sku/ripperdoc/dermal_mesh), + list(/datum/shop_sku/ripperdoc/second_wind_deep, /obj/item/organ/cyberimp/cyberware/second_wind/deep, 1800, 0, /datum/shop_sku/ripperdoc/shock_coils), + list(/datum/shop_sku/ripperdoc/coolant_street, /obj/item/organ/cyberimp/cyberware/coolant/street, 1500, 0, /datum/shop_sku/ripperdoc/shock_coils), + list(/datum/shop_sku/ripperdoc/frostline, /obj/item/organ/cyberimp/cyberware/frostline, 1500, 0, /datum/shop_sku/ripperdoc/shock_coils), + list(/datum/shop_sku/ripperdoc/slipwire_street, /obj/item/organ/cyberimp/cyberware/slipwire/street, 1800, 0, /datum/shop_sku/ripperdoc/dermal_mesh), + list(/datum/shop_sku/ripperdoc/slipwire_milspec, /obj/item/organ/cyberimp/cyberware/slipwire/milspec, 0, 3, /datum/shop_sku/ripperdoc/coolant), + list(/datum/shop_sku/ripperdoc/doppler_street, /obj/item/organ/cyberimp/cyberware/doppler/street, 1500, 0, /datum/shop_sku/ripperdoc/dermal_mesh), + ) + for(var/list/row as anything in skus) + var/datum/shop_sku/sku_type = row[1] + var/reference_type = row[5] + var/datum/shop_sku/reference = reference_type + TEST_ASSERT_EQUAL(initial(sku_type.item_path), row[2], "[sku_type] sells the wrong piece") + TEST_ASSERT_EQUAL(initial(sku_type.price_credits), row[3], "[sku_type] has the wrong credit price") + TEST_ASSERT_EQUAL(initial(sku_type.price_vouchers), row[4], "[sku_type] has the wrong voucher price") + TEST_ASSERT_EQUAL(initial(sku_type.zone_permission), initial(reference.zone_permission), "[sku_type] sits behind the wrong reputation") + var/list/quote = GLOB.cyberware_price_index[row[2]] + TEST_ASSERT_NOTNULL(quote, "The cradle has no price for [row[2]]") + if(quote) + TEST_ASSERT_EQUAL(quote["credits"], row[3], "The cradle quotes [row[2]] differently from its shelf") + TEST_ASSERT_EQUAL(quote["vouchers"], row[4], "The cradle quotes [row[2]] differently from its shelf") + + // The trade-in: one entry per credit-priced model, exact type, half list. + // Splice's entry and Ratchet's share the item and the pay. + var/list/ledgers = list( + list(/datum/shop_buyback/ripperdoc/hardweave, /datum/shop_sku/ripperdoc/hardweave), + list(/datum/shop_buyback/ripperdoc/atlas_street, /datum/shop_sku/ripperdoc/atlas_street), + list(/datum/shop_buyback/ripperdoc/second_wind_deep, /datum/shop_sku/ripperdoc/second_wind_deep), + list(/datum/shop_buyback/ripperdoc/coolant_street, /datum/shop_sku/ripperdoc/coolant_street), + list(/datum/shop_buyback/ripperdoc/frostline, /datum/shop_sku/ripperdoc/frostline), + list(/datum/shop_buyback/ripperdoc/slipwire_street, /datum/shop_sku/ripperdoc/slipwire_street), + list(/datum/shop_buyback/ripperdoc/doppler_street, /datum/shop_sku/ripperdoc/doppler_street), + ) + for(var/list/row as anything in ledgers) + var/ledger_type = row[1] + var/datum/shop_sku/sku_type = row[2] + var/datum/shop_buyback/ledger = allocate(ledger_type) + var/datum/shop_buyback/ratchet = allocate(text2path("[ledger_type]/street_doc")) + TEST_ASSERT_EQUAL(ledger.item_path, initial(sku_type.item_path), "[ledger_type] buys the wrong piece") + TEST_ASSERT(!ledger.match_subtypes, "[ledger_type] buys back its piece's subtypes") + TEST_ASSERT_EQUAL(ledger.pay_credits * 2, initial(sku_type.price_credits), "[ledger_type] does not pay half the shelf price") + TEST_ASSERT(!ledger.pay_vouchers, "[ledger_type] pays vouchers") + TEST_ASSERT_EQUAL(ratchet.item_path, ledger.item_path, "The street doc's [ledger_type] buys a different piece") + TEST_ASSERT_EQUAL(ratchet.pay_credits, ledger.pay_credits, "The street doc's [ledger_type] pays a different amount") + TEST_ASSERT(ratchet.desc != ledger.desc, "The street doc's [ledger_type] has no wording of his own") + + // The parents' own entries take only the parent, so a Hardweave or a + // Deep-lung never sells at the cheaper piece's rate. + var/datum/shop_buyback/mesh_ledger = allocate(/datum/shop_buyback/ripperdoc/dermal_mesh) + TEST_ASSERT(mesh_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh)), "The Dermal Mesh ledger won't take a Dermal Mesh") + TEST_ASSERT(!mesh_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave)), "The Dermal Mesh ledger takes a Hardweave") + var/datum/shop_buyback/bladder_ledger = allocate(/datum/shop_buyback/ripperdoc/second_wind) + TEST_ASSERT(bladder_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/second_wind)), "The Second Wind ledger won't take a Second Wind") + TEST_ASSERT(!bladder_ledger.matches(allocate(/obj/item/organ/cyberimp/cyberware/second_wind/deep)), "The Second Wind ledger takes a Deep-lung") + + // Vouchers cannot be refunded: the Weaver shunt has no entry anywhere. + for(var/buyback_type in typesof(/datum/shop_buyback/ripperdoc)) + var/datum/shop_buyback/ledger = buyback_type + var/path = initial(ledger.item_path) + if(!path) + continue + var/buys_weaver = initial(ledger.match_subtypes) ? ispath(/obj/item/organ/cyberimp/cyberware/slipwire/milspec, path) : (path == /obj/item/organ/cyberimp/cyberware/slipwire/milspec) + TEST_ASSERT(!buys_weaver, "[buyback_type] buys back the Weaver shunt") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_npcs.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_npcs.dm new file mode 100644 index 00000000000..fc7f8a78fbf --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_npcs.dm @@ -0,0 +1,215 @@ +/** + * Cyberware against the human NPCs and the gore layer. + * + * Human NPCs (voidcrew/modules/human_npcs/) are real human bodies, so the chrome works on them as on + * a player, but an NPC's chrome burns out to scrap (/obj/item/burnt_chrome) when it dies or a piece + * leaves its body by any route. These tests pin that the burn-out beats the chrome salvage (gib, + * dust, a lost limb), that the scrap is no chrome (nothing reinstalls it, no ledger buys it), and + * that Chrome Read works on an NPC. The kit's chrome dummy is such a body. + * + * The gore layer (voidcrew/modules/hyperviolence/): the Atlas frame's dismember immunity stops head + * bursts; the street Strut frame holds the bones only, so it stops fractures (the skull and jaw + * crits included) but not a burst; Hardweave plating counts toward the crit armour gate; a Lazarus + * node never brings back a body whose head burst during its wind-up; and the blades cut as blades. + * + * Literals (unit tests are included before the fork's defines): CYBERWARE_SCAN_ITEMIZED is 2; the + * Lazarus wind-up is 1 second. + */ + +/// Shared helpers; not a test itself +/datum/unit_test/voidcrew_cyberware_npcs + abstract_type = /datum/unit_test/voidcrew_cyberware_npcs + +/// The floor `dx`, `dy` tiles from the test room's bottom-left corner +/datum/unit_test/voidcrew_cyberware_npcs/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +/// The kit's chrome dummy carrying `ware_types`, cleaned up with the test +/datum/unit_test/voidcrew_cyberware_npcs/proc/dummy_with(list/ware_types, turf/where) + var/list/report = list() + var/mob/living/carbon/human/npc/chrome_dummy/dummy = chrome_kit_make_dummy(where || run_loc_floor_bottom_left, ware_types, report) + allocated += dummy + TEST_ASSERT(!length(report), "The dummy turned chrome away: [jointext(report, "; ")]") + return dummy + +/// Every piece of chrome lying loose (owned by nobody) in or near the test room, however deep it sits +/datum/unit_test/voidcrew_cyberware_npcs/proc/loose_chrome() + . = list() + for(var/turf/floor in range(6, run_loc_floor_bottom_left)) + for(var/obj/item/organ/ware in floor.get_all_contents()) + if(!ware.owner && ware.GetComponent(/datum/component/cyberware)) + . += ware + +/// The burnt-out scrap in or near the test room +/datum/unit_test/voidcrew_cyberware_npcs/proc/scrap_count() + . = 0 + for(var/turf/floor in range(6, run_loc_floor_bottom_left)) + for(var/obj/item/burnt_chrome/scrap in floor.get_all_contents()) + .++ + +/// An NPC's chrome burns out when it dies; Chrome Read works on it while it lives; the +/// scrap is not chrome and no ledger buys it. +/datum/unit_test/voidcrew_cyberware_npcs/burn_out + +/datum/unit_test/voidcrew_cyberware_npcs/burn_out/Run() + var/mob/living/carbon/human/npc/chrome_dummy/dummy = dummy_with(list( + /obj/item/organ/cyberimp/cyberware/slipwire, + /obj/item/organ/cyberimp/cyberware/dermal_mesh, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, + ), spot(2, 2)) + TEST_ASSERT(istype(dummy, /mob/living/carbon/human/npc), "The kit's chrome dummy isn't a human NPC body") + TEST_ASSERT_NULL(dummy.ai_controller, "The kit's chrome dummy has an AI") + TEST_ASSERT_EQUAL(length(get_installed_cyberware(dummy)), 3, "The dummy didn't take its three pieces") + + // Chrome Read reads an NPC like anyone else. + var/mob/living/carbon/human/reader = allocate(/mob/living/carbon/human/consistent, spot(0, 0)) + var/obj/item/organ/eyes/robotic/cyberware/deadeye/optics = allocate(/obj/item/organ/eyes/robotic/cyberware/deadeye) + TEST_ASSERT(optics.Insert(reader, special = TRUE), "Deadeye staging insert was refused") + var/list/report = cyberware_scan_report(dummy, 2) + TEST_ASSERT_EQUAL(report["count"], 3, "Chrome Read miscounted an NPC's chrome") + var/datum/action/cooldown/cyberware/chrome_read/read = locate() in optics.actions + TEST_ASSERT_NOTNULL(read, "The Deadeye link lost its chrome read") + TEST_ASSERT(read.PreActivate(dummy), "The chrome read didn't run on an NPC in reach") + TEST_ASSERT_NOTNULL(read.current_readout, "The chrome read drew nothing over an NPC") + + // Death: every piece comes out as scrap, nothing intact is left anywhere. + dummy.death() + TEST_ASSERT(!length(get_installed_cyberware(dummy)), "A dead NPC kept chrome in its body") + sleep(0.5 SECONDS) + TEST_ASSERT(!length(loose_chrome()), "A dead NPC left working chrome behind") + TEST_ASSERT_EQUAL(scrap_count(), 3, "A dead NPC didn't leave one burnt-out scrap per piece") + + // The scrap is no chrome: nothing can install it, and only the scrap rows buy it. + var/obj/item/burnt_chrome/scrap = locate() in range(6, run_loc_floor_bottom_left) + TEST_ASSERT_NOTNULL(scrap, "Fixture: no scrap to offer") + TEST_ASSERT(!istype(scrap, /obj/item/organ), "Burnt-out chrome is still an organ") + TEST_ASSERT_NULL(scrap.GetComponent(/datum/component/cyberware), "Burnt-out chrome still counts as chrome") + for(var/buyback_type in subtypesof(/datum/shop_buyback)) + if(ispath(buyback_type, /datum/shop_buyback/burnt_chrome)) + continue + var/datum/shop_buyback/ledger = new buyback_type + if(ledger.item_path && ledger.matches(scrap)) + TEST_FAIL("[buyback_type] buys burnt-out chrome") + qdel(ledger) + +/// Chrome the salvage throws loose (gib, dust) or a lost limb carries off burns out all the same. +/datum/unit_test/voidcrew_cyberware_npcs/salvage + +/datum/unit_test/voidcrew_cyberware_npcs/salvage/Run() + // A lost arm takes its chrome with it, and the chrome burns where the arm lies. + var/mob/living/carbon/human/npc/chrome_dummy/maimed = dummy_with(list(/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis), spot(1, 1)) + var/obj/item/bodypart/arm = maimed.get_bodypart(BODY_ZONE_R_ARM) + TEST_ASSERT(arm.dismember(), "Fixture: the dummy's arm wouldn't come off") + sleep(0.5 SECONDS) + TEST_ASSERT(!length(loose_chrome()), "Chrome in an NPC's lost arm stayed working") + TEST_ASSERT_EQUAL(scrap_count(), 1, "Chrome in an NPC's lost arm didn't burn out") + qdel(maimed) + + // Gibbed: the salvage throws the chrome loose, and it burns out where it lands. + var/mob/living/carbon/human/npc/chrome_dummy/gibbed = dummy_with(list( + /obj/item/organ/cyberimp/cyberware/slipwire, + /obj/item/organ/cyberimp/cyberware/atlas/street, + ), spot(2, 2)) + gibbed.gib() + sleep(0.5 SECONDS) + TEST_ASSERT(!length(loose_chrome()), "A gibbed NPC left working chrome behind") + TEST_ASSERT_EQUAL(scrap_count(), 3, "A gibbed NPC's chrome didn't burn out") + + // Dusted: the same. + var/mob/living/carbon/human/npc/chrome_dummy/dusted = dummy_with(list(/obj/item/organ/cyberimp/cyberware/dermal_mesh), spot(3, 3)) + dusted.dust() + sleep(0.5 SECONDS) + TEST_ASSERT(!length(loose_chrome()), "A dusted NPC left working chrome behind") + TEST_ASSERT_EQUAL(scrap_count(), 4, "A dusted NPC's chrome didn't burn out") + +/// The frames against the gore layer: Atlas stops bursts; the Strut frame stops fractures, the skull +/// and jaw crits included, but a head still bursts and a limb still comes off. +/datum/unit_test/voidcrew_cyberware_npcs/frames + +/datum/unit_test/voidcrew_cyberware_npcs/frames/Run() + var/datum/hv_crit/skull = locate(/datum/hv_crit/skull) in GLOB.hv_crits + var/datum/hv_crit/jaw = locate(/datum/hv_crit/jaw) in GLOB.hv_crits + TEST_ASSERT(skull && jaw, "The skull and jaw crits are gone") + + var/mob/living/carbon/human/plain = allocate(/mob/living/carbon/human/consistent, spot(0, 0)) + TEST_ASSERT(skull.can_apply_carbon(plain, plain.get_bodypart(BODY_ZONE_HEAD), WOUND_BLUNT), "Fixture: a plain head can't take the skull crit") + + // Strut: bones only. + var/mob/living/carbon/human/strut_bearer = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/obj/item/organ/cyberimp/cyberware/atlas/street/strut = allocate(/obj/item/organ/cyberimp/cyberware/atlas/street) + TEST_ASSERT(strut.Insert(strut_bearer, special = TRUE), "Strut frame staging insert was refused") + var/obj/item/bodypart/strut_head = strut_bearer.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT(!skull.can_apply_carbon(strut_bearer, strut_head, WOUND_BLUNT), "The skull caved in under a Strut frame") + TEST_ASSERT(!jaw.can_apply_carbon(strut_bearer, strut_head, WOUND_BLUNT), "The jaw shattered under a Strut frame") + var/datum/wound_pregen_data/fracture = GLOB.all_wound_pregen_data[/datum/wound/blunt/bone/severe] + TEST_ASSERT(!fracture.can_be_applied_to(strut_bearer.get_bodypart(BODY_ZONE_L_ARM), list(WOUND_BLUNT)), "An arm fractured under a Strut frame") + TEST_ASSERT(strut_head.can_dismember(), "A Strut frame made the head impossible to take off") + var/obj/item/bodypart/strut_leg = strut_bearer.get_bodypart(BODY_ZONE_R_LEG) + TEST_ASSERT(strut_leg.dismember(), "A Strut frame kept a leg on") + strut_bearer.adjustOxyLoss(160) + TEST_ASSERT_EQUAL(strut_bearer.stat, HARD_CRIT, "Fixture: the Strut bearer isn't in hard crit") + TEST_ASSERT(strut_bearer.hv_burst_head(NORTH), "A Strut frame stopped a head burst") + TEST_ASSERT_NULL(strut_bearer.get_bodypart(BODY_ZONE_HEAD), "A burst head is still on") + + // Atlas: nothing comes off, nothing bursts. + var/mob/living/carbon/human/atlas_bearer = allocate(/mob/living/carbon/human/consistent, spot(2, 0)) + var/obj/item/organ/cyberimp/cyberware/atlas/atlas = allocate(/obj/item/organ/cyberimp/cyberware/atlas) + TEST_ASSERT(atlas.Insert(atlas_bearer, special = TRUE), "Atlas frame staging insert was refused") + TEST_ASSERT(!skull.can_apply_carbon(atlas_bearer, atlas_bearer.get_bodypart(BODY_ZONE_HEAD), WOUND_BLUNT), "The skull caved in under an Atlas frame") + atlas_bearer.adjustOxyLoss(160) + TEST_ASSERT_EQUAL(atlas_bearer.stat, HARD_CRIT, "Fixture: the Atlas bearer isn't in hard crit") + TEST_ASSERT(!atlas_bearer.hv_burst_head(NORTH), "A head burst under an Atlas frame") + TEST_ASSERT_NOTNULL(atlas_bearer.get_bodypart(BODY_ZONE_HEAD), "An Atlas bearer lost the head") + +/// Plating: Hardweave sits in the body's physiology armour, so the crit gate counts it. +/datum/unit_test/voidcrew_cyberware_npcs/plating + +/datum/unit_test/voidcrew_cyberware_npcs/plating/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent, spot(0, 0)) + var/obj/item/bodypart/chest = bearer.get_bodypart(BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(round(hv_crit_cover_rating(bearer, chest, MELEE)), 0, "Fixture: a bare body has crit cover") + var/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave/plating = allocate(/obj/item/organ/cyberimp/cyberware/dermal_mesh/hardweave) + TEST_ASSERT(plating.Insert(bearer, special = TRUE), "Hardweave staging insert was refused") + TEST_ASSERT_EQUAL(round(hv_crit_cover_rating(bearer, chest, MELEE)), 20, "Hardweave plating doesn't count toward the crit gate") + +/// A Lazarus node winds up as its bearer goes down, but a head that bursts in that second stays burst. +/datum/unit_test/voidcrew_cyberware_npcs/lazarus + +/datum/unit_test/voidcrew_cyberware_npcs/lazarus/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent, spot(0, 0)) + var/obj/item/organ/cyberimp/cyberware/lazarus/node = allocate(/obj/item/organ/cyberimp/cyberware/lazarus) + TEST_ASSERT(node.Insert(bearer, special = TRUE), "Lazarus staging insert was refused") + bearer.adjustOxyLoss(160) + TEST_ASSERT_EQUAL(bearer.stat, HARD_CRIT, "Fixture: the Lazarus bearer isn't in hard crit") + TEST_ASSERT(node.jolting, "The Lazarus node didn't wind up as its bearer went down") + TEST_ASSERT(bearer.hv_burst_head(NORTH), "Fixture: the head didn't burst") + TEST_ASSERT_EQUAL(bearer.stat, DEAD, "A burst head didn't kill") + sleep(2 SECONDS) + TEST_ASSERT_EQUAL(bearer.stat, DEAD, "A Lazarus node brought back a body with a burst head") + TEST_ASSERT_NULL(bearer.get_bodypart(BODY_ZONE_HEAD), "A burst head came back") + +/// The blades cut as blades: brute, edged, so they bleed, spray and slash. An aimed Mantis cut at +/// the head can open the throat. +/datum/unit_test/voidcrew_cyberware_npcs/blades + +/datum/unit_test/voidcrew_cyberware_npcs/blades/Run() + var/static/list/blade_types = list( + /obj/item/melee/energy/blade/hardlight/cyberware_mantis, + /obj/item/melee/energy/blade/hardlight/cyberware_mantis/street, + /obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch, + /obj/item/melee/cyberware_monowire, + /obj/item/melee/cyberware_monowire/live, + ) + for(var/blade_type in blade_types) + var/obj/item/blade = allocate(blade_type) + TEST_ASSERT_EQUAL(blade.damtype, BRUTE, "[blade_type] doesn't cut for brute, so it never bleeds") + TEST_ASSERT_EQUAL(hv_crit_wounding_type(NONE, blade), WOUND_SLASH, "[blade_type] doesn't slash") + + var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human/consistent, spot(0, 0)) + var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/obj/item/mantis = allocate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis) + TEST_ASSERT(user.put_in_active_hand(mantis), "Fixture: the user couldn't hold the blade") + user.zone_selected = BODY_ZONE_HEAD + var/obj/item/bodypart/head = victim.get_bodypart(BODY_ZONE_HEAD) + var/datum/hv_crit/landed = victim.hv_try_aimed_crit(head, BODY_ZONE_HEAD, WOUND_SLASH, mantis.force, mantis.wound_bonus, 0, EAST, mantis, user, 95) + TEST_ASSERT(istype(landed, /datum/hv_crit/throat), "An aimed Mantis cut at the head couldn't open the throat") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_passives.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_passives.dm new file mode 100644 index 00000000000..c287e51b479 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_passives.dm @@ -0,0 +1,317 @@ +/** + * # Street passives (voidcrew/modules/cyberware/ware_street_passives.dm) + * + * Clotter node, Adrenal pump, Medic's palms, Cuffer's wrists, Subvocal mic and + * Muffler ear: their slots, their effects while online, the failing-gated + * passive layer taking them away on an EMP and handing them back on a tune-up, + * the pump's wait surviving a refit, and the two speech hooks behind the mic. + * Unit-test files compile before voidcrew/_DEFINES/, so the Subvocal trait is + * written as its literal "cyber_subvocal" and the slots as theirs. + */ + +/// A plain pair of earpieces: a worn item in the ears slot whose radio branch +/// needs no working radio behind it. +/obj/item/clothing/ears/voidcrew_test_subvocal_ears + name = "test earpiece" + +/// Shape: every piece sits in the slot the plan gives it, has an item state of +/// its own, carries no button, and the slot sharing is what the plan says. +/datum/unit_test/voidcrew_cyberware_passives_shape + +/datum/unit_test/voidcrew_cyberware_passives_shape/Run() + var/list/passives = list( + /obj/item/organ/cyberimp/cyberware/clotter_node, + /obj/item/organ/cyberimp/cyberware/adrenal_pump, + /obj/item/organ/cyberimp/cyberware/medic_palms, + /obj/item/organ/cyberimp/cyberware/cuffer_wrists, + /obj/item/organ/cyberimp/cyberware/subvocal_mic, + /obj/item/organ/cyberimp/cyberware/muffler_ear, + ) + for(var/passive_path in passives) + var/obj/item/organ/cyberimp/cyberware/ware = allocate(passive_path) + TEST_ASSERT(ware.icon_state, "[passive_path] has no item state") + TEST_ASSERT(ware.chrome_load > 0, "[passive_path] costs no neural load") + TEST_ASSERT(!length(ware.actions), "[passive_path] grew an action button. These are passive") + + var/obj/item/organ/cyberimp/cyberware/clotter_node/clotter = allocate(/obj/item/organ/cyberimp/cyberware/clotter_node) + var/obj/item/organ/cyberimp/cyberware/adrenal_pump/pump = allocate(/obj/item/organ/cyberimp/cyberware/adrenal_pump) + var/obj/item/organ/cyberimp/cyberware/medic_palms/palms = allocate(/obj/item/organ/cyberimp/cyberware/medic_palms) + var/obj/item/organ/cyberimp/cyberware/cuffer_wrists/wrists = allocate(/obj/item/organ/cyberimp/cyberware/cuffer_wrists) + var/obj/item/organ/cyberimp/cyberware/subvocal_mic/mic = allocate(/obj/item/organ/cyberimp/cyberware/subvocal_mic) + var/obj/item/organ/cyberimp/cyberware/muffler_ear/muffler = allocate(/obj/item/organ/cyberimp/cyberware/muffler_ear) + var/obj/item/organ/cyberimp/cyberware/gecko/gecko = allocate(/obj/item/organ/cyberimp/cyberware/gecko) + var/obj/item/organ/cyberimp/cyberware/doppler/doppler = allocate(/obj/item/organ/cyberimp/cyberware/doppler) + + // ORGAN_SLOT_CYBERWARE_HEART_AUX, _HANDS, _LARYNX and _EARS. + TEST_ASSERT_EQUAL(clotter.slot, "cyberware_heart_aux", "Clotter node is not in the spare heart slot") + TEST_ASSERT_EQUAL(pump.slot, clotter.slot, "The pump and the node can both be fitted. They share the heart slot") + TEST_ASSERT_EQUAL(palms.slot, gecko.slot, "Medic's palms are not in the Gecko Grip's hands slot") + TEST_ASSERT_EQUAL(wrists.slot, gecko.slot, "Cuffer's wrists are not in the Gecko Grip's hands slot") + TEST_ASSERT_EQUAL(mic.slot, "cyberware_larynx", "Subvocal mic is not in the larynx slot") + TEST_ASSERT_EQUAL(muffler.slot, doppler.slot, "Muffler ear is not in the Doppler's ears slot") + + // Cheap street chrome, T1 apart from the pump. + TEST_ASSERT_EQUAL(pump.tier, 2, "The pump is not T2") + for(var/obj/item/organ/cyberimp/cyberware/cheap as anything in list(clotter, palms, wrists, mic, muffler)) + TEST_ASSERT_EQUAL(cheap.tier, 1, "[cheap] is not T1") + + // The cradle quotes a credit price for each, and only the pump needs yellow. + build_cyberware_price_index() + for(var/obj/item/organ/cyberimp/cyberware/priced as anything in list(clotter, pump, palms, wrists, mic, muffler)) + var/list/price = get_cyberware_price(priced) + TEST_ASSERT(price && price["credits"] > 0 && !price["vouchers"], "[priced] quotes no credit-only price at the cradle") + var/datum/shop_sku/ripperdoc/adrenal_pump/pump_sku = allocate(/datum/shop_sku/ripperdoc/adrenal_pump) + var/datum/shop_sku/ripperdoc/clotter_node/clotter_sku = allocate(/datum/shop_sku/ripperdoc/clotter_node) + TEST_ASSERT_EQUAL(pump_sku.zone_permission, 1, "The pump is not sold at yellow permission") // ZONE_PERMISSION_YELLOW + TEST_ASSERT_EQUAL(clotter_sku.zone_permission, 0, "The node is gated") // ZONE_PERMISSION_PUBLIC + +/// Clotter node: halves the blood lost, only while online, with one multiply and +/// one divide however often the passive layer flips, and the pump evicts it. +/datum/unit_test/voidcrew_cyberware_clotter_node + +/datum/unit_test/voidcrew_cyberware_clotter_node/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/clotter_node/clotter = allocate(/obj/item/organ/cyberimp/cyberware/clotter_node) + var/datum/component/cyberware/chrome = clotter.GetComponent(/datum/component/cyberware) + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 1, "Test fixture: the bearer already bleeds differently") + + TEST_ASSERT(clotter.Insert(bearer, special = TRUE), "Test fixture: Clotter node staging insert was refused") + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 0.5, "An installed Clotter node didn't halve the bleed") + + // Asked twice, applied once. + clotter.chrome_passives_on(bearer) + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 0.5, "The node's multiplier was applied twice") + + chrome.start_emp_reboot() + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 1, "An EMP'd Clotter node kept the bleed halved") + chrome.tune_up() + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 0.5, "A tuned-up Clotter node didn't hand the bleed cut back") + + // Retuning a fitted organ takes off what was put on, not what the var says now. + clotter.bleed_multiplier = 0.25 + clotter.Remove(bearer, special = TRUE) + clotter.forceMove(run_loc_floor_bottom_left) + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 1, "Pulling the node left the bleed changed") + + // The heart slot holds one: the pump evicts the node and its cut with it. + clotter.bleed_multiplier = 0.5 + TEST_ASSERT(clotter.Insert(bearer, special = TRUE), "Test fixture: Clotter node refit was refused") + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 0.5, "A refitted Clotter node didn't halve the bleed") + var/obj/item/organ/cyberimp/cyberware/adrenal_pump/pump = allocate(/obj/item/organ/cyberimp/cyberware/adrenal_pump) + TEST_ASSERT(pump.Insert(bearer, special = TRUE), "Test fixture: pump staging insert was refused") + TEST_ASSERT(!clotter.owner, "The pump went in beside the node. They share a slot") + TEST_ASSERT_EQUAL(bearer.physiology.bleed_mod, 1, "The evicted node left its bleed cut on the bearer") + +/// Medic's palms and Cuffer's wrists: their traits while online, gone on an EMP +/// and on removal, and the three hands-slot pieces evict one another. +/datum/unit_test/voidcrew_cyberware_hand_traits + +/datum/unit_test/voidcrew_cyberware_hand_traits/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/medic_palms/palms = allocate(/obj/item/organ/cyberimp/cyberware/medic_palms) + var/obj/item/organ/cyberimp/cyberware/cuffer_wrists/wrists = allocate(/obj/item/organ/cyberimp/cyberware/cuffer_wrists) + var/obj/item/organ/cyberimp/cyberware/gecko/gecko = allocate(/obj/item/organ/cyberimp/cyberware/gecko) + + TEST_ASSERT(palms.Insert(bearer, special = TRUE), "Test fixture: Medic's palms staging insert was refused") + TEST_ASSERT(HAS_TRAIT(bearer, TRAIT_FASTMED), "Medic's palms didn't give the quicker chemistry trait") + TEST_ASSERT(HAS_TRAIT(bearer, TRAIT_QUICKER_CARRY), "Medic's palms didn't give the quicker carry trait") + TEST_ASSERT(!HAS_TRAIT(bearer, TRAIT_FAST_CUFFING), "Medic's palms give quicker cuffing") + + var/datum/component/cyberware/chrome = palms.GetComponent(/datum/component/cyberware) + chrome.start_emp_reboot() + TEST_ASSERT(!HAS_TRAIT(bearer, TRAIT_FASTMED) && !HAS_TRAIT(bearer, TRAIT_QUICKER_CARRY), "EMP'd Medic's palms kept their traits") + chrome.tune_up() + TEST_ASSERT(HAS_TRAIT(bearer, TRAIT_FASTMED) && HAS_TRAIT(bearer, TRAIT_QUICKER_CARRY), "Tuned-up Medic's palms didn't hand their traits back") + + // Cuffer's wrists evict the palms: same slot. + TEST_ASSERT(wrists.Insert(bearer, special = TRUE), "Test fixture: Cuffer's wrists staging insert was refused") + TEST_ASSERT(!palms.owner, "The wrists went in beside the palms. They share a slot") + TEST_ASSERT(HAS_TRAIT(bearer, TRAIT_FAST_CUFFING), "Cuffer's wrists didn't give quicker cuffing") + TEST_ASSERT(!HAS_TRAIT(bearer, TRAIT_FASTMED) && !HAS_TRAIT(bearer, TRAIT_QUICKER_CARRY), "The evicted palms left their traits on the bearer") + + // And the Gecko Grip evicts the wrists. + TEST_ASSERT(gecko.Insert(bearer, special = TRUE), "Test fixture: Gecko Grip staging insert was refused") + TEST_ASSERT(!wrists.owner, "The Gecko Grip went in beside the wrists. They share a slot") + TEST_ASSERT(!HAS_TRAIT(bearer, TRAIT_FAST_CUFFING), "The evicted wrists left quicker cuffing on the bearer") + +/// Muffler ear: a bang loses a point of intensity while the ear is online, the +/// same point earmuffs take off, and nothing when it is offline or pulled. The +/// intensity rides in a list, so the signal is read directly: the real +/// soundbang_act() also depends on the room's air. +/datum/unit_test/voidcrew_cyberware_muffler_ear + +/datum/unit_test/voidcrew_cyberware_muffler_ear/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/muffler_ear/muffler = allocate(/obj/item/organ/cyberimp/cyberware/muffler_ear) + var/datum/component/cyberware/chrome = muffler.GetComponent(/datum/component/cyberware) + + var/list/reflist = list(1) + SEND_SIGNAL(bearer, COMSIG_CARBON_SOUNDBANG, reflist) + TEST_ASSERT_EQUAL(reflist[1], 1, "A bare body took a point off a bang") + + TEST_ASSERT(muffler.Insert(bearer, special = TRUE), "Test fixture: Muffler ear staging insert was refused") + reflist = list(1) + SEND_SIGNAL(bearer, COMSIG_CARBON_SOUNDBANG, reflist) + TEST_ASSERT_EQUAL(reflist[1], 0, "The Muffler ear didn't take a point off the bang") + + // A bigger bang loses the one point and no more. + reflist = list(2) + SEND_SIGNAL(bearer, COMSIG_CARBON_SOUNDBANG, reflist) + TEST_ASSERT_EQUAL(reflist[1], 1, "The Muffler ear took more than a point off a bigger bang") + + chrome.start_emp_reboot() + reflist = list(1) + SEND_SIGNAL(bearer, COMSIG_CARBON_SOUNDBANG, reflist) + TEST_ASSERT_EQUAL(reflist[1], 1, "An EMP'd Muffler ear still muffled the bang") + chrome.tune_up() + reflist = list(1) + SEND_SIGNAL(bearer, COMSIG_CARBON_SOUNDBANG, reflist) + TEST_ASSERT_EQUAL(reflist[1], 0, "A tuned-up Muffler ear didn't muffle the bang again") + + muffler.Remove(bearer, special = TRUE) + reflist = list(1) + SEND_SIGNAL(bearer, COMSIG_CARBON_SOUNDBANG, reflist) + TEST_ASSERT_EQUAL(reflist[1], 1, "A pulled Muffler ear still muffled the bang") + +/// Adrenal pump: quiet below its trigger, one answer to a bad run of stamina +/// damage, nothing inside the wait (a refit doesn't reset it), nothing while +/// offline, and everything back once the wait is over. +/datum/unit_test/voidcrew_cyberware_adrenal_pump + +/datum/unit_test/voidcrew_cyberware_adrenal_pump/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/adrenal_pump/pump = allocate(/obj/item/organ/cyberimp/cyberware/adrenal_pump) + TEST_ASSERT(pump.Insert(bearer, special = TRUE), "Test fixture: Adrenal pump staging insert was refused") + var/datum/component/cyberware/chrome = pump.GetComponent(/datum/component/cyberware) + + // Below the trigger: nothing. + bearer.adjustStaminaLoss(50) + sleep(0.5 SECONDS) + TEST_ASSERT_EQUAL(pump.ready_at, 0, "The pump fired below its trigger level") + TEST_ASSERT(!bearer.has_status_effect(/datum/status_effect/cyberware_adrenal_rush), "A rush started below the pump's trigger level") + + // Over it: part of the loss comes off, the bearer is quick and flushed, and + // the wait starts. + bearer.adjustStaminaLoss(30) + sleep(0.5 SECONDS) + TEST_ASSERT(bearer.getStaminaLoss() <= 45, "The pump didn't take stamina loss off ([bearer.getStaminaLoss()] left of 80)") + TEST_ASSERT(bearer.has_status_effect(/datum/status_effect/cyberware_adrenal_rush), "The pump fired without a rush") + TEST_ASSERT(bearer.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_adrenal_rush), "The rush didn't speed the bearer up") + TEST_ASSERT(pump.ready_at > world.time, "The pump didn't start its wait") + + // Inside the wait: another bad run gets no answer. + bearer.adjustStaminaLoss(50) + sleep(0.5 SECONDS) + TEST_ASSERT(bearer.getStaminaLoss() >= 85, "The pump fired again inside its wait") + + // Pulled and refitted: still waiting. The clock lives on the organ. + var/waiting_until = pump.ready_at + pump.Remove(bearer, special = TRUE) + pump.forceMove(run_loc_floor_bottom_left) + TEST_ASSERT(pump.Insert(bearer, special = TRUE), "Test fixture: Adrenal pump refit was refused") + TEST_ASSERT_EQUAL(pump.ready_at, waiting_until, "Refitting the pump reset its wait") + bearer.adjustStaminaLoss(5) + sleep(0.5 SECONDS) + TEST_ASSERT(bearer.getStaminaLoss() >= 90, "A refitted pump fired inside its wait") + + // Offline: no answer, and the wait is not spent. + bearer.setStaminaLoss(0) + pump.ready_at = 0 + chrome.start_emp_reboot() + bearer.adjustStaminaLoss(80) + sleep(0.5 SECONDS) + TEST_ASSERT_EQUAL(pump.ready_at, 0, "An EMP'd pump fired") + TEST_ASSERT(bearer.getStaminaLoss() >= 75, "An EMP'd pump took stamina loss off") + + // Back online, the next bad run is answered. + chrome.tune_up() + bearer.adjustStaminaLoss(1) + sleep(0.5 SECONDS) + TEST_ASSERT(pump.ready_at > world.time, "A tuned-up pump didn't answer a bad run") + TEST_ASSERT(bearer.getStaminaLoss() <= 45, "A tuned-up pump didn't take stamina loss off") + +/// The Cascade and Redline crashes dump stamina as their own price. The pump +/// stands down for them: it is a bar against outside damage, not a way out of +/// the legend ware's bill. +/datum/unit_test/voidcrew_cyberware_adrenal_pump_crash + +/datum/unit_test/voidcrew_cyberware_adrenal_pump_crash/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/adrenal_pump/pump = allocate(/obj/item/organ/cyberimp/cyberware/adrenal_pump) + TEST_ASSERT(pump.Insert(bearer, special = TRUE), "Test fixture: Adrenal pump staging insert was refused") + + bearer.apply_status_effect(/datum/status_effect/cyberware_cascade_crash) + sleep(0.5 SECONDS) + TEST_ASSERT(bearer.has_status_effect(/datum/status_effect/cyberware_cascade_crash), "Test fixture: the Cascade crash isn't running") + TEST_ASSERT(bearer.getStaminaLoss() >= 70, "Test fixture: the Cascade crash dumped no stamina") + TEST_ASSERT_EQUAL(pump.ready_at, 0, "The pump answered the Cascade crash's own stamina dump") + TEST_ASSERT(!bearer.has_status_effect(/datum/status_effect/cyberware_adrenal_rush), "The pump started a rush in the middle of a Cascade crash") + bearer.remove_status_effect(/datum/status_effect/cyberware_cascade_crash) + + var/mob/living/carbon/human/redliner = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/cyberimp/cyberware/adrenal_pump/second_pump = allocate(/obj/item/organ/cyberimp/cyberware/adrenal_pump) + TEST_ASSERT(second_pump.Insert(redliner, special = TRUE), "Test fixture: second pump staging insert was refused") + redliner.apply_status_effect(/datum/status_effect/cyberware_redline_crash) + sleep(0.5 SECONDS) + TEST_ASSERT(redliner.has_status_effect(/datum/status_effect/cyberware_redline_crash), "Test fixture: the Redline crash isn't running") + TEST_ASSERT_EQUAL(second_pump.ready_at, 0, "The pump answered the Redline crash's own stamina dump") + redliner.remove_status_effect(/datum/status_effect/cyberware_redline_crash) + +/// Subvocal mic: a radio line from a bearer is spoken at range 0, anything else +/// they say, and every line from a body without the mic, keeps its range. The +/// mark the radio branch leaves is spent by the one send_speech() that follows. +/datum/unit_test/voidcrew_cyberware_subvocal_mic + /// The range the speaker's own Hear() was handed, or null before any line. + var/heard_range + +/datum/unit_test/voidcrew_cyberware_subvocal_mic/proc/on_heard(datum/source, list/hear_args) + SIGNAL_HANDLER + heard_range = hear_args[HEARING_RANGE] + +/// One radio line the way say() sends it: the radio branch first, then the +/// whisper-range send. Returns the range the speaker's own Hear() was given. +/datum/unit_test/voidcrew_cyberware_subvocal_mic/proc/speak_on_radio(mob/living/carbon/human/speaker) + heard_range = null + var/radio_flags = speaker.radio("test", list(MODE_HEADSET = TRUE), list(), null) + TEST_ASSERT(radio_flags & REDUCE_RANGE, "Test fixture: the radio branch didn't shorten the range") + speaker.send_speech("test", 1, speaker, speaker.bubble_icon, list(), null, list(WHISPER_MODE = MODE_WHISPER)) + return heard_range + +/datum/unit_test/voidcrew_cyberware_subvocal_mic/Run() + var/mob/living/carbon/human/speaker = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) + var/obj/item/clothing/ears/voidcrew_test_subvocal_ears/earpiece = allocate(/obj/item/clothing/ears/voidcrew_test_subvocal_ears) + speaker.equip_to_slot_if_possible(earpiece, ITEM_SLOT_EARS, qdel_on_fail = FALSE, disable_warning = TRUE) + TEST_ASSERT_EQUAL(speaker.ears, earpiece, "Test fixture: the earpiece didn't equip") + RegisterSignal(speaker, COMSIG_MOVABLE_PRE_HEAR, PROC_REF(on_heard)) + + // No mic: radio talk is whispered at range 1, as ever. + TEST_ASSERT_EQUAL(speak_on_radio(speaker), 1, "A body without the mic changed its radio range") + TEST_ASSERT(!speaker.cyberware_subvocal_pending, "A body without the mic left a mark behind") + + var/obj/item/organ/cyberimp/cyberware/subvocal_mic/mic = allocate(/obj/item/organ/cyberimp/cyberware/subvocal_mic) + TEST_ASSERT(mic.Insert(speaker, special = TRUE), "Test fixture: Subvocal mic staging insert was refused") + TEST_ASSERT(HAS_TRAIT(speaker, "cyber_subvocal"), "The Subvocal mic didn't give its trait") // TRAIT_CYBER_SUBVOCAL + + // Mic: the radio line is spoken at range 0, and the mark is spent. + TEST_ASSERT_EQUAL(speak_on_radio(speaker), 0, "A radio line from a Subvocal mic bearer kept its range") + TEST_ASSERT(!speaker.cyberware_subvocal_pending, "The radio line's mark outlived its send") + + // An ordinary line right after is not quieted. + heard_range = null + speaker.send_speech("test", 6, speaker, speaker.bubble_icon, list(), null, list()) + TEST_ASSERT_EQUAL(heard_range, 6, "A spoken line after a radio line was quieted") + + // A mark nobody sent is cleared by the next radio branch rather than quieting a plain line. + speaker.cyberware_subvocal_pending = TRUE + speaker.radio("test", list(), list(), null) + TEST_ASSERT(!speaker.cyberware_subvocal_pending, "A stale mark survived a radio branch that sent nothing") + + // Offline: radio talk is overheard again. + var/datum/component/cyberware/chrome = mic.GetComponent(/datum/component/cyberware) + chrome.start_emp_reboot() + TEST_ASSERT_EQUAL(speak_on_radio(speaker), 1, "An EMP'd Subvocal mic still quieted the radio") + chrome.tune_up() + TEST_ASSERT_EQUAL(speak_on_radio(speaker), 0, "A tuned-up Subvocal mic didn't quiet the radio again") + + mic.Remove(speaker, special = TRUE) + TEST_ASSERT_EQUAL(speak_on_radio(speaker), 1, "A pulled Subvocal mic still quieted the radio") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_soak.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_soak.dm new file mode 100644 index 00000000000..4fa57d641bb --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_soak.dm @@ -0,0 +1,935 @@ +/** + * # Chrome soak + * + * A long, loud, mostly random test for the cyberware module (voidcrew/modules/cyberware/). + * Ten humans get random chrome loadouts and are then put through five minutes of game time of + * everything players and the world do to chrome: every installed ability triggered (with real + * targets, so click abilities fire), EMPs on bodies and on single pieces, forced brownouts, + * cradle installs, removals and tune-ups, sell-backs at the ripperdoc ledgers, death and + * revival, gibbing and dusting (chrome salvage), lost limbs, stuns, cuffs, pacifism, zoom, + * a ride in a mech, speech. A sweep every two seconds checks that the ware's own bookkeeping + * stays consistent. At the end the survivors are healed, stripped of chrome, left alone and + * compared against a snapshot taken before they got any, and everything the soak made is + * deleted and checked for being garbage collected. + * + * It is a SOAK, not a regression test: it fails on any runtime (the error handler fails + * whichever test is running, see docs/UNIT_TESTING_LOCAL.md), on any inconsistency the sweep + * finds, and on anything left behind. It is also slow, so it extends voidcrew_opt_in and is + * left out of a general run. Run it on its own: + * + * dd.exe tgstation.dmb -port -close -trusted -invisible \ + * -params "log-directory=ci&test_only=/datum/unit_test/voidcrew_opt_in/cyberware_soak" + * + * Optional world params: soak_length (deciseconds of storm, default 3000) and soak_seed + * (a number, to repeat a roll of the dice). The report is also written to data/soak_report.txt. + * + * Unit-test files compile before voidcrew/_DEFINES/, so the fork defines this file needs are + * restated below under SOAK_ names. + */ + +/// ORGAN_SLOT_CYBERWARE_SKIN, the Ghostskin slot. +#define SOAK_SLOT_SKIN "cyberware_skin" +/// TRAIT_CYBER_CAMO and TRAIT_CYBER_ZOOMED. +#define SOAK_TRAIT_CAMO "cyber_camo" +#define SOAK_TRAIT_ZOOMED "cyber_zoomed" +/// CYBERWARE_INSTALL_TIME, CYBERWARE_REMOVAL_TIME, CYBERWARE_EMP_DOWNTIME and CYBERWARE_TUNEUP_FEE. +#define SOAK_INSTALL_TIME (4 SECONDS) +#define SOAK_REMOVAL_TIME (3 SECONDS) +#define SOAK_EMP_DOWNTIME (9 SECONDS) +#define SOAK_TUNEUP_FEE 200 +/// How long an inconsistency must hold before the sweep calls it a bug. SSmobs ticks every +/// two seconds and the ware's per-tick settle runs on it, so anything shorter is a race. +#define SOAK_PATIENCE (6 SECONDS) + +/// Ballast for forcing a brownout: far over any body's capacity, in a slot nothing else uses, +/// with no ability of its own. +/obj/item/organ/cyberimp/cyberware/soak_ballast + name = "soak ballast" + zone = BODY_ZONE_CHEST + slot = "voidcrew_soak_ballast" + chrome_load = 25 + +/datum/unit_test/voidcrew_opt_in/cyberware_soak + priority = TEST_LONGER + /// Game time the storm runs for. + var/storm_length = 3000 + /// Bodies kept in play. + var/crew_size = 10 + /// FALSE once the storm is over, so late async events stand down. + var/storming = FALSE + /// Live bodies. + var/list/crew = list() + /// Body -> its snapshot from before it had any chrome. + var/list/baselines = list() + /// Chrome that came off a body or out of a gib and lies about, for the cradle to reinstall. + var/list/loose_chrome = list() + /// Weakrefs to everything this test made that must be collected at the end. + var/list/made = list() + /// Every installable chrome typepath. + var/list/ware_pool = list() + /// Floor turfs in the room. + var/list/floor_turfs = list() + /// Splice's ledgers (the street doc's are the same entries with other words). + var/list/ledgers = list() + /// Problem category -> how many times it was seen. + var/list/problem_counts = list() + /// Problem category -> the first example. + var/list/problem_examples = list() + /// Counters for the report. + var/list/stats = list() + /// Sweep keys seen in this sweep. + var/list/seen_now = list() + /// Sweep key -> world.time it was first seen. + var/list/suspects = list() + /// Sweep keys already reported. + var/list/reported = list() + var/obj/machinery/chrome_cradle/cradle + /// The cradle is single-use at a time; this is the world.time its current user lets go. + var/cradle_lease = 0 + var/mech_lease = 0 + var/next_index = 0 + var/runtimes_at_start = 0 + var/skipped_runtimes_at_start = 0 + var/timers_at_start = 0 + /// SSgarbage failure and hard-delete counts per type before the storm. + var/list/gc_before = list() + +// ---- Bookkeeping --------------------------------------------------------- + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/note(category, detail) + problem_counts[category] = (problem_counts[category] || 0) + 1 + if(!problem_examples[category]) + problem_examples[category] = detail + log_world("SOAK PROBLEM: [category]: [detail]") + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/count(what, amount = 1) + stats[what] = (stats[what] || 0) + amount + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/track(datum/thing) + made += WEAKREF(thing) + return thing + +/// A sweep finding that only counts once it has held for `patience`. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/suspect(key, category, detail, patience = SOAK_PATIENCE) + seen_now[key] = TRUE + if(!suspects[key]) + suspects[key] = world.time + return + if(world.time - suspects[key] >= patience && !reported[key]) + reported[key] = TRUE + note(category, detail) + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/rng_seed() + var/seed = text2num(world.params["soak_seed"]) + if(isnull(seed)) + seed = rand(1, 999999) + rand_seed(seed) + log_world("SOAK seed [seed]") + return seed + +// ---- Setup --------------------------------------------------------------- + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/build_pool() + ware_pool = voidcrew_cyberware_pool().Copy() + TEST_ASSERT(length(ware_pool) > 40, "The chrome pool is only [length(ware_pool)] types, the walk of the subtypes found too little") + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/build_room() + var/turf/low = run_loc_floor_bottom_left + var/turf/high = run_loc_floor_top_right + for(var/x in min(low.x, high.x) to max(low.x, high.x)) + for(var/y in min(low.y, high.y) to max(low.y, high.y)) + var/turf/candidate = locate(x, y, low.z) + // The cradle's tile lifts whoever stands on it, which would be part of a snapshot. + if(isfloorturf(candidate) && candidate != run_loc_floor_top_right) + floor_turfs += candidate + TEST_ASSERT(length(floor_turfs) >= 12, "The test room only has [length(floor_turfs)] floor tiles") + +/// A fresh body. It stands bare for a few seconds first, so the snapshot it is later compared +/// with already has the modifiers every body picks up on its own (mood, for one). +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/spawn_body() + next_index++ + var/index = next_index + var/mob/living/carbon/human/body = new /mob/living/carbon/human/consistent(pick(floor_turfs)) + track(body) + body.fully_replace_character_name(body.real_name, "Soak [index]") + var/obj/item/card/id/id = new(body) + id.registered_account = allocate(/datum/bank_account, "Soak [index]", null, 1, FALSE) + id.registered_account.account_balance = 50000 + body.equip_to_slot_or_del(id, ITEM_SLOT_ID) + body.equip_to_slot_or_del(new /obj/item/clothing/under/color/grey(body), ITEM_SLOT_ICLOTHING) + sleep(6 SECONDS) + if(QDELETED(body) || !storming) + return body + baselines[body] = snapshot(body) + crew += body + random_loadout(body) + return body + +/// A random set of chrome in a random body. Most bodies fit their load; some are loaded +/// past capacity on purpose and start browned out. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/random_loadout(mob/living/carbon/human/body) + var/overshoot = prob(25) ? rand(1, 8) : 0 + var/pieces = rand(2, 7) + var/list/candidates = shuffle(ware_pool.Copy()) + for(var/ware_type in candidates) + if(pieces <= 0) + break + var/obj/item/organ/ware = track(new ware_type(get_turf(body))) + if(!body.get_bodypart(deprecise_zone(ware.zone))) + qdel(ware) + continue + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + var/list/incumbents = ware.cyberware_get_incumbents(body) + // Keep most loadouts free of evictions, they are not what is being tested here. + if(length(incumbents) && prob(85)) + qdel(ware) + continue + var/projected = get_chrome_load(body) + (chrome?.chrome_load || 0) + for(var/obj/item/organ/incumbent in incumbents) + projected -= get_installed_capacity_cost(incumbent) + if(projected > get_chrome_capacity(body) + (chrome?.capacity_bonus || 0) + overshoot) + qdel(ware) + continue + if(!ware.Insert(body, special = TRUE)) + qdel(ware) + continue + pieces-- + count("pieces installed") + +/// Everything that should be back to normal once a body has no chrome and has been left alone. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/snapshot(mob/living/carbon/human/body) + var/list/snap = list() + snap["filters"] = length(body.filters) + snap["actions"] = length(body.actions) + // tg's eyelids join the body's vis_contents whenever eyes are drawn, and stay there after + // the eyes leave, so chrome optics going in and out would read as a leak. Not chrome's. + var/visible = 0 + for(var/atom/movable/thing as anything in body.vis_contents) + if(!istype(thing, /obj/effect/abstract/eyelid_effect)) + visible++ + snap["vis_contents"] = visible + var/list/statuses = list() + for(var/datum/status_effect/effect as anything in body.status_effects) + statuses += "[effect.type]" + snap["status effects"] = statuses + var/list/traits = list() + for(var/trait in body._status_traits) + traits[trait] = length(body._status_traits[trait]) + snap["traits"] = traits + var/list/speed = list() + for(var/modifier in body.movespeed_modification) + speed += "[modifier]" + snap["movespeed"] = speed + var/list/action_speed = list() + for(var/modifier in body.actionspeed_modification) + // Mood's own modifier arrives on its own schedule. + if(!findtext("[modifier]", "sanity_component")) + action_speed += "[modifier]" + snap["actionspeed"] = action_speed + var/list/physiology = list() + for(var/var_name in body.physiology.vars) + // The reference finder stamps every datum it walks after a failed GC. + if(var_name == "last_find_references") + continue + var/value = body.physiology.vars[var_name] + if(isnum(value)) + physiology[var_name] = value + for(var/rating in ARMOR_LIST_ALL()) + physiology["armor [rating]"] = body.physiology.armor.get_rating(rating) + snap["physiology"] = physiology + var/list/components = list() + for(var/component_type in body._datum_components) + components += "[component_type]" + snap["components"] = components + var/list/loose = list() + for(var/atom/movable/thing as anything in body.contents) + if(isorgan(thing) || isbodypart(thing) || istype(thing, /obj/item/clothing) || istype(thing, /obj/item/card/id)) + continue + loose += "[thing.type]" + snap["carried"] = loose + var/list/held = list() + for(var/obj/item/thing in body.held_items) + held += "[thing.type]" + snap["held"] = held + snap["intercept"] = body.click_intercept ? "[body.click_intercept.type]" : null + return snap + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/Run() + rng_seed() + var/length_param = text2num(world.params["soak_length"]) + if(length_param) + storm_length = length_param + runtimes_at_start = GLOB.total_runtimes + skipped_runtimes_at_start = GLOB.total_runtimes_skipped + timers_at_start = length(SStimer.timer_id_dict) + for(var/gc_type in SSgarbage.items) + var/datum/qdel_item/item = SSgarbage.items[gc_type] + gc_before[gc_type] = list(item.failures, item.hard_deletes) + + build_pool() + build_room() + for(var/ledger_type in typesof(/datum/shop_buyback/ripperdoc) - /datum/shop_buyback/ripperdoc) + // Ratchet's entries are the same ledger in other words. + if(findtext("[ledger_type]", "/street_doc")) + continue + ledgers += allocate(ledger_type) + cradle = track(new /obj/machinery/chrome_cradle(run_loc_floor_top_right)) + storming = TRUE + for(var/i in 1 to crew_size) + INVOKE_ASYNC(src, PROC_REF(spawn_body)) + sleep(8 SECONDS) + // Two bodies are pacifists for the whole storm. + for(var/i in 1 to min(2, length(crew))) + var/mob/living/carbon/human/pacifist = crew[i] + ADD_TRAIT(pacifist, TRAIT_PACIFISM, "soak") + + var/end_time = world.time + storm_length + var/next_sweep = world.time + var/next_heal = world.time + 20 SECONDS + while(world.time < end_time) + sleep(1 SECONDS) + storm_tick() + if(world.time >= next_sweep) + next_sweep = world.time + 2 SECONDS + sweep() + if(world.time >= next_heal) + next_heal = world.time + 20 SECONDS + top_up() + storming = FALSE + // Let the long events (a death waiting to revive, a brownout waiting to lift, a cradle + // sequence) finish before anyone looks at the wreckage. + sleep(15 SECONDS) + sweep() + sweep() + + audit_survivors() + var/list/leaks = clean_up() + report(leaks) + +// ---- The storm ----------------------------------------------------------- + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/storm_tick() + var/static/list/event_weights = list( + "trigger" = 30, "swing" = 12, "wheel" = 4, "emp" = 8, "emp_one" = 4, "brownout" = 6, + "cradle" = 5, "sell" = 3, "kill" = 5, "gib" = 2, "dust" = 1, "dismember" = 5, "stun" = 6, + "cuff" = 3, "pacifist" = 2, "zoom" = 6, "damage" = 4, "mech" = 2, "speak" = 2, "swap" = 4, + ) + for(var/mob/living/carbon/human/body as anything in crew.Copy()) + if(QDELETED(body)) + crew -= body + baselines -= body + INVOKE_ASYNC(src, PROC_REF(spawn_body)) + continue + if(!prob(35)) + continue + switch(pick_weight(event_weights)) + if("trigger") + INVOKE_ASYNC(src, PROC_REF(ev_trigger), body) + if("swing") + INVOKE_ASYNC(src, PROC_REF(ev_swing), body) + if("wheel") + INVOKE_ASYNC(src, PROC_REF(ev_wheel), body) + if("emp") + INVOKE_ASYNC(src, PROC_REF(ev_emp), body) + if("emp_one") + INVOKE_ASYNC(src, PROC_REF(ev_emp_one), body) + if("brownout") + INVOKE_ASYNC(src, PROC_REF(ev_brownout), body) + if("cradle") + INVOKE_ASYNC(src, PROC_REF(ev_cradle), body) + if("sell") + INVOKE_ASYNC(src, PROC_REF(ev_sell), body) + if("kill") + INVOKE_ASYNC(src, PROC_REF(ev_kill), body) + if("gib") + INVOKE_ASYNC(src, PROC_REF(ev_gib), body, FALSE) + if("dust") + INVOKE_ASYNC(src, PROC_REF(ev_gib), body, TRUE) + if("dismember") + INVOKE_ASYNC(src, PROC_REF(ev_dismember), body) + if("stun") + INVOKE_ASYNC(src, PROC_REF(ev_stun), body) + if("cuff") + INVOKE_ASYNC(src, PROC_REF(ev_cuff), body) + if("pacifist") + INVOKE_ASYNC(src, PROC_REF(ev_pacifist), body) + if("zoom") + INVOKE_ASYNC(src, PROC_REF(ev_zoom), body) + if("damage") + INVOKE_ASYNC(src, PROC_REF(ev_damage), body) + if("mech") + INVOKE_ASYNC(src, PROC_REF(ev_mech), body) + if("speak") + INVOKE_ASYNC(src, PROC_REF(ev_speak), body) + if("swap") + INVOKE_ASYNC(src, PROC_REF(ev_swap), body) + +/// Something for an ability to be pointed at. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/some_target(mob/living/carbon/human/body) + var/roll = rand(1, 10) + if(roll <= 5) + var/list/others = crew - body + for(var/mob/living/carbon/human/other as anything in others.Copy()) + if(QDELETED(other)) + others -= other + if(length(others)) + return pick(others) + if(roll <= 7 && !QDELETED(cradle)) + return cradle + // A click on yourself is a click like any other, and every button has to take it. + if(roll == 10) + return body + return pick(floor_turfs) + +/// Every installed ability, pointed at something. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_trigger(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + for(var/obj/item/organ/ware as anything in get_installed_cyberware(body)) + for(var/datum/action/ability as anything in LAZYCOPY(ware.actions)) + if(QDELETED(ability) || ability.owner != body) + continue + // Cooldowns would stop most of these after the first press. + if(istype(ability, /datum/action/cooldown) && prob(60)) + var/datum/action/cooldown/timed = ability + timed.next_use_time = 0 + count("ability presses") + INVOKE_ASYNC(ability, TYPE_PROC_REF(/datum/action, Trigger), body, NONE, some_target(body)) + +/// A melee swing or a shot, through the real click path, with whatever is in the hands. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_swing(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + body.set_combat_mode(TRUE) + count("clicks") + click_wrapper(body, some_target(body)) + +/// The chrome wheel's Use OS chrome, the one wheel path that needs no screen. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_wheel(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/datum/component/chrome_wheel/wheel = get_chrome_wheel(body) + if(!wheel) + return + body.next_click = 0 + count("wheel presses") + wheel.use_os() + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_emp(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + count("body emps") + body.emp_act(prob(50) ? EMP_HEAVY : EMP_LIGHT) + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_emp_one(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/list/installed = get_installed_cyberware(body) + if(!length(installed)) + return + var/obj/item/organ/ware = pick(installed) + count("piece emps") + ware.emp_act(prob(50) ? EMP_HEAVY : EMP_LIGHT) + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_brownout(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/obj/item/organ/cyberimp/cyberware/soak_ballast/ballast = new /obj/item/organ/cyberimp/cyberware/soak_ballast(get_turf(body)) + track(ballast) + if(!ballast.Insert(body, special = TRUE)) + qdel(ballast) + return + count("brownouts") + sleep(rand(3 SECONDS, 9 SECONDS)) + if(QDELETED(ballast)) + return + if(ballast.owner) + ballast.Remove(ballast.owner, special = TRUE) + qdel(ballast) + +/// A cradle visit: lie down, then install something, take something out, or tune up. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_cradle(mob/living/carbon/human/body) + if(!storming || QDELETED(body) || QDELETED(cradle) || cradle_lease > world.time || !isturf(body.loc)) + return + cradle_lease = world.time + 14 SECONDS + body.forceMove(get_turf(cradle)) + if(!cradle.buckle_mob(body, force = TRUE, check_loc = FALSE)) + cradle_lease = 0 + return + var/list/installed = get_installed_cyberware(body) + var/roll = rand(1, 10) + if(roll <= 2) + count("tune-ups") + var/obj/item/card/id/id = body.get_idcard(TRUE) + var/before = id?.registered_account?.account_balance + cradle.try_tune_up(body) + var/after = id?.registered_account?.account_balance + if(!isnull(before) && before != after && before - after != SOAK_TUNEUP_FEE) + note("tune-up charged the wrong fee", "balance went from [before] to [after]") + else if(roll <= 5 && length(installed)) + count("cradle removals") + cradle.begin_removal(pick(installed)) + sleep(SOAK_REMOVAL_TIME + 1 SECONDS) + else + // A used piece from the floor when there is one, otherwise a fresh one. + var/obj/item/organ/ware + if(length(loose_chrome) && prob(50)) + ware = pick(loose_chrome) + loose_chrome -= ware + if(QDELETED(ware)) + ware = null + for(var/attempt in 1 to 8) + var/candidate_type = pick(ware_pool) + var/obj/item/organ/candidate = track(new candidate_type(get_turf(cradle))) + if(cyberware_insert_check(candidate, body, silent = TRUE)) + ware = candidate + break + qdel(candidate) + if(ware) + count("cradle installs") + ware.forceMove(cradle) + cradle.begin_install(ware) + sleep(SOAK_INSTALL_TIME + 1 SECONDS) + if(!QDELETED(body) && body.buckled == cradle) + cradle.unbuckle_mob(body, force = TRUE) + cradle_lease = 0 + +/// A sale at Splice's ledger: pull a credit-priced piece and hand it over. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_sell(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/obj/item/card/id/id = body.get_idcard(TRUE) + if(!id?.registered_account) + return + for(var/obj/item/organ/ware as anything in shuffle(get_installed_cyberware(body))) + for(var/datum/shop_buyback/ledger as anything in ledgers) + if(!ledger.matches(ware)) + continue + ledger.demand = 50 + ware.Remove(body, special = TRUE) + body.put_in_hands(ware) + var/before = id.registered_account.account_balance + var/sold = ledger.try_sell(body, null) + var/gained = id.registered_account.account_balance - before + if(sold) + count("sell-backs") + if(gained != ledger.pay_credits) + note("sell-back paid the wrong amount", "[ware.type] paid [gained], the ledger says [ledger.pay_credits]") + else + if(gained) + note("a refused sell-back still paid", "[ware.type] paid [gained]") + // Not taken: it goes back on the floor for the cradle. + loose_chrome += ware + ware.forceMove(get_turf(body)) + return + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_kill(mob/living/carbon/human/body) + if(!storming || QDELETED(body) || body.stat == DEAD) + return + count("deaths") + body.death() + sleep(rand(2 SECONDS, 9 SECONDS)) + if(QDELETED(body)) + return + body.revive(HEAL_ALL) + count("revives") + +/// Gib or dust a body. Its chrome must come out whole; a fresh body takes its place. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_gib(mob/living/carbon/human/body, dust = FALSE) + if(!storming || QDELETED(body)) + return + var/list/pieces = get_installed_cyberware(body) + // The ballast belongs to its own event, which deletes it when it is done. + for(var/obj/item/organ/ware as anything in pieces.Copy()) + if(istype(ware, /obj/item/organ/cyberimp/cyberware/soak_ballast)) + pieces -= ware + count(dust ? "dustings" : "gibs") + crew -= body + baselines -= body + if(dust) + body.dust() + else + body.gib() + sleep(1 SECONDS) + for(var/obj/item/organ/ware as anything in pieces) + if(QDELETED(ware)) + note("gibbing destroyed a piece of chrome", "[ware.type]") + continue + if(ware.owner) + note("gibbed chrome is still owned by the corpse", "[ware.type]") + continue + if(!isturf(ware.loc)) + note("gibbed chrome did not land on the floor", "[ware.type] is in [ware.loc ? ware.loc.type : "nullspace"]") + continue + count("pieces salvaged") + loose_chrome += ware + spawn_body() + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_dismember(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/obj/item/bodypart/limb = body.get_bodypart(pick(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)) + if(!limb || !limb.dismember()) + return + count("limbs lost") + var/list/riders = list() + for(var/obj/item/organ/ware in limb) + riders += ware + if(prob(40)) + // Burned up on the floor: the chrome has to come out of it. + sleep(1 SECONDS) + qdel(limb) + for(var/obj/item/organ/ware as anything in riders) + if(QDELETED(ware)) + note("destroying a severed limb destroyed its chrome", "[ware.type]") + else if(!isturf(ware.loc)) + note("chrome from a destroyed limb did not land on the floor", "[ware.type] is in [ware.loc ? ware.loc.type : "nullspace"]") + else + loose_chrome += ware + sleep(rand(3 SECONDS, 10 SECONDS)) + if(!QDELETED(body)) + body.regenerate_limbs() + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_stun(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + count("stuns") + switch(rand(1, 3)) + if(1) + body.Paralyze(rand(1 SECONDS, 5 SECONDS)) + if(2) + body.Stun(rand(1 SECONDS, 4 SECONDS)) + if(3) + body.Knockdown(rand(1 SECONDS, 4 SECONDS)) + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_cuff(mob/living/carbon/human/body) + if(!storming || QDELETED(body) || body.handcuffed) + return + var/obj/item/restraints/handcuffs/cuffs = new(body) + body.set_handcuffed(cuffs) + count("cuffings") + sleep(rand(3 SECONDS, 8 SECONDS)) + if(!QDELETED(body) && body.handcuffed == cuffs) + body.set_handcuffed(null) + qdel(cuffs) + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_pacifist(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + // The first two bodies keep it for the whole storm. + if(crew.Find(body) <= 2) + return + if(HAS_TRAIT_FROM(body, TRAIT_PACIFISM, "soak")) + REMOVE_TRAIT(body, TRAIT_PACIFISM, "soak") + else + ADD_TRAIT(body, TRAIT_PACIFISM, "soak") + count("pacifism flips") + +/// Optics zoom. There is no client for tg's scope, so the optics' own half is driven. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_zoom(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/obj/item/organ/eyes/robotic/cyberware/optics = body.get_organ_slot(ORGAN_SLOT_EYES) + if(!istype(optics)) + return + count("zoom flips") + if(optics.is_zoomed()) + optics.stop_zoom(body) + return + var/datum/component/cyberware/chrome = optics.GetComponent(/datum/component/cyberware) + if(chrome?.is_running() && body.stat == CONSCIOUS) + optics.engage_zoom(body) + +/// Damage on a piece until it fails, then it is repaired a moment later. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_damage(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/list/installed = get_installed_cyberware(body) + if(!length(installed)) + return + var/obj/item/organ/ware = pick(installed) + count("damaged pieces") + ware.apply_organ_damage(ware.maxHealth) + sleep(rand(2 SECONDS, 7 SECONDS)) + if(!QDELETED(ware)) + ware.set_organ_damage(0) + +/// A short ride in a mech, with the abilities going the whole time. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_mech(mob/living/carbon/human/body) + if(!storming || QDELETED(body) || mech_lease > world.time || !isturf(body.loc)) + return + mech_lease = world.time + 12 SECONDS + var/obj/vehicle/sealed/mecha/ripley/mech = new /obj/vehicle/sealed/mecha/ripley(get_turf(body)) + track(mech) + if(!mech.mob_enter(body, silent = TRUE)) + qdel(mech) + mech_lease = 0 + return + count("mech rides") + for(var/i in 1 to 4) + sleep(1 SECONDS) + if(QDELETED(body) || body.loc != mech) + break + ev_trigger(body) + ev_swing(body) + if(!QDELETED(body) && body.loc == mech) + mech.mob_exit(body, silent = TRUE) + qdel(mech) + mech_lease = 0 + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_speak(mob/living/carbon/human/body) + // A dead mouth goes to deadchat, which asks for a ckey this test body never has. + if(!storming || QDELETED(body) || body.stat == DEAD) + return + count("lines spoken") + body.say(prob(50) ? ";soak check, over" : "soak check") + +/// Chrome in or out by hand: what an autosurgeon with a context, a surgeon or an admin does. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/ev_swap(mob/living/carbon/human/body) + if(!storming || QDELETED(body)) + return + var/list/installed = get_installed_cyberware(body) + if(length(installed) && prob(50)) + var/obj/item/organ/ware = pick(installed) + ware.Remove(body, special = TRUE) + ware.forceMove(get_turf(body)) + loose_chrome += ware + count("pieces pulled") + return + var/candidate_type = pick(ware_pool) + var/obj/item/organ/ware = track(new candidate_type(get_turf(body))) + if(!body.get_bodypart(deprecise_zone(ware.zone)) || !cyberware_insert_check(ware, body, silent = TRUE) || !ware.Insert(body, special = TRUE)) + qdel(ware) + return + count("pieces slotted") + +/// Keeps the bodies fit enough to keep going without undoing the chrome's own state. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/top_up() + for(var/mob/living/carbon/human/body as anything in crew) + if(QDELETED(body) || body.stat == DEAD) + continue + body.adjustBruteLoss(-60, updating_health = FALSE, forced = TRUE) + body.adjustFireLoss(-60, updating_health = FALSE, forced = TRUE) + body.adjustToxLoss(-30, updating_health = FALSE, forced = TRUE) + body.adjustOxyLoss(-60, updating_health = FALSE, forced = TRUE) + body.updatehealth() + +// ---- The sweep ----------------------------------------------------------- + +/// Checks the ware's own bookkeeping on every body. Each finding has to hold for a while +/// before it counts, because the ware settles itself on SSmobs' two-second tick. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/sweep() + seen_now = list() + for(var/mob/living/carbon/human/body as anything in crew) + if(QDELETED(body)) + continue + var/over = get_chrome_load(body) > get_chrome_capacity(body) + for(var/obj/item/organ/ware as anything in get_installed_cyberware(body)) + var/datum/component/cyberware/chrome = ware.GetComponent(/datum/component/cyberware) + if(!chrome) + continue + var/ware_ref = REF(ware) + if(ware.owner != body) + suspect("[ware_ref]|owner", "installed chrome whose owner is not its bearer", "[ware.type] owner [ware.owner || "none"] in [body]") + var/running = !!chrome.is_running() + if(!!chrome.passives_online != running) + suspect("[ware_ref]|passives", "passive layer out of step with the ware", "[ware.type] passives_online [chrome.passives_online], running [running] (emp [chrome.emp_down], brownout [chrome.browned_out], damage [ware.damage]/[ware.maxHealth], flags [ware.organ_flags])") + if(!!chrome.browned_out != over) + suspect("[ware_ref]|brownout", "brownout flag out of step with the body's load", "[ware.type] browned_out [chrome.browned_out], load [get_chrome_load(body)] of [get_chrome_capacity(body)]") + if(chrome.emp_down && !chrome.emp_timer) + suspect("[ware_ref]|emptimer", "EMP downtime with no reboot timer", "[ware.type]") + // A reboot always ends on its timer (a missing one is caught just above), but EMPs + // landing back to back can keep a piece down across sweeps. Only a timer set further + // out than any EMP's downtime is an outage that would not end. + if(chrome.emp_down && chrome.emp_timer && timeleft(chrome.emp_timer) > SOAK_EMP_DOWNTIME) + suspect("[ware_ref]|empstuck", "EMP downtime that never ended", "[ware.type] still down", SOAK_EMP_DOWNTIME) + if(istype(ware, /obj/item/organ/cyberimp/arm/toolkit/cyberware)) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/arm = ware + if(arm.active_item && !running && arm.active_item.loc == body) + suspect("[ware_ref]|armweapon", "arm weapon deployed on offline chrome", "[ware.type] holding [arm.active_item.type]") + if(HAS_TRAIT(body, SOAK_TRAIT_ZOOMED)) + var/obj/item/organ/eyes/robotic/cyberware/optics = body.get_organ_slot(ORGAN_SLOT_EYES) + var/datum/component/cyberware/optic_chrome = istype(optics) ? optics.GetComponent(/datum/component/cyberware) : null + if(!istype(optics) || !optics.is_zoomed()) + suspect("[REF(body)]|zoomtrait", "zoom trait with no zoomed optics behind it", "[body]") + else if(!optic_chrome?.is_running()) + suspect("[REF(body)]|zoomoffline", "zoom held open on offline optics", "[optics.type]") + else if(body.stat != CONSCIOUS) + suspect("[REF(body)]|zoomstat", "zoom held open on a body that is not awake", "[body] stat [body.stat]") + if(HAS_TRAIT(body, SOAK_TRAIT_CAMO)) + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = body.get_organ_slot(SOAK_SLOT_SKIN) + var/datum/component/cyberware/weave_chrome = istype(weave) ? weave.GetComponent(/datum/component/cyberware) : null + if(!istype(weave) || !weave.camo_active) + suspect("[REF(body)]|camotrait", "camo trait with no engaged weave behind it", "[body]") + else if(!weave_chrome?.is_running()) + suspect("[REF(body)]|camooffline", "camo held on an offline weave", "[weave.type]") + for(var/key in suspects.Copy()) + if(!seen_now[key]) + suspects -= key + reported -= key + +// ---- The audit ----------------------------------------------------------- + +/// Heal the survivors, take all their chrome out, leave them alone and compare with the +/// snapshot from before they had any. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/audit_survivors() + var/list/survivors = list() + for(var/mob/living/carbon/human/body as anything in crew) + if(QDELETED(body) || !baselines[body]) + continue + survivors += body + body.drop_all_held_items() + body.forceMove(run_loc_floor_bottom_left) + body.set_handcuffed(null) + REMOVE_TRAIT(body, TRAIT_PACIFISM, "soak") + body.revive(ADMIN_HEAL_ALL) + body.regenerate_limbs() + var/index = 0 + for(var/obj/item/organ/ware as anything in get_installed_cyberware(body)) + index++ + // Half through the normal removal, half the way a dying body does it. + ware.Remove(body, special = (index % 2 == 0)) + ware.forceMove(get_turf(body)) + loose_chrome += ware + if(get_chrome_load(body) != 0) + note("a body still carries load with no chrome in it", "[body] carries [get_chrome_load(body)]") + // Chrome optics and lungs replaced the body's own, so pulling them leaves gaps a + // body without chrome never had (no eyes means blind). + body.dna.species.regenerate_organs(body, replace_current = FALSE) + log_world("SOAK auditing [length(survivors)] survivors after a 20 second quiet") + sleep(20 SECONDS) + for(var/mob/living/carbon/human/body as anything in survivors) + if(QDELETED(body)) + continue + var/list/before = baselines[body] + var/list/now = snapshot(body) + for(var/key in before) + var/old_value = before[key] + var/new_value = now[key] + if(islist(old_value)) + var/list/old_list = old_value + var/list/new_list = new_value + var/list/gained = list() + var/list/lost = list() + if(key == "traits" || key == "physiology") + for(var/entry in new_list) + if(new_list[entry] != old_list[entry]) + gained += "[entry] [old_list[entry]] -> [new_list[entry]]" + for(var/entry in old_list) + if(isnull(new_list[entry])) + lost += "[entry]" + else + var/list/remaining = old_list.Copy() + for(var/entry in new_list) + if(entry in remaining) + remaining -= entry + else + gained += "[entry]" + lost = remaining + if(length(gained) || length(lost)) + // The chrome wheel is made on first use and kept for the body's life. + if(key == "components") + gained -= "[/datum/component/chrome_wheel]" + // A baseline taken mid-fight can hold a passing effect (a stagger); only + // what was ADDED by the chrome and never left counts for these. + if(key == "status effects" || key == "movespeed" || key == "actionspeed") + lost = list() + if(length(gained) || length(lost)) + note("after stripping the chrome, [key] differ from before it", "[body]: gained [english_list(gained)], lost [english_list(lost)]") + else if(old_value != new_value) + note("after stripping the chrome, [key] differs from before it", "[body]: was [old_value], now [new_value]") + for(var/stale in voidcrew_cyberware_stale_listeners(body)) + note("a stripped body still has chrome listening to it", "[body]: [stale]") + +/// Delete everything this test made, wait for the garbage collector, and return what survived. +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/clean_up() + // The cradle's own loose ends first. + var/tray_strays = 0 + if(!QDELETED(cradle)) + if(cradle.busy) + note("the cradle ended the soak mid-sequence", "[cradle.busy_action]") + list_clear_nulls(cradle.tray) + for(var/obj/item/organ/stray in cradle.tray) + if(QDELETED(stray)) + tray_strays++ + if(tray_strays) + note("the cradle's tray holds deleted chrome", "[tray_strays] pieces") + crew.Cut() + baselines.Cut() + loose_chrome.Cut() + suspects.Cut() + reported.Cut() + seen_now.Cut() + // The cradle first, because its tray empties onto the floor when it goes. + qdel(cradle) + cradle = null + // Everything in the room goes, bodies and chrome and gibs. Twice: the first pass can drop + // things (a dead body's pockets, a limb's chrome) that the second one picks up. + for(var/pass in 1 to 2) + for(var/turf/where as anything in floor_turfs + run_loc_floor_top_right) + for(var/atom/movable/thing as anything in where.contents.Copy()) + if(istype(thing, /obj/effect/landmark)) + continue + qdel(thing) + floor_turfs.Cut() + ledgers.Cut() + // Past the longest queue the collector has, plus a margin. + sleep(45 SECONDS) + var/list/leaks = list() + for(var/datum/weakref/ref as anything in made) + var/datum/survivor = ref.resolve() + if(survivor) + leaks["[survivor.type]"] = (leaks["[survivor.type]"] || 0) + 1 + made.Cut() + // Anything that ran out of patience with the collector is counted per type. + for(var/gc_type in SSgarbage.items) + var/datum/qdel_item/item = SSgarbage.items[gc_type] + var/list/before = gc_before[gc_type] || list(0, 0) + if(item.failures > before[1] || item.hard_deletes > before[2]) + var/path_text = "[gc_type]" + if(findtext(path_text, "cyberware") || findtext(path_text, "chrome") || findtext(path_text, "/mob/living/carbon/human") || findtext(path_text, "shop_buyback")) + leaks["GC [path_text]: [item.failures - before[1]] failures, [item.hard_deletes - before[2]] hard deletes"] = 1 + // A timer pointing at an object that is already gone should not exist. + var/orphaned = 0 + for(var/timer_id in SStimer.timer_id_dict) + var/datum/timedevent/timer = SStimer.timer_id_dict[timer_id] + var/datum/object = timer?.callBack?.object + if(isdatum(object) && QDELETED(object)) + orphaned++ + if(orphaned) + leaks["timers aimed at deleted objects"] = orphaned + stats["timers before"] = timers_at_start + stats["timers after"] = length(SStimer.timer_id_dict) + return leaks + +/datum/unit_test/voidcrew_opt_in/cyberware_soak/proc/report(list/leaks) + var/list/lines = list() + lines += "CHROME SOAK REPORT" + lines += "storm length [storm_length / 10] s, [crew_size] bodies, [length(ware_pool)] kinds of chrome in the pool" + lines += "runtimes during the soak: [GLOB.total_runtimes - runtimes_at_start] (plus [GLOB.total_runtimes_skipped - skipped_runtimes_at_start] silenced as repeats)" + lines += "-- what was done" + for(var/what in stats) + lines += " [what]: [stats[what]]" + lines += "-- problems ([length(problem_counts)] kinds)" + for(var/category in problem_counts) + lines += " [category] x[problem_counts[category]]: [problem_examples[category]]" + lines += "-- left behind ([length(leaks)] kinds)" + for(var/leak in leaks) + lines += " [leak]: [leaks[leak]]" + var/text = lines.Join("\n") + fdel("data/soak_report.txt") + text2file(text, "data/soak_report.txt") + log_world(text) + for(var/category in problem_counts) + Fail("[category] (x[problem_counts[category]]): [problem_examples[category]]") + for(var/leak in leaks) + Fail("left behind: [leak]: [leaks[leak]]") + +#undef SOAK_SLOT_SKIN +#undef SOAK_TRAIT_CAMO +#undef SOAK_TRAIT_ZOOMED +#undef SOAK_INSTALL_TIME +#undef SOAK_REMOVAL_TIME +#undef SOAK_EMP_DOWNTIME +#undef SOAK_TUNEUP_FEE +#undef SOAK_PATIENCE diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_text.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_text.dm new file mode 100644 index 00000000000..d6b60288c15 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_text.dm @@ -0,0 +1,20 @@ +/** + * # Cyberware text + * + * Wares are described the way a person in the world would describe them: no figures and no talk + * of load, tiers, slots or EMPs. Ability buttons are the one place numbers belong, so they are not + * checked here. + */ +/datum/unit_test/voidcrew_cyberware_text + +/datum/unit_test/voidcrew_cyberware_text/Run() + var/list/roots = list( + /obj/item/organ/cyberimp/cyberware, + /obj/item/organ/eyes/robotic/cyberware, + /obj/item/organ/cyberimp/arm/toolkit/cyberware, + ) + for(var/root in roots) + for(var/obj/item/organ/ware_path as anything in typesof(root)) + var/ware_desc = initial(ware_path.desc) + TEST_ASSERT(!findtext(ware_desc, regex("\[0-9]")), "[ware_path]'s description has a figure in it: [ware_desc]") + TEST_ASSERT(!findtext(ware_desc, regex("\b(tier|load|slot|EMP)\b", "i")), "[ware_path]'s description talks about game rules: [ware_desc]") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_widowline.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_widowline.dm new file mode 100644 index 00000000000..12c7f7516df --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_widowline.dm @@ -0,0 +1,1015 @@ +/** + * The Widowline monowire against the gore layer (voidcrew/modules/hyperviolence/wire/): clean severs and their + * thresholds, the crossing cut, the Arc's seared stumps, the delayed cut's held limb, the through-cut, blood on + * the wire, the swing out of the spool and back, the garrote, and the sleeve mask on every stump. + * + * Fork defines are included after the tests, so these use literals, each with a comment naming the define. + * Cuts are driven through the wire's own hooks (wire_cut_begin(), apply_damage(), wire_cut_end()) so the zone + * they land on is not left to tg's 80% aim roll. + */ + +/// Shared helpers; not a test itself +/datum/unit_test/voidcrew_widowline + abstract_type = /datum/unit_test/voidcrew_widowline + +/// The floor `dx`, `dy` tiles from the test room's bottom-left corner +/datum/unit_test/voidcrew_widowline/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +/// A human holding a wire of `wire_type` in the active hand +/datum/unit_test/voidcrew_widowline/proc/wielder(turf/where, wire_type = /obj/item/melee/cyberware_monowire) + var/mob/living/carbon/human/consistent/user = allocate(/mob/living/carbon/human/consistent, where) + var/obj/item/melee/cyberware_monowire/wire = allocate(wire_type) + TEST_ASSERT(user.put_in_active_hand(wire), "Fixture: the wielder couldn't hold the wire") + user.set_combat_mode(TRUE) + return user + +/// The wire in `user`'s active hand +/datum/unit_test/voidcrew_widowline/proc/held(mob/living/user) + return user.get_active_held_item() + +/// One cut of `wire` held by `user` into `victim`'s `zone`, aimed there, for the wire's force. Returns the damage dealt. +/datum/unit_test/voidcrew_widowline/proc/cut(mob/living/user, mob/living/victim, zone, aim = zone) + var/obj/item/melee/cyberware_monowire/wire = held(user) + user.zone_selected = aim + wire.wire_cut_begin(victim, user) + . = victim.apply_damage(wire.force, BRUTE, zone, 0, wound_bonus = CANT_WOUND, sharpness = SHARP_EDGED, attack_direction = get_dir(user, victim), attacking_item = wire) + wire.wire_cut_end(victim) + +/// The texts queued on `victim`'s hit, joined +/datum/unit_test/voidcrew_widowline/proc/lines(mob/living/victim) + . = "" + for(var/list/line as anything in victim.hv_hit?.lines) + . += "[line[1]] | " + +/// Flying hitsplatter near `where` +/datum/unit_test/voidcrew_widowline/proc/splatter(atom/where) + . = 0 + for(var/obj/effect/decal/cleanable/blood/hitsplatter/splatter in range(6, where)) + .++ + +/// The held limb (wire_ghost) drawn on `victim`, if any +/datum/unit_test/voidcrew_widowline/proc/get_ghost(mob/living/victim) + for(var/obj/effect/abstract/cyberware_anim/wire_ghost/ghost in victim.vis_contents) + return ghost + +/// When a limb comes off: only an aimed cut on an arm or leg already hurt enough, never a fresh limb, a corpse, +/// an Atlas frame, the head or chest; downed bodies at a lower threshold. Off clean: dropped at the body, no fan. +/datum/unit_test/voidcrew_widowline/wire_sever + +/datum/unit_test/voidcrew_widowline/wire_sever/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + + // A fresh arm takes the cut and stays on. + cut(user, victim, BODY_ZONE_L_ARM) + TEST_ASSERT_NOTNULL(victim.get_bodypart(BODY_ZONE_L_ARM), "A fresh arm came off the first wire cut") + // Not aimed there: never, however hurt. + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, victim, BODY_ZONE_L_ARM, aim = BODY_ZONE_CHEST) + TEST_ASSERT_NOTNULL(victim.get_bodypart(BODY_ZONE_L_ARM), "An arm came off a cut aimed elsewhere") + + // Aimed at a badly hurt arm (60%, WIRE_SEVER_AT): off, clean. + var/obj/item/bodypart/right = victim.get_bodypart(BODY_ZONE_R_ARM) + right.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + var/before = splatter(victim) + cut(user, victim, BODY_ZONE_R_ARM) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_R_ARM), "An aimed cut didn't take off an arm at 60%") + TEST_ASSERT_EQUAL(right.loc, get_turf(victim), "The severed arm was flung instead of dropping at the body") + TEST_ASSERT_EQUAL(right.dir, victim.dir, "The severed arm lies facing another way than it hung") + + // In profile: the near limb keeps the body's facing and lies down by the feet; the far arm lies as the near one would. + var/mob/living/carbon/human/consistent/profile = allocate(/mob/living/carbon/human/consistent, spot(2, 3)) + profile.setDir(EAST) + arm = profile.get_bodypart(BODY_ZONE_R_LEG) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, profile, BODY_ZONE_R_LEG) + TEST_ASSERT_NULL(profile.get_bodypart(BODY_ZONE_R_LEG), "Fixture: the leg didn't come off") + TEST_ASSERT_EQUAL(arm.dir, EAST, "A leg cut from a body facing east doesn't lie facing east") + TEST_ASSERT(abs(arm.transform.a) < 0.1 && arm.transform.f < -4, "The cut leg doesn't lie on the floor ([arm.transform.a], [arm.transform.f])") + arm = profile.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + profile.setDir(EAST) + cut(user, profile, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(profile.get_bodypart(BODY_ZONE_L_ARM), "Fixture: the far arm didn't come off") + TEST_ASSERT_EQUAL(arm.dir, WEST, "The far arm cut in profile isn't drawn as the near arm") + TEST_ASSERT(abs(arm.transform.a) < 0.1, "The far arm cut in profile doesn't lie down") + TEST_ASSERT_EQUAL(splatter(victim), before, "A wire sever threw tg's flying hitsplatter") + TEST_ASSERT(findtext(lines(victim), "comes away clean"), "The sever's line didn't join the hit: [lines(victim)]") + TEST_ASSERT(!HAS_TRAIT(victim, "hv_clean_cut"), "TRAIT_HV_CLEAN_CUT outlived the cut") + + // Head and chest never, even hurt enough on someone down. + var/mob/living/carbon/human/consistent/stunned = allocate(/mob/living/carbon/human/consistent, spot(3, 3)) + stunned.Paralyze(100 SECONDS) + var/obj/item/bodypart/head = stunned.get_bodypart(BODY_ZONE_HEAD) + head.receive_damage(brute = 60, wound_bonus = CANT_WOUND) + var/obj/item/bodypart/chest = stunned.get_bodypart(BODY_ZONE_CHEST) + chest.receive_damage(brute = 60, wound_bonus = CANT_WOUND) + var/mob/living/carbon/human/attacker = wielder(spot(3, 2)) + cut(attacker, stunned, BODY_ZONE_HEAD) + TEST_ASSERT_NOTNULL(stunned.get_bodypart(BODY_ZONE_HEAD), "A wire cut took a head off") + cut(attacker, stunned, BODY_ZONE_CHEST) + TEST_ASSERT_NOTNULL(stunned.get_bodypart(BODY_ZONE_CHEST), "A wire cut took a chest off") + + // Down: a fifth is enough (WIRE_SEVER_AT_DOWN); less isn't. + var/mob/living/carbon/human/consistent/downed = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + downed.Paralyze(100 SECONDS) + var/obj/item/bodypart/leg = downed.get_bodypart(BODY_ZONE_L_LEG) + leg.receive_damage(brute = 5, wound_bonus = CANT_WOUND) + cut(user, downed, BODY_ZONE_L_LEG) + TEST_ASSERT_NOTNULL(downed.get_bodypart(BODY_ZONE_L_LEG), "A leg on someone down came off at 10%") + cut(user, downed, BODY_ZONE_L_LEG) + TEST_ASSERT_NULL(downed.get_bodypart(BODY_ZONE_L_LEG), "A leg on someone down didn't come off past 20%") + + // A corpse keeps its limbs. + var/mob/living/carbon/human/consistent/corpse = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + arm = corpse.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 45, wound_bonus = CANT_WOUND) + corpse.death() + cut(user, corpse, BODY_ZONE_L_ARM) + TEST_ASSERT_NOTNULL(corpse.get_bodypart(BODY_ZONE_L_ARM), "A wire cut took an arm off a corpse") + + // An Atlas frame keeps its limbs. + var/mob/living/carbon/human/consistent/framed = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + ADD_TRAIT(framed, TRAIT_NODISMEMBER, TRAIT_SOURCE_UNIT_TESTS) + arm = framed.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 45, wound_bonus = CANT_WOUND) + cut(user, framed, BODY_ZONE_L_ARM) + TEST_ASSERT_NOTNULL(framed.get_bodypart(BODY_ZONE_L_ARM), "A wire cut took an arm off through an Atlas frame") + +/// Mid wire cut tg's own roll never flings a limb: the wire takes it off clean after the hit. +/datum/unit_test/voidcrew_widowline/hv_wire_owed_sever + +/datum/unit_test/voidcrew_widowline/hv_wire_owed_sever/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + ADD_TRAIT(victim, "hv_clean_cut", TRAIT_SOURCE_UNIT_TESTS) // TRAIT_HV_CLEAN_CUT + var/datum/wound/loss/torn = new + torn.apply_dismember(arm, WOUND_SLASH) + REMOVE_TRAIT(victim, "hv_clean_cut", TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT_EQUAL(arm.owner, victim, "tg tore an arm off mid wire cut") + TEST_ASSERT_EQUAL(victim.hv_wire_owed_sever, arm, "The arm tg wanted wasn't left for the wire") + victim.hv_wire_owed_sever = null + + // Through the wire's own hook it comes off, though the arm was fresh and the cut aimed elsewhere. + var/obj/item/melee/cyberware_monowire/wire = held(user) + user.zone_selected = BODY_ZONE_CHEST + wire.wire_cut_begin(victim, user) + torn = new + torn.apply_dismember(arm, WOUND_SLASH) + victim.apply_damage(wire.force, BRUTE, BODY_ZONE_CHEST, 0, wound_bonus = CANT_WOUND, sharpness = SHARP_EDGED, attack_direction = EAST, attacking_item = wire) + wire.wire_cut_end(victim) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_L_ARM), "The wire didn't take the arm tg's roll wanted") + TEST_ASSERT_EQUAL(arm.loc, get_turf(victim), "The owed arm was flung") + + // A clean cut throws no hitsplatter; without it tg's does. + var/before = splatter(victim) + ADD_TRAIT(victim, "hv_clean_cut", TRAIT_SOURCE_UNIT_TESTS) + victim.spray_blood(EAST, 3) + TEST_ASSERT_EQUAL(splatter(victim), before, "spray_blood() threw hitsplatter during a clean cut") + REMOVE_TRAIT(victim, "hv_clean_cut", TRAIT_SOURCE_UNIT_TESTS) + victim.spray_blood(EAST, 3) + TEST_ASSERT(splatter(victim) > before, "spray_blood() is dead outside a clean cut") + +/// With a wire out in each hand every third landed hit crosses: both wires lash out, and a sever at half the damage. +/datum/unit_test/voidcrew_widowline/crossing + +/datum/unit_test/voidcrew_widowline/crossing/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 15, wound_bonus = CANT_WOUND) + + // One wire: 30% isn't enough, every time. + for(var/i in 1 to 3) + cut(user, victim, BODY_ZONE_CHEST) + cut(user, victim, BODY_ZONE_L_ARM) + TEST_ASSERT_NOTNULL(victim.get_bodypart(BODY_ZONE_L_ARM), "One wire took an arm at 30%") + TEST_ASSERT_EQUAL(user.wire_cross_hits, 0, "One wire counted toward a crossing cut") + victim.fully_heal(HEAL_DAMAGE) + arm = victim.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 15, wound_bonus = CANT_WOUND) + + // Two wires: the third landed hit crosses. + var/obj/item/melee/cyberware_monowire/second = allocate(/obj/item/melee/cyberware_monowire) + TEST_ASSERT(user.put_in_inactive_hand(second), "Fixture: no second hand for the second wire") + cut(user, victim, BODY_ZONE_CHEST) + cut(user, victim, BODY_ZONE_CHEST) + var/obj/item/melee/cyberware_monowire/wire = held(user) + TEST_ASSERT(wire.wire_cross_due(user), "The third hit with two wires out isn't the crossing one") + for(var/obj/effect/abstract/wire_reach/old_lash in get_turf(user)) + qdel(old_lash) + cut(user, victim, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_L_ARM), "The crossing cut didn't take an arm at 30%") + // The other hand's wire lashes out too, a beat later; nothing is drawn over the target. + sleep(0.2 SECONDS) + TEST_ASSERT(locate(/obj/effect/abstract/wire_reach) in get_turf(user), "The crossing cut didn't lash the other wire") + // The arm's own sever seam (wire_sever_fx.dm) shows on the body; the old crossing X must not. + for(var/obj/effect/abstract/cyberware_anim/drawn in victim.vis_contents) + TEST_ASSERT(!findtext(drawn.icon_state, "cross"), "The crossing cut drew over its target ([drawn.icon_state])") + TEST_ASSERT_EQUAL(user.wire_cross_hits, 0, "The count didn't start again after the crossing cut") + + // Hits too far apart start the count again. + cut(user, victim, BODY_ZONE_CHEST) + cut(user, victim, BODY_ZONE_CHEST) + user.wire_cross_last -= 10 SECONDS + TEST_ASSERT(!wire.wire_cross_due(user), "Hits seconds apart still cross") + + // The entry point with no mouse behind it: a crossing swing on demand, the target doll left as it was. + for(var/obj/effect/abstract/wire_reach/old_lash in get_turf(user)) + qdel(old_lash) + user.zone_selected = BODY_ZONE_HEAD + TEST_ASSERT(wire.wire_crossing_swing(user, victim, BODY_ZONE_CHEST), "wire_crossing_swing() didn't swing") + sleep(0.2 SECONDS) // the other hand's wire lashes out a beat later, as above + var/lashes = 0 + for(var/obj/effect/abstract/wire_reach/lash in get_turf(user)) + lashes++ + TEST_ASSERT(lashes >= 2, "wire_crossing_swing() didn't cross: [lashes] lash(es)") + TEST_ASSERT_EQUAL(user.zone_selected, BODY_ZONE_HEAD, "An aimed swing left the wielder's target doll changed") + TEST_ASSERT(!wire.force_cross, "A crossing swing left the next one crossing too") + +/// The Arc sears the stump: little blood, the stump drawn charred; not on a body its shock can't reach. +/datum/unit_test/voidcrew_widowline/wire_sears + +/datum/unit_test/voidcrew_widowline/wire_sears/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/attacker = wielder(spot(0, 3), /obj/item/melee/cyberware_monowire/live) + + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + var/blood_before = victim.blood_volume + cut(user, victim, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_L_ARM), "Fixture: the plain wire didn't sever") + TEST_ASSERT(blood_before - victim.blood_volume >= 40, "A plain sever lost too little blood ([blood_before - victim.blood_volume])") + TEST_ASSERT(!LAZYACCESS(victim.hv_stump_burnt, BODY_ZONE_L_ARM), "The plain wire seared a stump") + + var/mob/living/carbon/human/consistent/body = allocate(/mob/living/carbon/human/consistent, spot(1, 3)) + arm = body.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + blood_before = body.blood_volume + cut(attacker, body, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(body.get_bodypart(BODY_ZONE_L_ARM), "The Arc didn't sever") + TEST_ASSERT(blood_before - body.blood_volume <= 20, "A seared sever lost as much blood as a wet one ([blood_before - body.blood_volume])") + TEST_ASSERT(LAZYACCESS(body.hv_stump_burnt, BODY_ZONE_L_ARM), "The Arc's stump isn't seared") + TEST_ASSERT(findtext(lines(body), "seared shut"), "The seared sever's line is missing: [lines(body)]") + body.hv_reveal_stump(BODY_ZONE_L_ARM) + var/charred = FALSE + for(var/image/gore_image as anything in body.hv_gore_overlays) + if(gore_image.icon_state == "stump_l_arm_blood" && gore_image.color == "#2a1b15") // WIRE_BURNT_STUMP_COLOR + charred = TRUE + TEST_ASSERT(charred, "The seared stump isn't drawn charred") + // A limb back on forgets the sear. + body.regenerate_limb(BODY_ZONE_L_ARM) + body.update_damage_overlays() + TEST_ASSERT(!LAZYACCESS(body.hv_stump_burnt, BODY_ZONE_L_ARM), "A new arm kept the old stump's sear") + + // Shock-immune: a plain wet sever. + var/mob/living/carbon/human/consistent/grounded = allocate(/mob/living/carbon/human/consistent, spot(2, 3)) + ADD_TRAIT(grounded, TRAIT_SHOCKIMMUNE, TRAIT_SOURCE_UNIT_TESTS) + arm = grounded.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(attacker, grounded, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(grounded.get_bodypart(BODY_ZONE_L_ARM), "The Arc didn't sever a shock-immune arm") + TEST_ASSERT(!LAZYACCESS(grounded.hv_stump_burnt, BODY_ZONE_L_ARM), "The Arc seared a stump its shock can't reach") + +/// The delayed cut: the limb stays drawn on, its stump held back, until it slides; nothing lingers after, and a +/// body deleted, restored or carried off mid-beat takes the picture with it. +/datum/unit_test/voidcrew_widowline/wire_ghost + +/datum/unit_test/voidcrew_widowline/wire_ghost/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, victim, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_L_ARM), "Fixture: the arm didn't come off") + var/obj/effect/abstract/cyberware_anim/wire_ghost/ghost = get_ghost(victim) + TEST_ASSERT_NOTNULL(ghost, "The severed arm isn't held on its body for the beat") + TEST_ASSERT(length(ghost.overlays), "The held arm draws nothing") + TEST_ASSERT(!("stump_l_arm_blood" in victim.hv_gore_states()), "The stump shows while the arm is still drawn on") + TEST_ASSERT_EQUAL(arm.alpha, 255, "The severed arm on the floor isn't really there yet (server alpha)") + ghost.slide() + TEST_ASSERT(("stump_l_arm_blood" in victim.hv_gore_states()), "The stump didn't show when the arm slid off") + sleep(1 SECONDS) + TEST_ASSERT_NULL(get_ghost(victim), "The held arm lingered after it slid off") + + // The body deleted mid-beat. + var/mob/living/carbon/human/consistent/doomed = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + arm = doomed.get_bodypart(BODY_ZONE_R_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, doomed, BODY_ZONE_R_ARM) + ghost = get_ghost(doomed) + TEST_ASSERT_NOTNULL(ghost, "Fixture: no held arm on the doomed body") + qdel(doomed) + TEST_ASSERT(QDELETED(ghost), "The held arm outlived its body") + + // The limb back on mid-beat: the picture just goes. + var/mob/living/carbon/human/consistent/healed = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + arm = healed.get_bodypart(BODY_ZONE_R_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, healed, BODY_ZONE_R_ARM) + ghost = get_ghost(healed) + healed.regenerate_limb(BODY_ZONE_R_ARM) + ghost.slide() + TEST_ASSERT(!LAZYACCESS(healed.hv_stump_reveal_at, BODY_ZONE_R_ARM), "A restored arm left its stump held back") + sleep(0.3 SECONDS) + TEST_ASSERT_NULL(get_ghost(healed), "The held arm stayed on a body whose arm grew back") + + // Death mid-beat: it still never outlives the hard timer. + var/mob/living/carbon/human/consistent/dying = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + arm = dying.get_bodypart(BODY_ZONE_L_LEG) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, dying, BODY_ZONE_L_LEG) + TEST_ASSERT_NOTNULL(get_ghost(dying), "Fixture: no held leg") + dying.death() + sleep(1.5 SECONDS) + TEST_ASSERT_NULL(get_ghost(dying), "The held leg outlived its beat on a body that died") + +/// The wire carries on into the one body right behind the target, as a line of the one hit, and nobody beside it. +/// The body behind never loses a limb to it. +/datum/unit_test/voidcrew_widowline/wire_cleave + +/datum/unit_test/voidcrew_widowline/wire_cleave/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/mob/living/carbon/human/consistent/behind = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + var/mob/living/carbon/human/consistent/beside = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + // A limb tg's wound roll wanted off the body behind stays on. + var/obj/item/bodypart/arm = behind.get_bodypart(BODY_ZONE_L_ARM) + behind.hv_wire_owed_sever = arm + wire.wire_cleave(target, user) + TEST_ASSERT(behind.getBruteLoss() > 0, "The mob behind the target took no cut") + TEST_ASSERT_EQUAL(beside.getBruteLoss() + beside.getFireLoss(), 0, "The mob beside the target was cut") + TEST_ASSERT_EQUAL(behind.get_bodypart(BODY_ZONE_L_ARM), arm, "The body behind the target lost a limb") + TEST_ASSERT_NULL(behind.hv_wire_owed_sever, "The body behind the target is still owed a sever") + TEST_ASSERT_EQUAL(wire.lash_through?.resolve(), behind, "The body behind was cut with no line to it") + var/result = lines(target) + TEST_ASSERT(findtext(result, "carries through into [behind]"), "The through-cut's line didn't join the hit: [result]") + TEST_ASSERT(!findtext(result, "sings through"), "The old cleave's line joined the hit: [result]") + TEST_ASSERT_NULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/streak) in get_turf(behind), "The through-cut laid a streak on the floor") + TEST_ASSERT_NULL(locate(/obj/effect/ebeam) in range(3, target), "The through-cut drew a beam of its own") + TEST_ASSERT(!HAS_TRAIT(behind, "hv_clean_cut"), "TRAIT_HV_CLEAN_CUT outlived the cleave") + wire.lash_through = null + + // A real swing does all of it in one message. + target.hv_flush_hit() + behind.fully_heal(HEAL_DAMAGE) + user.zone_selected = BODY_ZONE_CHEST + wire.melee_attack_chain(user, target) + TEST_ASSERT(target.getBruteLoss() > 0, "The swing didn't land") + TEST_ASSERT(behind.getBruteLoss() > 0, "A landed swing didn't carry through") + TEST_ASSERT_EQUAL(beside.getBruteLoss() + beside.getFireLoss(), 0, "A landed swing cut the mob beside the target") + // The swing's one lash runs on to the body behind and ends there; it goes into the first body over it and comes + // out under it. + var/obj/effect/abstract/wire_reach/lash_end = locate() in get_turf(behind) + TEST_ASSERT_NOTNULL(lash_end, "The lash of a through-cut stopped short of the body behind") + TEST_ASSERT_EQUAL(lash_end.icon_state, wire.lash_state(), "The lash of a through-cut has no bright end on the body behind") + // Each body's drops leave from where that line cuts it: level with the first body's chest as it passes, and in the + // middle of the chest of the body behind, where it ends. + var/list/cuts = wire.wire_through_cuts(user, target, behind) + TEST_ASSERT_NOTNULL(cuts, "No line runs from the wielder through two bodies in a row") + var/list/passed = cuts[1] + var/list/chest = wire_zone_point(target, BODY_ZONE_CHEST) + TEST_ASSERT(abs(passed[1] - chest[1]) <= 1 && abs(passed[2] - chest[2]) <= 8, "The through-cut's line passes the first body away from its chest: [passed[1]], [passed[2]]") + var/list/ended = cuts[2] + var/list/end = wire_zone_point(behind, BODY_ZONE_CHEST) + TEST_ASSERT(ended[1] == end[1] && ended[2] == end[2], "The through-cut's line doesn't end in the middle of the chest of the body behind") + var/over = 0 + var/under = 0 + for(var/obj/effect/abstract/wire_reach/piece in get_turf(target)) + if(piece.layer == ABOVE_MOB_LAYER) + over++ + else if(piece.layer == BELOW_MOB_LAYER) + under++ + TEST_ASSERT(over == 1 && under == 1, "The lash of a through-cut should cross the first body in two pieces, over it then under it: [over] over, [under] under") + + // Two bodies behind: the wire carries into one of them. + target.hv_flush_hit() + behind.fully_heal(HEAL_DAMAGE) + var/mob/living/carbon/human/consistent/also_behind = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + wire.wire_cleave(target, user) + var/hurt = (behind.getBruteLoss() > 0) + (also_behind.getBruteLoss() > 0) + TEST_ASSERT_EQUAL(hurt, 1, "A swing carried into [hurt] bodies behind its target") + wire.lash_through = null + +/// The wire carries into nobody when no line runs from the hand through the target to the body behind: the wielder on +/// the target's tile, or a swing at a knight's move. The garrote's own blow never carries through either. +/datum/unit_test/voidcrew_widowline/wire_cleave_no_line + +/datum/unit_test/voidcrew_widowline/wire_cleave_no_line/Run() + // On the target's tile, facing the body behind. + var/mob/living/carbon/human/user = wielder(spot(1, 1)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/mob/living/carbon/human/consistent/behind = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + user.setDir(EAST) + wire.wire_cleave(target, user) + TEST_ASSERT_EQUAL(behind.getBruteLoss() + behind.getFireLoss(), 0, "A swing from the target's own tile cut the body beside it") + TEST_ASSERT_NULL(wire.lash_through, "A swing from the target's own tile carried through") + TEST_ASSERT(!findtext(lines(target), "carries through"), "A swing from the target's own tile said it carried through") + + // A reach-two swing at a knight's move: the tile past the target along it holds a body, but no line runs to it. + var/mob/living/carbon/human/far_user = wielder(spot(0, 0)) + var/obj/item/melee/cyberware_monowire/far_wire = held(far_user) + var/mob/living/carbon/human/consistent/far_target = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + var/mob/living/carbon/human/consistent/far_behind = allocate(/mob/living/carbon/human/consistent, spot(2, 3)) + TEST_ASSERT_EQUAL(get_step(far_target, get_dir(far_user, far_target)), get_turf(far_behind), "Fixture: the body isn't on the tile past the target") + TEST_ASSERT_NULL(far_wire.wire_through_line(far_user, far_target, far_behind), "A line runs through a knight's move") + far_wire.wire_cleave(far_target, far_user) + TEST_ASSERT_EQUAL(far_behind.getBruteLoss() + far_behind.getFireLoss(), 0, "A swing at a knight's move cut the body past its target") + TEST_ASSERT_EQUAL(behind.getBruteLoss() + behind.getFireLoss(), 0, "A swing at a knight's move cut a body beside its target") + TEST_ASSERT_NULL(far_wire.lash_through, "A swing at a knight's move carried through") + +/// The garrote's blow when armour turns the wire cuts the victim alone, never the body behind. +/datum/unit_test/voidcrew_widowline/wire_garrote_no_cleave + +/datum/unit_test/voidcrew_widowline/wire_garrote_no_cleave/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/mob/living/carbon/human/consistent/behind = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + TEST_ASSERT_EQUAL(wire.wire_through_target(victim, user), behind, "Fixture: a plain swing doesn't carry into the body behind") + wire.garrote_no_cleave = TRUE + TEST_ASSERT_NULL(wire.wire_through_target(victim, user), "The garrote's blow would carry into the body behind") + wire.garrote_no_cleave = FALSE + + user.zone_selected = BODY_ZONE_HEAD + victim.equip_to_slot_or_del(new /obj/item/clothing/head/helmet/space(victim), ITEM_SLOT_HEAD) + victim.Paralyze(100 SECONDS) + TEST_ASSERT(wire.wire_try_garrote(victim, user), "Fixture: no garrote on the helmeted victim") + var/datum/hv_finisher/garrote/garrote = wire.garrote_running + for(var/i in 1 to 10) + if(!garrote.running) + break + garrote.advance() + TEST_ASSERT(victim.getBruteLoss() > 0, "Fixture: the turned wire's blow didn't land") + TEST_ASSERT_EQUAL(behind.getBruteLoss() + behind.getFireLoss(), 0, "The garrote's blow cut the body behind the victim") + TEST_ASSERT(!wire.garrote_no_cleave, "The wire still thinks it is the garrote's blow") + +/// A through-cut that also takes a limb off its target still draws its line on through to the body behind. +/datum/unit_test/voidcrew_widowline/wire_through_sever + +/datum/unit_test/voidcrew_widowline/wire_through_sever/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/mob/living/carbon/human/consistent/behind = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + var/obj/item/bodypart/arm = target.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, target, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(target.get_bodypart(BODY_ZONE_L_ARM), "Fixture: the arm didn't come off") + TEST_ASSERT(behind.getBruteLoss() > 0, "Fixture: the cut didn't carry through") + TEST_ASSERT_EQUAL(wire.lash_through?.resolve(), behind, "A cut that took a limb off doesn't lash on through to the body behind") + wire.wire_lash_at(user, target, BODY_ZONE_L_ARM) + var/obj/effect/abstract/wire_reach/lash_end = locate() in get_turf(behind) + TEST_ASSERT_NOTNULL(lash_end, "The lash of a through-cut that took a limb off stopped short of the body behind") + +/// A cut wets the wire with the victim's blood, which drips, dries and flicks off on stowing; the DNA stays. The Arc stays clean. +/datum/unit_test/voidcrew_widowline/wire_bloody + +/datum/unit_test/voidcrew_widowline/wire_bloody/Run() + var/mob/living/carbon/human/user = wielder(spot(1, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + TEST_ASSERT_EQUAL(wire.blood_stage(), 0, "A new wire is bloody") + cut(user, victim, BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(wire.blood_stage(), 2, "A cut didn't wet the wire") + TEST_ASSERT(length(GET_ATOM_BLOOD_DNA(wire)), "A cut left no blood DNA on the wire") + var/found = FALSE + for(var/mutable_appearance/look in wire.worn_overlays(mutable_appearance(wire.righthand_file, "monowire"), TRUE, wire.righthand_file)) + if(look.icon_state == "monowire_blood2") + found = TRUE + TEST_ASSERT(found, "The wet wire draws no blood in hand") + for(var/look in wire.overlays) + var/mutable_appearance/drawn = look + TEST_ASSERT_NOTEQUAL(drawn.icon_state, "itemblood", "tg's generic stain is drawn on the wire") + + // Drips, capped. + for(var/i in 1 to 12) + wire.drip() + var/drips = 0 + for(var/obj/effect/decal/cleanable/blood/drip/drop in get_turf(user)) + drips++ + TEST_ASSERT(drips > 0, "A wet wire never dripped") + TEST_ASSERT(wire.drips_left >= 0, "The drips ran past their cap") + + // Dry to stained. + wire.wet_until = world.time - 1 + wire.update_blood_look() + TEST_ASSERT_EQUAL(wire.blood_stage(), 1, "The wire didn't dry to a stain") + + // Wet again, stowed: drops in front, the look clears, the DNA stays. + cut(user, victim, BODY_ZONE_CHEST) + // The cut throws its own drops off the seam (wire_seams.dm); let them land so only the fan is counted. + sleep(1 SECONDS) + user.setDir(EAST) + var/list/plan = wire_fan_plan(EAST, "right") + TEST_ASSERT_EQUAL(length(plan), 6, "The fan isn't six drops") // WIRE_FLICK_DROPS + for(var/list/drop as anything in plan) + TEST_ASSERT(drop[3] > drop[1] && abs(drop[4]) <= 48, "A drop of the fan lands behind the wielder or too far off ([drop[3]], [drop[4]])") + var/turf/ahead = get_step(user, EAST) + var/before = 0 + for(var/obj/effect/decal/cleanable/blood/drip/drop in range(2, user)) + if(get_turf(drop) != get_turf(user)) + before++ + wire.flick_blood(user, "right") + TEST_ASSERT(locate(/obj/effect/temp_visual/wire_blood_drop) in get_turf(user), "The fan threw no drops") + sleep(1 SECONDS) + // It scatters over the floor ahead: a row nearer or further as well as level with the wielder. + var/landed_ahead = FALSE + for(var/obj/effect/decal/cleanable/blood/drip/drop in range(2, user)) + if(drop.x == ahead.x) + landed_ahead = TRUE + break + TEST_ASSERT(landed_ahead, "The fan landed no blood ahead") + var/after = 0 + for(var/obj/effect/decal/cleanable/blood/drip/drop in range(2, user)) + if(get_turf(drop) != get_turf(user)) + after++ + TEST_ASSERT(after - before <= 6, "The fan left more drips than drops") + wire.clear_blood_look() + TEST_ASSERT_EQUAL(wire.blood_stage(), 0, "The flick left the wire looking bloody") + TEST_ASSERT(length(GET_ATOM_BLOOD_DNA(wire)), "The flick wiped the blood DNA") + + // A wash clears it all. + cut(user, victim, BODY_ZONE_CHEST) + wire.wash(CLEAN_TYPE_BLOOD) + TEST_ASSERT_EQUAL(wire.blood_stage(), 0, "A wash left the wire bloody") + + // The Arc burns its blood off. + var/mob/living/carbon/human/attacker = wielder(spot(1, 3), /obj/item/melee/cyberware_monowire/live) + var/obj/item/melee/cyberware_monowire/arc = held(attacker) + cut(attacker, victim, BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(arc.blood_stage(), 0, "The Arc shows blood") + +/// A lash hides the wire hanging in the hand that throws it whichever way the wielder faces, and is drawn behind a +/// body standing a row nearer the viewer and over one a row further off. +/datum/unit_test/voidcrew_widowline/wire_lash_look + +/datum/unit_test/voidcrew_widowline/wire_lash_look/Run() + var/mob/living/carbon/human/consistent/user = wielder(spot(2, 2)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + for(var/facing in GLOB.cardinals) + var/turf/stand = get_step(user, facing) + victim.forceMove(stand) + victim.setDir(REVERSE_DIR(facing)) + user.setDir(facing) + wire.show_inhand() + wire.wire_lash_at(user, victim, BODY_ZONE_R_LEG) + TEST_ASSERT(wire.inhand_hidden_until > world.time, "A lash facing [dir2text(facing)] left the hanging wire drawn") + var/obj/effect/abstract/wire_reach/lash_end = locate() in stand + TEST_ASSERT_NOTNULL(lash_end, "A lash facing [dir2text(facing)] drew nothing on its target's tile") + if(facing == SOUTH) + TEST_ASSERT_EQUAL(lash_end.layer, BELOW_MOB_LAYER, "A lash down to a body nearer the viewer drew over it") + else if(facing == NORTH) + TEST_ASSERT_EQUAL(lash_end.layer, ABOVE_MOB_LAYER, "A lash up to a body further off drew under it") + for(var/obj/effect/abstract/wire_reach/lash in range(1, user)) + qdel(lash) + +/// The wire leaves the hand at the pixel its spool lights: the hand table against the held art, facing by facing; a +/// lash's line placed on that pixel; and the spool left in the hand while the line is out. +/datum/unit_test/voidcrew_widowline/wire_hand_point + +/datum/unit_test/voidcrew_widowline/wire_hand_point/Run() + var/mob/living/carbon/human/consistent/user = wielder(spot(2, 2)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + var/icon/spools = icon('voidcrew/modules/hyperviolence/wire/icons/wire_spool.dmi') // WIRE_SPOOL_ICON + for(var/facing in GLOB.cardinals) + user.setDir(facing) + for(var/side in list("left", "right")) + var/list/hand = wire_hand_point(user, side) + // A hand behind the body shows no lit pixel: its line comes out from behind the body. + if(hand[3]) + continue + // Icon pixels count from 1 at the lower left corner; the table counts from the middle of the tile. + var/icon/held_art = icon(side == "left" ? wire.lefthand_file : wire.righthand_file) + var/lit = held_art.GetPixel(hand[1] + 17, hand[2] + 17, wire.inhand_icon_state, facing) + TEST_ASSERT_EQUAL(lit, "#f86cfa", "Facing [dir2text(facing)], the [side] hand's wire isn't drawn from the spool's lit pixel ([hand[1]], [hand[2]])") + var/spool = spools.GetPixel(hand[1] + 17, hand[2] + 17, "[wire.inhand_icon_state]_[side]", facing) + TEST_ASSERT_EQUAL(spool, lit, "Facing [dir2text(facing)], the [side] hand's spool on its own has no lit pixel where the wire leaves it") + var/turf/stand = get_step(user, facing) + victim.forceMove(stand) + victim.setDir(REVERSE_DIR(facing)) + wire.show_inhand() + wire.wire_lash_at(user, victim, BODY_ZONE_CHEST) + var/list/grip = wire_hand_point(user, wire.held_side(user)) + var/on_grip = FALSE + for(var/obj/effect/abstract/wire_reach/piece in get_turf(user)) + if(piece.pixel_w == user.pixel_x + grip[1] && piece.pixel_y + piece.pixel_z == user.pixel_y + grip[2]) + on_grip = TRUE + TEST_ASSERT(on_grip, "A lash facing [dir2text(facing)] doesn't start on the pixel the wire leaves the hand from") + TEST_ASSERT(wire.inhand_hidden_until > world.time && wire.inhand_bare_until <= world.time, "A lash facing [dir2text(facing)] took the spool out of the hand with the wire") + for(var/obj/effect/abstract/wire_reach/lash in range(1, user)) + qdel(lash) + +/// The wire swings out of the spool and reels back in, the held wire hidden for the swing; a wet one flicks. +/datum/unit_test/voidcrew_widowline/play_deploy + +/datum/unit_test/voidcrew_widowline/play_deploy/Run() + var/mob/living/carbon/human/consistent/bearer = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/housing = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire) + TEST_ASSERT(housing.Insert(bearer, special = TRUE), "Fixture: the housing wouldn't go in") + housing.ui_action_click() + var/obj/item/melee/cyberware_monowire/wire = housing.active_item + TEST_ASSERT(istype(wire) && bearer.is_holding(wire), "The wire didn't deploy") + var/list/states = list() + for(var/obj/effect/abstract/cyberware_anim/look in bearer.vis_contents) + states += look.icon_state + TEST_ASSERT(("monowire_deploy_right" in states) || ("monowire_deploy_left" in states), "The wire didn't swing out: [jointext(states, ", ")]") + TEST_ASSERT(wire.inhand_hidden_until > world.time, "The held wire shows over its own swing") + + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + bearer.zone_selected = BODY_ZONE_CHEST + wire.wire_cut_begin(victim, bearer) + victim.apply_damage(wire.force, BRUTE, BODY_ZONE_CHEST, 0, wound_bonus = CANT_WOUND, sharpness = SHARP_EDGED, attack_direction = EAST, attacking_item = wire) + wire.wire_cut_end(victim) + TEST_ASSERT_EQUAL(wire.blood_stage(), 2, "Fixture: the cut didn't wet the wire") + for(var/obj/effect/abstract/cyberware_anim/look in bearer.vis_contents) + qdel(look) + housing.ui_action_click() + TEST_ASSERT(wire.loc == housing, "The wire didn't stow") + states = list() + for(var/obj/effect/abstract/cyberware_anim/look in bearer.vis_contents) + states += look.icon_state + TEST_ASSERT(("monowire_retract_right" in states) || ("monowire_retract_left" in states), "The wire didn't reel in: [jointext(states, ", ")]") + TEST_ASSERT(("monowire_retract_blood2_right" in states) || ("monowire_retract_blood2_left" in states), "A wet wire reeled in clean: [jointext(states, ", ")]") + TEST_ASSERT_EQUAL(wire.blood_stage(), 0, "The wire is still bloody in its spool") + +/// The garrote: only on someone helpless (crit or stunned, not just lying down) and lying on the floor (not stunned on +/// their feet, not strapped into a chair), even a fellow player; no mark; a real grab; the head in hard crit, the +/// throat otherwise, turned by a collar; broken by damage or the victim getting up; the wire's blow. +/datum/unit_test/voidcrew_widowline/garrote + +/datum/unit_test/voidcrew_widowline/garrote/Run() + var/mob/living/carbon/human/user = wielder(spot(1, 1)) + var/obj/item/melee/cyberware_monowire/wire = held(user) + user.zone_selected = BODY_ZONE_HEAD + + // On their feet, or just lying down: no. + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + TEST_ASSERT(!wire.wire_try_garrote(victim, user), "A garrote started on someone standing") + victim.Knockdown(100 SECONDS) + TEST_ASSERT(!wire.wire_try_garrote(victim, user), "A garrote started on someone only knocked down") + victim.SetKnockdown(0) + + // Helpless but not on the floor: no. A stun leaves them on their feet (stood up at once: tg takes a second over it). + victim.get_up(instant = TRUE) + victim.Stun(100 SECONDS) + TEST_ASSERT(victim.body_position == STANDING_UP && HAS_TRAIT(victim, TRAIT_INCAPACITATED), "Fixture: the stun didn't leave them stunned on their feet") + TEST_ASSERT(!wire.wire_try_garrote(victim, user), "A garrote started on someone stunned on their feet") + victim.SetStun(0) + // In crit, strapped into a chair beside the garroter: no. + var/mob/living/carbon/human/consistent/seated = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/obj/structure/chair/chair = allocate(/obj/structure/chair, spot(1, 0)) + seated.apply_damage(150, OXY) + TEST_ASSERT(seated.stat >= SOFT_CRIT && seated.stat != DEAD, "Fixture: the seated one isn't in crit ([seated.stat])") + TEST_ASSERT(chair.buckle_mob(seated, force = TRUE) && seated.buckled == chair, "Fixture: couldn't strap them into the chair") + TEST_ASSERT(!wire.wire_start_garrote(user, seated), "A garrote started on someone in crit strapped into a chair") + + // Stunned, though both are neutral-faction people: yes. No mark; the wire thrown at the neck. + victim.Paralyze(100 SECONDS) + // A second wire in the other hand: the strands run from both hands, so it isn't drawn hanging there meanwhile. + var/obj/item/melee/cyberware_monowire/second = allocate(/obj/item/melee/cyberware_monowire) + TEST_ASSERT(user.put_in_inactive_hand(second), "Fixture: the garroter couldn't hold a second wire") + TEST_ASSERT(wire.wire_try_garrote(victim, user), "A garrote didn't start on a stunned person") + var/datum/hv_finisher/garrote/garrote = wire.garrote_running + TEST_ASSERT_NOTNULL(garrote, "The wire doesn't know its garrote") + TEST_ASSERT_EQUAL(length(garrote.reach_refs), 1, "No wire thrown at the neck in the wind-up") + TEST_ASSERT(user.wire_garrote_ready_at > world.time, "The garrote started with no wait after it") + TEST_ASSERT(!wire.wire_try_garrote(victim, user), "A second garrote started at once") + // The hold: a real grab, the wire tight. + garrote.advance() + TEST_ASSERT(garrote.gripped, "The garrote's hold didn't grip") + TEST_ASSERT(user.pulling == victim && user.grab_state >= GRAB_AGGRESSIVE, "The garrote's hold isn't a real aggressive grab") + var/datum/weakref/loop_ref = LAZYACCESS(garrote.loop_refs, 1) + var/obj/effect/abstract/cyberware_anim/loop = loop_ref?.resolve() + TEST_ASSERT(loop && loop.icon_state == "garrote_tight_front", "The wire didn't pull tight") + // The grab's own pull is applied (12 px toward the garroter, who stands west), the body lies head first to them, + // and the hold draws it in until its head lies at their feet, on the floor: never lifted. + TEST_ASSERT_EQUAL(LAZYACCESS(LAZYACCESS(victim.offsets, PIXEL_X_OFFSET), GRABBING_TRAIT), -12, "The grab didn't pull the body in") + TEST_ASSERT_EQUAL(victim.lying_angle, LYING_ANGLE_WEST, "The body doesn't lie head first to the garroter") + var/list/neck = garrote.neck_point() + var/list/hands = garrote.hold_point() + TEST_ASSERT(abs(neck[1] - hands[1]) <= 2 && abs(neck[2] - hands[2]) <= 2, "The neck isn't at the garroter's feet ([neck[1]],[neck[2]] vs [hands[1]],[hands[2]])") + TEST_ASSERT(!LAZYACCESS(LAZYACCESS(victim.offsets, PIXEL_Y_OFFSET), HV_FINISHER_OFFSET), "The hold lifted the body off the floor") + TEST_ASSERT_EQUAL(length(garrote.strand_refs), 2, "The wire doesn't run from both hands") + TEST_ASSERT(wire.inhand_hidden_until > world.time, "The garroting wire still hangs in its hand") + TEST_ASSERT(second.inhand_hidden_until > world.time, "The second wire hangs in its hand while a strand runs from it") + // The strands' ends on the neck go with it as it thrashes. + for(var/datum/weakref/strand_ref as anything in garrote.strand_refs) + var/obj/effect/abstract/wire_reach/strand = strand_ref.resolve() + TEST_ASSERT_EQUAL(length(strand?.span), 2, "A strand doesn't know where its end on the neck is") + garrote.thrash(0.5 SECONDS) + TEST_ASSERT(user.wire_garrote_ready_at - world.time > 10 SECONDS, "A garrote that got a grip has the short wait") + // The kill, not in hard crit: the throat. + for(var/i in 1 to 10) + if(!garrote.running) + break + garrote.advance() + var/obj/item/bodypart/head = victim.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_NOTNULL(head, "A garrote took the head off someone only stunned") + TEST_ASSERT_NOTNULL(locate(/datum/wound/slash/flesh/critical/hv_carotid) in head.wounds, "The garrote didn't slit the throat") + TEST_ASSERT_NULL(wire.garrote_running, "The wire still thinks it is garroting") + TEST_ASSERT(wire.inhand_hidden_until <= world.time, "The garroting wire isn't drawn in its hand again after the kill") + TEST_ASSERT(second.inhand_hidden_until <= world.time, "The second wire isn't drawn in its hand again after the kill") + TEST_ASSERT(!victim.has_status_effect(/datum/status_effect/hv_finisher_hold), "The victim is still held") + // Let go at the kill: nothing of the grab or the hold still draws the body off its tile. + TEST_ASSERT(user.pulling != victim, "The garroter still holds the body") + TEST_ASSERT(!LAZYACCESS(LAZYACCESS(victim.offsets, PIXEL_X_OFFSET), GRABBING_TRAIT) && !LAZYACCESS(LAZYACCESS(victim.offsets, PIXEL_X_OFFSET), HV_FINISHER_OFFSET), "The body is still drawn pulled in after the kill") + + // Hard crit: the head, at the body's feet. + user.wire_garrote_ready_at = 0 + var/mob/living/carbon/human/consistent/dying = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + dying.equip_to_slot_or_del(new /obj/item/radio/headset(dying), ITEM_SLOT_EARS) + dying.apply_damage(150, OXY) + TEST_ASSERT(dying.stat >= HARD_CRIT && dying.stat != DEAD, "Fixture: not in hard crit ([dying.stat])") + user.zone_selected = BODY_ZONE_CHEST + TEST_ASSERT(!wire.wire_try_garrote(dying, user), "A click at the chest started a garrote") + TEST_ASSERT(wire.wire_start_garrote(user, dying), "wire_start_garrote() didn't start on someone in hard crit") + user.zone_selected = BODY_ZONE_HEAD + garrote = wire.garrote_running + for(var/i in 1 to 10) + if(!garrote.running) + break + garrote.advance() + var/obj/item/bodypart/taken = locate(/obj/item/bodypart/head) in get_turf(dying) + TEST_ASSERT_NULL(dying.get_bodypart(BODY_ZONE_HEAD), "A garrote in hard crit didn't take the head") + TEST_ASSERT_NOTNULL(taken, "The head wasn't left at the body") + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/brain) in taken, "The head lost its brain") + // The garroter stands south of this one: the head drops toward their feet. Measured at the head's middle (9 px up + // on the body, turned with the head, then its picture's own shift), since a head turned as the body lay moves its + // picture's corner by several pixels either way, and tg lays a body down facing either way at random. + var/head_mid_y = taken.transform.e * 9 + taken.transform.f + taken.px_y + taken.pixel_y + TEST_ASSERT(head_mid_y < 0, "The head didn't drop at the garroter's feet ([head_mid_y] px, lying at [dying.lying_angle])") + // Facing away, it goes back with the body as it settles: it lies against the neck, where the body came to rest. + TEST_ASSERT(abs(head_mid_y - dying.pixel_y) <= 4, "The head didn't settle back with the body ([head_mid_y] px, body at [dying.pixel_y])") + // The headset came off with it and lies on its side by it, not stood up on the body. + var/obj/item/radio/headset/headset = locate() in get_turf(dying) + TEST_ASSERT_NOTNULL(headset, "The headset didn't come off with the head") + TEST_ASSERT(abs(headset.transform.b) > 0.5, "The headset isn't lying on its side by the head") + // The pool goes down once the body has settled after the kill. + sleep(0.5 SECONDS) + var/pooled = FALSE + for(var/obj/effect/decal/cleanable/blood/pool in get_turf(dying)) + if(!istype(pool, /obj/effect/decal/cleanable/blood/drip) && !istype(pool, /obj/effect/decal/cleanable/blood/hv_spray)) + pooled = TRUE + TEST_ASSERT(pooled, "The neck left no pool under the body") + + // A sealed helmet turns the wire: no slit throat, a blow instead. + user.wire_garrote_ready_at = 0 + var/mob/living/carbon/human/consistent/helmeted = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + helmeted.equip_to_slot_or_del(new /obj/item/clothing/head/helmet/space(helmeted), ITEM_SLOT_HEAD) + helmeted.Paralyze(100 SECONDS) + TEST_ASSERT(wire.wire_try_garrote(helmeted, user), "Fixture: no garrote on the helmeted victim") + garrote = wire.garrote_running + for(var/i in 1 to 10) + if(!garrote.running) + break + garrote.advance() + head = helmeted.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_NULL(locate(/datum/wound/slash/flesh/critical/hv_carotid) in head.wounds, "The wire slit a throat under a sealed helmet") + + // Damage on the garroter breaks it, and a garrote that never gripped has the short wait. + user.wire_garrote_ready_at = 0 + var/mob/living/carbon/human/consistent/saved = allocate(/mob/living/carbon/human/consistent, spot(0, 1)) + saved.Paralyze(100 SECONDS) + TEST_ASSERT(wire.wire_try_garrote(saved, user), "Fixture: no garrote on the last victim") + garrote = wire.garrote_running + // The wire thrown (its wind-up timer): only the thrown wire leaves its hand. The second hangs on until the hold runs a + // strand from its hand too. + garrote.hide_thrown_wire() + TEST_ASSERT(wire.inhand_hidden_until > world.time, "The thrown wire still hangs in its hand") + TEST_ASSERT(second.inhand_hidden_until <= world.time, "The throw hid the second wire before a strand runs from it") + // The strands (as the hold draws them), then broken off: both wires come back to their hands. + garrote.hide_hands() + TEST_ASSERT(second.inhand_hidden_until > world.time, "The strands left the second wire hanging in its hand") + user.apply_damage(25, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(!garrote.running, "25 damage on the garroter didn't break the garrote") + TEST_ASSERT_EQUAL(garrote.result, 3, "The garrote ended for the wrong reason") // HV_FINISHER_DAMAGED + TEST_ASSERT(user.wire_garrote_ready_at - world.time <= 5 SECONDS, "A garrote that never gripped has the long wait") + TEST_ASSERT(!saved.has_status_effect(/datum/status_effect/hv_finisher_hold), "The broken garrote still holds its victim") + TEST_ASSERT(second.inhand_hidden_until <= world.time, "The second wire stayed hidden after the garrote broke") + qdel(second) + + // The garrote's blow is the wire's, never the heaviest thing in the other hand. + user.fully_heal(HEAL_ALL) + user.wire_garrote_ready_at = 0 + var/obj/item/claymore/heavy = allocate(/obj/item/claymore) + user.put_in_inactive_hand(heavy) + saved.SetParalyzed(100 SECONDS) + TEST_ASSERT(wire.wire_try_garrote(saved, user), "A garrote didn't start with a heavier weapon in the other hand") + garrote = wire.garrote_running + TEST_ASSERT(garrote.real_blow(BODY_ZONE_HEAD), "The garrote's blow didn't swing") + TEST_ASSERT_EQUAL(user.get_active_held_item(), wire, "The garrote swung the heavier weapon, not the wire") + // Up off the floor, they're out of it. + TEST_ASSERT(garrote.running && !garrote.safety_check(), "Fixture: the last garrote isn't running") + saved.set_body_position(STANDING_UP) + TEST_ASSERT_EQUAL(garrote.safety_check(), 2, "The garrote kept on with its victim back on their feet") // HV_FINISHER_LOST_GRIP + garrote.stop(2) // HV_FINISHER_LOST_GRIP + + // The crit gates never count the wire's penetration; its cuts still do. + TEST_ASSERT_EQUAL(hv_crit_armour_pen(wire), 0, "The wire's penetration counts at the crit gates") + TEST_ASSERT_EQUAL(wire.armour_penetration, 100, "The wire lost its penetration for its cuts") + +/// The Widowline Arc's garrote takes the head whatever state the victim is in, not only in hard crit; a pair with one +/// Arc wire does too. A sealed helmet still turns it. +/datum/unit_test/voidcrew_widowline/garrote_arc + +/// Runs a garrote by `user`'s held wire on `victim` to its end. Returns TRUE if it started. +/datum/unit_test/voidcrew_widowline/garrote_arc/proc/garrote_through(mob/living/carbon/human/user, mob/living/carbon/human/victim) + var/obj/item/melee/cyberware_monowire/wire = held(user) + user.wire_garrote_ready_at = 0 + user.zone_selected = BODY_ZONE_HEAD + if(!wire.wire_try_garrote(victim, user)) + return FALSE + var/datum/hv_finisher/garrote/garrote = wire.garrote_running + for(var/i in 1 to 10) + if(!garrote.running) + break + garrote.advance() + return TRUE + +/datum/unit_test/voidcrew_widowline/garrote_arc/Run() + var/mob/living/carbon/human/user = wielder(spot(1, 1), /obj/item/melee/cyberware_monowire/live) + + // Soft crit, nowhere near hard crit: the Arc takes the head. + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + // Brute, not oxygen: past 50 oxyloss tg knocks a body out (check_passout()), which is not soft crit. + victim.apply_damage(110, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) + TEST_ASSERT_EQUAL(victim.stat, SOFT_CRIT, "Fixture: not in soft crit") + victim.set_body_position(LYING_DOWN) + TEST_ASSERT(garrote_through(user, victim), "The Arc's garrote didn't start on someone in soft crit") + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_HEAD), "The Arc's garrote didn't take the head off someone in soft crit") + + // Only stunned: the head too. + var/mob/living/carbon/human/consistent/stunned = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + stunned.Paralyze(100 SECONDS) + TEST_ASSERT(garrote_through(user, stunned), "The Arc's garrote didn't start on someone stunned") + TEST_ASSERT_NULL(stunned.get_bodypart(BODY_ZONE_HEAD), "The Arc's garrote didn't take the head off someone stunned") + + // A sealed helmet turns it, as it turns the plain wire: the head stays, the throat isn't slit. + var/mob/living/carbon/human/consistent/helmeted = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + helmeted.equip_to_slot_or_del(new /obj/item/clothing/head/helmet/space(helmeted), ITEM_SLOT_HEAD) + helmeted.Paralyze(100 SECONDS) + TEST_ASSERT(garrote_through(user, helmeted), "Fixture: no garrote on the helmeted victim") + var/obj/item/bodypart/head = helmeted.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_NOTNULL(head, "The Arc's garrote took the head off through a sealed helmet") + TEST_ASSERT_NULL(locate(/datum/wound/slash/flesh/critical/hv_carotid) in head.wounds, "The Arc's wire slit a throat under a sealed helmet") + + // A plain wire garroting, an Arc wire in the other hand: the pair takes the head. + var/mob/living/carbon/human/pair = wielder(spot(0, 1)) + var/obj/item/melee/cyberware_monowire/live/arc = allocate(/obj/item/melee/cyberware_monowire/live) + TEST_ASSERT(pair.put_in_inactive_hand(arc), "Fixture: the garroter couldn't hold the Arc wire") + var/mob/living/carbon/human/consistent/paired = allocate(/mob/living/carbon/human/consistent, spot(0, 2)) + paired.Paralyze(100 SECONDS) + TEST_ASSERT(garrote_through(pair, paired), "The paired garrote didn't start") + TEST_ASSERT_NULL(paired.get_bodypart(BODY_ZONE_HEAD), "A plain wire with an Arc wire in the other hand didn't take the head") + + // The plain wire alone on someone stunned: the throat, the head stays. + qdel(arc) + var/mob/living/carbon/human/consistent/plain = allocate(/mob/living/carbon/human/consistent, spot(3, 1)) + plain.Paralyze(100 SECONDS) + pair.forceMove(spot(3, 2)) + TEST_ASSERT(garrote_through(pair, plain), "The plain garrote didn't start") + head = plain.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_NOTNULL(head, "The plain wire took the head off someone only stunned") + TEST_ASSERT_NOTNULL(locate(/datum/wound/slash/flesh/critical/hv_carotid) in head.wounds, "The plain wire didn't slit the throat") + +/// A leg cut from someone on their feet puts them down (tg's knockdown) once it has dropped; an arm doesn't. +/datum/unit_test/voidcrew_widowline/wire_leg_fall + +/datum/unit_test/voidcrew_widowline/wire_leg_fall/Run() + var/mob/living/carbon/human/user = wielder(spot(0, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/bodypart/leg = victim.get_bodypart(BODY_ZONE_L_LEG) + leg.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, victim, BODY_ZONE_L_LEG) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_L_LEG), "Fixture: the leg didn't come off") + TEST_ASSERT_EQUAL(victim.body_position, STANDING_UP, "The body went down before the leg dropped") + sleep(1 SECONDS) + TEST_ASSERT_EQUAL(victim.body_position, LYING_DOWN, "Someone on their feet stayed up after losing a leg") + TEST_ASSERT(victim.IsKnockdown(), "The fall after losing a leg isn't tg's knockdown") + + var/mob/living/carbon/human/consistent/armless = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + var/obj/item/bodypart/arm = armless.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(user, armless, BODY_ZONE_L_ARM) + TEST_ASSERT_NULL(armless.get_bodypart(BODY_ZONE_L_ARM), "Fixture: the arm didn't come off") + sleep(1 SECONDS) + TEST_ASSERT_EQUAL(armless.body_position, STANDING_UP, "Losing an arm put someone down") + +/// Every stump: the jumpsuit is cut away where the lost limb was, and comes back with the limb. +/datum/unit_test/voidcrew_widowline/hv_mask_sleeves + +/datum/unit_test/voidcrew_widowline/hv_mask_sleeves/Run() + var/mob/living/carbon/human/consistent/body = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + body.equip_to_slot_or_del(new /obj/item/clothing/under/color/grey(body), ITEM_SLOT_ICLOTHING) + var/mutable_appearance/uniform = body.overlays_standing[UNIFORM_LAYER] + TEST_ASSERT(istype(uniform), "Fixture: no jumpsuit drawn") + TEST_ASSERT(!LAZYACCESS(uniform.filter_data, "hv_sleeve_mask"), "A whole body's jumpsuit is masked") + var/obj/item/bodypart/arm = body.get_bodypart(BODY_ZONE_L_ARM) + arm.dismember() + uniform = body.overlays_standing[UNIFORM_LAYER] + TEST_ASSERT(LAZYACCESS(uniform.filter_data, "hv_sleeve_mask"), "The jumpsuit keeps an empty sleeve on a lost arm") + body.regenerate_limb(BODY_ZONE_L_ARM) + body.update_body_parts() + uniform = body.overlays_standing[UNIFORM_LAYER] + TEST_ASSERT(!LAZYACCESS(uniform.filter_data, "hv_sleeve_mask"), "The jumpsuit stayed masked with the arm back on") + +/// The aimed sever, the crossing cut and the garrote are the wielder's moves, through one switch +/// (hv_wire_moves_allowed()): a human NPC holding a wire doesn't use them yet. +/datum/unit_test/voidcrew_widowline/hv_wire_moves_allowed + +/datum/unit_test/voidcrew_widowline/hv_wire_moves_allowed/Run() + var/mob/living/carbon/human/npc/chrome_dummy/npc = allocate(/mob/living/carbon/human/npc/chrome_dummy, spot(0, 1)) + var/mob/living/carbon/human/consistent/body = allocate(/mob/living/carbon/human/consistent, spot(0, 3)) + TEST_ASSERT(!hv_wire_moves_allowed(npc), "A human NPC may use the wire's moves") + TEST_ASSERT(hv_wire_moves_allowed(body), "A player's body may not use the wire's moves") + var/obj/item/melee/cyberware_monowire/wire = allocate(/obj/item/melee/cyberware_monowire) + TEST_ASSERT(npc.put_in_active_hand(wire), "Fixture: the NPC couldn't hold the wire") + npc.set_combat_mode(TRUE) + + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + arm.receive_damage(brute = 30, wound_bonus = CANT_WOUND) + cut(npc, victim, BODY_ZONE_L_ARM) + TEST_ASSERT_NOTNULL(victim.get_bodypart(BODY_ZONE_L_ARM), "A human NPC's aimed wire cut took an arm") + TEST_ASSERT(victim.getBruteLoss() > 0, "The NPC's wire did no damage at all") + + var/obj/item/melee/cyberware_monowire/second = allocate(/obj/item/melee/cyberware_monowire) + npc.put_in_inactive_hand(second) + npc.wire_cross_hits = 2 + npc.wire_cross_last = world.time + TEST_ASSERT(!wire.wire_cross_due(npc), "A human NPC with two wires makes the crossing cut") + + npc.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/downed = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + downed.Paralyze(100 SECONDS) + TEST_ASSERT(!wire.wire_try_garrote(downed, npc), "A human NPC started a garrote") + TEST_ASSERT(!wire.wire_start_garrote(npc, downed), "A human NPC started a garrote from the entry point") + TEST_ASSERT(!wire.wire_crossing_swing(npc, victim), "A human NPC made a crossing swing from the entry point") + // Its plain aimed swing still cuts, as the wire always did. + var/before = victim.getBruteLoss() + TEST_ASSERT(wire.wire_aimed_swing(npc, victim, BODY_ZONE_CHEST), "A human NPC couldn't swing the wire at all") + TEST_ASSERT(victim.getBruteLoss() > before, "A human NPC's wire swing did nothing") + +/// A second housing through the cradle goes on the free arm, one wire per arm, and both deploy. A third, with +/// both arms taken, replaces the right one and racks it in the tray: nothing lost, nothing doubled. +/datum/unit_test/voidcrew_widowline/cradle_second_arm + +/datum/unit_test/voidcrew_widowline/cradle_second_arm/Run() + var/obj/machinery/chrome_cradle/rig = allocate(/obj/machinery/chrome_cradle, spot(1, 1)) + var/mob/living/carbon/human/consistent/patient = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + rig.buckle_mob(patient, force = TRUE) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/first = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/second = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire) + first.forceMove(rig) + rig.begin_install(first) + TEST_ASSERT(rig.busy, "The first housing's install didn't begin") + rig.finish_install() + TEST_ASSERT_EQUAL(first.owner, patient, "The first housing didn't go in") + TEST_ASSERT_EQUAL(first.zone, BODY_ZONE_R_ARM, "The first housing didn't take its own arm") + + second.forceMove(rig) + rig.begin_install(second) + TEST_ASSERT(rig.busy, "The second housing's install didn't begin") + rig.finish_install() + TEST_ASSERT_EQUAL(second.owner, patient, "The second housing didn't go in") + TEST_ASSERT_EQUAL(first.owner, patient, "The second housing evicted the first") + TEST_ASSERT(!(first in rig.tray), "The first housing was racked in the tray") + TEST_ASSERT_EQUAL(second.zone, BODY_ZONE_L_ARM, "The second housing didn't go on the free arm") + TEST_ASSERT_EQUAL(second.slot, ORGAN_SLOT_LEFT_ARM_AUG, "The second housing's slot didn't follow its arm") + TEST_ASSERT_EQUAL(patient.get_organ_slot(ORGAN_SLOT_RIGHT_ARM_AUG), first, "The right arm doesn't hold the first housing") + TEST_ASSERT_EQUAL(patient.get_organ_slot(ORGAN_SLOT_LEFT_ARM_AUG), second, "The left arm doesn't hold the second housing") + + rig.unbuckle_mob(patient, force = TRUE) + first.ui_action_click() + second.ui_action_click() + var/obj/item/melee/cyberware_monowire/right_wire = first.active_item + var/obj/item/melee/cyberware_monowire/left_wire = second.active_item + TEST_ASSERT(istype(right_wire) && patient.is_holding(right_wire), "The right wire didn't deploy") + TEST_ASSERT(istype(left_wire) && patient.is_holding(left_wire), "The left wire didn't deploy") + TEST_ASSERT(IS_RIGHT_INDEX(patient.get_held_index_of_item(right_wire)), "The right housing's wire isn't in the right hand") + TEST_ASSERT(IS_LEFT_INDEX(patient.get_held_index_of_item(left_wire)), "The left housing's wire isn't in the left hand") + first.ui_action_click() + second.ui_action_click() + TEST_ASSERT(right_wire.loc == first && left_wire.loc == second, "The wires didn't stow") + + // Both arms taken: a third replaces the one on its own arm, which goes to the tray. + rig.buckle_mob(patient, force = TRUE) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/third = allocate(/obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire) + third.forceMove(rig) + rig.begin_install(third) + TEST_ASSERT(rig.busy, "The third housing's install didn't begin") + rig.finish_install() + TEST_ASSERT_EQUAL(third.owner, patient, "The third housing didn't go in") + TEST_ASSERT_EQUAL(third.zone, BODY_ZONE_R_ARM, "With both arms taken, the third housing left its own arm") + TEST_ASSERT(!first.owner && first.loc == rig && (first in rig.tray), "The replaced housing wasn't racked in the tray") + TEST_ASSERT_EQUAL(second.owner, patient, "The left housing was disturbed") + TEST_ASSERT(!QDELETED(first) && !QDELETED(second) && !QDELETED(third), "A housing was consumed") diff --git a/voidcrew/modules/unit_tests/voidcrew_cyberware_zoom.dm b/voidcrew/modules/unit_tests/voidcrew_cyberware_zoom.dm new file mode 100644 index 00000000000..719759ad15a --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_cyberware_zoom.dm @@ -0,0 +1,368 @@ +/** + * # Optics zoom (voidcrew/modules/cyberware/cyberware_zoom.dm, ware_line_zoom.dm) + * + * Every chrome optic zooms by tier, a zoomed bearer can't shoot, the zoom drops + * whenever the eyes or the bearer stop working, and a click on the zoomed view + * goes nowhere. There is no client here, so tg's scope never + * starts: these tests drive the optics' own half of a zoom (engage_zoom()) and + * stand in a hand-made cursor catcher for the scope's. + * + * Unit-test files compile before voidcrew/_DEFINES/, so fork defines are + * literals: TRAIT_CYBER_ZOOMED "cyber_zoomed", + * CYBERWARE_SCAN_SILHOUETTE 1 / _ITEMIZED 2, CYBERWARE_TIER_n n, and zone + * permissions Public/Yellow/Advanced 0/1/2. + */ + +/// Stands in for an armed click-to-target ability. +/datum/zoom_click_probe + /// How many clicks reached us as a click intercept. + var/intercepted = 0 + +/datum/zoom_click_probe/proc/InterceptClickOn(mob/user, params, atom/target) + intercepted++ + return TRUE + +/// The ladder: every optic zooms, carries the button and the scope, and reaches +/// what its tier says, never as far as binoculars (4). +/datum/unit_test/voidcrew_cyberware_zoom_ladder + +/datum/unit_test/voidcrew_cyberware_zoom_ladder/Run() + // optic => list(zoom, walk penalty) + var/list/expected = list( + /obj/item/organ/eyes/robotic/cyberware/spyglass = list(1, 1), + /obj/item/organ/eyes/robotic/cyberware/prospector/street = list(1, 1), + /obj/item/organ/eyes/robotic/cyberware/nightshade = list(1, 1), + /obj/item/organ/eyes/robotic/cyberware/prospector = list(1.5, 0.5), + /obj/item/organ/eyes/robotic/cyberware/deadeye = list(1.5, 0.5), + /obj/item/organ/eyes/robotic/cyberware/longsight = list(2, 0), + /obj/item/organ/eyes/robotic/cyberware/deadeye/milspec = list(2, 0), + /obj/item/organ/eyes/robotic/cyberware/lookout = list(2.5, 0), + ) + for(var/optic_type in subtypesof(/obj/item/organ/eyes/robotic/cyberware)) + var/obj/item/organ/eyes/robotic/cyberware/optics = allocate(optic_type) + TEST_ASSERT(optics.optics_zoom > 0, "[optic_type] doesn't zoom") + TEST_ASSERT(optics.optics_zoom < 4, "[optic_type] zooms as far as binoculars") + TEST_ASSERT_EQUAL(optics.slot, ORGAN_SLOT_EYES, "[optic_type] left the eye slot, so it would stack with other optics") + var/datum/component/scope/scope = optics.GetComponent(/datum/component/scope) + TEST_ASSERT_NOTNULL(scope, "[optic_type] has no scope to zoom with") + TEST_ASSERT_EQUAL(scope.range_modifier, optics.optics_zoom, "[optic_type]'s scope reaches a different distance from its zoom") + TEST_ASSERT(locate(/datum/action/cooldown/cyberware/optics_zoom) in optics.actions, "[optic_type] has no zoom button") + TEST_ASSERT(locate(/datum/action/cooldown/cyberware/chrome_read) in optics.actions, "[optic_type] lost its chrome read") + TEST_ASSERT(istype(optics.actions[length(optics.actions)], /datum/action/cooldown/cyberware/optics_zoom), "[optic_type]'s zoom is not its last button") + var/list/numbers = expected[optic_type] + if(!numbers) + continue + TEST_ASSERT_EQUAL(optics.optics_zoom, numbers[1], "[optic_type] zooms the wrong distance") + TEST_ASSERT_EQUAL(optics.zoom_walk_penalty, numbers[2], "[optic_type] has the wrong walk tax while zoomed") + for(var/optic_type in expected) + TEST_ASSERT(ispath(optic_type, /obj/item/organ/eyes/robotic/cyberware), "[optic_type] is no longer chrome optics") + +/// The existing optics keep their numbers now they're vars, and the new models +/// carry theirs. +/datum/unit_test/voidcrew_cyberware_zoom_models + +/datum/unit_test/voidcrew_cyberware_zoom_models/Run() + // Chrome read: 7 tiles every 12 seconds unless the optics say otherwise. + var/obj/item/organ/eyes/robotic/cyberware/nightshade/nightshade = allocate(/obj/item/organ/eyes/robotic/cyberware/nightshade) + var/datum/action/cooldown/cyberware/chrome_read/stock_read = locate() in nightshade.actions + TEST_ASSERT_EQUAL(nightshade.chrome_read_range, 7, "The stock chrome read range changed") + TEST_ASSERT_EQUAL(stock_read.cooldown_time, 12 SECONDS, "The stock chrome read cooldown changed") + + // Deadeye, unchanged. + var/obj/item/organ/eyes/robotic/cyberware/deadeye/deadeye = allocate(/obj/item/organ/eyes/robotic/cyberware/deadeye) + TEST_ASSERT_EQUAL(deadeye.tag_range, 9, "Deadeye tag range changed") + TEST_ASSERT_EQUAL(deadeye.tag_shots, 3, "Deadeye tracked shots changed") + TEST_ASSERT_EQUAL(deadeye.tag_duration, 15 SECONDS, "Deadeye tag length changed") + var/datum/action/cooldown/cyberware/deadeye_tag/deadeye_tag = locate() in deadeye.actions + TEST_ASSERT_EQUAL(deadeye_tag.type, /datum/action/cooldown/cyberware/deadeye_tag, "The Deadeye carries the wrong tag") + TEST_ASSERT_EQUAL(deadeye_tag.cooldown_time, 25 SECONDS, "Deadeye tag cooldown changed") + + // Marksman link: four shots, ten tiles, eighteen seconds, same tag length. + var/obj/item/organ/eyes/robotic/cyberware/deadeye/milspec/marksman = allocate(/obj/item/organ/eyes/robotic/cyberware/deadeye/milspec) + TEST_ASSERT_EQUAL(marksman.tag_range, 10, "Marksman tag range is not 10") + TEST_ASSERT_EQUAL(marksman.tag_shots, 4, "Marksman tracked shots are not 4") + TEST_ASSERT_EQUAL(marksman.tag_duration, 15 SECONDS, "Marksman tag length is not 15 s") + var/datum/action/cooldown/cyberware/deadeye_tag/marksman/marksman_tag = locate() in marksman.actions + TEST_ASSERT_NOTNULL(marksman_tag, "The Marksman link has no tag of its own") + TEST_ASSERT_EQUAL(marksman_tag.cooldown_time, 18 SECONDS, "Marksman tag cooldown is not 18 s") + check_chrome(marksman, 3, 4) + + // Prospector, unchanged; Assay optics shorter, slower and blind to caches. + var/obj/item/organ/eyes/robotic/cyberware/prospector/prospector = allocate(/obj/item/organ/eyes/robotic/cyberware/prospector) + TEST_ASSERT_EQUAL(prospector.pulse_range, 9, "Prospector pulse range changed") + TEST_ASSERT(prospector.pulse_marks_caches, "The Prospector stopped flagging caches") + var/datum/action/cooldown/cyberware/prospector_pulse/stock_pulse = locate() in prospector.actions + TEST_ASSERT_EQUAL(stock_pulse.cooldown_time, 10 SECONDS, "Prospector pulse cooldown changed") + var/obj/item/organ/eyes/robotic/cyberware/prospector/street/assay = allocate(/obj/item/organ/eyes/robotic/cyberware/prospector/street) + TEST_ASSERT_EQUAL(assay.pulse_range, 5, "Assay pulse range is not 5") + TEST_ASSERT(!assay.pulse_marks_caches, "Assay optics flag caches") + var/datum/action/cooldown/cyberware/prospector_pulse/assay/assay_pulse = locate() in assay.actions + TEST_ASSERT_NOTNULL(assay_pulse, "Assay optics have no pulse of their own") + TEST_ASSERT_EQUAL(assay_pulse.cooldown_time, 15 SECONDS, "Assay pulse cooldown is not 15 s") + TEST_ASSERT_EQUAL(assay.chrome_scan_resolution, 1, "Assay optics read at more than silhouette") + check_chrome(assay, 1, 1) + + // The plain scout line. + var/obj/item/organ/eyes/robotic/cyberware/spyglass/spyglass = allocate(/obj/item/organ/eyes/robotic/cyberware/spyglass) + TEST_ASSERT_EQUAL(spyglass.chrome_scan_resolution, 1, "Spyglass optics read at more than silhouette") + TEST_ASSERT_EQUAL(length(spyglass.actions), 2, "Spyglass optics should carry only the read and the zoom") + check_chrome(spyglass, 1, 1) + var/obj/item/organ/eyes/robotic/cyberware/longsight/longsight = allocate(/obj/item/organ/eyes/robotic/cyberware/longsight) + TEST_ASSERT_EQUAL(longsight.chrome_scan_resolution, 2, "Longsight optics don't name what they read") + TEST_ASSERT_EQUAL(longsight.chrome_read_range, 9, "Longsight read range is not 9") + check_chrome(longsight, 2, 2) + var/obj/item/organ/eyes/robotic/cyberware/lookout/lookout = allocate(/obj/item/organ/eyes/robotic/cyberware/lookout) + TEST_ASSERT_EQUAL(lookout.chrome_scan_resolution, 2, "Lookout optics don't name what they read") + TEST_ASSERT_EQUAL(lookout.chrome_read_range, 11, "Lookout read range is not 11") + var/datum/action/cooldown/cyberware/chrome_read/lookout_read = locate() in lookout.actions + TEST_ASSERT_EQUAL(lookout_read.cooldown_time, 8 SECONDS, "Lookout read cooldown is not 8 s") + TEST_ASSERT_EQUAL(lookout.lighting_cutoff, LIGHTING_CUTOFF_MEDIUM, "Lookout optics lost their low-light") + check_chrome(lookout, 3, 3) + +/datum/unit_test/voidcrew_cyberware_zoom_models/proc/check_chrome(obj/item/organ/eyes/robotic/cyberware/optics, tier, load) + var/datum/component/cyberware/chrome = optics.GetComponent(/datum/component/cyberware) + TEST_ASSERT_EQUAL(chrome.tier, tier, "[optics.type] is the wrong tier") + TEST_ASSERT_EQUAL(chrome.chrome_load, load, "[optics.type] carries the wrong neural load") + +/// A zoom holds the trait and the walk tax, refuses guns, and lets go cleanly. +/datum/unit_test/voidcrew_cyberware_zoom_state + +/datum/unit_test/voidcrew_cyberware_zoom_state/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/eyes/robotic/cyberware/spyglass/optics = allocate(/obj/item/organ/eyes/robotic/cyberware/spyglass) + TEST_ASSERT(optics.Insert(bearer, special = TRUE), "Spyglass staging insert was refused") + var/datum/action/cooldown/cyberware/optics_zoom/zoom = locate() in optics.actions + TEST_ASSERT_EQUAL(zoom.owner, bearer, "The zoom button didn't come with the eyes") + TEST_ASSERT(zoom.IsAvailable(), "Healthy installed optics can't zoom") + + // No client: the scope refuses, so the button can't zoom anyone here. + TEST_ASSERT(!optics.start_zoom(), "A clientless bearer zoomed") + TEST_ASSERT(!HAS_TRAIT(bearer, "cyber_zoomed"), "A refused zoom left the bearer zoomed") + + optics.engage_zoom(bearer) + TEST_ASSERT(optics.is_zoomed() && HAS_TRAIT(bearer, "cyber_zoomed"), "Engaging the zoom didn't mark the bearer zoomed") + TEST_ASSERT(zoom.is_action_active(null), "The zoom button doesn't show the zoom as on") + TEST_ASSERT(bearer.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_zoom), "Cheap optics didn't slow their bearer while zoomed") + + var/obj/item/gun/ballistic/automatic/pistol/pistol = allocate(/obj/item/gun/ballistic/automatic/pistol) + TEST_ASSERT(bearer.put_in_active_hand(pistol), "Test fixture: the bearer couldn't hold the pistol") + var/rounds = pistol.get_ammo() + TEST_ASSERT(rounds > 0, "Test fixture: the pistol spawned empty") + TEST_ASSERT(SEND_SIGNAL(bearer, COMSIG_MOB_TRYING_TO_FIRE_GUN, pistol, run_loc_floor_top_right, FALSE, null) & COMPONENT_CANCEL_GUN_FIRE, "A zoomed bearer's gun wasn't stopped") + pistol.fire_gun(run_loc_floor_top_right, bearer, FALSE, null) + TEST_ASSERT_EQUAL(pistol.get_ammo(), rounds, "A zoomed bearer fired a gun") + + optics.stop_zoom(bearer) + TEST_ASSERT(!optics.is_zoomed() && !HAS_TRAIT(bearer, "cyber_zoomed"), "Stopping the zoom left the bearer zoomed") + TEST_ASSERT(!bearer.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_zoom), "The walk tax outlived the zoom") + TEST_ASSERT(!(SEND_SIGNAL(bearer, COMSIG_MOB_TRYING_TO_FIRE_GUN, pistol, run_loc_floor_top_right, FALSE, null) & COMPONENT_CANCEL_GUN_FIRE), "The gun block outlived the zoom") + TEST_ASSERT(!zoom.is_action_active(null), "The zoom button still shows the zoom as on") + + // Scout optics zoom at full stride. + var/mob/living/carbon/human/scout = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/eyes/robotic/cyberware/longsight/scout_optics = allocate(/obj/item/organ/eyes/robotic/cyberware/longsight) + TEST_ASSERT(scout_optics.Insert(scout, special = TRUE), "Longsight staging insert was refused") + scout_optics.engage_zoom(scout) + TEST_ASSERT(!scout.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_zoom), "Scout optics slowed their bearer while zoomed") + scout_optics.stop_zoom(scout) + +/// Everything that should end a zoom does. +/datum/unit_test/voidcrew_cyberware_zoom_drops + +/datum/unit_test/voidcrew_cyberware_zoom_drops/Run() + var/obj/item/organ/eyes/robotic/cyberware/optics = zoomed() + var/datum/component/cyberware/chrome = optics.GetComponent(/datum/component/cyberware) + var/datum/action/cooldown/cyberware/optics_zoom/zoom = locate() in optics.actions + chrome.start_emp_reboot() + check_dropped(optics, "an EMP") + TEST_ASSERT(!zoom.IsAvailable(), "EMP-scrambled optics can still zoom") + chrome.tune_up() + TEST_ASSERT(zoom.IsAvailable(), "Rebooted optics can't zoom again") + + optics = zoomed() + chrome = optics.GetComponent(/datum/component/cyberware) + chrome.set_browned_out(TRUE) + check_dropped(optics, "a brownout") + chrome.set_browned_out(FALSE) + + optics = zoomed() + chrome = optics.GetComponent(/datum/component/cyberware) + optics.set_organ_damage(optics.maxHealth) + chrome.update_failing() // the bearer's life tick, which settles damage failure + check_dropped(optics, "the eyes failing") + + optics = zoomed() + optics.owner.flash_act(1) + check_dropped(optics, "a flash") + + optics = zoomed() + optics.owner.become_blind("voidcrew_zoom_test") + check_dropped(optics, "going blind") + + optics = zoomed() + optics.owner.Stun(2 SECONDS) + check_dropped(optics, "a stun") + + optics = zoomed() + optics.owner.Knockdown(2 SECONDS) + check_dropped(optics, "a knockdown") + + optics = zoomed() + optics.owner.Paralyze(2 SECONDS) + check_dropped(optics, "paralysis") + + optics = zoomed() + optics.owner.death() + check_dropped(optics, "death") + + optics = zoomed() + var/mob/living/carbon/human/bearer = optics.owner + optics.Remove(bearer, special = TRUE) + TEST_ASSERT(!HAS_TRAIT(bearer, "cyber_zoomed"), "Pulling the optics out left their bearer zoomed") + TEST_ASSERT(!bearer.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_zoom), "Pulling the optics out left the walk tax on") + +/// A fresh bearer, zoomed through a fresh pair of Spyglass optics. +/datum/unit_test/voidcrew_cyberware_zoom_drops/proc/zoomed() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/eyes/robotic/cyberware/spyglass/optics = allocate(/obj/item/organ/eyes/robotic/cyberware/spyglass) + TEST_ASSERT(optics.Insert(bearer, special = TRUE), "Spyglass staging insert was refused") + optics.engage_zoom(bearer) + TEST_ASSERT(optics.is_zoomed(), "Test fixture: the zoom didn't engage") + return optics + +/datum/unit_test/voidcrew_cyberware_zoom_drops/proc/check_dropped(obj/item/organ/eyes/robotic/cyberware/optics, cause) + var/mob/living/carbon/human/bearer = optics.owner + TEST_ASSERT(!optics.is_zoomed() && !HAS_TRAIT(bearer, "cyber_zoomed"), "The zoom survived [cause]") + TEST_ASSERT(!bearer.has_movespeed_modifier(/datum/movespeed_modifier/cyberware_zoom), "The walk tax survived [cause]") + TEST_ASSERT(!(SEND_SIGNAL(bearer, COMSIG_MOB_TRYING_TO_FIRE_GUN, null, null, FALSE, null) & COMPONENT_CANCEL_GUN_FIRE), "The gun block survived [cause]") + +/// A zoomed click never reaches a click intercept, and only while zoomed. +/datum/unit_test/voidcrew_cyberware_zoom_click + +/datum/unit_test/voidcrew_cyberware_zoom_click/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/far_body = allocate(/mob/living/carbon/human/consistent, run_loc_floor_top_right) + var/obj/item/organ/eyes/robotic/cyberware/lookout/optics = allocate(/obj/item/organ/eyes/robotic/cyberware/lookout) + TEST_ASSERT(optics.Insert(bearer, special = TRUE), "Lookout staging insert was refused") + + // Stand in for the scope's cursor catcher, pointed at the far body. + var/datum/component/scope/scope = optics.GetComponent(/datum/component/scope) + var/atom/movable/screen/fullscreen/cursor_catcher/scope/catcher = new + catcher.owner = bearer + catcher.given_turf = get_turf(far_body) + scope.tracker = catcher + optics.engage_zoom(bearer) + + var/datum/zoom_click_probe/probe = allocate(/datum/zoom_click_probe) + bearer.click_intercept = probe + + bearer.ClickOn(catcher, "") + TEST_ASSERT_EQUAL(probe.intercepted, 0, "An armed click intercept saw a zoomed click") + + // Out of the zoom, clicks are ordinary again. + optics.stop_zoom(bearer) + bearer.next_click = 0 + bearer.ClickOn(catcher, "") + TEST_ASSERT_EQUAL(probe.intercepted, 1, "Clicks stayed swallowed after the zoom ended") + + bearer.click_intercept = null + scope.tracker = null + qdel(catcher) + +/// The zoom button sits on the chrome wheel, and swapping optics with a +/// different number of buttons never moves the ear chrome beside them. +/datum/unit_test/voidcrew_cyberware_zoom_wheel + +/datum/unit_test/voidcrew_cyberware_zoom_wheel/Run() + var/mob/living/carbon/human/bearer = allocate(/mob/living/carbon/human/consistent) + var/obj/item/organ/eyes/robotic/cyberware/spyglass/cheap = allocate(/obj/item/organ/eyes/robotic/cyberware/spyglass) + TEST_ASSERT(cheap.Insert(bearer, special = TRUE), "Spyglass staging insert was refused") + var/obj/item/organ/cyberimp/cyberware/doppler/ears = allocate(/obj/item/organ/cyberimp/cyberware/doppler) + TEST_ASSERT(ears.Insert(bearer, special = TRUE), "Doppler staging insert was refused") + var/datum/action/cheap_zoom = locate(/datum/action/cooldown/cyberware/optics_zoom) in cheap.actions + var/datum/action/sonar = locate(/datum/action/item_action/organ_action/toggle) in ears.actions + TEST_ASSERT(cheap_zoom && sonar, "A staged organ is missing its button") + + var/list/abilities = get_chrome_wheel_actions(bearer) + TEST_ASSERT(cheap_zoom in abilities, "The zoom button isn't on the chrome wheel") + var/list/positions = chrome_wheel_layout(abilities) + var/list/ears_at = positions[sonar] + + // Optics with an ability of their own: three eye buttons instead of two. + var/obj/item/organ/eyes/robotic/cyberware/deadeye/milspec/link = allocate(/obj/item/organ/eyes/robotic/cyberware/deadeye/milspec) + TEST_ASSERT(link.Insert(bearer, special = TRUE), "Marksman link staging insert was refused") + abilities = get_chrome_wheel_actions(bearer) + TEST_ASSERT(!(cheap_zoom in abilities), "The pulled optics' zoom stayed on the wheel") + TEST_ASSERT(locate(/datum/action/cooldown/cyberware/optics_zoom) in abilities, "The new optics' zoom isn't on the wheel") + positions = chrome_wheel_layout(abilities) + var/list/ears_now = positions[sonar] + TEST_ASSERT(ears_at[1] == ears_now[1] && ears_at[2] == ears_now[2], "Swapping optics moved the ear chrome on the wheel") + + // All three of the link's buttons get a place of their own in the eyes + // socket: none sits on another, and none sits on any other socket's chip. + var/list/placements = chrome_wheel_placements(abilities) + var/list/eye_buttons = list() + for(var/datum/action/ability as anything in link.actions) + if(ability in abilities) + eye_buttons += ability + TEST_ASSERT_EQUAL(length(eye_buttons), 3, "The marksman link should put three buttons on the wheel") + var/list/eye_indexes = list() + for(var/datum/action/ability as anything in eye_buttons) + var/list/placement = placements[ability] + TEST_ASSERT_EQUAL(placement["socket"], "eyes", "[ability.name] is not in the eyes socket") + eye_indexes |= placement["index"] + TEST_ASSERT_EQUAL(length(eye_indexes), 3, "Two optics buttons share a place on the wheel") + for(var/datum/action/ability as anything in eye_buttons) + var/list/here = positions[ability] + for(var/datum/action/other as anything in abilities) + if(other == ability) + continue + var/list/there = positions[other] + // Chips are 22 px across (26 when pointed at). + TEST_ASSERT(sqrt((here[1] - there[1]) ** 2 + (here[2] - there[2]) ** 2) >= 24, "[ability.name] overlaps [other.name] on the wheel") + // Nor on the first places of the head socket beside it. + for(var/head_index in 1 to 2) + var/list/head_point = chrome_wheel_position("head", head_index) + TEST_ASSERT(sqrt((here[1] - head_point[1]) ** 2 + (here[2] - head_point[2]) ** 2) >= 24, "[ability.name] sits on the head socket's place [head_index]") + var/datum/action/link_zoom = locate(/datum/action/cooldown/cyberware/optics_zoom) in link.actions + TEST_ASSERT_EQUAL(link_zoom?.chrome_wheel_name(), "Zoom", "The zoom chip isn't called Zoom") + +/// Shelf prices and gates, half-list trade-ins, and cradle quotes. +/datum/unit_test/voidcrew_cyberware_zoom_catalog + +/datum/unit_test/voidcrew_cyberware_zoom_catalog/Run() + // SKU => list(item, credits, vouchers, zone permission) + var/list/skus = list( + /datum/shop_sku/ripperdoc/spyglass = list(/obj/item/organ/eyes/robotic/cyberware/spyglass, 400, 0, 0), + /datum/shop_sku/ripperdoc/assay_optics = list(/obj/item/organ/eyes/robotic/cyberware/prospector/street, 900, 0, 0), + /datum/shop_sku/ripperdoc/longsight = list(/obj/item/organ/eyes/robotic/cyberware/longsight, 2400, 0, 1), + /datum/shop_sku/ripperdoc/deadeye_milspec = list(/obj/item/organ/eyes/robotic/cyberware/deadeye/milspec, 0, 3, 2), + /datum/shop_sku/ripperdoc/lookout = list(/obj/item/organ/eyes/robotic/cyberware/lookout, 0, 3, 2), + ) + build_cyberware_price_index() + for(var/datum/shop_sku/sku_type as anything in skus) + var/list/row = skus[sku_type] + TEST_ASSERT_EQUAL(initial(sku_type.item_path), row[1], "[sku_type] sells the wrong optics") + TEST_ASSERT_EQUAL(initial(sku_type.price_credits), row[2], "[sku_type] has the wrong credit price") + TEST_ASSERT_EQUAL(initial(sku_type.price_vouchers), row[3], "[sku_type] has the wrong voucher price") + TEST_ASSERT_EQUAL(initial(sku_type.zone_permission), row[4], "[sku_type] has the wrong reputation gate") + var/obj/item/organ/optics = allocate(row[1]) + var/list/quote = get_cyberware_price(optics) + TEST_ASSERT(quote && (quote["credits"] > 0 || quote["vouchers"] > 0), "The cradle quotes no price for [row[1]]") + + // Trade-in => the SKU it pays half of. + var/list/trade_ins = list( + /datum/shop_buyback/ripperdoc/spyglass = /datum/shop_sku/ripperdoc/spyglass, + /datum/shop_buyback/ripperdoc/assay_optics = /datum/shop_sku/ripperdoc/assay_optics, + /datum/shop_buyback/ripperdoc/longsight = /datum/shop_sku/ripperdoc/longsight, + /datum/shop_buyback/ripperdoc/spyglass/street_doc = /datum/shop_sku/ripperdoc/spyglass, + /datum/shop_buyback/ripperdoc/assay_optics/street_doc = /datum/shop_sku/ripperdoc/assay_optics, + /datum/shop_buyback/ripperdoc/longsight/street_doc = /datum/shop_sku/ripperdoc/longsight, + ) + for(var/buyback_type in trade_ins) + var/datum/shop_buyback/ledger = allocate(buyback_type) + var/datum/shop_sku/sku_type = trade_ins[buyback_type] + TEST_ASSERT_EQUAL(ledger.item_path, initial(sku_type.item_path), "[buyback_type] buys something its shelf doesn't sell") + TEST_ASSERT(!ledger.match_subtypes, "[buyback_type] buys subtypes too") + TEST_ASSERT_EQUAL(ledger.pay_credits * 2, initial(sku_type.price_credits), "[buyback_type] doesn't pay half list") + TEST_ASSERT(!ledger.pay_vouchers, "[buyback_type] pays vouchers") diff --git a/voidcrew/modules/unit_tests/voidcrew_exploration_sweep.dm b/voidcrew/modules/unit_tests/voidcrew_exploration_sweep.dm new file mode 100644 index 00000000000..79fe487f620 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_exploration_sweep.dm @@ -0,0 +1,119 @@ +/// An exploration contract aimed at whatever test-room spot the test caches into its target +/datum/mission/exploration/sweep_test + // Never rolled onto a real board + weight = 0 + +/datum/mission/exploration/sweep_test/setup_target() + target = new /datum/mission_target/exploration_sweep_test(src) + return TRUE + +/// A green destination with no overmap object behind it +/datum/mission_target/exploration_sweep_test + +/datum/mission_target/exploration_sweep_test/get_zone_type() + return 1 // ZONE_GREEN + +/** + * Arriving at an exploration site starts a sweep rather than finishing the job: the + * ship holds station, drifting off pauses it without losing it, two crews on one site + * sweep independently, and the only thing a sweep turns up is an ordinary derelict + * signal that was already out there. + */ +/datum/unit_test/voidcrew_exploration_sweep + +/datum/unit_test/voidcrew_exploration_sweep/proc/make_ship() + var/obj/structure/overmap/ship/ship = allocate(/obj/structure/overmap/ship) + ship.ship_team = allocate(/datum/team/voidcrew) + ship.ship_team.ship = ship + allocated += ship.get_crew_record() + return ship + +/datum/unit_test/voidcrew_exploration_sweep/proc/make_contract(turf/site) + var/datum/mission/exploration/sweep_test/contract = allocate(/datum/mission/exploration/sweep_test) + contract.target?.cache_coords_from(site) + return contract + +/datum/unit_test/voidcrew_exploration_sweep/Run() + var/turf/site = run_loc_floor_top_right + var/turf/away = run_loc_floor_bottom_left + // Two tiles off the site: past the arrival range, still on station for the sweep + var/turf/edge = locate(site.x - 2, site.y, site.z) + TEST_ASSERT_NOTNULL(edge, "The test room must have a tile two west of its top right corner.") + + var/obj/structure/overmap/ship/first_ship = make_ship() + var/obj/structure/overmap/ship/second_ship = make_ship() + first_ship.forceMove(away) + second_ship.forceMove(away) + + var/datum/mission/exploration/sweep_test/first = make_contract(site) + var/datum/mission/exploration/sweep_test/second = make_contract(site) + TEST_ASSERT(!first.generation_failed && !second.generation_failed, "The test exploration contracts must generate.") + var/datum/mission_objective/sector_sweep/first_sweep = first.sweep + var/datum/mission_objective/sector_sweep/second_sweep = second.sweep + TEST_ASSERT_NOTNULL(first_sweep, "Exploration must build a sweep step.") + TEST_ASSERT_EQUAL(length(first.objectives), 2, "Exploration is travel, then the sweep.") + var/datum/mission_objective/goto_coords/first_approach = first.objectives[1] + TEST_ASSERT(istype(first_approach), "Exploration must still open with the travel step.") + TEST_ASSERT_NULL(first_approach.arrival_message, "The sweep announces the arrival, not the travel step.") + TEST_ASSERT_EQUAL(first.objectives[2], first_sweep, "The sweep must be the contract's last step.") + TEST_ASSERT(!first.requires_item, "Exploration is still claimed at the board, with nothing to hand over.") + + // Only the second crew's sweep can pick anything up + first_sweep.find_chance = 0 + second_sweep.find_chance = 100 + var/obj/structure/overmap/space_ruin/rumour_site = allocate(/obj/structure/overmap/space_ruin, away) + rumour_site.rare = TRUE + var/obj/structure/overmap/space_ruin/derelict = allocate(/obj/structure/overmap/space_ruin, away) + + TEST_ASSERT(first.start_mission(first_ship), "The first exploration contract must start.") + TEST_ASSERT(second.start_mission(second_ship), "The second exploration contract must start.") + TEST_ASSERT(!first_sweep.active, "The sweep waits until the ship reaches the site.") + + // Arrival: the travel step is done, the sweep runs, and the contract is not claimable yet + first_ship.forceMove(site) + TEST_ASSERT(first_approach.completed, "Reaching the site must finish the travel step.") + TEST_ASSERT(first_sweep.active && first_sweep.running, "Reaching the site must start the sweep.") + TEST_ASSERT_NOTNULL(first_sweep.finish_timer, "A running sweep must have its finish timer armed.") + TEST_ASSERT(!first.can_complete(), "Arriving alone must not make the contract claimable.") + TEST_ASSERT(!second_sweep.active, "One crew reaching the site must not start another crew's sweep.") + + second_ship.forceMove(site) + TEST_ASSERT(second_sweep.running, "The second crew's sweep must start when its own ship arrives.") + TEST_ASSERT_EQUAL(second_sweep.find_ref?.resolve(), derelict, "The sweep must pick up the plain derelict signal and pass over the rumour site.") + + // Drifting to the edge of the site keeps sweeping + first_ship.forceMove(edge) + TEST_ASSERT(first_sweep.running, "A ship two tiles off the site is still on station.") + + // Leaving pauses this crew's sweep only, and keeps it + first_ship.forceMove(away) + TEST_ASSERT(!first_sweep.running, "Leaving the site must pause the sweep.") + TEST_ASSERT_NULL(first_sweep.finish_timer, "A paused sweep must not finish on its own.") + TEST_ASSERT(first_sweep.active && !first_sweep.completed, "A paused sweep stays the contract's current step.") + TEST_ASSERT_EQUAL(first_sweep.get_progress_string(), "Sweep broken off", "The board must show the sweep as broken off.") + TEST_ASSERT(!first.can_complete(), "A broken-off sweep must not make the contract claimable.") + TEST_ASSERT(second_sweep.running, "Another crew leaving must not pause this crew's sweep.") + + first_ship.forceMove(site) + TEST_ASSERT(first_sweep.running, "Coming back must resume the sweep.") + TEST_ASSERT_NOTNULL(first_sweep.finish_timer, "A resumed sweep must re-arm its finish timer.") + + // The find is rolled once: breaking off and coming back with no luck left keeps it + second_ship.forceMove(away) + second_sweep.find_chance = 0 + second_ship.forceMove(site) + TEST_ASSERT_EQUAL(second_sweep.find_ref?.resolve(), derelict, "Breaking off and coming back must not reroll the find.") + + first_sweep.finish_sweep() + TEST_ASSERT(first_sweep.completed, "A finished sweep must complete its step.") + TEST_ASSERT(first.can_complete(), "A finished sweep must leave the contract ready to claim at the board.") + var/datum/ship_waypoint/site_mark = first_ship.get_waypoint(REF(first)) + TEST_ASSERT_NOTNULL(site_mark, "The contract's site stays on the helm until it is claimed.") + TEST_ASSERT_EQUAL(site_mark.name, "Charted sector", "The site's helm label must change once it is charted.") + TEST_ASSERT_NULL(first_ship.get_waypoint(REF(derelict)), "A sweep with no find must chart nothing extra.") + + second_sweep.finish_sweep() + TEST_ASSERT(second.can_complete(), "The second crew's contract must finish on its own sweep.") + TEST_ASSERT_NOTNULL(second_ship.get_waypoint(REF(derelict)), "The find must be charted on the sweeping crew's helm.") + TEST_ASSERT_NULL(second_ship.get_waypoint(REF(rumour_site)), "A rumour site must never be charted by a sweep.") + TEST_ASSERT_NULL(first_ship.get_waypoint(REF(derelict)), "One crew's find must not chart on another crew's helm.") diff --git a/voidcrew/modules/unit_tests/voidcrew_gorilla_gore.dm b/voidcrew/modules/unit_tests/voidcrew_gorilla_gore.dm new file mode 100644 index 00000000000..ca6bd9819d0 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_gorilla_gore.dm @@ -0,0 +1,1328 @@ +/** + * Gorilla Arms x hyperviolence (voidcrew/modules/hyperviolence_gorilla/). + * + * Fork defines are included after the tests, so these use the literal values, each with a comment + * naming the define. Finishers are driven by calling advance() directly, as the #509 finisher tests do. + */ + +/// Shared helpers; not a test itself +/datum/unit_test/voidcrew_gorilla_gore + abstract_type = /datum/unit_test/voidcrew_gorilla_gore + /// Turf -> its type before the test changed it. Put back when the test ends, however it ends. + var/list/changed_turfs + /// The outpost PvP enforcement a test swapped out, put back when it ends + var/datum/outpost_pvp_enforcement/real_enforcement + +/datum/unit_test/voidcrew_gorilla_gore/Destroy() + for(var/turf/changed as anything in changed_turfs) + clear_mess(changed) + changed.ChangeTurf(changed_turfs[changed]) + changed_turfs = null + if(real_enforcement) + GLOB.outpost_pvp_enforcement = real_enforcement + real_enforcement = null + return ..() + +/// Changes [target] to [new_type], remembering what it was so the test puts it back +/datum/unit_test/voidcrew_gorilla_gore/proc/change_turf(turf/target, new_type) + LAZYINITLIST(changed_turfs) + if(!changed_turfs[target]) + changed_turfs[target] = target.type + clear_mess(target) + return target.ChangeTurf(new_type) + +/// Puts a changed turf back now +/datum/unit_test/voidcrew_gorilla_gore/proc/restore_turf(turf/target) + var/old_type = changed_turfs?[target] + if(!old_type) + return + changed_turfs -= target + clear_mess(target) + target.ChangeTurf(old_type) + +/// Blood and other decals listen on their turf; a turf changed under them keeps the listener and the +/// decal can never be deleted cleanly. So the floor is wiped before it changes. +/datum/unit_test/voidcrew_gorilla_gore/proc/clear_mess(turf/target) + for(var/obj/effect/decal/cleanable/mess in target) + qdel(mess) + +/// The floor `dx`, `dy` tiles from the test room's bottom-left corner +/datum/unit_test/voidcrew_gorilla_gore/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +/// A human with a pair of Gorilla Arms (or Brawler myomers with [street]) at `where`, in combat mode +/datum/unit_test/voidcrew_gorilla_gore/proc/gorilla(turf/where, street = FALSE) + var/mob/living/carbon/human/consistent/bearer = allocate(/mob/living/carbon/human/consistent, where) + var/right_type = street ? /obj/item/organ/cyberimp/cyberware/gorilla_arms/street : /obj/item/organ/cyberimp/cyberware/gorilla_arms + var/left_type = street ? /obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left : /obj/item/organ/cyberimp/cyberware/gorilla_arms/left + var/obj/item/organ/right = allocate(right_type) + var/obj/item/organ/left = allocate(left_type) + TEST_ASSERT(right.Insert(bearer, special = TRUE), "Test fixture: the right arm wouldn't go in") + TEST_ASSERT(left.Insert(bearer, special = TRUE), "Test fixture: the left arm wouldn't go in") + bearer.set_combat_mode(TRUE) + return bearer + +/// The bearer's arm on [zone] +/datum/unit_test/voidcrew_gorilla_gore/proc/arm(mob/living/carbon/bearer, zone = BODY_ZONE_R_ARM) + for(var/obj/item/organ/cyberimp/cyberware/gorilla_arms/arm in bearer.organs) + if(arm.zone == zone) + return arm + +/// One punch from the right arm at [target], with the arm's own clock reset first +/datum/unit_test/voidcrew_gorilla_gore/proc/punch(mob/living/carbon/human/bearer, atom/target, zone = BODY_ZONE_R_ARM) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/fist = arm(bearer, zone) + bearer.swap_hand(zone == BODY_ZONE_L_ARM ? 1 : 2, silent = TRUE) + COOLDOWN_RESET(fist, slam_cooldown) + bearer.next_move = 0 + return fist.on_punch(bearer, target, TRUE, null) + +/// A human at `where`, stunned flat +/datum/unit_test/voidcrew_gorilla_gore/proc/downed(turf/where) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, where) + victim.Paralyze(100 SECONDS) + return victim + +/// Runs a finisher to its end through advance(), as its timer would. +/datum/unit_test/voidcrew_gorilla_gore/proc/run_to_end(datum/hv_finisher/finisher) + for(var/i in 1 to 20) + if(!finisher.running) + return + finisher.advance() + +/// Every chrome puppet left anywhere in the test room, and every body's stand-in (what shows until a client has the puppets' pictures) +/datum/unit_test/voidcrew_gorilla_gore/proc/puppets_left() + . = 0 + for(var/turf/floor in block(run_loc_floor_bottom_left, run_loc_floor_top_right)) + for(var/obj/effect/abstract/chrome_puppet/puppet in floor) + .++ + for(var/obj/effect/abstract/chrome_rig_stand_in/stand_in in floor) + .++ + +// ========================================================================= +// THE SAFE PATH +// ========================================================================= + +/// A knockback stops on the last good tile before space, glass and a door, hits a wall or a standing +/// body, and never launches from a tile without gravity. +/datum/unit_test/voidcrew_gorilla_gore/safe_path + +/datum/unit_test/voidcrew_gorilla_gore/safe_path/Run() + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(0, 0)) + // Clear floor: the full reach + var/list/plan = gorilla_plan_knockback(victim, EAST, 3) + TEST_ASSERT_EQUAL(plan[2], 3, "A clear floor didn't take the full knockback") + TEST_ASSERT_EQUAL(plan[1], spot(3, 0), "A clear knockback landed on the wrong tile") + + // Space two tiles out: stop on the tile before it + var/turf/hole = spot(2, 0) + change_turf(hole, /turf/open/space) + plan = gorilla_plan_knockback(victim, EAST, 4) + restore_turf(hole) + TEST_ASSERT_EQUAL(plan[2], 1, "A knockback went into space") + TEST_ASSERT_EQUAL(plan[3], 3, "A knockback into space didn't stop short") // GORILLA_THROW_SHORT + + // Glass in the way: stop before it, and nothing hits the glass + var/obj/structure/window/fulltile/glass = allocate(/obj/structure/window/fulltile, spot(2, 0)) + plan = gorilla_plan_knockback(victim, EAST, 4) + TEST_ASSERT_EQUAL(plan[2], 1, "A knockback went through a window") + TEST_ASSERT_EQUAL(plan[3], 3, "A knockback hit a window") // GORILLA_THROW_SHORT + qdel(glass) + + // A door: the same + var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, spot(1, 0)) + plan = gorilla_plan_knockback(victim, EAST, 4) + TEST_ASSERT_EQUAL(plan[2], 0, "A knockback went into a door") + qdel(door) + + // A wall: hit it + var/turf/wall = spot(2, 0) + change_turf(wall, /turf/closed/wall) + plan = gorilla_plan_knockback(victim, EAST, 4) + restore_turf(wall) + TEST_ASSERT_EQUAL(plan[3], 1, "A knockback into a wall didn't hit it") // GORILLA_THROW_WALL + TEST_ASSERT_EQUAL(plan[4], wall, "A knockback hit the wrong wall") + + // A standing body in the way: hit it + var/mob/living/carbon/human/consistent/bystander = allocate(/mob/living/carbon/human/consistent, spot(2, 0)) + plan = gorilla_plan_knockback(victim, EAST, 4) + TEST_ASSERT_EQUAL(plan[3], 2, "A knockback didn't hit the body in the way") // GORILLA_THROW_MOB + TEST_ASSERT_EQUAL(plan[4], bystander, "A knockback hit the wrong body") + qdel(bystander) + + // No gravity under the victim: no launch at all + var/turf/start = spot(0, 0) + change_turf(start, /turf/open/space) + plan = gorilla_plan_knockback(victim, EAST, 4) + restore_turf(start) + TEST_ASSERT_EQUAL(plan[2], 0, "A body was launched from a tile without gravity") + +// ========================================================================= +// THE PUNCH +// ========================================================================= + +/// The punch goes through #509 as one message, counts as aggression at an outpost, and the shove +/// rides the safe path. +/datum/unit_test/voidcrew_gorilla_gore/punch + +/datum/unit_test/voidcrew_gorilla_gore/punch/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + real_enforcement = GLOB.outpost_pvp_enforcement + var/datum/outpost_pvp_enforcement/gorilla_spy/spy = new + GLOB.outpost_pvp_enforcement = spy + var/hurt_before = victim.getBruteLoss() + var/punched = punch(bearer, victim) + // The blow lands when the fist is there: 0.1 s (GORILLA_THRUST_LANDS) + sleep(0.3 SECONDS) + GLOB.outpost_pvp_enforcement = real_enforcement + real_enforcement = null + TEST_ASSERT_EQUAL(punched, COMPONENT_CANCEL_ATTACK_CHAIN, "The Gorilla arm didn't take the punch") + TEST_ASSERT(victim.getBruteLoss() > hurt_before, "The piston punch did no damage") + TEST_ASSERT_NULL(victim.hv_hit, "The punch left its attack line held") + TEST_ASSERT(length(spy.hits) && spy.hits[1] == victim, "A piston punch wasn't counted as aggression") + qdel(spy) + + // The shove never goes into a hazard (lava here: a space hole would vent the room and the wind would do it) + var/turf/hole = spot(2, 0) + victim.forceMove(spot(1, 0)) + victim.set_resting(FALSE, instant = TRUE) + change_turf(hole, /turf/open/lava/smooth) + punch(bearer, victim) + sleep(1 SECONDS) + var/landed_in = victim.loc + restore_turf(hole) + TEST_ASSERT_NOTEQUAL(landed_in, hole, "The piston punch knocked someone into lava") + +/// Records aggression instead of judging it +/datum/outpost_pvp_enforcement/gorilla_spy + var/list/hits = list() + +/datum/outpost_pvp_enforcement/gorilla_spy/New() + return + +/datum/outpost_pvp_enforcement/gorilla_spy/register_pvp_aggression(mob/living/victim, mob/living/offender) + hits += victim + +/// Three piston hits on one arm snap it (four from Brawler myomers); heavy armour or the Atlas frame stops it. +/datum/unit_test/voidcrew_gorilla_gore/bone_breakers + +/datum/unit_test/voidcrew_gorilla_gore/bone_breakers/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + for(var/i in 1 to 2) + gorilla_add_strain(victim, BODY_ZONE_L_ARM, bearer, 3, null, EAST) + TEST_ASSERT_NULL(arm.get_wound_type(/datum/wound/blunt/bone/critical), "An arm snapped before the third hit") + TEST_ASSERT(gorilla_add_strain(victim, BODY_ZONE_L_ARM, bearer, 3, null, EAST), "The third piston hit didn't snap the arm") + TEST_ASSERT_NOTNULL(arm.get_wound_type(/datum/wound/blunt/bone/critical), "A snapped arm has no compound fracture") + TEST_ASSERT("snap_l_arm_bone" in victim.hv_gore_states() + gorilla_snap_states(victim), "A snapped arm shows no bone") + + // The head never snaps + for(var/i in 1 to 4) + TEST_ASSERT(!gorilla_add_strain(victim, BODY_ZONE_HEAD, bearer, 3, null, EAST), "A head snapped") + + // Brawler myomers take four + var/mob/living/carbon/human/consistent/second = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + for(var/i in 1 to 3) + TEST_ASSERT(!gorilla_add_strain(second, BODY_ZONE_R_LEG, bearer, 4, null, EAST), "A Brawler snapped a leg early") + TEST_ASSERT(gorilla_add_strain(second, BODY_ZONE_R_LEG, bearer, 4, null, EAST), "The fourth Brawler hit didn't snap the leg") + + // Heavy melee armour on the limb stops it + var/mob/living/carbon/human/consistent/armoured = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + armoured.physiology.armor = armoured.physiology.armor.generate_new_with_modifiers(list(MELEE = 60)) + for(var/i in 1 to 3) + gorilla_add_strain(armoured, BODY_ZONE_R_ARM, bearer, 3, null, EAST) + TEST_ASSERT_NULL(armoured.get_bodypart(BODY_ZONE_R_ARM).get_wound_type(/datum/wound/blunt/bone/critical), "Heavy armour didn't stop a snap") + + // So does the Atlas frame + var/mob/living/carbon/human/consistent/framed = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + var/obj/item/organ/atlas = allocate(/obj/item/organ/cyberimp/cyberware/atlas) + TEST_ASSERT(atlas.Insert(framed, special = TRUE), "Test fixture: the Atlas frame wouldn't go in") + for(var/i in 1 to 3) + gorilla_add_strain(framed, BODY_ZONE_R_ARM, bearer, 3, null, EAST) + TEST_ASSERT_NULL(framed.get_bodypart(BODY_ZONE_R_ARM).get_wound_type(/datum/wound/blunt/bone/critical), "The Atlas frame let an arm snap") + +/// The snapped-bone states drawn on [victim] now +/proc/gorilla_snap_states(mob/living/carbon/victim) + . = list() + for(var/image/snap as anything in victim.gorilla_snap_overlays) + . += snap.icon_state + +/// A grabbed body is hurled once per grab-move cooldown; the next grabbed punch holds them. +/datum/unit_test/voidcrew_gorilla_gore/hurl_cooldown + +/datum/unit_test/voidcrew_gorilla_gore/hurl_cooldown/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + victim.grabbedby(bearer, supress_message = TRUE) + victim.grabbedby(bearer, supress_message = TRUE) + TEST_ASSERT(bearer.grab_state >= GRAB_AGGRESSIVE, "Test fixture: no aggressive grab") + punch(bearer, victim) + sleep(0.3 SECONDS) // the fist arrives + TEST_ASSERT(!TIMER_COOLDOWN_FINISHED(bearer, "gorilla_grab_move"), "A hurl didn't start the grab-move cooldown") // COOLDOWN_GORILLA_GRAB_MOVE + sleep(1 SECONDS) + TEST_ASSERT_NOTEQUAL(victim.loc, spot(1, 0), "A grabbed body wasn't hurled") + // Grab them again: no second hurl inside the cooldown + victim.forceMove(spot(1, 0)) + victim.SetAllImmobility(0) + victim.grabbedby(bearer, supress_message = TRUE) + victim.grabbedby(bearer, supress_message = TRUE) + punch(bearer, victim) + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(victim.loc, spot(1, 0), "A grabbed body was hurled twice inside the cooldown") + +/// A human at `where` in [bearer]'s aggressive grab +/datum/unit_test/voidcrew_gorilla_gore/proc/held_by(mob/living/carbon/human/bearer, turf/where) + var/mob/living/carbon/human/consistent/held = allocate(/mob/living/carbon/human/consistent, where) + held.grabbedby(bearer, supress_message = TRUE) + held.grabbedby(bearer, supress_message = TRUE) + TEST_ASSERT(bearer.pulling == held && bearer.grab_state >= GRAB_AGGRESSIVE, "Test fixture: no aggressive grab") + return held + +/// A click on the floor under a held body slams them into it; a table click slams them onto the table +/// instead of caving the table in. Nothing happens to anyone until the body comes down. +/datum/unit_test/voidcrew_gorilla_gore/slam + +/datum/unit_test/voidcrew_gorilla_gore/slam/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/victim = held_by(bearer, spot(1, 0)) + var/hurt_before = victim.getBruteLoss() + TEST_ASSERT_EQUAL(punch(bearer, spot(1, 0)), COMPONENT_CANCEL_ATTACK_CHAIN, "A floor click while grabbing wasn't a slam") + // On the way up: the grab is held, the bearer stays put, and the body is unhurt and still on its feet + TEST_ASSERT_EQUAL(bearer.pulling, victim, "The slam let go before the body came down") + TEST_ASSERT(HAS_TRAIT_FROM(bearer, TRAIT_IMMOBILIZED, "gorilla_slam"), "The bearer can walk off in the middle of a slam") // GORILLA_SLAM_TRAIT + TEST_ASSERT_EQUAL(victim.getBruteLoss(), hurt_before, "The slam hurt them before it landed") + TEST_ASSERT(victim.body_position == STANDING_UP, "The slam floored them before it landed") + TEST_ASSERT(puppets_left() > 0, "The slam posed nobody") + TEST_ASSERT_NOTNULL(victim.get_filter("chrome_rig_hide"), "The real body shows under its puppet") // CHROME_RIG_HIDE_FILTER + sleep(0.5 SECONDS) // 0.44 s to the impact + TEST_ASSERT_NULL(bearer.pulling, "The slam kept the grab") + TEST_ASSERT(victim.getBruteLoss() > hurt_before, "The floor slam did no damage") + TEST_ASSERT(victim.body_position == LYING_DOWN, "The floor slam didn't knock them down") + // On its back, head at the feet of a bearer seen from the side + TEST_ASSERT_EQUAL(victim.dir, SOUTH, "A slammed body didn't land on its back") + TEST_ASSERT_EQUAL(victim.lying_angle, 270, "A body slammed to the east doesn't lie with its head at the bearer's feet") // LYING_ANGLE_WEST + sleep(0.4 SECONDS) // 0.70 s in all + TEST_ASSERT_EQUAL(puppets_left(), 0, "The slam left puppets standing") + TEST_ASSERT_NULL(victim.get_filter("chrome_rig_hide"), "A slammed body stayed hidden") // CHROME_RIG_HIDE_FILTER + TEST_ASSERT_NULL(bearer.get_filter("chrome_rig_hide"), "The bearer stayed hidden after a slam") // CHROME_RIG_HIDE_FILTER + TEST_ASSERT(!HAS_TRAIT_FROM(bearer, TRAIT_IMMOBILIZED, "gorilla_slam"), "The bearer is still held in place after a slam") // GORILLA_SLAM_TRAIT + TEST_ASSERT_NULL(bearer.gorilla_slam, "The slam never ended for the bearer") + TEST_ASSERT_NULL(victim.gorilla_slam, "The slam never ended for the body") + + // The table. A head-aimed one lands face down. + var/mob/living/carbon/human/table_bearer = gorilla(spot(0, 3)) + var/mob/living/carbon/human/consistent/table_victim = held_by(table_bearer, spot(1, 3)) + var/obj/structure/table/table = allocate(/obj/structure/table, spot(1, 4)) + var/table_before = table.get_integrity() + table_bearer.zone_selected = BODY_ZONE_HEAD + TEST_ASSERT_EQUAL(punch(table_bearer, table), COMPONENT_CANCEL_ATTACK_CHAIN, "A table click while grabbing wasn't a slam") + TEST_ASSERT_EQUAL(table_victim.loc, spot(1, 3), "The body was on the table before the slam landed") + sleep(0.5 SECONDS) + TEST_ASSERT_EQUAL(table_victim.loc, spot(1, 4), "The slam didn't put them on the table") + TEST_ASSERT(QDELETED(table) || table.get_integrity() <= table_before - 50, "The table didn't take the slam") // GORILLA_SLAM_TABLE_BREAK + TEST_ASSERT_EQUAL(table_victim.dir, NORTH, "A head-aimed table slam didn't land face down") + +/// A slam is called off before it lands if the bearer is stunned, loses the grab, or the body is moved or can't be put +/// where it was going: the body is unhurt and on its feet, the puppets go, and the bearer is free to move. +/datum/unit_test/voidcrew_gorilla_gore/slam_called_off + +/datum/unit_test/voidcrew_gorilla_gore/slam_called_off/Run() + // The bearer is stunned on the way up + var/mob/living/carbon/human/stunned = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/first = held_by(stunned, spot(1, 0)) + TEST_ASSERT_EQUAL(punch(stunned, spot(1, 0)), COMPONENT_CANCEL_ATTACK_CHAIN, "Test fixture: no slam") + TEST_ASSERT_NOTNULL(stunned.gorilla_slam, "Test fixture: the slam didn't start") + stunned.Paralyze(2 SECONDS) + TEST_ASSERT(!HAS_TRAIT_FROM(stunned, TRAIT_IMMOBILIZED, "gorilla_slam"), "A called-off slam still holds the bearer in place") // GORILLA_SLAM_TRAIT + TEST_ASSERT_NULL(stunned.get_filter("chrome_rig_hide"), "A stunned bearer stayed hidden behind his puppets") // CHROME_RIG_HIDE_FILTER + sleep(0.7 SECONDS) + TEST_ASSERT_EQUAL(first.getBruteLoss(), 0, "A slam landed after the bearer was stunned") + TEST_ASSERT_EQUAL(first.getStaminaLoss(), 0, "A called-off slam winded them") + TEST_ASSERT(first.body_position == STANDING_UP, "A called-off slam knocked them down") + TEST_ASSERT_EQUAL(first.loc, spot(1, 0), "A called-off slam moved the body") + TEST_ASSERT_EQUAL(puppets_left(), 0, "A called-off slam left puppets standing") + TEST_ASSERT_NULL(first.get_filter("chrome_rig_hide"), "A body put back down stayed hidden") // CHROME_RIG_HIDE_FILTER + TEST_ASSERT_NULL(first.gorilla_slam, "A called-off slam never ended for the body") + TEST_ASSERT_NULL(stunned.gorilla_slam, "A called-off slam never ended for the bearer") + + // The grab is lost on the way up + var/mob/living/carbon/human/dropper = gorilla(spot(0, 2)) + var/mob/living/carbon/human/consistent/second = held_by(dropper, spot(1, 2)) + TEST_ASSERT_EQUAL(punch(dropper, spot(1, 2)), COMPONENT_CANCEL_ATTACK_CHAIN, "Test fixture: no second slam") + dropper.stop_pulling() + sleep(0.7 SECONDS) + TEST_ASSERT_EQUAL(second.getBruteLoss(), 0, "A slam landed after the grab was lost") + TEST_ASSERT(second.body_position == STANDING_UP, "A slam with the grab lost knocked them down") + TEST_ASSERT(!HAS_TRAIT_FROM(dropper, TRAIT_IMMOBILIZED, "gorilla_slam"), "A bearer who lost the grab is still held in place") // GORILLA_SLAM_TRAIT + TEST_ASSERT_NULL(second.get_filter("chrome_rig_hide"), "A body that slipped the grab stayed hidden") // CHROME_RIG_HIDE_FILTER + + // The body is pulled away on the way up + var/mob/living/carbon/human/robbed = gorilla(spot(0, 4)) + var/mob/living/carbon/human/consistent/third = held_by(robbed, spot(1, 4)) + TEST_ASSERT_EQUAL(punch(robbed, spot(1, 4)), COMPONENT_CANCEL_ATTACK_CHAIN, "Test fixture: no third slam") + third.forceMove(spot(4, 4)) + TEST_ASSERT_NULL(third.get_filter("chrome_rig_hide"), "A body taken away stayed hidden") // CHROME_RIG_HIDE_FILTER + sleep(0.7 SECONDS) + TEST_ASSERT_EQUAL(third.getBruteLoss(), 0, "A slam landed on a body that was taken away") + TEST_ASSERT_EQUAL(third.loc, spot(4, 4), "A slam brought back a body that was taken away") + TEST_ASSERT_NULL(robbed.gorilla_slam, "A slam on a body taken away never ended") + + // Something blocks the table before the body gets there: it comes down where it stood + var/mob/living/carbon/human/blocked = gorilla(spot(3, 0)) + var/mob/living/carbon/human/consistent/fourth = held_by(blocked, spot(4, 0)) + var/obj/structure/table/table = allocate(/obj/structure/table, spot(3, 1)) + var/table_before = table.get_integrity() + TEST_ASSERT_EQUAL(punch(blocked, table), COMPONENT_CANCEL_ATTACK_CHAIN, "Test fixture: no table slam") + allocate(/obj/structure/window/reinforced/fulltile, spot(3, 1)) + sleep(0.7 SECONDS) + TEST_ASSERT_EQUAL(fourth.loc, spot(4, 0), "A body went through a window onto a table") + TEST_ASSERT_EQUAL(fourth.getBruteLoss(), 0, "A slam that couldn't reach the table hurt them") + TEST_ASSERT_EQUAL(table.get_integrity(), table_before, "A slam that couldn't reach the table hit it") + TEST_ASSERT_EQUAL(puppets_left(), 0, "A slam that couldn't reach the table left puppets standing") + +// ========================================================================= +// WALL IMPACTS (owner D38) +// ========================================================================= + +/// The mark a wall impact leaves follows the injury: a dent with no broken skin, a floor half-moon and +/// edge smear for a bleeding cut, a spray and runs for a heavy one. +/datum/unit_test/voidcrew_gorilla_gore/wall_impact + +/datum/unit_test/voidcrew_gorilla_gore/wall_impact/Run() + var/turf/wall_spot = spot(2, 0) + change_turf(wall_spot, /turf/closed/wall) + var/turf/closed/wall/wall = spot(2, 0) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + + // Unhurt: a dent, no blood + TEST_ASSERT_EQUAL(victim.gorilla_splat_kind(), 1, "An unhurt body doesn't dent") // GORILLA_SPLAT_DENT + var/dents_before = LAZYLEN(wall.dent_decals) + victim.gorilla_wall_impact(wall, null) + TEST_ASSERT_EQUAL(LAZYLEN(wall.dent_decals), dents_before + 1, "An unhurt impact left no dent") + + // A bleeding cut: the half-moon and the edge + var/obj/item/bodypart/chest = victim.get_bodypart(BODY_ZONE_CHEST) + var/datum/wound/slash/flesh/moderate/cut = new + cut.apply_wound(chest, silent = TRUE) + TEST_ASSERT_EQUAL(victim.gorilla_splat_kind(), 2, "A bleeding cut doesn't splash") // GORILLA_SPLAT_EDGE + victim.gorilla_wall_impact(wall, null) + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/gorilla_splash) in spot(1, 0), "A bleeding impact left no half-moon") + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/edge) in spot(1, 0), "A bleeding impact left no edge smear") + + // A heavy cut: the spray and the runs + var/datum/wound/slash/flesh/severe/gash = new + gash.apply_wound(victim.get_bodypart(BODY_ZONE_L_ARM), silent = TRUE) + TEST_ASSERT_EQUAL(victim.gorilla_splat_kind(), 3, "A heavy cut doesn't spray") // GORILLA_SPLAT_SPRAY + victim.gorilla_wall_impact(wall, null) + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray) in spot(1, 0), "A heavy impact left no spray") + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/runs) in spot(1, 0), "A heavy impact left no runs") + // Twice on the same wall face refreshes, never stacks + victim.gorilla_wall_impact(wall, null) + var/sprays = 0 + for(var/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/spray in spot(1, 0)) + if(spray.type == /obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray) + sprays++ + TEST_ASSERT_EQUAL(sprays, 1, "Wall sprays stacked") + +/// A Gorilla throw's wall crash wounds through tg (owner D48): a shove only dents; a haymaker into a wall +/// wounds an unhurt body and the mark follows the wound it caused; an already-bleeding body sprays; a hurl +/// through the real throw_impact deals the crash's own damage instead of tg's random-limb crash. +/datum/unit_test/voidcrew_gorilla_gore/wall_crash + +/datum/unit_test/voidcrew_gorilla_gore/wall_crash/Run() + var/turf/wall_spot = spot(2, 0) + change_turf(wall_spot, /turf/closed/wall) + var/turf/closed/wall/wall = spot(2, 0) + var/mob/living/carbon/human/consistent/thrower = allocate(/mob/living/carbon/human/consistent, spot(0, 2)) + + // A light shove: a dent, nothing else + var/mob/living/carbon/human/consistent/shoved = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/datum/gorilla_flight/shove = new(shoved, thrower, FALSE, FALSE, 1) // GORILLA_IMPACT_SHOVE + var/dents_before = LAZYLEN(wall.dent_decals) + shoved.gorilla_wall_impact(wall, shove) + shove.end() + TEST_ASSERT_EQUAL(LAZYLEN(wall.dent_decals), dents_before + 1, "A shove into a wall left no dent") + TEST_ASSERT_EQUAL(shoved.getBruteLoss(), 0, "A shove into a wall did damage") + TEST_ASSERT_EQUAL(length(shoved.all_wounds), 0, "A shove into a wall wounded") + TEST_ASSERT(!shoved.IsParalyzed(), "A shove into a wall knocked them down") + TEST_ASSERT_NULL(locate(/obj/effect/decal/cleanable/blood/hv_spray) in spot(1, 0), "A shove into a wall left blood") + qdel(shoved) + + // A haymaker into the wall: a real wound on an unhurt body, and the mark that wound calls for. The roll + // is tg's, so a few fresh bodies get a go; each must match its own wounds. + var/wounded_one = FALSE + for(var/attempt in 1 to 6) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/datum/gorilla_flight/flight = new(victim, thrower, TRUE, FALSE) + TEST_ASSERT_EQUAL(flight.impact, 3, "A haymaker flight isn't a haymaker impact") // GORILLA_IMPACT_HAYMAKER + victim.gorilla_wall_impact(wall, flight) + flight.end() + TEST_ASSERT(victim.getBruteLoss() > 0, "A haymaker into a wall did no damage") + TEST_ASSERT(victim.IsParalyzed(), "A haymaker into a wall didn't knock them down") + var/kind = victim.gorilla_splat_kind() + if(kind == 3) // GORILLA_SPLAT_SPRAY + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/runs) in spot(1, 0), "A haymaker that tore a heavy wound left no spray") + else if(kind == 2) // GORILLA_SPLAT_EDGE + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/gorilla_splash) in spot(1, 0), "A haymaker that split the skin left no half-moon") + else + TEST_ASSERT_NULL(locate(/obj/effect/decal/cleanable/blood/hv_spray) in spot(1, 0), "A haymaker with no broken skin left blood") + if(length(victim.all_wounds)) + wounded_one = TRUE + qdel(victim) + clear_mess(spot(1, 0)) + if(wounded_one) + break + TEST_ASSERT(wounded_one, "Six haymakers into a wall never wounded an unhurt body") + + // Already bleeding hard: the spray up the wall + var/mob/living/carbon/human/consistent/bleeder = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/datum/wound/slash/flesh/severe/gash = new + gash.apply_wound(bleeder.get_bodypart(BODY_ZONE_L_ARM), silent = TRUE) + var/datum/gorilla_flight/slam = new(bleeder, thrower, TRUE, FALSE) + bleeder.gorilla_wall_impact(wall, slam) + slam.end() + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray) in spot(1, 0), "A bleeding body slammed into a wall left no spray") + TEST_ASSERT_NOTNULL(locate(/obj/effect/decal/cleanable/blood/hv_spray/wall/gorilla_spray/runs) in spot(1, 0), "A bleeding body slammed into a wall left no runs") + qdel(bleeder) + clear_mess(spot(1, 0)) + + // A hurl through the real impact: the crash's own 12 brute, not tg's random-limb crash on top + var/mob/living/carbon/human/consistent/hurled = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/datum/gorilla_flight/hurl = new(hurled, thrower, FALSE, FALSE, 2) // GORILLA_IMPACT_HURL + var/datum/thrownthing/throw_datum = new(hurled, wall, EAST, 1, 2, thrower, FALSE, MOVE_FORCE_STRONG, FALSE, null, null) + hurled.throw_impact(wall, throw_datum) + TEST_ASSERT(!throw_datum.gentle, "The wall crash left the throw marked gentle") + TEST_ASSERT_EQUAL(hurled.getBruteLoss(), 12, "A hurl into a wall did the wrong damage") // GORILLA_WALL_HURL_BLUNT + GORILLA_WALL_HURL_EDGE + TEST_ASSERT(hurled.IsParalyzed(), "A hurl into a wall didn't knock them down") + hurl.end() + qdel(throw_datum) + +// ========================================================================= +// THE HAYMAKER +// ========================================================================= + +/// Each real arm winds up a haymaker; the Brawler has none. A wound-up release hits the body in +/// front, sends it flying and spends the pistons; a swing at nothing staggers; a vent costs less. +/datum/unit_test/voidcrew_gorilla_gore/haymaker + +/datum/unit_test/voidcrew_gorilla_gore/haymaker/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/datum/action/cooldown/cyberware/gorilla_haymaker/right_haymaker = locate() in arm(bearer, BODY_ZONE_R_ARM).actions + var/datum/action/cooldown/cyberware/gorilla_haymaker/left_haymaker = locate() in arm(bearer, BODY_ZONE_L_ARM).actions + TEST_ASSERT_NOTNULL(right_haymaker, "The right Gorilla arm has no haymaker") + TEST_ASSERT_NOTNULL(left_haymaker, "The left Gorilla arm has no haymaker") + TEST_ASSERT_EQUAL(right_haymaker.owner, bearer, "The haymaker wasn't granted") + var/mob/living/carbon/human/brawler = gorilla(spot(4, 4), street = TRUE) + TEST_ASSERT_NULL(locate(/datum/action/cooldown/cyberware/gorilla_haymaker) in arm(brawler).actions, "Brawler myomers have a haymaker") + + // Wind up, then let go at someone in front + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + bearer.setDir(EAST) + right_haymaker.Trigger(bearer) + TEST_ASSERT(right_haymaker.charging(), "Triggering the haymaker didn't wind it up") + TEST_ASSERT_NOTNULL(bearer.has_status_effect(/datum/status_effect/gorilla_windup), "The wind-up has no status effect") + TEST_ASSERT(bearer.has_movespeed_modifier(/datum/movespeed_modifier/gorilla_windup), "The wind-up doesn't slow") + // The lean: a pixel back at once, turning with the bearer, GORILLA_HAYMAKER_LEAN and a tremble at full charge + var/datum/status_effect/gorilla_windup/windup = bearer.has_status_effect(/datum/status_effect/gorilla_windup) + TEST_ASSERT_EQUAL(bearer.has_offset("gorilla_windup", PIXEL_X_OFFSET), -1, "The wind-up doesn't start a pixel back from an east facing") + bearer.setDir(NORTH) + TEST_ASSERT_EQUAL(bearer.has_offset("gorilla_windup", PIXEL_X_OFFSET), 0, "A turn left the old lean behind") + TEST_ASSERT_EQUAL(bearer.has_offset("gorilla_windup", PIXEL_Z_OFFSET), -1, "Facing away, the lean isn't down the screen") + bearer.setDir(EAST) + right_haymaker.charge_started = world.time - 2 SECONDS + windup.tick(0.2) + TEST_ASSERT_EQUAL(bearer.has_offset("gorilla_windup", PIXEL_X_OFFSET), -4, "A full charge doesn't lean all the way back") // GORILLA_HAYMAKER_LEAN + TEST_ASSERT(bearer.has_offset("gorilla_windup_tremble", PIXEL_W_OFFSET), "A full charge doesn't tremble") + var/hurt_before = victim.getBruteLoss() + right_haymaker.InterceptClickOn(bearer, null, victim) + TEST_ASSERT(!right_haymaker.charging(), "The haymaker still winds up after the release") + TEST_ASSERT_NULL(bearer.has_status_effect(/datum/status_effect/gorilla_windup), "The wind-up outlived the release") + TEST_ASSERT(!bearer.has_movespeed_modifier(/datum/movespeed_modifier/gorilla_windup), "The wind-up's slow outlived it") + TEST_ASSERT(!bearer.has_offset("gorilla_windup"), "The wind-up's lean outlived it") + TEST_ASSERT(!bearer.has_offset("gorilla_windup_tremble"), "The wind-up's tremble outlived it") + // The blow lands when the thrown fist does (GORILLA_HAYMAKER_THROW) + TEST_ASSERT_EQUAL(victim.getBruteLoss(), hurt_before, "The haymaker landed before its fist was thrown") + sleep(0.2 SECONDS) + TEST_ASSERT(victim.getBruteLoss() - hurt_before >= 20, "A full haymaker hit for too little") // GORILLA_HAYMAKER_MIN_DAMAGE + TEST_ASSERT(!TIMER_COOLDOWN_FINISHED(bearer, "gorilla_pistons"), "The haymaker didn't spend the pistons") // COOLDOWN_GORILLA_PISTONS + TEST_ASSERT(!left_haymaker.IsAvailable(), "The other arm's haymaker didn't share the cooldown") + sleep(2 SECONDS) + TEST_ASSERT_NOTEQUAL(victim.loc, spot(1, 0), "The haymaker didn't send them flying") + + // A swing at nothing staggers and still spends the pistons + var/mob/living/carbon/human/whiffer = gorilla(spot(0, 4)) + var/datum/action/cooldown/cyberware/gorilla_haymaker/whiff = locate() in arm(whiffer).actions + whiffer.setDir(EAST) + whiff.Trigger(whiffer) + whiff.charge_started = world.time - 1 SECONDS + whiff.InterceptClickOn(whiffer, null, spot(1, 4)) + TEST_ASSERT_NOTNULL(whiffer.has_status_effect(/datum/status_effect/staggered), "A whiffed haymaker didn't stagger") + TEST_ASSERT(!TIMER_COOLDOWN_FINISHED(whiffer, "gorilla_pistons"), "A whiff didn't spend the pistons") + + // Called off: the pistons vent for a shorter while + var/mob/living/carbon/human/venter = gorilla(spot(2, 2)) + var/datum/action/cooldown/cyberware/gorilla_haymaker/vent = locate() in arm(venter).actions + vent.Trigger(venter) + TEST_ASSERT(vent.charging(), "Test fixture: the third haymaker didn't wind up") + vent.unset_click_ability(venter, refund_cooldown = TRUE) + TEST_ASSERT(!vent.charging(), "Calling the haymaker off left it winding up") + var/left = S_TIMER_COOLDOWN_TIMELEFT(venter, "gorilla_pistons") + TEST_ASSERT(left > 0 && left <= 5 SECONDS, "A vent cost the wrong cooldown ([left])") // GORILLA_PISTONS_VENTED + +/** + * The piston punch's arm: the blow waits for the fist; for the punch and no longer, the punching arm is a puppet over a + * body with that arm masked out; a bearer who looks the same is not pictured again; the arm steps with a bearer who + * steps and comes down when they turn; and a bearer who can't be drawn still lands the blow. + */ +/datum/unit_test/voidcrew_gorilla_gore/punch_thrust + +/datum/unit_test/voidcrew_gorilla_gore/punch_thrust/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + bearer.setDir(EAST) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/fist = arm(bearer) + var/obj/item/bodypart/hand = bearer.get_bodypart(BODY_ZONE_R_ARM) + var/filters_before = length(bearer.filters) + var/hurt_before = victim.getBruteLoss() + TEST_ASSERT(fist.piston_hit(bearer, victim, hand, BODY_ZONE_CHEST), "The piston punch wasn't thrown") + TEST_ASSERT_EQUAL(victim.getBruteLoss(), hurt_before, "The piston punch landed before its fist did") + TEST_ASSERT_NOTNULL(bearer.gorilla_thrust, "The punch drew no arm") + TEST_ASSERT_EQUAL(puppets_left(), 2, "A punch seen from the side isn't an arm and the torso under it") + TEST_ASSERT_EQUAL(length(bearer.filters), filters_before + 1, "The real arm wasn't masked out under its puppet") + sleep(0.3 SECONDS) + TEST_ASSERT(victim.getBruteLoss() > hurt_before, "The piston punch never landed") + sleep(0.4 SECONDS) + TEST_ASSERT_NULL(bearer.gorilla_thrust, "The punch's arm outlived the punch") + TEST_ASSERT_EQUAL(puppets_left(), 0, "The punch left a puppet behind") + TEST_ASSERT_EQUAL(length(bearer.filters), filters_before, "The mask on the real arm outlived the punch") + var/matrix/rested = bearer.transform + TEST_ASSERT(rested.a == 1 && !rested.b && !rested.c && !rested.d && rested.e == 1 && !rested.f, "The lunge left the bearer off their feet") + + // The same look is not pictured twice; the arm walks with its bearer and comes down on a turn + var/mob/living/carbon/human/walker = gorilla(spot(0, 2)) + var/mob/living/carbon/human/consistent/bag = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + ADD_TRAIT(bag, TRAIT_GODMODE, TRAIT_SOURCE_UNIT_TESTS) + bag.anchored = TRUE + walker.setDir(EAST) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/walker_fist = arm(walker) + var/obj/item/bodypart/walker_hand = walker.get_bodypart(BODY_ZONE_R_ARM) + walker_fist.piston_hit(walker, bag, walker_hand, BODY_ZONE_HEAD) + var/datum/gorilla_arm_look/look = walker.gorilla_arm_looks?["[EAST]"] + TEST_ASSERT_NOTNULL(look, "The punch kept no picture of its bearer") + sleep(0.6 SECONDS) + walker_fist.piston_hit(walker, bag, walker_hand, BODY_ZONE_HEAD) + TEST_ASSERT_EQUAL(walker.gorilla_arm_looks["[EAST]"], look, "A second punch pictured a bearer who hadn't changed") + var/datum/gorilla_thrust/thrust = walker.gorilla_thrust + TEST_ASSERT_NOTNULL(thrust, "The second punch drew no arm") + walker.forceMove(spot(0, 3)) + TEST_ASSERT_EQUAL(walker.gorilla_thrust, thrust, "A step took the arm down") + for(var/obj/effect/abstract/chrome_puppet/puppet as anything in thrust.pieces) + TEST_ASSERT_EQUAL(puppet.loc, walker.loc, "The arm didn't step with its bearer") + walker.setDir(NORTH) + TEST_ASSERT_NULL(walker.gorilla_thrust, "A turn left the old facing's arm up") + TEST_ASSERT_EQUAL(puppets_left(), 0, "A turn left a puppet behind") + sleep(0.6 SECONDS) + + // A bearer on the floor can't be drawn: tg's lunge, and the blow still lands + var/mob/living/carbon/human/floored = gorilla(spot(2, 4)) + var/mob/living/carbon/human/consistent/kicked = allocate(/mob/living/carbon/human/consistent, spot(3, 4)) + floored.set_resting(TRUE, silent = TRUE, instant = TRUE) + var/kicked_before = kicked.getBruteLoss() + arm(floored).piston_hit(floored, kicked, floored.get_bodypart(BODY_ZONE_R_ARM), BODY_ZONE_CHEST) + TEST_ASSERT_NULL(floored.gorilla_thrust, "A bearer lying down drew an arm") + sleep(0.3 SECONDS) + TEST_ASSERT(kicked.getBruteLoss() > kicked_before, "A punch from the floor never landed") + + // The first punch a picture is taken for lands as soon as any other + var/mob/living/carbon/human/fresh = gorilla(spot(3, 2)) + var/mob/living/carbon/human/consistent/dummy = allocate(/mob/living/carbon/human/consistent, spot(4, 2)) + ADD_TRAIT(dummy, TRAIT_GODMODE, TRAIT_SOURCE_UNIT_TESTS) + dummy.anchored = TRUE + fresh.setDir(EAST) + var/first_wait = gorilla_thrust(fresh, dummy, BODY_ZONE_R_ARM, BODY_ZONE_CHEST) + TEST_ASSERT_NOTNULL(fresh.gorilla_thrust, "Test fixture: the first punch drew no arm") + TEST_ASSERT_EQUAL(first_wait, 0.1 SECONDS, "The first punch of a new look lands late") // GORILLA_THRUST_LANDS + sleep(0.6 SECONDS) + TEST_ASSERT_EQUAL(gorilla_thrust(fresh, dummy, BODY_ZONE_R_ARM, BODY_ZONE_CHEST), first_wait, "A later punch lands at another time than the first") + sleep(0.6 SECONDS) + + // The fist reaches the part it is thrown at, down to the leg of a body beside its bearer + var/datum/gorilla_arm_look/fresh_look = fresh.gorilla_arm_looks?["[EAST]"] + var/datum/chrome_rig/fresh_rig = fresh_look?.rig + TEST_ASSERT_NOTNULL(fresh_rig, "Test fixture: the punch kept no picture") + for(var/zone in list(BODY_ZONE_HEAD, BODY_ZONE_CHEST, BODY_ZONE_L_LEG)) + var/list/point = gorilla_fist_target(fresh, dummy, zone) + // GORILLA_THRUST_LUNGE_MIN, GORILLA_THRUST_LUNGE_MAX, GORILLA_THRUST_TIP, GORILLA_SWING_EASY_LENGTH, GORILLA_SWING_MAX_LENGTH + var/list/reach = chrome_swing_reach(fresh_rig, "r", point[1], point[2], list(1, 0), 8, 16, 15, 1.9, 3.3, -90) + var/list/fist_at = fresh_rig.hand_at("r", list(reach[2], reach[3], chrome_swing_base(reach[1], 0, 15))) + TEST_ASSERT(abs(fist_at[1] - point[1]) <= 1 && abs(fist_at[2] - point[2]) <= 1, "The fist stops short of the [zone] of a body beside its bearer") + + // A body a corner away gets tg's lunge: the arm is thrown the way its bearer faces + var/mob/living/carbon/human/consistent/cornered = allocate(/mob/living/carbon/human/consistent, spot(4, 3)) + var/cornered_before = cornered.getBruteLoss() + arm(fresh).piston_hit(fresh, cornered, fresh.get_bodypart(BODY_ZONE_R_ARM), BODY_ZONE_CHEST) + TEST_ASSERT_NULL(fresh.gorilla_thrust, "A punch at a corner tile threw its arm past the body") + sleep(0.3 SECONDS) + TEST_ASSERT(cornered.getBruteLoss() > cornered_before, "A punch at a corner tile never landed") + +/** + * The haymaker's arm: a bearer who stands still winds up on the rig, whose puppets lean with the hidden body; the blow + * lands when the thrown fist does, and the rig comes down when the arms are back at rest. A step or a turn mid + * wind-up takes the rig down and the wind-up goes on; a wind-up called off lowers the arms and then the rig. + */ +/datum/unit_test/voidcrew_gorilla_gore/haymaker_swing + +/datum/unit_test/voidcrew_gorilla_gore/haymaker_swing/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + bearer.setDir(EAST) + var/datum/action/cooldown/cyberware/gorilla_haymaker/haymaker = locate() in arm(bearer, BODY_ZONE_R_ARM).actions + haymaker.Trigger(bearer) + TEST_ASSERT_NOTNULL(haymaker.rig, "A wind-up standing still raised no rig") + // Three puppets, plus the body's stand-in that every concealed rig puts up (chrome_rig/conceal()) + TEST_ASSERT_EQUAL(puppets_left(), 4, "The wind-up's rig isn't a body and two arms") + TEST_ASSERT_EQUAL(length(haymaker.rig.puppets), 3, "The wind-up's rig isn't a body and two arms") + var/datum/status_effect/gorilla_windup/windup = bearer.has_status_effect(/datum/status_effect/gorilla_windup) + haymaker.charge_started = world.time - 2 SECONDS + windup.tick(0.2) + var/obj/effect/abstract/chrome_puppet/body_puppet = haymaker.rig.puppet("body") + TEST_ASSERT_EQUAL(body_puppet.pixel_x, bearer.pixel_x, "The puppets didn't lean with the hidden body") + TEST_ASSERT_EQUAL(body_puppet.pixel_w, bearer.pixel_w, "The puppets didn't tremble with the hidden body") + var/hurt_before = victim.getBruteLoss() + haymaker.InterceptClickOn(bearer, null, victim) + TEST_ASSERT_NOTNULL(haymaker.rig, "The rig came down before the swing") + TEST_ASSERT_EQUAL(victim.getBruteLoss(), hurt_before, "The haymaker landed before its fist was thrown") + sleep(0.2 SECONDS) + TEST_ASSERT(victim.getBruteLoss() - hurt_before >= 20, "The thrown haymaker never landed") // GORILLA_HAYMAKER_MIN_DAMAGE + TEST_ASSERT_NOTNULL(haymaker.rig, "The rig came down before the follow-through") + sleep(0.6 SECONDS) + TEST_ASSERT_NULL(haymaker.rig, "The rig outlived the swing") + TEST_ASSERT_EQUAL(puppets_left(), 0, "The swing left a puppet behind") + TEST_ASSERT(!bearer.get_filter("chrome_rig_hide"), "The swing left its bearer hidden") // CHROME_RIG_HIDE_FILTER + + // A step: the lean alone from there, and the wind-up goes on + var/mob/living/carbon/human/walker = gorilla(spot(0, 2)) + walker.setDir(EAST) + var/datum/action/cooldown/cyberware/gorilla_haymaker/walking = locate() in arm(walker, BODY_ZONE_R_ARM).actions + walking.Trigger(walker) + TEST_ASSERT_NOTNULL(walking.rig, "Test fixture: the second wind-up raised no rig") + walker.forceMove(spot(0, 3)) + TEST_ASSERT_NULL(walking.rig, "A step left the rig standing where the bearer was") + TEST_ASSERT(walking.charging(), "A step ended the wind-up") + TEST_ASSERT_NOTNULL(walker.has_status_effect(/datum/status_effect/gorilla_windup), "A step ended the wind-up's lean") + walking.unset_click_ability(walker, refund_cooldown = TRUE) + + // A turn does the same + var/mob/living/carbon/human/turner = gorilla(spot(2, 2)) + turner.setDir(EAST) + var/datum/action/cooldown/cyberware/gorilla_haymaker/turning = locate() in arm(turner, BODY_ZONE_R_ARM).actions + turning.Trigger(turner) + TEST_ASSERT_NOTNULL(turning.rig, "Test fixture: the third wind-up raised no rig") + turner.setDir(SOUTH) + TEST_ASSERT_NULL(turning.rig, "A turn left the old facing's puppets up") + TEST_ASSERT(turning.charging(), "A turn ended the wind-up") + turning.unset_click_ability(turner, refund_cooldown = TRUE) + + // Called off: the arms come down first, then the rig + var/mob/living/carbon/human/venter = gorilla(spot(2, 4)) + venter.setDir(EAST) + var/datum/action/cooldown/cyberware/gorilla_haymaker/vented = locate() in arm(venter, BODY_ZONE_R_ARM).actions + vented.Trigger(venter) + TEST_ASSERT_NOTNULL(vented.rig, "Test fixture: the fourth wind-up raised no rig") + vented.unset_click_ability(venter, refund_cooldown = TRUE) + TEST_ASSERT(!vented.charging(), "Test fixture: the wind-up wasn't called off") + TEST_ASSERT_NOTNULL(vented.rig, "A wind-up called off dropped its arms in one frame") + sleep(0.5 SECONDS) + TEST_ASSERT_NULL(vented.rig, "The rig outlived a wind-up called off") + TEST_ASSERT_EQUAL(puppets_left(), 0, "A wind-up called off left a puppet behind") + + // Thrown at a body a corner away: the rig comes down, the lunge is tg's, and the blow still lands + var/mob/living/carbon/human/cornerer = gorilla(spot(3, 3)) + var/mob/living/carbon/human/consistent/cornered = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + cornerer.setDir(EAST) + var/datum/action/cooldown/cyberware/gorilla_haymaker/corner_swing = locate() in arm(cornerer, BODY_ZONE_R_ARM).actions + corner_swing.Trigger(cornerer) + TEST_ASSERT_NOTNULL(corner_swing.rig, "Test fixture: the fifth wind-up raised no rig") + corner_swing.charge_started = world.time - 1 SECONDS + var/cornered_before = cornered.getBruteLoss() + corner_swing.InterceptClickOn(cornerer, null, cornered) + TEST_ASSERT_NULL(corner_swing.rig, "A haymaker at a corner tile threw its arm past the body") + TEST_ASSERT_EQUAL(puppets_left(), 0, "A haymaker at a corner tile left a puppet behind") + sleep(0.2 SECONDS) + TEST_ASSERT(cornered.getBruteLoss() - cornered_before >= 20, "A haymaker at a corner tile never landed") // GORILLA_HAYMAKER_MIN_DAMAGE + + // Something in the guard hand: that arm stays down, so the thing isn't pulled apart + var/mob/living/carbon/human/guarder = gorilla(spot(4, 2)) + guarder.setDir(EAST) + guarder.put_in_hand(allocate(/obj/item/wrench), 1) + var/datum/action/cooldown/cyberware/gorilla_haymaker/guarded = locate() in arm(guarder, BODY_ZONE_R_ARM).actions + guarded.Trigger(guarder) + TEST_ASSERT_NOTNULL(guarded.rig, "A wind-up with something in the guard hand raised no rig") + TEST_ASSERT_NOTNULL(guarded.rig.arm_poses["r"], "Test fixture: the punching arm wasn't drawn back") + TEST_ASSERT_NULL(guarded.rig.arm_poses["l"], "A guard arm with something in its hand was raised") + guarded.unset_click_ability(guarder, refund_cooldown = TRUE) + + // Something in the punching hand: no drawing, and the wind-up goes on + var/mob/living/carbon/human/gripper = gorilla(spot(0, 4)) + gripper.setDir(EAST) + gripper.put_in_hand(allocate(/obj/item/wrench), 2) + var/datum/action/cooldown/cyberware/gorilla_haymaker/gripped = locate() in arm(gripper, BODY_ZONE_R_ARM).actions + gripped.Trigger(gripper) + TEST_ASSERT_NULL(gripped.rig, "A punching arm with something in its hand was drawn on the rig") + TEST_ASSERT(gripped.charging(), "Something in the punching hand stopped the wind-up") + gripped.unset_click_ability(gripper, refund_cooldown = TRUE) + sleep(0.4 SECONDS) + TEST_ASSERT_EQUAL(puppets_left(), 0, "A wind-up with full hands left a puppet behind") + +// ========================================================================= +// GROUND POUND +// ========================================================================= + +/// The synced pair grants the chip; the pound staggers and dazes everyone around but the bearer, does no +/// brute, and loose things hop outward but never into space. +/datum/unit_test/voidcrew_gorilla_gore/ground_pound + +/datum/unit_test/voidcrew_gorilla_gore/ground_pound/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(2, 2)) + TEST_ASSERT(gorilla_synced(bearer), "Test fixture: the pair isn't synced") + var/datum/action/cooldown/cyberware/gorilla_pound/pound = locate() in arm(bearer, BODY_ZONE_R_ARM).actions + TEST_ASSERT_NOTNULL(pound, "A synced pair has no ground pound") + TEST_ASSERT_EQUAL(pound.owner, bearer, "The ground pound wasn't granted") + + var/mob/living/carbon/human/consistent/near = allocate(/mob/living/carbon/human/consistent, spot(3, 2)) + var/mob/living/carbon/human/consistent/far = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + // Lava, not space: a space hole would vent the room and the wind would move things itself + var/turf/hole = spot(0, 2) + change_turf(hole, /turf/open/lava/smooth) + var/obj/item/wrench/loose = allocate(/obj/item/wrench, spot(1, 2)) + var/brute_before = near.getBruteLoss() + var/list/hit = gorilla_ground_pound(bearer, get_turf(bearer)) + TEST_ASSERT(near in hit, "The pound missed someone beside it") + TEST_ASSERT(!(far in hit), "The pound reached someone two tiles off") + TEST_ASSERT(!(bearer in hit), "The pound hit its bearer") + TEST_ASSERT_NOTNULL(near.has_status_effect(/datum/status_effect/staggered), "The pound didn't stagger") + TEST_ASSERT_EQUAL(near.getBruteLoss(), brute_before, "The pound did brute") + var/hopped_to = loose.loc + restore_turf(hole) + TEST_ASSERT_NOTEQUAL(hopped_to, hole, "The pound hopped a loose thing into lava") + + // Out of sync: the chip goes + var/obj/item/organ/left = arm(bearer, BODY_ZONE_L_ARM) + left.Remove(bearer, special = TRUE) + sleep(0.1 SECONDS) + TEST_ASSERT(QDELETED(pound) || pound.owner != bearer, "The ground pound outlived the pair") + +// ========================================================================= +// DOOR PRY +// ========================================================================= + +/// A trader outpost's airlock never gives to the Gorilla. +/datum/unit_test/voidcrew_gorilla_gore/pry_outpost + +/datum/unit_test/voidcrew_gorilla_gore/pry_outpost/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + bearer.set_combat_mode(FALSE) + var/obj/machinery/door/airlock/outpost/door = allocate(/obj/machinery/door/airlock/outpost, spot(1, 0)) + TEST_ASSERT(gorilla_pry_refused(door), "An outpost airlock isn't refused") + var/result = SEND_SIGNAL(bearer, COMSIG_LIVING_UNARMED_ATTACK, door, TRUE, list()) + TEST_ASSERT(result & COMPONENT_CANCEL_ATTACK_CHAIN, "The pry didn't take the outpost door click") + sleep(0.5 SECONDS) + TEST_ASSERT(door.density, "The Gorilla pried an outpost airlock") + var/obj/machinery/door/airlock/plain = allocate(/obj/machinery/door/airlock, spot(0, 1)) + TEST_ASSERT(!gorilla_pry_refused(plain), "A plain airlock is refused") + +// ========================================================================= +// FINISHERS (owner D39) +// ========================================================================= + +/// Never on someone just lying there or with something in hand; Brawler myomers never clap a head. +/datum/unit_test/voidcrew_gorilla_gore/finisher_gates + +/datum/unit_test/voidcrew_gorilla_gore/finisher_gates/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + bearer.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/resting = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + resting.set_resting(TRUE, instant = TRUE) + TEST_ASSERT(!gorilla_try_finisher(bearer, resting), "A finisher started on someone just lying down") + + var/mob/living/carbon/human/consistent/stunned = downed(spot(0, 1)) + var/obj/item/wrench/tool = allocate(/obj/item/wrench) + bearer.put_in_hands(tool) + TEST_ASSERT(!gorilla_try_finisher(bearer, stunned), "A finisher started with something in hand") + qdel(tool) + + var/mob/living/carbon/human/brawler = gorilla(spot(3, 3), street = TRUE) + brawler.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/brawler_victim = downed(spot(4, 3)) + TEST_ASSERT(!gorilla_try_finisher(brawler, brawler_victim), "Brawler myomers started the head clap") + + // The pistons' cooldown blocks it + gorilla_cooldown(bearer, "gorilla_pistons", 20 SECONDS) // COOLDOWN_GORILLA_PISTONS + TEST_ASSERT(!gorilla_try_finisher(bearer, stunned), "A finisher started while the pistons were spent") + +/// The head clap bursts the head, the brain survives, the rig comes down and the pistons are spent. +/datum/unit_test/voidcrew_gorilla_gore/finisher_clap + +/datum/unit_test/voidcrew_gorilla_gore/finisher_clap/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(1, 1)) + bearer.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/victim = downed(spot(2, 1)) + TEST_ASSERT(gorilla_try_finisher(bearer, victim), "The head clap didn't start on someone stunned") + var/datum/hv_finisher/chrome/gorilla/clap/finisher = bearer.chrome_finisher + TEST_ASSERT(istype(finisher), "A head aim didn't pick the head clap") + TEST_ASSERT(puppets_left() > 0, "The head clap put up no rig") + run_to_end(finisher) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_HEAD), "The head clap didn't burst the head") + TEST_ASSERT_EQUAL(bearer.loc, spot(1, 1), "The burst moved the bearer (a thrown head knocks a body back)") + TEST_ASSERT_EQUAL(victim.loc, spot(1, 1), "The burst body didn't come down on the bearer's tile, where it was held") + var/obj/item/organ/brain/brain + for(var/turf/floor in block(run_loc_floor_bottom_left, run_loc_floor_top_right)) + brain ||= locate(/obj/item/organ/brain) in floor + TEST_ASSERT_NOTNULL(brain, "The burst head lost its brain") + TEST_ASSERT_EQUAL(puppets_left(), 0, "The head clap left puppets behind") + TEST_ASSERT_NULL(bearer.get_filter("chrome_rig_hide"), "The bearer stayed hidden") + TEST_ASSERT_NULL(victim.get_filter("chrome_rig_hide"), "The victim stayed hidden") + TEST_ASSERT_NOTEQUAL(bearer.mouse_opacity, MOUSE_OPACITY_OPAQUE, "The bearer kept the hidden click area") + var/left = S_TIMER_COOLDOWN_TIMELEFT(bearer, "gorilla_pistons") + TEST_ASSERT(left > 10 SECONDS, "A finished clap didn't spend the pistons for long ([left])") + TEST_ASSERT_NULL(bearer.chrome_finisher, "The finished clap is still on the bearer") + TEST_ASSERT(QDELETED(finisher), "A finished clap outlived its end and kept hold of both bodies") + +/// A helmet crumples instead and the skull caves in; the Atlas frame holds. +/datum/unit_test/voidcrew_gorilla_gore/finisher_clap_armour + +/datum/unit_test/voidcrew_gorilla_gore/finisher_clap_armour/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(1, 1)) + bearer.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/helmeted = downed(spot(2, 1)) + helmeted.equip_to_slot_or_del(new /obj/item/clothing/head/helmet/swat(helmeted), ITEM_SLOT_HEAD) + var/datum/hv_finisher/chrome/gorilla/clap/finisher = new(bearer, helmeted) + TEST_ASSERT(finisher.start(), "Test fixture: the clap wouldn't start on a helmet") + run_to_end(finisher) + TEST_ASSERT_NOTNULL(helmeted.get_bodypart(BODY_ZONE_HEAD), "A helmet didn't stop the burst") + TEST_ASSERT_NOTNULL(helmeted.get_bodypart(BODY_ZONE_HEAD).get_wound_type(/datum/wound/blunt/bone/critical/hv_skull), "The skull didn't cave in under the helmet") + qdel(finisher) + + var/mob/living/carbon/human/second = gorilla(spot(1, 3)) + second.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/framed = downed(spot(2, 3)) + var/obj/item/organ/atlas = allocate(/obj/item/organ/cyberimp/cyberware/atlas) + TEST_ASSERT(atlas.Insert(framed, special = TRUE), "Test fixture: the Atlas frame wouldn't go in") + var/datum/hv_finisher/chrome/gorilla/clap/frame_finisher = new(second, framed) + TEST_ASSERT(frame_finisher.start(), "Test fixture: the clap wouldn't start on the Atlas frame") + run_to_end(frame_finisher) + TEST_ASSERT_NOTNULL(framed.get_bodypart(BODY_ZONE_HEAD), "The Atlas frame's head burst") + qdel(frame_finisher) + +/// The limb rip tears the aimed arm off and leaves it on the victim's tile. +/datum/unit_test/voidcrew_gorilla_gore/finisher_rip + +/datum/unit_test/voidcrew_gorilla_gore/finisher_rip/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(1, 1)) + bearer.zone_selected = BODY_ZONE_L_ARM + var/mob/living/carbon/human/consistent/victim = downed(spot(2, 1)) + // Blood an earlier test left here would keep the tear's own where it is + clear_mess(spot(2, 1)) + TEST_ASSERT(gorilla_try_finisher(bearer, victim), "The limb rip didn't start") + var/datum/hv_finisher/chrome/gorilla/rip/finisher = bearer.chrome_finisher + TEST_ASSERT(istype(finisher), "An arm aim didn't pick the limb rip") + run_to_end(finisher) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_L_ARM), "The aimed arm wasn't torn off") + TEST_ASSERT_NOTNULL(victim.get_bodypart(BODY_ZONE_R_ARM), "The wrong arm was torn off") + var/obj/item/bodypart/arm/left/torn = locate() in get_turf(victim) + TEST_ASSERT_NOTNULL(torn, "The torn arm wasn't left on the victim's tile") + TEST_ASSERT_EQUAL(puppets_left(), 0, "The limb rip left puppets behind") + // The blood is the tear's, laid under the shoulder as the arm came off: nothing fresh when the arm is dropped + var/obj/effect/decal/cleanable/blood/pool + for(var/obj/effect/decal/cleanable/blood/found in get_turf(victim)) + if(found.type == /obj/effect/decal/cleanable/blood) + pool = found + TEST_ASSERT_NOTNULL(pool, "The torn shoulder left no blood on the floor") + TEST_ASSERT(pool.base_pixel_x || pool.base_pixel_y, "The torn shoulder's blood was laid on the middle of the tile, off the body held in the grab") + TEST_ASSERT_NULL(locate(/obj/effect/decal/cleanable/blood/splatter) in get_turf(victim), "The dropped arm laid a splash of its own after the wound") + + // Armour on the arm: the shoulder comes out instead + var/mob/living/carbon/human/second = gorilla(spot(1, 3)) + second.zone_selected = BODY_ZONE_R_ARM + var/mob/living/carbon/human/consistent/armoured = downed(spot(2, 3)) + armoured.physiology.armor = armoured.physiology.armor.generate_new_with_modifiers(list(MELEE = 60)) + var/datum/hv_finisher/chrome/gorilla/rip/armoured_rip = new(second, armoured) + armoured_rip.aimed_zone = BODY_ZONE_R_ARM + TEST_ASSERT(armoured_rip.start(), "Test fixture: the rip wouldn't start on armour") + run_to_end(armoured_rip) + TEST_ASSERT_NOTNULL(armoured.get_bodypart(BODY_ZONE_R_ARM), "An armoured arm was torn off") + TEST_ASSERT_NOTNULL(armoured.get_bodypart(BODY_ZONE_R_ARM).get_wound_type(/datum/wound/blunt/bone/moderate), "An armoured arm didn't dislocate") + qdel(armoured_rip) + +/// The backbreaker breaks the back (they can't stand) and shoves the body onto the tile the bearer faces, or drops it +/// at his feet if that tile is blocked; the fold comes off when the body is moved. +/datum/unit_test/voidcrew_gorilla_gore/finisher_backbreaker + +/datum/unit_test/voidcrew_gorilla_gore/finisher_backbreaker/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(1, 1)) + bearer.zone_selected = BODY_ZONE_CHEST + var/mob/living/carbon/human/consistent/victim = downed(spot(2, 1)) + TEST_ASSERT(gorilla_try_finisher(bearer, victim), "The backbreaker didn't start") + var/datum/hv_finisher/chrome/gorilla/backbreaker/finisher = bearer.chrome_finisher + TEST_ASSERT(istype(finisher), "A chest aim didn't pick the backbreaker") + // Whatever blood earlier tests left where the body is broken and where it comes down + clear_mess(spot(1, 1)) + clear_mess(spot(2, 1)) + run_to_end(finisher) + TEST_ASSERT_NULL(locate(/obj/effect/decal/cleanable/blood) in spot(1, 1), "The backbreaker laid blood of its own at the knee") + TEST_ASSERT_NULL(locate(/obj/effect/decal/cleanable/blood) in spot(2, 1), "The backbreaker laid blood of its own where the body landed") + var/obj/item/bodypart/chest = victim.get_bodypart(BODY_ZONE_CHEST) + var/datum/wound/spine = chest.get_wound_type(/datum/wound/blunt/bone/critical/gorilla_spine) + TEST_ASSERT_NOTNULL(spine, "The back didn't break") + TEST_ASSERT(HAS_TRAIT_FROM(victim, TRAIT_FLOORED, REF(spine)), "A broken back can still stand") + TEST_ASSERT_EQUAL(bearer.loc, spot(1, 1), "The backbreaker moved the bearer") + TEST_ASSERT_EQUAL(victim.loc, spot(2, 1), "The body wasn't shoved off the knee onto the tile the bearer faces") + TEST_ASSERT_EQUAL(victim.lying_angle, LYING_ANGLE_EAST, "The body lies the other way from its bent halves, so it flips when they come down") + TEST_ASSERT_NOTNULL(victim.GetComponent(/datum/component/gorilla_fold), "The broken back isn't drawn bent") + TEST_ASSERT_NOTNULL(victim.get_filter("chrome_rig_hide"), "The bent body isn't the one shown") + TEST_ASSERT_NULL(victim.GetComponent(/datum/component/gorilla_laid_in_front), "A body shoved clear of the bearer is drawn off its tile") + victim.forceMove(spot(3, 3)) + TEST_ASSERT_NULL(victim.GetComponent(/datum/component/gorilla_fold), "The fold stayed on a moved body") + TEST_ASSERT_NULL(victim.get_filter("chrome_rig_hide"), "A moved body stayed hidden") + TEST_ASSERT_EQUAL(puppets_left(), 0, "The fold left puppets behind") + var/spine_ref = REF(spine) + spine.remove_wound() + TEST_ASSERT(!HAS_TRAIT_FROM(victim, TRAIT_FLOORED, spine_ref), "A set back still can't stand") + + // Something solid on the tile he faces: the body comes down at his feet, drawn in front of him + var/mob/living/carbon/human/second = gorilla(spot(1, 3)) + second.zone_selected = BODY_ZONE_CHEST + var/mob/living/carbon/human/consistent/boxed_in = downed(spot(2, 3)) + allocate(/obj/structure/closet/crate, spot(2, 3)) + var/datum/hv_finisher/chrome/gorilla/backbreaker/blocked = new(second, boxed_in) + TEST_ASSERT(blocked.start(), "Test fixture: the backbreaker wouldn't start beside a crate") + run_to_end(blocked) + TEST_ASSERT_EQUAL(boxed_in.loc, spot(1, 3), "With the tile ahead blocked the body didn't come down at the bearer's feet") + TEST_ASSERT_NOTNULL(boxed_in.GetComponent(/datum/component/gorilla_laid_in_front), "The body at his feet isn't drawn in front of the bearer standing over it") + boxed_in.forceMove(spot(3, 3)) + TEST_ASSERT_NULL(boxed_in.GetComponent(/datum/component/gorilla_laid_in_front), "A moved body is still drawn off its tile") + TEST_ASSERT_EQUAL(puppets_left(), 0, "The fold at his feet left puppets behind") + +/// Damage on the bearer, the bearer moving, or the victim coming out of the stun stops it, with the +/// shorter cooldown, and nothing is left hidden or posed. +/datum/unit_test/voidcrew_gorilla_gore/finisher_interrupts + +/datum/unit_test/voidcrew_gorilla_gore/finisher_interrupts/Run() + // Hit hard enough: lets go + var/mob/living/carbon/human/bearer = gorilla(spot(1, 1)) + bearer.zone_selected = BODY_ZONE_CHEST + var/mob/living/carbon/human/consistent/victim = downed(spot(2, 1)) + TEST_ASSERT(gorilla_try_finisher(bearer, victim), "Test fixture: no finisher") + var/datum/hv_finisher/chrome/gorilla/finisher = bearer.chrome_finisher + finisher.advance() + bearer.apply_damage(15, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(!finisher.running, "Damage on the bearer didn't stop the finisher") + TEST_ASSERT(QDELETED(finisher), "A stopped finisher outlived its end") + TEST_ASSERT_EQUAL(finisher.result, 3, "Damage stopped it for the wrong reason") // HV_FINISHER_DAMAGED + TEST_ASSERT_EQUAL(puppets_left(), 0, "A stopped finisher left puppets") + TEST_ASSERT_NULL(victim.get_filter("chrome_rig_hide"), "A stopped finisher left the victim hidden") + TEST_ASSERT_NULL(bearer.get_filter("chrome_rig_hide"), "A stopped finisher left the bearer hidden") + var/left = S_TIMER_COOLDOWN_TIMELEFT(bearer, "gorilla_pistons") + TEST_ASSERT(left > 0 && left <= 10 SECONDS, "A stopped finisher cost the wrong cooldown ([left])") // GORILLA_PISTONS_INTERRUPTED + TEST_ASSERT_NOTNULL(victim.get_bodypart(BODY_ZONE_CHEST), "Test fixture: no chest") + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_CHEST).get_wound_type(/datum/wound/blunt/bone/critical/gorilla_spine), "A stopped backbreaker still broke the back") + + // The bearer steps away: lets go + var/mob/living/carbon/human/walker = gorilla(spot(1, 3)) + walker.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/walk_victim = downed(spot(2, 3)) + TEST_ASSERT(gorilla_try_finisher(walker, walk_victim), "Test fixture: no second finisher") + var/datum/hv_finisher/chrome/gorilla/walk_finisher = walker.chrome_finisher + walker.forceMove(spot(0, 3)) + TEST_ASSERT(!walk_finisher.running, "The bearer walked off mid-finisher") + TEST_ASSERT_NOTNULL(walk_victim.get_bodypart(BODY_ZONE_HEAD), "A walked-off clap still burst the head") + + // The victim comes out of the stun before the kill: twists free + var/mob/living/carbon/human/third = gorilla(spot(3, 0)) + third.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/waking = downed(spot(4, 0)) + TEST_ASSERT(gorilla_try_finisher(third, waking), "Test fixture: no third finisher") + var/datum/hv_finisher/chrome/gorilla/wake_finisher = third.chrome_finisher + waking.SetAllImmobility(0) + wake_finisher.tick() + TEST_ASSERT(!wake_finisher.running, "A victim out of the stun didn't twist free") + TEST_ASSERT_NOTNULL(waking.get_bodypart(BODY_ZONE_HEAD), "A victim who twisted free lost the head") + TEST_ASSERT_EQUAL(puppets_left(), 0, "Twisting free left puppets") + +/// From a corner the punch is only a punch: the finisher starts square on. A body dragged onto a corner mid-move lets go. +/datum/unit_test/voidcrew_gorilla_gore/finisher_square_on + +/datum/unit_test/voidcrew_gorilla_gore/finisher_square_on/Run() + var/mob/living/carbon/human/bearer = gorilla(spot(1, 1)) + bearer.zone_selected = BODY_ZONE_CHEST + var/mob/living/carbon/human/consistent/victim = downed(spot(2, 2)) + var/hurt_before = victim.getBruteLoss() + TEST_ASSERT_EQUAL(punch(bearer, victim), COMPONENT_CANCEL_ATTACK_CHAIN, "The Gorilla arm didn't take the corner punch") + TEST_ASSERT_NULL(bearer.chrome_finisher, "A finisher started on someone on a corner") + TEST_ASSERT(!victim.has_status_effect(/datum/status_effect/hv_finisher_hold), "Someone on a corner was held for a finisher") + // The blow lands when the fist is there: 0.1 s (GORILLA_THRUST_LANDS) + sleep(0.3 SECONDS) + TEST_ASSERT(victim.getBruteLoss() > hurt_before, "The corner punch did no damage") + for(var/zone in list(BODY_ZONE_HEAD, BODY_ZONE_R_ARM)) + bearer.zone_selected = zone + TEST_ASSERT(!gorilla_try_finisher(bearer, victim), "A [zone] finisher started on someone on a corner") + + // Square on, the same punch starts it + victim.forceMove(spot(2, 1)) + bearer.zone_selected = BODY_ZONE_CHEST + punch(bearer, victim) + var/datum/hv_finisher/chrome/gorilla/backbreaker/finisher = bearer.chrome_finisher + TEST_ASSERT(istype(finisher) && finisher.running, "The backbreaker didn't start square on") + + // Dragged onto a corner before the kill: lets go + finisher.advance() + victim.forceMove(spot(2, 2)) + TEST_ASSERT(QDELETED(finisher) || !finisher.running, "The backbreaker went on with the body on a corner") + TEST_ASSERT_NULL(bearer.chrome_finisher, "The bearer is still finishing a body on a corner") + TEST_ASSERT_EQUAL(puppets_left(), 0, "A finisher stopped on a corner left puppets") + TEST_ASSERT_NULL(victim.get_filter("chrome_rig_hide"), "A finisher stopped on a corner left the victim hidden") + +/// Each new move can be started without a mouse or an aimed zone, for an AI later. +/datum/unit_test/voidcrew_gorilla_gore/ai_entry_points + +/datum/unit_test/voidcrew_gorilla_gore/ai_entry_points/Run() + // The haymaker: the same wind-up, then the hit + var/mob/living/carbon/human/bearer = gorilla(spot(0, 0)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/hurt_before = victim.getBruteLoss() + TEST_ASSERT(gorilla_try_haymaker(bearer, victim, 0.8 SECONDS), "The haymaker couldn't be started without a click") + TEST_ASSERT_NOTNULL(bearer.has_status_effect(/datum/status_effect/gorilla_windup), "An AI haymaker skipped the wind-up") + sleep(1.5 SECONDS) + TEST_ASSERT(victim.getBruteLoss() > hurt_before, "An AI haymaker never landed") + TEST_ASSERT(!TIMER_COOLDOWN_FINISHED(bearer, "gorilla_pistons"), "An AI haymaker didn't spend the pistons") // COOLDOWN_GORILLA_PISTONS + + // The ground pound + var/mob/living/carbon/human/pounder = gorilla(spot(2, 4)) + TEST_ASSERT(gorilla_try_pound(pounder), "The ground pound couldn't be started without the chip") + TEST_ASSERT(!TIMER_COOLDOWN_FINISHED(pounder, "gorilla_pound"), "An AI pound didn't start its cooldown") // COOLDOWN_GORILLA_POUND + + // A finisher by zone, whatever the bearer aims at + var/mob/living/carbon/human/finisher_bearer = gorilla(spot(0, 2)) + finisher_bearer.zone_selected = BODY_ZONE_HEAD + var/mob/living/carbon/human/consistent/downed_victim = downed(spot(1, 2)) + TEST_ASSERT(gorilla_try_finisher(finisher_bearer, downed_victim, BODY_ZONE_CHEST), "A finisher couldn't be started by zone") + TEST_ASSERT(istype(finisher_bearer.chrome_finisher, /datum/hv_finisher/chrome/gorilla/backbreaker), "The zone given didn't pick the finisher") + run_to_end(finisher_bearer.chrome_finisher) + + // The slam, clear of row 0: the haymaker above knocks its victim along it, onto the tiles used here before + var/mob/living/carbon/human/slammer = gorilla(spot(3, 2)) + var/mob/living/carbon/human/consistent/held = allocate(/mob/living/carbon/human/consistent, spot(4, 2)) + held.grabbedby(slammer, supress_message = TRUE) + held.grabbedby(slammer, supress_message = TRUE) + slammer.swap_hand(2, silent = TRUE) + TEST_ASSERT(gorilla_try_slam(slammer, get_turf(held)), "The slam couldn't be started without a click") + +// ========================================================================= +// BRAWLER MYOMERS (owner D49): the street slam, the light pound, the rip, doors +// ========================================================================= + +/// Brawler myomers slam a held body lighter and on a longer clock, never hurl it, and need the chrome +/// running and a bearer who will hurt someone. +/datum/unit_test/voidcrew_gorilla_gore/brawler_slam + +/datum/unit_test/voidcrew_gorilla_gore/brawler_slam/Run() + var/mob/living/carbon/human/brawler = gorilla(spot(0, 0), street = TRUE) + var/mob/living/carbon/human/consistent/held = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + held.grabbedby(brawler, supress_message = TRUE) + held.grabbedby(brawler, supress_message = TRUE) + var/brute_before = held.getBruteLoss() + var/stamina_before = held.getStaminaLoss() + TEST_ASSERT_EQUAL(punch(brawler, spot(1, 0)), COMPONENT_CANCEL_ATTACK_CHAIN, "A Brawler floor click while grabbing wasn't a slam") + var/grab_wait = S_TIMER_COOLDOWN_TIMELEFT(brawler, "gorilla_grab_move") // COOLDOWN_GORILLA_GRAB_MOVE + TEST_ASSERT(grab_wait > 10 SECONDS, "The Brawler slam's grab clock is the Gorilla's ([grab_wait])") // BRAWLER_GRAB_MOVE_COOLDOWN 15 s + sleep(0.3 SECONDS) + TEST_ASSERT_EQUAL(held.getBruteLoss(), brute_before, "A Brawler slam landed inside 0.3 s") // 0.40 s to the impact + sleep(0.2 SECONDS) + TEST_ASSERT_NULL(brawler.pulling, "The Brawler slam kept the grab") + TEST_ASSERT_EQUAL(held.loc, spot(1, 0), "The Brawler slam moved the body") + TEST_ASSERT_EQUAL(held.getBruteLoss() - brute_before, 18, "A Brawler floor slam didn't land 18") // BRAWLER_SLAM_FLOOR_DAMAGE + var/winded = held.getStaminaLoss() - stamina_before + TEST_ASSERT(winded > 15 && winded <= 20, "A Brawler floor slam took [winded] stamina, not 20") // BRAWLER_SLAM_FLOOR_STAMINA + TEST_ASSERT(held.body_position == LYING_DOWN, "The Brawler slam didn't knock them down") + TEST_ASSERT(held.AmountKnockdown() <= 1 SECONDS, "The Brawler slam floored them for the Gorilla's two seconds") // BRAWLER_SLAM_KNOCKDOWN + + // The table, lighter on the body and on the table + var/mob/living/carbon/human/table_brawler = gorilla(spot(0, 3), street = TRUE) + var/mob/living/carbon/human/consistent/table_victim = allocate(/mob/living/carbon/human/consistent, spot(1, 3)) + var/obj/structure/table/table = allocate(/obj/structure/table, spot(1, 4)) + var/table_before = table.get_integrity() + var/table_brute = table_victim.getBruteLoss() + table_victim.grabbedby(table_brawler, supress_message = TRUE) + table_victim.grabbedby(table_brawler, supress_message = TRUE) + TEST_ASSERT_EQUAL(punch(table_brawler, table), COMPONENT_CANCEL_ATTACK_CHAIN, "A Brawler table click while grabbing wasn't a slam") + sleep(0.5 SECONDS) + TEST_ASSERT_EQUAL(table_victim.getBruteLoss() - table_brute, 22, "A Brawler table slam didn't land 22") // BRAWLER_SLAM_TABLE_DAMAGE + TEST_ASSERT(!QDELETED(table) && table.get_integrity() > table_before - 50 && table.get_integrity() <= table_before - 30, "A Brawler table slam didn't do 30 to the table") // BRAWLER_SLAM_TABLE_BREAK + + // A punch on a held body lands where it stands: no hurl + var/mob/living/carbon/human/hurler = gorilla(spot(3, 0), street = TRUE) + var/mob/living/carbon/human/consistent/punched = allocate(/mob/living/carbon/human/consistent, spot(4, 0)) + punched.grabbedby(hurler, supress_message = TRUE) + punched.grabbedby(hurler, supress_message = TRUE) + TEST_ASSERT_EQUAL(punch(hurler, punched), COMPONENT_CANCEL_ATTACK_CHAIN, "Test fixture: the Brawler punch didn't land") + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(punched.loc, spot(4, 0), "Brawler myomers hurled a held body") + + // A pacifist never slams; neither does an arm that's down + var/mob/living/carbon/human/pacifist = gorilla(spot(3, 2), street = TRUE) + var/mob/living/carbon/human/consistent/spared = allocate(/mob/living/carbon/human/consistent, spot(4, 2)) + ADD_TRAIT(pacifist, TRAIT_PACIFISM, TRAIT_SOURCE_UNIT_TESTS) + spared.grabbedby(pacifist, supress_message = TRUE) + spared.grabbedby(pacifist, supress_message = TRUE) + TEST_ASSERT_NOTEQUAL(punch(pacifist, spot(4, 2)), COMPONENT_CANCEL_ATTACK_CHAIN, "A pacifist Brawler slammed someone") + REMOVE_TRAIT(pacifist, TRAIT_PACIFISM, TRAIT_SOURCE_UNIT_TESTS) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/fried = arm(pacifist) + fried.organ_flags |= ORGAN_FAILING + TEST_ASSERT(!fried.gorilla_running(), "Test fixture: the failing arm still runs") + TEST_ASSERT_NOTEQUAL(fried.try_slam(pacifist, spot(4, 2), pacifist.get_active_hand()), 1, "A failing Brawler arm slammed someone") // GORILLA_SLAM_DONE + +/// The synced Brawler pair's pound staggers and winds those beside it, never dazes them and moves nothing. +/datum/unit_test/voidcrew_gorilla_gore/brawler_pound + +/datum/unit_test/voidcrew_gorilla_gore/brawler_pound/Run() + var/mob/living/carbon/human/brawler = gorilla(spot(2, 2), street = TRUE) + TEST_ASSERT(brawler_synced(brawler), "Test fixture: the Brawler pair isn't synced") + TEST_ASSERT(!gorilla_synced(brawler), "A Brawler pair synced as Gorilla Arms") + var/datum/action/cooldown/cyberware/gorilla_pound/brawler/pound = locate() in arm(brawler, BODY_ZONE_R_ARM).actions + TEST_ASSERT_NOTNULL(pound, "A synced Brawler pair has no ground pound") + TEST_ASSERT_EQUAL(pound.owner, brawler, "The Brawler ground pound wasn't granted") + TEST_ASSERT_EQUAL(pound.cooldown_time, 60 SECONDS, "The Brawler pound isn't on a minute's clock") // BRAWLER_POUND_COOLDOWN + TEST_ASSERT(!pound.daze, "The Brawler pound dazes") + + var/mob/living/carbon/human/consistent/near = allocate(/mob/living/carbon/human/consistent, spot(3, 2)) + var/obj/item/wrench/loose = allocate(/obj/item/wrench, spot(1, 2)) + var/brute_before = near.getBruteLoss() + var/stamina_before = near.getStaminaLoss() + var/list/hit = gorilla_ground_pound(brawler, get_turf(brawler), pound.stagger, pound.daze, pound.stamina, pound.full_pound) + TEST_ASSERT(near in hit, "The Brawler pound missed someone beside it") + var/datum/status_effect/staggered/stagger = near.has_status_effect(/datum/status_effect/staggered) + TEST_ASSERT_NOTNULL(stagger, "The Brawler pound didn't stagger") + TEST_ASSERT(stagger.duration - world.time <= 6 SECONDS, "The Brawler pound staggered past six seconds") // BRAWLER_POUND_STAGGER + TEST_ASSERT_NULL(near.has_status_effect(/datum/status_effect/dazed), "The Brawler pound dazed someone") + var/winded = near.getStaminaLoss() - stamina_before + TEST_ASSERT(winded > 5 && winded <= 10, "The Brawler pound took [winded] stamina, not 10") // BRAWLER_POUND_STAMINA + TEST_ASSERT_EQUAL(near.getBruteLoss(), brute_before, "The Brawler pound did brute") + TEST_ASSERT_EQUAL(loose.loc, spot(1, 2), "The Brawler pound moved a loose thing") + + // Through the chip, on its own clock + var/mob/living/carbon/human/pounder = gorilla(spot(0, 4), street = TRUE) + TEST_ASSERT(gorilla_try_pound(pounder), "The Brawler pound couldn't be started without the chip") + TEST_ASSERT(S_TIMER_COOLDOWN_TIMELEFT(pounder, "gorilla_pound") > 45 SECONDS, "The Brawler pound ran on the Gorilla's clock") // COOLDOWN_GORILLA_POUND + + // A mixed pair has no pound at all + var/mob/living/carbon/human/consistent/mixed = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + var/obj/item/organ/real = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) + var/obj/item/organ/street = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left) + TEST_ASSERT(real.Insert(mixed, special = TRUE), "Test fixture: the real arm wouldn't go in") + TEST_ASSERT(street.Insert(mixed, special = TRUE), "Test fixture: the Brawler arm wouldn't go in") + TEST_ASSERT_NULL(locate(/datum/action/cooldown/cyberware/gorilla_pound) in real.actions, "A mixed pair got a ground pound") + TEST_ASSERT_NULL(locate(/datum/action/cooldown/cyberware/gorilla_pound) in street.actions, "A mixed pair got a Brawler pound") + + // Out of sync: the chip goes + var/obj/item/organ/left = arm(brawler, BODY_ZONE_L_ARM) + left.Remove(brawler, special = TRUE) + sleep(0.1 SECONDS) + TEST_ASSERT(QDELETED(pound) || pound.owner != brawler, "The Brawler pound outlived the pair") + +/// The synced Brawler pair's only finisher is the limb rip, on the same terms as the Gorilla's. A mixed pair has none. +/datum/unit_test/voidcrew_gorilla_gore/brawler_rip + +/datum/unit_test/voidcrew_gorilla_gore/brawler_rip/Run() + var/mob/living/carbon/human/brawler = gorilla(spot(1, 1), street = TRUE) + var/mob/living/carbon/human/consistent/victim = downed(spot(2, 1)) + brawler.zone_selected = BODY_ZONE_HEAD + TEST_ASSERT(!gorilla_try_finisher(brawler, victim), "Brawler myomers started the head clap") + brawler.zone_selected = BODY_ZONE_CHEST + TEST_ASSERT(!gorilla_try_finisher(brawler, victim), "Brawler myomers started the backbreaker") + brawler.zone_selected = BODY_ZONE_L_ARM + TEST_ASSERT(gorilla_try_finisher(brawler, victim), "The Brawler limb rip didn't start") + var/datum/hv_finisher/chrome/gorilla/rip/finisher = brawler.chrome_finisher + TEST_ASSERT(istype(finisher), "An arm aim didn't pick the limb rip for a Brawler") + run_to_end(finisher) + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_L_ARM), "The Brawler rip didn't tear the aimed arm off") + TEST_ASSERT_NOTNULL(victim.get_bodypart(BODY_ZONE_R_ARM), "The Brawler rip tore the wrong arm off") + TEST_ASSERT_EQUAL(puppets_left(), 0, "The Brawler rip left puppets behind") + TEST_ASSERT(!TIMER_COOLDOWN_FINISHED(brawler, "gorilla_pistons"), "The Brawler rip didn't spend the pistons") // COOLDOWN_GORILLA_PISTONS + + // Not someone just lying there + var/mob/living/carbon/human/second = gorilla(spot(1, 3), street = TRUE) + second.zone_selected = BODY_ZONE_R_ARM + var/mob/living/carbon/human/consistent/resting = allocate(/mob/living/carbon/human/consistent, spot(2, 3)) + resting.set_resting(TRUE, instant = TRUE) + TEST_ASSERT(!gorilla_try_finisher(second, resting), "The Brawler rip started on someone just lying down") + + // A mixed pair rips nothing + var/mob/living/carbon/human/consistent/mixed = allocate(/mob/living/carbon/human/consistent, spot(4, 1)) + var/obj/item/organ/real = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms) + var/obj/item/organ/street = allocate(/obj/item/organ/cyberimp/cyberware/gorilla_arms/street/left) + TEST_ASSERT(real.Insert(mixed, special = TRUE), "Test fixture: the real arm wouldn't go in") + TEST_ASSERT(street.Insert(mixed, special = TRUE), "Test fixture: the Brawler arm wouldn't go in") + mixed.set_combat_mode(TRUE) + mixed.zone_selected = BODY_ZONE_L_ARM + var/mob/living/carbon/human/consistent/mixed_victim = downed(spot(4, 2)) + TEST_ASSERT(!gorilla_try_finisher(mixed, mixed_victim), "A mixed pair started the limb rip") + +/// Brawler punches dent plain and reinforced airlocks, less than the Gorilla's; the synced pair forces a +/// powered one slower than the Gorilla; a trader outpost's door takes neither. +/datum/unit_test/voidcrew_gorilla_gore/brawler_doors + +/datum/unit_test/voidcrew_gorilla_gore/brawler_doors/Run() + var/mob/living/carbon/human/brawler = gorilla(spot(0, 0), street = TRUE) + var/obj/machinery/door/airlock/plain = allocate(/obj/machinery/door/airlock, spot(1, 0)) + var/plain_before = plain.get_integrity() + TEST_ASSERT_EQUAL(punch(brawler, plain), COMPONENT_CANCEL_ATTACK_CHAIN, "A Brawler punch at an airlock wasn't a smash") + var/brawler_dent = plain_before - plain.get_integrity() + TEST_ASSERT(brawler_dent > 0, "A Brawler punch didn't dent a plain airlock") + + var/obj/machinery/door/airlock/reinforced = allocate(/obj/machinery/door/airlock, spot(0, 1)) + reinforced.damage_deflection = 30 // AIRLOCK_DAMAGE_DEFLECTION_R + var/reinforced_before = reinforced.get_integrity() + punch(brawler, reinforced) + TEST_ASSERT(reinforced.get_integrity() < reinforced_before, "A Brawler punch didn't dent a reinforced airlock") + + var/mob/living/carbon/human/real = gorilla(spot(3, 0)) + var/obj/machinery/door/airlock/real_door = allocate(/obj/machinery/door/airlock, spot(4, 0)) + var/real_before = real_door.get_integrity() + punch(real, real_door) + TEST_ASSERT(real_before - real_door.get_integrity() > brawler_dent, "A Brawler punch dents an airlock as deep as a Gorilla's") + + // Forcing a powered airlock that won't open for them: slower than the Gorilla's four seconds + brawler.set_combat_mode(FALSE) + var/obj/machinery/door/airlock/shut = allocate(/obj/machinery/door/airlock, spot(1, 1)) + shut.req_access = list(ACCESS_CAPTAIN) + TEST_ASSERT(shut.hasPower(), "Test fixture: the test room airlock has no power") + TEST_ASSERT(!shut.allowed(brawler), "Test fixture: the airlock opens for the Brawler anyway") + var/forced = SEND_SIGNAL(brawler, COMSIG_LIVING_UNARMED_ATTACK, shut, TRUE, list()) + TEST_ASSERT(forced & COMPONENT_CANCEL_ATTACK_CHAIN, "The Brawler pair didn't take the airlock click") + sleep(4.5 SECONDS) + TEST_ASSERT(shut.density, "The Brawler pair forced an airlock as fast as the Gorilla") // GORILLA_PRY_TIME + // 7 s of prying, then the airlock's own opening before it stops blocking + sleep(4 SECONDS) + TEST_ASSERT(!shut.density, "The Brawler pair never forced the airlock") // BRAWLER_PRY_TIME 7 s + + // An arm that's down forces nothing: the click is an ordinary one + var/obj/machinery/door/airlock/second_shut = allocate(/obj/machinery/door/airlock, spot(1, 2)) + second_shut.req_access = list(ACCESS_CAPTAIN) + var/obj/item/organ/cyberimp/cyberware/gorilla_arms/down_arm = arm(brawler, BODY_ZONE_L_ARM) + down_arm.organ_flags |= ORGAN_FAILING + var/weak = SEND_SIGNAL(brawler, COMSIG_LIVING_UNARMED_ATTACK, second_shut, TRUE, list()) + TEST_ASSERT(!(weak & COMPONENT_CANCEL_ATTACK_CHAIN), "A Brawler pair with an arm down started forcing an airlock") + down_arm.organ_flags &= ~ORGAN_FAILING + + // A trader outpost's airlock takes no punch and no pry + var/obj/machinery/door/airlock/outpost/outpost_door = allocate(/obj/machinery/door/airlock/outpost, spot(0, 2)) + var/outpost_before = outpost_door.get_integrity() + brawler.set_combat_mode(TRUE) + TEST_ASSERT_EQUAL(punch(brawler, outpost_door), COMPONENT_CANCEL_ATTACK_CHAIN, "A Brawler punch at an outpost airlock went through to the door") + TEST_ASSERT_EQUAL(outpost_door.get_integrity(), outpost_before, "A Brawler punch dented an outpost airlock") + brawler.set_combat_mode(FALSE) + var/refused = SEND_SIGNAL(brawler, COMSIG_LIVING_UNARMED_ATTACK, outpost_door, TRUE, list()) + TEST_ASSERT(refused & COMPONENT_CANCEL_ATTACK_CHAIN, "The Brawler pry didn't take the outpost door click") + sleep(0.5 SECONDS) + TEST_ASSERT(outpost_door.density, "The Brawler pair pried an outpost airlock") diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs_combat_sense.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs_combat_sense.dm index b3f34f8905e..987bd53af49 100644 --- a/voidcrew/modules/unit_tests/voidcrew_human_npcs_combat_sense.dm +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs_combat_sense.dm @@ -56,6 +56,19 @@ bolt.starting = get_turf(hunter) target.bullet_act(bolt, BODY_ZONE_CHEST) +/// A normal criminal of `tier` fighting in `style`, made the way production makes one (its record as its look) +/datum/unit_test/voidcrew_human_npc_combat_sense/proc/make_normal_criminal(tier, style, turf/where) + var/datum/bounty_record/record = generate_bounty_record(tier, "normal", "planet", /datum/species/human) // BOUNTY_ARCHETYPE_NORMAL, BOUNTY_PLACEMENT_PLANET + record.tier = tier + record.style = style + var/datum/human_npc_order/order = spawn_human_npc(/mob/living/carbon/human/npc/bounty_criminal/normal, where, look = record, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = order?.spawned_ref?.resolve() + qdel(order) + if(criminal) + allocated += criminal + criminal.ai_update_style() + return criminal + /// Whether `npc`'s rules let it act right now (false while a get-up do_after runs) /datum/unit_test/voidcrew_human_npc_combat_sense/proc/sense_acts_mid_get_up(mob/living/carbon/human/npc/npc) if(!LAZYLEN(npc.do_afters)) @@ -331,6 +344,8 @@ /mob/living/carbon/human/npc/faction_pirate/silverscale/ranged, /mob/living/carbon/human/npc/faction_pirate/grey/captain, /mob/living/carbon/human/npc/ruin/trooper/syndicate, + /mob/living/carbon/human/npc/bounty_criminal/normal, + /mob/living/carbon/human/npc/bounty_companion, /mob/living/carbon/human/npc/outpost_prison_guard, )) var/mob/living/carbon/human/npc/armed_path = armed_type @@ -343,10 +358,41 @@ TEST_ASSERT_NULL(civilian.GetComponent(/datum/component/npc_combat_sense), "A townsperson has combat sense") TEST_ASSERT_NULL(civilian.ai_controller?.blackboard["human_npc_cover"], "A townsperson ran for cover") -/// The families' rules: a pirate holding its ground stays put, and a pirate with no crew keeps near home. +/// The families' rules: a Wanted criminal carries a stimpack and keeps cover on its leash; a Petty one +/// carries none; a pirate holding its ground stays put, and a pirate with no crew keeps near home. /datum/unit_test/voidcrew_human_npc_combat_sense/families /datum/unit_test/voidcrew_human_npc_combat_sense/families/Run() + // BOUNTY_TIER_WANTED 2, BOUNTY_STYLE_BRAWLER: a free pocket for the stimpack + var/mob/living/carbon/human/npc/bounty_criminal/normal/wanted = make_normal_criminal(2, "brawler", tile(2, 2)) + TEST_ASSERT_NOTNULL(wanted, "Test fixture: no Wanted criminal was made") + var/obj/item/reagent_containers/hypospray/medipen/wanted_stim = human_npc_find_stim(wanted) + TEST_ASSERT_NOTNULL(wanted_stim, "A Wanted brawler carries no stimpack it can reach") + TEST_ASSERT_EQUAL(wanted_stim.type, /obj/item/reagent_containers/hypospray/medipen/stimpack, "A Wanted brawler carries the wrong stimulant") + var/datum/component/npc_combat_sense/sense = wanted.GetComponent(/datum/component/npc_combat_sense) + TEST_ASSERT_NOTNULL(sense, "A Wanted criminal has no combat sense") + TEST_ASSERT_EQUAL(sense.rules.reach(wanted, wanted.ai_controller), 1, "A brawler counts as a gunner") + var/turf/corner = tile(1, 1) + var/turf/far_corner = tile(3, 3) + wanted.site_bounds = list(corner.x, corner.y, far_corner.x, far_corner.y, corner.z) + TEST_ASSERT(sense.rules.tile_ok(wanted, wanted.ai_controller, tile(2, 3)), "A tile on the criminal's leash is refused") + TEST_ASSERT(!sense.rules.tile_ok(wanted, wanted.ai_controller, tile(4, 4)), "A tile off the criminal's leash is allowed") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/petty = make_normal_criminal(1, "brawler", tile(0, 0)) // BOUNTY_TIER_PETTY + TEST_ASSERT_NOTNULL(petty, "Test fixture: no Petty criminal was made") + TEST_ASSERT_NULL(human_npc_find_stim(petty), "A Petty criminal carries a stimpack") + TEST_ASSERT_NOTNULL(petty.GetComponent(/datum/component/npc_combat_sense), "A Petty criminal has no combat sense") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/most_wanted = make_normal_criminal(3, "club", tile(0, 4)) // BOUNTY_TIER_MOST_WANTED + TEST_ASSERT_NOTNULL(most_wanted, "Test fixture: no Most Wanted criminal was made") + // Every Most Wanted is a mini-boss, which carries the combat stimpack (boss_supplies()); a plain one made by hand carries none + TEST_ASSERT_NULL(human_npc_find_stim(most_wanted), "A plain Most Wanted club fighter carries a stimulant") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunman = make_normal_criminal(2, "pistol", tile(4, 4)) // BOUNTY_STYLE_PISTOL + TEST_ASSERT_NOTNULL(gunman, "Test fixture: no Wanted gunman was made") + var/datum/component/npc_combat_sense/gunman_sense = gunman.GetComponent(/datum/component/npc_combat_sense) + TEST_ASSERT(gunman_sense.rules.reach(gunman, gunman.ai_controller) > 3, "A pistol criminal counts as a close fighter") // HUMAN_NPC_SENSE_CLOSE_IN_REACH + var/datum/human_npc_order/order = spawn_human_npc(/mob/living/carbon/human/npc/faction_pirate/grey/ranged, tile(4, 0), immediate = TRUE) var/mob/living/carbon/human/npc/faction_pirate/grey/ranged/pirate = order?.spawned_ref?.resolve() qdel(order) diff --git a/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm b/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm index 15677552d34..a52ae18d4b9 100644 --- a/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm +++ b/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm @@ -14,6 +14,11 @@ for(var/prefix in prefixes) for(var/part in list("blood", "bone")) TEST_ASSERT(icon_exists(gore_icon, "[prefix]_[part]"), "Gore sheet is missing [prefix]_[part]") + // The neck the garrote cuts swaps in the wire's own stump (hyperviolence/wire/wire_seams.dm). + var/wire_icon = 'voidcrew/modules/hyperviolence/wire/icons/wire_gore.dmi' // WIRE_GORE_ICON + for(var/zone in GLOB.hv_wire_stump_zones) + for(var/part in list("blood", "bone")) + TEST_ASSERT(icon_exists(wire_icon, "stump_[zone]_wire_[part]"), "Wire sheet is missing stump_[zone]_wire_[part]") /// A torn-off limb leaves a wet stump, a clean removal a healed one, and a limb put back clears it. /datum/unit_test/hv_stump_overlays @@ -47,7 +52,24 @@ var/obj/item/bodypart/head = dummy.get_bodypart(BODY_ZONE_HEAD) TEST_ASSERT(head.dismember(), "The head would not come off") TEST_ASSERT("stump_head_blood" in dummy.hv_gore_states(), "Decapitation drew no neck stump") - + TEST_ASSERT(!LAZYACCESS(dummy.hv_stump_wire_cut, BODY_ZONE_HEAD), "A head torn off without the wire drew the wire's stump") + + // A head the wire takes (the garrote) leaves the wire's clean cut, seared dark by a hot wire. + var/mob/living/carbon/human/consistent/garroted = allocate(/mob/living/carbon/human/consistent) + TEST_ASSERT(hv_wire_take_part(garroted.get_bodypart(BODY_ZONE_HEAD)), "The wire would not take the head") + var/list/neck = garroted.hv_gore_states() + TEST_ASSERT("stump_head_wire_blood" in neck, "A head the wire took drew no wire stump: [english_list(neck)]") + TEST_ASSERT("stump_head_wire_bone" in neck, "A head the wire took drew no bone in its stump") + TEST_ASSERT(!("stump_head_blood" in neck), "A head the wire took drew the ragged stump too") + LAZYSET(garroted.hv_stump_burnt, BODY_ZONE_HEAD, TRUE) + garroted.hv_gore_key = null + garroted.hv_update_gore_overlays() + var/image/neck_blood + for(var/image/gore_image as anything in garroted.hv_gore_overlays) + if(gore_image.icon_state == "stump_head_wire_blood") + neck_blood = gore_image + TEST_ASSERT_NOTNULL(neck_blood, "A seared wire stump lost its picture") + TEST_ASSERT_EQUAL(neck_blood.color, "#2a1b15", "A seared wire stump wasn't charred") // WIRE_BURNT_STUMP_COLOR /// One heavy hit opens a skull wound, more damage widens it, healing closes it; small hits never open one. /datum/unit_test/hv_skull_wound diff --git a/voidcrew/modules/unit_tests/voidcrew_loot.dm b/voidcrew/modules/unit_tests/voidcrew_loot.dm index 9037d9e5d19..242a65edb83 100644 --- a/voidcrew/modules/unit_tests/voidcrew_loot.dm +++ b/voidcrew/modules/unit_tests/voidcrew_loot.dm @@ -504,11 +504,12 @@ TEST_ASSERT_EQUAL(spawned, 1, "Contraband did not pay exactly one green melee weapon") for(var/marker_path in list(/obj/effect/zone_mobs/syndicate, /obj/effect/zone_mobs/syndicate/boss)) var/obj/effect/zone_mobs/marker = new marker_path() + // Human NPC operatives (voidcrew/modules/human_npcs/ruins/); their tables also hold SMGs and shotguns back to the red zone. TEST_ASSERT_EQUAL(length(marker.mobs_green), 1, "Green syndicate pool still includes sword guards") - TEST_ASSERT(marker.mobs_green[/mob/living/basic/trooper/syndicate/melee], "Green syndicate guards lost their knives") + TEST_ASSERT(marker.mobs_green[/mob/living/carbon/human/npc/ruin/trooper/syndicate], "Green syndicate guards lost their knives") for(var/entry in marker.mobs_yellow) - TEST_ASSERT(!ispath(entry, /mob/living/basic/trooper/syndicate/ranged/smg) && !ispath(entry, /mob/living/basic/trooper/syndicate/ranged/shotgun), "Yellow syndicate guard has an advanced ranged weapon") - TEST_ASSERT(marker.mobs_red[/mob/living/basic/trooper/syndicate/ranged/smg] || marker.mobs_red[/mob/living/basic/trooper/syndicate/ranged/smg/space/stormtrooper], "Red syndicate pool lost its SMG guards") + TEST_ASSERT(!ispath(entry, /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg) && !ispath(entry, /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/shotgun), "Yellow syndicate guard has an advanced ranged weapon") + TEST_ASSERT(marker.mobs_red[/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg] || marker.mobs_red[/mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper], "Red syndicate pool lost its SMG guards") qdel(marker) /** @@ -740,6 +741,8 @@ /obj/item/claymore/cutlass/old, /obj/item/claymore/weak, /obj/item/crowbar/large/twenty_force, + /obj/item/cyberware_pair_case/gorilla_arms/street, + /obj/item/cyberware_pair_case/mantis_street, /obj/item/fireaxe/boardingaxe, /obj/item/fireaxe/boneaxe, /obj/item/gun/ballistic/automatic/ar, @@ -807,6 +810,7 @@ /obj/item/nullrod/vibro, /obj/item/nullrod/vibro/spellblade, /obj/item/nullrod/vibro/talking, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout, /obj/item/pen/edagger, /obj/item/shield/buckler, /obj/item/shield/buckler/parmula, @@ -828,6 +832,7 @@ /obj/item/cursed_katana, /obj/item/cyberware_pair_case/gorilla_arms, /obj/item/cyberware_pair_case/mantis_blades, + /obj/item/cyberware_pair_case/mantis_scorch, /obj/item/energy_katana, /obj/item/gun/ballistic/automatic/heater/scorcher, /obj/item/gun/ballistic/automatic/l6_saw/unrestricted, @@ -861,6 +866,7 @@ /obj/item/mjollnir, /obj/item/organ/cyberimp/arm/toolkit/cyberware/bunker_buster, /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live, /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin, /obj/item/shield/energy, /obj/item/singularityhammer, @@ -893,3 +899,23 @@ TEST_ASSERT(entry != /obj/item/his_grace, "His Grace remains in ordinary cache loot") for(var/entry in all_weapons) TEST_ASSERT(entry in seen, "Retained weapon [entry] lost its guarded cache source") + +/// Everything the street doc sells can also turn up in a zone cache (owner: low-tier chrome rides the loot pools too). +/datum/unit_test/voidcrew_street_chrome_in_loot + +/datum/unit_test/voidcrew_street_chrome_in_loot/Run() + var/list/lootable = list() + for(var/theme_path in GLOB.loot_themes) + var/datum/loot_theme/theme = GLOB.loot_themes[theme_path] + for(var/table_name in list("loot_common", "loot_uncommon", "loot_prime", "loot_uniques")) + for(var/entry in theme.vars[table_name]) + lootable[entry] = TRUE + for(var/extras_name in list("gun_extras", "melee_extras")) + var/list/extras = theme.vars[extras_name] + for(var/weapon_class in extras) + for(var/entry in extras[weapon_class]) + lootable[entry] = TRUE + var/datum/outpost_shop/vendor/street_doc/shop = allocate(/datum/outpost_shop/vendor/street_doc) + TEST_ASSERT(length(shop.skus), "The street doc has nothing on his shelf") + for(var/datum/shop_sku/sku as anything in shop.skus) + TEST_ASSERT(lootable[sku.item_path], "[sku.item_path], sold by the street doc, is in no loot theme") diff --git a/voidcrew/modules/unit_tests/voidcrew_mantis_gore.dm b/voidcrew/modules/unit_tests/voidcrew_mantis_gore.dm new file mode 100644 index 00000000000..5e5a860c919 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_mantis_gore.dm @@ -0,0 +1,960 @@ +/** + * # Mantis Blades x hyperviolence (voidcrew/modules/mantis_gore/) + * + * Arterial gashes, the impaling lunge, the scissor, the kill reset, the charged leap and the safe dash, + * the X-slash, blood on the blades and the stance. Unit-test files compile before voidcrew/_DEFINES/, so + * the fork's numbers are restated below under MG_ names. + */ + +/// MANTIS_MOVE_IMPALE, MANTIS_MOVE_XSLASH +#define MG_MOVE_IMPALE (1<<1) +#define MG_MOVE_XSLASH (1<<3) +/// MANTIS_IMPALE_TRAIT, MANTIS_CHARGE_TRAIT +#define MG_IMPALE_TRAIT "mantis_impale" +#define MG_CHARGE_TRAIT "mantis_charge" +/// TRAIT_CYBER_CAMO +#define MG_TRAIT_CAMO "cyber_camo" +/// HV_FINISHER_DONE and HV_FINISHER_DAMAGED +#define MG_FINISHER_DONE 1 +#define MG_FINISHER_DAMAGED 3 +/// MANTIS_GORE_ICON, MANTIS_GORE_LARGE_ICON and the held-blade files +#define MANTIS_TEST_ICON 'voidcrew/modules/mantis_gore/icons/mantis_gore.dmi' +#define MANTIS_TEST_LARGE_ICON 'voidcrew/modules/mantis_gore/icons/mantis_gore_large.dmi' +#define MANTIS_TEST_ARTERY_ICON 'voidcrew/modules/mantis_gore/icons/mantis_artery.dmi' +/// MANTIS_ARTERY_WOUND_RISE +#define MG_ARTERY_WOUND_RISE 16 +#define MANTIS_TEST_LEFTHAND 'voidcrew/modules/mantis_gore/icons/mantis_lefthand.dmi' +#define MANTIS_TEST_RIGHTHAND 'voidcrew/modules/mantis_gore/icons/mantis_righthand.dmi' +/// MANTIS_GORE_REACH_ICON +#define MANTIS_TEST_REACH_ICON 'voidcrew/modules/mantis_gore/icons/mantis_gore_reach.dmi' +/// MANTIS_RIG_ORDER +#define MG_RIG_ORDER 1 + +/datum/unit_test/voidcrew_mantis_gore + abstract_type = /datum/unit_test/voidcrew_mantis_gore + +/// The floor [dx], [dy] tiles from the test room's bottom-left corner +/datum/unit_test/voidcrew_mantis_gore/proc/spot(dx, dy) + return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) + +/// A human at [where] with both housings of [housing_type] installed. [out] extends the blades. +/datum/unit_test/voidcrew_mantis_gore/proc/bearer(turf/where, housing_type = /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis, out = TRUE) + var/mob/living/carbon/human/consistent/body = allocate(/mob/living/carbon/human/consistent, where) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right = allocate(housing_type) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left = allocate(text2path("[housing_type]/left")) + TEST_ASSERT(right.Insert(body, special = TRUE), "Fixture: the right housing would not install") + TEST_ASSERT(left.Insert(body, special = TRUE), "Fixture: the left housing would not install") + if(out) + right.Extend(right.contents[1]) + left.Extend(left.contents[1]) + TEST_ASSERT(right.blade_extended() && left.blade_extended(), "Fixture: the blades never came out") + return body + +/// [body]'s Mantis housings, right then left. +/datum/unit_test/voidcrew_mantis_gore/proc/housings(mob/living/carbon/body) + . = list() + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing in body.organs) + . += housing + +/// [body]'s held Mantis blade in its right hand, or the first one. +/datum/unit_test/voidcrew_mantis_gore/proc/right_blade(mob/living/carbon/body) + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing in body.organs) + if(housing.zone == BODY_ZONE_R_ARM) + return housing.active_item + return locate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis) in body.held_items + +/// A landed cut on [victim]'s [zone] with [blade], as the blade's own swing reads it. 10 a cut, so five +/// fit on one arm before it is at its most damage. +/datum/unit_test/voidcrew_mantis_gore/proc/cut(obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade, mob/living/user, mob/living/victim, zone, damage = 10) + blade.mantis_watch_cut(victim, user) + victim.apply_damage(damage, BRUTE, zone, 0, wound_bonus = CANT_WOUND, sharpness = SHARP_EDGED, attack_direction = EAST, attacking_item = blade) + blade.mantis_unwatch_cut(victim) + +/// Puts [victim] in crit with plenty of health to spare before death. That much air loss also knocks +/// them out, which still counts: out cold at crit health. +/// The blade rig's pictures standing on [body]'s tile (mantis_rig.dm). +/datum/unit_test/voidcrew_mantis_gore/proc/rig_pictures(mob/living/body) + . = list() + for(var/obj/effect/abstract/mantis_puppet/picture in get_turf(body)) + . += picture + +/datum/unit_test/voidcrew_mantis_gore/proc/crit(mob/living/carbon/victim) + victim.adjustOxyLoss(110) + TEST_ASSERT(mantis_in_crit(victim), "Fixture: [victim] isn't dying (stat [victim.stat], health [victim.health])") + +// --------------------------------------------------------------------------------------------- + +/// Three cuts on a bare limb tear its artery, five under light cover, never under heavy cover. The count +/// starts over after a gap, the Shiv never tears, and an Atlas frame (bone only) doesn't stop it. +/datum/unit_test/voidcrew_mantis_gore/artery + +/datum/unit_test/voidcrew_mantis_gore/artery/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 0)) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + var/limb_artery = /datum/wound/slash/flesh/critical/hv_carotid/limb + // One blade, so no X-slash follow-through adds to the limb between the counted cuts. + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/off_housing = housings(user)[2] + off_housing.Retract() + + var/mob/living/carbon/human/consistent/bare = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/obj/item/bodypart/arm = bare.get_bodypart(BODY_ZONE_L_ARM) + cut(blade, user, bare, BODY_ZONE_L_ARM) + cut(blade, user, bare, BODY_ZONE_L_ARM) + TEST_ASSERT(!arm.get_wound_type(limb_artery), "Two cuts tore the artery") + cut(blade, user, bare, BODY_ZONE_L_ARM) + var/datum/wound/slash/flesh/critical/hv_carotid/limb/torn = arm.get_wound_type(limb_artery) + TEST_ASSERT(torn, "Three cuts on a bare arm didn't tear its artery") + TEST_ASSERT_EQUAL(torn?.spurt_dir, EAST, "The artery doesn't pump the way the cut went") + var/found_line = FALSE + for(var/list/line as anything in bare.hv_hit?.lines) + if(findtext(line[1], "artery")) + found_line = TRUE + TEST_ASSERT(found_line, "The tear added no hit line") + TEST_ASSERT(blade.drenched_until > world.time, "A torn artery didn't drench the blade") + blade.stop_dripping() + + // Light cover (Slabskin-like plating 25, less the blade's 10): five cuts. + var/mob/living/carbon/human/consistent/plated = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + plated.physiology.armor = plated.physiology.armor.generate_new_with_modifiers(list(MELEE = 25)) + var/obj/item/bodypart/plated_arm = plated.get_bodypart(BODY_ZONE_R_ARM) + for(var/i in 1 to 4) + cut(blade, user, plated, BODY_ZONE_R_ARM) + TEST_ASSERT(!plated_arm.get_wound_type(limb_artery), "Four cuts tore a plated arm") + cut(blade, user, plated, BODY_ZONE_R_ARM) + TEST_ASSERT(plated_arm.get_wound_type(limb_artery), "Five cuts didn't tear a plated arm") + + // Heavy cover (45 less 10 = 35): never. + var/mob/living/carbon/human/consistent/armoured = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + armoured.physiology.armor = armoured.physiology.armor.generate_new_with_modifiers(list(MELEE = 45)) + var/obj/item/bodypart/armoured_leg = armoured.get_bodypart(BODY_ZONE_L_LEG) + for(var/i in 1 to 6) + cut(blade, user, armoured, BODY_ZONE_L_LEG) + TEST_ASSERT(!armoured_leg.get_wound_type(limb_artery), "A heavily armoured leg tore") + + // A gap starts the count over. + var/mob/living/carbon/human/consistent/patient = allocate(/mob/living/carbon/human/consistent, spot(2, 0)) + var/obj/item/bodypart/patient_leg = patient.get_bodypart(BODY_ZONE_R_LEG) + cut(blade, user, patient, BODY_ZONE_R_LEG) + cut(blade, user, patient, BODY_ZONE_R_LEG) + var/datum/status_effect/mantis_cuts/cuts = patient.has_status_effect(/datum/status_effect/mantis_cuts) + TEST_ASSERT(cuts, "Cuts left no count on the target") + cuts.limb_cut_times[BODY_ZONE_R_LEG] = world.time - 9 SECONDS + cut(blade, user, patient, BODY_ZONE_R_LEG) + TEST_ASSERT(!patient_leg.get_wound_type(limb_artery), "The count carried over a gap") + TEST_ASSERT_EQUAL(cuts.limb_cuts[BODY_ZONE_R_LEG], 1, "The count didn't start over after a gap") + + // A light cut doesn't count. + var/mob/living/carbon/human/consistent/grazed = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + var/obj/item/bodypart/grazed_arm = grazed.get_bodypart(BODY_ZONE_L_ARM) + for(var/i in 1 to 4) + cut(blade, user, grazed, BODY_ZONE_L_ARM, 5) + TEST_ASSERT(!grazed_arm.get_wound_type(limb_artery), "Grazes tore an artery") + + // Atlas covers bone, not soft tissue. + var/mob/living/carbon/human/consistent/framed = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + ADD_TRAIT(framed, TRAIT_NODISMEMBER, TRAIT_SOURCE_UNIT_TESTS) + for(var/i in 1 to 3) + cut(blade, user, framed, BODY_ZONE_R_ARM) + TEST_ASSERT(framed.get_bodypart(BODY_ZONE_R_ARM).get_wound_type(limb_artery), "An Atlas frame stopped the artery tear") + + // The neck is #509's slit throat. + var/mob/living/carbon/human/consistent/necked = allocate(/mob/living/carbon/human/consistent, spot(3, 0)) + for(var/i in 1 to 3) + cut(blade, user, necked, BODY_ZONE_HEAD) + TEST_ASSERT(necked.get_bodypart(BODY_ZONE_HEAD).get_wound_type(/datum/wound/slash/flesh/critical/hv_carotid), "Three cuts on the neck didn't slit the throat") + + // The Shiv only bleeds them. + var/mob/living/carbon/human/shiv_user = bearer(spot(4, 4), /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/shiv = right_blade(shiv_user) + var/mob/living/carbon/human/consistent/shivved = allocate(/mob/living/carbon/human/consistent, spot(3, 4)) + for(var/i in 1 to 4) + cut(shiv, shiv_user, shivved, BODY_ZONE_L_ARM) + TEST_ASSERT(!shivved.get_bodypart(BODY_ZONE_L_ARM).get_wound_type(limb_artery), "The Shiv tore an artery") + + // The Scorch sears it half shut. + var/mob/living/carbon/human/scorch_user = bearer(spot(4, 0), /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/scorch) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch = right_blade(scorch_user) + var/mob/living/carbon/human/consistent/seared = allocate(/mob/living/carbon/human/consistent, spot(3, 1)) + for(var/i in 1 to 3) + cut(scorch, scorch_user, seared, BODY_ZONE_L_LEG) + var/datum/wound/seared_wound = seared.get_bodypart(BODY_ZONE_L_LEG).get_wound_type(/datum/wound/slash/flesh/critical/hv_carotid/limb/seared) + TEST_ASSERT(seared_wound, "Three scorch cuts didn't sear the artery open") + TEST_ASSERT(seared_wound?.blood_flow < torn?.blood_flow, "The seared artery bleeds as hard as a cut one") + +/// The limb artery: no gargle, a hemostat clamps it, and the seared one clots. +/datum/unit_test/voidcrew_mantis_gore/wounds + +/datum/unit_test/voidcrew_mantis_gore/wounds/Run() + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_R_ARM) + var/datum/wound/slash/flesh/critical/hv_carotid/limb/torn = hv_crit_apply_wound(arm, /datum/wound/slash/flesh/critical/hv_carotid/limb, WEST, null) + TEST_ASSERT(torn, "The limb artery wound would not apply") + TEST_ASSERT_EQUAL(torn.spurt_dir, WEST, "The limb artery forgot the cut's direction") + TEST_ASSERT_EQUAL(torn.next_spurt, INFINITY, "The throat's pulse still runs on a limb") + var/list/message_args = list("hello there") + torn.gargle_speech(victim, message_args) + TEST_ASSERT_EQUAL(message_args[TREAT_MESSAGE_ARG], "hello there", "An arm wound gargled speech") + var/before = torn.blood_flow + torn.clamped = TRUE + torn.adjust_blood_flow(-2.5) + TEST_ASSERT(torn.blood_flow < before, "Clamping did nothing") + var/obj/item/bodypart/leg = victim.get_bodypart(BODY_ZONE_L_LEG) + var/datum/wound/slash/flesh/critical/hv_carotid/limb/seared/seared = hv_crit_apply_wound(leg, /datum/wound/slash/flesh/critical/hv_carotid/limb/seared, EAST, null) + TEST_ASSERT(seared, "The seared artery would not apply") + TEST_ASSERT(seared.clot_rate > 0, "The seared artery never clots") + TEST_ASSERT(GLOB.all_wound_pregen_data[/datum/wound/slash/flesh/critical/hv_carotid/limb], "The limb artery has no pregen data") + TEST_ASSERT(!GLOB.all_wound_pregen_data[/datum/wound/slash/flesh/critical/hv_carotid/limb].can_be_randomly_generated, "The limb artery can come from tg's random wound roll") + +/// Two blades into someone hurt hold them; a wall behind pins them longer. Safety ends it with no rip, +/// the rip floors them, and everything is put back. +/datum/unit_test/voidcrew_mantis_gore/impale + +/datum/unit_test/voidcrew_mantis_gore/impale/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 2)) + var/list/held_housings = housings(user) + var/datum/action/cooldown/cyberware/mantis_lunge/lunge = locate() in mantis_lunge_actions(user) + + var/mob/living/carbon/human/consistent/fresh = allocate(/mob/living/carbon/human/consistent, spot(1, 2)) + TEST_ASSERT(!mantis_can_impale(user, fresh, held_housings), "Someone unhurt can be skewered") + fresh.adjustBruteLoss(40) + TEST_ASSERT(mantis_can_impale(user, fresh, held_housings), "Someone at 60% health can't be skewered") + TEST_ASSERT(!mantis_can_impale(user, fresh, list(held_housings[1])), "One blade skewered") + fresh.mob_size = MOB_SIZE_LARGE + TEST_ASSERT(!mantis_can_impale(user, fresh, held_housings), "Something big was skewered") + fresh.mob_size = MOB_SIZE_HUMAN + var/mob/living/carbon/human/consistent/floored = allocate(/mob/living/carbon/human/consistent, spot(1, 3)) + floored.Knockdown(10 SECONDS) + TEST_ASSERT(mantis_can_impale(user, floored, held_housings), "Someone on the floor can't be skewered") + // Off the floor and up on the blades: drawn upright, still lying down to tg, and laid back down after. + var/datum/mantis_impale/hoisted = new(user, floored, held_housings, 2 SECONDS) + TEST_ASSERT(hoisted.start(), "Someone on the floor wasn't skewered") + TEST_ASSERT(hoisted.hoist_angle, "Someone on the floor wasn't brought up on the blades") + TEST_ASSERT(abs(floored.transform.b) < 0.01 && floored.transform.a > 0.99, "Someone brought up on the blades isn't drawn upright") + TEST_ASSERT_EQUAL(floored.body_position, LYING_DOWN, "Bringing them up stood them up") + hoisted.begin_rig() + hoisted.finish() + TEST_ASSERT(!hoisted.hoist_angle, "The hoist outlived the hold") + TEST_ASSERT(!length(rig_pictures(user)), "The blades stayed drawn after the hold") + var/mob/living/basic/mouse/mouse = allocate(/mob/living/basic/mouse, spot(1, 1)) + TEST_ASSERT(!mantis_can_impale(user, mouse, held_housings), "A mouse was skewered") + + // Open floor behind: held up for the short beat. + TEST_ASSERT(mantis_start_impale(lunge, user, fresh, held_housings, 2 SECONDS), "The impale didn't start") + var/datum/mantis_impale/skewer = lunge.impale + TEST_ASSERT(skewer, "The lunge doesn't know about its skewer") + TEST_ASSERT(!skewer.wall_pin, "Open floor counted as a wall") + TEST_ASSERT_EQUAL(skewer.hold_time, 0.8 SECONDS, "The open hold isn't 0.8 seconds") + TEST_ASSERT(HAS_TRAIT_FROM(user, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT) && HAS_TRAIT_FROM(user, TRAIT_HANDS_BLOCKED, MG_IMPALE_TRAIT), "The bearer isn't rooted with full hands") + TEST_ASSERT(HAS_TRAIT_FROM(fresh, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT), "The victim isn't held") + TEST_ASSERT(!HAS_TRAIT(fresh, TRAIT_HANDS_BLOCKED), "The victim's hands are tied") + TEST_ASSERT_EQUAL(fresh.dir, WEST, "The victim wasn't turned onto the blades") + // The bearer is drawn by the rig from the glide in; the lunging body lands and the blades go in: drawn + // under them and over them. + TEST_ASSERT(skewer.rig, "The lunging body isn't drawn by the rig") + skewer.begin_rig() + skewer.stab() + TEST_ASSERT(skewer.rig, "The bearer isn't drawn around the victim") + TEST_ASSERT(fresh.has_offset(MG_IMPALE_TRAIT, PIXEL_W_OFFSET) < 0, "The victim isn't drawn onto the blades") + var/list/pictures = rig_pictures(user) + TEST_ASSERT_EQUAL(length(pictures), 5, "The blades going in aren't drawn in four pieces and the wounds") + var/under = 0 + var/over = 0 + for(var/obj/effect/abstract/mantis_puppet/picture as anything in pictures) + if(picture.layer < fresh.layer) + under++ + else if(picture.layer > fresh.layer) + over++ + TEST_ASSERT(under == 2 && over == 3, "The bearer isn't split around the victim ([under] under, [over] over)") + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/held_blade = right_blade(user) + TEST_ASSERT(held_blade.inhand_hidden_until > world.time, "The held blade is drawn over the blades going in") + skewer.show_beat("hold") + TEST_ASSERT(fresh.has_offset(MG_IMPALE_TRAIT, PIXEL_Z_OFFSET) > 0, "The victim isn't lifted") + var/brute_before = fresh.getBruteLoss() + skewer.rip() + TEST_ASSERT(HAS_TRAIT_FROM(fresh, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT), "The pull-back let them go before the blades came out") + var/datum/mantis_rig/dropping = skewer.rig + skewer.tear_out() + TEST_ASSERT(!dropping || !QDELETED(dropping), "The bearer wasn't drawn through the drop") + qdel(dropping) + TEST_ASSERT(!length(rig_pictures(user)), "The blades stayed drawn in them after the rip") + TEST_ASSERT(!user.get_filter("mantis_rig_hide"), "The bearer is still hidden after the rip") + TEST_ASSERT(!held_blade.inhand_hidden_until, "The held blade never came back") + TEST_ASSERT(fresh.getBruteLoss() > brute_before, "The rip did no damage") + TEST_ASSERT(fresh.IsKnockdown(), "The rip didn't floor them") + TEST_ASSERT(!HAS_TRAIT_FROM(user, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT) && !HAS_TRAIT_FROM(user, TRAIT_HANDS_BLOCKED, MG_IMPALE_TRAIT), "The bearer is still held") + TEST_ASSERT(!HAS_TRAIT_FROM(fresh, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT), "The victim is still held") + TEST_ASSERT(!fresh.has_offset(MG_IMPALE_TRAIT, PIXEL_Z_OFFSET), "The victim's lift outlived the hold") + TEST_ASSERT(isnull(lunge.impale), "The lunge still holds a skewer") + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + TEST_ASSERT_EQUAL(blade.mantis_pose, "guard", "The blades didn't come back to the guard") + TEST_ASSERT(blade.drenched_until > world.time, "The rip didn't drench the blades") + blade.stop_dripping() + + // A wall right behind: pinned for longer. + var/mob/living/carbon/human/consistent/pinned = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + pinned.adjustBruteLoss(40) + allocate(/obj/structure/window/fulltile, spot(3, 2)) + user.forceMove(spot(1, 2)) + TEST_ASSERT(mantis_start_impale(lunge, user, pinned, held_housings, 2 SECONDS), "The wall impale didn't start") + skewer = lunge.impale + TEST_ASSERT(skewer.wall_pin, "A window behind them didn't pin them") + TEST_ASSERT_EQUAL(skewer.hold_time, 1.5 SECONDS, "The pin isn't 1.5 seconds") + // It runs out on its own and rips: the 1.5 s hold, up to a 0.2 s tick, then the 0.4 s pull-back and tear-out. + sleep(2.5 SECONDS) + TEST_ASSERT(isnull(lunge.impale), "The pin never ended") + TEST_ASSERT(pinned.IsKnockdown(), "The pin ended without the rip") + + // An EMP stows a blade: it ends at once, no rip. + var/mob/living/carbon/human/consistent/emp_victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + emp_victim.adjustBruteLoss(40) + user.forceMove(spot(1, 1)) + TEST_ASSERT(mantis_start_impale(lunge, user, emp_victim, held_housings, 2 SECONDS), "The EMP impale didn't start") + skewer = lunge.impale + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in held_housings) + housing.Retract() + skewer.tick() + TEST_ASSERT(isnull(lunge.impale), "Stowed blades kept them held") + TEST_ASSERT(!emp_victim.IsKnockdown(), "Stowed blades still ripped out") + TEST_ASSERT(!HAS_TRAIT_FROM(emp_victim, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT), "Stowed blades left the victim held") + for(var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/housing as anything in held_housings) + housing.Extend(housing.contents[1]) + + // Teleported out: ends. + var/mob/living/carbon/human/consistent/jaunter = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + jaunter.adjustBruteLoss(40) + TEST_ASSERT(mantis_start_impale(lunge, user, jaunter, held_housings, 2 SECONDS), "The teleport impale didn't start") + jaunter.forceMove(spot(4, 4)) + TEST_ASSERT(isnull(lunge.impale), "Teleporting away didn't end the hold") + TEST_ASSERT(!HAS_TRAIT_FROM(jaunter, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT), "Teleporting away left them held") + + // Died on the blades: ends. + var/mob/living/carbon/human/consistent/goner = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + goner.adjustBruteLoss(40) + TEST_ASSERT(mantis_start_impale(lunge, user, goner, held_housings, 2 SECONDS), "The death impale didn't start") + goner.death() + TEST_ASSERT(isnull(lunge.impale), "A death on the blades didn't end the hold") + TEST_ASSERT(!HAS_TRAIT_FROM(user, TRAIT_IMMOBILIZED, MG_IMPALE_TRAIT), "A death on the blades left the bearer rooted") + + // Hit hard while holding: lets go at half the rip, and staggers. + var/mob/living/carbon/human/consistent/rescued = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + rescued.adjustBruteLoss(40) + TEST_ASSERT(mantis_start_impale(lunge, user, rescued, held_housings, 2 SECONDS), "The interrupted impale didn't start") + user.apply_damage(16, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(isnull(lunge.impale), "Taking a beating didn't break the hold") + TEST_ASSERT(user.has_status_effect(/datum/status_effect/staggered), "Losing the grip didn't stagger the bearer") + TEST_ASSERT(rescued.IsKnockdown(), "Losing the grip didn't drop them") + +/// Crit only, any player on any player, never someone strapped down; damage breaks it; Atlas keeps the +/// head on; otherwise the head comes off with the brain. +/datum/unit_test/voidcrew_mantis_gore/scissor + +/datum/unit_test/voidcrew_mantis_gore/scissor/Run() + var/mob/living/carbon/human/user = bearer(spot(1, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + victim.Knockdown(30 SECONDS) + var/datum/hv_finisher/mantis_scissor/early = allocate(/datum/hv_finisher/mantis_scissor, user, victim) + TEST_ASSERT(!early.can_start(), "Someone only knocked down can be scissored") + crit(victim) + TEST_ASSERT(!hv_finisher_valid_victim(user, victim), "Test premise: #509's check now lets players finish players") + TEST_ASSERT(early.can_start(), "Someone dying can't be scissored by another player") + ADD_TRAIT(user, TRAIT_PACIFISM, TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT(!early.can_start(), "A pacifist can scissor") + REMOVE_TRAIT(user, TRAIT_PACIFISM, TRAIT_SOURCE_UNIT_TESTS) + + var/obj/structure/chair/chair = allocate(/obj/structure/chair, spot(2, 1)) + chair.buckle_mob(victim, force = TRUE) + TEST_ASSERT(!early.can_start(), "Someone strapped to a chair can be scissored") + chair.unbuckle_mob(victim, force = TRUE) + + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left = housings(user)[2] + left.Retract() + TEST_ASSERT(!early.can_start(), "One blade can scissor") + left.Extend(left.contents[1]) + + // Started by the swing: combat mode, head aimed. + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + user.set_combat_mode(TRUE) + user.zone_selected = BODY_ZONE_CHEST + TEST_ASSERT(!blade.mantis_try_scissor(victim, user), "A chest swing started the scissor") + user.zone_selected = BODY_ZONE_HEAD + TEST_ASSERT(blade.attack(victim, user, list(), list()), "A head swing at someone dying didn't start the scissor") + var/datum/hv_finisher/mantis_scissor/scissor = user.mantis_state?.scissor + TEST_ASSERT(scissor?.running, "The scissor isn't running") + TEST_ASSERT_EQUAL(blade.mantis_pose, "raise", "The blades didn't rise for the wind-up") + + // Hurt it: it reels back. + user.apply_damage(16, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(scissor.result, MG_FINISHER_DAMAGED, "Damage didn't break the scissor") + TEST_ASSERT(user.has_status_effect(/datum/status_effect/hv_finisher_reeling), "The bearer didn't reel") + TEST_ASSERT_EQUAL(blade.mantis_pose, "guard", "The blades stayed raised") + TEST_ASSERT(isnull(user.mantis_state.scissor), "The broken scissor is still on the bearer") + TEST_ASSERT(!blade.mantis_try_scissor(victim, user), "The scissor has no cooldown") + user.remove_status_effect(/datum/status_effect/hv_finisher_reeling) + user.mantis_state.next_scissor = 0 + user.heal_overall_damage(brute = 50) + + // Atlas: the blades stop on metal, the head stays. + ADD_TRAIT(victim, TRAIT_NODISMEMBER, TRAIT_SOURCE_UNIT_TESTS) + var/datum/hv_finisher/mantis_scissor/framed = allocate(/datum/hv_finisher/mantis_scissor, user, victim, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_scissor_ended))) + TEST_ASSERT(framed.start(), "The scissor didn't start on an Atlas body") + var/head_brute = victim.get_bodypart(BODY_ZONE_HEAD).brute_dam + for(var/i in 1 to 20) + if(!framed.running) + break + framed.advance() + TEST_ASSERT(framed.completed, "The Atlas scissor never closed") + TEST_ASSERT(victim.get_bodypart(BODY_ZONE_HEAD), "An Atlas body lost its head") + TEST_ASSERT(victim.get_bodypart(BODY_ZONE_HEAD).brute_dam > head_brute, "The blades did nothing to the Atlas neck") + REMOVE_TRAIT(victim, TRAIT_NODISMEMBER, TRAIT_SOURCE_UNIT_TESTS) + // Ended as the game ends one (mantis_try_scissor()'s callback): the rig fades into the real bearer + sleep(0.25 SECONDS) // mantis_rig/hand_back(), MANTIS_RIG_HANDBACK 0.15 s + + // The head comes off, brain inside, and lands where they lie. + // Side on (west of the bearer), where the rig draws a far blade: north or south it draws both arms as one piece + var/mob/living/carbon/human/consistent/doomed = allocate(/mob/living/carbon/human/consistent, spot(0, 1)) + crit(doomed) + var/datum/hv_finisher/mantis_scissor/kill = allocate(/datum/hv_finisher/mantis_scissor, user, doomed, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(mantis_scissor_ended))) + TEST_ASSERT(kill.start(), "The scissor didn't start") + TEST_ASSERT(kill.rig, "The bearer isn't drawn around the victim") + kill.advance() + // The cut opens on the swing down and shows the blades meeting a step later (MANTIS_SCISSOR_SWING_STEP): show + // that beat now, as its timer would + var/datum/hv_finisher_stage/kill/decapitate/mantis/cut = kill.current_stage + TEST_ASSERT(istype(cut), "The scissor's second stage isn't the cut") + cut.close() + var/list/closing = rig_pictures(user) + var/below = 0 + for(var/obj/effect/abstract/mantis_puppet/picture as anything in closing) + if(picture.layer < doomed.layer) + below++ + TEST_ASSERT(length(closing) == 4 && below == 1, "The closing blades aren't drawn with the far blade under the neck ([length(closing)] pieces, [below] under)") + TEST_ASSERT(right_blade(user).inhand_hidden_until > world.time, "The held blade is drawn over the closing blades") + for(var/i in 1 to 20) + if(!kill.running) + break + kill.advance() + TEST_ASSERT_EQUAL(kill.result, MG_FINISHER_DONE, "The scissor didn't finish") + sleep(0.25 SECONDS) // the rig fades out (mantis_rig/hand_back(), MANTIS_RIG_HANDBACK 0.15 s) + TEST_ASSERT(!length(rig_pictures(user)) && !user.get_filter("mantis_rig_hide"), "The bearer is still drawn by the rig after the scissor") + TEST_ASSERT_NULL(doomed.get_bodypart(BODY_ZONE_HEAD), "The head is still on") + var/obj/item/bodypart/head/head = locate() in get_turf(doomed) + TEST_ASSERT(head, "The head isn't at their feet") + TEST_ASSERT(locate(/obj/item/organ/brain) in head, "The brain didn't stay in the head") + + // A human NPC below boss rank never scissors. + var/mob/living/carbon/human/npc/grunt = allocate(/mob/living/carbon/human/npc, spot(3, 3)) + var/mob/living/carbon/human/consistent/npc_victim = allocate(/mob/living/carbon/human/consistent, spot(3, 2)) + crit(npc_victim) + var/datum/hv_finisher/mantis_scissor/npc_try = allocate(/datum/hv_finisher/mantis_scissor, grunt, npc_victim) + TEST_ASSERT(!grunt.hv_can_execute() && !npc_try.can_start(), "An ordinary NPC can scissor") + +/// From a corner a head swing at someone dying is only a swing: the scissor starts square on. +/datum/unit_test/voidcrew_mantis_gore/scissor_square_on + +/datum/unit_test/voidcrew_mantis_gore/scissor_square_on/Run() + var/mob/living/carbon/human/user = bearer(spot(1, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + crit(victim) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + user.set_combat_mode(TRUE) + user.zone_selected = BODY_ZONE_HEAD + TEST_ASSERT(!blade.mantis_try_scissor(victim, user), "The scissor started on someone on a corner") + var/hurt_before = victim.getBruteLoss() + victim.getFireLoss() + blade.attack(victim, user, list(), list()) + TEST_ASSERT(isnull(user.mantis_state?.scissor), "A corner swing started the scissor") + TEST_ASSERT(victim.getBruteLoss() + victim.getFireLoss() > hurt_before, "The corner swing didn't cut") + + // Square on, it starts; dragged onto a corner before the cut, it stops + victim.forceMove(spot(2, 1)) + user.next_move = 0 + var/datum/outpost_pvp_enforcement/real_enforcement = GLOB.outpost_pvp_enforcement + var/datum/outpost_pvp_enforcement/gorilla_spy/spy = new + GLOB.outpost_pvp_enforcement = spy + var/started = blade.mantis_try_scissor(victim, user) + GLOB.outpost_pvp_enforcement = real_enforcement + TEST_ASSERT(started, "The scissor didn't start square on") + TEST_ASSERT(victim in spy.hits, "The scissor didn't count as an attack at a trader outpost") + var/datum/hv_finisher/mantis_scissor/scissor = user.mantis_state.scissor + TEST_ASSERT(scissor?.running, "The scissor isn't running") + victim.forceMove(spot(2, 2)) + TEST_ASSERT(QDELETED(scissor) || !scissor.running, "The scissor went on with the body on a corner") + TEST_ASSERT(isnull(user.mantis_state.scissor), "The stopped scissor is still on the bearer") + // The rig fades back into the real bearer (MANTIS_RIG_HANDBACK), then goes + sleep(0.35 SECONDS) // MANTIS_RIG_HANDBACK is 0.15 s + TEST_ASSERT(!length(rig_pictures(user)), "A scissor stopped on a corner left the bearer drawn by the rig") + +/// Who counts, at most once per bearer per 8 s and per body per 2 min, never prisoners, only kills +/// within 5 s of the bearer's cut, and never under 3 s. +/datum/unit_test/voidcrew_mantis_gore/reset + +/datum/unit_test/voidcrew_mantis_gore/reset/proc/cooldown_left(mob/living/carbon/body) + var/datum/action/cooldown/cyberware/mantis_lunge/lunge = locate() in mantis_lunge_actions(body) + return lunge.next_use_time - world.time + +/datum/unit_test/voidcrew_mantis_gore/reset/proc/wind_up(mob/living/carbon/body) + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge as anything in mantis_lunge_actions(body)) + lunge.StartCooldown(20 SECONDS) + +/datum/unit_test/voidcrew_mantis_gore/reset/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 0)) + TEST_ASSERT(length(mantis_lunge_actions(user)) == 2, "Fixture: the bearer hasn't two lunge buttons") + + var/mob/living/carbon/human/consistent/person = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/mob/living/carbon/human/species/monkey/monkey = allocate(/mob/living/carbon/human/species/monkey, spot(1, 1)) + var/mob/living/basic/mouse/mouse = allocate(/mob/living/basic/mouse, spot(1, 2)) + TEST_ASSERT(mantis_kill_reset_counts(person), "A person doesn't count") + TEST_ASSERT(!mantis_kill_reset_counts(monkey), "A monkey counts") + TEST_ASSERT(!mantis_kill_reset_counts(mouse), "A mouse counts") + mouse.maxHealth = 150 + TEST_ASSERT(mantis_kill_reset_counts(mouse), "Something big doesn't count") + + wind_up(user) + TEST_ASSERT(mantis_try_kill_reset(user, person), "A kill didn't reset the lunge") + TEST_ASSERT(cooldown_left(user) <= 3 SECONDS && cooldown_left(user) > 0, "The reset isn't down to 3 seconds") + + // Once per 8 seconds. + var/mob/living/carbon/human/consistent/second = allocate(/mob/living/carbon/human/consistent, spot(2, 0)) + wind_up(user) + TEST_ASSERT(!mantis_try_kill_reset(user, second), "Two resets inside 8 seconds") + user.mantis_state.next_kill_reset = 0 + TEST_ASSERT(mantis_try_kill_reset(user, second), "The second kill after the 8 seconds didn't reset") + + // Once per body per 2 minutes. + user.mantis_state.next_kill_reset = 0 + wind_up(user) + TEST_ASSERT(!mantis_try_kill_reset(user, person), "The same body reset twice inside 2 minutes") + person.mantis_reset_given_at = world.time - 2 MINUTES - 1 + TEST_ASSERT(mantis_try_kill_reset(user, person), "The body still blocks after 2 minutes") + + // Never prisoners. + var/mob/living/carbon/human/consistent/prisoner = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + ADD_TRAIT(prisoner, TRAIT_RESTRAINED, TRAIT_SOURCE_UNIT_TESTS) + user.mantis_state.next_kill_reset = 0 + wind_up(user) + TEST_ASSERT(!mantis_try_kill_reset(user, prisoner), "Killing a cuffed prisoner reset the lunge") + var/mob/living/carbon/human/consistent/strapped = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + var/obj/structure/chair/chair = allocate(/obj/structure/chair, spot(2, 2)) + chair.buckle_mob(strapped, force = TRUE) + TEST_ASSERT(!mantis_try_kill_reset(user, strapped), "Killing someone strapped down reset the lunge") + + // Never shorter than the floor: a cooldown already under 3 s is left alone. + for(var/datum/action/cooldown/cyberware/mantis_lunge/lunge as anything in mantis_lunge_actions(user)) + lunge.StartCooldown(2 SECONDS) + var/mob/living/carbon/human/consistent/late = allocate(/mob/living/carbon/human/consistent, spot(3, 0)) + TEST_ASSERT(!mantis_try_kill_reset(user, late), "A reset lengthened a short cooldown") + TEST_ASSERT(cooldown_left(user) <= 2 SECONDS, "A short cooldown got longer") + + // Through the death signal: a cut 6 seconds back is not the kill; a fresh one is. + user.mantis_state.next_kill_reset = 0 + wind_up(user) + var/mob/living/carbon/human/consistent/bled_out = allocate(/mob/living/carbon/human/consistent, spot(3, 1)) + var/datum/status_effect/mantis_cuts/old_cuts = mantis_note_hit(bled_out, user) + old_cuts.last_hit = world.time - 6 SECONDS + bled_out.death() + TEST_ASSERT(cooldown_left(user) > 3 SECONDS, "A death long after the cut reset the lunge") + var/mob/living/carbon/human/consistent/killed = allocate(/mob/living/carbon/human/consistent, spot(3, 2)) + mantis_note_hit(killed, user) + killed.death() + TEST_ASSERT(cooldown_left(user) <= 3 SECONDS, "A fresh kill didn't reset the lunge") + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + TEST_ASSERT(blade.drenched_until > world.time, "A kill didn't drench the blades") + blade.stop_dripping() + + // A plain NPC bearer gets no reset. + var/mob/living/carbon/human/npc/grunt = allocate(/mob/living/carbon/human/npc, spot(4, 4)) + var/mob/living/carbon/human/consistent/npc_kill = allocate(/mob/living/carbon/human/consistent, spot(4, 3)) + TEST_ASSERT(!mantis_try_kill_reset(grunt, npc_kill), "An ordinary NPC got a reset") + +/// The hold to charge: reach by hold time, the field drops at the press, a hit breaks the crouch for the +/// whole cooldown, a light hit doesn't, it straightens up on its own, and a release leaps. +/datum/unit_test/voidcrew_mantis_gore/charge + +/datum/unit_test/voidcrew_mantis_gore/charge/Run() + TEST_ASSERT_EQUAL(mantis_charge_range(0.2 SECONDS, 5), 5, "A tap reaches further than the lunge") + TEST_ASSERT_EQUAL(mantis_charge_range(0.35 SECONDS, 5), 5, "The start of the crouch reaches further than the lunge") + TEST_ASSERT_EQUAL(mantis_charge_range(0.775 SECONDS, 5), 6, "Halfway reaches the wrong distance") + TEST_ASSERT_EQUAL(mantis_charge_range(1.2 SECONDS, 5), 7, "A full charge doesn't reach 7") + TEST_ASSERT_EQUAL(mantis_charge_range(3 SECONDS, 5), 7, "A long hold reaches past 7") + + var/mob/living/carbon/human/user = bearer(spot(0, 0)) + var/obj/item/organ/cyberimp/cyberware/ghostskin/weave = allocate(/obj/item/organ/cyberimp/cyberware/ghostskin) + TEST_ASSERT(weave.Insert(user, special = TRUE), "Fixture: the weave would not install") + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(4, 0)) + var/datum/action/cooldown/cyberware/mantis_lunge/lunge = locate() in mantis_lunge_actions(user) + weave.engage_camo(user) + TEST_ASSERT(HAS_TRAIT(user, MG_TRAIT_CAMO), "Fixture: the field didn't come up") + TEST_ASSERT(lunge.begin_charge(target), "The charge didn't begin") + TEST_ASSERT(!HAS_TRAIT(user, MG_TRAIT_CAMO), "The field stayed up through the press") + + // The crouch, then a solid hit. + lunge.enter_crouch() + TEST_ASSERT(lunge.crouched, "The crouch didn't show") + TEST_ASSERT(HAS_TRAIT_FROM(user, TRAIT_IMMOBILIZED, MG_CHARGE_TRAIT), "The crouch isn't rooted") + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + TEST_ASSERT_EQUAL(blade.mantis_pose, "coil", "The blades aren't drawn back") + user.apply_damage(5, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(lunge.crouched, "A graze broke the crouch") + user.apply_damage(12, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(!lunge.crouched, "A solid hit didn't break the crouch") + TEST_ASSERT(!HAS_TRAIT_FROM(user, TRAIT_IMMOBILIZED, MG_CHARGE_TRAIT), "The broken crouch is still rooted") + TEST_ASSERT(!user.has_offset(MG_CHARGE_TRAIT, PIXEL_Z_OFFSET), "The broken crouch left the bearer sunk") + for(var/datum/action/cooldown/cyberware/mantis_lunge/each as anything in mantis_lunge_actions(user)) + TEST_ASSERT(each.next_use_time - world.time > 15 SECONDS, "A broken crouch didn't cost the full cooldown") + each.ResetCooldown() + TEST_ASSERT_EQUAL(blade.mantis_pose, "guard", "The blades stayed drawn back") + user.heal_overall_damage(brute = 50) + user.mantis_state.next_charge = 0 + + // Held too long: straightens up, no cooldown, a moment before setting again. + TEST_ASSERT(lunge.begin_charge(target), "The second charge didn't begin") + lunge.enter_crouch() + lunge.charge_started = world.time - 3.1 SECONDS + lunge.crouch_tick() + TEST_ASSERT(!lunge.crouched, "A long hold never straightened up") + TEST_ASSERT(lunge.IsAvailable(), "Straightening up cost the cooldown") + TEST_ASSERT(!lunge.begin_charge(target), "The bearer set again at once") + user.mantis_state.next_charge = 0 + + // Released after a full charge: the leap lands next to them. + TEST_ASSERT(lunge.begin_charge(target), "The third charge didn't begin") + lunge.enter_crouch() + lunge.charge_started = world.time - 1.2 SECONDS + TEST_ASSERT(lunge.release_charge(), "The release didn't leap") + TEST_ASSERT(user.Adjacent(target), "The leap didn't land beside the target") + TEST_ASSERT(!lunge.crouched && !HAS_TRAIT_FROM(user, TRAIT_IMMOBILIZED, MG_CHARGE_TRAIT), "The leap left the bearer crouched") + TEST_ASSERT(!lunge.IsAvailable(), "The leap cost no cooldown") + // They go down with the impact, once the body has glided in (land_lunge(), mantis_lunge_knockdown()) + sleep(1 SECONDS) + TEST_ASSERT(target.IsKnockdown(), "The leap didn't drop the target") + +/// The dash stops at the edge of a chasm or lava, never on it. +/datum/unit_test/voidcrew_mantis_gore/lunge_path + var/list/turf/changed_turfs = list() + var/list/original_turf_types = list() + +/datum/unit_test/voidcrew_mantis_gore/lunge_path/Destroy() + for(var/i in 1 to length(changed_turfs)) + var/turf/changed = changed_turfs[i] + changed.ChangeTurf(original_turf_types[i]) + return ..() + +/datum/unit_test/voidcrew_mantis_gore/lunge_path/Run() + for(var/hazard in list(/turf/open/chasm, /turf/open/lava/smooth)) + var/mob/living/carbon/human/user = bearer(spot(0, 2)) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(4, 2)) + var/turf/gap = spot(2, 2) + original_turf_types += gap.type + changed_turfs += gap.ChangeTurf(hazard) + var/datum/action/cooldown/cyberware/mantis_lunge/lunge = locate() in mantis_lunge_actions(user) + lunge.do_lunge(WEAKREF(target)) + TEST_ASSERT_EQUAL(get_turf(user), spot(1, 2), "The dash didn't stop at the edge of [hazard]") + TEST_ASSERT(!target.IsKnockdown(), "A dash stopped short of [hazard] still dropped the target") + var/turf/changed = changed_turfs[length(changed_turfs)] + changed.ChangeTurf(original_turf_types[length(original_turf_types)]) + changed_turfs.Cut() + original_turf_types.Cut() + qdel(user) + qdel(target) + TEST_ASSERT(mantis_lunge_unsafe_turf(null), "No turf counted as safe") + +/// Every third landed cut with both blades out, on the same target and inside the window, crosses both +/// blades; its follow-through never counts as a cut of its own. +/datum/unit_test/voidcrew_mantis_gore/xslash + +/datum/unit_test/voidcrew_mantis_gore/xslash/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 0)) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + cut(blade, user, target, BODY_ZONE_CHEST) + cut(blade, user, target, BODY_ZONE_CHEST) + TEST_ASSERT(!target.has_status_effect(/datum/status_effect/staggered), "Two cuts staggered them") + var/brute_before = target.getBruteLoss() + cut(blade, user, target, BODY_ZONE_CHEST) + TEST_ASSERT(target.has_status_effect(/datum/status_effect/staggered), "The third cut didn't stagger them") + TEST_ASSERT(target.getBruteLoss() - brute_before > 10, "The off blade didn't follow through") + TEST_ASSERT_EQUAL(user.mantis_state.xslash_count, 0, "The follow-through counted as a cut, or the count didn't reset") + + // A new target starts over. + var/mob/living/carbon/human/consistent/other = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + cut(blade, user, target, BODY_ZONE_CHEST) + cut(blade, user, target, BODY_ZONE_CHEST) + cut(blade, user, other, BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(user.mantis_state.xslash_count, 1, "Switching targets kept the count") + // So does a gap. + cut(blade, user, other, BODY_ZONE_CHEST) + user.mantis_state.xslash_last = world.time - 5 SECONDS + cut(blade, user, other, BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(user.mantis_state.xslash_count, 1, "A gap kept the count") + + // One blade out: never. + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left = housings(user)[2] + left.Retract() + var/mob/living/carbon/human/consistent/single = allocate(/mob/living/carbon/human/consistent, spot(2, 0)) + for(var/i in 1 to 3) + cut(blade, user, single, BODY_ZONE_CHEST) + TEST_ASSERT(!single.has_status_effect(/datum/status_effect/staggered), "One blade crossed itself") + + // The Shiv has no X. + var/mob/living/carbon/human/shiv_user = bearer(spot(4, 4), /obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/street) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/shiv = right_blade(shiv_user) + TEST_ASSERT(!(shiv.gore_moves & MG_MOVE_XSLASH), "The Shiv can X-slash") + TEST_ASSERT(!(shiv.gore_moves & MG_MOVE_IMPALE), "The Shiv can impale") + +/// The Mantis blade takes blood, the Scorch doesn't. Stowing a bloody blade flicks it clean onto the +/// floor ahead and stains the housing until the bearer washes. +/datum/unit_test/voidcrew_mantis_gore/blood + +/datum/unit_test/voidcrew_mantis_gore/blood/Run() + var/mob/living/carbon/human/consistent/donor = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/loose = allocate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis) + loose.add_mob_blood(donor) + TEST_ASSERT(loose.is_bloody(), "The Mantis blade refuses blood") + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch/clean = allocate(/obj/item/melee/energy/blade/hardlight/cyberware_mantis/scorch) + clean.add_mob_blood(donor) + TEST_ASSERT(!clean.is_bloody(), "The Scorch blade took blood") + TEST_ASSERT(!clean.drench(donor), "The Scorch blade drenched") + + var/mob/living/carbon/human/user = bearer(spot(1, 1)) + user.setDir(EAST) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + TEST_ASSERT(blade.drench(donor), "The blade wouldn't drench") + TEST_ASSERT(blade.drenched_until > world.time && blade.drip_timer, "A drenched blade doesn't drip") + var/list/overlays = blade.worn_overlays(mutable_appearance(MANTIS_TEST_RIGHTHAND, "mantis_guard"), TRUE, MANTIS_TEST_RIGHTHAND) + var/stained_hand = FALSE + var/drips = FALSE + for(var/mutable_appearance/overlay as anything in overlays) + if(overlay.icon_state == "mantis_guard_soak") + stained_hand = TRUE + if(overlay.icon_state == "mantis_guard_drip") + drips = TRUE + TEST_ASSERT(stained_hand, "The held blade shows no blood") + TEST_ASSERT(drips, "The drenched held blade shows no drops") + + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right = housings(user)[1] + right.Retract() + TEST_ASSERT(!blade.is_bloody(), "Stowing didn't flick the blade clean") + TEST_ASSERT(!blade.drip_timer, "A stowed blade still drips") + TEST_ASSERT(right.stained, "The housing kept no stain") + TEST_ASSERT(findtext(right.cyberware_worn_key(), "blood"), "The stain isn't part of the housing's look") + // Past the fold, the housing shows again, stain and all. + right.stop_blade_anim() + var/list/dressed = right.cyberware_dress_worn(list(image(icon = 'voidcrew/modules/cyberware/icons/cyberware_worn.dmi', icon_state = "mantis_right")), -27, user.get_bodypart(BODY_ZONE_R_ARM)) + var/stain_drawn = FALSE + for(var/image/part as anything in dressed) + if(part.icon_state == "mantis_right_stain") + stain_drawn = TRUE + TEST_ASSERT(stain_drawn, "The stained housing draws no stain") + // The flicked blood is in the air for a moment before it lands. + sleep(0.4 SECONDS) + var/obj/effect/decal/cleanable/blood/mantis_flick/spatter = locate() in spot(2, 1) + TEST_ASSERT_NOTNULL(spatter, "The flick left no spatter ahead") + TEST_ASSERT_EQUAL(spatter.dir, user.dir, "The flick's spatter doesn't point the way it was thrown") + TEST_ASSERT(icon_exists(spatter.icon, spatter.icon_state), "The flick's spatter has no picture") + TEST_ASSERT(!(locate(/obj/effect/decal/cleanable/blood/hv_spray/streak) in spot(2, 1)), "The flick still lays a streak") + user.wash(CLEAN_TYPE_BLOOD) + TEST_ASSERT(!right.stained, "Washing didn't clear the housing") + + // A clean blade just stows. + right.Extend(right.contents[1]) + right.Retract() + TEST_ASSERT(!right.stained, "A clean blade stained the housing") + +/// While a blade is out its fist rides up and it holds the guard; it glints now and then; all of it ends +/// when the blade is stowed or the housing pulled. Every pose has its art. +/datum/unit_test/voidcrew_mantis_gore/stance + +/datum/unit_test/voidcrew_mantis_gore/stance/Run() + var/mob/living/carbon/human/user = bearer(spot(1, 1), out = FALSE) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right = housings(user)[1] + var/obj/item/bodypart/arm = user.get_bodypart(BODY_ZONE_R_ARM) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right.contents[1] + right.Extend(blade) + TEST_ASSERT_EQUAL(blade.inhand_icon_state, "mantis_guard", "The blade isn't held in the guard") + TEST_ASSERT(right.stance_overlay && (right.stance_overlay in arm.bodypart_overlays), "The fist didn't come up") + TEST_ASSERT_EQUAL(right.stance_overlay.raise, 2, "The guard fist isn't 2 pixels up") + TEST_ASSERT(right.glint_timer, "No glint is coming") + blade.set_mantis_pose("raise") + TEST_ASSERT_EQUAL(blade.inhand_icon_state, "mantis_raise", "The raise pose didn't take") + TEST_ASSERT_EQUAL(right.stance_overlay.raise, 3, "The fist didn't follow the raise") + blade.set_mantis_pose("nonsense") + TEST_ASSERT_EQUAL(blade.inhand_icon_state, "mantis_guard", "A pose with no art didn't fall back to the guard") + right.Retract() + TEST_ASSERT(isnull(right.stance_overlay), "The stance outlived the blade") + for(var/datum/bodypart_overlay/overlay as anything in arm.bodypart_overlays) + TEST_ASSERT(!istype(overlay, /datum/bodypart_overlay/mantis_stance), "The raised fist stayed on the arm") + TEST_ASSERT(!right.glint_timer, "The glint outlived the blade") + right.Extend(blade) + right.Remove(user, special = TRUE) + TEST_ASSERT(isnull(right.stance_overlay), "A pulled housing left the fist raised") + + var/static/list/poses_by_model = list( + "mantis" = list("guard", "lunge", "raise", "coil"), + "mantis_street" = list("guard"), + "mantis_scorch" = list("guard", "lunge", "raise", "coil"), + ) + for(var/model in poses_by_model) + for(var/pose in poses_by_model[model]) + for(var/hand_file in list(MANTIS_TEST_LEFTHAND, MANTIS_TEST_RIGHTHAND)) + TEST_ASSERT(icon_exists(hand_file, "[model]_[pose]"), "[hand_file] has no [model]_[pose]") + for(var/state in list("mantis_trail", "mantis_scorch_trail", "mantis_impale", "mantis_scorch_impale", "mantis_coil_glow_right", "mantis_scorch_coil_glow_left", "mantis_guard_glint_right", "mantis_raise_glint_left", "scorch_gash_l_arm", "scorch_gash_head", "flick_spatter_right", "flick_spatter_left")) + TEST_ASSERT(icon_exists(MANTIS_TEST_ICON, state), "The gore sheet has no [state]") + for(var/state in list("mantis_flick_right", "mantis_flick_left")) + TEST_ASSERT(icon_exists(MANTIS_TEST_LARGE_ICON, state), "The large gore sheet has no [state]") + // Every piece the blade rig draws, for every model that can impale and scissor. + var/list/moves = list( + "impale" = list("arrive", "contact", "enter", "lift1", "lift2", "hold", "pull1", "pull2", "pull3", "rip", "drop"), + "scissor" = list("raise", "glint", "close", "cut", "recover"), + ) + for(var/model in list("mantis", "mantis_scorch")) + for(var/move in moves) + for(var/beat in moves[move]) + for(var/facing in GLOB.cardinals) + var/list/spec = mantis_rig_beat(move, beat, facing) + TEST_ASSERT(spec, "The rig has no [move] [beat] facing [dir2text(facing)]") + for(var/piece in spec[MG_RIG_ORDER]) + if(piece == "T" || piece == "body" || piece == "whole") + continue + TEST_ASSERT(icon_exists(MANTIS_TEST_REACH_ICON, "[model]_[move]_[beat]_[piece]"), "The reach sheet has no [model]_[move]_[beat]_[piece]") + // The beat only some views draw: the scissor's swing, seen from the side and the front. + var/list/side_moves = list("scissor" = list("swing")) + for(var/model in list("mantis", "mantis_scorch")) + for(var/move in side_moves) + for(var/beat in side_moves[move]) + for(var/facing in list(EAST, WEST, SOUTH)) + var/list/spec = mantis_rig_beat(move, beat, facing) + TEST_ASSERT(spec, "The rig has no [move] [beat] facing [dir2text(facing)]") + for(var/piece in spec[MG_RIG_ORDER]) + if(piece == "T" || piece == "body" || piece == "whole") + continue + TEST_ASSERT(icon_exists(MANTIS_TEST_REACH_ICON, "[model]_[move]_[beat]_[piece]"), "The reach sheet has no [model]_[move]_[beat]_[piece]") + +/// What a torn artery looks like: drops thrown the way the cut went that land as spots, and the blood running +/// down the body for as long as the wound is open. +/datum/unit_test/voidcrew_mantis_gore/artery_look + +/datum/unit_test/voidcrew_mantis_gore/artery_look/Run() + for(var/height in list("low", "mid", "high")) + for(var/strength in list("", "_weak")) + TEST_ASSERT(icon_exists(MANTIS_TEST_ARTERY_ICON, "spurt_[height][strength]"), "The artery sheet has no spurt_[height][strength]") + TEST_ASSERT(icon_exists(MANTIS_TEST_ICON, "artery_drops_[height][strength]"), "The gore sheet has no artery_drops_[height][strength]") + for(var/zone in GLOB.all_body_zones) + TEST_ASSERT(icon_exists(MANTIS_TEST_ICON, "artery_run_[zone]"), "The gore sheet has no artery_run_[zone]") + TEST_ASSERT(icon_exists(MANTIS_TEST_ICON, "artery_ran_[zone]"), "The gore sheet has no artery_ran_[zone]") + for(var/drips in 1 to 3) + TEST_ASSERT(icon_exists(MANTIS_TEST_ICON, "artery_feet_[drips]"), "The gore sheet has no artery_feet_[drips]") + + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + victim.setDir(SOUTH) + var/obj/item/bodypart/arm = victim.get_bodypart(BODY_ZONE_L_ARM) + var/datum/wound/slash/flesh/critical/hv_carotid/limb/torn = hv_crit_apply_wound(arm, /datum/wound/slash/flesh/critical/hv_carotid/limb, EAST, null) + TEST_ASSERT(torn, "The limb artery wound would not apply") + // The artery throws its own drops: tg's wound spray, a line of blood three tiles long, stays out of it. + TEST_ASSERT(!(locate(/obj/effect/decal/cleanable/blood/hitsplatter) in range(1, victim)), "The limb artery threw tg's own wound spray as well") + TEST_ASSERT_EQUAL(torn.spurt_dir, EAST, "The limb artery forgot the cut's direction") + TEST_ASSERT_EQUAL(mantis_artery_height(victim, BODY_ZONE_L_ARM), "mid", "An arm's artery is not at arm height") + TEST_ASSERT_EQUAL(mantis_artery_height(victim, BODY_ZONE_R_LEG), "low", "A leg's artery is not near the floor") + TEST_ASSERT_EQUAL(mantis_artery_height(victim, BODY_ZONE_HEAD), "high", "The neck's artery is not at neck height") + + // One spurt: drops in the air the way the cut went, then spots where they come down, a tile east. + var/obj/effect/abstract/cyberware_anim/jet = mantis_spurt_fx(victim, BODY_ZONE_L_ARM, EAST) + TEST_ASSERT_NOTNULL(jet, "A torn artery throws nothing") + TEST_ASSERT_EQUAL(jet.icon_state, "spurt_mid", "An arm's spurt isn't the arm-height one") + TEST_ASSERT_EQUAL(jet.dir, EAST, "The spurt doesn't fly the way the cut went") + TEST_ASSERT(!(locate(/obj/effect/decal/cleanable/blood/drip/mantis_drops) in spot(2, 1)), "The drops are on the floor before they have flown") + sleep(0.5 SECONDS) + var/obj/effect/decal/cleanable/blood/drip/mantis_drops/drops = locate() in spot(2, 1) + TEST_ASSERT_NOTNULL(drops, "The spurt's drops left no spots where they came down") + TEST_ASSERT_EQUAL(drops.icon_state, "artery_drops_mid", "The spots are not the spurt's own") + TEST_ASSERT_EQUAL(drops.dir, EAST, "The spots don't lie the way the drops flew") + TEST_ASSERT(!(locate(/obj/effect/decal/cleanable/blood/hv_spray) in spot(2, 1)), "A spurt still lays a spray") + // The next beat comes down on the same spots. + mantis_spurt_fx(victim, BODY_ZONE_L_ARM, EAST) + sleep(0.5 SECONDS) + var/spots = 0 + for(var/obj/effect/decal/cleanable/blood/drip/mantis_drops/laid in spot(2, 1)) + spots++ + TEST_ASSERT_EQUAL(spots, 1, "A second beat stacked its spots on the first's") + // A weak one falls close by. + var/obj/effect/abstract/cyberware_anim/weak_jet = mantis_spurt_fx(victim, BODY_ZONE_L_ARM, EAST, TRUE) + TEST_ASSERT_EQUAL(weak_jet?.icon_state, "spurt_mid_weak", "A weak spurt isn't the weak one") + // Thrown straight up or down the screen out of an arm, the drops lean out to that arm's side and land clear + // of the body. Thrown sideways they don't lean. + var/list/straight = mantis_spurt_spot(list(6, 1), "mid", FALSE, NORTH) + var/list/leaning = mantis_spurt_spot(list(6, 1), "mid", FALSE, NORTH, 1) + TEST_ASSERT(leaning[1] > straight[1], "Drops thrown up the screen out of an arm on the right don't lean out to the right") + TEST_ASSERT_EQUAL(leaning[2], straight[2], "Leaning out changed how far the drops fly") + TEST_ASSERT_EQUAL(mantis_spurt_lean(FALSE, EAST, 1), 0, "Drops thrown sideways lean") + // Every spurt's drops are still in its picture where they come down, on the last frame it holds. The neck's, + // thrown down the screen, fall furthest: the wound sits above the picture's middle to leave them the room. + // And its first frame is empty: the half beat a swinging blade cocks back, so no drop is out ahead of the cut. + var/icon/spurt_sheet = icon(MANTIS_TEST_ARTERY_ICON) + for(var/spurt_height in list("low", "mid", "high")) + for(var/spurt_weak in list(FALSE, TRUE)) + var/list/spurt_shape = mantis_spurt_shape(spurt_height, spurt_weak) + var/spurt_state = "spurt_[spurt_height][spurt_weak ? "_weak" : ""]" + var/last_frame = spurt_shape[3] / 0.5 + 2 + for(var/way in GLOB.alldirs) + var/list/landing = mantis_spurt_spot(list(0, 0), spurt_height, spurt_weak, way) + var/landed = FALSE + for(var/across in -3 to 3) + for(var/up in -3 to 3) + if(spurt_sheet.GetPixel(49 + landing[1] + across, 48 + MG_ARTERY_WOUND_RISE + landing[2] + up, spurt_state, way, last_frame)) + landed = TRUE + TEST_ASSERT(landed, "The [spurt_state] thrown [dir2text(way)] has left its picture before its drops come down") + var/early = FALSE + for(var/across in -2 to 2) + for(var/up in -2 to 2) + if(spurt_sheet.GetPixel(49 + across, 48 + MG_ARTERY_WOUND_RISE + up, spurt_state, way, 1)) + early = TRUE + TEST_ASSERT(!early, "The [spurt_state] thrown [dir2text(way)] has drops out of the wound before the blade has cut") + + // The blood runs down the body, and goes when the wound does. + var/obj/effect/abstract/cyberware_anim/mantis_run/run = mantis_artery_run_fx(victim, BODY_ZONE_L_ARM, torn) + TEST_ASSERT_NOTNULL(run, "A torn artery doesn't run down the body") + TEST_ASSERT(run in victim.vis_contents, "The run isn't drawn on the body") + TEST_ASSERT_EQUAL(run.icon_state, "artery_run_l_arm", "The run isn't the arm's") + sleep(0.9 SECONDS) + TEST_ASSERT_EQUAL(run.icon_state, "artery_ran_l_arm", "The run isn't held once it has run its length") + // Three drips fall off its lower end and make a small pool at the feet, just under the body's own tile. + sleep(0.5 SECONDS) + var/obj/effect/decal/cleanable/blood/drip/mantis_drops/pool + for(var/obj/effect/decal/cleanable/blood/drip/mantis_drops/found in get_step(victim, SOUTH)) + if(found.feet_drips) + pool = found + TEST_ASSERT_NOTNULL(pool, "The run dripped nothing at the feet") + TEST_ASSERT_EQUAL(pool.icon_state, "artery_feet_3", "Three drips at the feet did not make the small pool") + TEST_ASSERT_NOTNULL(mantis_artery_run_foot(BODY_ZONE_L_ARM, EAST), "The blood off a far arm comes down to no sole") + // tg's own bleeding still drips onto a tile that holds the artery's spots, and makes its pool there in the end. + var/turf/spotted = spot(2, 1) + for(var/drips in 1 to 6) + victim.get_bloodtype()?.make_blood_splatter(victim, spotted, TRUE) + var/pooled = FALSE + for(var/obj/effect/decal/cleanable/blood/splatter in spotted) + if(!istype(splatter, /obj/effect/decal/cleanable/blood/drip)) + pooled = TRUE + TEST_ASSERT(pooled, "Blood dripping onto the artery's spots never made a pool") + qdel(torn) + TEST_ASSERT(QDELETED(run), "The run outlived its wound") + + // Lying down the blood goes to the floor: low drops, and nothing runs down the body. + victim.set_body_position(LYING_DOWN) + TEST_ASSERT_EQUAL(mantis_artery_height(victim, BODY_ZONE_L_ARM), "low", "A body lying down still bleeds from arm height") + var/datum/wound/slash/flesh/critical/hv_carotid/limb/again = hv_crit_apply_wound(arm, /datum/wound/slash/flesh/critical/hv_carotid/limb, EAST, null) + TEST_ASSERT(again, "The limb artery wound would not apply a second time") + TEST_ASSERT_NULL(mantis_artery_run_fx(victim, BODY_ZONE_L_ARM, again), "Blood runs down a body lying flat") + +#undef MG_MOVE_IMPALE +#undef MG_MOVE_XSLASH +#undef MG_IMPALE_TRAIT +#undef MG_CHARGE_TRAIT +#undef MG_TRAIT_CAMO +#undef MG_FINISHER_DONE +#undef MG_FINISHER_DAMAGED +#undef MANTIS_TEST_ICON +#undef MANTIS_TEST_LARGE_ICON +#undef MANTIS_TEST_ARTERY_ICON +#undef MG_ARTERY_WOUND_RISE +#undef MANTIS_TEST_LEFTHAND +#undef MANTIS_TEST_RIGHTHAND +#undef MANTIS_TEST_REACH_ICON +#undef MG_RIG_ORDER diff --git a/voidcrew/modules/unit_tests/voidcrew_mantis_swing.dm b/voidcrew/modules/unit_tests/voidcrew_mantis_swing.dm new file mode 100644 index 00000000000..e70091c2d3e --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_mantis_swing.dm @@ -0,0 +1,181 @@ +/// An ordinary hit swings the hand that hit (voidcrew/modules/mantis_gore/mantis_swing.dm): the swing plays on +/// the bearer, the held blade hides under it, and putting the blade away ends it. Each hand's slash over the target +/// runs the way its own blade cuts. +/datum/unit_test/voidcrew_mantis_gore/swing + +/datum/unit_test/voidcrew_mantis_gore/swing/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 0)) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + user.swap_hand(user.get_held_index_of_item(blade)) + user.set_combat_mode(TRUE) + // The unfold still hides the blade; that wait is over in play. + blade.show_inhand() + + blade.melee_attack_chain(user, target) + var/obj/effect/abstract/cyberware_anim/swing = blade.mantis_swing() + TEST_ASSERT(swing && (swing in user.vis_contents), "A hit didn't swing the blade") + TEST_ASSERT_EQUAL(swing.icon_state, "mantis_swing_right", "The right hand swung the wrong picture") + TEST_ASSERT(blade.inhand_hidden_until > world.time, "The held blade draws under its own swing") + // The slash over the target goes up with the swing, so the client plays both from the same moment. + var/obj/effect/abstract/cyberware_anim/slash = blade.swing_impact_ref?.resolve() + TEST_ASSERT(slash && (slash in target.vis_contents), "The swing put no slash over its target") + + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right = housings(user)[1] + right.Retract() + TEST_ASSERT(QDELETED(swing), "Putting the blade away left its swing playing") + + // Facing south the two hands cut toward each other, so their slashes are mirror images. + TEST_ASSERT(mantis_swing_impact_mirrored(SOUTH, "right") != mantis_swing_impact_mirrored(SOUTH, "left"), "Facing south both hands' swings show the same slash") + // The swing's say goes over the side the target is on (east of the user here, which draws it plain). + var/obj/effect/abstract/cyberware_anim/impact = cyberware_play_impact(user, target, "impact_mantis", TRUE) + TEST_ASSERT(impact, "No impact was drawn on the target") + var/matrix/turned = impact.transform + TEST_ASSERT(turned.a < 0, "An impact told to mirror was drawn plain") + +/// The name of the mask on a far arm's picture (CHROME_ANIM_ARM_COVER_FILTER, cyberware_anim.dm). +#define MANTIS_TEST_SWING_COVER "chrome_arm_cover" + +/// Whether [under] is drawn under [over] on [body]: pictures in vis_contents draw in the order they went in. +/datum/unit_test/voidcrew_mantis_gore/proc/drawn_under(mob/living/body, atom/movable/under, atom/movable/over) + var/list/order = list() + for(var/atom/movable/picture as anything in body.vis_contents) + order += picture + var/low = order.Find(under) + var/high = order.Find(over) + return low && high && low < high + +/// [body]'s other held Mantis blade, not [blade]. +/datum/unit_test/voidcrew_mantis_gore/proc/other_blade(mob/living/carbon/body, obj/item/blade) + for(var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/held in body.held_items) + if(held != blade) + return held + +/// Side on, the far arm swings behind the near one: what the near hand holds is cut out of the far swing while +/// it is drawn in the hand, and not while the near blade swings itself, nor once the bearer turns around. +/datum/unit_test/voidcrew_mantis_gore/swing_far + +/datum/unit_test/voidcrew_mantis_gore/swing_far/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 0)) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + ADD_TRAIT(target, TRAIT_GODMODE, TRAIT_SOURCE_UNIT_TESTS) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/near = right_blade(user) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/far = other_blade(user, near) + TEST_ASSERT(far, "Fixture: the bearer holds one blade") + near.show_inhand() + far.show_inhand() + user.set_combat_mode(TRUE) + user.setDir(EAST) + + user.swap_hand(user.get_held_index_of_item(far)) + far.melee_attack_chain(user, target) + var/obj/effect/abstract/cyberware_anim/mantis_swing/far_swing = far.mantis_swing() + TEST_ASSERT(far_swing, "The far hand didn't swing") + TEST_ASSERT(far_swing.get_filter(MANTIS_TEST_SWING_COVER), "The far arm's swing draws over the near blade") + + // The near blade swings too: it leaves the hand, and its own swing is drawn in front. + user.swap_hand(user.get_held_index_of_item(near)) + near.melee_attack_chain(user, target) + var/obj/effect/abstract/cyberware_anim/mantis_swing/near_swing = near.mantis_swing() + TEST_ASSERT(near_swing, "The near hand didn't swing") + TEST_ASSERT(!near_swing.get_filter(MANTIS_TEST_SWING_COVER), "Something is cut out of the near arm's swing") + TEST_ASSERT(drawn_under(user, far_swing, near_swing), "The near arm's swing is under the far arm's") + TEST_ASSERT(!far_swing.get_filter(MANTIS_TEST_SWING_COVER), "The far swing is still cut around a blade that left the hand") + + // Back in the hand, it is cut out again. + near.show_inhand() + far_swing.fit_to_facing() + TEST_ASSERT(far_swing.get_filter(MANTIS_TEST_SWING_COVER), "The near blade came back and the far swing draws over it") + + // Facing west the left hand is the near one. + user.setDir(WEST) + TEST_ASSERT(!far_swing.get_filter(MANTIS_TEST_SWING_COVER), "Turning around kept the left swing cut") + TEST_ASSERT(drawn_under(user, near_swing, far_swing), "Turning around kept the left swing under the right") + +/// Side on, the far blade unfolds and folds behind the near one, as it swings behind it: the near blade is cut out +/// of the far arm's picture, which goes under the near arm's. +/datum/unit_test/voidcrew_mantis_gore/unfold_far + +/datum/unit_test/voidcrew_mantis_gore/unfold_far/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 0), out = FALSE) + user.setDir(EAST) + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/right = housings(user)[1] + var/obj/item/organ/cyberimp/arm/toolkit/cyberware/mantis/left = housings(user)[2] + + // Facing east the right arm is the near one. Its blade is out and drawn in the hand. + right.Extend(right.contents[1]) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/near = right.active_item + near.show_inhand() + var/obj/effect/abstract/cyberware_anim/near_unfold = right.blade_anim() + TEST_ASSERT(near_unfold, "Fixture: the near blade's unfold never played") + TEST_ASSERT(!near_unfold.get_filter(MANTIS_TEST_SWING_COVER), "Something is cut out of the near arm's unfold") + + left.Extend(left.contents[1]) + var/obj/effect/abstract/cyberware_anim/far_unfold = left.blade_anim() + TEST_ASSERT(far_unfold, "Fixture: the far blade's unfold never played") + TEST_ASSERT(far_unfold.get_filter(MANTIS_TEST_SWING_COVER), "The far blade unfolds over the near blade") + TEST_ASSERT(drawn_under(user, far_unfold, near_unfold), "The far blade's unfold isn't under the near blade's") + + // And back in: the far blade folds behind the near one. + left.Retract() + var/obj/effect/abstract/cyberware_anim/far_fold = left.blade_anim() + TEST_ASSERT(far_fold, "Fixture: the far blade's fold never played") + TEST_ASSERT(far_fold.get_filter(MANTIS_TEST_SWING_COVER), "The far blade folds over the near blade") + + // Turned around, the left arm is the near one: nothing is cut out of its pictures. + left.Extend(left.contents[1]) + user.setDir(WEST) + var/obj/effect/abstract/cyberware_anim/left_unfold = left.blade_anim() + TEST_ASSERT(left_unfold && !left_unfold.get_filter(MANTIS_TEST_SWING_COVER), "The near blade's unfold is cut around the far blade") + +/// Only the blade that hit takes the blood: a hit or a kill with one blade leaves the other clean. The X-slash +/// cuts with both, so both run red. +/datum/unit_test/voidcrew_mantis_gore/swing_blood + +/datum/unit_test/voidcrew_mantis_gore/swing_blood/Run() + var/mob/living/carbon/human/user = bearer(spot(0, 0)) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/blade = right_blade(user) + var/obj/item/melee/energy/blade/hardlight/cyberware_mantis/other = other_blade(user, blade) + TEST_ASSERT(other, "Fixture: the bearer holds one blade") + blade.show_inhand() + user.set_combat_mode(TRUE) + user.swap_hand(user.get_held_index_of_item(blade)) + + // Ordinary hits, on two people in turn so none is an X-slash: any blood is on the blade that swung. + var/mob/living/carbon/human/consistent/first = allocate(/mob/living/carbon/human/consistent, spot(1, 0)) + var/mob/living/carbon/human/consistent/second = allocate(/mob/living/carbon/human/consistent, spot(0, 1)) + for(var/i in 1 to 6) + blade.melee_attack_chain(user, i % 2 ? first : second) + TEST_ASSERT(!other.is_bloody(), "A hit with one blade bloodied the other") + + // A kill: only the blade that made it runs red. + var/mob/living/carbon/human/consistent/killed = allocate(/mob/living/carbon/human/consistent, spot(1, 1)) + killed.adjustOxyLoss(185) + cut(blade, user, killed, BODY_ZONE_CHEST, 30) + TEST_ASSERT_EQUAL(killed.stat, DEAD, "Fixture: the cut didn't kill (health [killed.health])") + TEST_ASSERT(blade.drenched_until > world.time, "The killing blade didn't run red") + TEST_ASSERT(!other.is_bloody() && !other.drenched_until, "A kill with one blade bloodied the other") + + // The X-slash lands at once with no swing playing; both blades cut, both run red. + qdel(blade.mantis_swing()) + var/mob/living/carbon/human/consistent/crossed = allocate(/mob/living/carbon/human/consistent, spot(2, 0)) + for(var/i in 1 to 3) + cut(blade, user, crossed, BODY_ZONE_CHEST) + TEST_ASSERT(crossed.has_status_effect(/datum/status_effect/staggered), "Fixture: the third cut was no X-slash") + TEST_ASSERT(other.drenched_until > world.time, "The X-slash left the other blade clean") + // The cross is two strokes on the target, one the mirror of the other, both set on the part cut. + var/list/strokes = list() + for(var/obj/effect/abstract/cyberware_anim/picture in crossed.vis_contents) + if(picture.icon_state == "xslash_mantis") + strokes += picture + TEST_ASSERT_EQUAL(length(strokes), 2, "The X-slash didn't draw its two strokes") + var/obj/effect/abstract/cyberware_anim/one = strokes[1] + var/obj/effect/abstract/cyberware_anim/two = strokes[2] + var/matrix/one_way = one.transform + var/matrix/other_way = two.transform + TEST_ASSERT_EQUAL(one_way.a, -other_way.a, "The two strokes run the same way") + TEST_ASSERT(one.pixel_w == two.pixel_w && one.pixel_z == two.pixel_z, "The two strokes don't cross on the same point") + var/list/chest = mantis_part_point(crossed, BODY_ZONE_CHEST) + TEST_ASSERT(one.pixel_w == -16 + chest[1] && one.pixel_z == -16 + chest[2], "The cross isn't on the part cut") + +#undef MANTIS_TEST_SWING_COVER diff --git a/voidcrew/modules/unit_tests/voidcrew_mission_spawn_cover.dm b/voidcrew/modules/unit_tests/voidcrew_mission_spawn_cover.dm new file mode 100644 index 00000000000..2480c897343 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_mission_spawn_cover.dm @@ -0,0 +1,52 @@ +/// Mission field spawns stay off turfs a player could be looking at, and walls count as cover +/datum/unit_test/voidcrew_mission_spawn_cover + +/datum/unit_test/voidcrew_mission_spawn_cover/Run() + var/turf/eye_turf = run_loc_floor_bottom_left + var/turf/beside = locate(eye_turf.x + 1, eye_turf.y, eye_turf.z) + var/turf/near = locate(eye_turf.x + 2, eye_turf.y, eye_turf.z) + // Well past any screen, on the same level + var/far_x = (eye_turf.x + 40 <= world.maxx) ? eye_turf.x + 40 : eye_turf.x - 40 + var/turf/far = locate(far_x, eye_turf.y, eye_turf.z) + TEST_ASSERT_NOTNULL(near, "The test room must be at least three tiles wide.") + TEST_ASSERT_NOTNULL(far, "The test level must be wider than one screen.") + + // No z: nobody is registered as watching + var/datum/spawn_cover/cover = new + TEST_ASSERT(cover.is_hidden(near), "With nobody watching, every turf is hidden.") + + cover.add_watcher(eye_turf, 9, 7) + TEST_ASSERT(!cover.is_hidden(near), "A turf two tiles from a watcher, in the open, is in view.") + TEST_ASSERT(!cover.is_hidden(beside), "The turf next to a watcher is in view.") + TEST_ASSERT_EQUAL(cover.fallback, near, "The fallback is the seen turf farthest from the watcher.") + TEST_ASSERT(cover.is_hidden(far), "A turf forty tiles away is off the watcher's screen.") + + // An opaque wall between them hides what's behind it + allocate(/obj/structure/falsewall, beside) + TEST_ASSERT(IS_OPAQUE_TURF(beside), "The false wall must make its turf opaque.") + TEST_ASSERT(cover.is_hidden(near), "A turf behind a wall is hidden from the watcher.") + + // The list picker never hands back anything but one of its candidates + var/list/candidates = list(beside, near) + TEST_ASSERT(pick_unwatched_turf(candidates) in candidates, "The picker must return one of its candidates.") + TEST_ASSERT_NULL(pick_unwatched_turf(list()), "An empty candidate list has nothing to pick.") + +/// Set dressing is effects only, stays off walls, and leaves the objective's tile to the objective +/datum/unit_test/voidcrew_mission_site_dressing + +/datum/unit_test/voidcrew_mission_site_dressing/Run() + var/turf/anchor = locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y + 2, run_loc_floor_bottom_left.z) + var/obj/item/mission_recovery/objective = allocate(__IMPLIED_TYPE__, anchor) + for(var/scene_type in subtypesof(/datum/mission_scene)) + dress_mission_scene(scene_type, anchor, null) + var/pieces = 0 + for(var/turf/tile as anything in RANGE_TURFS(3, anchor)) + for(var/obj/item/loot in tile) + TEST_ASSERT_EQUAL(loot, objective, "Set dressing must not leave items lying around ([loot.type]).") + for(var/obj/effect/decal/mission_scene/piece in tile) + pieces++ + TEST_ASSERT(!isclosedturf(tile), "[piece.type] was placed on a wall.") + if(tile == anchor) + TEST_ASSERT(istype(piece, /obj/effect/decal/mission_scene/scorch) || istype(piece, /obj/effect/decal/mission_scene/skid), "Only ground marks may share the objective's tile, not [piece.type].") + TEST_ASSERT(pieces > 0, "The scenes must lay something down.") + TEST_ASSERT_EQUAL(objective.loc, anchor, "Dressing must not move the objective.") diff --git a/voidcrew/modules/unit_tests/voidcrew_missions.dm b/voidcrew/modules/unit_tests/voidcrew_missions.dm index afb948cbc1a..c9797953765 100644 --- a/voidcrew/modules/unit_tests/voidcrew_missions.dm +++ b/voidcrew/modules/unit_tests/voidcrew_missions.dm @@ -481,7 +481,7 @@ repeated.voucher_count = initial(rescue_type.voucher_count) var/datum/mission_objective/field/escort/repeated_escort = new repeated.add_objective(repeated_escort) - repeated_escort.survivor = allocate(/mob/living/carbon/human/npc/mission_survivor, pad_turf) + repeated_escort.survivor = allocate(/mob/living/carbon/human/npc/ambient_npc/mission_survivor, pad_turf) repeated_escort.on_turn_in_finalized(pad) TEST_ASSERT_EQUAL(repeated.value, 1250, "A healthy survivor must add 25% to credits") TEST_ASSERT_NULL(repeated_escort.survivor, "Finalization must clear the survivor reference") @@ -489,6 +489,28 @@ TEST_ASSERT_EQUAL(repeated.value, 1250, "Repeated finalization must not stack the bonus") TEST_ASSERT_EQUAL(repeated.voucher_count, initial(rescue_type.voucher_count), "Repeated finalization must not change vouchers") +/** + * A survivor the contract lets go of in front of someone is taken up in the transporter's beam: + * held still for the length of it, with the column on their tile, rather than + * blinking out. With nobody about they are simply deleted (the delivery test above relies on it). + */ +/datum/unit_test/voidcrew_mission_survivor_beam/Run() + var/turf/spot = run_loc_floor_bottom_left + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/watched = allocate(/mob/living/carbon/human/npc/ambient_npc/mission_survivor, spot) + watched.beam_out(force_visual = TRUE) + TEST_ASSERT(!QDELETED(watched), "A watched survivor must stay for the beam, not vanish on the spot") + TEST_ASSERT(watched.beaming_out, "A watched survivor must be marked as leaving") + TEST_ASSERT(!HAS_TRAIT(watched, TRAIT_GODMODE), "A survivor in the beam is still a person: no godmode") + TEST_ASSERT(HAS_TRAIT(watched, TRAIT_IMMOBILIZED), "A survivor in the beam must not walk out of it") + TEST_ASSERT(watched.anchored, "A survivor in the beam must not be pulled out of it") + TEST_ASSERT(locate(/obj/effect/temp_visual/transporter_beam) in spot, "A watched survivor must get the beam column on their tile") + watched.talked_to(allocate(/mob/living/carbon/human/consistent, get_step(spot, NORTH))) + TEST_ASSERT(!watched.is_following(), "A survivor in the beam must not start following anyone") + + var/mob/living/carbon/human/npc/ambient_npc/mission_survivor/unseen = allocate(/mob/living/carbon/human/npc/ambient_npc/mission_survivor, get_step(spot, EAST)) + unseen.beam_out() + TEST_ASSERT(QDELETED(unseen), "A survivor nobody can see must be deleted at once") + /** * A contract that marks itself exclusive_site must get a wreck to itself. * @@ -619,7 +641,7 @@ /datum/unit_test/voidcrew_mission_kill_rewind abstract_type = /datum/unit_test/voidcrew_mission_kill_rewind -/datum/unit_test/voidcrew_mission_kill_rewind/proc/make_hunt(big_game = FALSE) +/datum/unit_test/voidcrew_mission_kill_rewind/proc/make_hunt(big_game = FALSE, wait_for_beast = FALSE) var/datum/mission/kill_rewind_test/mission = allocate(__IMPLIED_TYPE__) mission.servant = allocate(/obj/structure/overmap/ship) mission.servant.ship_account = allocate(/datum/bank_account) @@ -652,8 +674,13 @@ mission.activate_current_objective() if(lure) lure.on_planted(null, target.spawn_turf) - // The single-turf fixture stands in for the whole hunting ground. - hunt.target_mob.forceMove(target.spawn_turf) + if(!wait_for_beast) + // In play the beast comes in after a wait and a walk; the fixture skips both. + var/datum/mission_objective/field/kill_named/big_game/trophy_hunt = hunt + trophy_hunt.cancel_arrival() + trophy_hunt.spawn_field_objects(target.spawn_turf) + // The single-turf fixture stands in for the whole hunting ground. + hunt.target_mob.forceMove(target.spawn_turf) return mission /datum/unit_test/voidcrew_mission_kill_rewind/proc/test_mobs() @@ -746,6 +773,22 @@ TEST_ASSERT(!mission.turn_in(run_loc_floor_bottom_left, null, TRUE), "Repeated forced turn-in must still honor mission completion") TEST_ASSERT_EQUAL(mission.reward_calls, 1, "Repeated turn-in must not distribute rewards twice") +/// The beast is called in with a wait, not conjured beside the staked lure. +/datum/unit_test/voidcrew_mission_kill_rewind/lure_wait/Run() + var/datum/mission/kill_rewind_test/mission = make_hunt(TRUE, wait_for_beast = TRUE) + var/datum/mission_objective/field/kill_named/big_game/hunt = mission.current_objective() + TEST_ASSERT_NULL(hunt.target_mob, "The beast must not appear in the tick the lure goes in") + TEST_ASSERT_EQUAL(length(test_mobs()), 0, "Neither the beast nor its guards may appear in the tick the lure goes in") + TEST_ASSERT(hunt.arrival_pending && hunt.arrival_timer, "The staked lure must call the beast in with a wait") + var/obj/structure/hunting_lure_stake/stake = hunt.lure_stake_ref?.resolve() + TEST_ASSERT_NOTNULL(stake, "The staked lure must stay in the world") + TEST_ASSERT(stake.anchored, "The staked lure must be anchored") + TEST_ASSERT_NULL(mission.quest_atom, "The staked lure is scenery, not the tracked quest atom") + hunt.deactivate() + TEST_ASSERT_NULL(hunt.arrival_timer, "A contract that ends during the wait must cancel the arrival") + TEST_ASSERT(stake.toppled, "A contract that ends must leave the lure down") + TEST_ASSERT_EQUAL(length(test_mobs()), 0, "A cancelled arrival must not spawn anything") + /// Carried proof stays valid while the crew revisits an emptied site. /datum/unit_test/voidcrew_mission_kill_rewind/carried/Run() for(var/big_game in list(FALSE, TRUE)) diff --git a/voidcrew/modules/unit_tests/voidcrew_resale.dm b/voidcrew/modules/unit_tests/voidcrew_resale.dm index d6be684611a..05752cdbae4 100644 --- a/voidcrew/modules/unit_tests/voidcrew_resale.dm +++ b/voidcrew/modules/unit_tests/voidcrew_resale.dm @@ -186,7 +186,7 @@ var/datum/outpost_shop/vendor/patchup_clinic/clinic = allocate(/datum/outpost_shop/vendor/patchup_clinic) for(var/datum/shop_buyback/intake as anything in clinic.buybacks) TEST_ASSERT(!ispath(intake.item_path, /obj/item/defibrillator), "The clinic still buys defibrillators") - TEST_ASSERT_EQUAL(length(clinic.buybacks), 4, "The clinic lost another intake line") + TEST_ASSERT_EQUAL(length(clinic.buybacks), 7, "The clinic lost another intake line") /datum/unit_test/voidcrew_resale/market_floor/Run() save_economy() diff --git a/voidcrew/modules/unit_tests/voidcrew_shop_catalog.dm b/voidcrew/modules/unit_tests/voidcrew_shop_catalog.dm index 1b221c8b8c5..3bff2b7846f 100644 --- a/voidcrew/modules/unit_tests/voidcrew_shop_catalog.dm +++ b/voidcrew/modules/unit_tests/voidcrew_shop_catalog.dm @@ -363,7 +363,9 @@ ), /datum/outpost_shop/vendor/ripperdoc = list( list(/datum/shop_sku/ripperdoc/monowire, /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire, 1, 0, 3), + list(/datum/shop_sku/ripperdoc/monowire_live, /obj/item/organ/cyberimp/arm/toolkit/cyberware/monowire/live, 1, 0, 5), list(/datum/shop_sku/ripperdoc/mantis, /obj/item/cyberware_pair_case/mantis_blades, 1, 0, 4), + list(/datum/shop_sku/ripperdoc/mantis_scorch, /obj/item/cyberware_pair_case/mantis_scorch, 1, 0, 4), list(/datum/shop_sku/ripperdoc/gorilla, /obj/item/cyberware_pair_case/gorilla_arms, 1, 0, 3), ), ) @@ -439,14 +441,18 @@ /obj/item/cultivator, /obj/item/shovel/spade, /obj/item/hatchet, /obj/item/secateurs, /obj/item/reagent_containers/cup/watering_can, /obj/item/plant_analyzer, /obj/item/fishing_rod/tech, ) - for(var/shop_type in list(/datum/outpost_shop/general, /datum/outpost_shop/outfitter, /datum/outpost_shop/black_market, /datum/outpost_shop/vendor/potting_shed, /datum/outpost_shop/vendor/bait_shop, /datum/outpost_shop/vendor/ripperdoc)) + for(var/shop_type in list(/datum/outpost_shop/general, /datum/outpost_shop/outfitter, /datum/outpost_shop/black_market, /datum/outpost_shop/vendor/potting_shed, /datum/outpost_shop/vendor/bait_shop, /datum/outpost_shop/vendor/ripperdoc, /datum/outpost_shop/vendor/street_doc)) var/datum/outpost_shop/shop = allocate(shop_type) for(var/datum/shop_sku/sku_type as anything in shop.sku_types + shop.rotating_pool + shop.rare_pool + shop.favor_sku_types) var/item_path = initial(sku_type.item_path) TEST_ASSERT(!(item_path in printed_gear), "[shop_type] still sells printable gear [item_path]") if(ispath(item_path, /obj/item/gun)) TEST_ASSERT(item_path in allowed_guns, "[shop_type] bypasses the ladder with [item_path]") - TEST_ASSERT(item_path != /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin && item_path != /obj/item/organ/cyberimp/arm/toolkit/cyberware/bunker_buster, "Splice still sells a gun arm") + // The heavy gun arms (the Ronin SMG and the Bunker Buster pod, and any + // model of them) stay loot-only. The Holdout's .38 is the one gun arm + // that is shelf stock, on purpose. + if(ispath(item_path, /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin) || ispath(item_path, /obj/item/organ/cyberimp/arm/toolkit/cyberware/bunker_buster)) + TEST_ASSERT(item_path == /obj/item/organ/cyberimp/arm/toolkit/cyberware/ronin/holdout, "[shop_type] sells the heavy gun arm [item_path]; only the Holdout housing is shelf stock") /// Convoys and rotations cannot accelerate deliveries or revive finite stock. /datum/unit_test/voidcrew_ladder_restock/Run() @@ -503,7 +509,7 @@ TEST_ASSERT_EQUAL(finite.stock, 0, "A rotation refilled restricted stock") // Arm chrome takes one unit every few convoys, and a full shelf banks nothing toward the next. - for(var/sku_type in list(/datum/shop_sku/ripperdoc/monowire, /datum/shop_sku/ripperdoc/mantis, /datum/shop_sku/ripperdoc/gorilla)) + for(var/sku_type in list(/datum/shop_sku/ripperdoc/monowire, /datum/shop_sku/ripperdoc/monowire_live, /datum/shop_sku/ripperdoc/mantis, /datum/shop_sku/ripperdoc/mantis_scorch, /datum/shop_sku/ripperdoc/gorilla)) var/datum/outpost_shop/chrome_shop = allocate(/datum/outpost_shop) chrome_shop.add_sku(sku_type, "core") var/datum/shop_sku/chrome = chrome_shop.skus[1] @@ -551,6 +557,7 @@ /datum/shop_sku/black_market/brimstone, /datum/shop_sku/black_market/flaming_arrow, /datum/shop_sku/black_market/slammer, /datum/shop_sku/black_market/absolution, /datum/shop_sku/black_market/conflagration, /datum/shop_sku/black_market/cutlass, /datum/shop_sku/black_market/rare/energy_sword, /datum/shop_sku/ripperdoc/monowire, /datum/shop_sku/ripperdoc/gorilla, /datum/shop_sku/ripperdoc/mantis, + /datum/shop_sku/ripperdoc/monowire_live, /datum/shop_sku/ripperdoc/mantis_scorch, /datum/shop_sku/ripperdoc/mantis_street, /datum/shop_sku/general/rotating/freight_crate, /datum/shop_sku/black_market/mystery_cache, /datum/shop_sku/black_market/mystery_cache_rare, ) for(var/sku_type in restricted) @@ -695,7 +702,10 @@ var/ammo_path = GLOB.loot_gun_spare_ammo[gun.type] TEST_ASSERT(locate(ammo_path) in cache, "A freight gun arrived without its spare reload") TEST_ASSERT(contents_count - spare_count >= 2 + (zone == 3 ? 2 : zone == 2 ? 1 : 0) + cache.bonus_draws, "Premium crate lost ordinary draws") - TEST_ASSERT(contents_count - spare_count <= 3 + (zone == 3 ? 2 : zone == 2 ? 1 : 0) + cache.bonus_draws, "Premium crate added unbudgeted draws") + var/list/packed = list() + for(var/atom/movable/inside as anything in cache.contents) + packed += "[inside.type]" + TEST_ASSERT(contents_count - spare_count <= 3 + (zone == 3 ? 2 : zone == 2 ? 1 : 0) + cache.bonus_draws, "Premium crate added unbudgeted draws (zone [zone], [row[1]]): [packed.Join(", ")]") cache.PopulateContents() TEST_ASSERT_EQUAL(length(cache.contents), contents_count, "Reopening bought cargo paid twice") TEST_ASSERT(deep_compare_list(list(theme.loot_common, theme.loot_uncommon, theme.loot_prime, theme.loot_uniques), original_pools), "Bought cargo mutated the shared theme") diff --git a/voidcrew/modules/unit_tests/voidcrew_zone_shops.dm b/voidcrew/modules/unit_tests/voidcrew_zone_shops.dm index 8d28f05a27a..1e80bea671c 100644 --- a/voidcrew/modules/unit_tests/voidcrew_zone_shops.dm +++ b/voidcrew/modules/unit_tests/voidcrew_zone_shops.dm @@ -54,6 +54,11 @@ /datum/shop_sku/favor/freight_beacon = 1, /datum/shop_sku/favor/fitter_gauntlets = 1, /datum/shop_sku/ripperdoc/nightshade = 1, + /datum/shop_sku/ripperdoc/cascade_street = 1, + /datum/shop_sku/ripperdoc/redline_street = 1, + /datum/shop_sku/ripperdoc/ghostskin_street = 1, + /datum/shop_sku/ripperdoc/governor_street = 1, + /datum/shop_sku/ripperdoc/mantis_street = 1, /datum/shop_sku/ripperdoc/fixers = 1, /datum/shop_sku/ripperdoc/dermal_mesh = 1, /datum/shop_sku/ripperdoc/hopper = 1, @@ -62,6 +67,15 @@ /datum/shop_sku/ripperdoc/deadeye = 1, /datum/shop_sku/ripperdoc/slipwire = 1, /datum/shop_sku/ripperdoc/prospector = 1, + /datum/shop_sku/ripperdoc/hardweave = 1, + /datum/shop_sku/ripperdoc/atlas_street = 1, + /datum/shop_sku/ripperdoc/slipwire_street = 1, + /datum/shop_sku/ripperdoc/doppler_street = 1, + /datum/shop_sku/ripperdoc/adrenal_pump = 1, + /datum/shop_sku/ripperdoc/hopper_street = 1, + /datum/shop_sku/ripperdoc/gorilla_street = 1, + /datum/shop_sku/ripperdoc/ronin_holdout = 1, + /datum/shop_sku/ripperdoc/longsight = 1, /datum/shop_sku/black_market/c4 = 1, /datum/shop_sku/black_market/emp_grenade = 1, /datum/shop_sku/black_market/frag_grenade = 1, @@ -111,6 +125,13 @@ /datum/shop_sku/ripperdoc/atlas = 2, /datum/shop_sku/ripperdoc/gorilla = 2, /datum/shop_sku/ripperdoc/rigger = 2, + /datum/shop_sku/ripperdoc/cascade_milspec = 2, + /datum/shop_sku/ripperdoc/redline_milspec = 2, + /datum/shop_sku/ripperdoc/governor_milspec = 2, + /datum/shop_sku/ripperdoc/slipwire_milspec = 2, + /datum/shop_sku/ripperdoc/hopper_milspec = 2, + /datum/shop_sku/ripperdoc/deadeye_milspec = 2, + /datum/shop_sku/ripperdoc/lookout = 2, /datum/shop_sku/fitter/rare/mod_emp_shield_advanced = 2, /datum/shop_sku/fitter/rare/mod_projectile_dampener = 2, /datum/shop_sku/black_market/mod_chassis_syndicate = 2, @@ -143,11 +164,13 @@ /datum/shop_sku/ripperdoc/governor_delete = 3, /datum/shop_sku/ripperdoc/redline = 3, /datum/shop_sku/ripperdoc/cascade = 3, + /datum/shop_sku/ripperdoc/mantis_scorch = 3, + /datum/shop_sku/ripperdoc/monowire_live = 3, ) /datum/unit_test/voidcrew_zone_shops/catalog/Run() var/list/expected = expected_tags() - TEST_ASSERT_EQUAL(length(expected), 117, "The retained permission catalog is incomplete") + TEST_ASSERT_EQUAL(length(expected), 140, "The retained permission catalog is incomplete") var/datum/voidcrew_crew_record/crew = allocate(/datum/voidcrew_crew_record) for(var/datum/shop_sku/sku_type as anything in subtypesof(/datum/shop_sku)) var/permission = expected[sku_type] || 0 diff --git a/voidcrew/sound/monowire_deploy.ogg b/voidcrew/sound/monowire_deploy.ogg new file mode 100644 index 00000000000..faf42a97a45 Binary files /dev/null and b/voidcrew/sound/monowire_deploy.ogg differ diff --git a/voidcrew/sound/monowire_retract.ogg b/voidcrew/sound/monowire_retract.ogg new file mode 100644 index 00000000000..90520487011 Binary files /dev/null and b/voidcrew/sound/monowire_retract.ogg differ diff --git a/wiki/content/bounty-hunting.md b/wiki/content/bounty-hunting.md index 0bf64a28862..c62f13f3166 100644 --- a/wiki/content/bounty-hunting.md +++ b/wiki/content/bounty-hunting.md @@ -22,7 +22,7 @@ Each card is a wanted poster: - **WANTED** or **MOST WANTED**, and **Private offer** on one made to your ship alone; - 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; +- where they were last seen, who they were seen with ("with two friends, one armed"), and the zone; - 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. @@ -98,10 +98,12 @@ About 70% of Wanted criminals and 30% of Petty ones are normal. A Wanted crimina - 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 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. +- 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. Gunmen open fire from about 7 tiles away and keep closing to about 5. A shotgun gets in close first. - 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 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. +- Wanted criminals carry a stimpack if their pockets have room, and jab it when they tire in a fight. +- Hit by a disabler or other stun shot, a gunner or bottle thrower ducks behind the nearest cover and looks out again a moment later. A fist, knife, bat or shotgun fighter charges whoever shot it. +- They may have up to two companions who fight beside them, and the card says who they were seen with. At most one companion carries a gun. Companions get up and draw a moment after their criminal, and their guns fire shorter strings and bursts. Now and then a companion has a piece of chrome. 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. @@ -109,22 +111,23 @@ About 70% of Wanted criminals and 30% of Petty ones are normal. A Wanted crimina ### Mini-bosses -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. +Every Most Wanted criminal is a mini-boss with one of six kits. The board's **Other crews hunting** line excludes your own active hunt. - 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. -- 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. +- When they tire they jab a stimulant: for a while they shrug off batons and get up from stuns quickly. They carry three, one of them a combat stimpack that also heals them a little. - 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 | 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; 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. | +| Juggernaut | A giant in riot plates with a tower shield | Raises its shield when the fight starts; shots from in front stop at it. Charges along a line after a roar, smashing what's in the way. Slams the floor around it when you're close. | Hit it from the side or behind. 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 and gas mask, a flamethrower in one hand and a molotov in the other | Goes for whoever shoots it. Hoses a line of fire up to 3 tiles out with its flamethrower; every few sweeps the tank runs dry and it stops for a few seconds to change it, and throws molotovs that leave burning floor. Shot from further off, it throws one of its two smoke grenades halfway to you and comes through the cloud. Its fire suit keeps the flames off it and its mask keeps the smoke out. | Keep your distance and keep moving. Stay more than 3 tiles away, off its line and off burning floor. Hit it while it changes tanks. Back out of the smoke before it reaches you: without internals or a gas mask you cough and drop what you're holding. Watch the cloud from the side, or see through it with thermals. 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. An implant gets it back up a second after you first drop it. | Close the distance, and move off the blinking ring. Put it down again and cuff it; an EMP knocks the implant out. | +| 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. Shot from afar, it ducks out of your line and comes back from cover. 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. Corner it; hunters on more sides leave it nowhere to hide. | +| Heavy | A heavily armed criminal in a hooded coat, with a belt-fed gun | An ablative coat and hood turn aside about half of laser and disabler shots. 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. Use bullets, or bring a lot of disablers. | +| Cyberpsycho (rare) | A twitching criminal in shorts, chrome on its arms, chest and legs | Fights with a blade from its forearm. Lunges down a lit line, leaps onto you under a red mark, and throws a piston punch. Its chrome fist breaks windows. Hurt, or hit with a stun weapon, it roars and shrugs off stuns for a while, then collapses. Gets up once after it goes down. | Get off the line and out from under the mark. Back off while it roars, and cuff it when it collapses. An EMP makes its chrome spark and shuts it down for a while, and then it tires like the others. | !!! warning "Worn out means switch to stuns" 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. @@ -140,8 +143,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. +- **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 a MODsuit for each mini-boss. A mini-boss in a MODsuit has no coat or riot plates over it. 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. On a MODsuit, theirs comes off whole. !!! tip "Bring cuffs and a stun" A stun only lasts a little while. Have the cuffs in hand before you stun them. diff --git a/wiki/content/cyberware.md b/wiki/content/cyberware.md index dbed7a15dee..8339f1313e4 100644 --- a/wiki/content/cyberware.md +++ b/wiki/content/cyberware.md @@ -2,32 +2,36 @@ title: Cyberware category: Economy order: 6 -blurb: Chrome implants from the Chop Shop at the Undertow Exchange, neural capacity, the four tiers, the full catalog, and what an EMP does to a chromed body. +blurb: Chrome implants from the Chop Shop at the Undertow Exchange and the Back Bay at Quartermain Depot, neural capacity, the four tiers, the full catalog, and what an EMP does to a chromed body. --- -Cyberware (**chrome**) is a roster of implantable robotic organs sold at the **Chop Shop**, the neon-lit parlor off the Dregs cantina at the [Undertow Exchange](trader-outposts.md). Every piece does something no printed equipment does, from seeing in the dark to a deployable pair of hardlight blades, and every piece costs **neural load** against a fixed capacity, so a build is a budget rather than a shopping spree. Street chrome sells for credits; the good stuff wants [vouchers](money-and-trade.md). +Cyberware (**chrome**) is a roster of implantable robotic organs sold at the **Chop Shop**, the neon-lit parlor off the Dregs cantina at the [Undertow Exchange](trader-outposts.md), and, street chrome only, at the **Back Bay** in [Quartermain Depot](trader-outposts.md). Every piece does something no printed equipment does, from seeing in the dark to a deployable pair of hardlight blades, and every piece costs **neural load** against a fixed capacity, so a build is a budget rather than a shopping spree. Street chrome sells for credits; the good stuff wants [vouchers](money-and-trade.md). ## The Chop Shop Splice runs the parlor from behind counter glass. Click them for the shop, sorted into Street, Pro, Military and Legend tabs plus an ammunition shelf. Bought chrome lands in your hands as an organ, which does nothing until it is installed. -Installation is the **Chrome Cradle**, the salvaged operating slab in the middle of the parlor, the only one in the galaxy. Drag yourself onto it and its console opens, showing your neural load, every piece of chrome within reach (installed, carried, or in the parts tray), and a projection of what any swap would cost and evict. Hit Install and the rig sedates you and does the work in seconds. Only you can ever order work on your own body, and only while conscious and unrestrained. Nobody can be strapped to the slab and carved for their chrome. Evicted and removed pieces wait in the parts tray, which anyone adjacent can eject. +Installation is the **Chrome Cradle**, the salvaged operating slab in the middle of the parlor. Drag yourself onto it and its console opens, showing your neural load, every piece of chrome within reach (installed, carried, or in the parts tray), and a projection of what any swap would cost and evict. Hit Install and the rig sedates you and does the work in seconds. Only you can ever order work on your own body, and only while conscious and unrestrained. Nobody can be strapped to the slab and carved for their chrome. Evicted and removed pieces wait in the parts tray, which anyone adjacent can eject. The Cradle also removes chrome in three seconds flat, and runs a **tune-up** for 200 credits that clears EMP scramble and repairs all your installed ware. If you carry the Chromatic Dermis ink suite, the Cradle's ink panel re-keys its color and pattern for free. -Outside the parlor, ordinary organ-manipulation surgery at any operating table installs and removes chrome too, leg surgery exists for exactly this reason. Autosurgeons refuse the work entirely. +Outside the parlors, ordinary organ-manipulation surgery at any operating table installs and removes chrome too, leg surgery exists for exactly this reason. Autosurgeons refuse the work entirely. + +## The Back Bay + +Ratchet, a loader mechanic who started putting chrome in people, works out of a storage bay off Quartermain's upper landing. He sells street chrome only, for credits, at Splice's prices, and the bay has a Chrome Cradle of its own that works the same way. He buys pulled chrome back on the same terms as Splice, even the pieces only Splice sells. His shelf carries the newer street pieces too: the cheap optics and the quiet passives below. ## Neural load Your body has **20 capacity** shared by chrome, ordinary implants, cybernetic organs, surgical enhancements and installed nanite programs. Ordinary implants, robotic organs and surgical enhancements cost **1 each**. Mindshield implants cost **0**. Prosthetic limbs cost **0**, but implants inside them still count. Chrome uses the catalogue loads below. Nanite costs depend on the program and count even when switched off. See [Nanites & Revival](nanites-and-revival.md). Every installed upgrade sums its load against capacity, and the Cradle refuses any install that would take you over, though swapping within a ladder only costs the difference, since the piece being replaced comes out first. If you somehow end up over capacity anyway, everything browns out: **every** piece of chrome goes offline and beneficial nanite programs pause until the load drops back under, Remove enough installed load to restore capacity. -Same-slot ware is mutually exclusive, one operating system, one dermal layer, one leg rig, one piece of hardware per arm, which makes most slots either a ladder (Shock Coils into Hopper Pistons, Dermal Mesh into Slabskin) or a straight choice (Cascade Lattice *or* Redline Core). Arm chrome always claims the whole arm: installing Mantis Blades evicts whatever that arm already carried. Chrome optics replace your natural eyes outright. The Governor Delete raises capacity by **15**, to **35**. It occupies the chest operating-system slot, so it competes with the Cascade lattice and Redline core. +Same-slot ware is mutually exclusive, one operating system, one dermal layer, one leg rig, one piece of hardware per arm, which makes most slots either a ladder (Shock Coils into Hopper Pistons, Dermal Mesh into Slabskin) or a straight choice (Cascade Lattice *or* Redline Core). Arm chrome always claims the whole arm: installing Mantis Blades evicts whatever that arm already carried. Chrome optics replace your natural eyes outright. The Governor Delete raises capacity by **15**, to **35**, and the cheaper Governor Patch and Governor Bypass raise it by **5** and **10**. All three occupy the chest operating-system slot, so they compete with the Cascade lattice and Redline core. Much of it shows. Plated arms, leg rigs, dermal weaves and spine lattices draw on your body under your clothes, and stacking enough chrome genuinely stops you looking human. ## The catalog -Prices are Splice's, stock is limited per round, and load is the neural cost. Nightshade optics, Fixer's Fingers, Dermal Mesh, Hopper pistons, Icepick Jack, Heartbeat Doppler, Deadeye link, Slipwire and Prospector Suite need 4 [reputation](zone-reputation.md). Coolant Loop, Dead Channel, Atlas frame, Gorilla Arms and Rigger socket need 11. The rest of the military and legend stock needs 22. Barnaby at Waystation Halcyon also sells Shock Coils and Second Wind at these prices. "Pair" ware is sold as a cased set and installed one organ per arm. +Prices are the same at both counters, stock is limited per round, and load is the neural cost. Nightshade optics, Fixer's Fingers, Dermal Mesh, Hopper pistons, Icepick Jack, Heartbeat Doppler, Deadeye link, Slipwire, Prospector Suite and every street model need 4 [reputation](zone-reputation.md). Coolant Loop, Dead Channel, Atlas frame, Gorilla Arms, Rigger socket, the service reflex lattice, the Vanguard core and the Governor Bypass need 11. The rest of the military and legend stock needs 22. Barnaby at Waystation Halcyon also sells Shock Coils and Second Wind at these prices. "Pair" ware is sold as a cased set and installed one organ per arm. ### Tier 1: Street chrome (credits) @@ -43,7 +47,7 @@ Prices are Splice's, stock is limited per round, and load is the neural cost. Ni | Cargo Cavity | 1,000 cr | 1 | A chest stash for one small item that no scanner, pat-down or Chrome Read finds | | Rockjaw drill fist | 1,200 cr | 2 | Deployable forearm mining drill; ore from walls you crack auto-pockets into a hopper | | Fixer's Fingers | 1,800 cr | 2 | Fingertip screwdriver, wrench and wirecutters, plus 25% faster timed actions full-time | -| Dermal Mesh weave | 2,000 cr | 2 | Light built-in armor: melee 15, bullet 15, laser 10 | +| Dermal Mesh weave | 2,000 cr | 2 | Light built-in armor: melee 15, bullet 15, laser 10. 15% of bullets from the front glance off | ### Tier 2: Pro chrome (credits or vouchers) @@ -69,13 +73,13 @@ Prices are Splice's, stock is limited per round, and load is the neural cost. Ni |---|---|---|---| | Atlas frame | 2 | 4 | Bones cannot break and limbs cannot come off; knockback against you is halved | | Gorilla Arms (pair) | 3 | 3/arm | 20-damage punches with knockback, fists that break rock, and bare-handed airlock prying | -| Widowline monowire | 3 | 5 | A two-tile whip that ignores armor entirely and cleaves bystanders for 75% | +| Widowline monowire | 3 | 5 | A two-tile whip that ignores armor entirely and cuts through into one person standing right behind the target for 75% | | Popup Ronin housing | *loot only* | 5 | Deployable full-auto machine pistol in 10x24mm caseless. Reloads are sold at the parlor or printed with Experimental Ammunition | | Rigger socket | 3 | 4 | Jack into your own ship's helm from anywhere aboard and fly it from a corridor | -| Slabskin plate | 3 | 6 | Heavy built-in armor in every damage type. Solid hits visibly spark off you. Everyone can see you are plated | -| Mantis Blades (pair) | 4 | 3/arm | Deployable hardlight blades, plus a five-tile lunge that knocks the target down | +| Slabskin plate | 3 | 6 | Heavy built-in armor in every damage type. 45% of bullets from the front glance off. Solid hits visibly spark off you. Everyone can see you are plated | +| Mantis Blades (pair) | 4 | 3/arm | Deployable hardlight blades, plus a five-tile lunge that knocks the target down. Press and hold the lunge on a target to crouch, and let go to spring up to seven tiles; a solid hit or a stun while you crouch wastes it. A kill brings the lunge back almost at once. Three quick cuts to one limb open its artery, a two-blade lunge skewers someone already hurt, every third cut with both blades out crosses them and staggers, and a swing at the head of someone dying takes it off | | Bunker Buster housing | *loot only* | 5 | Two shaped micro-rockets: 60 damage, no splash, will never breach a hull. Reloads are sold at the parlor or printed with Experimental Ammunition | -| Ghostskin weave | 4 | 5 | Ten seconds of optical camo. NPCs will not target you, and Chrome Reads scatter. Attacking, taking a hit or an EMP drops it | +| Ghostskin weave | 4 | 5 | Ten seconds of optical camo. NPCs will not target you, and Chrome Reads scatter. Attacking, throwing, taking a hit or a shock, or an EMP drops it | | Lazarus node | 4 | 5 | The moment you drop into crit, it charges for a second and shocks you back to your feet at 30% health. Once per six minutes | ### Tier 4: Legend chrome (vouchers, one of each per round) @@ -84,10 +88,45 @@ Prices are Splice's, stock is limited per round, and load is the neural cost. Ni |---|---|---|---| | Governor Delete | 5 | 0 | +15 capacity. Occupies the chest OS slot, competing with Cascade and Redline | | Redline core | 6 | 10 | Twelve seconds of stun immunity, 40% less brute and burn taken, +8 unarmed damage and a roar that staggers everyone nearby, then the crash | -| Cascade lattice | 8 | 12 | The sandevistan: eight seconds at double time with halved melee cooldowns and 40% projectile dodge while moving, then the crash. An EMP mid-window ends it early and eats the cooldown | +| Cascade lattice | 8 | 12 | Eight seconds at double time with halved melee cooldowns and 60% dodge against blows, or against projectiles while moving, and harder-hitting strikes, then the crash. An EMP mid-window ends it early and eats the cooldown | | Meteor Piledriver frame | *never sold* | 8 | An eight-tile leap that crushes whoever is standing on the landing tile and hurls everyone around them. A rare guarded-mission completion prize; see [Missions](missions.md) | -The **ammunition shelf** is the return-visit hook: Ronin magazines at 250 credits and Buster rocket pairs at 300, both at 4 [reputation](zone-reputation.md). Splice also buys back *removed* street chrome at about half list price; military chrome is never bought back. +### Cheaper models + +Six of the big pieces come in cheaper models from other makers. Each takes the same slot as the original, so you can start on the cheap one, sell it back and move up. Street models sell for credits at both counters. The service models and the fire and shock variants are vouchers, from Splice only. + +| Piece | Price | Load | What it does | +|---|---|---|---| +| Flickerskin weave | 2,400 cr | 2 | Seven seconds of patchy camo. It fools people, but NPCs still see you and Chrome Reads still land | +| Shiv Blades (pair) | 2,400 cr | 2/arm | Deployable hardlight blades, duller than the Mantis, with no lunge and none of its tricks. They still bleed people | +| Governor Patch | 2,500 cr | 0 | +5 capacity. Occupies the chest OS slot | +| Hothead core | 3,000 cr | 4 | Eight seconds of 20% less brute and burn and +3 unarmed damage, then the crash. No stun immunity and no roar | +| Spliced reflex rig | 3,600 cr | 6 | Six seconds of quicker movement, melee cooldowns cut by a quarter and 30% dodge against blows, or against projectiles while moving, and harder-hitting strikes, then a long crash | +| Governor Bypass | 3 vouchers | 0 | +10 capacity. Occupies the chest OS slot | +| Service reflex lattice | 4 vouchers | 9 | Seven seconds of quicker movement, melee cooldowns cut by 40% and 45% dodge against blows, or against projectiles while moving, and harder-hitting strikes, then the crash | +| Vanguard core | 4 vouchers | 8 | Ten seconds of stun immunity, 30% less brute and burn and +5 unarmed damage, opened by a roar that staggers people nearby, then the crash | +| Scorch Blades (pair) | 4 vouchers | 4/arm | Mantis Blades that set whoever they cut on fire. The lunge lights them harder, and the heat half-seals the arteries they open | +| Widowline Arc | 5 vouchers | 6 | A Widowline that shocks on every hit, cuts robots and mechs much harder, and briefly knocks out turrets, consoles and cameras it strikes | + +The **ammunition shelf** is the return-visit hook: Ronin magazines at 250 credits and Buster rocket pairs at 300, both at 4 [reputation](zone-reputation.md). Both ripperdocs buy back any *removed* chrome that sells for credits, even pieces they sold you, at half list price. Chrome paid for in vouchers is never bought back. + +### More street pieces + +The newer makers fill in the gaps under the big names. Each takes the same slot as the piece it copies, so it sells back and climbs like the others. + +- **Spring calves** and **Vaulter pistons**: a short hop on cheap springs, and the service pistons that clear a room. +- **Brawler myomers**: a cased pair of forearms that hit hard, break rock, slam a held body down and force an airlock, slower than Gorilla Arms. +- **Tinker's fingers** and the **Deepcore drill fist**: a looser set of fingertip tools, and a heavier drill on the same ore hopper. +- **Holdout housing**: a snub revolver folded into the forearm, loaded one round at a time. +- **Hardweave plating** and the **Strut frame**: a heavier dermal weave that turns 30% of bullets from the front, and a frame that keeps your bones whole. +- **Deep-lung bladder**, **Heat-sink lining** and **Frostline lining**: a longer breath, a lining for the heat, a lining for the cold. +- **Twitchwire** and the **Weaver shunt**: a twitchy reflex shunt, and the service model. +- **Thumper ear**: a louder, shorter-ranged sonar behind the ear. +- Quiet pieces with no button: the **Clotter node** slows bleeding, the **Adrenal pump** kicks in when you're about to drop, **Medic's palms** and **Cuffer's wrists** do the glove's job without the glove, the **Subvocal mic** keeps your radio talk from the people next to you, and the **Muffler ear** shuts out a bang. + +## Optics and zoom + +Every pair of chrome eyes can zoom: focus on something far off and your view pulls toward it. Better eyes see further, and cheap ones make you slow while you look. Nobody shoots straight through a zoom, so you have to look up before you fire. A flash, a stun or an EMP snaps you out of it. Spyglass and assay optics are the cheap way in; the Longsight, the marksman link and the Lookout are what scouts and sharpshooters save for. ## Finding chrome in the wild @@ -98,4 +137,5 @@ Most of the roster also appears in zone loot caches. Street and utility chrome a - **EMP is the hard counter.** A pulse downs every piece you carry (nine seconds on a heavy blast, four and a half on a light one) then it reboots on its own. Gecko Grips spasm and throw whatever you are holding, Ghostskin camo collapses, and a Cascade window crashes on the spot. A Cradle tune-up cancels the reboot early. Actions and arm weapons stay unavailable while the chrome is offline. An EMP interrupting Lazarus during its charge does not spend the revival charge. - **Detection cuts both ways.** Chrome optics carry the Chrome Read, a scan that names a target's ware (street optics only count it), and the subject always feels the handshake. The Cargo Cavity never resolves on any scan, and Ghostskin scatters reads entirely. - **Death does not keep it.** Gibbing, dusting or destroying a limb ejects every piece onto the floor, and killers absolutely loot a chromed corpse. Cloning leaves the chrome on the body. +- **Plating turns bullets.** Dermal Mesh, Hardweave and Slabskin make bullets and buckshot pellets glance off with a spark and a ping, each pellet on its own. It never stops lasers, energy or blows, and never a shot into your back. The round keeps flying, so whoever stands beside you can still catch it. Each glance costs a little stamina, so steady fire still wears you down. A dodge and a glance together never stop more than 60% of shots. - **Nothing is subtle.** Slabskin sparks on every hit, the Chromatic Dermis flares whenever your chrome fires, and the heavy installs change how you look. Chromed is a fashion statement whether you want it or not. diff --git a/wiki/content/glossary.md b/wiki/content/glossary.md index 67fdcfeaf13..f6a28516a56 100644 --- a/wiki/content/glossary.md +++ b/wiki/content/glossary.md @@ -59,7 +59,7 @@ Voidcrew adds a vocabulary that /tg/station does not have, and most of it turns | **[Ship parts](ship-parts.md)** | Physical items in four classes (combat, science, trade and misc). Bank them through an extraction case to keep them between rounds and buy permanent shipyard unlocks. | | **Extraction case** | The secure case parts must be sitting in, on your person, for them to survive the round. Request one with the **Request Extraction Case** verb. Only the first standard case counts. | | **Voucher** | A trade voucher: a physical chit earned from dangerous work, never bought with credits, and spent at any trader for restricted goods. Being an item, it can be stolen off you. | -| **Chrome** | Cyberware, implantable robotic organs sold at the Chop Shop on the Undertow Exchange. See [Cyberware](cyberware.md). | +| **Chrome** | Cyberware, implantable robotic organs sold at the Chop Shop on the Undertow Exchange and the Back Bay at Quartermain Depot. See [Cyberware](cyberware.md). | | **Neural load** | The shared cost of chrome, implants, robotic organs, surgical enhancements and installed nanite programs against 20 capacity. Overload disables chrome and beneficial nanite programs. | | **Trader outpost** | One of three permanent markets, one per zone: general store in green, outfitter in yellow, black market in red. Turrets shoot people who keep starting fights. See [Trader Outposts](trader-outposts.md). | | **Player outpost** | A base a crew plants for itself using an outpost deed. See [Player Outposts](player-outposts.md). | diff --git a/wiki/content/missions.md b/wiki/content/missions.md index 5265ce0d1dd..65983aa88cd 100644 --- a/wiki/content/missions.md +++ b/wiki/content/missions.md @@ -13,7 +13,7 @@ The mission board links to a nearby mission pad. Open **Available** to browse wo The console posts a set of **five offers every 20 minutes**, including a green-zone exploration job when one is available. Up to three slots are reserved for targeted work in the highest zone your crew's [reputation](zone-reputation.md) allows. Taking or losing a job leaves a vacancy until the next set arrives. **Refresh** becomes available when the next set is due; it does not give an early replacement. Reopening or rebuilding the console keeps the ship's offers and schedule. -For a starting job, look for an **Exploration Contract** in green space. Fly to its marked coordinates, then collect the listed fee at the board. +For a starting job, look for an **Exploration Contract** in green space. Fly to its marked coordinates and hold there while the sensors sweep the sector, then collect the listed fee at the board. Each offer shows its task, pay, and allowed time. Accepting starts its deadline and adds a helm waypoint when there is a destination. Some jobs also leave equipment on the mission pad: collect it before leaving. Tap a handheld GPS on the board to copy active mission beacons, or use **Link Mission Beacons** with a fitted MOD GPS. @@ -86,13 +86,13 @@ These prizes are separate from the offer's ordinary credits, vouchers and goods. | Contract | What it asks | |---|---| | Delivery Contract | Bring the listed goods to the pad: spice pods, sinew, goliath hides, glacial cores, raw telecrystals, a sea crystal, or Syndicate documents. Stored goods qualify. | -| Exploration Contract | Fly the ship to marked coordinates, then collect the fee. | +| Exploration Contract | Fly the ship to marked coordinates, hold position for the sensor sweep, then collect the fee. The sweep sometimes turns up a nearby derelict. | | Survey Contract | Scan the requested celestial objects with the orbital survey console. | | Telemetry Contract | Gather the requested survey scans and return for credits and research notes. | | Recovery Contract | Retrieve a named object from inside a space ruin. | | Kill Contract | Hunt a named pirate captain in a ruin and bring back their identification tag. | | Survey Contract (pylons) | Calibrate the ruin's survey pylons, survive their defenders, and bring back the printed core. | -| Extraction Contract | Unbolt cargo inside a ruin, deal with the defenders, and bring it home. | +| Extraction Contract | Unbolt cargo inside a ruin with a wrench, deal with the defenders, and bring it home. | | Rescue Contract | Escort a survivor out of a wreck and bring them back alive. | | Suppression Sweep | Confirm the requested pirate kills in the required area, then collect at the board. | | Gas Harvest Contract | Deliver a tank containing the requested gas and amount. Gas already aboard qualifies. See [Fuel & Gas](gas-economy.md). | @@ -100,7 +100,7 @@ These prizes are separate from the offer's ordinary credits, vouchers and goods. | Big Game Hunt | Deploy the supplied lure, kill the named beast, and return its trophy. | | Live Capture | Find the marked specimen, weaken it without killing it, and deliver it alive in the supplied capture crate. | | Poacher Bust | Clear a poacher camp and recover its evidence cache. | -| Prospect Stake | Deploy a claim beacon aboard your ship at the marked coordinates, hold station through its defense, and deliver the deed. | +| Prospect Stake | Land on the marked planet, deploy the claim beacon on open ground, stay with it through its defense, and deliver the deed. | | Containment Contract | Find and neutralize the named anomaly, then deliver its core. | | Core Sample Contract | Complete a planet's sampling work and return the sample. | diff --git a/wiki/content/pirates-and-npc-ships.md b/wiki/content/pirates-and-npc-ships.md index f1650dc6dde..29a71f0f616 100644 --- a/wiki/content/pirates-and-npc-ships.md +++ b/wiki/content/pirates-and-npc-ships.md @@ -82,3 +82,4 @@ The one exception is dispatched rather than roaming: **NTSV Vigilant**, a Nanotr - Paying is often cheaper than the repair bill. - If you intend to fight, do it in the Lawless Zone with shields up and your own [weapons](ship-combat.md) built. Getting jumped in the Contested Zone with no interdictor means you cannot chase, cannot board and cannot shoot back. - Bring guns before you board. Their crew does not stop being dangerous because their ship stopped moving. +- Pirate gunners hit by stun shots duck behind cover and look out again a moment later; their melee fighters and shotgunners charge whoever shot them. diff --git a/wiki/content/trader-outposts.md b/wiki/content/trader-outposts.md index 9fd588e5910..64a835a256d 100644 --- a/wiki/content/trader-outposts.md +++ b/wiki/content/trader-outposts.md @@ -73,6 +73,7 @@ Each outpost's concourse has its own side vendors, each with their own shopkeep | Halcyon | The Chowder Pot | Roux | The diner. Hot meals in tiers, galley staples, buys home cooking | | Quartermain | The Skunkworks | Boffin | Research and fabrication gear, Strong-Arm implants, robotics and xenobiology starter packs, raw anomaly cores and anomaly charts | | Quartermain | The Fitting Bay | Wick | Civilian through advanced MODsuits | +| Quartermain | The Back Bay | Ratchet | Street chrome for credits, installed in the bay's own Chrome Cradle | | The Undertow | The Dregs | Dram | The cantina | | The Undertow | Patch-Up Clinic | Sawbones | Medical supplies, the genetics starter pack | | The Undertow | The Chop Shop | Splice | Cyberware implants in four tiers, installed in the parlor's own Chrome Cradle | @@ -81,7 +82,9 @@ Each outpost's concourse has its own side vendors, each with their own shopkeep **The Fitting Bay** at Quartermain has a **MOD fitting bench**, a powered frame you back into while still wearing your suit. It swaps modules for free with no screwdriver work, sells permanent upgrades (plating, module capacity, actuator tuning, power regulation, cell swaps) and per-visit servicing, gives away paint and engraving, and trickle-charges your cell while the frame is shut. Reinforced plating needs 4 [reputation](zone-reputation.md) and composite plating needs 11. It will not convert a suit from one theme to another. For the tier Wick won't touch, syndicate and elite chassis, Interdyne and infiltrator control units, the antag modules. Go to **Vex**: 3600 credits plus 2 vouchers for a syndicate chassis, 5400 plus 3 for an elite, 5 vouchers for a fully equipped syndicate suit. -**The Chop Shop** at the Undertow is the galaxy's only cyberware parlor, a neon annex off the Dregs. Splice sells chrome implants off four shelves, street chrome for credits, pro chrome for credits or vouchers, military and legend chrome for vouchers only, and the **Chrome Cradle** in the middle of the room does the installing: you lie on the slab, pick a piece off the rack, and the rig does the surgery in seconds. Removals, repairs and ink re-keying run on the same console, an ammunition shelf keeps implanted weapons fed, and Splice buys back pulled street chrome at about half price. The full catalog is on [Cyberware](cyberware.md). +**The Chop Shop** at the Undertow is the full cyberware parlor, a neon annex off the Dregs. Splice sells chrome implants off four shelves, street chrome for credits, pro chrome for credits or vouchers, military and legend chrome for vouchers only, and the **Chrome Cradle** in the middle of the room does the installing: you lie on the slab, pick a piece off the rack, and the rig does the surgery in seconds. Removals, repairs and ink re-keying run on the same console, an ammunition shelf keeps implanted weapons fed, and Splice buys back pulled street chrome at about half price. The full catalog is on [Cyberware](cyberware.md). + +**The Back Bay** at Quartermain is the cheap end of the trade: Ratchet works out of a storage bay off the upper landing, with a Chrome Cradle of his own. He sells street chrome only, for credits, at Splice's prices, and buys pulled street chrome back on the same terms. Vex's own shelves carry the other half of the deep-band trade: **exploit software** for ship hacking, from 500-credit lightshow cartridges to the voucher-only exotics, plus the electronic-warfare suite board itself. See [Ship Hacking](ship-hacking.md).