q6 z@LFL`O4%YP(`z}d^SKA(6YuCQ$8Io>b9~V^BT&Ivgr>3iVkBtoxU;GrJ9(m;|wiMRMLjM7@3v Oa5U52|G;wq%rLh?mmKbCD_Mb2fLWhMY_*JA=?O=Q8J^yoC!y66pJwoo_mx z5^|;_Jh52kbH-m>V-Rrb(8P42#C4&F(C^Ph(x@o2LVq#l_*rN~eooeaS}VMquV9sD z6(dwoaI(1YDkA3$!j) tZ)|EDjBVI3eo%ux^@vx{cD<>os?mi{6xOwU)ewlhBfWMhyCsZQr|dYII=Rr*ST z9vVDSx+2wt1{eJ#AOC!~D9vI-p`z3}+laD}8Fa=B*QYhR9~Sp1&8DXC+#R8hf0xNn zDoI~0;|v?^%)AEjz2@Q~O@Eo*B+YGy5y_~WPREcfw|M54KJhvAE~0X_@nqyqH^?q? zXOXkCo5*{Y`?|pV9o?SpB|c$XLT}+24hT?Z!JVbUPmMFa0FONR_|ta=X;RhXGp46u zFxcgxxmp&PkA9*+!X1id=Dk^}ljS~Wi7cCQarFB2BH=~Em+Ao?n226*?lgN8=Uv~y zmqTV>q;yAxiNNG@IM?2rD`q`7qy{o~V1>F&naoo<=^wu (=9nlbnor zzNVE&f?RVdc%#w5J39!{Sm#%A-~$lK0`Z#esZLm0Q~}ema*J$J9B;QX+jQu@XDBVl z0(0#i0&(|i+PT}Hb98anxI7JPzZ+8nt>{M_7GI1$n5;{)XB 6N7`(`Vma6&Qq%Kmj@Qgbi|;&UbIp`$#<%K}e#ed3O{PkaCQF zsIm- RG_(+w}>$?w9Ro{X5RJCYyvUIyVy0h50z;ckVqtb^k0xyZ-~xb!3G%Ymx2EJ zPdQZuegYAUKq3+Y!} h=#{Zh|IzU7@Q{bs(Q*sA=!u<4@mQJNDRR~S?3Dw=@R7t^fPPk!=y zb>aY9Ze7E&@-4Ykl|F!2<@;iA`*DB4mK8!Y^JQ&eNK~;rjN#>Hfb@jvD-aeeeM%tu zc(EKdZZ2_y2Mr-M8c*-GlrbJ}(H-*)YHl&C0u-0I4H3XQl^GXdZW|gaD2=E&_4pHz z3wJL&dvUXPjw9%nXIO|-|97;bp40g0uyA~e&Lf<$Om8YrniD1E7(kan) dLJOeOp);On8^-n 7?{3}tc2B2~Yr0K~YMTU`mW@$Z*&A1j{W;wIV z#SC}DzL1aiE&TF|hQRQzo0^R;#_u&6m`Bw-r{g=x^YV(+$aNDQu93pt%-tL=93dT@ zNf#uoPI!E$1os8$IicMC)eoT*f8|4eQ@lMs`lRMD9=Z)p z!!%%*`#)n29TpceJY6Ah|B6)m ~_!R0o9ELy4mZN7GS&C3F?zE%>Hto$?Vl zCuA`b(PM$=7WWy_pPfxDkcj^tCliG5Osl54?=H7z7@#a-&IUccJT%M~PigPrEPZ2e zTuS+l(8}V{CH*Km2^cP?AF`(0A@POo1sZ 639z$C3Wm;Wx&|Y 8y~2hZj??Uj+LUxX`V*U8UI%=ejO&zLSF^7DB^6s zV*fX-s2lmdJ5HX)1K&bJUnnkue5c(~%y7;)H#2LtZId%R$q9ee;--)RS3L1B!7DNp zXUW(PXx;24|JZq>RHs(3nE01MMq3!ImSNR~aqd)+#7jL)(mQk|oU+WV#jD46G4f=T zG*JqX^KA5)L;hdoIOH|9{P^cPZq*KJtR0s=inAJT5pUm>&eY*Y_d<-PoDY=pVaZb4 zUNM5Vz>|}50nyB48+(%er5FfmOl Y_e7>Uh5Vb5Y A=ovfLPjV zyw41zk^w~1p=v36AJU 8G) z_UDz}TP)OSOS+eh{gDfepga13S`T<#d8hq4K<|<|4|1qMH0#Pj)CwRu%AUR}=Z&;V zkhm?c2E7W_kA*~?jkqIjCCO^l)L?L(%nm>KW1jaXr6jL_!+&`s}P#CUWuz-D!UP znO+u3KciD4j^C}iS)364hhHF8g5|VTd5JBX`EBAA)SqW<4}NkRqejcEWtGBh#jVcW z6`R)Q?0F%FEq{vmctgOc@X4kU7rx`&fURb4I`2q7b^;Xt4y3`b%GUv5fpVO%ey1E+ zFt4P+Z;hG#)HhC0Vh?HND<}}0)4UdD?WL4OG$M*c{*dah;>`1MpW&x9PF(sl`0Zx` z+KNpttH&(%-q`z?MTwwaEMQOaj^@%z9ALsp!_RaNfYx}xaxq^hYzkvxXTw3P3h(4` zKkEkkv@U%qA)wWNnyv>exv?lKP+S`6&o&xz{r^V5(~GD3qaB{cQ+#1b$^w;x{vg;b z7>i7YRfw{YSR34bNB#o?Yw=}H-eS)GX$r`ILc=}=WssJxKFp)&r!dRCRK831%j%$z zp!6$(l*Z!G`*N@+*;P39l@o@0s$3F2F?g*oze7J5t{)20Pccynnb&`d`~uD(GHFQK z@LbC3GIwQ5TR-iJM)=K3^V*=UiWh?lYQ3{w4q)%b_IfOQvY*wH;GEAy1qS z76{R{{W~(HY- J_5r#gKAC(cX}DZOl~)^bOIRHGZ1{ zH}W(U#L1%+GjbvCT`EY~^1x@wCH Wy7K{7(F5{UOY zlmVQba0Vc j4O8;qRM (#14*3s?^-D>jYh>#t%i25u`?HZ`d`G$ z@z(JH1(I=oqpccRH88OY3Js3c?i{&ouED_fSPw{tFj_nTNQk+m&j7ji^zQv&sH*nJ z>08f9Rt5r^@vmCJk 0fk #r}qrYUD_6c03EdZ$@}BS3Si{} zlj?Z^Wc`(b8mej*DdjA`mr@LzsxixUm*tcIHCS>Ztn2^Nj`1$&drzo;0=zaYP7!Bz z96u^W)z>*H#|+TnffyjxjC?Y?Zfk)X+%*yzdO)cLbfpt2(V0F0`V!ViWji26!H(vS zE|4*b)!c04mN5*eNvF^FLHa>iTAWi}p)+Ht^uw~WRHwX-NZ3Ck(C-j0EIiln?YUxQ z;gh$+WyF7nu6m+$V$zTkkf3Ze^-03aqf#$iy}>G+ZwD_k{%3v|jxp=y!!~zXwy#af zUe 4W2QkA_jmla`iqqz&AJ4uRUQ z!I1_@X~akU%OC5KZc+S{Xn9GH;4XtCVFk*Vb>-3}#8rBOq{3%G)HtC78WrH@rdI`7 zEVC3oWZOCgls)sO7P)CBAjDvJ#Jg{1lf=Kb2C`QOyGQeWEAQ%DP_NV8Fw5~N&;62+ z>(RtN?~_l|0K(k_O>}CRpX|BtD*V^P3is+!b4F(n#uz4V&aVg70=-)-Ig_RvfVkRk zc0(_G6J-6az^R)IRO%@$bEC708Nvo)$Di)B5d5s*|5*!gX6Jhka(H%mx sWqX-Q{siU^MK>hBuoW?foYnet(CZG7SPc}}O #R3Pc#cQ33Bm6&i#yj@Zr9i-{z7Mi^x?ID@Fzmw8 zT@bwH2YC1N1-a;?0KQ)ZYFNbl@a7&cPS$Ehh~#Yo%mL@v?eyt8Is?dovvnrIlRtz| UMLJfNLBPK->Ie4V)wY57XTnQ2+n{ literal 0 HcmV?d00001 From 03e816044172d99a81e3f4156602cc35951b153a Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 20:58:33 -0800 Subject: [PATCH 03/20] Add the artifact core and the Nova artifact effects Artifacts roll a main effect by the band they were dug in and sometimes a minor second effect, each with its own trigger. A stimulus wakes a matching effect for a while; air and proximity triggers hold it awake while they last. Auras spend charge faster than it refills, pulses fire when the store is full, and touch effects act on whoever touches it. Ported from NovaSector with fixes: planet air is only ever read, oxygen and nitrogen triggers are gone, nothing generates free power, helpful effects never burst when smashed, healing shares one cap per person, harmful effects log like weapons, and the scan lock frees itself. Artifacts do nothing when crated or inside a trader outpost, can be bolted down, and are never saved with a ship. Each energy kind has its own glow, particles, light, hum and wake sound. Unit tests cover pricing, the effect catalogue, triggers, the lock, checkpoint exclusion, the healing cap, cleanup and planet air. --- tgstation.dme | 20 + .../outpost_checkpoint_snapshot.dm | 4 + .../unit_tests/voidcrew_xenoarch_core.dm | 206 +++++++++ voidcrew/modules/xenoarch/core/artifact.dm | 427 +++++++++++++++++- .../xenoarch/core/artifact_appearance.dm | 389 ++++++++++++++++ .../modules/xenoarch/core/artifact_effect.dm | 412 ++++++++++++++++- .../xenoarch/core/artifact_energy_kinds.dm | 304 +++++++++++++ .../modules/xenoarch/core/artifact_helpers.dm | 126 ++++++ voidcrew/modules/xenoarch/effects/blood.dm | 63 +++ .../modules/xenoarch/effects/bodyhorror.dm | 68 +++ voidcrew/modules/xenoarch/effects/cell.dm | 104 +++++ voidcrew/modules/xenoarch/effects/disgust.dm | 33 ++ voidcrew/modules/xenoarch/effects/emp.dm | 19 + voidcrew/modules/xenoarch/effects/feelings.dm | 105 +++++ voidcrew/modules/xenoarch/effects/gas.dm | 58 +++ voidcrew/modules/xenoarch/effects/gravity.dm | 58 +++ .../modules/xenoarch/effects/hallucination.dm | 35 ++ voidcrew/modules/xenoarch/effects/health.dm | 94 ++++ voidcrew/modules/xenoarch/effects/light.dm | 41 ++ voidcrew/modules/xenoarch/effects/noise.dm | 34 ++ .../modules/xenoarch/effects/radiation.dm | 42 ++ voidcrew/modules/xenoarch/effects/sleepy.dm | 35 ++ voidcrew/modules/xenoarch/effects/stun.dm | 38 ++ voidcrew/modules/xenoarch/effects/teleport.dm | 55 +++ .../modules/xenoarch/effects/temperature.dm | 84 ++++ voidcrew/modules/xenoarch/effects/tesla.dm | 26 ++ 26 files changed, 2872 insertions(+), 8 deletions(-) create mode 100644 voidcrew/modules/xenoarch/core/artifact_appearance.dm create mode 100644 voidcrew/modules/xenoarch/core/artifact_energy_kinds.dm create mode 100644 voidcrew/modules/xenoarch/effects/blood.dm create mode 100644 voidcrew/modules/xenoarch/effects/bodyhorror.dm create mode 100644 voidcrew/modules/xenoarch/effects/cell.dm create mode 100644 voidcrew/modules/xenoarch/effects/disgust.dm create mode 100644 voidcrew/modules/xenoarch/effects/emp.dm create mode 100644 voidcrew/modules/xenoarch/effects/feelings.dm create mode 100644 voidcrew/modules/xenoarch/effects/gas.dm create mode 100644 voidcrew/modules/xenoarch/effects/gravity.dm create mode 100644 voidcrew/modules/xenoarch/effects/hallucination.dm create mode 100644 voidcrew/modules/xenoarch/effects/health.dm create mode 100644 voidcrew/modules/xenoarch/effects/light.dm create mode 100644 voidcrew/modules/xenoarch/effects/noise.dm create mode 100644 voidcrew/modules/xenoarch/effects/radiation.dm create mode 100644 voidcrew/modules/xenoarch/effects/sleepy.dm create mode 100644 voidcrew/modules/xenoarch/effects/stun.dm create mode 100644 voidcrew/modules/xenoarch/effects/teleport.dm create mode 100644 voidcrew/modules/xenoarch/effects/temperature.dm create mode 100644 voidcrew/modules/xenoarch/effects/tesla.dm diff --git a/tgstation.dme b/tgstation.dme index beeb8a121f1..ea3c71f9d1d 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7732,7 +7732,9 @@ #include "voidcrew\modules\weapons_bench\ammunition.dm" #include "voidcrew\modules\worldgen_logging\worldgen.dm" #include "voidcrew\modules\xenoarch\core\artifact.dm" +#include "voidcrew\modules\xenoarch\core\artifact_appearance.dm" #include "voidcrew\modules\xenoarch\core\artifact_effect.dm" +#include "voidcrew\modules\xenoarch\core\artifact_energy_kinds.dm" #include "voidcrew\modules\xenoarch\core\artifact_helpers.dm" #include "voidcrew\modules\xenoarch\core\artifact_label.dm" #include "voidcrew\modules\xenoarch\core\artifact_pricing.dm" @@ -7748,6 +7750,24 @@ #include "voidcrew\modules\xenoarch\dig\stabiliser.dm" #include "voidcrew\modules\xenoarch\dig\strange_rock.dm" #include "voidcrew\modules\xenoarch\dig\tools.dm" +#include "voidcrew\modules\xenoarch\effects\blood.dm" +#include "voidcrew\modules\xenoarch\effects\bodyhorror.dm" +#include "voidcrew\modules\xenoarch\effects\cell.dm" +#include "voidcrew\modules\xenoarch\effects\disgust.dm" +#include "voidcrew\modules\xenoarch\effects\emp.dm" +#include "voidcrew\modules\xenoarch\effects\feelings.dm" +#include "voidcrew\modules\xenoarch\effects\gas.dm" +#include "voidcrew\modules\xenoarch\effects\gravity.dm" +#include "voidcrew\modules\xenoarch\effects\hallucination.dm" +#include "voidcrew\modules\xenoarch\effects\health.dm" +#include "voidcrew\modules\xenoarch\effects\light.dm" +#include "voidcrew\modules\xenoarch\effects\noise.dm" +#include "voidcrew\modules\xenoarch\effects\radiation.dm" +#include "voidcrew\modules\xenoarch\effects\sleepy.dm" +#include "voidcrew\modules\xenoarch\effects\stun.dm" +#include "voidcrew\modules\xenoarch\effects\teleport.dm" +#include "voidcrew\modules\xenoarch\effects\temperature.dm" +#include "voidcrew\modules\xenoarch\effects\tesla.dm" #include "voidcrew\modules\xenoarch\effects_polaris\animate.dm" #include "voidcrew\modules\xenoarch\effects_polaris\berserk.dm" #include "voidcrew\modules\xenoarch\effects_polaris\disarm.dm" diff --git a/voidcrew/modules/player_outposts/outpost_checkpoint_snapshot.dm b/voidcrew/modules/player_outposts/outpost_checkpoint_snapshot.dm index 71dc3b0dffb..58f417f997b 100644 --- a/voidcrew/modules/player_outposts/outpost_checkpoint_snapshot.dm +++ b/voidcrew/modules/player_outposts/outpost_checkpoint_snapshot.dm @@ -48,6 +48,10 @@ GLOBAL_LIST_INIT(outpost_checkpoint_excluded, typecacheof(list( /obj/structure/headpike, // Outpost property that works a ship bay's side rooms, never a ship's fitting. /obj/structure/outpost_yard_droid, + // Dug finds live for the round only: rebuilding one would reroll its effects and refill its + // harvests (voidcrew/modules/xenoarch/). + /obj/machinery/artifact, + /obj/machinery/power/charged_crystal, ))) /** diff --git a/voidcrew/modules/unit_tests/voidcrew_xenoarch_core.dm b/voidcrew/modules/unit_tests/voidcrew_xenoarch_core.dm index 321a3bff218..08abd9a3cbc 100644 --- a/voidcrew/modules/unit_tests/voidcrew_xenoarch_core.dm +++ b/voidcrew/modules/unit_tests/voidcrew_xenoarch_core.dm @@ -1 +1,207 @@ // Xenoarchaeology tests: core. +// +// Test files compile before voidcrew/_DEFINES, so the values below are literals. They mirror +// voidcrew/_DEFINES/xenoarch.dm: +// bands (ZONE_*): green 1, yellow 2, red 3 +// tiers: common 1, uncommon 2, rare 3, extreme 4 +// triggers: touch 1, water 2, acid 4, volatile 8, toxin 16, impact 32, energy 64, +// heat 128, cold 256, plasma 512, co2 1024, proximity 2048 +// release methods: "touch", "aura", "pulse" + +/// Sale price: the design's worked examples, the label floor, condition and rounding. +/datum/unit_test/voidcrew_xenoarch_price/Run() + TEST_ASSERT_EQUAL(xenoarch_price_for(1, 1, 1), 250, "green common, perfect label") + TEST_ASSERT_EQUAL(xenoarch_price_for(2, 3, 1), 1125, "yellow rare, perfect label") + TEST_ASSERT_EQUAL(xenoarch_price_for(3, 3, 1), 1750, "red rare, perfect label") + TEST_ASSERT_EQUAL(xenoarch_price_for(3, 4, 1), 2800, "red extreme, perfect label") + TEST_ASSERT_EQUAL(xenoarch_price_for(3, 1, 0), 140, "red common, unlabelled") + TEST_ASSERT_EQUAL(xenoarch_price_for(3, 1, 0.3), 140, "a label under half right pays the unlabelled rate") + TEST_ASSERT_EQUAL(xenoarch_price_for(3, 1, 0.5), 350, "a half-right label pays half") + TEST_ASSERT_EQUAL(xenoarch_price_for(3, 1, 0.5 + 0.3 + 0.2), 700, "a perfect label summed in floating point pays in full") + TEST_ASSERT_EQUAL(xenoarch_price_for(2, 1, 1, TRUE), 225, "damaged halves the price") + TEST_ASSERT_EQUAL(xenoarch_price_for(1, 1, 1, FALSE, 3), 130, "three harvests take 0.8 cubed, rounded to 5") + TEST_ASSERT_EQUAL(xenoarch_price_for(null, 1, 1), 250, "an unknown band prices as green") + TEST_ASSERT_EQUAL(xenoarch_research_points(1, 1), 100, "green research") + TEST_ASSERT_EQUAL(xenoarch_research_points(3, 3), 375, "red rare research") + + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/heal, null, 2) + TEST_ASSERT_EQUAL(artifact_sale_value(find), 0, "a find never dug sold for credits") + find.stamp_origin(2) + TEST_ASSERT(!find.stamp_origin(3), "a second stamp replaced the first") + TEST_ASSERT_EQUAL(artifact_sale_value(find), 135, "an unlabelled yellow uncommon find") + var/trigger_word = artifact_trigger_name(find.main_effect.trigger) + find.apply_label(new /datum/artifact_label("Heals", trigger_word, "None")) + TEST_ASSERT_EQUAL(find.label_accuracy(), 1, "a perfect label did not read as perfect") + TEST_ASSERT_EQUAL(artifact_sale_value(find), 675, "a perfectly labelled yellow uncommon find") + find.apply_label(new /datum/artifact_label("Heals", trigger_word, "Light")) + TEST_ASSERT_EQUAL(artifact_sale_value(find), 540, "a wrong second effect costs a fifth") + find.damaged = TRUE + find.harvests_left = 2 + TEST_ASSERT_EQUAL(artifact_sale_value(find), 215, "damaged and harvested once") + find.research_paid = TRUE + TEST_ASSERT_EQUAL(artifact_research_value(find), 0, "research paid twice for one artifact") + +/// Every rollable effect is complete, every tier can roll, and the free-power fix holds. +/datum/unit_test/voidcrew_xenoarch_catalogue/Run() + var/list/tiers_seen = list() + for(var/datum/artifact_effect/effect_type as anything in artifact_effect_types()) + var/datum/artifact_effect/effect = new effect_type(null, 1) + TEST_ASSERT(effect.tier >= 1 && effect.tier <= 4, "[effect_type] has tier [effect.tier]") + TEST_ASSERT(!effect.minor || effect.tier <= 2, "[effect_type] is minor above uncommon") + TEST_ASSERT(length(effect.allowed_release_methods), "[effect_type] can't release at all") + TEST_ASSERT(effect.release_method in list("touch", "aura", "pulse"), "[effect_type] rolled release [effect.release_method]") + TEST_ASSERT(GLOB.artifact_energy_kinds[effect.energy_kind], "[effect_type] rolled unknown energy kind [effect.energy_kind]") + TEST_ASSERT(effect.trigger in list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048), "[effect_type] rolled trigger [effect.trigger]") + TEST_ASSERT(effect.label_name in artifact_effect_label_names(), "[effect_type]'s label is missing from the labeler words") + TEST_ASSERT(!(effect.helpful && effect.harmful), "[effect_type] is both helpful and harmful") + tiers_seen |= effect.tier + qdel(effect) + for(var/tier in 1 to 4) + TEST_ASSERT(tier in tiers_seen, "no effect can roll at tier [tier]") + TEST_ASSERT(xenoarch_pick_effect_type(tier, 1), "picking a tier [tier] effect found nothing") + TEST_ASSERT(xenoarch_pick_effect_type(null, 3, minor_only = TRUE), "no minor second effect can roll") + var/datum/artifact_effect/tesla/tesla = new(null, 3) + TEST_ASSERT(!(tesla.zap_flags & ZAP_GENERATES_POWER), "the tesla effect powers tesla coils") + qdel(tesla) + + // Deeper bands roll stronger effects (2000 rolls each; the means are about 1.5 and 2.15). + var/green_total = 0 + var/red_total = 0 + for(var/i in 1 to 2000) + green_total += xenoarch_roll_tier(1) + red_total += xenoarch_roll_tier(3) + TEST_ASSERT(red_total > green_total * 1.2, "red tier rolls ([red_total]) are not clearly above green ([green_total])") + +/// Triggers: only the matching stimulus wakes an effect, wakes lapse, and a crated find never stirs. +/datum/unit_test/voidcrew_xenoarch_triggers/Run() + TEST_ASSERT_EQUAL(artifact_reagent_trigger(/datum/reagent/water), 2, "water is not a water trigger") + TEST_ASSERT_EQUAL(artifact_reagent_trigger(/datum/reagent/hydrogen), 2, "hydrogen is not a water trigger") + TEST_ASSERT_EQUAL(artifact_reagent_trigger(/datum/reagent/toxin/acid), 4, "acid is not an acid trigger") + TEST_ASSERT_EQUAL(artifact_reagent_trigger(/datum/reagent/toxin/plasma), 8, "liquid plasma is not volatile") + TEST_ASSERT_EQUAL(artifact_reagent_trigger(/datum/reagent/toxin), 16, "toxin is not a toxin trigger") + TEST_ASSERT_EQUAL(artifact_reagent_trigger(/datum/reagent/consumable/sugar), 0, "sugar set something off") + TEST_ASSERT_EQUAL(artifact_reagent_triggers(list(/datum/reagent/water, /datum/reagent/toxin/acid)), 6, "a mixture should count as both") + + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/temperature/heat, /datum/artifact_effect/light, 1) + find.main_effect.trigger = 2 + find.second_effect.trigger = 32 + TEST_ASSERT(!find.stimulate(1), "touch matched a water trigger") + TEST_ASSERT(!find.is_active(), "a wrong stimulus woke it") + TEST_ASSERT(find.stimulate(2), "water did not match a water trigger") + TEST_ASSERT(find.main_effect.activated, "water did not wake the main effect") + TEST_ASSERT(!find.second_effect.activated, "water woke the impact-triggered second effect") + TEST_ASSERT(find.shown_awake, "the artifact does not look awake") + TEST_ASSERT_EQUAL(find.icon_state, "[find.shape]_active", "the artifact did not switch to its active sprite") + find.main_effect.awake_until = world.time - 1 + find.process(2) + TEST_ASSERT(!find.main_effect.activated, "an expired wake did not lapse") + TEST_ASSERT_EQUAL(find.icon_state, find.shape, "the artifact kept its active sprite asleep") + + // The glove rule. + var/mob/living/carbon/human/consistent/tester = allocate(/mob/living/carbon/human/consistent) + TEST_ASSERT(artifact_touch_counts(tester), "a bare hand did not count as touch") + var/obj/item/clothing/gloves/latex/latex = allocate(/obj/item/clothing/gloves/latex) + tester.equip_to_slot_if_possible(latex, ITEM_SLOT_GLOVES) + TEST_ASSERT(!artifact_touch_counts(tester), "latex gloves counted as touch") + qdel(latex) + var/obj/item/clothing/gloves/color/yellow/insulated = allocate(/obj/item/clothing/gloves/color/yellow) + tester.equip_to_slot_if_possible(insulated, ITEM_SLOT_GLOVES) + TEST_ASSERT(artifact_touch_counts(tester), "ordinary gloves did not count as touch") + find.main_effect.trigger = 1 + find.touched_by(tester) + TEST_ASSERT(find.main_effect.activated, "a gloved hand did not wake a touch trigger") + + // Proximity is held while someone stands near, and only then. + find.main_effect.deactivate(quiet = TRUE) + find.main_effect.trigger = 2048 + tester.moveToNullspace() + find.process(2) + TEST_ASSERT(!find.main_effect.activated, "proximity woke with nobody near") + tester.forceMove(get_step(find, EAST)) + find.process(2) + TEST_ASSERT(find.main_effect.activated, "proximity did not wake with someone beside it") + + // Crated, it goes still and ignores everything. + var/obj/structure/closet/crate/specimen/crate = allocate(/obj/structure/closet/crate/specimen, get_step(find, NORTH)) + find.forceMove(crate) + TEST_ASSERT(!find.is_active(), "a crated find stayed awake") + TEST_ASSERT(!find.stimulate(2048), "a crated find took a stimulus") + find.process(2) + TEST_ASSERT(!find.is_active(), "a crated find woke from proximity") + +/// The analyser and harvester lock frees itself on release, on its holder's deletion and on timeout. +/datum/unit_test/voidcrew_xenoarch_lock/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + var/datum/analyser = allocate(/datum) + var/datum/harvester = allocate(/datum) + TEST_ASSERT(find.try_lock(analyser), "a free artifact refused a lock") + TEST_ASSERT(find.is_being_used(), "a locked artifact reads as free") + TEST_ASSERT(!find.try_lock(harvester), "a second machine took a held lock") + TEST_ASSERT(!find.release_lock(harvester), "a machine released someone else's lock") + TEST_ASSERT(find.release_lock(analyser), "a halted scan could not release its lock") + TEST_ASSERT(!find.is_being_used(), "releasing left the artifact locked") + TEST_ASSERT(find.try_lock(harvester), "a released artifact refused a new lock") + qdel(harvester) + TEST_ASSERT(!find.is_being_used(), "a deleted machine kept its lock") + TEST_ASSERT(find.try_lock(analyser, 0), "could not take a lock") + TEST_ASSERT(!find.is_being_used(), "a lock outlived its timeout") + +/// Finds never ride along in a ship checkpoint or save. +/datum/unit_test/voidcrew_xenoarch_checkpoints/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + TEST_ASSERT(!outpost_checkpoint_saves(find), "a checkpoint would save a loose artifact") + find.set_anchored(TRUE) + TEST_ASSERT(!outpost_checkpoint_saves(find), "a checkpoint would save a bolted artifact") + TEST_ASSERT_NULL(find.checkpoint_type(), "an artifact has a checkpoint rebuild type") + var/obj/machinery/power/charged_crystal/crystal = allocate(/obj/machinery/power/charged_crystal) + TEST_ASSERT(!outpost_checkpoint_saves(crystal), "a checkpoint would save a charged crystal") + +/// Artifact healing shares one cap per person, whatever does the healing. +/datum/unit_test/voidcrew_xenoarch_heal_cap/Run() + var/mob/living/carbon/human/consistent/patient = allocate(/mob/living/carbon/human/consistent) + patient.take_overall_damage(60, 60) + var/healed = 0 + for(var/i in 1 to 6) + healed += artifact_capped_heal(patient, 12) + TEST_ASSERT(healed <= 30.5, "artifact healing went past the cap ([healed])") + TEST_ASSERT(healed >= 29.5, "artifact healing stopped short of the cap ([healed])") + TEST_ASSERT_EQUAL(artifact_capped_heal(patient, 50), 0, "a fresh call slipped past the cap") + +/// Deleting an artifact deletes its effects and leaves them no holder. +/datum/unit_test/voidcrew_xenoarch_cleanup/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/heal, /datum/artifact_effect/light, 1) + var/datum/artifact_effect/main = find.main_effect + var/datum/artifact_effect/second = find.second_effect + main.wake(1 MINUTES) + second.wake(1 MINUTES) + qdel(find) + TEST_ASSERT(QDELETED(main), "the main effect outlived its artifact") + TEST_ASSERT(QDELETED(second), "the second effect outlived its artifact") + TEST_ASSERT_NULL(main.holder, "the main effect kept its artifact") + +/** + * An artifact idling, or running heat and gas, on a planet never gives a planet turf private air. + * Uses the shared planet air room from voidcrew_planet_shared_air.dm. + */ +/datum/unit_test/voidcrew_planet_shared_air/xenoarch_idle_artifact/Run() + if(!planetary_atmos_shared_mix_enabled()) + return + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, center) + find.replace_effects(/datum/artifact_effect/temperature/heat, /datum/artifact_effect/gas, 3) + // Air triggers read the air every process. + find.main_effect.trigger = 128 + find.second_effect.trigger = 1024 + TEST_ASSERT(room_is_pristine(), "placing an artifact gave the planet private air") + for(var/i in 1 to 3) + find.process(2) + TEST_ASSERT(room_is_pristine(), "an idle artifact gave the planet private air") + find.main_effect.release_method = "aura" + find.second_effect.release_method = "aura" + find.main_effect.wake(1 MINUTES) + find.second_effect.wake(1 MINUTES) + for(var/i in 1 to 3) + find.process(2) + TEST_ASSERT(room_is_pristine(), "heat or gas running on a planet gave it private air") diff --git a/voidcrew/modules/xenoarch/core/artifact.dm b/voidcrew/modules/xenoarch/core/artifact.dm index c609d116946..02b38852dc4 100644 --- a/voidcrew/modules/xenoarch/core/artifact.dm +++ b/voidcrew/modules/xenoarch/core/artifact.dm @@ -1,15 +1,34 @@ /** * # Large alien artifact * - * A dense machine dug out of a planet's old dig sites. It carries a main effect and sometimes - * a minor second one, each with its own trigger. + * Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/artifacts/artifact_machine.dm, + * reworked for Voidcrew: + * - Effects roll by the band the find was dug in (tier odds and strength), and the find is + * stamped with that band, a catalogue serial, and later a crew's label. + * - A stimulus wakes a matching effect for a while (ARTIFACT_WAKE_MIN to _MAX); level triggers + * (heat, cold, plasma or CO2 in the air, someone nearby) hold it awake while they last. + * Oxygen and nitrogen triggers are gone. Air is read with return_air_readonly(), so an idle + * artifact never gives a planet turf its own private air. + * - It does nothing off a turf (crated, carried in a mech) or inside a trader outpost. + * - Anyone can bolt it down with a wrench, except inside a trader outpost. + * - Scan and harvest machines lock it through try_lock()/release_lock(); a lock frees itself + * when its holder is deleted or after ARTIFACT_LOCK_TIMEOUT (Nova's halt never unlocked it). + * - Smashing it lets harmful effects off in one last burst, never helpful ones, and an admin + * delete or planet unload does nothing at all. + * + * Looks, sounds and examine text are in artifact_appearance.dm. */ /obj/machinery/artifact name = "alien artifact" desc = "A large object of no make you recognise." + icon = 'voidcrew/modules/xenoarch/icons/artifacts.dmi' + icon_state = "pylon" density = TRUE anchored = FALSE use_power = NO_POWER_USE + // No UI and no power: a hand on it is a touch, nothing else. + interaction_flags_atom = NONE + interaction_flags_machine = INTERACT_MACHINE_OFFLINE max_integrity = 1000 resistance_flags = LAVA_PROOF | FIRE_PROOF | ACID_PROOF @@ -29,6 +48,77 @@ var/datum/artifact_effect/main_effect /// A minor second effect, or null var/datum/artifact_effect/second_effect + /// Rolls its own effects on Initialize. Finds that are not true artifacts turn this off. + var/rolls_effects = TRUE + + /// How long one contact stimulus keeps an effect awake; rolled once per artifact + var/wake_duration = ARTIFACT_WAKE_MIN + /// Whoever last woke, struck, splashed or hauled it. Logged for any harm it does. + var/datum/weakref/last_disturbed_by + /// Last time a touch counted, so hauling and bumping count once per ARTIFACT_TOUCH_COOLDOWN + var/last_touch_time = 0 + /// Effects are held asleep: it is off a turf or inside a trader outpost + var/suppressed = FALSE + + /// The scan or harvest machine using it, if any + var/datum/weakref/locked_by + /// world.time the lock lapses if never released + var/lock_expires = 0 + +/obj/machinery/artifact/Initialize(mapload, band) + . = ..() + serial = xenoarch_new_serial() + wake_duration = rand(ARTIFACT_WAKE_MIN, ARTIFACT_WAKE_MAX) + setup_shape() + if(rolls_effects) + roll_effects(band) + if(!isnull(band)) + stamp_origin(band) + suppressed = is_suppressed() + update_activity_visuals() + +/obj/machinery/artifact/Destroy() + locked_by = null + last_disturbed_by = null + clear_activity_visuals() + QDEL_NULL(main_effect) + QDEL_NULL(second_effect) + QDEL_NULL(label) + return ..() + +/// Both effects, skipping a missing second. +/obj/machinery/artifact/proc/effects() + . = list() + if(main_effect) + . += main_effect + if(second_effect) + . += second_effect + +/// Any effect awake. +/obj/machinery/artifact/proc/is_active() + return main_effect?.activated || second_effect?.activated + +// ===== Rolling ===== + +/// Rolls a main effect from the band's tier odds and, half the time, a minor second effect. +/obj/machinery/artifact/proc/roll_effects(band) + var/main_type = xenoarch_pick_effect_type(xenoarch_roll_tier(band), band) + var/second_type + if(main_type && prob(ARTIFACT_SECOND_EFFECT_CHANCE)) + second_type = xenoarch_pick_effect_type(null, band, minor_only = TRUE, exclude = main_type) + replace_effects(main_type, second_type, band) + +/// Swaps both effects for new ones of the given types (second may be null). For rolling, tests and admins. +/obj/machinery/artifact/proc/replace_effects(main_type, second_type, band) + QDEL_NULL(main_effect) + QDEL_NULL(second_effect) + if(main_type) + main_effect = new main_type(src, band) + if(second_type) + second_effect = new second_type(src, band) + update_activity_visuals(force = TRUE) + +// ===== Seams read by other parts ===== /// Whether it came out of a dig site. Buyers refuse anything else. /obj/machinery/artifact/proc/is_dug() @@ -75,3 +165,336 @@ origin_band = XENOARCH_BAND_INDEX(band) SEND_SIGNAL(src, COMSIG_ARTIFACT_STAMPED, origin_band) return TRUE + +// ===== Scan and harvest lock ===== + +/** + * Claims it for a scan or harvest. Fails while another live machine holds it. The lock frees + * itself when its holder is deleted or after `duration`, so a crashed or halted scan can never + * lock an artifact for good. + */ +/obj/machinery/artifact/proc/try_lock(datum/locker, duration = ARTIFACT_LOCK_TIMEOUT) + if(!locker) + return FALSE + if(is_being_used() && locked_by.resolve() != locker) + return FALSE + locked_by = WEAKREF(locker) + lock_expires = world.time + duration + return TRUE + +/// Frees the lock. With a `locker`, only if that is who holds it. +/obj/machinery/artifact/proc/release_lock(datum/locker) + if(!locked_by) + return FALSE + var/datum/holder = locked_by.resolve() + if(locker && holder && holder != locker) + return FALSE + locked_by = null + lock_expires = 0 + return TRUE + +/// Whether a live machine holds the lock (Nova's being_used). +/obj/machinery/artifact/proc/is_being_used() + if(!locked_by) + return FALSE + var/datum/holder = locked_by.resolve() + if(QDELETED(holder) || world.time >= lock_expires) + locked_by = null + lock_expires = 0 + return FALSE + return TRUE + +// ===== Stimuli ===== + +/// Remembers who set it off, for the combat log. +/obj/machinery/artifact/proc/note_disturbance(mob/user) + if(ismob(user)) + last_disturbed_by = WEAKREF(user) + +/** + * A stimulus reached it. Wakes every effect whose trigger matches. + * Returns TRUE if anything matched. + */ +/obj/machinery/artifact/proc/stimulate(trigger, mob/user) + if(suppressed || QDELETED(src)) + return FALSE + note_disturbance(user) + var/woke = FALSE + for(var/datum/artifact_effect/effect as anything in effects()) + if(effect.trigger == trigger) + effect.wake(wake_duration) + woke = TRUE + SEND_SIGNAL(src, COMSIG_ARTIFACT_STIMULATED, trigger, user, woke) + return woke + +/// Wakes every effect a bitfield of triggers matches. +/obj/machinery/artifact/proc/stimulate_all(triggers, mob/user) + . = FALSE + for(var/trigger in ARTIFACT_ALL_TRIGGERS) + if(triggers & trigger) + . = stimulate(trigger, user) || . + +/** + * Someone laid a hand on it, or brushed it (bumped, hauled). A bare or non-latex hand wakes + * touch effects; any touch lets an awake contact effect act on them. + */ +/obj/machinery/artifact/proc/touched_by(mob/living/user, accidental = FALSE) + if(!isliving(user)) + return + if(accidental && world.time < last_touch_time + ARTIFACT_TOUCH_COOLDOWN) + return + last_touch_time = world.time + if(!accidental) + to_chat(user, span_notice("You run your hand over [src].")) + if(artifact_touch_counts(user)) + stimulate(ARTIFACT_TRIGGER_TOUCH, user) + else + note_disturbance(user) + if(suppressed) + return + for(var/datum/artifact_effect/effect as anything in effects()) + if(accidental && prob(50)) + continue + effect.touch(user) + +/obj/machinery/artifact/attack_hand(mob/living/user, list/modifiers) + . = ..() + if(. || !user.Adjacent(src)) + return + touched_by(user) + return TRUE + +/obj/machinery/artifact/attack_robot(mob/user) + if(!user.Adjacent(src)) + return ..() + touched_by(user) + return TRUE + +/obj/machinery/artifact/attack_paw(mob/living/user, list/modifiers) + if(!user.Adjacent(src)) + return ..() + touched_by(user) + return TRUE + +/obj/machinery/artifact/Bumped(atom/movable/bumped_atom) + . = ..() + if(isliving(bumped_atom)) + touched_by(bumped_atom, accidental = TRUE) + +/obj/machinery/artifact/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) + . = ..() + refresh_suppression() + // Hauling it counts as touching it (Nova did this through Move() and Bumped()). + if(isliving(pulledby)) + touched_by(pulledby, accidental = TRUE) + +/obj/machinery/artifact/attacked_by(obj/item/attacking_item, mob/living/user, list/modifiers, list/attack_modifiers) + note_disturbance(user) + . = ..() + if(QDELETED(src)) + return + if(attacking_item.force > 0) + stimulate(ARTIFACT_TRIGGER_IMPACT, user) + if(artifact_tool_is_energetic(attacking_item)) + stimulate(ARTIFACT_TRIGGER_ENERGY, user) + if(attacking_item.get_temperature() > ARTIFACT_HEAT_TOOL_KELVIN) + stimulate(ARTIFACT_TRIGGER_HEAT, user) + +/obj/machinery/artifact/hitby(atom/movable/hit_by, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum) + var/mob/thrower = throwingdatum?.get_thrower() + note_disturbance(thrower) + . = ..() + if(QDELETED(src)) + return + var/hard_enough = isliving(hit_by) + if(isobj(hit_by)) + var/obj/thrown_object = hit_by + hard_enough = thrown_object.throwforce >= ARTIFACT_IMPACT_THROWFORCE + if(hard_enough) + stimulate(ARTIFACT_TRIGGER_IMPACT, thrower) + +/obj/machinery/artifact/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit = FALSE) + var/mob/firer = hitting_projectile.firer + note_disturbance(firer) + . = ..() + if(QDELETED(src)) + return + if(hitting_projectile.armor_flag == LASER || hitting_projectile.armor_flag == ENERGY) + stimulate(ARTIFACT_TRIGGER_ENERGY, firer) + else if(hitting_projectile.damage > 0) + stimulate(ARTIFACT_TRIGGER_IMPACT, firer) + +/obj/machinery/artifact/take_damage(damage_amount, damage_type = BRUTE, damage_flag = "", sound_effect = TRUE, attack_dir, armour_penetration = 0) + . = ..() + if(QDELETED(src)) + return + // Hits with a known culprit are handled where they land; these are fires, blasts and arcs. + switch(damage_flag) + if(FIRE) + stimulate(ARTIFACT_TRIGGER_HEAT) + if(ENERGY, LASER) + stimulate(ARTIFACT_TRIGGER_ENERGY) + if(BOMB) + stimulate(ARTIFACT_TRIGGER_IMPACT) + stimulate(ARTIFACT_TRIGGER_HEAT) + +/obj/machinery/artifact/emp_act(severity) + . = ..() + if(!(. & EMP_PROTECT_SELF)) + stimulate(ARTIFACT_TRIGGER_ENERGY) + +/obj/machinery/artifact/fire_act(exposed_temperature, exposed_volume) + . = ..() + if(exposed_temperature > ARTIFACT_HEAT_AIR_KELVIN) + stimulate(ARTIFACT_TRIGGER_HEAT) + +/obj/machinery/artifact/expose_reagents(list/reagents, datum/reagents/source, methods = TOUCH, volume_modifier = 1, show_message = TRUE) + . = ..() + if(. & COMPONENT_NO_EXPOSE_REAGENTS) + return + stimulate_all(artifact_reagent_triggers(reagents)) + +/obj/machinery/artifact/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(is_reagent_container(tool) && tool.is_drainable()) + return splash_with(tool, user) + if(artifact_tool_is_energetic(tool)) + user.visible_message( + span_notice("[user] presses [tool] against [src]."), + span_notice("You press [tool] against [src]."), + ) + playsound(src, 'sound/effects/sparks/sparks1.ogg', 40, TRUE) + stimulate(ARTIFACT_TRIGGER_ENERGY, user) + if(tool.get_temperature() > ARTIFACT_HEAT_TOOL_KELVIN) + stimulate(ARTIFACT_TRIGGER_HEAT, user) + return ITEM_INTERACT_SUCCESS + if(tool.get_temperature() > ARTIFACT_HEAT_TOOL_KELVIN) + return heat_with(tool, user) + return NONE + +/obj/machinery/artifact/welder_act(mob/living/user, obj/item/tool) + if(tool.get_temperature() <= ARTIFACT_HEAT_TOOL_KELVIN) + return NONE + return heat_with(tool, user) + +/// Holds a hot tool to it. +/obj/machinery/artifact/proc/heat_with(obj/item/tool, mob/living/user) + user.visible_message( + span_notice("[user] holds [tool] to [src]."), + span_notice("You hold [tool] to [src] until the surface ticks with heat."), + ) + playsound(src, 'sound/items/tools/welder.ogg', 30, TRUE) + stimulate(ARTIFACT_TRIGGER_HEAT, user) + return ITEM_INTERACT_SUCCESS + +/// Splashes a little of an open container over it. +/obj/machinery/artifact/proc/splash_with(obj/item/container, mob/living/user) + var/datum/reagents/held = container.reagents + if(!held?.total_volume) + balloon_alert(user, "empty!") + return ITEM_INTERACT_BLOCKING + note_disturbance(user) + var/amount = min(held.total_volume, 10) + user.visible_message( + span_notice("[user] splashes [src] with the contents of [container]."), + span_notice("You splash [src] with [container]."), + ) + playsound(src, 'sound/effects/slosh.ogg', 25, TRUE) + held.expose(src, TOUCH, amount / held.total_volume) + held.remove_all(amount) + return ITEM_INTERACT_SUCCESS + +/obj/machinery/artifact/wrench_act(mob/living/user, obj/item/tool) + if(istype(get_area(src), /area/voidcrew/trader_outpost)) + balloon_alert(user, "the deck won't take bolts!") + return ITEM_INTERACT_BLOCKING + if(default_unfasten_wrench(user, tool, 4 SECONDS) == SUCCESSFUL_UNFASTEN) + playsound(src, 'sound/machines/clockcult/integration_cog_install.ogg', 30, TRUE) + return ITEM_INTERACT_SUCCESS + +/// Whether a tool counts as electrical contact: a live stun baton or a lit energy blade. +/proc/artifact_tool_is_energetic(obj/item/tool) + if(istype(tool, /obj/item/melee/baton/security)) + var/obj/item/melee/baton/security/baton = tool + return baton.active + if(istype(tool, /obj/item/melee/energy)) + return HAS_TRAIT(tool, TRAIT_TRANSFORM_ACTIVE) + return FALSE + +// ===== Processing ===== + +/obj/machinery/artifact/process(seconds_per_tick) + for(var/datum/artifact_effect/effect as anything in effects()) + effect.recharge(seconds_per_tick) + if(refresh_suppression()) + return + check_level_triggers() + for(var/datum/artifact_effect/effect as anything in effects()) + effect.tick(seconds_per_tick) + +/// Off a turf, or inside a trader outpost, it does nothing at all. +/obj/machinery/artifact/proc/is_suppressed() + return !isturf(loc) || is_trader_outpost_protected(src) + +/// Re-reads suppression; puts everything to sleep when it starts. Returns TRUE while suppressed. +/obj/machinery/artifact/proc/refresh_suppression() + var/now_suppressed = is_suppressed() + if(now_suppressed == suppressed) + return suppressed + suppressed = now_suppressed + if(suppressed) + // A crate lid or an outpost's dampers: it goes still without a show. + for(var/datum/artifact_effect/effect as anything in effects()) + effect.deactivate(quiet = !isturf(loc)) + update_activity_visuals() + return suppressed + +/** + * Air and proximity triggers. Reads the tile's air without materializing it: a planet turf + * still on its shared mix stays on it. + */ +/obj/machinery/artifact/proc/check_level_triggers() + var/wanted = NONE + for(var/datum/artifact_effect/effect as anything in effects()) + if(effect.trigger & ARTIFACT_TRIGGERS_LEVEL) + wanted |= effect.trigger + if(!wanted) + return + var/met = NONE + if(wanted & ARTIFACT_TRIGGERS_AIR) + var/turf/here = get_turf(src) + var/datum/gas_mixture/air = here?.return_air_readonly() + if(air) + if(air.temperature > ARTIFACT_HEAT_AIR_KELVIN) + met |= ARTIFACT_TRIGGER_HEAT + if(air.temperature < ARTIFACT_COLD_AIR_KELVIN) + met |= ARTIFACT_TRIGGER_COLD + var/list/gases = air.gases + if(gases[/datum/gas/plasma]?[MOLES] >= ARTIFACT_GAS_TRIGGER_MOLES) + met |= ARTIFACT_TRIGGER_PLASMA + if(gases[/datum/gas/carbon_dioxide]?[MOLES] >= ARTIFACT_GAS_TRIGGER_MOLES) + met |= ARTIFACT_TRIGGER_CO2 + if(wanted & ARTIFACT_TRIGGER_PROXIMITY) + for(var/mob/living/nearby in view(ARTIFACT_PROXIMITY_RANGE, src)) + if(nearby.stat != DEAD) + met |= ARTIFACT_TRIGGER_PROXIMITY + break + if(!met) + return + for(var/datum/artifact_effect/effect as anything in effects()) + if(effect.trigger & met) + effect.wake(ARTIFACT_LEVEL_LINGER) + +// ===== Destruction ===== + +/obj/machinery/artifact/atom_destruction(damage_flag) + var/mob/culprit = last_disturbed_by?.resolve() + visible_message( + span_danger("[src] cracks apart with a sound like a bell breaking!"), + blind_message = span_hear("You hear something ring and shatter."), + ) + playsound(src, 'sound/effects/glass/glassbr3.ogg', 70, TRUE) + if(!suppressed) + log_game("Artifact [serial] ([main_effect?.log_name]) was smashed at [AREACOORD(src)][culprit ? " after [key_name(culprit)] disturbed it" : ""].") + for(var/datum/artifact_effect/effect as anything in effects()) + effect.do_effect_destroy() + return ..() diff --git a/voidcrew/modules/xenoarch/core/artifact_appearance.dm b/voidcrew/modules/xenoarch/core/artifact_appearance.dm new file mode 100644 index 00000000000..6f578ebe3a5 --- /dev/null +++ b/voidcrew/modules/xenoarch/core/artifact_appearance.dm @@ -0,0 +1,389 @@ +/** + * # Artifact looks, sounds and examine text + * + * Shapes come from icons/artifacts.dmi, assembled from clean sources only (CC BY-SA 3.0): + * NovaSector 5ce2bd2215c0 artifacts.dmi states 7-13 (pylon, terminal, vents, growth, three + * crystals), Polaris 6cd19fe0dec6 xenoarchaeology.dmi ano10/70/80/120/130/140/150 (torus, + * monolith, spire, idol, cradle, effigy, spindle), and Aurora's crystal_madness (shard; its + * active frames were drawn for Voidcrew). No Goon art: Nova artifact_1-6 and Bay/Polaris + * ano00/20/30/40/50 are Goon copies and are not used. + * + * While it sleeps an artifact breathes a faint glow in its energy kind's colour. Awake, it plays + * its shape's active animation, glows brighter, sheds particles, lights the room a little and + * hums. Waking, falling asleep and each burst it releases have their own small moment. + */ + +/// Shape key -> list("name", "descs", "tag" = list(pixel_x, pixel_y) for the label sticker) +GLOBAL_LIST_INIT(artifact_shapes, list( + "pylon" = list( + "name" = "alien pylon", + "descs" = list( + "A grey orb held above a slim stand by nothing you can see.", + "A metal stand topped with a perfectly smooth grey sphere.", + ), + "tag" = list(15, -22), + ), + "terminal" = list( + "name" = "alien terminal", + "descs" = list( + "A dark glass screen in a heavy frame, lettered in a script nobody reads.", + "It looks like a console. The keys are the wrong shape for any hand you know of.", + ), + "tag" = list(22, -22), + ), + "vents" = list( + "name" = "vented casing", + "descs" = list( + "A heavy grey casing, louvred down one side.", + "A squat metal housing with vents along its flank. Nothing comes out of them.", + ), + "tag" = list(23, -22), + ), + "growth" = list( + "name" = "fronded mass", + "descs" = list( + "A tangle of hard green fronds around a single lidded eye.", + "Green fronds, like metal grown as a plant, curl around a closed eye.", + ), + "tag" = list(21, -21), + ), + "crystal_green" = list( + "name" = "large crystal", + "descs" = list( + "A green crystal the size of a dog. It shines faintly as it catches the light.", + "A green crystal with a faint glow somewhere deep inside.", + ), + "tag" = list(17, -21), + ), + "crystal_violet" = list( + "name" = "large crystal", + "descs" = list( + "A violet crystal the size of a dog. Something twinkles deep inside it.", + "A violet crystal, cold and heavy, with a faint inner glow.", + ), + "tag" = list(17, -21), + ), + "crystal_blue" = list( + "name" = "large crystal", + "descs" = list( + "A blue crystal the size of a dog. It shines faintly as it catches the light.", + "A blue crystal, clear near the edges and cloudy at the heart.", + ), + "tag" = list(17, -21), + ), + "torus" = list( + "name" = "black torus", + "descs" = list( + "A ring of black stone, cold and smooth. The hole looks deeper than the ring is thick.", + "A small black ring, far heavier than it has any right to be.", + ), + "tag" = list(15, -14), + ), + "monolith" = list( + "name" = "green monolith", + "descs" = list( + "A leaning slab of green stone, striped with darker veins.", + "A green slab with grooves down its face, too regular to be weathering.", + ), + "tag" = list(20, -23), + ), + "spire" = list( + "name" = "violet spire", + "descs" = list( + "A twisted violet spire, ridged like horn.", + "A curled violet spike. The ridges on it are warm to the touch.", + ), + "tag" = list(22, -23), + ), + "idol" = list( + "name" = "sandstone idol", + "descs" = list( + "A weathered figure with its arms raised. Its face has been worn away.", + "A sandstone figure holding up two empty hands.", + ), + "tag" = list(17, -17), + ), + "cradle" = list( + "name" = "black cradle", + "descs" = list( + "A forked pedestal of black metal, shaped to hold something that isn't there.", + "Two black prongs rising from a heavy base. Whatever they held is gone.", + ), + "tag" = list(14, -22), + ), + "effigy" = list( + "name" = "pale effigy", + "descs" = list( + "A smooth white figure the height of a child. It has no mouth.", + "A pale figure standing very straight. Its eyes are two dark beads.", + ), + "tag" = list(16, -23), + ), + "spindle" = list( + "name" = "red spindle", + "descs" = list( + "A red crystal turning slowly in place, touching nothing.", + "A spindle of red crystal that hangs a hand's width off the ground and turns.", + ), + "tag" = list(14, -19), + ), + "shard" = list( + "name" = "pale shard", + "descs" = list( + "A cluster of pale blue crystal growing out of a dark stone.", + "Pale blue crystals jut from a lump of black rock like broken glass.", + ), + "tag" = list(16, -23), + ), +)) + +/// Close-up details; each artifact keeps two. +GLOBAL_LIST_INIT(artifact_examine_notes, list( + "It is heavier than it looks.", + "There are no seams, bolts or tool marks anywhere on it.", + "It is a few degrees warmer than the air around it.", + "Grit from the dig is still packed into its crevices.", + "Up close, the surface has a fine grain, like fingerprints.", + "It doesn't ring when tapped. It doesn't make any sound at all.", + "Dust doesn't seem to settle on it.", + "Your reflection in it is a moment late.", +)) + +/// Lines for falling asleep: "[artifact] [line]" +#define ARTIFACT_SLEEP_LINES list("grows dull.", "fades.", "goes very still.", "falls quiet.") + +/// Glow levels, faintest first. +#define ARTIFACT_GLOW_NONE 0 +#define ARTIFACT_GLOW_IDLE 1 +#define ARTIFACT_GLOW_RESTING 2 +#define ARTIFACT_GLOW_AWAKE 3 + +/obj/machinery/artifact + /// GLOB.artifact_shapes key. Set on a subtype or map to fix the shape; random otherwise. + var/shape + /// Two close-up details for examine_more + var/list/examine_notes + /// Glow level and colour now showing, so the filter is only rebuilt when they change + var/glow_level = ARTIFACT_GLOW_NONE + var/glow_color + /// Shared particle type now attached + var/particles_shown + /// Hum while awake + var/datum/looping_sound/hum + /// Shown on the last visual refresh: awake at all + var/shown_awake = FALSE + +/// Picks a shape if none is set and takes its name, description and icon. +/obj/machinery/artifact/proc/setup_shape() + if(!GLOB.artifact_shapes[shape]) + shape = pick(GLOB.artifact_shapes) + var/list/shape_data = GLOB.artifact_shapes[shape] + name = shape_data["name"] + desc = pick(shape_data["descs"]) + var/list/notes = GLOB.artifact_examine_notes.Copy() + examine_notes = list() + for(var/i in 1 to 2) + examine_notes += pick_n_take(notes) + update_appearance() + +/obj/machinery/artifact/update_icon_state() + icon_state = "[shape][shown_awake ? "_active" : ""]" + return ..() + +/obj/machinery/artifact/update_overlays() + . = ..() + if(!label) + return + var/list/tag_offset = GLOB.artifact_shapes[shape]?["tag"] || list(16, -22) + var/mutable_appearance/sticker = mutable_appearance(icon, "label_tag") + sticker.pixel_x = tag_offset[1] + sticker.pixel_y = tag_offset[2] + . += sticker + +/obj/machinery/artifact/examine(mob/user) + . = ..() + if(is_dug()) + . += "A field tag wired to it reads [serial]." + if(label) + . += label.examine_text() + if(damaged) + . += span_warning("Cracks run through it where it came out of the rock badly.") + if(anchored) + . += "It is bolted to the deck." + if(!shown_awake) + return + var/datum/artifact_energy_kind/kind = visual_kind() + if(kind) + . += span_notice(pick(kind.awake_examine)) + if(all_awake_resting()) + . += "Its glow gutters, as if gathering itself." + +/obj/machinery/artifact/examine_more(mob/user) + . = ..() + . += examine_notes + +/// The kind that sets its look: the main effect's, or the second's if it has no main. +/obj/machinery/artifact/proc/visual_kind() + var/datum/artifact_effect/lead = main_effect || second_effect + return lead ? artifact_energy_kind(lead.energy_kind) : null + +/// Every awake effect is an aura resting between runs. +/obj/machinery/artifact/proc/all_awake_resting() + var/any_awake = FALSE + for(var/datum/artifact_effect/effect as anything in effects()) + if(!effect.activated) + continue + any_awake = TRUE + if(!effect.exhausted) + return FALSE + return any_awake + +// ===== Moments ===== + +/// An effect woke. The first one to wake brings the whole artifact to life. +/obj/machinery/artifact/proc/effect_woke(datum/artifact_effect/effect) + SEND_SIGNAL(src, COMSIG_ARTIFACT_EFFECT_ACTIVATED, effect) + if(!shown_awake && !QDELETED(src)) + var/datum/artifact_energy_kind/kind = visual_kind() + if(kind) + visible_message(span_warning(kind.wake_line(src))) + playsound(src, kind.wake_sound, 50, TRUE) + throb(1.12) + update_activity_visuals() + +/// An effect went to sleep. When the last one sleeps, so does the artifact. +/obj/machinery/artifact/proc/effect_slept(datum/artifact_effect/effect, quiet = FALSE) + SEND_SIGNAL(src, COMSIG_ARTIFACT_EFFECT_DEACTIVATED, effect) + if(QDELETED(src)) + return + if(shown_awake && !is_active() && !quiet) + visible_message(span_notice("[src] [pick(ARTIFACT_SLEEP_LINES)]")) + playsound(src, 'sound/effects/stealthoff.ogg', 40, TRUE) + update_activity_visuals() + +/// An effect let off a burst. +/obj/machinery/artifact/proc/effect_pulsed(datum/artifact_effect/effect) + var/datum/artifact_energy_kind/kind = artifact_energy_kind(effect.energy_kind) + playsound(src, kind.pulse_sound, 45, TRUE) + throb(1.18) + var/old_level = glow_level + set_glow(ARTIFACT_GLOW_AWAKE, kind.color, flash = TRUE) + glow_level = old_level + +/// A quick swell and settle. +/obj/machinery/artifact/proc/throb(scale) + var/matrix/swell = matrix() + swell.Scale(scale) + animate(src, transform = swell, time = 0.15 SECONDS, easing = SINE_EASING | EASE_OUT) + animate(transform = matrix(), time = 0.4 SECONDS, easing = SINE_EASING | EASE_IN) + +// ===== Glow, light, particles, hum ===== + +/** + * Brings icon, glow, light, particles and hum in line with what the effects are doing. + * Cheap when nothing changed; `force` rebuilds everything (after effects were replaced). + */ +/obj/machinery/artifact/proc/update_activity_visuals(force = FALSE) + if(QDELETED(src)) + return + var/datum/artifact_energy_kind/kind = visual_kind() + var/awake = is_active() && !suppressed + var/resting = awake && all_awake_resting() + if(awake != shown_awake || force) + shown_awake = awake + update_appearance(UPDATE_ICON_STATE) + + var/wanted_glow = ARTIFACT_GLOW_NONE + if(kind && isturf(loc)) + if(!awake) + wanted_glow = ARTIFACT_GLOW_IDLE + else + wanted_glow = resting ? ARTIFACT_GLOW_RESTING : ARTIFACT_GLOW_AWAKE + set_glow(wanted_glow, kind?.color, force = force) + + var/wanted_particles = (awake && !resting) ? kind?.particle_type : null + if(wanted_particles != particles_shown || force) + if(particles_shown) + remove_shared_particles(particles_shown) + particles_shown = wanted_particles + if(particles_shown) + add_shared_particles(particles_shown) + + update_artifact_light(awake, resting, kind) + + if(awake) + if(force && hum) + QDEL_NULL(hum) + if(!hum && kind?.hum_type) + hum = new kind.hum_type(src) + hum?.start() + else + hum?.stop() + +/// Light: an awake light or darkness effect sets it; otherwise a small glow while awake. +/obj/machinery/artifact/proc/update_artifact_light(awake, resting, datum/artifact_energy_kind/kind) + if(awake) + for(var/datum/artifact_effect/effect as anything in effects()) + if(!effect.activated) + continue + var/list/override = effect.light_override() + if(override) + set_light(override[1], override[2], override[3]) + return + if(awake && kind) + set_light(2, resting ? 0.4 : 0.9, kind.color) + else + set_light(0) + +/// Sets the drop-shadow glow and starts it breathing. `flash` spikes it once, then settles. +/obj/machinery/artifact/proc/set_glow(level, color, force = FALSE, flash = FALSE) + if(!flash && !force && level == glow_level && color == glow_color) + return + glow_level = level + glow_color = color + if(level == ARTIFACT_GLOW_NONE || !color) + remove_filter("artifact_glow") + return + var/low_alpha + var/high_alpha + var/size + var/period + switch(level) + if(ARTIFACT_GLOW_AWAKE) + low_alpha = "70" + high_alpha = "c8" + size = 2.5 + period = 1 SECONDS + if(ARTIFACT_GLOW_RESTING) + low_alpha = "30" + high_alpha = "60" + size = 1.5 + period = 2 SECONDS + else + low_alpha = "14" + high_alpha = "3c" + size = 1 + period = 3 SECONDS + if(flash) + add_filter("artifact_glow", 2, drop_shadow_filter(0, 0, 4, 0, "[color]ff")) + else + add_filter("artifact_glow", 2, drop_shadow_filter(0, 0, size, 0, "[color][low_alpha]")) + transition_filter_chain("artifact_glow", -1, \ + FilterChainStep(list("color" = "[color][high_alpha]", "size" = size), period, SINE_EASING), \ + FilterChainStep(list("color" = "[color][low_alpha]", "size" = size), period, SINE_EASING)) + +/// Strips glow, particles, light and hum (deletion). +/obj/machinery/artifact/proc/clear_activity_visuals() + if(particles_shown) + remove_shared_particles(particles_shown) + particles_shown = null + remove_filter("artifact_glow") + glow_level = ARTIFACT_GLOW_NONE + QDEL_NULL(hum) + set_light(0) + +#undef ARTIFACT_SLEEP_LINES +#undef ARTIFACT_GLOW_NONE +#undef ARTIFACT_GLOW_IDLE +#undef ARTIFACT_GLOW_RESTING +#undef ARTIFACT_GLOW_AWAKE diff --git a/voidcrew/modules/xenoarch/core/artifact_effect.dm b/voidcrew/modules/xenoarch/core/artifact_effect.dm index d838ca53fa6..b9531404a84 100644 --- a/voidcrew/modules/xenoarch/core/artifact_effect.dm +++ b/voidcrew/modules/xenoarch/core/artifact_effect.dm @@ -1,8 +1,21 @@ /** * # Artifact effect * - * What an artifact does. A rollable effect is any subtype that sets label_name and tier; - * parents that only share code leave label_name null and never roll. + * Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/artifacts/effect.dm, + * reworked for Voidcrew: + * - Tiers, band-weighted rolls, a label name and harvest flag drive the catalogue. + * - Charge is per second. Auras spend faster than the store refills, so they rest about two + * thirds of the time; a pulse fires when the store is full. The store refills while asleep, + * so a freshly woken artifact acts at once. + * - A stimulus wakes an effect for a while instead of toggling it; level triggers (air and + * proximity) hold it awake while their condition lasts. + * - Harmful effects log like a weapon. Helpful effects never burst when smashed. + * + * Whatever holds an effect (an artifact, or a battery once harvested) calls tick() every + * process and touch() when touched. Subtypes implement do_effect_touch/aura/pulse. + * + * A rollable effect is any subtype that sets label_name. Parents that only share code leave it + * null and never roll. Adding an effect is adding a subtype: nothing else to register. */ /datum/artifact_effect /// The plain words a labeler offers for it, such as "Heals". Null on abstract parents. @@ -15,11 +28,398 @@ var/harvestable = TRUE /// Can roll as an artifact's second effect (common and uncommon effects only) var/minor = FALSE - /// The trigger that wakes it (one ARTIFACT_TRIGGER_* flag) - var/trigger = ARTIFACT_TRIGGER_TOUCH + /// Relative weight against other effects of its tier + var/weight = 10 + /// Weight multipliers by stamped band + var/green_weight = 1 + var/yellow_weight = 1 + var/red_weight = 1 + /// Logged as a weapon when it lands on someone + var/harmful = FALSE + /// Never fires a last burst when its artifact is smashed + var/helpful = FALSE + + /// ARTIFACT_ENERGY_* kinds it can present as; one is picked + var/list/possible_kinds = list(ARTIFACT_ENERGY_CONCENTRATED) + /// ARTIFACT_ENERGY_*: what the analyser reads off it, and how its artifact looks + var/energy_kind = ARTIFACT_ENERGY_CONCENTRATED + /// ARTIFACT_RELEASE_* it can roll + var/list/allowed_release_methods = list(ARTIFACT_RELEASE_TOUCH, ARTIFACT_RELEASE_AURA, ARTIFACT_RELEASE_PULSE) /// ARTIFACT_RELEASE_* var/release_method = ARTIFACT_RELEASE_TOUCH - /// ARTIFACT_ENERGY_*: what the analyser reads off it - var/energy_kind = ARTIFACT_ENERGY_CONCENTRATED + /// ARTIFACT_TRIGGER_* it can roll; null for any + var/list/allowed_triggers + /// The trigger that wakes it (one ARTIFACT_TRIGGER_* flag) + var/trigger = ARTIFACT_TRIGGER_TOUCH + + /// ARTIFACT_STRENGTH_* + var/strength = ARTIFACT_STRENGTH_SMALL + /// Tiles its aura and pulses reach + var/range = 3 + /// Size of its charge store; a pulse spends all of it + var/maximum_charges = 10 + /// Charge in store + var/current_charge = 0 + /// Charge one touch spends + var/touch_cost = ARTIFACT_TOUCH_COST + + /// Awake and releasing + var/activated = FALSE + /// An aura that ran its store dry and is resting until full + var/exhausted = FALSE + /// world.time it falls asleep unless woken again + var/awake_until = 0 + /// Whatever holds it: an artifact, or a battery once harvested var/atom/holder + /// Who answers for it when it hurts someone, if not its artifact's last disturber + var/datum/weakref/responsible_ref + /// REF(victim) -> world.time last logged, so an aura logs each person twice a minute at most + var/list/last_logged + +/datum/artifact_effect/New(atom/location, band) + . = ..() + holder = location + roll_traits(band) + setup() + current_charge = maximum_charges + +/datum/artifact_effect/Destroy(force) + if(activated) + activated = FALSE + on_deactivate() + holder = null + responsible_ref = null + last_logged = null + return ..() + +/// Rolls energy kind, release method, trigger and strength. +/datum/artifact_effect/proc/roll_traits(band) + energy_kind = pick(possible_kinds) + release_method = pick(allowed_release_methods) + trigger = roll_trigger() + roll_strength(band) + +/datum/artifact_effect/proc/roll_trigger() + var/list/candidates = allowed_triggers || ARTIFACT_ALL_TRIGGERS + var/list/weights = list() + for(var/candidate in candidates) + weights += artifact_trigger_weight(candidate) + var/index = xenoarch_pick_weighted_index(weights) + return index ? candidates[index] : ARTIFACT_TRIGGER_TOUCH + +/// Picks small, medium or large by band (green leans small, red leans large). +/datum/artifact_effect/proc/roll_strength(band) + var/list/odds + switch(XENOARCH_BAND_INDEX(band)) + if(ZONE_RED) + odds = ARTIFACT_STRENGTH_ODDS_RED + if(ZONE_YELLOW) + odds = ARTIFACT_STRENGTH_ODDS_YELLOW + else + odds = ARTIFACT_STRENGTH_ODDS_GREEN + switch(xenoarch_pick_weighted_index(odds)) + if(3) + set_strength(ARTIFACT_STRENGTH_LARGE) + if(2) + set_strength(ARTIFACT_STRENGTH_MEDIUM) + else + set_strength(ARTIFACT_STRENGTH_SMALL) + +/// Nova's charge and range bands for each strength, range capped at 8. +/datum/artifact_effect/proc/set_strength(new_strength) + strength = new_strength + switch(strength) + if(ARTIFACT_STRENGTH_LARGE) + maximum_charges = rand(20, 50) + range = rand(6, 8) + if(ARTIFACT_STRENGTH_MEDIUM) + maximum_charges = rand(15, 30) + range = rand(4, 6) + else + maximum_charges = rand(5, 20) + range = rand(2, 4) + current_charge = min(current_charge, maximum_charges) + +/// Subtype setup after the roll: fix a release method, pick a gas, and so on. +/datum/artifact_effect/proc/setup() + return + +// ===== Waking and sleeping ===== + +/// Keeps it awake for at least `duration` more, waking it if it slept. +/datum/artifact_effect/proc/wake(duration) + awake_until = max(awake_until, world.time + duration) + if(!activated) + activate() + +/datum/artifact_effect/proc/activate() + if(activated) + return + activated = TRUE + exhausted = FALSE + on_activate() + var/obj/machinery/artifact/artifact = holder + if(istype(artifact)) + artifact.effect_woke(src) + +/// Puts it to sleep. `quiet` skips its artifact's sleep moment (used when it is crated or deleted). +/datum/artifact_effect/proc/deactivate(quiet = FALSE) + if(!activated) + return + activated = FALSE + exhausted = FALSE + awake_until = 0 + on_deactivate() + var/obj/machinery/artifact/artifact = holder + if(istype(artifact)) + artifact.effect_slept(src, quiet) + +/// Hook: it just woke. +/datum/artifact_effect/proc/on_activate() + return + +/// Hook: it just went to sleep. +/datum/artifact_effect/proc/on_deactivate() + return + +/// The light it gives off while awake as list(range, power, colour), or null to leave the +/// artifact's own glow alone. Light and darkness effects override this. +/datum/artifact_effect/proc/light_override() + return null + +// ===== Releasing ===== + +/// Refills the store. Called every process, awake or not. +/datum/artifact_effect/proc/recharge(seconds_per_tick) + current_charge = min(maximum_charges, current_charge + ARTIFACT_RECHARGE_PER_SECOND * seconds_per_tick) + +/// Called by the holder every process: lets an expired wake lapse, then releases an aura or pulse. +/datum/artifact_effect/proc/tick(seconds_per_tick) + if(!activated) + return + if(world.time >= awake_until) + deactivate() + return + switch(release_method) + if(ARTIFACT_RELEASE_AURA) + release_aura(seconds_per_tick) + if(ARTIFACT_RELEASE_PULSE) + release_pulse() + +/datum/artifact_effect/proc/release_aura(seconds_per_tick) + var/cost = ARTIFACT_AURA_COST_PER_SECOND * seconds_per_tick + if(exhausted) + if(current_charge < maximum_charges) + return + set_exhausted(FALSE) + if(current_charge < cost) + set_exhausted(TRUE) + return + current_charge -= cost + do_effect_aura(seconds_per_tick) + +/datum/artifact_effect/proc/release_pulse() + if(current_charge < maximum_charges) + return + current_charge = 0 + var/obj/machinery/artifact/artifact = holder + if(istype(artifact)) + artifact.effect_pulsed(src) + do_effect_pulse(maximum_charges) + +/datum/artifact_effect/proc/set_exhausted(new_value) + if(exhausted == new_value) + return + exhausted = new_value + var/obj/machinery/artifact/artifact = holder + if(istype(artifact)) + artifact.update_activity_visuals() + +/// Someone touched its holder. Returns TRUE if it acted on them. +/datum/artifact_effect/proc/touch(mob/living/user) + if(!activated || release_method != ARTIFACT_RELEASE_TOUCH || !isliving(user)) + return FALSE + if(current_charge < touch_cost) + return FALSE + current_charge -= touch_cost + do_effect_touch(user) + return TRUE + +/// Hook: acts on one person touching it. +/datum/artifact_effect/proc/do_effect_touch(mob/living/user) + return + +/// Hook: acts on everything in range, once per process while the aura runs. +/datum/artifact_effect/proc/do_effect_aura(seconds_per_tick) + return + +/// Hook: one burst. `power` is the charge spent, from 5 to 50. +/datum/artifact_effect/proc/do_effect_pulse(power) + return + +/// Hook: its artifact was smashed. Harmful effects let off one last burst; helpful ones nothing. +/datum/artifact_effect/proc/do_effect_destroy() + if(helpful) + return + do_effect_pulse(maximum_charges) + +// ===== Helpers for subtypes ===== + +/// The turf it acts from. +/datum/artifact_effect/proc/source_turf() + return get_turf(holder) + +/// Living mobs within its range (plus `extra_range`). +/datum/artifact_effect/proc/living_in_range(extra_range = 0) + . = list() + var/turf/center = source_turf() + if(!center) + return + for(var/mob/living/target in range(range + extra_range, center)) + . += target + +/// Who answers for harm it does: whoever set it going on a battery, else whoever last woke or +/// moved its artifact. +/datum/artifact_effect/proc/get_responsible() + var/mob/responsible = responsible_ref?.resolve() + if(responsible) + return responsible + var/obj/machinery/artifact/artifact = holder + if(istype(artifact)) + return artifact.last_disturbed_by?.resolve() + return null + +/datum/artifact_effect/proc/set_responsible(mob/user) + responsible_ref = user ? WEAKREF(user) : null + +/// Logs harm to `victim` like a weapon hit, at most twice a minute per victim. +/datum/artifact_effect/proc/log_harm(mob/living/victim) + if(!harmful || !istype(victim) || QDELETED(holder)) + return + var/key = REF(victim) + if(LAZYACCESS(last_logged, key) > world.time - 30 SECONDS) + return + LAZYSET(last_logged, key, world.time) + var/mob/responsible = get_responsible() + log_combat(responsible || holder, victim, "exposed", holder, "to [log_name]") + +/// What the analyser can read off it: list("kind", "release", "family"), in report words. +/datum/artifact_effect/proc/report_parts() + var/datum/artifact_energy_kind/kind = artifact_energy_kind(energy_kind) + var/release_text + switch(release_method) + if(ARTIFACT_RELEASE_AURA) + release_text = "released as a field" + if(ARTIFACT_RELEASE_PULSE) + release_text = "released in bursts" + else + release_text = "released on contact" + var/family_text + switch(artifact_trigger_family(trigger)) + if(ARTIFACT_FAMILY_CONTACT) + family_text = "Reacts to physical contact." + if(ARTIFACT_FAMILY_ENERGY) + family_text = "Reacts to energetic contact." + else + family_text = "Reacts to its surroundings." + return list("kind" = kind.report_name, "release" = release_text, "family" = family_text) + +/// One report line, such as "Electromagnetic energy, released in bursts. Reacts to energetic contact." +/datum/artifact_effect/proc/report_line() + var/list/parts = report_parts() + return "[parts["kind"]], [parts["release"]]. [parts["family"]]" + +/** + * A copy of this effect for a battery (harvesting). Same kind, release, trigger, strength and + * subtype settings, with an empty store. The copy's holder is `new_holder`. + */ +/datum/artifact_effect/proc/make_harvest_copy(atom/new_holder) + var/datum/artifact_effect/copy = new type(new_holder, null) + copy.energy_kind = energy_kind + copy.release_method = release_method + copy.trigger = trigger + copy.strength = strength + copy.range = range + copy.maximum_charges = maximum_charges + copy.touch_cost = touch_cost + copy.current_charge = 0 + copy_settings_to(copy) + return copy + +/// Hook: copy subtype settings (target temperature, gas, and so on) onto a harvest copy. +/datum/artifact_effect/proc/copy_settings_to(datum/artifact_effect/copy) + return + +// ===== Catalogue ===== + +/// Every rollable effect type (has a label_name), built once. +/proc/artifact_effect_types() + var/static/list/types + if(!types) + types = list() + for(var/datum/artifact_effect/effect_type as anything in subtypesof(/datum/artifact_effect)) + if(initial(effect_type.label_name)) + types += effect_type + return types + +/// The labeler's "what it does" words: every rollable effect's label_name, sorted, no repeats. +/proc/artifact_effect_label_names() + var/static/list/names + if(!names) + names = list() + for(var/datum/artifact_effect/effect_type as anything in artifact_effect_types()) + names |= initial(effect_type.label_name) + sortTim(names, GLOBAL_PROC_REF(cmp_text_asc)) + return names.Copy() + +/// Rolls a main-effect tier for a large find from its band. +/proc/xenoarch_roll_tier(band) + var/list/odds + switch(XENOARCH_BAND_INDEX(band)) + if(ZONE_RED) + odds = ARTIFACT_TIER_ODDS_RED + if(ZONE_YELLOW) + odds = ARTIFACT_TIER_ODDS_YELLOW + else + odds = ARTIFACT_TIER_ODDS_GREEN + return max(xenoarch_pick_weighted_index(odds), ARTIFACT_TIER_COMMON) + +/** + * Picks an effect type. + * + * * tier - ARTIFACT_TIER_* to pick from, or null for any tier (minor picks) + * * band - stamped band, for band weights + * * minor_only - only effects that may be a second effect + * * exclude - a type not to pick (the main effect, when picking the second) + * + * Falls back to lower tiers if a tier has nothing to offer. + */ +/proc/xenoarch_pick_effect_type(tier, band, minor_only = FALSE, exclude) + var/band_index = XENOARCH_BAND_INDEX(band) + for(var/try_tier = tier || ARTIFACT_TIER_EXTREME; try_tier >= ARTIFACT_TIER_COMMON; try_tier--) + var/list/candidates = list() + var/list/weights = list() + for(var/datum/artifact_effect/effect_type as anything in artifact_effect_types()) + if(effect_type == exclude) + continue + if(minor_only && !initial(effect_type.minor)) + continue + if(tier && initial(effect_type.tier) != try_tier) + continue + var/band_mult = initial(effect_type.green_weight) + if(band_index == ZONE_YELLOW) + band_mult = initial(effect_type.yellow_weight) + else if(band_index == ZONE_RED) + band_mult = initial(effect_type.red_weight) + var/effect_weight = initial(effect_type.weight) * band_mult + if(effect_weight <= 0) + continue + candidates += effect_type + weights += effect_weight + var/index = xenoarch_pick_weighted_index(weights) + if(index) + return candidates[index] + if(!tier) + break + return null diff --git a/voidcrew/modules/xenoarch/core/artifact_energy_kinds.dm b/voidcrew/modules/xenoarch/core/artifact_energy_kinds.dm new file mode 100644 index 00000000000..276d72df482 --- /dev/null +++ b/voidcrew/modules/xenoarch/core/artifact_energy_kinds.dm @@ -0,0 +1,304 @@ +/** + * # Artifact energy kinds + * + * The seven kinds of energy an analyser can read off a find (Nova's type_name values). Each + * kind also sets how an artifact looks and sounds: a faint glow while it sleeps, and a brighter + * glow, drifting particles, a light and a hum while it is awake. Several effects share each + * kind, so learning the look narrows a find down without naming what it does. + * + * Sounds and particles are existing tg assets. + */ + +/// Every energy kind, keyed by ARTIFACT_ENERGY_*. +GLOBAL_LIST_INIT(artifact_energy_kinds, init_artifact_energy_kinds()) + +/proc/init_artifact_energy_kinds() + . = list() + for(var/kind_type in subtypesof(/datum/artifact_energy_kind)) + var/datum/artifact_energy_kind/kind = new kind_type + .[kind.key] = kind + +/// The energy kind datum for a key, falling back to concentrated energy. +/proc/artifact_energy_kind(key) + return GLOB.artifact_energy_kinds[key] || GLOB.artifact_energy_kinds[ARTIFACT_ENERGY_CONCENTRATED] + +/datum/artifact_energy_kind + /// ARTIFACT_ENERGY_* + var/key + /// How the analyser names it + var/report_name + /// Glow, light and particle colour + var/color + /// Particles drifting off it while awake + var/particle_type + /// The hum while awake + var/hum_type + /// Played when it wakes + var/wake_sound + /// Played on each burst it releases + var/pulse_sound = 'sound/effects/magic/repulse.ogg' + /// "[artifact] [line]" when it wakes + var/list/wake_lines + /// Examine line while it is awake + var/list/awake_examine + +/datum/artifact_energy_kind/proc/wake_line(atom/artifact) + return "[artifact] [pick(wake_lines)]" + +/datum/artifact_energy_kind/concentrated + key = ARTIFACT_ENERGY_CONCENTRATED + report_name = "Concentrated energy" + color = "#ffb347" + particle_type = /particles/artifact/concentrated + hum_type = /datum/looping_sound/artifact_hum/concentrated + wake_sound = 'sound/effects/magic/charge.ogg' + wake_lines = list( + "brightens with a rising whine.", + "flares, and warm light rolls off it.", + "starts to hum. You can feel the heat from here.", + ) + awake_examine = list( + "It is giving off a low, warm hum.", + "Heat shimmers off its surface.", + ) + +/datum/artifact_energy_kind/psionic + key = ARTIFACT_ENERGY_PSIONIC + report_name = "Psionic wavefront" + color = "#b86bff" + particle_type = /particles/artifact/psionic + hum_type = /datum/looping_sound/artifact_hum/psionic + wake_sound = 'sound/effects/magic/magic_block_mind.ogg' + pulse_sound = 'sound/effects/hallucinations/far_noise.ogg' + wake_lines = list( + "shudders, and the air around it wavers.", + "goes very quiet, and your ears start to ring.", + "shimmers like a reflection on water.", + ) + awake_examine = list( + "The air around it wavers like heat haze.", + "Looking at it for long makes your teeth ache.", + ) + +/datum/artifact_energy_kind/electromagnetic + key = ARTIFACT_ENERGY_ELECTROMAGNETIC + report_name = "Electromagnetic energy" + color = "#5fd3ff" + particle_type = /particles/artifact/electromagnetic + hum_type = /datum/looping_sound/artifact_hum/electromagnetic + wake_sound = 'sound/effects/supermatter.ogg' + pulse_sound = 'sound/effects/sparks/sparks2.ogg' + wake_lines = list( + "crackles, and static crawls over it.", + "snaps with a blue spark.", + "buzzes, and the hair on your arms stands up.", + ) + awake_examine = list( + "Static crawls across its surface.", + "It buzzes faintly, like a transformer.", + ) + +/datum/artifact_energy_kind/particle + key = ARTIFACT_ENERGY_PARTICLE + report_name = "High-frequency particles" + color = "#e6efff" + particle_type = /particles/artifact/particle + hum_type = /datum/looping_sound/artifact_hum/particle + wake_sound = 'sound/effects/magic/cosmic_energy.ogg' + wake_lines = list( + "brightens, and motes of light lift off it.", + "glitters as if dusted with frost.", + "gives off a thin, high tone.", + ) + awake_examine = list( + "Tiny motes of light drift off its surface.", + "It glitters, though nothing is shining on it.", + ) + +/datum/artifact_energy_kind/organic + key = ARTIFACT_ENERGY_ORGANIC + report_name = "Organically reactive particles" + color = "#ff5f7a" + particle_type = /particles/artifact/organic + hum_type = /datum/looping_sound/artifact_hum/organic + wake_sound = 'sound/effects/magic/enter_blood.ogg' + pulse_sound = 'sound/effects/singlebeat.ogg' + wake_lines = list( + "swells slightly, then settles into a slow pulse.", + "flushes a dull red.", + "twitches.", + ) + awake_examine = list( + "It pulses slowly, like something breathing.", + "Its surface is damp and faintly warm.", + ) + +/datum/artifact_energy_kind/bluespace + key = ARTIFACT_ENERGY_BLUESPACE + report_name = "Bluespace phasing" + color = "#4a6bff" + particle_type = /particles/artifact/bluespace + hum_type = /datum/looping_sound/artifact_hum/bluespace + wake_sound = 'sound/effects/phasein.ogg' + pulse_sound = 'sound/effects/magic/blink.ogg' + wake_lines = list( + "blurs at the edges.", + "flickers, as if it were briefly somewhere else.", + "seems to lean without moving.", + ) + awake_examine = list( + "Its edges won't hold still.", + "It is hard to say exactly how far away it is.", + ) + +/datum/artifact_energy_kind/synthesis + key = ARTIFACT_ENERGY_SYNTHESIS + report_name = "Atomic synthesis" + color = "#7dff6a" + particle_type = /particles/artifact/synthesis + hum_type = /datum/looping_sound/artifact_hum/synthesis + wake_sound = 'sound/effects/bubbles/bubbles.ogg' + pulse_sound = 'sound/effects/spray.ogg' + wake_lines = list( + "fizzes, and a sharp chemical smell rises from it.", + "beads with moisture.", + "hisses softly.", + ) + awake_examine = list( + "It fizzes faintly. The air near it tastes of metal.", + "A sharp, clean smell hangs around it.", + ) + +// ===== Hums ===== + +/datum/looping_sound/artifact_hum + volume = 20 + extra_range = -8 + falloff_distance = 2 + falloff_exponent = 5 + ignore_walls = FALSE + vary = TRUE + +/datum/looping_sound/artifact_hum/concentrated + mid_sounds = list('sound/machines/sm/loops/calm.ogg' = 1) + mid_length = 10 SECONDS + volume = 15 + +/datum/looping_sound/artifact_hum/psionic + mid_sounds = list('sound/ambience/misc/ambimystery.ogg' = 1) + mid_length = 10 SECONDS + volume = 12 + +/datum/looping_sound/artifact_hum/electromagnetic + mid_sounds = list( + 'sound/machines/tcomms/tcomms_mid1.ogg' = 1, + 'sound/machines/tcomms/tcomms_mid2.ogg' = 1, + 'sound/machines/tcomms/tcomms_mid3.ogg' = 1, + 'sound/machines/tcomms/tcomms_mid4.ogg' = 1, + ) + mid_length = 2 SECONDS + +/datum/looping_sound/artifact_hum/particle + mid_sounds = list('sound/machines/hypertorus/loops/hypertorus_nominal.ogg' = 1) + mid_length = 6.6 SECONDS + volume = 12 + +/datum/looping_sound/artifact_hum/organic + mid_sounds = list('sound/effects/singlebeat.ogg' = 1) + mid_length = 1.6 SECONDS + volume = 15 + +/datum/looping_sound/artifact_hum/bluespace + mid_sounds = list( + 'sound/machines/gravgen/grav_gen_mid1.ogg' = 12, + 'sound/machines/gravgen/grav_gen_mid2.ogg' = 1, + ) + mid_length = 2.3 SECONDS + volume = 15 + +/datum/looping_sound/artifact_hum/synthesis + mid_sounds = list( + 'sound/effects/soup_boil/soup_boil1.ogg' = 1, + 'sound/effects/soup_boil/soup_boil2.ogg' = 1, + 'sound/effects/soup_boil/soup_boil3.ogg' = 1, + 'sound/effects/soup_boil/soup_boil4.ogg' = 1, + ) + mid_length = 3 SECONDS + volume = 15 + +// ===== Particles ===== +// Shared holders (add_shared_particles): one emitter per kind serves every artifact of that kind. + +/particles/artifact + icon = 'icons/effects/particles/generic.dmi' + icon_state = "dot" + width = 64 + height = 64 + count = 24 + spawning = 0.6 + lifespan = 1.5 SECONDS + fade = 1 SECONDS + fadein = 0.2 SECONDS + position = generator(GEN_CIRCLE, 6, 13, NORMAL_RAND) + scale = generator(GEN_VECTOR, list(0.4, 0.4), list(0.8, 0.8), NORMAL_RAND) + +/particles/artifact/concentrated + color = "#ffb347" + velocity = list(0, 0.6) + drift = generator(GEN_VECTOR, list(-0.1, 0), list(0.1, 0.05), UNIFORM_RAND) + +/particles/artifact/psionic + icon = 'icons/effects/particles/echo.dmi' + icon_state = list("echo1" = 1, "echo2" = 1, "echo3" = 1) + color = "#b86bff" + spawning = 0.25 + lifespan = 2 SECONDS + scale = generator(GEN_VECTOR, list(0.15, 0.15), list(0.3, 0.3), NORMAL_RAND) + position = generator(GEN_CIRCLE, 0, 12, NORMAL_RAND) + rotation = generator(GEN_NUM, 0, 360, UNIFORM_RAND) + +/particles/artifact/electromagnetic + icon_state = "cross" + color = "#5fd3ff" + spawning = 1.2 + lifespan = 0.4 SECONDS + fade = 0.3 SECONDS + fadein = 0 + position = generator(GEN_CIRCLE, 8, 15, UNIFORM_RAND) + scale = generator(GEN_VECTOR, list(0.3, 0.3), list(0.6, 0.6), NORMAL_RAND) + +/particles/artifact/particle + color = "#e6efff" + spawning = 0.5 + lifespan = 2.5 SECONDS + velocity = list(0, 0.25) + drift = generator(GEN_VECTOR, list(-0.15, 0), list(0.15, 0), UNIFORM_RAND) + scale = generator(GEN_VECTOR, list(0.25, 0.25), list(0.5, 0.5), NORMAL_RAND) + +/particles/artifact/organic + icon_state = "drop" + color = "#ff5f7a" + spawning = 0.3 + lifespan = 1.2 SECONDS + gravity = list(0, -0.3) + position = generator(GEN_CIRCLE, 0, 9, NORMAL_RAND) + +/particles/artifact/bluespace + icon = 'icons/effects/particles/echo.dmi' + icon_state = list("echo1" = 3, "echo2" = 1, "echo3" = 1) + color = "#4a6bff" + spawning = 1 + lifespan = 0.6 SECONDS + fade = 0.5 SECONDS + friction = 0.5 + position = generator(GEN_SPHERE, 4, 12, NORMAL_RAND) + drift = generator(GEN_VECTOR, list(-1, 1), list(1, 2), NORMAL_RAND) + scale = 0.6 + +/particles/artifact/synthesis + icon_state = "curl" + color = "#7dff6a" + spawning = 0.4 + lifespan = 1.8 SECONDS + velocity = list(0, 0.4) + spin = generator(GEN_NUM, -20, 20, NORMAL_RAND) diff --git a/voidcrew/modules/xenoarch/core/artifact_helpers.dm b/voidcrew/modules/xenoarch/core/artifact_helpers.dm index 3a1308b1d81..7266df46f6c 100644 --- a/voidcrew/modules/xenoarch/core/artifact_helpers.dm +++ b/voidcrew/modules/xenoarch/core/artifact_helpers.dm @@ -112,3 +112,129 @@ GLOBAL_LIST_EMPTY(artifact_serials_used) if(roll < 0) return index return length(weights) + +/** + * How exposed a mob is to an artifact, from 0 (fully protected) to 1 (bare). + * Biosuits do most of it; latex gloves and science goggles help a little. Ported from Nova's + * get_anomaly_protection(), reading bio armor with getarmor() instead of Nova's helper. + */ +/proc/artifact_exposure(mob/living/target) + if(!ishuman(target)) + return 1 + var/mob/living/carbon/human/person = target + var/protection = 0 + if(person.getarmor(BODY_ZONE_CHEST, BIO) >= 85) + protection += 0.5 + if(person.getarmor(BODY_ZONE_HEAD, BIO) >= 85) + protection += 0.3 + if(istype(person.gloves, /obj/item/clothing/gloves/latex)) + protection += 0.1 + if(istype(person.glasses, /obj/item/clothing/glasses/science)) + protection += 0.1 + return clamp(1 - protection, 0, 1) + +/// Whether a mob's touch counts as touching the artifact's surface: a bare hand, or any gloves +/// that are not latex. Things without hands always count. +/proc/artifact_touch_counts(mob/living/toucher) + if(!iscarbon(toucher)) + return TRUE + var/mob/living/carbon/carbon_toucher = toucher + var/obj/item/clothing/gloves/worn = carbon_toucher.get_item_by_slot(ITEM_SLOT_GLOVES) + return !istype(worn, /obj/item/clothing/gloves/latex) + +// ===== Healing cap ===== +// Heal and robo-heal effects share one budget per person across every artifact and utilizer: +// ARTIFACT_HEAL_CAP brute plus burn per ARTIFACT_HEAL_WINDOW. + +#define ARTIFACT_HEAL_CAP 30 +#define ARTIFACT_HEAL_WINDOW (5 MINUTES) + +/// REF(mob) -> list(window ends at, amount healed in the window). Holds no hard references. +GLOBAL_LIST_EMPTY(artifact_heal_ledger) + +/// How much artifact healing this mob may still take in its current window. +/proc/artifact_heal_allowance(mob/living/target) + var/list/entry = GLOB.artifact_heal_ledger[REF(target)] + if(!entry || world.time >= entry[1]) + return ARTIFACT_HEAL_CAP + return max(ARTIFACT_HEAL_CAP - entry[2], 0) + +/// Records artifact healing against this mob's window. +/proc/artifact_record_heal(mob/living/target, amount) + if(amount <= 0) + return + var/key = REF(target) + var/list/entry = GLOB.artifact_heal_ledger[key] + if(!entry || world.time >= entry[1]) + entry = list(world.time + ARTIFACT_HEAL_WINDOW, 0) + GLOB.artifact_heal_ledger[key] = entry + // Lazy sweep of stale windows so the ledger never grows past the people healed recently. + if(length(GLOB.artifact_heal_ledger) > 50) + for(var/old_key in GLOB.artifact_heal_ledger) + var/list/old = GLOB.artifact_heal_ledger[old_key] + if(world.time >= old[1]) + GLOB.artifact_heal_ledger -= old_key + entry[2] += amount + +/** + * Heals brute and burn on `target`, never past what the shared cap allows. + * Returns the amount actually healed. + * + * * required_bodytype - limit to robotic or organic limbs on carbons (heal_overall_damage's arg) + */ +/proc/artifact_capped_heal(mob/living/target, amount, required_bodytype) + var/allowed = min(amount, artifact_heal_allowance(target)) + if(allowed <= 0) + return 0 + var/before = target.getBruteLoss() + target.getFireLoss() + target.heal_overall_damage(allowed / 2, allowed / 2, required_bodytype = required_bodytype) + var/healed = max(before - (target.getBruteLoss() + target.getFireLoss()), 0) + artifact_record_heal(target, healed) + return healed + +#undef ARTIFACT_HEAL_CAP +#undef ARTIFACT_HEAL_WINDOW + +// ===== Reagent triggers ===== + +/// Reagents that count as volatile (Nova's GLOB.volatile_reagents). +GLOBAL_LIST_INIT(artifact_volatile_reagents, typecacheof(list( + /datum/reagent/thermite, + /datum/reagent/toxin/plasma, + /datum/reagent/nitroglycerin, + /datum/reagent/clf3, + /datum/reagent/sorium, + /datum/reagent/liquid_dark_matter, + /datum/reagent/gunpowder, + /datum/reagent/rdx, + /datum/reagent/tatp, + /datum/reagent/flash_powder, + /datum/reagent/phlogiston, + /datum/reagent/napalm, + /datum/reagent/pyrosium, + /datum/reagent/teslium, +))) + +/// The trigger one reagent type counts as, or NONE. +/proc/artifact_reagent_trigger(reagent_type) + if(!ispath(reagent_type, /datum/reagent)) + return NONE + if(ispath(reagent_type, /datum/reagent/water) || ispath(reagent_type, /datum/reagent/hydrogen)) + return ARTIFACT_TRIGGER_WATER + if(ispath(reagent_type, /datum/reagent/toxin/acid)) + return ARTIFACT_TRIGGER_ACID + if(GLOB.artifact_volatile_reagents[reagent_type]) + return ARTIFACT_TRIGGER_VOLATILE + if(ispath(reagent_type, /datum/reagent/toxin) || ispath(reagent_type, /datum/reagent/consumable/ethanol/neurotoxin)) + return ARTIFACT_TRIGGER_TOXIN + return NONE + +/// Every trigger a list of reagents counts as (datums or types), as one bitfield. +/proc/artifact_reagent_triggers(list/reagents) + . = NONE + for(var/reagent in reagents) + var/reagent_type = reagent + if(istype(reagent, /datum/reagent)) + var/datum/reagent/reagent_datum = reagent + reagent_type = reagent_datum.type + . |= artifact_reagent_trigger(reagent_type) diff --git a/voidcrew/modules/xenoarch/effects/blood.dm b/voidcrew/modules/xenoarch/effects/blood.dm new file mode 100644 index 00000000000..b3d3dec9433 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/blood.dm @@ -0,0 +1,63 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/blood.dm. +// Voidcrew: blood_volume set directly (Nova's adjust_blood_volume() doesn't exist here); regen stops +// at a normal amount; drain never takes anyone below the point where they start to pass out. + +/datum/artifact_effect/blood + tier = ARTIFACT_TIER_RARE + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC) + +/// Whether `target` has blood to work on. +/datum/artifact_effect/blood/proc/bleeds(mob/living/target) + return target.stat != DEAD && target.blood_volume > 0 && !HAS_TRAIT(target, TRAIT_NOBLOOD) + +/datum/artifact_effect/blood/regen + label_name = "Restores blood" + log_name = "Blood regeneration" + helpful = TRUE + +/datum/artifact_effect/blood/regen/do_effect_touch(mob/living/user) + if(restore(user, 20)) + to_chat(user, span_notice("Your body feels full, somehow.")) + +/datum/artifact_effect/blood/regen/do_effect_aura(seconds_per_tick) + for(var/mob/living/target as anything in living_in_range()) + if(restore(target, 2 * seconds_per_tick) && prob(10)) + to_chat(target, span_notice("Your chest feels warm.")) + +/datum/artifact_effect/blood/regen/do_effect_pulse(power) + for(var/mob/living/target as anything in living_in_range()) + if(restore(target, power * 1.5)) + to_chat(target, span_notice("Warmth floods through your veins.")) + +/datum/artifact_effect/blood/regen/proc/restore(mob/living/target, amount) + if(!bleeds(target) || target.blood_volume >= BLOOD_VOLUME_NORMAL) + return FALSE + target.blood_volume = min(BLOOD_VOLUME_NORMAL, target.blood_volume + amount * artifact_exposure(target)) + return TRUE + +/datum/artifact_effect/blood/drain + label_name = "Drains blood" + log_name = "Blood drain" + harmful = TRUE + +/datum/artifact_effect/blood/drain/do_effect_touch(mob/living/user) + if(bleed(user, 40)) + to_chat(user, span_warning("Blood beads up through the skin of your palm!")) + +/datum/artifact_effect/blood/drain/do_effect_aura(seconds_per_tick) + for(var/mob/living/target as anything in living_in_range()) + if(bleed(target, 2 * seconds_per_tick) && prob(10)) + to_chat(target, span_warning("Your nose starts to bleed.")) + +/datum/artifact_effect/blood/drain/do_effect_pulse(power) + for(var/mob/living/target as anything in living_in_range()) + if(bleed(target, power)) + to_chat(target, span_warning("You feel suddenly light-headed.")) + target.add_splatter_floor(get_turf(target), small_drip = TRUE) + +/datum/artifact_effect/blood/drain/proc/bleed(mob/living/target, amount) + if(!bleeds(target) || target.blood_volume <= BLOOD_VOLUME_OKAY) + return FALSE + target.blood_volume = max(BLOOD_VOLUME_OKAY, target.blood_volume - amount * artifact_exposure(target)) + log_harm(target) + return TRUE diff --git a/voidcrew/modules/xenoarch/effects/bodyhorror.dm b/voidcrew/modules/xenoarch/effects/bodyhorror.dm new file mode 100644 index 00000000000..c5dc7911e73 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/bodyhorror.dm @@ -0,0 +1,68 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/bodyhorror.dm. +// Voidcrew: half as likely in green; one victim per burst; not harvestable; logged. + +/datum/artifact_effect/bodyhorror + label_name = "Twists flesh" + log_name = "Body horror" + tier = ARTIFACT_TIER_EXTREME + harvestable = FALSE + harmful = TRUE + green_weight = 0.5 + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC) + allowed_release_methods = list(ARTIFACT_RELEASE_PULSE) + +/datum/artifact_effect/bodyhorror/setup() + range = min(range, 4) + +/datum/artifact_effect/bodyhorror/do_effect_pulse(power) + var/list/victims = list() + for(var/mob/living/carbon/target in living_in_range()) + if(target.stat == DEAD || HAS_TRAIT(target, TRAIT_NODISMEMBER) || artifact_exposure(target) <= 0.5) + continue + victims += target + while(length(victims)) + if(mutate_limb(pick_n_take(victims))) + return + +/// Swaps one arm or leg (or a missing one) for a living flesh limb. Returns TRUE if it did. +/datum/artifact_effect/bodyhorror/proc/mutate_limb(mob/living/carbon/target) + var/list/zones = target.get_missing_limbs() + for(var/obj/item/bodypart/part as anything in target.bodyparts) + if(part.body_zone == BODY_ZONE_HEAD || part.body_zone == BODY_ZONE_CHEST) + continue + if(HAS_TRAIT(part, TRAIT_IGNORED_BY_LIVING_FLESH) || (part.bodypart_flags & BODYPART_UNREMOVABLE)) + continue + zones += part.body_zone + if(!length(zones)) + return FALSE + var/zone = pick(zones) + var/part_type + switch(zone) + if(BODY_ZONE_L_ARM) + part_type = /obj/item/bodypart/arm/left/flesh + if(BODY_ZONE_R_ARM) + part_type = /obj/item/bodypart/arm/right/flesh + if(BODY_ZONE_L_LEG) + part_type = /obj/item/bodypart/leg/left/flesh + if(BODY_ZONE_R_LEG) + part_type = /obj/item/bodypart/leg/right/flesh + if(!part_type) + return FALSE + var/obj/item/bodypart/old_part = target.get_bodypart(zone) + if(old_part) + old_part.dismember() + else + target.emote("scream") + target.visible_message( + span_danger("[target]'s limb swells and splits, and something red and living pushes out of it!"), + span_userdanger("Your limb swells and splits, and something red and living pushes out of it!"), + blind_message = span_hear("You hear tearing flesh and cracking bone."), + ) + // The same steps the living flesh mob uses to take a limb (ruin_defender/flesh.dm). + var/obj/item/bodypart/new_part = new part_type() + var/mob/living/basic/living_limb_flesh/parasite = new + parasite.forceMove(new_part) + new_part.replace_limb(target, TRUE) + parasite.register_to_limb(new_part) + log_harm(target) + return TRUE diff --git a/voidcrew/modules/xenoarch/effects/cell.dm b/voidcrew/modules/xenoarch/effects/cell.dm new file mode 100644 index 00000000000..5121c9fd4e8 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/cell.dm @@ -0,0 +1,104 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/cellcharge.dm and celldrain.dm. +// Voidcrew: no free power. Charging works on at most two ordinary power cells at a time, no +// faster than a tier-1 recharger (the cell's own charge rate, capped at a standard cell's), and +// never on APCs, SMES units, megacells or any machine. Nova gave 125 kW to everything in range +// and a billion joules to every cell when smashed. Draining reaches the same cells. + +/datum/artifact_effect/cell + tier = ARTIFACT_TIER_UNCOMMON + minor = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ELECTROMAGNETIC) + /// Cells it works on at once + var/cell_limit = 2 + +/// Seconds of recharger-rate charge for this cell, capped at a standard cell's rate. +/datum/artifact_effect/cell/proc/charge_for(obj/item/stock_parts/power_store/cell/cell, seconds) + return min(cell.chargerate, STANDARD_CELL_RATE) * seconds + +/// Ordinary power cells carried by `holder_atom` (itself, or anything inside it). +/datum/artifact_effect/cell/proc/cells_in(atom/holder_atom) + return holder_atom.get_all_contents_type(/obj/item/stock_parts/power_store/cell) + +/// Cells in range, loose or carried, never inside a machine. `want_room` picks cells that are +/// not full; otherwise cells that are not empty. +/datum/artifact_effect/cell/proc/cells_nearby(want_room) + . = list() + var/turf/center = source_turf() + if(!center) + return + for(var/atom/movable/thing in range(range, center)) + if(!isitem(thing) && !isliving(thing)) + continue + for(var/obj/item/stock_parts/power_store/cell/cell as anything in cells_in(thing)) + if(want_room ? cell.charge < cell.maxcharge : cell.charge > 0) + . += cell + if(length(.) >= cell_limit) + return + +/datum/artifact_effect/cell/proc/after_change(obj/item/stock_parts/power_store/cell/cell) + cell.update_appearance() + if(isatom(cell.loc)) + var/atom/cell_holder = cell.loc + cell_holder.update_appearance() + +/datum/artifact_effect/cell/charge + label_name = "Charges cells" + log_name = "Cell charge" + helpful = TRUE + +/datum/artifact_effect/cell/charge/do_effect_touch(mob/living/user) + var/charged = 0 + for(var/obj/item/stock_parts/power_store/cell/cell as anything in cells_in(user)) + if(charged >= cell_limit) + break + if(cell.charge >= cell.maxcharge) + continue + cell.give(charge_for(cell, 5)) + after_change(cell) + charged++ + if(charged && issilicon(user)) + to_chat(user, span_notice("Your cell takes a charge.")) + +/datum/artifact_effect/cell/charge/do_effect_aura(seconds_per_tick) + for(var/obj/item/stock_parts/power_store/cell/cell as anything in cells_nearby(want_room = TRUE)) + cell.give(charge_for(cell, seconds_per_tick)) + after_change(cell) + +/datum/artifact_effect/cell/charge/do_effect_pulse(power) + for(var/obj/item/stock_parts/power_store/cell/cell as anything in cells_nearby(want_room = TRUE)) + cell.give(charge_for(cell, 10)) + after_change(cell) + +/datum/artifact_effect/cell/drain + label_name = "Drains cells" + log_name = "Cell drain" + harmful = TRUE + +/datum/artifact_effect/cell/drain/do_effect_touch(mob/living/user) + var/drained = 0 + for(var/obj/item/stock_parts/power_store/cell/cell as anything in cells_in(user)) + if(drained >= cell_limit) + break + if(cell.charge <= 0) + continue + cell.use(charge_for(cell, 30), force = TRUE) + after_change(cell) + drained++ + if(drained) + log_harm(user) + if(issilicon(user)) + to_chat(user, span_warning("Your cell is draining fast!")) + +/datum/artifact_effect/cell/drain/do_effect_aura(seconds_per_tick) + drain_nearby(charge_seconds = seconds_per_tick * 2) + +/datum/artifact_effect/cell/drain/do_effect_pulse(power) + drain_nearby(charge_seconds = 20) + +/datum/artifact_effect/cell/drain/proc/drain_nearby(charge_seconds) + for(var/obj/item/stock_parts/power_store/cell/cell as anything in cells_nearby(want_room = FALSE)) + cell.use(charge_for(cell, charge_seconds), force = TRUE) + after_change(cell) + var/mob/living/carrier = get(cell, /mob/living) + if(carrier) + log_harm(carrier) diff --git a/voidcrew/modules/xenoarch/effects/disgust.dm b/voidcrew/modules/xenoarch/effects/disgust.dm new file mode 100644 index 00000000000..579a6e3575d --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/disgust.dm @@ -0,0 +1,33 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/disgust.dm. +// Voidcrew: nausea that builds, rather than one touch that empties your stomach. + +/datum/artifact_effect/disgust + label_name = "Nausea" + log_name = "Disgust" + tier = ARTIFACT_TIER_UNCOMMON + minor = TRUE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_ORGANIC) + +/datum/artifact_effect/disgust/do_effect_touch(mob/living/user) + sicken(user, 50) + +/datum/artifact_effect/disgust/do_effect_aura(seconds_per_tick) + for(var/mob/living/carbon/target in living_in_range()) + if(SPT_PROB(40, seconds_per_tick)) + sicken(target, 4) + +/datum/artifact_effect/disgust/do_effect_pulse(power) + for(var/mob/living/carbon/target in living_in_range()) + sicken(target, clamp(power * 1.5, 10, 60)) + +/datum/artifact_effect/disgust/proc/sicken(mob/living/target, amount) + if(!iscarbon(target) || target.stat == DEAD) + return + var/exposure = artifact_exposure(target) + if(exposure <= 0) + return + if(prob(30)) + to_chat(target, span_warning(pick("Your stomach turns over.", "You don't feel so good.", "Your mouth floods with spit."))) + target.adjust_disgust(amount * exposure) + log_harm(target) diff --git a/voidcrew/modules/xenoarch/effects/emp.dm b/voidcrew/modules/xenoarch/effects/emp.dm new file mode 100644 index 00000000000..2a1af40041e --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/emp.dm @@ -0,0 +1,19 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/emp.dm. +// Voidcrew: smaller pulses (Nova's light radius reached ten tiles); logged. + +/datum/artifact_effect/emp + label_name = "EMP" + log_name = "EMP" + tier = ARTIFACT_TIER_RARE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ELECTROMAGNETIC) + allowed_release_methods = list(ARTIFACT_RELEASE_PULSE) + +/datum/artifact_effect/emp/do_effect_pulse(power) + var/turf/here = source_turf() + if(!here) + return + var/light_range = clamp(range - 1, 1, 6) + empulse(here, round(light_range / 3), light_range) + for(var/mob/living/carbon/human/target in living_in_range()) + log_harm(target) diff --git a/voidcrew/modules/xenoarch/effects/feelings.dm b/voidcrew/modules/xenoarch/effects/feelings.dm new file mode 100644 index 00000000000..142fcfb1b2b --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/feelings.dm @@ -0,0 +1,105 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/feelings.dm. +// Voidcrew: trimmed message lists, plain spans instead of font tags, dizziness only from dread. + +/datum/artifact_effect/feelings + tier = ARTIFACT_TIER_COMMON + minor = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC) + /// Strong feelings + var/list/major_messages + /// Passing feelings + var/list/minor_messages + var/major_mood_type + var/minor_mood_type + /// Span proc for messages + var/good = TRUE + +/datum/artifact_effect/feelings/do_effect_touch(mob/living/user) + feel(user, 50, 100) + +/datum/artifact_effect/feelings/do_effect_aura(seconds_per_tick) + for(var/mob/living/carbon/human/target in living_in_range()) + if(SPT_PROB(2.5, seconds_per_tick)) + feel(target, 100, 0) + else if(SPT_PROB(5, seconds_per_tick)) + feel(target, 0, 100) + +/datum/artifact_effect/feelings/do_effect_pulse(power) + for(var/mob/living/carbon/human/target in living_in_range()) + feel(target, 80, 100) + +/// Gives `target` a strong feeling with `major_chance`, else a passing one with `minor_chance`. +/datum/artifact_effect/feelings/proc/feel(mob/living/target, major_chance, minor_chance) + if(!ishuman(target) || prob(100 * (1 - artifact_exposure(target)))) + return + if(prob(major_chance)) + to_chat(target, good ? span_nicegreen("[pick(major_messages)]") : span_boldwarning(pick(major_messages))) + target.add_mood_event("artifact_feeling_major", major_mood_type) + if(!good) + target.adjust_dizzy_up_to(4 SECONDS, 20 SECONDS) + else if(prob(minor_chance)) + to_chat(target, good ? span_nicegreen(pick(minor_messages)) : span_warning(pick(minor_messages))) + target.add_mood_event("artifact_feeling_minor", minor_mood_type) + +/datum/artifact_effect/feelings/good + label_name = "Good mood" + log_name = "Good feeling" + good = TRUE + major_mood_type = /datum/mood_event/artifact_good_major + minor_mood_type = /datum/mood_event/artifact_good_minor + major_messages = list( + "You want to hug everyone you meet!", + "Everything is going so well!", + "You feel giddy.", + "You could dance.", + ) + minor_messages = list( + "You feel good.", + "You've got a good feeling about this.", + "Something smells good.", + "You fight the urge to smile.", + "The colours around you seem a bit brighter.", + "Your worries seem very far away.", + ) + +/datum/artifact_effect/feelings/bad + label_name = "Dread" + log_name = "Bad feeling" + good = FALSE + major_mood_type = /datum/mood_event/artifact_bad_major + minor_mood_type = /datum/mood_event/artifact_bad_minor + major_messages = list( + "You've got to get out of here!", + "Someone's trying to kill you!", + "There's something out there!", + "What's happening to you?", + ) + minor_messages = list( + "You feel worried.", + "Something doesn't feel right.", + "You get a strange feeling in your gut.", + "You've got a bad feeling about this.", + "Your scalp prickles.", + "The shadows seem longer than they were.", + "The walls feel closer.", + ) + +/datum/mood_event/artifact_good_major + description = "Everything's going great and I don't even know why." + mood_change = 6 + timeout = 5 MINUTES + +/datum/mood_event/artifact_good_minor + description = "I feel strangely relaxed." + mood_change = 3 + timeout = 3 MINUTES + +/datum/mood_event/artifact_bad_major + description = "Something is very, very wrong around here." + mood_change = -6 + timeout = 5 MINUTES + +/datum/mood_event/artifact_bad_minor + description = "I feel uneasy and I can't say why." + mood_change = -3 + timeout = 3 MINUTES diff --git a/voidcrew/modules/xenoarch/effects/gas.dm b/voidcrew/modules/xenoarch/effects/gas.dm new file mode 100644 index 00000000000..9e617b33629 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/gas.dm @@ -0,0 +1,58 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/gas.dm. +// Voidcrew: oxygen, nitrogen or carbon dioxide only (plasma and nitrous oxide are their own +// effects); room-temperature gas; vents indoors only, never into planet air; stops at a modest +// pressure; no destroy burst. + +/datum/artifact_effect/gas + label_name = "Vents gas" + log_name = "Gas" + tier = ARTIFACT_TIER_COMMON + possible_kinds = list(ARTIFACT_ENERGY_PARTICLE, ARTIFACT_ENERGY_SYNTHESIS) + /// The gas it vents + var/gas_type = /datum/gas/oxygen + /// It stops venting once its tile reaches this pressure (kPa) + var/max_pressure = ONE_ATMOSPHERE + +/datum/artifact_effect/gas/setup() + var/static/list/gas_weights = list( + /datum/gas/oxygen = 4, + /datum/gas/nitrogen = 4, + /datum/gas/carbon_dioxide = 2, + ) + gas_type = pick_weight(gas_weights) + max_pressure = rand(105, 150) + +/datum/artifact_effect/gas/copy_settings_to(datum/artifact_effect/gas/copy) + copy.gas_type = gas_type + copy.max_pressure = max_pressure + +/datum/artifact_effect/gas/do_effect_touch(mob/living/user) + if(vent(rand(2, 8))) + to_chat(user, span_warning("Gas hisses out of [holder] around your hand.")) + +/datum/artifact_effect/gas/do_effect_aura(seconds_per_tick) + vent(rand(0, 3) * seconds_per_tick) + +/datum/artifact_effect/gas/do_effect_pulse(power) + if(vent(power / 2)) + playsound(holder, 'sound/effects/spray.ogg', 40, TRUE) + +/datum/artifact_effect/gas/do_effect_destroy() + return + +/// Lets `moles` of its gas out onto its tile. Returns TRUE if any came out. +/datum/artifact_effect/gas/proc/vent(moles) + if(moles <= 0) + return FALSE + var/turf/open/here = source_turf() + if(!istype(here) || here.planetary_atmos || isspaceturf(here)) + return FALSE + var/datum/gas_mixture/air = here.return_air() + if(!air || air.return_pressure() >= max_pressure) + return FALSE + var/datum/gas_mixture/puff = new + puff.assert_gas(gas_type) + puff.gases[gas_type][MOLES] = moles + puff.temperature = T20C + here.assume_air(puff) + return TRUE diff --git a/voidcrew/modules/xenoarch/effects/gravity.dm b/voidcrew/modules/xenoarch/effects/gravity.dm new file mode 100644 index 00000000000..e864b8e520f --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/gravity.dm @@ -0,0 +1,58 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/gravity.dm. +// Voidcrew: shorter reach (four tiles of pull or push, not eight), anchored and heavy things stay +// put, only loose items, structures and people move; any trigger. Moving people is logged. + +#define ARTIFACT_GRAVITY_PULL 1 +#define ARTIFACT_GRAVITY_PUSH 2 +#define ARTIFACT_GRAVITY_SCATTER 3 + +/datum/artifact_effect/gravity + label_name = "Gravity" + log_name = "Gravity" + tier = ARTIFACT_TIER_UNCOMMON + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_BLUESPACE) + allowed_release_methods = list(ARTIFACT_RELEASE_PULSE) + /// Pull, push or scatter + var/mode = ARTIFACT_GRAVITY_PULL + +/datum/artifact_effect/gravity/setup() + mode = pick(ARTIFACT_GRAVITY_PULL, ARTIFACT_GRAVITY_PUSH, ARTIFACT_GRAVITY_SCATTER) + range = min(range, 6) + +/datum/artifact_effect/gravity/copy_settings_to(datum/artifact_effect/gravity/copy) + copy.mode = mode + +/datum/artifact_effect/gravity/do_effect_pulse(power) + var/turf/center = source_turf() + if(!center) + return + new /obj/effect/temp_visual/circle_wave/gravity(center) + for(var/atom/movable/thing in range(range, center)) + if(thing == holder || !can_shift(thing)) + continue + var/exposure = isliving(thing) ? artifact_exposure(thing) : 1 + if(exposure <= 0) + continue + switch(mode) + if(ARTIFACT_GRAVITY_PULL) + for(var/step in 1 to round(4 * exposure)) + step_towards(thing, center) + if(ARTIFACT_GRAVITY_PUSH) + for(var/step in 1 to round(4 * exposure)) + step_away(thing, center) + if(ARTIFACT_GRAVITY_SCATTER) + var/turf/landing = pick(RANGE_TURFS(range, center)) + thing.throw_at(landing, round(4 * exposure), 2) + if(isliving(thing)) + log_harm(thing) + +/// Loose items, unanchored structures and the living; nothing anchored or immovable. +/datum/artifact_effect/gravity/proc/can_shift(atom/movable/thing) + if(thing.anchored || thing.move_resist > MOVE_FORCE_STRONG) + return FALSE + return isitem(thing) || isstructure(thing) || isliving(thing) + +#undef ARTIFACT_GRAVITY_PULL +#undef ARTIFACT_GRAVITY_PUSH +#undef ARTIFACT_GRAVITY_SCATTER diff --git a/voidcrew/modules/xenoarch/effects/hallucination.dm b/voidcrew/modules/xenoarch/effects/hallucination.dm new file mode 100644 index 00000000000..677ae52e793 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/hallucination.dm @@ -0,0 +1,35 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/drugs.dm. +// Voidcrew: real hallucinations as well as the colours, capped at a minute. + +/datum/artifact_effect/hallucination + label_name = "Hallucinations" + log_name = "Hallucination" + tier = ARTIFACT_TIER_UNCOMMON + minor = TRUE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_ORGANIC) + +/datum/artifact_effect/hallucination/do_effect_touch(mob/living/user) + if(dose(user, 20 SECONDS)) + to_chat(user, span_hypnophrase("The colours go soft at the edges.")) + +/datum/artifact_effect/hallucination/do_effect_aura(seconds_per_tick) + for(var/mob/living/carbon/target in living_in_range()) + if(SPT_PROB(20, seconds_per_tick) && dose(target, 5 SECONDS)) + to_chat(target, span_hypnophrase("Something at the corner of your eye moves.")) + +/datum/artifact_effect/hallucination/do_effect_pulse(power) + for(var/mob/living/carbon/target in living_in_range()) + if(dose(target, power SECONDS)) + to_chat(target, span_hypnophrase("The world tilts and blooms.")) + +/datum/artifact_effect/hallucination/proc/dose(mob/living/target, duration) + if(!iscarbon(target) || target.stat == DEAD) + return FALSE + var/exposure = artifact_exposure(target) + if(exposure <= 0) + return FALSE + target.adjust_hallucinations_up_to(duration * exposure, 60 SECONDS) + target.adjust_drugginess_up_to(duration * exposure, 30 SECONDS) + log_harm(target) + return TRUE diff --git a/voidcrew/modules/xenoarch/effects/health.dm b/voidcrew/modules/xenoarch/effects/health.dm new file mode 100644 index 00000000000..5c5135220d9 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/health.dm @@ -0,0 +1,94 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/health.dm. +// Voidcrew: healing shares one cap per person across every artifact (artifact_capped_heal()), +// so a heal artifact bolted in a corridor is a comfort, not a medbay. Robo variants work on +// silicons, robotic mobs and prosthetic limbs. Hurt effects log like weapons. Nova's numbers +// (pulses scaling to 250 healing or 160 damage) are cut to sane ranges. + +/datum/artifact_effect/heal + label_name = "Heals" + log_name = "Heal" + tier = ARTIFACT_TIER_UNCOMMON + minor = TRUE + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC) + /// Which limbs it works on for carbons, and which mobs otherwise + var/robotic = FALSE + +/datum/artifact_effect/heal/do_effect_touch(mob/living/user) + if(mend(user, 12)) + to_chat(user, span_notice(robotic ? "Your damaged parts knit themselves back together." : "A soothing warmth spreads through you.")) + +/datum/artifact_effect/heal/do_effect_aura(seconds_per_tick) + for(var/mob/living/target as anything in living_in_range()) + if(mend(target, 0.75 * seconds_per_tick) && prob(10)) + to_chat(target, span_notice(robotic ? "A faint hum steadies your systems." : "You feel a gentle warmth from something nearby.")) + +/datum/artifact_effect/heal/do_effect_pulse(power) + for(var/mob/living/target as anything in living_in_range()) + if(mend(target, clamp(power * 0.6, 4, 20))) + to_chat(target, span_notice(robotic ? "A wave of energy mends your plating." : "A wave of warmth washes through you.")) + +/// Heals one mob within the shared cap. Returns the amount healed. +/datum/artifact_effect/heal/proc/mend(mob/living/target, amount) + if(target.stat == DEAD) + return 0 + amount *= artifact_exposure(target) + if(iscarbon(target)) + return artifact_capped_heal(target, amount, robotic ? BODYTYPE_ROBOTIC : BODYTYPE_ORGANIC) + if(robotic ? !(target.mob_biotypes & MOB_ROBOTIC) : !(target.mob_biotypes & MOB_ORGANIC)) + return 0 + return artifact_capped_heal(target, amount) + +/datum/artifact_effect/heal/robotic + label_name = "Mends machines" + log_name = "Robo-heal" + possible_kinds = list(ARTIFACT_ENERGY_ELECTROMAGNETIC, ARTIFACT_ENERGY_PARTICLE) + robotic = TRUE + +/datum/artifact_effect/hurt + label_name = "Hurts" + log_name = "Hurt" + tier = ARTIFACT_TIER_UNCOMMON + minor = TRUE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_CONCENTRATED, ARTIFACT_ENERGY_ORGANIC) + var/robotic = FALSE + +/datum/artifact_effect/hurt/do_effect_touch(mob/living/user) + if(wound(user, 8)) + to_chat(user, span_warning(robotic ? "Your systems report sudden damage!" : "A painful discharge of energy strikes you!")) + +/datum/artifact_effect/hurt/do_effect_aura(seconds_per_tick) + for(var/mob/living/target as anything in living_in_range()) + if(wound(target, 0.5 * seconds_per_tick) && prob(10)) + to_chat(target, span_warning(robotic ? "Something nearby is stressing your plating." : "You feel a painful force radiating from something nearby.")) + +/datum/artifact_effect/hurt/do_effect_pulse(power) + for(var/mob/living/target as anything in living_in_range()) + if(wound(target, clamp(power * 0.3, 3, 12))) + to_chat(target, span_warning(robotic ? "A wave of energy buckles your plating!" : "A wave of energy tears at your skin!")) + +/// Hurts one mob, split between brute and burn. Returns TRUE if it took any. +/datum/artifact_effect/hurt/proc/wound(mob/living/target, amount) + if(target.stat == DEAD) + return FALSE + amount *= artifact_exposure(target) + if(amount <= 0) + return FALSE + if(iscarbon(target)) + var/before = target.getBruteLoss() + target.getFireLoss() + target.take_overall_damage(amount / 2, amount / 2, required_bodytype = robotic ? BODYTYPE_ROBOTIC : BODYTYPE_ORGANIC) + if(target.getBruteLoss() + target.getFireLoss() <= before) + return FALSE + else + if(robotic ? !(target.mob_biotypes & MOB_ROBOTIC) : !(target.mob_biotypes & MOB_ORGANIC)) + return FALSE + target.take_overall_damage(amount / 2, amount / 2) + log_harm(target) + return TRUE + +/datum/artifact_effect/hurt/robotic + label_name = "Damages machines" + log_name = "Robo-hurt" + possible_kinds = list(ARTIFACT_ENERGY_ELECTROMAGNETIC, ARTIFACT_ENERGY_PARTICLE) + robotic = TRUE diff --git a/voidcrew/modules/xenoarch/effects/light.dm b/voidcrew/modules/xenoarch/effects/light.dm new file mode 100644 index 00000000000..a66120473f6 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/light.dm @@ -0,0 +1,41 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/light.dm. +// Voidcrew: shines (or darkens) the whole time it is awake and costs no charge; any trigger; +// brightness kept to an ordinary lamp's range. + +/datum/artifact_effect/light + label_name = "Light" + log_name = "Light" + tier = ARTIFACT_TIER_COMMON + minor = TRUE + possible_kinds = list(ARTIFACT_ENERGY_CONCENTRATED, ARTIFACT_ENERGY_PARTICLE) + allowed_release_methods = list(ARTIFACT_RELEASE_AURA) + /// Light colour + var/light_tint = "#fff3d6" + /// Light power sign: 1 for light, -1 for darkness + var/light_sign = 1 + +/datum/artifact_effect/light/release_aura(seconds_per_tick) + return + +/datum/artifact_effect/light/do_effect_destroy() + return + +/datum/artifact_effect/light/light_override() + return list(range, light_sign * clamp(maximum_charges / 12, 0.8, 3), light_tint) + +/datum/artifact_effect/light/on_activate() + // An artifact refreshes its own light; anything else (a battery in a utilizer) is lit here. + if(holder && !istype(holder, /obj/machinery/artifact)) + var/list/glow = light_override() + holder.set_light(glow[1], glow[2], glow[3]) + +/datum/artifact_effect/light/on_deactivate() + if(holder && !istype(holder, /obj/machinery/artifact)) + holder.set_light(0) + +/datum/artifact_effect/light/darkness + label_name = "Darkness" + log_name = "Darkness" + possible_kinds = list(ARTIFACT_ENERGY_PARTICLE, ARTIFACT_ENERGY_BLUESPACE) + light_tint = COLOR_WHITE + light_sign = -1 diff --git a/voidcrew/modules/xenoarch/effects/noise.dm b/voidcrew/modules/xenoarch/effects/noise.dm new file mode 100644 index 00000000000..b0bf2c93d43 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/noise.dm @@ -0,0 +1,34 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/noise.dm. +// Voidcrew: eerie sounds only (Nova's list mixed in bike horns and sitcom laughter); any trigger +// (Nova fixed it to oxygen, which is gone); not harvestable. + +/datum/artifact_effect/noise + label_name = "Noise" + log_name = "Noise" + tier = ARTIFACT_TIER_COMMON + minor = TRUE + harvestable = FALSE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC) + allowed_release_methods = list(ARTIFACT_RELEASE_PULSE) + +/datum/artifact_effect/noise/do_effect_pulse(power) + var/static/list/noises = list( + 'sound/effects/hallucinations/wail.ogg', + 'sound/effects/hallucinations/far_noise.ogg', + 'sound/effects/hallucinations/veryfar_noise.ogg', + 'sound/effects/hallucinations/growl1.ogg', + 'sound/effects/hallucinations/growl2.ogg', + 'sound/effects/hallucinations/growl3.ogg', + 'sound/effects/hallucinations/radio_static.ogg', + 'sound/effects/screech.ogg', + 'sound/effects/gong.ogg', + 'sound/effects/clang.ogg', + 'sound/effects/magic/curse.ogg', + 'sound/ambience/misc/signal.ogg', + 'sound/machines/airlock/airlock_alien_prying.ogg', + 'sound/misc/scary_horn.ogg', + ) + playsound(holder, pick(noises), 60, TRUE, extrarange = 6) + +/datum/artifact_effect/noise/do_effect_destroy() + playsound(holder, 'sound/effects/hallucinations/wail.ogg', 80, TRUE, extrarange = 20, pressure_affected = FALSE) diff --git a/voidcrew/modules/xenoarch/effects/radiation.dm b/voidcrew/modules/xenoarch/effects/radiation.dm new file mode 100644 index 00000000000..5c518663dcf --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/radiation.dm @@ -0,0 +1,42 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/radiate.dm. +// Voidcrew: lower aura chances (Nova reached 100% per tick); exposure logged. + +/datum/artifact_effect/radiation + label_name = "Radiation" + log_name = "Radiation" + tier = ARTIFACT_TIER_RARE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PARTICLE, ARTIFACT_ENERGY_ORGANIC) + /// How hot it runs, 1 to 5 + var/intensity = 1 + +/datum/artifact_effect/radiation/setup() + intensity = rand(1, 5) + +/datum/artifact_effect/radiation/copy_settings_to(datum/artifact_effect/radiation/copy) + copy.intensity = intensity + +/datum/artifact_effect/radiation/do_effect_touch(mob/living/user) + var/turf/here = source_turf() + if(!here) + return + radiation_pulse(here, max_range = 1, threshold = RAD_MEDIUM_INSULATION, chance = 50) + log_harm(user) + +/datum/artifact_effect/radiation/do_effect_aura(seconds_per_tick) + var/turf/here = source_turf() + if(!here) + return + radiation_pulse(here, max_range = range, threshold = RAD_MEDIUM_INSULATION, chance = 4 + intensity * 2) + log_nearby() + +/datum/artifact_effect/radiation/do_effect_pulse(power) + var/turf/here = source_turf() + if(!here) + return + radiation_pulse(here, max_range = range, threshold = RAD_MEDIUM_INSULATION, chance = clamp(power, 10, 50)) + log_nearby() + +/datum/artifact_effect/radiation/proc/log_nearby() + for(var/mob/living/carbon/human/target in living_in_range()) + log_harm(target) diff --git a/voidcrew/modules/xenoarch/effects/sleepy.dm b/voidcrew/modules/xenoarch/effects/sleepy.dm new file mode 100644 index 00000000000..38a2a324fcc --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/sleepy.dm @@ -0,0 +1,35 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/sleepy.dm. +// Voidcrew: drowsiness first, then short sleeps (Nova slept you 25 seconds per touch). + +/datum/artifact_effect/sleepy + label_name = "Puts people to sleep" + log_name = "Sleep" + tier = ARTIFACT_TIER_UNCOMMON + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_ORGANIC) + +/datum/artifact_effect/sleepy/do_effect_touch(mob/living/user) + lull(user, 30 SECONDS, 4 SECONDS) + +/datum/artifact_effect/sleepy/do_effect_aura(seconds_per_tick) + for(var/mob/living/carbon/target in living_in_range()) + if(SPT_PROB(30, seconds_per_tick)) + lull(target, 4 SECONDS) + +/datum/artifact_effect/sleepy/do_effect_pulse(power) + for(var/mob/living/carbon/target in living_in_range()) + lull(target, power * 0.8 SECONDS, power >= 30 ? 3 SECONDS : 0) + +/// Makes `target` drowsy (up to 40 seconds) and maybe nod off. +/datum/artifact_effect/sleepy/proc/lull(mob/living/target, drowsy, nap = 0) + if(!iscarbon(target) || target.stat == DEAD) + return + var/exposure = artifact_exposure(target) + if(exposure <= 0) + return + if(prob(25)) + to_chat(target, span_notice(pick("You feel a yawn coming on.", "Your eyelids are heavy.", "You could do with a nap."))) + target.adjust_drowsiness_up_to(drowsy * exposure, 40 SECONDS) + if(nap) + target.Sleeping(nap * exposure) + log_harm(target) diff --git a/voidcrew/modules/xenoarch/effects/stun.dm b/voidcrew/modules/xenoarch/effects/stun.dm new file mode 100644 index 00000000000..e970bc04431 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/stun.dm @@ -0,0 +1,38 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/stun.dm. +// Voidcrew: Nova's touch put 200 stamina damage into one hand; touch now knocks you down briefly, +// auras sap stamina, bursts can floor a room. Logged like a weapon. + +/datum/artifact_effect/stun + label_name = "Knocks people down" + log_name = "Stun" + tier = ARTIFACT_TIER_UNCOMMON + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_ORGANIC) + +/datum/artifact_effect/stun/do_effect_touch(mob/living/user) + if(sap(user, 45, 2 SECONDS)) + to_chat(user, span_warning("A jolt runs up your arm and your legs give out.")) + +/datum/artifact_effect/stun/do_effect_aura(seconds_per_tick) + for(var/mob/living/target as anything in living_in_range()) + if(SPT_PROB(15, seconds_per_tick) && sap(target, 12)) + to_chat(target, span_warning("Your limbs go heavy for a moment.")) + +/datum/artifact_effect/stun/do_effect_pulse(power) + for(var/mob/living/target as anything in living_in_range()) + if(sap(target, clamp(power * 2, 20, 70), power >= 20 ? 1.5 SECONDS : 0)) + to_chat(target, span_warning("A wave of force knocks the wind out of you!")) + +/// Saps stamina and maybe knocks down. Returns TRUE if it took. +/datum/artifact_effect/stun/proc/sap(mob/living/target, stamina, knockdown = 0) + if(target.stat != CONSCIOUS || issilicon(target)) + return FALSE + var/exposure = artifact_exposure(target) + if(exposure <= 0) + return FALSE + target.adjust_confusion_up_to(3 SECONDS * exposure, 10 SECONDS) + target.adjustStaminaLoss(stamina * exposure) + if(knockdown) + target.Knockdown(knockdown * exposure) + log_harm(target) + return TRUE diff --git a/voidcrew/modules/xenoarch/effects/teleport.dm b/voidcrew/modules/xenoarch/effects/teleport.dm new file mode 100644 index 00000000000..f5f6bfbb237 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/teleport.dm @@ -0,0 +1,55 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/teleport.dm. +// Voidcrew: short hops onto open floor (never into walls, space or a chasm), through unforced +// do_teleport() so no-teleport areas and the zone guard still apply; no sparks, which light +// plasma; logged. + +/datum/artifact_effect/teleport + label_name = "Teleports" + log_name = "Teleport" + tier = ARTIFACT_TIER_RARE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_BLUESPACE) + +/datum/artifact_effect/teleport/do_effect_touch(mob/living/user) + if(hop(user, 6)) + to_chat(user, span_warning("The world folds, and you are somewhere else.")) + +/datum/artifact_effect/teleport/do_effect_aura(seconds_per_tick) + for(var/mob/living/target as anything in living_in_range()) + if(SPT_PROB(10, seconds_per_tick) && hop(target, range)) + to_chat(target, span_warning("You are displaced by a strange force!")) + +/datum/artifact_effect/teleport/do_effect_pulse(power) + var/turf/center = source_turf() + if(center) + new /obj/effect/temp_visual/circle_wave/bluespace(center) + for(var/mob/living/target as anything in living_in_range()) + if(hop(target, range + 2)) + to_chat(target, span_warning("You are displaced by a strange force!")) + +/// Hops `target` to a random open floor up to `distance` tiles away. Returns TRUE if it moved. +/datum/artifact_effect/teleport/proc/hop(mob/living/target, distance) + if(target.buckled || target.anchored) + return FALSE + var/exposure = artifact_exposure(target) + distance = round(distance * exposure) + if(distance < 1) + return FALSE + var/turf/origin = get_turf(target) + var/list/landings = list() + for(var/turf/open/spot in RANGE_TURFS(distance, origin)) + if(spot == origin || isspaceturf(spot) || isgroundlessturf(spot) || islava(spot)) + continue + if(spot.is_blocked_turf(exclude_mobs = TRUE)) + continue + landings += spot + if(!length(landings)) + return FALSE + var/turf/landing = pick(landings) + new /obj/effect/temp_visual/bluespace_fissure(origin) + if(!do_teleport(target, landing, precision = 0, no_effects = TRUE, channel = TELEPORT_CHANNEL_BLUESPACE)) + return FALSE + playsound(origin, 'sound/effects/magic/blink.ogg', 40, TRUE) + playsound(landing, 'sound/effects/phasein.ogg', 40, TRUE) + log_harm(target) + return TRUE diff --git a/voidcrew/modules/xenoarch/effects/temperature.dm b/voidcrew/modules/xenoarch/effects/temperature.dm new file mode 100644 index 00000000000..752c88dba9d --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/temperature.dm @@ -0,0 +1,84 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/temperature.dm. +// Voidcrew: gentle targets (a common minor effect makes a room uncomfortable, not lethal); bodies +// never pushed past the damage limits; planet air is never written (bodies only on planet turfs); +// no destroy burst. + +/datum/artifact_effect/temperature + tier = ARTIFACT_TIER_COMMON + minor = TRUE + allowed_release_methods = list(ARTIFACT_RELEASE_TOUCH, ARTIFACT_RELEASE_AURA, ARTIFACT_RELEASE_PULSE) + /// Air near it moves toward this + var/target_temp = T20C + var/target_low = T20C + var/target_high = T20C + /// Bodies never go past this (kept short of the damage limit) + var/body_limit = T20C + /// Kelvin per second the tile's air moves while the aura runs + var/air_rate = 8 + /// Kelvin per second bodies in range move while the aura runs + var/body_rate = 1.5 + /// Shown to a toucher + var/touch_message + +/datum/artifact_effect/temperature/setup() + target_temp = rand(target_low, target_high) + +/datum/artifact_effect/temperature/copy_settings_to(datum/artifact_effect/temperature/copy) + copy.target_temp = target_temp + +/datum/artifact_effect/temperature/do_effect_touch(mob/living/user) + to_chat(user, span_warning(touch_message)) + nudge_body(user, 15) + nudge_air(20) + +/datum/artifact_effect/temperature/do_effect_aura(seconds_per_tick) + nudge_air(air_rate * seconds_per_tick) + for(var/mob/living/target as anything in living_in_range()) + nudge_body(target, body_rate * seconds_per_tick) + +/datum/artifact_effect/temperature/do_effect_pulse(power) + nudge_air(clamp(power * 2, 10, 60)) + for(var/mob/living/target as anything in living_in_range()) + nudge_body(target, clamp(power / 3, 3, 12)) + +/datum/artifact_effect/temperature/do_effect_destroy() + return + +/// Moves the air on its own tile toward the target. Never planet air, never vacuum. +/datum/artifact_effect/temperature/proc/nudge_air(amount) + var/turf/open/here = source_turf() + if(!istype(here) || here.planetary_atmos || isspaceturf(here)) + return + var/datum/gas_mixture/air = here.return_air() + if(!air || air.total_moles() <= 0) + return + var/difference = target_temp - air.temperature + if(abs(difference) < 1) + return + air.temperature += clamp(difference, -amount, amount) + here.air_update_turf(FALSE, FALSE) + +/datum/artifact_effect/temperature/proc/nudge_body(mob/living/target, amount) + var/goal = target_temp > T20C ? min(target_temp, body_limit) : max(target_temp, body_limit) + var/difference = goal - target.bodytemperature + if(abs(difference) < 0.5) + return + target.adjust_bodytemperature(clamp(difference, -amount, amount) * artifact_exposure(target)) + +/datum/artifact_effect/temperature/heat + label_name = "Heat" + log_name = "Heat" + possible_kinds = list(ARTIFACT_ENERGY_CONCENTRATED, ARTIFACT_ENERGY_SYNTHESIS) + target_low = 310 + target_high = 345 + body_limit = BODYTEMP_HEAT_DAMAGE_LIMIT - 5 + touch_message = "A wave of heat runs up your arm." + +/datum/artifact_effect/temperature/cold + label_name = "Cold" + log_name = "Cold" + possible_kinds = list(ARTIFACT_ENERGY_SYNTHESIS, ARTIFACT_ENERGY_BLUESPACE) + target_low = 255 + target_high = 280 + body_limit = BODYTEMP_COLD_DAMAGE_LIMIT + 5 + touch_message = "A chill runs up your spine." diff --git a/voidcrew/modules/xenoarch/effects/tesla.dm b/voidcrew/modules/xenoarch/effects/tesla.dm new file mode 100644 index 00000000000..9d88b5f38a0 --- /dev/null +++ b/voidcrew/modules/xenoarch/effects/tesla.dm @@ -0,0 +1,26 @@ +// Ported from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/effects/tesla.dm. +// Voidcrew: ZAP_GENERATES_POWER removed, so tesla coils get nothing from it; weaker arcs (Nova's +// reached 90 burn); not harvestable; logged. + +/datum/artifact_effect/tesla + label_name = "Lightning" + log_name = "Tesla" + tier = ARTIFACT_TIER_EXTREME + harvestable = FALSE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ELECTROMAGNETIC, ARTIFACT_ENERGY_CONCENTRATED) + allowed_release_methods = list(ARTIFACT_RELEASE_PULSE) + /// Never ZAP_GENERATES_POWER: no running a ship off an artifact. + var/zap_flags = ZAP_OBJ_DAMAGE | ZAP_MOB_DAMAGE | ZAP_MOB_STUN + +/datum/artifact_effect/tesla/setup() + maximum_charges = max(maximum_charges, 15) + +/datum/artifact_effect/tesla/do_effect_pulse(power) + if(QDELETED(holder)) + return + var/reach = 3 + rand(0, 2) + playsound(holder, 'sound/effects/magic/lightningshock.ogg', 60, TRUE, extrarange = 5) + tesla_zap(source = holder, zap_range = reach, power = rand(12, 30) * 1000, cutoff = 1e4, zap_flags = zap_flags) + for(var/mob/living/target in range(reach, source_turf())) + log_harm(target) From 8c93939327407a8a1be5695866ba4ecdf92e40bf Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:06:10 -0800 Subject: [PATCH 04/20] Tidy artifact flavour text and brighten the idle glow --- voidcrew/modules/xenoarch/core/artifact_appearance.dm | 6 +++--- voidcrew/modules/xenoarch/effects/hallucination.dm | 2 +- voidcrew/modules/xenoarch/effects/teleport.dm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/voidcrew/modules/xenoarch/core/artifact_appearance.dm b/voidcrew/modules/xenoarch/core/artifact_appearance.dm index 6f578ebe3a5..347790a2883 100644 --- a/voidcrew/modules/xenoarch/core/artifact_appearance.dm +++ b/voidcrew/modules/xenoarch/core/artifact_appearance.dm @@ -146,7 +146,7 @@ GLOBAL_LIST_INIT(artifact_examine_notes, list( "Up close, the surface has a fine grain, like fingerprints.", "It doesn't ring when tapped. It doesn't make any sound at all.", "Dust doesn't seem to settle on it.", - "Your reflection in it is a moment late.", + "It smells faintly of ozone.", )) /// Lines for falling asleep: "[artifact] [line]" @@ -360,8 +360,8 @@ GLOBAL_LIST_INIT(artifact_examine_notes, list( size = 1.5 period = 2 SECONDS else - low_alpha = "14" - high_alpha = "3c" + low_alpha = "18" + high_alpha = "50" size = 1 period = 3 SECONDS if(flash) diff --git a/voidcrew/modules/xenoarch/effects/hallucination.dm b/voidcrew/modules/xenoarch/effects/hallucination.dm index 677ae52e793..49357b5df31 100644 --- a/voidcrew/modules/xenoarch/effects/hallucination.dm +++ b/voidcrew/modules/xenoarch/effects/hallucination.dm @@ -21,7 +21,7 @@ /datum/artifact_effect/hallucination/do_effect_pulse(power) for(var/mob/living/carbon/target in living_in_range()) if(dose(target, power SECONDS)) - to_chat(target, span_hypnophrase("The world tilts and blooms.")) + to_chat(target, span_hypnophrase("Everything starts to swim.")) /datum/artifact_effect/hallucination/proc/dose(mob/living/target, duration) if(!iscarbon(target) || target.stat == DEAD) diff --git a/voidcrew/modules/xenoarch/effects/teleport.dm b/voidcrew/modules/xenoarch/effects/teleport.dm index f5f6bfbb237..5b31e1ed267 100644 --- a/voidcrew/modules/xenoarch/effects/teleport.dm +++ b/voidcrew/modules/xenoarch/effects/teleport.dm @@ -12,7 +12,7 @@ /datum/artifact_effect/teleport/do_effect_touch(mob/living/user) if(hop(user, 6)) - to_chat(user, span_warning("The world folds, and you are somewhere else.")) + to_chat(user, span_warning("You're suddenly standing somewhere else!")) /datum/artifact_effect/teleport/do_effect_aura(seconds_per_tick) for(var/mob/living/target as anything in living_in_range()) From a01a027cd52d61cc6e54c106507c246df54cf409 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:50:42 -0800 Subject: [PATCH 05/20] Give the specimen crate its own art and a lid tag A lead-grey recolour of the plain crate with padded straps and a stencilled lid. A shut crate holding a find shows its field tag. --- .../modules/xenoarch/icons/specimen_crate.dmi | Bin 0 -> 1131 bytes .../modules/xenoarch/trade/specimen_crate.dm | 22 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 voidcrew/modules/xenoarch/icons/specimen_crate.dmi diff --git a/voidcrew/modules/xenoarch/icons/specimen_crate.dmi b/voidcrew/modules/xenoarch/icons/specimen_crate.dmi new file mode 100644 index 0000000000000000000000000000000000000000..8820a1096e6bf0a990cbf984a057746ef9f0233d GIT binary patch literal 1131 zcmeAS@N?(olHy`uVBq!ia0vp^4nUm1!3HGP9xZtRq}r=OB1&9Ri<65o3raHc^B5Q^ z<^+co6qSDe5?t`{>k}<+U9EFx&IfM@HMnT};E~RGAI*~tMLoScER2JUFB^L~7>UIk zRqa$=>98!Q&@rnhEiY@Hka)URTA*RTi3#1tYc&kbMGqYdm=W*L^61WyJ!iIDc_h@t zbvn2>C@8o<6KK`fV#aE2h6^SRLg^K4a~K$y=X<(1hE&XXJICHbI#A~L{-1?c_~trI z+~(FkNikz$(2~i{%Xx&l7FbNV;Mvt2%&uF)c~o %cWxegcToP1M9syb34XgC_s@^mwkYmC>l;r67LLWmdDCNWa~*%S zJTU5ikKfN7v-rN=xt#FE=trJPWAk%%rS%5>j# z&bTs=i1%yHP&C+UuFhm!c1{x=nYZ81~L%D_bG_H16LM=AD9{YPrswI~ysr z_-d_<6#FT`>{?@sm+#(B7u>-j6Uuj`_(0h;t0n6B;-Qfi_4hX=s^2|vqT`de2*;s| zKh8H#Z2u8;B0jpYeBHTyTXJrAeqSLJ`0rKW_qZi*tz9?o>I;7G^2z39@|oMsjjpFG zPn+!f(r8YOvERSB8(tf~eU<&JEo*7gRGGE$|I?oST5s{~>tWC7*BR8`Y~o(LTdTA6 zv#0mpKaXBZ|FwR3>u+}7-o%GD{U0=jR!q-(u}1W6*oQ;=udUd)>tj%=;D)q~l2#YL zUa|*8XiLxbqw%_WFXL=FKD_PP&$Rja@2B=x>SN<@L^fvh6D{&&+QSH)ZHL%Z)D&d+ zUN2w1Jpbo|Vmqmm;@z&clTSvZ{FwFn{JC=>(YBImQ@vi6MHX9Mzgc?rxm1kO?6Yxm zk3as{wrOclr+d$ >)x$fLAf! !&d+H7yjc`e0qc7oA$Ogg>PmvPCqTE zsOV5wyfgF9vZL?!`#R_@_`Fw+<>7?;vL9yGU(*pdx}fH>2e9;D@O1TaS?83{1OVFL B5`zE$ literal 0 HcmV?d00001 diff --git a/voidcrew/modules/xenoarch/trade/specimen_crate.dm b/voidcrew/modules/xenoarch/trade/specimen_crate.dm index 5242834cb0d..3bcd9203c23 100644 --- a/voidcrew/modules/xenoarch/trade/specimen_crate.dm +++ b/voidcrew/modules/xenoarch/trade/specimen_crate.dm @@ -3,13 +3,24 @@ * * A heavy crate built to hold one large find. Effects stop while it is shut inside (an * artifact off a turf never stirs), so a crew can haul a dangerous find without it going off. + * Any shut crate gets a find past an outpost checkpoint and up to a buyer; this one takes only + * the find and small things, never people or other machines, and shows the find's field tag on + * the lid so a hold full of crates can be told apart. + * + * Art: a recolour of tg's plain crate (icons/obj/storage/crates.dmi "crate"/"crateopen"), lead + * grey with padded straps; "manifest" and "welded" are tg's own, copied so crate overlays line up. */ /obj/structure/closet/crate/specimen name = "specimen crate" desc = "A padded, lead-lined crate big enough for one large find." + icon = 'voidcrew/modules/xenoarch/icons/specimen_crate.dmi' + icon_state = "specimen" + base_icon_state = "specimen" allow_dense = TRUE allow_objects = TRUE storage_capacity = 10 + // Its own sprite sheet holds no other crate's states + paint_jobs = null /obj/structure/closet/crate/specimen/insertion_allowed(atom/movable/thing) // The only dense thing it takes is one artifact. No people, no other machines. @@ -21,3 +32,14 @@ if(ismob(thing) || (isobj(thing) && thing.density)) return FALSE return ..() + +/obj/structure/closet/crate/specimen/examine(mob/user) + . = ..() + if(opened) + return + var/obj/machinery/artifact/find = locate() in contents + if(!find) + return + . += "It sits heavy on its straps." + if(find.is_dug()) + . += "A field tag clipped to the lid reads [find.serial]." From 24a561c4a17bd7d86248c4b97e137abc55b63136 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:50:42 -0800 Subject: [PATCH 06/20] Sell dig finds to Barnaby, Boffin and Vex Each buyer gets a large-find row and (Barnaby, Boffin) a curio row on their wanted ledger. A large find sells when the seller hauls it to the counter, loose or in a shut crate: the trader looks it over, pays the sale value into the usual account, hands over a receipt in their own hand and says what they made of it. Vex adds a voucher for an extreme find. Undug finds are refused. Traders remark on finds hauled in. Outpost checkpoints turn back a loose find on the way in, with a line from the guard. Sales record the artifact_sold metric and send COMSIG_ARTIFACT_SOLD. --- .../unit_tests/voidcrew_xenoarch_trade.dm | 271 +++++ voidcrew/modules/xenoarch/trade/buyers.dm | 941 +++++++++++++++++- voidcrew/modules/xenoarch/trade/checkpoint.dm | 79 +- voidcrew/modules/xenoarch/trade/metrics.dm | 23 +- 4 files changed, 1311 insertions(+), 3 deletions(-) diff --git a/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm b/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm index 46dc0d06d1f..35bd1273292 100644 --- a/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm +++ b/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm @@ -1 +1,272 @@ // Xenoarchaeology tests: trade. +// +// Test files compile before voidcrew/_DEFINES, so the values below are literals. They mirror +// voidcrew/_DEFINES/xenoarch.dm and the part-local defines in xenoarch/trade/: +// bands (ZONE_*): green 1, yellow 2, red 3 +// tiers: common 1, uncommon 2, rare 3, extreme 4 +// COMSIG_ARTIFACT_SOLD "artifact_sold" +// XENOARCH_FIND_DEMAND 3, XENOARCH_CURIO_DEMAND 6 +// buyer line keys "perfect", "close", "wrong", "blank", "live" +// checkpoint refusal for a loose find "xenoarch_loose_find" + +/// Shared helpers for the trade tests; runs nothing itself. +/datum/unit_test/voidcrew_xenoarch_trade + abstract_type = /datum/unit_test/voidcrew_xenoarch_trade + +/// A seller with a bank card in hand, the way the outpost ledger finds an account without a crew. +/datum/unit_test/voidcrew_xenoarch_trade/proc/make_seller(datum/bank_account/account) + var/mob/living/carbon/human/consistent/seller = allocate(/mob/living/carbon/human/consistent) + var/obj/item/card/id/advanced/card = allocate(/obj/item/card/id/advanced) + qdel(card.registered_account) + card.registered_account = account + seller.put_in_hands(card) + return seller + +/// Deletes the receipts and vouchers a sale left in hand or underfoot. +/datum/unit_test/voidcrew_xenoarch_trade/proc/tidy(mob/living/seller) + for(var/obj/item/paper/xenoarch_receipt/receipt in near_seller(seller)) + qdel(receipt) + for(var/obj/item/stack/trade_voucher/chits in near_seller(seller)) + qdel(chits) + +/// Everything the seller holds, plus everything at their feet. +/datum/unit_test/voidcrew_xenoarch_trade/proc/near_seller(mob/living/seller) + var/turf/feet = get_turf(seller) + return seller.get_all_contents() + feet.contents + +/// Barnaby, Boffin and Vex buy finds; Vex takes no curios; nobody else buys either. +/datum/unit_test/voidcrew_xenoarch_trade/buyers/Run() + var/list/expected = list( + /datum/outpost_shop/general = list(TRUE, TRUE), + /datum/outpost_shop/vendor/skunkworks = list(TRUE, TRUE), + /datum/outpost_shop/black_market = list(TRUE, FALSE), + /datum/outpost_shop/outfitter = list(FALSE, FALSE), + /datum/outpost_shop/vendor/dregs_bar = list(FALSE, FALSE), + ) + for(var/shop_type in expected) + var/datum/outpost_shop/shop = allocate(shop_type) + var/list/wants = expected[shop_type] + var/datum/shop_buyback/xenoarch_find/find_row = locate() in shop.buybacks + var/datum/shop_buyback/xenoarch_curio/curio_row = locate() in shop.buybacks + TEST_ASSERT_EQUAL(!!find_row, wants[1], "[shop_type] large-find row") + TEST_ASSERT_EQUAL(!!curio_row, wants[2], "[shop_type] curio row") + if(find_row) + TEST_ASSERT(find_row.buyer == shop.xenoarch_buyer, "[shop_type]'s find row has no buyer") + TEST_ASSERT_EQUAL(find_row.demand, 3, "[shop_type] wants the wrong number of large finds") + TEST_ASSERT_NULL(find_row.item_path, "[shop_type]'s find row has an item path, so Pike's ledger would sell finds remotely") + TEST_ASSERT(find_row.get_ui_icon(), "[shop_type]'s find row has no picture") + if(curio_row) + TEST_ASSERT_EQUAL(curio_row.demand, 6, "[shop_type] wants the wrong number of curios") + TEST_ASSERT(curio_row.get_ui_icon(), "[shop_type]'s curio row has no picture") + // A convoy tops the rows up like any other ledger row + if(find_row) + find_row.demand = 0 + shop.convoy_restock() + TEST_ASSERT(find_row.demand > 0, "[shop_type]'s find demand never comes back") + TEST_ASSERT_EQUAL(xenoarch_credits_text(1125), "1,125 cr", "credit formatting") + TEST_ASSERT_EQUAL(xenoarch_credits_text(250), "250 cr", "credit formatting") + TEST_ASSERT_EQUAL(xenoarch_credits_text(1000000), "1,000,000 cr", "credit formatting") + +/// A sale pays the sale value once, takes the find, prints a receipt and tells the artifact. +/datum/unit_test/voidcrew_xenoarch_trade/sale + /// Arguments of the last COMSIG_ARTIFACT_SOLD seen + var/list/sold_args + +/datum/unit_test/voidcrew_xenoarch_trade/sale/proc/on_sold(datum/source, credits, vouchers, mob/seller) + SIGNAL_HANDLER + sold_args = list(credits, vouchers, seller) + +/datum/unit_test/voidcrew_xenoarch_trade/sale/Run() + var/datum/outpost_shop/general/shop = allocate(/datum/outpost_shop/general) + var/datum/shop_buyback/xenoarch_find/row = locate() in shop.buybacks + var/datum/bank_account/account = allocate(/datum/bank_account, "Xenoarch sale test", null, 1, FALSE) + var/mob/living/carbon/human/seller = make_seller(account) + + // Never dug: refused, nothing moves + var/obj/machinery/artifact/stray = allocate(/obj/machinery/artifact, get_step(seller, EAST)) + stray.replace_effects(/datum/artifact_effect/heal, null, 2) + TEST_ASSERT_EQUAL(row.settle(stray, seller, account, null), 0, "an undug find sold") + TEST_ASSERT(!QDELETED(stray), "an undug find was taken without pay") + TEST_ASSERT_EQUAL(account.account_balance, 0, "an undug find paid out") + TEST_ASSERT_EQUAL(row.demand, 3, "a refused sale used up demand") + qdel(stray) + + // Dug in yellow, labelled right: full price + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, get_step(seller, EAST), 2) + find.replace_effects(/datum/artifact_effect/heal, null, 2) + find.apply_label(new /datum/artifact_label("Heals", artifact_trigger_name(find.main_effect.trigger), "None")) + var/expected = artifact_sale_value(find) + TEST_ASSERT_EQUAL(expected, 675, "a perfectly labelled yellow uncommon find is not worth 675") + TEST_ASSERT(shop.xenoarch_buyer.closing_line(find) in shop.xenoarch_buyer.lines["perfect"], "Barnaby didn't praise a perfect label") + var/serial = find.serial + RegisterSignal(find, "artifact_sold", PROC_REF(on_sold)) + TEST_ASSERT_EQUAL(row.settle(find, seller, account, null), expected, "the sale paid the wrong amount") + TEST_ASSERT_EQUAL(account.account_balance, expected, "the account got the wrong amount") + TEST_ASSERT(QDELETED(find), "the sold find stayed in the world") + TEST_ASSERT_EQUAL(row.demand, 2, "a sale did not use up demand") + TEST_ASSERT_NOTNULL(sold_args, "COMSIG_ARTIFACT_SOLD was not sent") + TEST_ASSERT_EQUAL(sold_args[1], expected, "COMSIG_ARTIFACT_SOLD carried the wrong credits") + TEST_ASSERT_EQUAL(sold_args[2], 0, "Barnaby paid a voucher") + TEST_ASSERT_EQUAL(sold_args[3], seller, "COMSIG_ARTIFACT_SOLD named the wrong seller") + var/obj/item/paper/xenoarch_receipt/receipt = locate() in near_seller(seller) + TEST_ASSERT_NOTNULL(receipt, "no receipt was handed over") + TEST_ASSERT(findtext(receipt.name, serial), "the receipt doesn't name the find") + TEST_ASSERT(!(locate(/obj/item/stack/trade_voucher) in near_seller(seller)), "Barnaby handed over a voucher") + tidy(seller) + + // Selling it again is impossible: it is gone + TEST_ASSERT_EQUAL(row.settle(find, seller, account, null), 0, "a sold find sold twice") + TEST_ASSERT_EQUAL(account.account_balance, expected, "a second sale of one find paid") + + // Out of demand: refused + var/obj/machinery/artifact/late = allocate(/obj/machinery/artifact, get_step(seller, EAST), 1) + row.demand = 0 + TEST_ASSERT_EQUAL(row.settle(late, seller, account, null), 0, "a buyer with no demand left bought a find") + TEST_ASSERT(!QDELETED(late), "a refused find was taken") + + // No account: refused + row.demand = 3 + TEST_ASSERT_EQUAL(row.settle(late, seller, null, null), 0, "a find sold with nowhere to pay") + TEST_ASSERT(!QDELETED(late), "a find was taken with nowhere to pay") + +/// Vex pays one voucher on top for an extreme main effect, and only for that. +/datum/unit_test/voidcrew_xenoarch_trade/vex_voucher/Run() + var/datum/outpost_shop/black_market/shop = allocate(/datum/outpost_shop/black_market) + var/datum/shop_buyback/xenoarch_find/row = locate() in shop.buybacks + var/datum/bank_account/account = allocate(/datum/bank_account, "Xenoarch voucher test", null, 1, FALSE) + var/mob/living/carbon/human/seller = make_seller(account) + + var/obj/machinery/artifact/plain = allocate(/obj/machinery/artifact, get_step(seller, EAST), 3) + plain.replace_effects(/datum/artifact_effect/heal, null, 3) + TEST_ASSERT_EQUAL(shop.xenoarch_buyer.vouchers_for(plain), 0, "Vex pays a voucher for an uncommon find") + TEST_ASSERT(row.settle(plain, seller, account, null) > 0, "Vex refused a dug red find") + TEST_ASSERT(!(locate(/obj/item/stack/trade_voucher) in near_seller(seller)), "Vex handed over a voucher for an uncommon find") + tidy(seller) + + var/obj/machinery/artifact/live = allocate(/obj/machinery/artifact, get_step(seller, EAST), 3) + live.replace_effects(/datum/artifact_effect/tesla, null, 3) + TEST_ASSERT_EQUAL(live.main_effect.tier, 4, "the tesla effect is no longer extreme; pick another extreme effect for this test") + TEST_ASSERT(shop.xenoarch_buyer.closing_line(live) in shop.xenoarch_buyer.lines["live"], "Vex didn't remark on an extreme find") + var/before = account.account_balance + var/expected = artifact_sale_value(live) + TEST_ASSERT_EQUAL(expected, 560, "an unlabelled red extreme find is not worth 560") + TEST_ASSERT_EQUAL(row.settle(live, seller, account, null), expected, "Vex paid the wrong credits for an extreme find") + TEST_ASSERT_EQUAL(account.account_balance - before, expected, "the account got the wrong amount") + var/vouchers = 0 + for(var/obj/item/stack/trade_voucher/chits in near_seller(seller)) + vouchers += chits.amount + TEST_ASSERT_EQUAL(vouchers, 1, "Vex didn't pay exactly one voucher for an extreme find") + tidy(seller) + + // The others pay credits only, extreme or not + var/datum/outpost_shop/general/halcyon = allocate(/datum/outpost_shop/general) + var/obj/machinery/artifact/other = allocate(/obj/machinery/artifact, get_step(seller, EAST), 3) + other.replace_effects(/datum/artifact_effect/tesla, null, 3) + TEST_ASSERT_EQUAL(halcyon.xenoarch_buyer.vouchers_for(other), 0, "Barnaby pays vouchers") + +/// Only a find the seller hauls counts: pulled loose, or in a shut crate they pull. +/datum/unit_test/voidcrew_xenoarch_trade/hauling/Run() + var/datum/outpost_shop/vendor/skunkworks/shop = allocate(/datum/outpost_shop/vendor/skunkworks) + var/datum/shop_buyback/xenoarch_find/row = locate() in shop.buybacks + var/datum/bank_account/account = allocate(/datum/bank_account, "Xenoarch hauling test", null, 1, FALSE) + var/mob/living/carbon/human/seller = make_seller(account) + var/turf/beside = get_step(seller, EAST) + + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, beside, 2) + TEST_ASSERT_EQUAL(length(row.sellable_finds(seller)), 0, "a find nobody pulls counted as hauled") + TEST_ASSERT_EQUAL(row.count_carried_units(seller), 0, "a find nobody pulls showed on the ledger") + seller.start_pulling(find) + TEST_ASSERT(seller.pulling == find, "the seller could not pull the find") + TEST_ASSERT_EQUAL(length(row.sellable_finds(seller)), 1, "a pulled find did not count") + seller.stop_pulling() + + var/obj/structure/closet/crate/specimen/crate = allocate(/obj/structure/closet/crate/specimen, beside) + if(crate.opened) + crate.close() + find.forceMove(crate) + TEST_ASSERT(find.loc == crate, "the find would not go in the crate") + TEST_ASSERT(findtext(jointext(crate.examine(seller), " "), find.serial), "the crate lid doesn't show the find's tag") + seller.start_pulling(crate) + TEST_ASSERT_EQUAL(length(row.sellable_finds(seller)), 1, "a find in a pulled crate did not count") + TEST_ASSERT_EQUAL(xenoarch_find_holder(find), crate, "a crated find's holder is not its crate") + crate.open() + TEST_ASSERT_EQUAL(length(row.sellable_finds(seller)), 0, "an open crate still counted as holding the find") + seller.stop_pulling() + + // A plain crate works too + var/obj/structure/closet/crate/plain = allocate(/obj/structure/closet/crate, beside) + if(plain.opened) + plain.close() + find.forceMove(plain) + seller.start_pulling(plain) + TEST_ASSERT_EQUAL(length(row.sellable_finds(seller)), 1, "a find in a pulled plain crate did not count") + seller.stop_pulling() + + // An undug find shows as hauled but never sellable + var/obj/machinery/artifact/stray = allocate(/obj/machinery/artifact, get_step(seller, NORTH)) + seller.start_pulling(stray) + TEST_ASSERT_EQUAL(length(xenoarch_hauled_finds(seller)), 1, "an undug pulled find wasn't hauled") + TEST_ASSERT_EQUAL(length(row.sellable_finds(seller)), 0, "an undug find was sellable") + TEST_ASSERT_NOTNULL(row.get_denial_reason(seller), "an undug find could be sold") + seller.stop_pulling() + + // The find row never matches an inventory item (plunder appraisal, Pike's ledger) + var/obj/item/relic/relic = allocate(/obj/item/relic) + TEST_ASSERT(!row.matches(relic), "the large-find row matched an item") + +/// Curios sell only with the dug mark, at their own price; only Boffin takes strange objects. +/datum/unit_test/voidcrew_xenoarch_trade/curios/Run() + var/datum/outpost_shop/general/halcyon = allocate(/datum/outpost_shop/general) + var/datum/outpost_shop/vendor/skunkworks/skunkworks = allocate(/datum/outpost_shop/vendor/skunkworks) + var/datum/shop_buyback/xenoarch_curio/barnaby_row = locate() in halcyon.buybacks + var/datum/shop_buyback/xenoarch_curio/boffin_row = locate() in skunkworks.buybacks + + var/obj/item/relic/maint_relic = allocate(/obj/item/relic) + TEST_ASSERT(!boffin_row.matches(maint_relic), "an unmarked strange object passed as a find") + var/obj/item/relic/dug_relic = allocate(/obj/item/relic) + TEST_ASSERT(xenoarch_mark_curio(dug_relic, 200), "could not mark a strange object as dug") + TEST_ASSERT(boffin_row.matches(dug_relic), "Boffin refused a dug strange object") + TEST_ASSERT(!barnaby_row.matches(dug_relic), "Barnaby took a strange object") + TEST_ASSERT(!xenoarch_mark_curio(maint_relic, 0), "a curio was marked as worth nothing") + + var/datum/bank_account/account = allocate(/datum/bank_account, "Xenoarch curio test", null, 1, FALSE) + var/mob/living/carbon/human/seller = make_seller(account) + var/obj/item/statuebust/shard = allocate(/obj/item/statuebust) + xenoarch_mark_curio(shard, 50) + seller.put_in_hands(shard) + TEST_ASSERT_EQUAL(barnaby_row.count_carried_units(seller), 1, "a carried curio didn't count") + TEST_ASSERT_NULL(barnaby_row.get_denial_reason(seller), "a carried curio was refused") + TEST_ASSERT(barnaby_row.try_sell(seller, null), "a curio didn't sell") + TEST_ASSERT_EQUAL(account.account_balance, 50, "a curio paid the wrong amount") + TEST_ASSERT(QDELETED(shard), "a sold curio stayed in hand") + TEST_ASSERT_EQUAL(barnaby_row.demand, 5, "a curio sale did not use up demand") + TEST_ASSERT(!barnaby_row.try_sell(seller, null), "a curio sold that wasn't there") + +/// The checkpoint turns back a loose find, lets a crated one through, and never stops one leaving. +/datum/unit_test/voidcrew_xenoarch_trade/checkpoint/Run() + var/datum/outpost_checkpoint/checkpoint = allocate(/datum/outpost_checkpoint) + var/turf/chamber = run_loc_floor_bottom_left + checkpoint.chamber_turfs = list(chamber) + TEST_ASSERT_EQUAL(length(checkpoint.inspect_chamber()), 0, "an empty chamber refused something") + + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, chamber, 1) + var/list/refused = checkpoint.inspect_chamber() + TEST_ASSERT_EQUAL(refused[find], "xenoarch_loose_find", "a loose find walked through the checkpoint") + TEST_ASSERT(checkpoint.refusing_only_loose_finds(), "a loose find read as something else") + + checkpoint.exit_request = TRUE + var/list/leaving = checkpoint.inspect_chamber() + TEST_ASSERT(!leaving[find], "a find was stopped on its way out") + checkpoint.exit_request = FALSE + + var/obj/structure/closet/crate/specimen/crate = allocate(/obj/structure/closet/crate/specimen, chamber) + if(crate.opened) + crate.close() + find.forceMove(crate) + TEST_ASSERT_EQUAL(length(checkpoint.inspect_chamber()), 0, "a crated find was turned back") + + var/datum/outpost_shop/vendor/checkpoint/halcyon/desk = allocate(/datum/outpost_shop/vendor/checkpoint/halcyon) + TEST_ASSERT(desk.get_line("xenoarch_loose_find") in desk.xenoarch_loose_lines, "Hollis has nothing to say about a loose find") + TEST_ASSERT(desk.get_line("checkpoint_pass"), "Hollis lost his ordinary lines") + var/obj/machinery/outpost_checkpoint_sensor/sensor = allocate(/obj/machinery/outpost_checkpoint_sensor) + TEST_ASSERT(sensor.machine_line("xenoarch_loose_find"), "the wall scanner has nothing to say about a loose find") diff --git a/voidcrew/modules/xenoarch/trade/buyers.dm b/voidcrew/modules/xenoarch/trade/buyers.dm index 8577a192a25..5fb61281f84 100644 --- a/voidcrew/modules/xenoarch/trade/buyers.dm +++ b/voidcrew/modules/xenoarch/trade/buyers.dm @@ -1 +1,940 @@ -// Outpost traders buying large finds and curios. +/** + * # Outpost buyers for dig finds + * + * Barnaby at Halcyon, Boffin at the Quartermain's Skunkworks and Vex at the Undertow buy what + * comes out of the old dig sites. They are the outposts' own traders: this file gives each one a + * buyer's voice (/datum/xenoarch_buyer) and two rows on their wanted ledger, so a find sells from + * the same Sell tab as everything else they buy. + * + * - Large finds are machinery, so the stock ledger (which only takes inventory items) can't hold + * them. /datum/shop_buyback/xenoarch_find takes the find the seller is pulling, loose or in a + * shut crate, once it is at the counter. The trader looks it over while the seller waits, then + * pays artifact_sale_value() into the account every other sale pays (get_shop_buyback_account()), + * prints a receipt and says what they made of it. The sale is final: nothing is quoted, so a + * label can't be tried out on the buyer. + * - Only finds stamped as dug sell. Vex pays a voucher on top for an extreme main effect. + * - Curios (/datum/shop_buyback/xenoarch_curio) are ordinary items marked as dug finds with + * xenoarch_mark_curio(); Barnaby and Boffin take them, and only Boffin takes strange objects. + * - Each buyer takes XENOARCH_FIND_DEMAND large finds and XENOARCH_CURIO_DEMAND curios at a time, + * topped up by the convoy like any other ledger row (shop.dm convoy_restock()). + * - A buyer notices a find being hauled up to the counter and says so, once per find. + * - Selling earns no reputation; that comes from jobs (trader_favor.dm). + */ + +/// Large finds each buyer takes before the next convoy +#define XENOARCH_FIND_DEMAND 3 +/// Curios each buyer takes before the next convoy +#define XENOARCH_CURIO_DEMAND 6 +/// How far from the trader a hauled find may be and still count as at the counter +#define XENOARCH_COUNTER_REACH 3 +/// How long the trader looks a find over before paying +#define XENOARCH_INSPECT_TIME (2.5 SECONDS) +/// Least time between the starts of two inspections, so the Sell button can't be used to make the trader spam +#define XENOARCH_INSPECT_COOLDOWN (4 SECONDS) +/// How far away a trader notices a find being hauled in +#define XENOARCH_NOTICE_RANGE 4 +/// Least time between two "what have you got there" remarks +#define XENOARCH_NOTICE_COOLDOWN (30 SECONDS) +/// How many finds a trader remembers having remarked on +#define XENOARCH_NOTICE_MEMORY 20 + +// Line keys for /datum/xenoarch_buyer/var/lines +/// Spoken when a find is hauled up +#define XENOARCH_LINE_NOTICE "notice" +/// Emotes while looking over a loose find; %THING% is the find +#define XENOARCH_LINE_INSPECT "inspect" +/// Emotes while looking into a crate; %THING% is the crate +#define XENOARCH_LINE_INSPECT_CRATED "inspect_crated" +/// Spoken while looking over a find that came out of the rock cracked +#define XENOARCH_LINE_CRACKED "cracked" +/// Spoken while looking over a find that has been drained +#define XENOARCH_LINE_TAPPED "tapped" +/// Spoken on paying for a find labelled right on every line +#define XENOARCH_LINE_PERFECT "perfect" +/// Spoken on paying for a find labelled mostly right +#define XENOARCH_LINE_CLOSE "close" +/// Spoken on paying for a find labelled mostly wrong +#define XENOARCH_LINE_WRONG "wrong" +/// Spoken on paying for a find with no label +#define XENOARCH_LINE_BLANK "blank" +/// Spoken on paying for a find with an extreme main effect +#define XENOARCH_LINE_LIVE "live" +/// Spoken when the seller walks off mid-inspection +#define XENOARCH_LINE_WALKED "walked" + +// ========================================================================= +// HAULING +// ========================================================================= + +/// The large find in `thing`: the artifact itself, or the first artifact in a shut crate. Null otherwise. +/proc/xenoarch_find_in(atom/movable/thing) + if(istype(thing, /obj/machinery/artifact)) + return thing + if(istype(thing, /obj/structure/closet)) + var/obj/structure/closet/box = thing + if(!box.opened) + return locate(/obj/machinery/artifact) in box.contents + return null + +/// Every large find `user` is hauling: the artifact they pull, or those in the shut crate they pull. +/proc/xenoarch_hauled_finds(mob/living/user) + . = list() + var/atom/movable/hauled = user?.pulling + if(istype(hauled, /obj/machinery/artifact)) + . += hauled + else if(istype(hauled, /obj/structure/closet)) + var/obj/structure/closet/box = hauled + if(!box.opened) + for(var/obj/machinery/artifact/find in box.contents) + . += find + +/// What a hauled find rides in: its crate, or the find itself when loose. +/proc/xenoarch_find_holder(obj/machinery/artifact/find) + if(!find) + return null + return isturf(find.loc) ? find : find.loc + +/// "1,125 cr" +/proc/xenoarch_credits_text(amount) + var/digits = num2text(round(abs(amount)), 12) + var/grouped = "" + while(length(digits) > 3) + grouped = ",[copytext(digits, -3)][grouped]" + digits = copytext(digits, 1, -3) + return "[amount < 0 ? "-" : ""][digits][grouped] cr" + +// ========================================================================= +// THE BUYERS +// ========================================================================= + +/** + * # Dig-find buyer + * + * The buying side of one outpost trader: their voice for finds, what they take, and how their + * receipt reads. One per shop, made by the shop (see /datum/outpost_shop/New below). + */ +/datum/xenoarch_buyer + /// The shop this buyer works for + var/datum/outpost_shop/shop + /// Vouchers paid on top of credits for a find whose main effect is extreme + var/extreme_vouchers = 0 + /// Buys curios at all + var/buys_curios = TRUE + /// Takes tg's strange objects among the curios + var/takes_strange_objects = FALSE + /// Large-find ledger row: name, description and picture + var/find_name = "dig pieces" + var/find_desc = "Large finds out of the old dig sites." + var/find_icon = 'voidcrew/modules/xenoarch/icons/artifacts.dmi' + var/find_icon_state = "idol" + /// Curio ledger row: name, description and picture + var/curio_name = "curios" + var/curio_desc = "Small finds out of the old dig sites." + var/curio_icon = 'icons/obj/mining.dmi' + var/curio_icon_state = "skull" + /// Receipt heading, subheading, sign-off, hand, ink and paper stamp + var/receipt_title = "RECEIPT" + var/receipt_subtitle + var/receipt_signoff + var/receipt_font = PEN_FONT + var/receipt_ink = "#202020" + var/receipt_stamp + /// Heard while the buyer looks a find over + var/inspect_sound = 'sound/items/handling/paper_pickup.ogg' + /// Speech and emotes, by XENOARCH_LINE_* key + var/list/lines = list() + /// Extra idle chatter added to the shop's own + var/list/idle_lines = list() + /// Serials already remarked on, oldest first + var/list/noticed = list() + /// The find being looked over right now + var/datum/weakref/inspecting + /// When the buyer may next remark on a hauled find + COOLDOWN_DECLARE(notice_cooldown) + /// When the buyer may next start looking a find over + COOLDOWN_DECLARE(inspect_cooldown) + +/datum/xenoarch_buyer/New(datum/outpost_shop/shop) + . = ..() + src.shop = shop + +/datum/xenoarch_buyer/Destroy() + shop = null + inspecting = null + return ..() + +/// Ledger rows this buyer adds to their shop. +/datum/xenoarch_buyer/proc/ledger_types() + . = list(/datum/shop_buyback/xenoarch_find) + if(buys_curios) + . += /datum/shop_buyback/xenoarch_curio + +/// The trader at the counter, if the interior has one. +/datum/xenoarch_buyer/proc/trader() + return shop?.trader_npc + +/// Looking a find over right now (a live find, not one sold or lost meanwhile), or only just done with one. +/datum/xenoarch_buyer/proc/is_busy() + var/obj/machinery/artifact/find = inspecting?.resolve() + if(QDELETED(find)) + inspecting = null + return !COOLDOWN_FINISHED(src, inspect_cooldown) + return TRUE + +/// Vouchers this buyer adds for `find`. +/datum/xenoarch_buyer/proc/vouchers_for(obj/machinery/artifact/find) + if(extreme_vouchers > 0 && find?.main_effect?.tier == ARTIFACT_TIER_EXTREME) + return extreme_vouchers + return 0 + +/// A random line for `key`, or null. +/datum/xenoarch_buyer/proc/line(key) + var/list/options = lines[key] + return length(options) ? pick(options) : null + +/// The trader says `text`, and holds their other chatter back for a moment. +/datum/xenoarch_buyer/proc/speak(mob/living/basic/outpost_trader/vendor, text) + if(QDELETED(vendor) || !text) + return + COOLDOWN_START(vendor, speak_cooldown, 3 SECONDS) + vendor.say(text) + +/// The trader starts looking over `find`, riding in `holder` (the find itself, or its crate). +/datum/xenoarch_buyer/proc/begin_inspection(mob/living/basic/outpost_trader/vendor, obj/machinery/artifact/find, atom/movable/holder) + if(QDELETED(vendor)) + return + var/emote = line(holder == find ? XENOARCH_LINE_INSPECT : XENOARCH_LINE_INSPECT_CRATED) + if(emote) + vendor.manual_emote(replacetext(emote, "%THING%", "\the [holder]")) + if(holder != find) + playsound(holder, 'sound/machines/crate/crate_open.ogg', 20, TRUE) + if(inspect_sound) + playsound(vendor, inspect_sound, 30, TRUE) + // Cracks and a drained feel are plain to anyone looking; said while looking, not as a verdict. + if(find.damaged) + speak(vendor, line(XENOARCH_LINE_CRACKED)) + else if(find.harvests_taken() > 0) + speak(vendor, line(XENOARCH_LINE_TAPPED)) + +/// What the trader says as they pay for `find`. Only said once the find is theirs. +/datum/xenoarch_buyer/proc/closing_line(obj/machinery/artifact/find) + if(find.main_effect?.tier == ARTIFACT_TIER_EXTREME) + return line(XENOARCH_LINE_LIVE) + if(!find.label) + return line(XENOARCH_LINE_BLANK) + var/accuracy = round(find.label_accuracy(), 0.01) + if(accuracy >= 1) + return line(XENOARCH_LINE_PERFECT) + if(accuracy >= ARTIFACT_LABEL_ACCURACY_FLOOR) + return line(XENOARCH_LINE_CLOSE) + return line(XENOARCH_LINE_WRONG) + +/** + * Remarks on a find being hauled up to the counter, once per find and not too often. Runs on the + * trader's life tick. Only finds a player is pulling count: that is someone showing it off. + */ +/datum/xenoarch_buyer/proc/look_around(mob/living/basic/outpost_trader/vendor) + if(!COOLDOWN_FINISHED(src, notice_cooldown) || is_busy() || !isturf(vendor.loc)) + return + for(var/atom/movable/thing in range(XENOARCH_NOTICE_RANGE, vendor)) + var/mob/living/hauler = thing.pulledby + if(!hauler?.client) + continue + var/obj/machinery/artifact/find = xenoarch_find_in(thing) + if(!find?.is_dug() || (find.serial in noticed)) + continue + noticed += find.serial + if(length(noticed) > XENOARCH_NOTICE_MEMORY) + noticed.Cut(1, 2) + COOLDOWN_START(src, notice_cooldown, XENOARCH_NOTICE_COOLDOWN) + speak(vendor, line(XENOARCH_LINE_NOTICE)) + return + +/// The receipt's body: the facts of one sale, in this buyer's hand. +/datum/xenoarch_buyer/proc/receipt_text(list/sale) + var/list/parts = list() + parts += " [receipt_title][receipt_subtitle ? "
[receipt_subtitle]" : ""]
" + parts += "Bought of [sale["seller"]], [sale["time"]].
" + parts += "One [sale["find"]], field tag [sale["serial"]].
" + parts += sale["label"] ? "The tag on it says: [sale["label"]].
" : "No label on it.
" + if(sale["condition"]) + parts += "Condition: [sale["condition"]].
" + parts += "
Paid [sale["price"]] to [sale["account"]].
" + if(sale["vouchers"]) + parts += "Also handed over: [sale["vouchers"]] trade voucher[sale["vouchers"] > 1 ? "s" : ""].
" + if(receipt_signoff) + parts += "
[receipt_signoff]" + return parts.Join() + +/// The facts of a sale, taken before the find is gone. +/datum/xenoarch_buyer/proc/sale_record(obj/machinery/artifact/find, mob/living/seller, price, vouchers, datum/bank_account/account) + var/list/condition = list() + if(find.damaged) + condition += "cracked" + if(find.harvests_taken() > 0) + condition += "drained" + var/label_text + if(find.label) + label_text = "[find.label.effect_name || "?"] / [find.label.trigger_name || "?"] / [find.label.second_name || ARTIFACT_LABEL_NONE]" + return list( + "seller" = seller?.real_name || "a stranger", + "time" = station_time_timestamp("hh:mm"), + "find" = find.name, + "serial" = find.serial, + "label" = label_text, + "label_off" = !!find.label && round(find.label_accuracy(), 0.01) < 1, + "condition" = length(condition) ? condition.Join(", ") : null, + "price" = xenoarch_credits_text(price), + "vouchers" = vouchers, + "account" = account?.account_holder || "the seller", + ) + +// ----- Barnaby: Waystation Halcyon, green ----- + +/datum/xenoarch_buyer/barnaby + find_name = "dig pieces" + find_desc = "Anything big and old out of the cliffs. Barnaby pays fair and keeps the nice ones in the back." + find_icon_state = "idol" + curio_name = "curios" + curio_desc = "Fossils, pots, little figures. The gift shop does well out of them." + curio_icon = 'icons/obj/mining.dmi' + curio_icon_state = "skull" + receipt_title = "WAYSTATION HALCYON" + receipt_subtitle = "General Store" + receipt_signoff = "With thanks, B." + receipt_font = FOUNTAIN_PEN_FONT + receipt_ink = "#24305e" + receipt_stamp = "stamp-qm" + inspect_sound = 'sound/items/handling/book_pickup.ogg' + lines = list( + XENOARCH_LINE_NOTICE = list( + "Goodness, what have you dragged in? Bring it round, dear.", + "Oh, that's come out of the ground, hasn't it. Let's have a look.", + "Mind the floor with that. It's only just been mopped.", + ), + XENOARCH_LINE_INSPECT = list( + "pushes his reading glasses up his nose and leans over %THING%.", + "peers at %THING% over his glasses, humming.", + ), + XENOARCH_LINE_INSPECT_CRATED = list( + "lifts the lid of %THING% and peers inside, glasses on the end of his nose.", + "props open %THING% with one hand and has a good long look.", + ), + XENOARCH_LINE_CRACKED = list( + "Oh dear. Cracked right down the side.", + "Somebody's been rough with this one.", + ), + XENOARCH_LINE_TAPPED = list( + "Feels tired, this one. Somebody's had a go at it.", + "Hm. Not as lively as it ought to be.", + ), + XENOARCH_LINE_PERFECT = list( + "Labelled proper and everything. You've done your homework, dear.", + "Exactly what it says on the tag. Lovely.", + ), + XENOARCH_LINE_CLOSE = list( + "Near enough what it says on the tag. I'll not quibble.", + "Mostly right, that label. Mostly.", + ), + XENOARCH_LINE_WRONG = list( + "I'm not sure this label's been anywhere near this thing, dear.", + "Whoever wrote this tag was guessing. I'll pay for the rock.", + ), + XENOARCH_LINE_BLANK = list( + "No label? Then I'm buying a mystery, and mysteries come cheap.", + "Not a word on it about what it does. I'll take it on faith, at a faith price.", + ), + XENOARCH_LINE_LIVE = list( + "Goodness. This one's very much awake in there. I'll be glad when the courier takes it.", + "Oh my. I'll be keeping this one well away from the biscuit tin.", + ), + XENOARCH_LINE_WALKED = list( + "Oh! Never mind, then.", + "Changed your mind? That's all right, dear.", + ), + ) + idle_lines = list( + "Folk keep digging funny old things out of the cliffs. I'll buy them, if they don't hum too loud.", + "Had a lad bring in a stone that whistled. Paid him for it. It's in the back. It still whistles.", + ) + +// ----- Boffin: the Skunkworks, Quartermain Depot, yellow ----- + +/datum/xenoarch_buyer/boffin + takes_strange_objects = TRUE + find_name = "alien artifacts" + find_desc = "Large finds out of the old dig sites. Boffin likes them catalogued and in one piece." + find_icon_state = "terminal" + curio_name = "curios and oddities" + curio_desc = "Small dig finds, and the strange objects nobody can explain. Especially those." + curio_icon = 'icons/obj/devices/artefacts.dmi' + curio_icon_state = "prototype3" + receipt_title = "THE SKUNKWORKS" + receipt_subtitle = "Specimen intake" + receipt_signoff = "Received for bench testing. Boffin, QA." + receipt_font = PEN_FONT + receipt_ink = "#1d3b6e" + receipt_stamp = "stamp-rd" + inspect_sound = 'sound/machines/scanner/scanner.ogg' + lines = list( + XENOARCH_LINE_NOTICE = list( + "Oh. Oh, that's not from around here. Bring it closer. No, not THAT close.", + "Is that a dig piece? Wheel it over, wheel it over.", + "I can hear that from here. Lovely.", + ), + XENOARCH_LINE_INSPECT = list( + "waves his multitool over %THING%, squinting at the readout.", + "taps %THING% with his multitool and listens.", + ), + XENOARCH_LINE_INSPECT_CRATED = list( + "pries up the lid of %THING% and pokes his multitool inside.", + "leans into %THING% with his multitool held out like a divining rod.", + ), + XENOARCH_LINE_CRACKED = list( + "Cracked straight through. Somebody dug this out with a shovel and a prayer.", + "Fracture lines. I can see them. I can always see them.", + ), + XENOARCH_LINE_TAPPED = list( + "Someone's been siphoning this. It's running on fumes.", + "Drained. Partly. The hum's a semitone flat.", + ), + XENOARCH_LINE_PERFECT = list( + "Label checks out on every line. Somebody on your crew owns a notebook. Keep them.", + "Correct on every count. I'm almost disappointed. Nothing left for me to discover.", + ), + XENOARCH_LINE_CLOSE = list( + "Label's close. I'll fix the rest in pencil.", + "Mostly right. The rest is what we in the trade call a learning opportunity.", + ), + XENOARCH_LINE_WRONG = list( + "Your label and my multitool disagree. My multitool is right.", + "This label is fiction. Good fiction. Still fiction.", + ), + XENOARCH_LINE_BLANK = list( + "No label. I love a blind test, but I don't pay for one.", + "Unlabelled. So I'm paying for a rock and a hunch.", + ), + XENOARCH_LINE_LIVE = list( + "Oh, this is a LIVE one. Nobody touch anything. Especially me.", + "That's the real thing. I'm going to need a bigger bench.", + ), + XENOARCH_LINE_WALKED = list( + "Hey! I was measuring that!", + "Fine. Take your rock. I'll measure the dent it left.", + ), + ) + idle_lines = list( + "Old dig pieces! Alien, ancient, occasionally ticking. My three favourite words.", + "Bring me something out of the deep rock. I promise to only lick it once.", + ) + +// A lab intake sheet, with a pencil note when the label needed fixing. +/datum/xenoarch_buyer/boffin/receipt_text(list/sale) + var/list/parts = list() + parts += "[receipt_title]
[receipt_subtitle]
" + parts += "Specimen: [sale["serial"]] ([sale["find"]])
" + parts += "From: [sale["seller"]], [sale["time"]]
" + parts += "Label as received: [sale["label"] ? "[sale["label"]][sale["label_off"] ? " (corrected in pencil)" : ""]" : "none"]
" + parts += "Condition: [sale["condition"] || "intact"]
" + parts += "Paid: [sale["price"]] to [sale["account"]]
" + parts += "
[receipt_signoff]" + return parts.Join() + +// ----- Vex: Undertow Exchange, red ----- + +/datum/xenoarch_buyer/vex + extreme_vouchers = 1 + buys_curios = FALSE + find_name = "dig pieces" + find_desc = "Old alien finds. Vex has collectors in the deep ring who pay for the strange ones." + find_icon_state = "spindle" + receipt_title = "UNDERTOW EXCHANGE" + receipt_signoff = "No returns. This never happened." + receipt_font = PRINTER_FONT + receipt_ink = "#111111" + receipt_stamp = "stamp-void" + inspect_sound = null + lines = list( + XENOARCH_LINE_NOTICE = list( + "That's a dig piece. Bring it here. Slowly.", + "Now that's a conversation piece. Over here.", + "Collectors in the deep ring would kill for one of those. Some have.", + ), + XENOARCH_LINE_INSPECT = list( + "slides their sunglasses down and looks %THING% over without a word.", + "walks once around %THING%, slowly.", + ), + XENOARCH_LINE_INSPECT_CRATED = list( + "lifts the lid of %THING% with one gloved finger and looks in.", + "cracks %THING% open an inch and studies the gap.", + ), + XENOARCH_LINE_CRACKED = list( + "Cracked. Collectors hate cracks.", + "Somebody dropped this. More than once.", + ), + XENOARCH_LINE_TAPPED = list( + "Tapped. Somebody's had their fun with this.", + "Half of what it was. I can tell.", + ), + XENOARCH_LINE_PERFECT = list( + "Clean paperwork. My buyer likes clean paperwork.", + "Label's right. That's rarer than the rock.", + ), + XENOARCH_LINE_CLOSE = list( + "Label's close enough for my buyer. Not for me.", + "Mostly right. Mostly gets mostly paid.", + ), + XENOARCH_LINE_WRONG = list( + "Somebody guessed. I don't pay for guesses.", + "Wrong label. My buyer's going to ask questions. I'll answer them, for a fee.", + ), + XENOARCH_LINE_BLANK = list( + "No label. You're selling me a rock with a story you don't know.", + "Blank. Fine. I'll make up a story. Mine sell better.", + ), + XENOARCH_LINE_LIVE = list( + "Now this is worth something to people who don't deal in credits. Take the chit.", + "My buyer's going to want this very badly. Here. A little extra.", + ), + XENOARCH_LINE_WALKED = list( + "Walking away. Smart, or stupid. We'll see.", + "Suit yourself.", + ), + ) + idle_lines = list( + "The deep-ring collectors pay silly money for old dig pieces. The scarier the better.", + "Somebody brought me a crystal that hummed in a key I didn't like. Sold it in an hour.", + ) + +// Vex writes as little as possible down. +/datum/xenoarch_buyer/vex/receipt_text(list/sale) + var/list/parts = list() + parts += "[receipt_title]
" + parts += "[sale["serial"]]. [sale["price"]] to [sale["account"]].[sale["vouchers"] ? " One chit." : ""]
" + parts += "
[receipt_signoff]" + return parts.Join() + +// ========================================================================= +// SHOPS AND TRADERS +// ========================================================================= + +/datum/outpost_shop + /// /datum/xenoarch_buyer type for a shop that buys dig finds, or null + var/xenoarch_buyer_type + /// This shop's dig-find buyer, if it buys them + var/datum/xenoarch_buyer/xenoarch_buyer + +/datum/outpost_shop/general + xenoarch_buyer_type = /datum/xenoarch_buyer/barnaby + +/datum/outpost_shop/vendor/skunkworks + xenoarch_buyer_type = /datum/xenoarch_buyer/boffin + +/datum/outpost_shop/black_market + xenoarch_buyer_type = /datum/xenoarch_buyer/vex + +// The buyer's ledger rows go in before the base New() makes the buybacks, so they share the +// shop's demand and convoy restock like any other row. +/datum/outpost_shop/New(obj/structure/overmap/trader_outpost/outpost) + if(xenoarch_buyer_type) + xenoarch_buyer = new xenoarch_buyer_type(src) + buyback_types = buyback_types + xenoarch_buyer.ledger_types() + if(length(xenoarch_buyer.idle_lines)) + var/list/idle = trader_lines[TRADER_LINE_IDLE] + trader_lines[TRADER_LINE_IDLE] = (islist(idle) ? idle : list()) + xenoarch_buyer.idle_lines + . = ..() + if(!xenoarch_buyer) + return + for(var/datum/shop_buyback/buyback as anything in buybacks) + if(istype(buyback, /datum/shop_buyback/xenoarch_find)) + var/datum/shop_buyback/xenoarch_find/find_row = buyback + find_row.attach(xenoarch_buyer) + else if(istype(buyback, /datum/shop_buyback/xenoarch_curio)) + var/datum/shop_buyback/xenoarch_curio/curio_row = buyback + curio_row.attach(xenoarch_buyer) + +/datum/outpost_shop/Destroy() + QDEL_NULL(xenoarch_buyer) + return ..() + +/mob/living/basic/outpost_trader/Life(seconds_per_tick, times_fired) + . = ..() + shop?.xenoarch_buyer?.look_around(src) + +// ========================================================================= +// LARGE FINDS +// ========================================================================= + +/** + * # Large-find ledger row + * + * Buys the find the seller is pulling (loose, or in a shut crate), not anything in their pack. + * item_path stays null on purpose: Pike's remote ledger and the contract pricing skip rows without + * one, so a large find can only be sold by hauling it to an outpost. + */ +/datum/shop_buyback/xenoarch_find + name = "dig pieces" + desc = "Large finds out of the old dig sites." + category = "Dig Finds" + item_path = null + demand_min = XENOARCH_FIND_DEMAND + demand_max = XENOARCH_FIND_DEMAND + /// The buyer whose ledger this is + var/datum/xenoarch_buyer/buyer + +/datum/shop_buyback/xenoarch_find/Destroy() + buyer = null + return ..() + +/// Takes on `new_buyer`'s wording for the ledger. +/datum/shop_buyback/xenoarch_find/proc/attach(datum/xenoarch_buyer/new_buyer) + buyer = new_buyer + name = new_buyer.find_name + desc = new_buyer.find_desc + cached_icon = null + +/datum/shop_buyback/xenoarch_find/get_ui_icon() + if(!cached_icon && buyer) + cached_icon = icon2base64(icon(buyer.find_icon, buyer.find_icon_state, SOUTH, frame = 1)) + return cached_icon + +/datum/shop_buyback/xenoarch_find/get_payment_text() + return "by the piece" + +// Never an inventory item, whoever asks (plunder appraisal, Pike's ledger). +/datum/shop_buyback/xenoarch_find/matches(obj/item/offered) + return FALSE + +/datum/shop_buyback/xenoarch_find/find_refused_variant(mob/living/user) + return null + +/// The finds `user` is hauling that a buyer pays for (dug, and worth something), first to sell at the front. +/datum/shop_buyback/xenoarch_find/proc/sellable_finds(mob/living/user) + . = list() + for(var/obj/machinery/artifact/find as anything in xenoarch_hauled_finds(user)) + if(artifact_sale_value(find) > 0) + . += find + +// The trader takes one piece at a time, so a crate of three still shows one. +/datum/shop_buyback/xenoarch_find/count_carried_units(mob/living/user) + if(!istype(user)) + return 0 + return length(sellable_finds(user)) ? 1 : 0 + +/// Whether `find` is close enough to `vendor` to be looked at. +/datum/shop_buyback/xenoarch_find/proc/at_counter(obj/machinery/artifact/find, mob/living/basic/outpost_trader/vendor) + var/atom/movable/holder = xenoarch_find_holder(find) + return !QDELETED(vendor) && holder && get_dist(holder, vendor) <= XENOARCH_COUNTER_REACH + +/datum/shop_buyback/xenoarch_find/get_denial_reason(mob/living/user) + if(demand <= 0) + return "Not buying any more this shift." + if(buyer?.is_busy()) + return "Already looking one over." + var/list/hauled = xenoarch_hauled_finds(user) + if(!length(hauled)) + return "Nothing at the counter." + var/list/finds = sellable_finds(user) + if(!length(finds)) + for(var/obj/machinery/artifact/find as anything in hauled) + if(!find.is_dug()) + return "No field tag on it." + return "Not buying that." + if(!at_counter(finds[1], buyer?.trader())) + return "Bring it closer." + if(!get_shop_buyback_account(user)) + return "No bank account on your ID." + return null + +// The sale finishes once the trader has looked the find over, so this starts it and reports +// nothing sold yet: the window's own sale sound and line would come too early. The buyer makes +// their own noise when the money changes hands. +/datum/shop_buyback/xenoarch_find/try_sell(mob/living/user, mob/living/basic/outpost_trader/vendor, quiet = FALSE) + if(!buyer || QDELETED(vendor)) + return FALSE + INVOKE_ASYNC(src, PROC_REF(sell_hauled_find), user, vendor) + return FALSE + +/datum/shop_buyback/xenoarch_find/try_sell_bulk(mob/living/user, mob/living/basic/outpost_trader/vendor) + try_sell(user, vendor) + return 0 + +/// Whether the sale of `find` can still go ahead: same seller, same counter, still hauled, still wanted. +/datum/shop_buyback/xenoarch_find/proc/sale_still_on(mob/living/seller, mob/living/basic/outpost_trader/vendor, obj/machinery/artifact/find) + if(QDELETED(src) || QDELETED(find) || QDELETED(vendor) || QDELETED(seller) || !buyer) + return FALSE + if(demand <= 0 || !(find in sellable_finds(seller)) || !at_counter(find, vendor)) + return FALSE + if(!vendor.check_menu(seller) || vendor.outpost?.is_user_barred(seller)) + return FALSE + if(vendor.outpost && !vendor.outpost.contains_site_turf(get_turf(vendor))) + return FALSE + return TRUE + +/** + * The seller waits at the counter while the trader looks over the first find they are hauling. + * Walking off, letting go of it or the trader's demand running out calls it off. Sleeps. + */ +/datum/shop_buyback/xenoarch_find/proc/sell_hauled_find(mob/living/seller, mob/living/basic/outpost_trader/vendor) + var/denial = get_denial_reason(seller) + if(denial) + to_chat(seller, span_warning(denial)) + vendor?.play_denial() + return FALSE + var/obj/machinery/artifact/find = sellable_finds(seller)[1] + if(!sale_still_on(seller, vendor, find)) + vendor?.play_denial() + return FALSE + var/atom/movable/holder = xenoarch_find_holder(find) + buyer.inspecting = WEAKREF(find) + COOLDOWN_START(buyer, inspect_cooldown, XENOARCH_INSPECT_COOLDOWN) + buyer.begin_inspection(vendor, find, holder) + var/looked = do_after(seller, XENOARCH_INSPECT_TIME, holder, timed_action_flags = IGNORE_HELD_ITEM, extra_checks = CALLBACK(src, PROC_REF(sale_still_on), seller, vendor, find), hidden = TRUE) + if(buyer) + buyer.inspecting = null + if(!looked || !sale_still_on(seller, vendor, find)) + if(!QDELETED(find) && buyer) + buyer.speak(vendor, buyer.line(XENOARCH_LINE_WALKED)) + return FALSE + if(settle(find, seller, get_shop_buyback_account(seller), vendor) > 0) + return TRUE + vendor.play_denial() + return FALSE + +/** + * Pays for `find` and takes it: credits into `account`, any voucher and the receipt into the + * seller's hands, the find gone. All checks and the payment happen without a sleep between them. + * Returns the credits paid, or 0 if nothing was sold. + */ +/datum/shop_buyback/xenoarch_find/proc/settle(obj/machinery/artifact/find, mob/living/seller, datum/bank_account/account, mob/living/basic/outpost_trader/vendor) + if(QDELETED(find) || !find.is_dug() || demand <= 0 || !account) + return 0 + var/price = artifact_sale_value(find) + if(price <= 0) + return 0 + var/vouchers = buyer ? buyer.vouchers_for(find) : 0 + var/list/sale = buyer?.sale_record(find, seller, price, vouchers, account) + var/reaction = buyer?.closing_line(find) + var/atom/drop_spot = seller?.drop_location() || vendor?.drop_location() || get_turf(find) + var/serial = find.serial + var/trader_name = buyer?.shop?.trader_name || "The buyer" + + demand-- + SEND_SIGNAL(find, COMSIG_ARTIFACT_SOLD, price, vouchers, seller) + metric_artifact_sold(find, seller, price, vouchers, buyer?.shop) + log_game("XENOARCH: [key_name(seller)] sold [serial] ([find.main_effect?.log_name]) to [trader_name] for [price] cr[vouchers ? " and [vouchers] voucher\s" : ""] at [AREACOORD(drop_spot)].") + if(isturf(find.loc)) + new /obj/effect/temp_visual/xenoarch_sold_find(find.loc, find) + qdel(find) + + account.adjust_money(price, "Trader Outpost: [trader_name] bought [serial]") + if(vouchers > 0) + var/obj/item/stack/trade_voucher/chits = new(drop_spot, vouchers) + seller?.put_in_hands(chits) + if(sale) + var/obj/item/paper/xenoarch_receipt/receipt = new(drop_spot) + receipt.fill_in(buyer, sale) + seller?.put_in_hands(receipt) + if(!QDELETED(vendor)) + playsound(vendor, 'sound/effects/cashregister.ogg', 40, TRUE) + if(sale) + playsound(vendor, 'sound/items/handling/standard_stamp.ogg', 35, TRUE) + buyer?.speak(vendor, reaction) + if(seller) + to_chat(seller, span_notice("[trader_name] pays [xenoarch_credits_text(price)] for [serial][vouchers ? " and slides over a trade voucher" : ""].")) + return price + +/// The sold find, fading off the counter as it is carried into the back. +/obj/effect/temp_visual/xenoarch_sold_find + duration = 0.8 SECONDS + randomdir = FALSE + +/obj/effect/temp_visual/xenoarch_sold_find/Initialize(mapload, atom/movable/find) + . = ..() + if(find) + icon = find.icon + icon_state = find.icon_state + pixel_x = find.pixel_x + pixel_y = find.pixel_y + animate(src, alpha = 0, pixel_z = 6, time = duration, easing = SINE_EASING | EASE_IN) + +// ========================================================================= +// CURIOS +// ========================================================================= + +/** + * # Dug curio + * + * Marks a small find as having come out of a dig site, and what a buyer pays for it. Buyers take + * only marked items, so strange objects from maintenance or the experimentor (never marked) can't + * pass as finds. Copies made of a curio don't carry the mark. + */ +/datum/component/xenoarch_curio + /// Credits a buyer pays for it + var/value = 0 + +/datum/component/xenoarch_curio/Initialize(value) + if(!isitem(parent)) + return COMPONENT_INCOMPATIBLE + src.value = max(round(value), 0) + +/// Marks `find` as a dug curio worth `value` credits to a buyer. Call when a small find comes out of the rock. +/proc/xenoarch_mark_curio(obj/item/find, value) + if(!istype(find) || value <= 0) + return FALSE + find.AddComponent(/datum/component/xenoarch_curio, value) + return TRUE + +/// What a buyer pays for `thing` as a curio: 0 if it never came out of a dig site. +/proc/xenoarch_curio_value(obj/item/thing) + var/datum/component/xenoarch_curio/mark = thing?.GetComponent(/datum/component/xenoarch_curio) + return mark ? mark.value : 0 + +/** + * # Curio ledger row + * + * An ordinary inventory buyback, except that every curio carries its own price. item_path stays + * null so contract pricing and Pike's remote ledger leave it alone. + */ +/datum/shop_buyback/xenoarch_curio + name = "curios" + desc = "Small finds out of the old dig sites." + category = "Dig Finds" + item_path = null + demand_min = XENOARCH_CURIO_DEMAND + demand_max = XENOARCH_CURIO_DEMAND + /// The buyer whose ledger this is + var/datum/xenoarch_buyer/buyer + /// Credits the last single sale paid (bulk sales add these up) + var/last_sale_value = 0 + +/datum/shop_buyback/xenoarch_curio/Destroy() + buyer = null + return ..() + +/// Takes on `new_buyer`'s wording for the ledger. +/datum/shop_buyback/xenoarch_curio/proc/attach(datum/xenoarch_buyer/new_buyer) + buyer = new_buyer + name = new_buyer.curio_name + desc = new_buyer.curio_desc + cached_icon = null + +/datum/shop_buyback/xenoarch_curio/get_ui_icon() + if(!cached_icon && buyer) + cached_icon = icon2base64(icon(buyer.curio_icon, buyer.curio_icon_state, SOUTH, frame = 1)) + return cached_icon + +/datum/shop_buyback/xenoarch_curio/get_payment_text() + return "by the piece" + +/datum/shop_buyback/xenoarch_curio/matches(obj/item/offered) + if(!isitem(offered) || is_trader_good(offered)) + return FALSE + if((offered.item_flags & ABSTRACT) || (offered.flags_1 & HOLOGRAM_1)) + return FALSE + if(istype(offered, /obj/item/relic) && !buyer?.takes_strange_objects) + return FALSE + return xenoarch_curio_value(offered) > 0 + +/datum/shop_buyback/xenoarch_curio/find_refused_variant(mob/living/user) + return null + +/datum/shop_buyback/xenoarch_curio/get_denial_reason(mob/living/user) + if(demand <= 0) + return "Not buying any more this shift." + if(count_carried_units(user) < 1) + return "Carrying none of the goods: [get_wanted_text()]." + if(!get_shop_buyback_account(user)) + return "No bank account on your ID." + return null + +/datum/shop_buyback/xenoarch_curio/try_sell(mob/living/user, mob/living/basic/outpost_trader/vendor, quiet = FALSE) + last_sale_value = 0 + if(demand <= 0) + return FALSE + var/datum/bank_account/account = get_shop_buyback_account(user) + if(!account) + return FALSE + var/list/found = find_offered_items(user) + if(!length(found)) + return FALSE + var/obj/item/curio = found[1] + var/value = xenoarch_curio_value(curio) + if(value <= 0) + return FALSE + var/curio_name = curio.name + var/curio_type = curio.type + qdel(curio) + demand-- + account.adjust_money(value, "Trader Outpost: sold [curio_name]") + last_sale_value = value + if(!quiet) + to_chat(user, span_notice("Sold: [curio_name] ([xenoarch_credits_text(value)]).")) + // The ordinary ledger metric, priced by the piece + if(SSmetrics.accepting) + var/list/details = list("name" = name, "sales" = 1, "curio" = curio_name) + if(vendor?.shop) + details["shop"] = "[vendor.shop.type]" + record_metric(METRIC_TRADE, "shop_buyback", subject = curio_type, credits = value, quantity = 1, details = details, actor = user) + return TRUE + +/datum/shop_buyback/xenoarch_curio/try_sell_bulk(mob/living/user, mob/living/basic/outpost_trader/vendor) + var/sold = 0 + var/total = 0 + var/safety = 50 + while(demand > 0 && safety-- > 0) + if(!try_sell(user, vendor, quiet = TRUE)) + break + sold++ + total += last_sale_value + if(sold > 0) + to_chat(user, span_notice("Sold [sold] [sold > 1 ? "curios" : "curio"] ([xenoarch_credits_text(total)]).")) + return sold + +// ========================================================================= +// THE RECEIPT +// ========================================================================= + +/// What a buyer hands over with the money: a dealer's paper, in their own hand. +/obj/item/paper/xenoarch_receipt + name = "receipt" + desc = "A dealer's receipt for something old and heavy." + /// Paper stamp icon state to press on once the stamp sheet is ready + var/pending_stamp + +/obj/item/paper/xenoarch_receipt/proc/fill_in(datum/xenoarch_buyer/buyer, list/sale) + name = "receipt ([sale["serial"]])" + add_raw_text(buyer.receipt_text(sale), buyer.receipt_font, buyer.receipt_ink) + update_appearance() + if(buyer.receipt_stamp) + pending_stamp = buyer.receipt_stamp + // The stamp's class comes from the paper spritesheet, which may have to be made ready first + INVOKE_ASYNC(src, PROC_REF(stamp_it)) + +/obj/item/paper/xenoarch_receipt/proc/stamp_it() + var/datum/asset/spritesheet_batched/sheet = get_asset_datum(/datum/asset/spritesheet/simple/paper) + if(QDELETED(src) || !sheet || !pending_stamp) + return + add_stamp(sheet.icon_class_name(pending_stamp), rand(180, 260), rand(40, 120), rand(-15, 15), pending_stamp) + pending_stamp = null + update_appearance() + +#undef XENOARCH_FIND_DEMAND +#undef XENOARCH_CURIO_DEMAND +#undef XENOARCH_COUNTER_REACH +#undef XENOARCH_INSPECT_TIME +#undef XENOARCH_INSPECT_COOLDOWN +#undef XENOARCH_NOTICE_RANGE +#undef XENOARCH_NOTICE_COOLDOWN +#undef XENOARCH_NOTICE_MEMORY +#undef XENOARCH_LINE_NOTICE +#undef XENOARCH_LINE_INSPECT +#undef XENOARCH_LINE_INSPECT_CRATED +#undef XENOARCH_LINE_CRACKED +#undef XENOARCH_LINE_TAPPED +#undef XENOARCH_LINE_PERFECT +#undef XENOARCH_LINE_CLOSE +#undef XENOARCH_LINE_WRONG +#undef XENOARCH_LINE_BLANK +#undef XENOARCH_LINE_LIVE +#undef XENOARCH_LINE_WALKED diff --git a/voidcrew/modules/xenoarch/trade/checkpoint.dm b/voidcrew/modules/xenoarch/trade/checkpoint.dm index 49b987779d0..43ec2af87bc 100644 --- a/voidcrew/modules/xenoarch/trade/checkpoint.dm +++ b/voidcrew/modules/xenoarch/trade/checkpoint.dm @@ -1 +1,78 @@ -// Outpost checkpoints turning back loose finds. +/** + * # Outpost checkpoints turning back loose finds + * + * A large find comes into a trader outpost crated, or not at all. The scan chamber + * (voidcrew/modules/trade/outpost_checkpoint.dm) refuses an artifact standing loose on its floor + * the way it refuses a gun on the floor: the inner door stays shut, the guard (or the wall + * scanner) says so, and the outer door waits until the find has been taken back out. A find in + * any shut crate, or carried in an exosuit, passes. Leaving through an exterior hatch is never + * refused for a find. + * + * Inside, a find does nothing anyway (the outpost holds it still); this keeps one from being + * dragged through the crowd at the door and gives the guards something to say about it. + */ + +/// The refusal category for a loose find: a refused[] value and a line key for guards and scanners +#define XENOARCH_CHECKPOINT_LINE_LOOSE "xenoarch_loose_find" + +/datum/outpost_checkpoint/inspect_chamber() + var/list/refused = ..() + if(exit_request) + return refused + for(var/turf/tile as anything in chamber_turfs) + for(var/obj/machinery/artifact/find in tile) + if(!refused[find]) + refused[find] = XENOARCH_CHECKPOINT_LINE_LOOSE + return refused + +/// Whether everything the chamber refuses right now is a loose find. +/datum/outpost_checkpoint/proc/refusing_only_loose_finds() + var/list/refused = inspect_chamber() + if(!length(refused)) + return FALSE + for(var/atom/movable/thing as anything in refused) + if(refused[thing] != XENOARCH_CHECKPOINT_LINE_LOOSE) + return FALSE + return TRUE + +// A refusal is announced as "armed"; when the only thing refused is a loose find, say that instead. +/datum/outpost_checkpoint/announce(category, urgent = FALSE) + if(category == CHECKPOINT_LINE_ARMED && state == CHECKPOINT_REJECTING && refusing_only_loose_finds()) + category = XENOARCH_CHECKPOINT_LINE_LOOSE + return ..(category, urgent) + +/obj/machinery/outpost_checkpoint_sensor/machine_line(category) + if(category == XENOARCH_CHECKPOINT_LINE_LOOSE) + return "Uncontained specimen." + return ..() + +/datum/outpost_shop/vendor/checkpoint + /// What this guard says to someone pulling a find in loose + var/list/xenoarch_loose_lines = list( + "Crate it first.", + ) + +/datum/outpost_shop/vendor/checkpoint/get_line(category) + if(category == XENOARCH_CHECKPOINT_LINE_LOOSE) + return length(xenoarch_loose_lines) ? pick(xenoarch_loose_lines) : null + return ..() + +/datum/outpost_shop/vendor/checkpoint/halcyon + xenoarch_loose_lines = list( + "Crate it first, please. That doesn't come in loose.", + "Whatever that is, it goes in a crate before it comes past me.", + ) + +/datum/outpost_shop/vendor/checkpoint/quartermain + xenoarch_loose_lines = list( + "Crate it first.", + "Not loose. Box it and come back.", + ) + +/datum/outpost_shop/vendor/checkpoint/undertow + xenoarch_loose_lines = list( + "Crate it.", + "Loose rocks stay outside.", + ) + +#undef XENOARCH_CHECKPOINT_LINE_LOOSE diff --git a/voidcrew/modules/xenoarch/trade/metrics.dm b/voidcrew/modules/xenoarch/trade/metrics.dm index 72bea68c7ee..9612690ccee 100644 --- a/voidcrew/modules/xenoarch/trade/metrics.dm +++ b/voidcrew/modules/xenoarch/trade/metrics.dm @@ -1 +1,22 @@ -// Round metrics for digging, analysing, harvesting and selling finds. +// Round metrics for selling finds. Digging, analysing and harvesting record their own events +// (XENOARCH_METRIC_DUG/LOST/ANALYSED/HARVESTED) where they happen; curios sold over the counter use +// the ordinary "shop_buyback" event. + +/// A large find sold at an outpost. Call before the find is deleted. `zone` is the band it was dug in. +/proc/metric_artifact_sold(obj/machinery/artifact/find, mob/living/seller, credits, vouchers, datum/outpost_shop/shop) + if(!SSmetrics.accepting || QDELETED(find)) + return + var/list/details = list( + "serial" = find.serial, + "accuracy" = round(find.label_accuracy(), 0.01), + "labelled" = !!find.label, + "tier" = find.main_effect?.tier, + "band" = xenoarch_band_name(find.origin_band), + "harvests" = find.harvests_taken(), + "damaged" = !!find.damaged, + "crated" = !isturf(find.loc), + ) + if(shop) + details["buyer"] = shop.trader_name + details["shop"] = "[shop.type]" + record_metric(METRIC_TRADE, XENOARCH_METRIC_SOLD, zone = xenoarch_band_name(find.origin_band), subject = find.main_effect?.type || find.type, credits = credits, vouchers = vouchers, quantity = 1, details = details, actor = seller) From 7a1ca41dada0a85690f33f1004f986c1e458b1b6 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:53:11 -0800 Subject: [PATCH 07/20] core change: split capped artifact heals by the wounds present artifact_capped_heal() always asked for half brute and half burn, so a one-sided wound (most wounds) healed only half the amount asked. It now splits the heal in proportion to the brute and burn the target has. The cap and ledger are unchanged. --- voidcrew/modules/xenoarch/core/artifact_helpers.dm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/voidcrew/modules/xenoarch/core/artifact_helpers.dm b/voidcrew/modules/xenoarch/core/artifact_helpers.dm index 7266df46f6c..6ac141d22c0 100644 --- a/voidcrew/modules/xenoarch/core/artifact_helpers.dm +++ b/voidcrew/modules/xenoarch/core/artifact_helpers.dm @@ -177,7 +177,8 @@ GLOBAL_LIST_EMPTY(artifact_heal_ledger) entry[2] += amount /** - * Heals brute and burn on `target`, never past what the shared cap allows. + * Heals brute and burn on `target`, never past what the shared cap allows. The heal is split in + * proportion to the brute and burn they have, so a one-sided wound gets the whole amount. * Returns the amount actually healed. * * * required_bodytype - limit to robotic or organic limbs on carbons (heal_overall_damage's arg) @@ -187,7 +188,10 @@ GLOBAL_LIST_EMPTY(artifact_heal_ledger) if(allowed <= 0) return 0 var/before = target.getBruteLoss() + target.getFireLoss() - target.heal_overall_damage(allowed / 2, allowed / 2, required_bodytype = required_bodytype) + if(before <= 0) + return 0 + var/brute_share = allowed * target.getBruteLoss() / before + target.heal_overall_damage(brute_share, allowed - brute_share, required_bodytype = required_bodytype) var/healed = max(before - (target.getBruteLoss() + target.getFireLoss()), 0) artifact_record_heal(target, healed) return healed From 3b67b1beb557e6b10561e97775b3e6d3fb87f921 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:53:18 -0800 Subject: [PATCH 08/20] Add the Polaris and VOREStation artifact effects Twenty effects rewritten for tg from Polaris 6cd19fe0dec6 and VOREStation 9335d66b9fdf: extinguisher, animate, sweat, electric field, fortify, faraday, sprint, berserk, disarm, force walls, gaia, plasma vent, poltergeist, feysight, sleeping gas, life drain, gravity wave, spines, life steal and resurrect. Polaris modifiers become tg status effects. Gas vents are indoor only with a finite reserve; resurrect gives three lives and only to a body whose player can come back. --- .../voidcrew_xenoarch_effects_polaris.dm | 267 +++++++++++++++ .../xenoarch/effects_polaris/animate.dm | 120 +++++++ .../xenoarch/effects_polaris/berserk.dm | 32 ++ .../xenoarch/effects_polaris/disarm.dm | 46 +++ .../effects_polaris/electric_field.dm | 94 ++++++ .../xenoarch/effects_polaris/extinguisher.dm | 108 ++++++ .../xenoarch/effects_polaris/faraday.dm | 24 ++ .../xenoarch/effects_polaris/feysight.dm | 32 ++ .../xenoarch/effects_polaris/forcefield.dm | 128 ++++++++ .../xenoarch/effects_polaris/fortify.dm | 24 ++ .../modules/xenoarch/effects_polaris/gaia.dm | 117 +++++++ .../xenoarch/effects_polaris/gravity_wave.dm | 121 +++++++ .../xenoarch/effects_polaris/life_drain.dm | 101 ++++++ .../xenoarch/effects_polaris/life_steal.dm | 81 +++++ .../xenoarch/effects_polaris/plasma_vent.dm | 115 +++++++ .../xenoarch/effects_polaris/poltergeist.dm | 105 ++++++ .../xenoarch/effects_polaris/resurrect.dm | 190 +++++++++++ .../xenoarch/effects_polaris/sleeping_gas.dm | 14 + .../xenoarch/effects_polaris/spines.dm | 98 ++++++ .../xenoarch/effects_polaris/sprint.dm | 24 ++ .../effects_polaris/status_effects.dm | 307 ++++++++++++++++++ .../modules/xenoarch/effects_polaris/sweat.dm | 91 ++++++ 22 files changed, 2239 insertions(+) diff --git a/voidcrew/modules/unit_tests/voidcrew_xenoarch_effects_polaris.dm b/voidcrew/modules/unit_tests/voidcrew_xenoarch_effects_polaris.dm index 0042d09ba8f..7461949a10b 100644 --- a/voidcrew/modules/unit_tests/voidcrew_xenoarch_effects_polaris.dm +++ b/voidcrew/modules/unit_tests/voidcrew_xenoarch_effects_polaris.dm @@ -1 +1,268 @@ // Xenoarchaeology tests: effects_polaris. +// +// Test files compile before voidcrew/_DEFINES, so the values below are literals. They mirror +// voidcrew/_DEFINES/xenoarch.dm: +// bands (ZONE_*): green 1, yellow 2, red 3 +// tiers: common 1, uncommon 2, rare 3, extreme 4 +// triggers: plasma 512 (the only one a test names) +// release methods: "touch", "aura", "pulse" + +/// The Polaris and VOREStation effects: type -> list(tier, minor, harvestable), from the design catalogue. +/proc/voidcrew_xenoarch_polaris_catalogue() + return list( + /datum/artifact_effect/extinguisher = list(1, TRUE, TRUE), + /datum/artifact_effect/animate = list(1, FALSE, FALSE), + /datum/artifact_effect/sweat = list(1, TRUE, TRUE), + /datum/artifact_effect/electric_field = list(2, FALSE, TRUE), + /datum/artifact_effect/bestow/fortify = list(2, FALSE, TRUE), + /datum/artifact_effect/bestow/faraday = list(2, FALSE, TRUE), + /datum/artifact_effect/bestow/sprint = list(2, FALSE, TRUE), + /datum/artifact_effect/bestow/berserk = list(2, FALSE, TRUE), + /datum/artifact_effect/disarm = list(2, FALSE, TRUE), + /datum/artifact_effect/forcefield = list(2, FALSE, FALSE), + /datum/artifact_effect/gaia = list(2, FALSE, TRUE), + /datum/artifact_effect/gas_vent/plasma = list(2, FALSE, FALSE), + /datum/artifact_effect/poltergeist = list(3, FALSE, TRUE), + /datum/artifact_effect/bestow/feysight = list(3, FALSE, TRUE), + /datum/artifact_effect/gas_vent/sleeping = list(3, FALSE, FALSE), + /datum/artifact_effect/life_drain = list(3, FALSE, TRUE), + /datum/artifact_effect/gravity_wave = list(4, FALSE, FALSE), + /datum/artifact_effect/spines = list(4, FALSE, FALSE), + /datum/artifact_effect/life_steal = list(4, FALSE, TRUE), + /datum/artifact_effect/resurrect = list(4, FALSE, FALSE), + ) + +/// Every Polaris effect is rollable with the catalogue's tier, minor and harvest flags, and rolls sane traits. +/datum/unit_test/voidcrew_xenoarch_polaris_catalogue/Run() + var/list/catalogue = voidcrew_xenoarch_polaris_catalogue() + var/list/rollable = artifact_effect_types() + TEST_ASSERT(!(/datum/artifact_effect/bestow in rollable), "the shared status-giving parent can roll") + TEST_ASSERT(!(/datum/artifact_effect/gas_vent in rollable), "the shared gas vent parent can roll") + for(var/effect_type in catalogue) + var/list/row = catalogue[effect_type] + TEST_ASSERT(effect_type in rollable, "[effect_type] can't roll") + var/label_count = 0 + var/datum/artifact_effect/probe = effect_type + for(var/datum/artifact_effect/other as anything in rollable) + if(initial(other.label_name) == initial(probe.label_name)) + label_count++ + TEST_ASSERT_EQUAL(label_count, 1, "[effect_type]'s label word is shared with another effect") + for(var/band in 1 to 3) + for(var/roll in 1 to 10) + var/datum/artifact_effect/effect = new effect_type(null, band) + TEST_ASSERT_EQUAL(effect.tier, row[1], "[effect_type] has the wrong tier") + TEST_ASSERT_EQUAL(effect.minor, row[2], "[effect_type] has the wrong minor flag") + TEST_ASSERT_EQUAL(effect.harvestable, row[3], "[effect_type] has the wrong harvest flag") + TEST_ASSERT(effect.release_method in effect.allowed_release_methods, "[effect_type] rolled a release it doesn't allow") + TEST_ASSERT(effect.energy_kind in effect.possible_kinds, "[effect_type] rolled a kind it doesn't allow") + TEST_ASSERT(effect.range >= 1 && effect.range <= 8, "[effect_type] rolled range [effect.range]") + TEST_ASSERT(effect.touch_cost <= effect.maximum_charges, "[effect_type] can never be touched off") + qdel(effect) + // Plasma air never wakes the plasma vent, or it would feed itself. + for(var/roll in 1 to 100) + var/datum/artifact_effect/gas_vent/plasma/vent = new(null, 3) + TEST_ASSERT(vent.trigger != 512, "the plasma vent rolled a plasma-air trigger") + qdel(vent) + var/datum/artifact_effect/spines/spines = new(null, 1) + TEST_ASSERT_EQUAL(spines.green_weight, 0.5, "spines are not halved in green") + qdel(spines) + +/// Every Polaris effect wakes, touches, runs a field and bursts on a real artifact without errors, +/// and leaves no force walls standing once it is gone. +/datum/unit_test/voidcrew_xenoarch_polaris_effects_run/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + var/turf/home = get_turf(find) + var/mob/living/carbon/human/consistent/tester = allocate(/mob/living/carbon/human/consistent, get_step(home, EAST)) + tester.mind_initialize() + allocate(/obj/item/crowbar, get_step(get_step(home, NORTH), NORTH)) + for(var/effect_type in voidcrew_xenoarch_polaris_catalogue()) + find.forceMove(home) + tester.forceMove(get_step(home, EAST)) + find.replace_effects(effect_type, null, 3) + var/datum/artifact_effect/effect = find.main_effect + TEST_ASSERT(effect, "[effect_type] did not attach to the artifact") + if(istype(effect, /datum/artifact_effect/gas_vent)) + var/datum/artifact_effect/gas_vent/vent = effect + vent.reserve = 0 // Venting is tested on its own, with the air put back afterwards. + effect.wake(1 MINUTES) + TEST_ASSERT(effect.activated, "[effect_type] did not wake") + effect.do_effect_touch(tester) + effect.do_effect_aura(2) + effect.do_effect_pulse(effect.maximum_charges) + effect.deactivate(quiet = TRUE) + tester.fully_heal(HEAL_ALL) + find.replace_effects(null, null) + for(var/obj/effect/forcefield/artifact/wall in range(4, home)) + TEST_ASSERT(!wall.density, "a force wall still stands after its effect is gone") + for(var/obj/effect/decal/cleanable/artifact_ooze/puddle in range(4, home)) + TEST_ASSERT(puddle.reagents?.total_volume <= 30, "an ooze puddle grew past a cupful") + +/// Resurrect: three lives, then spent; refuses the long dead, minds that moved on, and the absent. +/datum/unit_test/voidcrew_xenoarch_resurrect/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/resurrect, null, 3) + var/datum/artifact_effect/resurrect/rite = find.main_effect + var/mob/living/carbon/human/consistent/patient = allocate(/mob/living/carbon/human/consistent, get_step(find, EAST)) + patient.mind_initialize() + for(var/life in 1 to 3) + patient.adjustBruteLoss(40) + patient.death() + TEST_ASSERT_EQUAL(patient.stat, DEAD, "the patient did not die (life [life])") + TEST_ASSERT_EQUAL(rite.raise_refusal(patient), "gone", "a body with no player to come back was offered a revival") + TEST_ASSERT(rite.raise(patient), "a fresh body was not raised (life [life])") + TEST_ASSERT(patient.stat != DEAD, "the patient is still dead after being raised (life [life])") + TEST_ASSERT_EQUAL(rite.uses_left, 3 - life, "a revival did not spend a use") + patient.death() + TEST_ASSERT_EQUAL(rite.raise_refusal(patient), "spent", "a spent artifact offered a fourth life") + TEST_ASSERT(!rite.raise(patient), "a spent artifact raised the dead") + TEST_ASSERT_EQUAL(patient.stat, DEAD, "a spent artifact brought the patient back") + + // A fresh artifact for the remaining rules. + find.replace_effects(/datum/artifact_effect/resurrect, null, 3) + rite = find.main_effect + patient.timeofdeath = world.time - 6 MINUTES + TEST_ASSERT_EQUAL(rite.raise_refusal(patient), "too late", "a body dead six minutes was offered a revival") + patient.timeofdeath = world.time + var/mob/living/carbon/human/consistent/clone = allocate(/mob/living/carbon/human/consistent, get_step(find, WEST)) + patient.mind.transfer_to(clone) + TEST_ASSERT_EQUAL(rite.raise_refusal(patient), "gone", "a body whose mind moved on was offered a revival") + clone.mind.transfer_to(patient) + ADD_TRAIT(patient, TRAIT_SUICIDED, "unit_test") + TEST_ASSERT_EQUAL(rite.raise_refusal(patient), "ruined", "a suicide was offered a revival") + REMOVE_TRAIT(patient, TRAIT_SUICIDED, "unit_test") + + // Its mending is capped like any artifact healing. + var/mob/living/carbon/human/consistent/wreck = allocate(/mob/living/carbon/human/consistent, get_step(find, NORTH)) + wreck.mind_initialize() + wreck.adjustBruteLoss(170) + wreck.death() + rite.raise(wreck) + TEST_ASSERT(wreck.getBruteLoss() >= 139.5, "resurrect mended past the artifact healing cap ([wreck.getBruteLoss()] brute left)") + +/// Life steal: never heals past the shared cap, and takes exactly what it gives. +/datum/unit_test/voidcrew_xenoarch_life_steal/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/life_steal, null, 3) + var/datum/artifact_effect/life_steal/thief = find.main_effect + thief.range = 3 + var/mob/living/carbon/human/consistent/user = allocate(/mob/living/carbon/human/consistent, get_step(find, EAST)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, get_step(find, WEST)) + TEST_ASSERT_EQUAL(thief.steal_for(user, 10), 0, "life steal healed an unhurt person") + TEST_ASSERT_EQUAL(victim.getBruteLoss() + victim.getFireLoss(), 0, "life steal hurt someone without healing anyone") + user.take_overall_damage(60, 0) + var/healed = 0 + for(var/i in 1 to 6) + healed += thief.steal_for(user, 10) + TEST_ASSERT(healed <= 30.5, "life steal healed past the artifact cap ([healed])") + TEST_ASSERT(healed >= 29.5, "life steal stopped short of the cap ([healed])") + var/lost = victim.getBruteLoss() + victim.getFireLoss() + TEST_ASSERT(abs(lost - healed) < 1, "life steal took [lost] but gave [healed]") + +/// The status effects do what they say while they last and leave nothing behind. +/datum/unit_test/voidcrew_xenoarch_polaris_status_effects/Run() + var/mob/living/carbon/human/consistent/tester = allocate(/mob/living/carbon/human/consistent) + + tester.apply_status_effect(/datum/status_effect/artifact/fortify, 30 SECONDS) + tester.apply_damage(20, BRUTE, BODY_ZONE_CHEST) + var/fortified_loss = tester.getBruteLoss() + TEST_ASSERT(fortified_loss > 15 && fortified_loss < 19, "fortified skin took [fortified_loss] from a 20 brute hit") + tester.remove_status_effect(/datum/status_effect/artifact/fortify) + tester.apply_damage(20, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(tester.getBruteLoss() - fortified_loss > 19.5, "fortify outlived its status effect") + tester.fully_heal(HEAL_ALL) + + // Doses never stack past one dose, nor past the cap. + var/datum/status_effect/artifact/fortify/dose = tester.apply_status_effect(/datum/status_effect/artifact/fortify, 10 SECONDS) + tester.apply_status_effect(/datum/status_effect/artifact/fortify, 10 SECONDS) + TEST_ASSERT(dose.duration <= world.time + 10 SECONDS, "two fortify doses stacked") + tester.apply_status_effect(/datum/status_effect/artifact/fortify, 10 MINUTES) + TEST_ASSERT(dose.duration <= world.time + 90 SECONDS, "a fortify dose ran past its cap") + tester.remove_status_effect(/datum/status_effect/artifact/fortify) + + tester.apply_status_effect(/datum/status_effect/artifact/sprint, 30 SECONDS) + TEST_ASSERT(tester.has_movespeed_modifier(/datum/movespeed_modifier/status_effect/artifact_sprint), "sprint did not speed anyone up") + tester.remove_status_effect(/datum/status_effect/artifact/sprint) + TEST_ASSERT(!tester.has_movespeed_modifier(/datum/movespeed_modifier/status_effect/artifact_sprint), "sprint outlived its status effect") + + tester.apply_status_effect(/datum/status_effect/artifact/faraday, 30 SECONDS) + TEST_ASSERT(tester.emp_act(EMP_HEAVY) & EMP_PROTECT_SELF, "faraday did not stop an EMP") + tester.remove_status_effect(/datum/status_effect/artifact/faraday) + TEST_ASSERT(!(tester.emp_act(EMP_HEAVY) & EMP_PROTECT_SELF), "faraday outlived its status effect") + + tester.apply_status_effect(/datum/status_effect/artifact/feysight, 30 SECONDS) + TEST_ASSERT(HAS_TRAIT(tester, TRAIT_THERMAL_VISION), "feysight gave no sight through walls") + tester.remove_status_effect(/datum/status_effect/artifact/feysight) + TEST_ASSERT(!HAS_TRAIT(tester, TRAIT_THERMAL_VISION), "feysight outlived its status effect") + + tester.apply_status_effect(/datum/status_effect/artifact/berserk, 30 SECONDS) + TEST_ASSERT(HAS_TRAIT(tester, TRAIT_PERFECT_ATTACKER), "berserk did not take") + tester.remove_status_effect(/datum/status_effect/artifact/berserk) + TEST_ASSERT(!HAS_TRAIT(tester, TRAIT_PERFECT_ATTACKER), "berserk outlived its status effect") + TEST_ASSERT(tester.has_status_effect(/datum/status_effect/artifact/exhausted), "berserk ended without the crash") + tester.apply_status_effect(/datum/status_effect/artifact/berserk, 30 SECONDS) + TEST_ASSERT(!tester.has_status_effect(/datum/status_effect/artifact/berserk), "an exhausted person was enraged again") + tester.remove_status_effect(/datum/status_effect/artifact/exhausted) + TEST_ASSERT(!tester.has_movespeed_modifier(/datum/movespeed_modifier/status_effect/artifact_exhausted), "exhaustion outlived its status effect") + +/// Gas vents: indoors they vent from a finite reserve, then run dry for good. +/datum/unit_test/voidcrew_xenoarch_gas_vent_reserve/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + var/turf/open/here = get_turf(find) + var/datum/gas_mixture/original = here.return_air().copy() + find.replace_effects(/datum/artifact_effect/gas_vent/plasma, null, 3) + var/datum/artifact_effect/gas_vent/plasma/vent = find.main_effect + vent.reserve = 10 + vent.max_pressure = 1000 + TEST_ASSERT_EQUAL(vent.vent(6), 6, "the plasma vent did not vent indoors") + TEST_ASSERT_EQUAL(vent.vent(6), 4, "the plasma vent vented past its reserve") + TEST_ASSERT_EQUAL(vent.vent(6), 0, "a dry plasma vent kept venting") + var/list/plasma = here.return_air().gases[/datum/gas/plasma] + TEST_ASSERT(plasma && plasma[MOLES] >= 9.5, "the vented plasma is not on the tile") + here.return_air().copy_from(original) + here.air_update_turf(FALSE, FALSE) + +/// Animate never walks while bolted down, and follows someone when loose. +/datum/unit_test/voidcrew_xenoarch_animate/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/animate, null, 1) + var/datum/artifact_effect/animate/walker = find.main_effect + walker.range = 5 + var/turf/start = get_turf(find) + var/mob/living/carbon/human/consistent/quarry = allocate(/mob/living/carbon/human/consistent, locate(start.x + 3, start.y, start.z)) + quarry.mind_initialize() + find.set_anchored(TRUE) + walker.stalk() + TEST_ASSERT_EQUAL(get_turf(find), start, "a bolted artifact walked") + find.set_anchored(FALSE) + TEST_ASSERT(walker.stalk(), "a loose artifact did not follow someone in reach") + TEST_ASSERT(get_dist(find, quarry) < 3, "the artifact did not close in on its quarry") + +/** + * Polaris effects on planet ground never give a planet turf private air: the gas vents, the + * extinguisher and the force walls. (A real flame writes the air itself, so none is lit here.) Uses the shared planet air room from voidcrew_planet_shared_air.dm. + */ +/datum/unit_test/voidcrew_planet_shared_air/xenoarch_polaris_effects/Run() + if(!planetary_atmos_shared_mix_enabled()) + return + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, center) + find.replace_effects(/datum/artifact_effect/gas_vent/plasma, /datum/artifact_effect/gas_vent/sleeping, 3) + TEST_ASSERT(room_is_pristine(), "placing an artifact gave the planet private air") + for(var/datum/artifact_effect/gas_vent/vent as anything in find.effects()) + vent.release_method = "aura" + vent.wake(1 MINUTES) + TEST_ASSERT_EQUAL(vent.vent(10), 0, "a gas vent vented into planet air") + vent.do_effect_touch(null) + vent.do_effect_pulse(50) + for(var/i in 1 to 3) + find.process(2) + TEST_ASSERT(room_is_pristine(), "a gas vent running on a planet gave it private air") + find.replace_effects(/datum/artifact_effect/extinguisher, /datum/artifact_effect/forcefield, 3) + var/datum/artifact_effect/extinguisher/snuffer = find.main_effect + snuffer.range = 2 + snuffer.do_effect_pulse(50) + snuffer.do_effect_aura(2) + var/datum/artifact_effect/forcefield/field = find.second_effect + field.ring_radius = 2 + field.raise_ring(10 SECONDS) + TEST_ASSERT(room_is_pristine(), "the extinguisher or force walls gave the planet private air") + field.drop_ring() diff --git a/voidcrew/modules/xenoarch/effects_polaris/animate.dm b/voidcrew/modules/xenoarch/effects_polaris/animate.dm index 9dc7522445f..17d22f7b658 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/animate.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/animate.dm @@ -1 +1,121 @@ // Artifact effect: animate. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/animate_anomaly.dm, +// also in VOREStation (9335d66b9fdf). Voidcrew: the artifact itself lurches one step at a time +// toward the nearest person (or away from a hand laid on it). It only moves with an ordinary +// Move(), so walls, doors and people stop it, and it never steps into space, open air, lava or a +// chasm. Bolted down, it strains against the bolts instead. Not harvestable: only an artifact +// can walk. No destroy burst. + +/datum/artifact_effect/animate + label_name = "Moves on its own" + log_name = "Animate" + tier = ARTIFACT_TIER_COMMON + harvestable = FALSE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_BLUESPACE) + /// Who it is following + var/datum/weakref/quarry_ref + /// Throttles the lurch and strain messages + COOLDOWN_DECLARE(message_cooldown) + +/datum/artifact_effect/animate/setup() + range = max(range, 3) + +/datum/artifact_effect/animate/Destroy(force) + quarry_ref = null + return ..() + +/datum/artifact_effect/animate/do_effect_touch(mob/living/user) + var/obj/machinery/artifact/artifact = holder + if(!istype(artifact) || !isturf(artifact.loc)) + return + if(lurch(get_step_away(artifact, user))) + artifact.visible_message(span_warning("[artifact] lurches away from [user]!")) + +/datum/artifact_effect/animate/do_effect_aura(seconds_per_tick) + stalk() + +/datum/artifact_effect/animate/do_effect_pulse(power) + for(var/step in 1 to clamp(round(power / 12), 1, 3)) + if(!stalk()) + return + +/datum/artifact_effect/animate/do_effect_destroy() + return + +/// One step toward whoever it is following. Returns TRUE if it moved. +/datum/artifact_effect/animate/proc/stalk() + var/obj/machinery/artifact/artifact = holder + if(!istype(artifact) || !isturf(artifact.loc)) + return FALSE + var/mob/living/quarry = find_quarry() + if(!quarry) + return FALSE + artifact.setDir(get_dir(artifact, quarry)) + if(get_dist(artifact, quarry) <= 1) + return FALSE + if(!lurch(get_step_to(artifact, quarry))) + return FALSE + if(COOLDOWN_FINISHED(src, message_cooldown)) + COOLDOWN_START(src, message_cooldown, 8 SECONDS) + artifact.visible_message(span_warning("[artifact] lurches toward [quarry].")) + return TRUE + +/// Steps onto `destination` if it can stand there. Returns TRUE if it moved. +/datum/artifact_effect/animate/proc/lurch(turf/destination) + var/obj/machinery/artifact/artifact = holder + if(!istype(artifact) || !isturf(destination) || destination.z != artifact.z) + return FALSE + if(isspaceturf(destination) || isgroundlessturf(destination) || islava(destination) || ischasm(destination)) + return FALSE + if(artifact.anchored) + strain(artifact) + return FALSE + var/turf/start = artifact.loc + if(!artifact.Move(destination, get_dir(start, destination)) || artifact.loc == start) + return FALSE + playsound(artifact, pick('sound/effects/footstep/heavy1.ogg', 'sound/effects/footstep/heavy2.ogg'), 40, TRUE) + hop(artifact) + return TRUE + +/// Bolted down, it rocks against the bolts. +/datum/artifact_effect/animate/proc/strain(obj/machinery/artifact/artifact) + playsound(artifact, 'sound/effects/creak/creak1.ogg', 35, TRUE) + var/shove = pick(-3, 3) + animate(artifact, pixel_x = artifact.base_pixel_x + shove, time = 0.1 SECONDS, flags = ANIMATION_PARALLEL) + animate(pixel_x = artifact.base_pixel_x, time = 0.2 SECONDS) + if(COOLDOWN_FINISHED(src, message_cooldown)) + COOLDOWN_START(src, message_cooldown, 8 SECONDS) + artifact.visible_message(span_warning("[artifact] strains against its bolts.")) + +/// A heavy little hop. +/datum/artifact_effect/animate/proc/hop(obj/machinery/artifact/artifact) + animate(artifact, pixel_z = 4, time = 0.1 SECONDS, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + animate(pixel_z = 0, time = 0.15 SECONDS, easing = SINE_EASING | EASE_IN) + +/** + * The person it follows: the last one while they stay close and awake, else the nearest + * conscious mob in range, preferring people with a mind over animals. + */ +/datum/artifact_effect/animate/proc/find_quarry() + var/turf/center = source_turf() + if(!center) + return null + var/mob/living/quarry = quarry_ref?.resolve() + if(quarry && quarry.stat == CONSCIOUS && quarry.z == center.z && get_dist(center, quarry) <= range) + return quarry + quarry = null + var/quarry_distance = INFINITY + var/quarry_has_mind = FALSE + for(var/mob/living/candidate in living_in_range()) + if(candidate.stat != CONSCIOUS) + continue + var/has_mind = !!candidate.mind + var/distance = get_dist(center, candidate) + if(quarry_has_mind && !has_mind) + continue + if((has_mind && !quarry_has_mind) || distance < quarry_distance) + quarry = candidate + quarry_distance = distance + quarry_has_mind = has_mind + quarry_ref = quarry ? WEAKREF(quarry) : null + return quarry diff --git a/voidcrew/modules/xenoarch/effects_polaris/berserk.dm b/voidcrew/modules/xenoarch/effects_polaris/berserk.dm index 5e21a5f6cd7..f0072e09cd5 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/berserk.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/berserk.dm @@ -1 +1,33 @@ // Artifact effect: berserk. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/berserk.dm, also in +// VOREStation (9335d66b9fdf). Voidcrew: a status effect instead of Polaris' /datum/modifier. Rage +// makes every punch land, weapons hit a quarter harder and swings come faster; when it ends the +// person is drained and slow for a while, and can't be enraged again until they recover. Polaris' +// brain damage per dose is dropped: the crash afterwards is the price. Works on people only. + +/datum/artifact_effect/bestow/berserk + label_name = "Rage" + log_name = "Berserk" + tier = ARTIFACT_TIER_UNCOMMON + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_ORGANIC) + status_type = /datum/status_effect/artifact/berserk + touch_duration = 30 SECONDS + pulse_duration = 25 SECONDS + aura_duration = 10 SECONDS + aura_chance = 6 + +/datum/artifact_effect/bestow/berserk/can_bestow(mob/living/target) + return iscarbon(target) && target.stat == CONSCIOUS + +/datum/artifact_effect/bestow/berserk/on_bestowed(mob/living/target) + target.visible_message( + span_warning("[target]'s face twists with sudden fury."), + span_userdanger("Heat floods your face. Your hands want something to break."), + ) + playsound(target, 'sound/effects/magic/demon_attack1.ogg', 15, TRUE, SILENCED_SOUND_EXTRARANGE) + +/datum/artifact_effect/bestow/berserk/on_renewed(mob/living/target) + to_chat(target, span_warning("Your anger flares up again.")) + +/datum/artifact_effect/bestow/berserk/on_refused(mob/living/target) + to_chat(target, span_notice("A flash of anger comes and goes. You're too tired to hold onto it.")) diff --git a/voidcrew/modules/xenoarch/effects_polaris/disarm.dm b/voidcrew/modules/xenoarch/effects_polaris/disarm.dm index 60e09910339..fb2b5ca82fd 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/disarm.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/disarm.dm @@ -1 +1,47 @@ // Artifact effect: disarm. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/disarm.dm. Voidcrew: +// pries open the hand people are using, so what they hold drops at their feet (never thrown, so +// nothing lands in a chasm or lava); items that can't be dropped stay put. Logged like a weapon. + +/datum/artifact_effect/disarm + label_name = "Makes people drop things" + log_name = "Disarm" + tier = ARTIFACT_TIER_UNCOMMON + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_BLUESPACE) + +/datum/artifact_effect/disarm/do_effect_touch(mob/living/user) + pry(user) + +/datum/artifact_effect/disarm/do_effect_aura(seconds_per_tick) + for(var/mob/living/target in living_in_range()) + if(SPT_PROB(6, seconds_per_tick)) + pry(target) + +/datum/artifact_effect/disarm/do_effect_pulse(power) + var/turf/center = source_turf() + if(center) + new /obj/effect/temp_visual/circle_wave/artifact_mist/pry(center, max(range * 0.6, 1.5)) + for(var/mob/living/target in living_in_range()) + pry(target) + +/// Makes `target` drop what is in their active hand. Returns TRUE if it fell. +/datum/artifact_effect/disarm/proc/pry(mob/living/target) + if(target.stat != CONSCIOUS || !prob(100 * artifact_exposure(target))) + return FALSE + var/obj/item/held = target.get_active_held_item() + if(!held || !target.dropItemToGround(held)) + return FALSE + target.visible_message( + span_warning("[target]'s hand jerks open and [held] falls to the floor."), + span_warning("Something pries your fingers open. [held] falls out of your grip!"), + ) + playsound(target, 'sound/items/weapons/thudswoosh.ogg', 40, TRUE) + new /obj/effect/temp_visual/telekinesis(get_turf(target)) + log_harm(target) + return TRUE + +/// A faint violet ripple for the burst. +/obj/effect/temp_visual/circle_wave/artifact_mist/pry + color = "#e17ceb" + max_alpha = 110 diff --git a/voidcrew/modules/xenoarch/effects_polaris/electric_field.dm b/voidcrew/modules/xenoarch/effects_polaris/electric_field.dm index 870a293c5f0..4ca6380c00d 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/electric_field.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/electric_field.dm @@ -1 +1,95 @@ // Artifact effect: electric field. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/electric_field.dm, +// also in VOREStation (9335d66b9fdf). Voidcrew: arcs only find robots, prosthetic-bodied mobs and +// people holding something metal, so it can be read and avoided (empty hands, insulated gloves); +// Polaris shocked everyone in range for up to 40 burn. Field arcs never stun, bursts only knock +// down briefly, and every arc is logged. A hand on it grounds the toucher: the charge leaps to +// everyone else nearby instead, as in Polaris. Lights in range flicker as it charges. + +/// Lights one charge can flicker, so a room full of lamps costs no more than a few +#define ARTIFACT_FIELD_MAX_FLICKERS 6 + +/datum/artifact_effect/electric_field + label_name = "Shocks" + log_name = "Electric field" + tier = ARTIFACT_TIER_UNCOMMON + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ELECTROMAGNETIC, ARTIFACT_ENERGY_CONCENTRATED) + +/datum/artifact_effect/electric_field/do_effect_touch(mob/living/user) + flicker_lights() + var/arcs = 0 + for(var/mob/living/target in living_in_range()) + if(target == user) + continue + if(arc_to(target, rand(10, 15), knockdown = FALSE)) + arcs++ + if(arcs) + to_chat(user, span_warning("A charge runs up your arm, through you, and leaps away.")) + playsound(source_turf(), 'sound/effects/magic/lightningshock.ogg', 35, TRUE) + else + to_chat(user, span_notice("The hair on your arm stands up, then settles.")) + +/datum/artifact_effect/electric_field/do_effect_aura(seconds_per_tick) + if(SPT_PROB(15, seconds_per_tick)) + flicker_lights(2) + for(var/mob/living/target in living_in_range()) + if(SPT_PROB(10, seconds_per_tick)) + arc_to(target, rand(3, 6), knockdown = FALSE) + +/datum/artifact_effect/electric_field/do_effect_pulse(power) + var/turf/center = source_turf() + if(!center) + return + flicker_lights() + playsound(center, 'sound/effects/magic/lightningshock.ogg', 50, TRUE) + new /obj/effect/temp_visual/electricity(center) + for(var/mob/living/target in living_in_range()) + arc_to(target, clamp(power * 0.4, 6, 18), knockdown = power >= 25) + +/** + * Arcs to `target` if it is a machine or holds something metal. Returns TRUE if the shock took. + * Insulated gloves and a suit's insulation work as they do against any shock. + */ +/datum/artifact_effect/electric_field/proc/arc_to(mob/living/target, damage, knockdown) + if(target.stat == DEAD || !conducts(target)) + return FALSE + damage *= artifact_exposure(target) + if(damage < 1) + return FALSE + var/flags = SHOCK_SUPPRESS_MESSAGE | (knockdown ? SHOCK_KNOCKDOWN : SHOCK_NOSTUN) + // Positional on purpose: only the carbon override has the jitter, stutter and stun arguments. + if(!target.electrocute_act(damage, holder, 1, flags, 4 SECONDS, 2 SECONDS, 1 SECONDS)) + return FALSE + var/atom/origin = get_atom_on_turf(holder) + origin?.Beam(target, icon_state = "lightning[rand(1, 12)]", time = 0.5 SECONDS) + if(issilicon(target) || (target.mob_biotypes & MOB_ROBOTIC)) + to_chat(target, span_danger("ERROR: Electrical fault detected!")) + target.adjust_stutter(3 SECONDS) + else + to_chat(target, span_danger("A spark leaps from [holder] to you!")) + log_harm(target) + return TRUE + +/// Robots and anything with metal in hand make a path for the charge. +/datum/artifact_effect/electric_field/proc/conducts(mob/living/target) + if(issilicon(target) || (target.mob_biotypes & MOB_ROBOTIC)) + return TRUE + for(var/obj/item/held in target.held_items) + if(held.obj_flags & CONDUCTS_ELECTRICITY) + return TRUE + return FALSE + +/// Makes a few lights in range stutter. +/datum/artifact_effect/electric_field/proc/flicker_lights(limit = ARTIFACT_FIELD_MAX_FLICKERS) + var/turf/center = source_turf() + if(!center) + return + var/flickered = 0 + for(var/obj/machinery/light/light in range(range, center)) + if(flickered >= limit) + return + if(light.flicker(rand(3, 6))) + flickered++ + +#undef ARTIFACT_FIELD_MAX_FLICKERS diff --git a/voidcrew/modules/xenoarch/effects_polaris/extinguisher.dm b/voidcrew/modules/xenoarch/effects_polaris/extinguisher.dm index f7405b2a680..66166f5a773 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/extinguisher.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/extinguisher.dm @@ -1 +1,109 @@ // Artifact effect: extinguisher. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/extinguisher.dm. +// Voidcrew: puts out burning people, burning objects and open flames in its range, and wets +// people a little so they are slow to catch again. Air is only cooled indoors; on planet ground +// it snuffs the flames and never touches the shared planet air. No wet floors (Polaris left +// slippery tiles); no destroy burst. + +/// Hot air on a fire tile is pulled down toward this +#define ARTIFACT_EXTINGUISH_COOL_TO (T20C + 30) +/// At most this many kelvin come off a fire tile's air per douse +#define ARTIFACT_EXTINGUISH_COOL_STEP 120 + +/datum/artifact_effect/extinguisher + label_name = "Puts out fires" + log_name = "Extinguisher" + tier = ARTIFACT_TIER_COMMON + minor = TRUE + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_SYNTHESIS, ARTIFACT_ENERGY_PARTICLE) + +/datum/artifact_effect/extinguisher/do_effect_touch(mob/living/user) + douse(user, 4) + to_chat(user, span_notice("Cold mist beads on your skin where you touched [holder].")) + playsound(source_turf(), 'sound/effects/extinguish.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) + +/datum/artifact_effect/extinguisher/do_effect_aura(seconds_per_tick) + var/turf/center = source_turf() + if(!center) + return + var/quenched = quench_area(center) + for(var/mob/living/target in living_in_range()) + if(target.on_fire) + douse(target, 2) + quenched = TRUE + if(quenched) + playsound(center, 'sound/effects/extinguish.ogg', 30, TRUE) + else if(SPT_PROB(15, seconds_per_tick)) + new /obj/effect/temp_visual/artifact_mist(center) + +/datum/artifact_effect/extinguisher/do_effect_pulse(power) + var/turf/center = source_turf() + if(!center) + return + new /obj/effect/temp_visual/circle_wave/artifact_mist(center, max(range * 0.6, 1.5)) + playsound(center, 'sound/effects/extinguish.ogg', 45, TRUE) + quench_area(center) + for(var/mob/living/target in living_in_range()) + douse(target, 3) + +/datum/artifact_effect/extinguisher/do_effect_destroy() + return + +/// Puts out `target` and leaves them damp. Tells them if they were burning. +/datum/artifact_effect/extinguisher/proc/douse(mob/living/target, wetness) + var/was_burning = target.on_fire + target.extinguish_mob() + target.adjust_wet_stacks(wetness * artifact_exposure(target)) + if(was_burning && !target.on_fire) + to_chat(target, span_notice("A cold mist rolls over you, and the flames on you gutter out.")) + +/// Snuffs open flames and burning objects in range. Returns TRUE if it put anything out. +/datum/artifact_effect/extinguisher/proc/quench_area(turf/center) + . = FALSE + for(var/obj/effect/hotspot/flame in range(range, center)) + var/turf/open/flame_turf = flame.loc + qdel(flame) + cool_air(flame_turf) + new /obj/effect/temp_visual/artifact_mist(flame_turf) + . = TRUE + for(var/obj/burning in range(range, center)) + if(burning.resistance_flags & ON_FIRE) + burning.extinguish() + . = TRUE + +/// Takes the heat out of an indoor fire tile so it doesn't flare straight back. Never planet air. +/datum/artifact_effect/extinguisher/proc/cool_air(turf/open/spot) + if(!istype(spot) || spot.planetary_atmos || isspaceturf(spot)) + return + var/datum/gas_mixture/air = spot.return_air() + if(!air || air.temperature <= ARTIFACT_EXTINGUISH_COOL_TO) + return + air.temperature = max(ARTIFACT_EXTINGUISH_COOL_TO, air.temperature - ARTIFACT_EXTINGUISH_COOL_STEP) + spot.air_update_turf(FALSE, FALSE) + +/// A puff of cold mist. +/obj/effect/temp_visual/artifact_mist + icon_state = "extinguish" + alpha = 200 + duration = 0.8 SECONDS + +/obj/effect/temp_visual/artifact_mist/Initialize(mapload) + . = ..() + pixel_x = rand(-6, 6) + pixel_y = rand(-4, 8) + animate(src, alpha = 0, pixel_y = pixel_y + 6, time = duration) + +/// A ring of mist rolling out from the artifact. +/obj/effect/temp_visual/circle_wave/artifact_mist + color = "#cfe9ff" + max_alpha = 170 + duration = 0.8 SECONDS + +/obj/effect/temp_visual/circle_wave/artifact_mist/Initialize(mapload, scale) + if(isnum(scale)) + amount_to_scale = scale + return ..() + +#undef ARTIFACT_EXTINGUISH_COOL_TO +#undef ARTIFACT_EXTINGUISH_COOL_STEP diff --git a/voidcrew/modules/xenoarch/effects_polaris/faraday.dm b/voidcrew/modules/xenoarch/effects_polaris/faraday.dm index 653c55103f6..117dfd06f43 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/faraday.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/faraday.dm @@ -1 +1,25 @@ // Artifact effect: faraday. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/faraday.dm. +// Voidcrew: a status effect that swallows EMPs for the wearer and everything they carry +// (Polaris used a /datum/modifier); doses never stack past two minutes. + +/datum/artifact_effect/bestow/faraday + label_name = "EMP shielding" + log_name = "Faraday" + tier = ARTIFACT_TIER_UNCOMMON + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ELECTROMAGNETIC, ARTIFACT_ENERGY_PARTICLE) + status_type = /datum/status_effect/artifact/faraday + touch_duration = 90 SECONDS + pulse_duration = 30 SECONDS + aura_duration = 10 SECONDS + +/datum/artifact_effect/bestow/faraday/on_bestowed(mob/living/target) + if(issilicon(target)) + to_chat(target, span_notice("Your sensors go quiet. Background interference: none.")) + else + to_chat(target, span_notice("The hair on your arms lies flat, and a cold hush settles over your skin.")) + playsound(target, 'sound/effects/magic/magic_block.ogg', 20, TRUE, SILENCED_SOUND_EXTRARANGE) + +/datum/artifact_effect/bestow/faraday/on_renewed(mob/living/target) + to_chat(target, span_notice("The hush on your skin deepens.")) diff --git a/voidcrew/modules/xenoarch/effects_polaris/feysight.dm b/voidcrew/modules/xenoarch/effects_polaris/feysight.dm index 902c4ab4625..60c5fb1ca08 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/feysight.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/feysight.dm @@ -1 +1,33 @@ // Artifact effect: feysight. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/feysight.dm, also in +// VOREStation (9335d66b9fdf). Voidcrew: a status effect giving thermal sight (living things show +// through walls) with a faint green tint, instead of Polaris' /datum/modifier. The first dose +// still costs a pounding headache, as in Polaris. Doses never stack past 45 seconds. + +#define ARTIFACT_FEYSIGHT_HEADACHE 10 + +/datum/artifact_effect/bestow/feysight + label_name = "Second sight" + log_name = "Feysight" + tier = ARTIFACT_TIER_RARE + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC) + status_type = /datum/status_effect/artifact/feysight + touch_duration = 30 SECONDS + pulse_duration = 20 SECONDS + aura_duration = 8 SECONDS + aura_chance = 8 + +/datum/artifact_effect/bestow/feysight/can_bestow(mob/living/target) + return iscarbon(target) && target.stat != DEAD + +/datum/artifact_effect/bestow/feysight/on_bestowed(mob/living/target) + to_chat(target, span_hypnophrase("The walls go thin as paper, and through them, warm shapes move.")) + to_chat(target, span_warning("The inside of your head hurts...")) + target.adjustStaminaLoss(ARTIFACT_FEYSIGHT_HEADACHE) + playsound(target, 'sound/effects/magic/magic_block_mind.ogg', 20, TRUE, SILENCED_SOUND_EXTRARANGE) + +/datum/artifact_effect/bestow/feysight/on_renewed(mob/living/target) + to_chat(target, span_hypnophrase("The shapes behind the walls sharpen.")) + +#undef ARTIFACT_FEYSIGHT_HEADACHE diff --git a/voidcrew/modules/xenoarch/effects_polaris/forcefield.dm b/voidcrew/modules/xenoarch/effects_polaris/forcefield.dm index 4ee85013446..b50008e930e 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/forcefield.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/forcefield.dm @@ -1 +1,129 @@ // Artifact effect: forcefield. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/forcefield.dm, also in +// VOREStation (9335d66b9fdf). Voidcrew: a ring of short-lived force walls two tiles out (three for a +// strong one) instead of Polaris' permanent sixteen-wall box. A burst or a touch raises it for a +// few seconds; a field holds it up only while the field runs and drops it the moment it rests. +// Walls skip tiles already blocked (walls, closed doors, machines) and fade in, so nobody is +// sealed into a wall. Everything it raised goes when it sleeps or is destroyed. Not harvestable. + +/// How long a field keeps its ring after its last run before letting it drop +#define ARTIFACT_FORCEFIELD_AURA_GRACE (3 SECONDS) + +/datum/artifact_effect/forcefield + label_name = "Force walls" + log_name = "Forcefield" + tier = ARTIFACT_TIER_UNCOMMON + harvestable = FALSE + possible_kinds = list(ARTIFACT_ENERGY_PARTICLE, ARTIFACT_ENERGY_BLUESPACE) + /// Tiles from the artifact to the ring + var/ring_radius = 2 + /// How long a burst or touch keeps the ring up + var/ring_time = 10 SECONDS + /// The walls it raised that still stand + var/list/obj/effect/forcefield/artifact/walls = list() + /// world.time a field last held the ring up + var/last_held = 0 + +/datum/artifact_effect/forcefield/setup() + switch(strength) + if(ARTIFACT_STRENGTH_LARGE) + ring_radius = 3 + ring_time = 15 SECONDS + if(ARTIFACT_STRENGTH_MEDIUM) + ring_time = 12 SECONDS + else + ring_time = 8 SECONDS + // A touch needs a good part of the store, so a hand can't keep the ring up for free. + touch_cost = max(touch_cost, round(maximum_charges / 2)) + +/datum/artifact_effect/forcefield/copy_settings_to(datum/artifact_effect/forcefield/copy) + copy.ring_radius = ring_radius + copy.ring_time = ring_time + +/datum/artifact_effect/forcefield/Destroy(force) + drop_ring() + return ..() + +/datum/artifact_effect/forcefield/on_deactivate() + drop_ring() + +/datum/artifact_effect/forcefield/tick(seconds_per_tick) + . = ..() + if(release_method == ARTIFACT_RELEASE_AURA && length(walls) && world.time > last_held + ARTIFACT_FORCEFIELD_AURA_GRACE) + drop_ring() + +/datum/artifact_effect/forcefield/do_effect_touch(mob/living/user) + to_chat(user, span_notice("The air around [holder] goes taut as a drumskin.")) + raise_ring(ring_time) + +/datum/artifact_effect/forcefield/do_effect_aura(seconds_per_tick) + last_held = world.time + if(!length(walls)) + // Long enough to outlast any one run; the field drops it itself when it rests. + raise_ring(2 MINUTES) + +/datum/artifact_effect/forcefield/do_effect_pulse(power) + raise_ring(ring_time) + +/datum/artifact_effect/forcefield/do_effect_destroy() + return + +/// Raises a fresh ring around the artifact. Returns how many walls went up. +/datum/artifact_effect/forcefield/proc/raise_ring(duration) + drop_ring() + var/turf/center = source_turf() + if(!center) + return 0 + var/tint = artifact_energy_kind(energy_kind).color + for(var/turf/open/spot in RANGE_TURFS(ring_radius, center)) + if(max(abs(spot.x - center.x), abs(spot.y - center.y)) != ring_radius) + continue + if(isspaceturf(spot) || isgroundlessturf(spot) || spot.is_blocked_turf(exclude_mobs = TRUE)) + continue + var/obj/effect/forcefield/artifact/wall = new(spot, duration, tint) + walls += wall + RegisterSignal(wall, COMSIG_QDELETING, PROC_REF(wall_gone)) + if(length(walls)) + playsound(center, 'sound/effects/magic/forcewall.ogg', 45, TRUE) + center.visible_message(span_warning("Walls of rippling light spring up around [holder]!")) + return length(walls) + +/// Takes down every wall it raised. +/datum/artifact_effect/forcefield/proc/drop_ring() + if(!length(walls)) + return + for(var/obj/effect/forcefield/artifact/wall as anything in walls) + UnregisterSignal(wall, COMSIG_QDELETING) + wall.fade_out() + walls.Cut() + +/// A wall timed out or was deleted: forget it. +/datum/artifact_effect/forcefield/proc/wall_gone(datum/source) + SIGNAL_HANDLER + walls -= source + +/// One pane of the ring. +/obj/effect/forcefield/artifact + name = "shimmering wall" + desc = "A pane of rippling light, hard as glass." + icon_state = "shield-greyscale" + alpha = 0 + initial_duration = 10 SECONDS + +/obj/effect/forcefield/artifact/Initialize(mapload, duration, tint) + if(isnum(duration)) + initial_duration = duration + . = ..() + if(tint) + color = tint + animate(src, alpha = 190, time = 0.4 SECONDS) + +/// Fades and goes, rather than blinking out. +/obj/effect/forcefield/artifact/proc/fade_out() + if(QDELETED(src)) + return + set_density(FALSE) + animate(src, alpha = 0, time = 0.3 SECONDS) + QDEL_IN(src, 0.3 SECONDS) + +#undef ARTIFACT_FORCEFIELD_AURA_GRACE diff --git a/voidcrew/modules/xenoarch/effects_polaris/fortify.dm b/voidcrew/modules/xenoarch/effects_polaris/fortify.dm index fb611a3afe2..c89b845939a 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/fortify.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/fortify.dm @@ -1 +1,25 @@ // Artifact effect: fortify. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/fortify.dm, also in +// VOREStation (9335d66b9fdf). Voidcrew: a short status effect taking 15% off brute and burn +// (Polaris used a /datum/modifier); doses never stack past a minute and a half. + +/datum/artifact_effect/bestow/fortify + label_name = "Toughens skin" + log_name = "Fortify" + tier = ARTIFACT_TIER_UNCOMMON + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_CONCENTRATED, ARTIFACT_ENERGY_ORGANIC) + status_type = /datum/status_effect/artifact/fortify + touch_duration = 60 SECONDS + pulse_duration = 30 SECONDS + aura_duration = 10 SECONDS + +/datum/artifact_effect/bestow/fortify/on_bestowed(mob/living/target) + if(issilicon(target)) + to_chat(target, span_notice("Your plating hums and stiffens.")) + else + to_chat(target, span_notice("Your skin tightens and goes tough as old leather.")) + playsound(target, 'sound/effects/magic/fleshtostone.ogg', 20, TRUE, SILENCED_SOUND_EXTRARANGE) + +/datum/artifact_effect/bestow/fortify/on_renewed(mob/living/target) + to_chat(target, span_notice("Your skin tightens again.")) diff --git a/voidcrew/modules/xenoarch/effects_polaris/gaia.dm b/voidcrew/modules/xenoarch/effects_polaris/gaia.dm index d3a5bd5022e..0e8583eb7be 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/gaia.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/gaia.dm @@ -1 +1,118 @@ // Artifact effect: gaia. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/gaia.dm, also in +// VOREStation (9335d66b9fdf). Voidcrew: tends living plants in hydroponics trays nearby (water, +// health, weeds, pests and toxins) but never speeds their growth or revives dead ones, so it +// saves a gardener's chores without making more crop. Plant people nearby feel it too, inside the +// shared artifact healing cap. Polaris' glitterflies become a few short-lived butterflies, at +// most three at a time, that fade away on their own. + +/// Butterflies alive at once, per artifact +#define ARTIFACT_GAIA_MAX_BUTTERFLIES 3 + +/datum/artifact_effect/gaia + label_name = "Feeds plants" + log_name = "Gaia" + tier = ARTIFACT_TIER_UNCOMMON + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC, ARTIFACT_ENERGY_SYNTHESIS) + /// Weakrefs to the butterflies it has drawn + var/list/datum/weakref/butterflies = list() + +/datum/artifact_effect/gaia/Destroy(force) + for(var/datum/weakref/butterfly_ref as anything in butterflies) + var/mob/living/basic/butterfly/lavaland/temporary/butterfly = butterfly_ref.resolve() + if(butterfly) + butterfly.fadeout() + butterflies = null + return ..() + +/datum/artifact_effect/gaia/do_effect_touch(mob/living/user) + to_chat(user, span_notice("You feel the presence of something long forgotten, and green.")) + var/tended = tend_all(range + 2, 3, 30) + if(tended) + to_chat(user, span_notice("Somewhere nearby, leaves rustle.")) + +/datum/artifact_effect/gaia/do_effect_aura(seconds_per_tick) + tend_all(range, 0.5 * seconds_per_tick, 2) + for(var/mob/living/carbon/human/sprout in living_in_range()) + if(SPT_PROB(10, seconds_per_tick)) + nourish(sprout, 2) + +/datum/artifact_effect/gaia/do_effect_pulse(power) + var/turf/center = source_turf() + if(!center) + return + new /obj/effect/temp_visual/circle_wave/artifact_mist/gaia(center, max(range * 0.6, 1.5)) + playsound(center, 'sound/effects/rustle/rustle1.ogg', 40, TRUE) + tend_all(range, clamp(power / 5, 2, 8), 10) + for(var/mob/living/carbon/human/sprout in living_in_range()) + nourish(sprout, clamp(power / 4, 2, 8)) + +/** + * Tends every planted tray in `reach` by `amount`, with `butterfly_chance` per tray of drawing a + * butterfly. Returns how many it tended. + */ +/datum/artifact_effect/gaia/proc/tend_all(reach, amount, butterfly_chance) + . = 0 + var/turf/center = source_turf() + if(!center) + return + for(var/obj/machinery/hydroponics/tray in range(reach, center)) + if(!tend(tray, amount)) + continue + .++ + if(prob(butterfly_chance)) + draw_butterfly(get_turf(tray)) + +/// Waters, weeds and soothes one tray's living plant. Never ages it. Returns TRUE if it had one. +/datum/artifact_effect/gaia/proc/tend(obj/machinery/hydroponics/tray, amount) + if(!tray.myseed || tray.plant_status == HYDROTRAY_PLANT_DEAD) + return FALSE + tray.adjust_waterlevel(amount * 3) + tray.adjust_plant_health(amount) + tray.adjust_weedlevel(-1) + tray.adjust_pestlevel(-1) + tray.adjust_toxic(-amount) + tray.update_appearance() + if(prob(40)) + new /obj/effect/temp_visual/artifact_gaia_bloom(get_turf(tray)) + return TRUE + +/// Plant people take a little warmth from it, inside the shared healing cap. +/datum/artifact_effect/gaia/proc/nourish(mob/living/carbon/human/sprout, amount) + if(sprout.stat == DEAD || !(sprout.mob_biotypes & MOB_PLANT)) + return + if(artifact_capped_heal(sprout, amount * artifact_exposure(sprout)) > 0 && prob(30)) + to_chat(sprout, span_notice("A warm, green feeling seeps into your leaves.")) + +/// A butterfly comes to the plants for a while. +/datum/artifact_effect/gaia/proc/draw_butterfly(turf/spot) + for(var/datum/weakref/butterfly_ref as anything in butterflies) + if(!butterfly_ref.resolve()) + butterflies -= butterfly_ref + if(length(butterflies) >= ARTIFACT_GAIA_MAX_BUTTERFLIES || !istype(spot)) + return + var/mob/living/basic/butterfly/lavaland/temporary/butterfly = new(spot) + butterfly.source = get_atom_on_turf(holder) + butterfly.max_distance = range + 3 + butterflies += WEAKREF(butterfly) + addtimer(CALLBACK(butterfly, TYPE_PROC_REF(/mob/living/basic/butterfly/lavaland/temporary, fadeout)), rand(60, 120) SECONDS, TIMER_DELETE_ME) + +/// A green shimmer over a tended tray. +/obj/effect/temp_visual/artifact_gaia_bloom + icon = 'icons/obj/service/hydroponics/equipment.dmi' + icon_state = "gaia_blessing" + duration = 1.5 SECONDS + +/obj/effect/temp_visual/artifact_gaia_bloom/Initialize(mapload) + . = ..() + alpha = 0 + animate(src, alpha = 255, time = 0.4 SECONDS) + animate(alpha = 0, time = 1.1 SECONDS) + +/// A soft green ring for the burst. +/obj/effect/temp_visual/circle_wave/artifact_mist/gaia + color = "#8cd448" + max_alpha = 140 + +#undef ARTIFACT_GAIA_MAX_BUTTERFLIES diff --git a/voidcrew/modules/xenoarch/effects_polaris/gravity_wave.dm b/voidcrew/modules/xenoarch/effects_polaris/gravity_wave.dm index 5cf9fe346fc..cd95625b693 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/gravity_wave.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/gravity_wave.dm @@ -1 +1,122 @@ // Artifact effect: gravity wave. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/gravitational_waves.dm, +// also in VOREStation (9335d66b9fdf). Voidcrew: one huge knockback ring instead of Polaris' +// singularity pull. It draws the air in for a moment first (a shimmer closing on it, a rising +// hum), so anyone watching has time to brace or back off; then everything loose in reach is +// flung outward and people are knocked down, hardest near the middle. Anchored things stay put. +// Smashing it lets the wave go at once. Not harvestable; logged. + +/// How long it gathers before the wave +#define ARTIFACT_WAVE_WINDUP (1.5 SECONDS) +/// Furthest it ever reaches +#define ARTIFACT_WAVE_MAX_RANGE 7 + +/datum/artifact_effect/gravity_wave + label_name = "Shockwave" + log_name = "Gravity wave" + tier = ARTIFACT_TIER_EXTREME + harvestable = FALSE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_BLUESPACE, ARTIFACT_ENERGY_CONCENTRATED, ARTIFACT_ENERGY_PSIONIC) + allowed_release_methods = list(ARTIFACT_RELEASE_TOUCH, ARTIFACT_RELEASE_PULSE) + /// A wave is gathering + var/gathering = FALSE + +/datum/artifact_effect/gravity_wave/setup() + range = clamp(range, 3, ARTIFACT_WAVE_MAX_RANGE) + // A wave needs a good part of the store; a hand can't set one off every few seconds. + touch_cost = max(touch_cost, round(maximum_charges / 2)) + +/datum/artifact_effect/gravity_wave/do_effect_touch(mob/living/user) + to_chat(user, span_warning("[holder] hums under your hand, louder and louder.")) + gather() + +/datum/artifact_effect/gravity_wave/do_effect_pulse(power) + gather() + +/datum/artifact_effect/gravity_wave/do_effect_destroy() + release_wave() + +/// The warning: the air draws in toward it, then the wave goes. +/datum/artifact_effect/gravity_wave/proc/gather() + var/turf/center = source_turf() + if(gathering || !center) + return FALSE + gathering = TRUE + center.visible_message(span_danger("The air around [holder] bends and draws in toward it.")) + playsound(center, 'sound/effects/magic/cosmic_expansion.ogg', 50, TRUE) + new /obj/effect/temp_visual/artifact_wave_gather(center, range) + addtimer(CALLBACK(src, PROC_REF(release_wave)), ARTIFACT_WAVE_WINDUP, TIMER_DELETE_ME) + return TRUE + +/// Flings everything loose in reach outward. Does nothing if it was crated or put to sleep meanwhile. +/datum/artifact_effect/gravity_wave/proc/release_wave() + gathering = FALSE + var/obj/machinery/artifact/artifact = holder + if(istype(artifact) && artifact.suppressed) + return + var/turf/center = source_turf() + if(!center) + return + new /obj/effect/temp_visual/circle_wave/artifact_mist/gravity_wave(center, range) + playsound(center, 'sound/effects/gravhit.ogg', 70, TRUE, extrarange = 4) + playsound(center, 'sound/effects/magic/repulse.ogg', 60, TRUE) + for(var/atom/movable/thing in range(range, center)) + if(thing == holder || thing == get_atom_on_turf(holder) || !can_fling(thing)) + continue + fling(thing, center) + +/// Loose items, unanchored structures and the living; nothing anchored or immovable. +/datum/artifact_effect/gravity_wave/proc/can_fling(atom/movable/thing) + if(thing.anchored || thing.move_resist > MOVE_FORCE_STRONG || !isturf(thing.loc)) + return FALSE + if(isliving(thing)) + var/mob/living/victim = thing + return !victim.buckled + return isitem(thing) || isstructure(thing) + +/// Throws `thing` directly away from `center`, harder the closer it stood. +/datum/artifact_effect/gravity_wave/proc/fling(atom/movable/thing, turf/center) + var/distance = get_dist(center, thing) + var/exposure = isliving(thing) ? artifact_exposure(thing) : 1 + var/throw_range = round(clamp(range - distance + 2, 2, 6) * exposure) + if(throw_range < 1) + return + var/direction = (distance > 0) ? get_dir(center, thing) : pick(GLOB.alldirs) + var/turf/landing = get_ranged_target_turf(thing, direction, throw_range) + if(!landing) + return + if(isliving(thing)) + var/mob/living/victim = thing + shake_camera(victim, 3, 2) + victim.Knockdown(2 SECONDS * exposure) + to_chat(victim, span_userdanger("A wall of force hits you and lifts you off your feet!")) + log_harm(victim) + // Positional: some throw_at() overrides rename their arguments. + thing.throw_at(landing, throw_range, 2) + +/// A shimmer closing in on the artifact before the wave. +/obj/effect/temp_visual/artifact_wave_gather + icon = 'icons/effects/64x64.dmi' + icon_state = "circle_wave" + pixel_x = -16 + pixel_y = -16 + color = "#d8c3ff" + alpha = 0 + duration = ARTIFACT_WAVE_WINDUP + +/obj/effect/temp_visual/artifact_wave_gather/Initialize(mapload, reach = 4) + . = ..() + transform = matrix().Scale(max(reach, 1)) + animate(src, transform = matrix().Scale(0.1), time = duration, easing = SINE_EASING | EASE_IN, flags = ANIMATION_PARALLEL) + animate(src, alpha = 160, time = duration * 0.5, flags = ANIMATION_PARALLEL) + animate(alpha = 220, time = duration * 0.5) + +/// The wave itself. +/obj/effect/temp_visual/circle_wave/artifact_mist/gravity_wave + color = "#d8c3ff" + max_alpha = 230 + duration = 0.6 SECONDS + +#undef ARTIFACT_WAVE_WINDUP +#undef ARTIFACT_WAVE_MAX_RANGE diff --git a/voidcrew/modules/xenoarch/effects_polaris/life_drain.dm b/voidcrew/modules/xenoarch/effects_polaris/life_drain.dm index 6fc56609d67..c23a4099252 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/life_drain.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/life_drain.dm @@ -1 +1,102 @@ // Artifact effect: life drain. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/lifedrain.dm. Voidcrew: +// a sickly beam hooks into someone nearby; if they are still in reach a few seconds later, it +// tears a little life out of them (bruising, breathlessness and a spell of weakness). Stepping out +// of reach snaps the beam, so it can always be escaped. One beam per person at a time, people in +// a good biosuit are ignored (as in Polaris), and every drain is logged. Polaris healed the +// toucher with what it took; that is the extreme Life steal effect, so this only takes. + +/// Seconds between the hook and the drain +#define ARTIFACT_DRAIN_WINDUP (3 SECONDS) + +/datum/artifact_effect/life_drain + label_name = "Drains life" + log_name = "Life drain" + tier = ARTIFACT_TIER_RARE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC, ARTIFACT_ENERGY_CONCENTRATED) + /// REF(victim) -> TRUE while a beam is hooked into them + var/list/hooked = list() + +/datum/artifact_effect/life_drain/Destroy(force) + hooked = null + return ..() + +/datum/artifact_effect/life_drain/do_effect_touch(mob/living/user) + hook(user, 10) + +/datum/artifact_effect/life_drain/do_effect_aura(seconds_per_tick) + for(var/mob/living/target in living_in_range()) + if(SPT_PROB(6, seconds_per_tick)) + hook(target, 5) + +/datum/artifact_effect/life_drain/do_effect_pulse(power) + var/list/victims = living_in_range() + for(var/i in 1 to 2) + if(!length(victims)) + return + hook(pick_n_take(victims), clamp(power * 0.3, 4, 12)) + +/// Smashed, it lashes everyone in reach at once, with no warning. +/datum/artifact_effect/life_drain/do_effect_destroy() + for(var/mob/living/target in living_in_range()) + if(can_hook(target)) + siphon(target, 6) + +/// Whether `target` is somebody it can feed on. +/datum/artifact_effect/life_drain/proc/can_hook(mob/living/target) + if(target.stat == DEAD || hooked?[REF(target)]) + return FALSE + if(target == get_atom_on_turf(holder)) + return FALSE + return artifact_exposure(target) >= 0.5 + +/// Hooks a beam into `target`; the drain lands after the windup if they stay. Returns TRUE if it hooked. +/datum/artifact_effect/life_drain/proc/hook(mob/living/target, damage) + if(!can_hook(target)) + return FALSE + var/atom/origin = get_atom_on_turf(holder) + if(!origin) + return FALSE + var/datum/beam/drain_beam = origin.Beam(target, icon_state = "drain_life", time = ARTIFACT_DRAIN_WINDUP + 0.5 SECONDS, maxdistance = range + 1) + var/key = REF(target) + hooked[key] = TRUE + target.visible_message( + span_danger("A sickly beam lashes out from [holder] and hooks into [target]!"), + span_userdanger("A sickly beam lashes out from [holder] and hooks into you. Something cold starts to pull."), + ) + playsound(target, 'sound/effects/magic/enter_blood.ogg', 35, TRUE) + addtimer(CALLBACK(src, PROC_REF(finish_hook), WEAKREF(target), WEAKREF(drain_beam), key, damage), ARTIFACT_DRAIN_WINDUP, TIMER_DELETE_ME) + return TRUE + +/// The windup ended: drains `target` if the beam still holds them. +/datum/artifact_effect/life_drain/proc/finish_hook(datum/weakref/target_ref, datum/weakref/beam_ref, key, damage) + hooked -= key + var/mob/living/target = target_ref?.resolve() + var/datum/beam/drain_beam = beam_ref?.resolve() + if(!target || target.stat == DEAD) + qdel(drain_beam) + return + if(QDELETED(drain_beam)) + to_chat(target, span_notice("The cold hook slips out of you.")) + return + qdel(drain_beam) + siphon(target, damage) + +/// Tears `damage` worth of life out of `target`. +/datum/artifact_effect/life_drain/proc/siphon(mob/living/target, damage) + damage *= artifact_exposure(target) + if(damage <= 0) + return + target.take_overall_damage(damage) + target.adjustStaminaLoss(damage * 2) + target.apply_status_effect(/datum/status_effect/artifact/exhausted, 10 SECONDS) + new /obj/effect/temp_visual/heal(get_turf(target), "#7a1d3a") + target.visible_message( + span_danger("[holder] pulls something pale and shining out of [target]."), + span_userdanger("Something is torn out of you. Your legs go weak."), + ) + playsound(target, 'sound/effects/magic/exit_blood.ogg', 40, TRUE) + log_harm(target) + +#undef ARTIFACT_DRAIN_WINDUP diff --git a/voidcrew/modules/xenoarch/effects_polaris/life_steal.dm b/voidcrew/modules/xenoarch/effects_polaris/life_steal.dm index 9af86bcbc54..70d0b1ff0cc 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/life_steal.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/life_steal.dm @@ -1 +1,82 @@ // Artifact effect: life steal. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/lifesteal.dm. +// Voidcrew: heals one person by taking the same amount from everyone else in reach, split between +// them. It only takes what it gives, so nothing happens unless the person it feeds is hurt, and +// what it gives goes through the shared artifact healing cap: it is a slow trickle, never a +// medbay and never a weapon. Who it feeds: the hand on it, the person carrying it, or for a burst +// the nearest hurt person. Every theft is logged. + +/datum/artifact_effect/life_steal + label_name = "Steals life" + log_name = "Life steal" + tier = ARTIFACT_TIER_EXTREME + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC, ARTIFACT_ENERGY_CONCENTRATED) + allowed_release_methods = list(ARTIFACT_RELEASE_TOUCH, ARTIFACT_RELEASE_PULSE) + +/datum/artifact_effect/life_steal/do_effect_touch(mob/living/user) + if(!steal_for(user, 10)) + to_chat(user, span_notice("Something in [holder] reaches for you, then lets go.")) + +/datum/artifact_effect/life_steal/do_effect_pulse(power) + steal_for(pick_beneficiary(), clamp(power * 0.4, 5, 15)) + +/// Whoever a burst feeds: the person carrying it, else the nearest hurt person in reach. +/datum/artifact_effect/life_steal/proc/pick_beneficiary() + var/atom/carrier = get_atom_on_turf(holder) + if(isliving(carrier)) + return carrier + var/turf/center = source_turf() + if(!center) + return null + var/mob/living/best + var/best_distance = INFINITY + for(var/mob/living/candidate in living_in_range()) + if(candidate.stat == DEAD || candidate.getBruteLoss() + candidate.getFireLoss() <= 0) + continue + var/distance = get_dist(center, candidate) + if(distance < best_distance) + best = candidate + best_distance = distance + return best + +/** + * Heals `beneficiary` by up to `amount`, taken from everyone else in reach. + * Returns the amount healed. + */ +/datum/artifact_effect/life_steal/proc/steal_for(mob/living/beneficiary, amount) + if(!beneficiary || beneficiary.stat == DEAD) + return 0 + var/wanted = min(amount, beneficiary.getBruteLoss() + beneficiary.getFireLoss(), artifact_heal_allowance(beneficiary)) + if(wanted <= 0) + return 0 + var/list/victims = list() + for(var/mob/living/victim in living_in_range()) + if(victim == beneficiary || victim.stat == DEAD || artifact_exposure(victim) <= 0) + continue + victims += victim + if(!length(victims)) + return 0 + // What each victim can give: an even share, less for those in protective gear. + var/list/shares = list() + var/offered = 0 + for(var/mob/living/victim as anything in victims) + var/share = wanted / length(victims) * artifact_exposure(victim) + shares[victim] = share + offered += share + if(offered <= 0) + return 0 + var/healed = artifact_capped_heal(beneficiary, offered) + if(healed <= 0) + return 0 + // Everyone gives up exactly their part of what was healed. + var/scale = healed / offered + for(var/mob/living/victim as anything in shares) + victim.take_overall_damage(shares[victim] * scale) + victim.Beam(beneficiary, icon_state = "lichbeam", time = 1.5 SECONDS) + to_chat(victim, span_danger("Warmth bleeds out of you and runs toward [beneficiary].")) + log_harm(victim) + new /obj/effect/temp_visual/heal(get_turf(beneficiary), "#b0306a") + to_chat(beneficiary, span_notice("Stolen warmth floods into you, and your wounds pull shut.")) + playsound(beneficiary, 'sound/effects/magic/exit_blood.ogg', 35, TRUE) + return healed diff --git a/voidcrew/modules/xenoarch/effects_polaris/plasma_vent.dm b/voidcrew/modules/xenoarch/effects_polaris/plasma_vent.dm index 6a82f0b756b..302bab411dd 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/plasma_vent.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/plasma_vent.dm @@ -1 +1,116 @@ // Artifact effect: plasma vent. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/gasphoron.dm. +// Voidcrew: vents plasma (Polaris' "phoron") indoors only: never into planet air, never into space. +// Each vent stops at a modest pressure on its tile, and holds a finite reserve, less than one gas +// contract asks for, so it can never become a free plasma well. Plasma air never wakes it, or it +// would feed itself. Everyone breathing near it is logged. Not harvestable. +// +// Also the shared parent for gas vents with a reserve (sleeping gas uses it). + +/datum/artifact_effect/gas_vent + harvestable = FALSE + harmful = TRUE + /// The /datum/gas it vents + var/gas_type + /// Gas puff colour + var/puff_color = "#ffffff" + /// Moles left in it; it runs dry for good when this hits zero + var/reserve = 0 + var/reserve_low = 100 + var/reserve_high = 200 + /// It stops venting once its tile reaches this pressure (kPa) + var/max_pressure = ONE_ATMOSPHERE + /// Said it was dry + var/announced_dry = FALSE + +/datum/artifact_effect/gas_vent/setup() + reserve = rand(reserve_low, reserve_high) + max_pressure = rand(110, 140) + +/datum/artifact_effect/gas_vent/copy_settings_to(datum/artifact_effect/gas_vent/copy) + copy.reserve = reserve + copy.max_pressure = max_pressure + +/datum/artifact_effect/gas_vent/do_effect_touch(mob/living/user) + if(vent(rand(3, 8))) + to_chat(user, span_warning("Gas hisses out of [holder] around your hand.")) + +/datum/artifact_effect/gas_vent/do_effect_aura(seconds_per_tick) + if(SPT_PROB(50, seconds_per_tick)) + vent(rand(1, 3)) + +/datum/artifact_effect/gas_vent/do_effect_pulse(power) + vent(clamp(power / 2, 3, 20)) + +/** + * Lets up to `moles` of its gas out onto its tile, from its reserve. Indoors only: never a planet + * turf (whose air is shared), never space. Returns the moles that came out. + */ +/datum/artifact_effect/gas_vent/proc/vent(moles) + if(moles <= 0 || !gas_type) + return 0 + var/turf/open/here = source_turf() + if(!istype(here) || here.planetary_atmos || isspaceturf(here)) + return 0 + if(reserve <= 0) + run_dry(here) + return 0 + var/datum/gas_mixture/air = here.return_air() + if(!air || air.return_pressure() >= max_pressure) + return 0 + moles = min(moles, reserve) + reserve -= moles + var/datum/gas_mixture/puff = new + puff.assert_gas(gas_type) + puff.gases[gas_type][MOLES] = moles + puff.temperature = T20C + here.assume_air(puff) + var/obj/effect/temp_visual/artifact_gas_puff/cloud = new(here) + cloud.color = puff_color + playsound(here, 'sound/effects/spray2.ogg', 20, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) + for(var/mob/living/breather in living_in_range()) + log_harm(breather) + return moles + +/// Its reserve is spent: one last wheeze, then nothing ever again. +/datum/artifact_effect/gas_vent/proc/run_dry(turf/here) + if(announced_dry) + return + announced_dry = TRUE + here.visible_message(span_notice("[holder] wheezes, and nothing more comes out.")) + playsound(here, 'sound/effects/spray3.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) + +/datum/artifact_effect/gas_vent/plasma + label_name = "Vents plasma" + log_name = "Plasma vent" + tier = ARTIFACT_TIER_UNCOMMON + possible_kinds = list(ARTIFACT_ENERGY_BLUESPACE, ARTIFACT_ENERGY_SYNTHESIS) + // Every trigger but plasma air, which it would make itself. + allowed_triggers = list( + ARTIFACT_TRIGGER_TOUCH, + ARTIFACT_TRIGGER_WATER, + ARTIFACT_TRIGGER_ACID, + ARTIFACT_TRIGGER_VOLATILE, + ARTIFACT_TRIGGER_TOXIN, + ARTIFACT_TRIGGER_IMPACT, + ARTIFACT_TRIGGER_ENERGY, + ARTIFACT_TRIGGER_HEAT, + ARTIFACT_TRIGGER_COLD, + ARTIFACT_TRIGGER_CO2, + ARTIFACT_TRIGGER_PROXIMITY, + ) + gas_type = /datum/gas/plasma + puff_color = "#c95ad8" + reserve_low = 150 + reserve_high = 300 + +/// A small cloud of vented gas. +/obj/effect/temp_visual/artifact_gas_puff + icon_state = "smoke" + alpha = 120 + duration = 1.2 SECONDS + +/obj/effect/temp_visual/artifact_gas_puff/Initialize(mapload) + . = ..() + pixel_x = rand(-4, 4) + animate(src, alpha = 0, pixel_y = 10, time = duration) diff --git a/voidcrew/modules/xenoarch/effects_polaris/poltergeist.dm b/voidcrew/modules/xenoarch/effects_polaris/poltergeist.dm index cb67d56ee74..af1c9c251c9 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/poltergeist.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/poltergeist.dm @@ -1 +1,106 @@ // Artifact effect: poltergeist. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/poltergeist.dm, also in +// VOREStation (9335d66b9fdf). Voidcrew: picks a loose object lying near the artifact, lifts it for a +// moment (time to duck) and hurls it at the nearest person. Only small and medium items lying on +// the floor fly; nothing is pulled from hands, bags or tables' contents, and a thrown object only +// hits as hard as its own weight allows. Logged like a weapon. + +/// How long an object hangs in the air before it flies +#define ARTIFACT_POLTERGEIST_WINDUP (0.8 SECONDS) + +/datum/artifact_effect/poltergeist + label_name = "Throws things" + log_name = "Poltergeist" + tier = ARTIFACT_TIER_RARE + harmful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_PSIONIC, ARTIFACT_ENERGY_BLUESPACE) + +/datum/artifact_effect/poltergeist/do_effect_touch(mob/living/user) + lift_and_throw(user) + +/datum/artifact_effect/poltergeist/do_effect_aura(seconds_per_tick) + if(SPT_PROB(15, seconds_per_tick)) + lift_and_throw(nearest_target()) + +/datum/artifact_effect/poltergeist/do_effect_pulse(power) + var/mob/living/target = nearest_target() + if(!target) + return + var/throws = power >= 30 ? 2 : 1 + for(var/i in 1 to throws) + lift_and_throw(target) + +/// Smashed, it flings what is near it at once, with no warning. +/datum/artifact_effect/poltergeist/do_effect_destroy() + var/mob/living/target = nearest_target() + var/obj/item/missile = find_missile(target) + if(target && missile) + hurl(WEAKREF(missile), WEAKREF(target)) + +/// The closest conscious mob in range, preferring people with a mind over animals. +/datum/artifact_effect/poltergeist/proc/nearest_target() + var/turf/center = source_turf() + if(!center) + return null + var/mob/living/best + var/best_distance = INFINITY + var/best_has_mind = FALSE + for(var/mob/living/candidate in living_in_range()) + if(candidate.stat != CONSCIOUS || candidate == get_atom_on_turf(holder)) + continue + var/has_mind = !!candidate.mind + var/distance = get_dist(center, candidate) + if(best_has_mind && !has_mind) + continue + if((has_mind && !best_has_mind) || distance < best_distance) + best = candidate + best_distance = distance + best_has_mind = has_mind + return best + +/// A loose item on the floor within its reach, not right under `target`'s feet. +/datum/artifact_effect/poltergeist/proc/find_missile(mob/living/target) + var/turf/center = source_turf() + if(!center || !target) + return null + var/list/candidates = list() + for(var/obj/item/thing in range(range, center)) + if(!isturf(thing.loc) || thing.anchored || thing.w_class > WEIGHT_CLASS_BULKY) + continue + if((thing.item_flags & ABSTRACT) || HAS_TRAIT(thing, TRAIT_NODROP) || thing.throwforce <= 0) + continue + if(get_dist(thing, target) < 2) + continue + candidates += thing + return length(candidates) ? pick(candidates) : null + +/// Lifts something toward `target`; it flies after a short windup. Returns TRUE if it lifted one. +/datum/artifact_effect/poltergeist/proc/lift_and_throw(mob/living/target) + if(!target || target.stat == DEAD || !prob(100 * artifact_exposure(target))) + return FALSE + var/obj/item/missile = find_missile(target) + if(!missile) + return FALSE + missile.visible_message(span_warning("[missile] lifts off the floor and turns toward [target]!")) + playsound(missile, 'sound/effects/magic/summonitems_generic.ogg', 30, TRUE) + animate(missile, pixel_z = 10, time = ARTIFACT_POLTERGEIST_WINDUP, easing = SINE_EASING | EASE_OUT, flags = ANIMATION_PARALLEL) + var/atom/origin = get_atom_on_turf(holder) + origin?.Beam(missile, icon_state = "kinesis", time = ARTIFACT_POLTERGEIST_WINDUP) + addtimer(CALLBACK(src, PROC_REF(hurl), WEAKREF(missile), WEAKREF(target)), ARTIFACT_POLTERGEIST_WINDUP, TIMER_DELETE_ME) + return TRUE + +/// Throws the lifted item, if it is still lying where it was lifted and the target still stands. +/datum/artifact_effect/poltergeist/proc/hurl(datum/weakref/missile_ref, datum/weakref/target_ref) + var/obj/item/missile = missile_ref?.resolve() + var/mob/living/target = target_ref?.resolve() + if(!missile) + return + animate(missile, pixel_z = 0, time = 0.1 SECONDS, flags = ANIMATION_PARALLEL) + if(!isturf(missile.loc) || !target || target.stat == DEAD || missile.z != target.z) + return + playsound(missile, 'sound/effects/magic/repulse.ogg', 30, TRUE) + // Positional: some item overrides of throw_at() rename their arguments. + missile.throw_at(target, range * 2, 3) + log_harm(target) + +#undef ARTIFACT_POLTERGEIST_WINDUP diff --git a/voidcrew/modules/xenoarch/effects_polaris/resurrect.dm b/voidcrew/modules/xenoarch/effects_polaris/resurrect.dm index d61062271d4..a2e7887495f 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/resurrect.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/resurrect.dm @@ -1 +1,191 @@ // Artifact effect: resurrect. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/resurrect.dm and the +// VOREStation (9335d66b9fdf) "vitality swap" version. Voidcrew (owner decision 4): brings back one +// person lying beside it who died less than five minutes ago, three times in all, then it cracks +// and goes dull for good. It is never a free revive loop: +// - three lives per artifact, stored on the effect; not harvestable, and artifacts are never +// saved with a ship, so the count can't be copied or reset; +// - only a body whose own player is still there to come back: a ghost that can re-enter, or a +// player still in the body. Do-not-resuscitate, logged-out players, and a mind that already moved +// on (a clone, a new body) are refused; +// - the same checks as a defibrillator: suicides, husks, failing or missing hearts and brains, and +// bodies too broken to hold life; +// - its healing goes through the shared artifact cap (30 brute and burn); it clears the choking +// and some poison, but a body torn apart past that stays dead and costs no use. +// Polaris drained the living nearby to fuel it; that is dropped. The price is the use, and the +// person comes back weak. Every revival is logged. + +/// Lives it can give back before it is spent +#define ARTIFACT_RESURRECT_USES 3 +/// How long after death a body can still be raised +#define ARTIFACT_RESURRECT_WINDOW (5 MINUTES) +/// How long the light works on a body before it wakes +#define ARTIFACT_RESURRECT_RITE (4 SECONDS) +/// Poison it clears from a body +#define ARTIFACT_RESURRECT_TOX_MEND 40 + +/datum/artifact_effect/resurrect + label_name = "Raises the dead" + log_name = "Resurrect" + tier = ARTIFACT_TIER_EXTREME + harvestable = FALSE + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC) + /// Lives it can still give back. At zero it is spent for good. + var/uses_left = ARTIFACT_RESURRECT_USES + /// The body it is working on, if any + var/datum/weakref/working_on + /// REF(body) -> world.time it last showed it could not help them + var/list/refused_at + +/datum/artifact_effect/resurrect/Destroy(force) + working_on = null + refused_at = null + return ..() + +/datum/artifact_effect/resurrect/copy_settings_to(datum/artifact_effect/resurrect/copy) + copy.uses_left = uses_left + +/datum/artifact_effect/resurrect/do_effect_touch(mob/living/user) + seek() + +/datum/artifact_effect/resurrect/do_effect_aura(seconds_per_tick) + seek() + +/datum/artifact_effect/resurrect/do_effect_pulse(power) + seek() + +/// Spent, it only gives the faintest light when woken. +/datum/artifact_effect/resurrect/light_override() + if(uses_left <= 0) + return list(1, 0.3, "#5a1a1a") + return null + +/// Looks for a body laid beside it and starts on the first one that can come back. +/datum/artifact_effect/resurrect/proc/seek() + if(uses_left <= 0 || working_on?.resolve()) + return + var/turf/center = source_turf() + if(!center) + return + for(var/mob/living/carbon/human/body in range(1, center)) + if(body.stat != DEAD) + continue + var/refusal = raise_refusal(body) + if(refusal) + show_refusal(body, refusal) + continue + begin_rite(body) + return + +/** + * Why `body` can't be raised, as a short reason, or null if it can. + * "spent", "not here", "too late", "gone" (nobody to come back) or "ruined" (the body can't hold life). + */ +/datum/artifact_effect/resurrect/proc/raise_refusal(mob/living/carbon/human/body) + if(uses_left <= 0) + return "spent" + if(!istype(body) || QDELETED(body) || body.stat != DEAD || !isturf(body.loc)) + return "not here" + if(world.time - body.timeofdeath > ARTIFACT_RESURRECT_WINDOW) + return "too late" + if(!body.mind || body.mind.current != body) + return "gone" + if(body.can_defib() != DEFIB_POSSIBLE) + return "ruined" + if(projected_health(body) <= HEALTH_THRESHOLD_DEAD) + return "ruined" + if(!body.client && !body.get_ghost(FALSE, TRUE)) + return "gone" + return null + +/// What `body`'s health would be after the mending it gives. +/datum/artifact_effect/resurrect/proc/projected_health(mob/living/carbon/human/body) + var/mended = min(artifact_heal_allowance(body), body.getBruteLoss() + body.getFireLoss()) + mended += body.getOxyLoss() + min(body.getToxLoss(), ARTIFACT_RESURRECT_TOX_MEND) + return body.health + mended + +/// Shows, now and then, that it reached for a body and could not take hold. +/datum/artifact_effect/resurrect/proc/show_refusal(mob/living/carbon/human/body, refusal) + if(refusal == "spent" || refusal == "not here") + return + var/key = REF(body) + if(LAZYACCESS(refused_at, key) > world.time - 30 SECONDS) + return + LAZYSET(refused_at, key, world.time) + if(refusal == "gone") + body.visible_message(span_notice("A thread of red light reaches from [holder] to [body], finds no one there, and fades.")) + else + body.visible_message(span_notice("A thread of red light touches [body], slides off, and fades.")) + +/// The light goes to work on `body`; it wakes after the rite if nothing has changed. +/datum/artifact_effect/resurrect/proc/begin_rite(mob/living/carbon/human/body) + working_on = WEAKREF(body) + var/atom/origin = get_atom_on_turf(holder) + origin?.Beam(body, icon_state = "lichbeam", time = ARTIFACT_RESURRECT_RITE) + body.visible_message(span_warning("Threads of red light reach out of [holder] and sink into [body]. The body twitches.")) + playsound(body, 'sound/effects/magic/enter_blood.ogg', 45, TRUE) + playsound(body, 'sound/effects/singlebeat.ogg', 60, TRUE) + body.do_jitter_animation(100) + body.notify_revival("Something is dragging you back toward your body!", source = holder) + addtimer(CALLBACK(src, PROC_REF(finish_rite), WEAKREF(body)), ARTIFACT_RESURRECT_RITE, TIMER_DELETE_ME) + +/// The rite ends: raises the body if it still can be. +/datum/artifact_effect/resurrect/proc/finish_rite(datum/weakref/body_ref) + working_on = null + var/mob/living/carbon/human/body = body_ref?.resolve() + if(!body) + return + var/obj/machinery/artifact/artifact = holder + if((istype(artifact) && artifact.suppressed) || get_dist(source_turf(), body) > 1 || raise_refusal(body)) + body.visible_message(span_notice("The red light drains out of [body] and is gone.")) + return + raise(body) + +/** + * Brings `body` back to life and spends one use. Returns TRUE if they live. + * Checks nothing about whether they should: raise_refusal() does that. + */ +/datum/artifact_effect/resurrect/proc/raise(mob/living/carbon/human/body) + if(uses_left <= 0 || QDELETED(body) || body.stat != DEAD) + return FALSE + artifact_capped_heal(body, artifact_heal_allowance(body)) + body.adjustOxyLoss(-body.getOxyLoss(), updating_health = FALSE) + body.adjustToxLoss(-min(body.getToxLoss(), ARTIFACT_RESURRECT_TOX_MEND), updating_health = FALSE, forced = TRUE) + body.updatehealth() + body.set_heartattack(FALSE) + if(body.health <= HEALTH_THRESHOLD_DEAD) + return FALSE + body.grab_ghost() + if(!body.revive_from("artifact")) + return FALSE + uses_left-- + body.emote("gasp") + body.set_jitter_if_lower(20 SECONDS) + body.apply_status_effect(/datum/status_effect/artifact/exhausted, 60 SECONDS) + body.visible_message( + span_warning("[body]'s eyes snap open in a flash of red light!"), + span_userdanger("You are dragged back into your body, gasping. Everything aches."), + ) + playsound(body, 'sound/effects/magic/staff_healing.ogg', 50, TRUE) + var/mob/responsible = get_responsible() + log_combat(responsible || holder, body, "revived", holder, "with [log_name] ([uses_left] uses left)") + if(uses_left <= 0) + go_dull() + return TRUE + +/// The last life is given: it cracks and the light inside goes out. +/datum/artifact_effect/resurrect/proc/go_dull() + var/turf/here = source_turf() + if(!here) + return + here.visible_message(span_warning("[holder] cracks with a sound like a knuckle, and the light deep inside it goes out.")) + playsound(here, 'sound/effects/wounds/crack1.ogg', 50, TRUE) + var/obj/machinery/artifact/artifact = holder + if(istype(artifact)) + artifact.update_activity_visuals() + +#undef ARTIFACT_RESURRECT_USES +#undef ARTIFACT_RESURRECT_WINDOW +#undef ARTIFACT_RESURRECT_RITE +#undef ARTIFACT_RESURRECT_TOX_MEND diff --git a/voidcrew/modules/xenoarch/effects_polaris/sleeping_gas.dm b/voidcrew/modules/xenoarch/effects_polaris/sleeping_gas.dm index 7278bea4aa6..66b00d1fd5b 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/sleeping_gas.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/sleeping_gas.dm @@ -1 +1,15 @@ // Artifact effect: sleeping gas. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/gassleeping.dm. +// Voidcrew: vents nitrous oxide indoors only, from a finite reserve, and stops at a modest +// pressure on its tile (see the gas_vent parent in plasma_vent.dm). Everyone breathing near it is +// logged. Not harvestable. + +/datum/artifact_effect/gas_vent/sleeping + label_name = "Vents sleeping gas" + log_name = "Sleeping gas" + tier = ARTIFACT_TIER_RARE + possible_kinds = list(ARTIFACT_ENERGY_BLUESPACE, ARTIFACT_ENERGY_SYNTHESIS) + gas_type = /datum/gas/nitrous_oxide + puff_color = "#f2f2ff" + reserve_low = 100 + reserve_high = 200 diff --git a/voidcrew/modules/xenoarch/effects_polaris/spines.dm b/voidcrew/modules/xenoarch/effects_polaris/spines.dm index d391810f000..78fd5cf321e 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/spines.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/spines.dm @@ -1 +1,99 @@ // Artifact effect: spines. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/indiscriminate_spines.dm. +// Voidcrew: it bristles for a second (a rattle and a visible shiver, time to duck behind cover), +// then looses a ring of bone spines evenly around itself, eight or twelve by strength. A hand on +// it is spared: no spine flies toward the person touching it, as in Polaris. Half as likely in the +// green zone (design catalogue). Polaris' spore variant is not ported. Not harvestable; logged. + +/// How long it bristles before it fires +#define ARTIFACT_SPINES_WINDUP (1 SECONDS) + +/datum/artifact_effect/spines + label_name = "Fires spines" + log_name = "Spines" + tier = ARTIFACT_TIER_EXTREME + harvestable = FALSE + harmful = TRUE + green_weight = 0.5 + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC) + allowed_release_methods = list(ARTIFACT_RELEASE_TOUCH, ARTIFACT_RELEASE_PULSE) + /// Spines in one volley + var/volley = 8 + /// A volley is being readied + var/bristling = FALSE + +/datum/artifact_effect/spines/setup() + volley = (strength == ARTIFACT_STRENGTH_LARGE) ? 12 : 8 + // A volley needs a good part of the store; a hand can't set one off every few seconds. + touch_cost = max(touch_cost, round(maximum_charges / 2)) + +/datum/artifact_effect/spines/copy_settings_to(datum/artifact_effect/spines/copy) + copy.volley = volley + +/datum/artifact_effect/spines/do_effect_touch(mob/living/user) + bristle(user) + +/datum/artifact_effect/spines/do_effect_pulse(power) + bristle() + +/datum/artifact_effect/spines/do_effect_destroy() + fire_volley() + +/// The warning: it shivers and rattles, then fires. `spared` is the person touching it. +/datum/artifact_effect/spines/proc/bristle(mob/living/spared) + var/turf/center = source_turf() + if(bristling || !center) + return FALSE + bristling = TRUE + center.visible_message(span_danger("[holder] bristles with sharp bone!")) + playsound(center, 'sound/effects/blob/blobattack.ogg', 50, TRUE) + var/atom/movable/shaker = get_atom_on_turf(holder) + if(shaker) + shaker.Shake(1, 1, ARTIFACT_SPINES_WINDUP) + addtimer(CALLBACK(src, PROC_REF(fire_volley), spared ? WEAKREF(spared) : null), ARTIFACT_SPINES_WINDUP, TIMER_DELETE_ME) + return TRUE + +/// Looses one ring of spines. Skips the direction of whoever `spared_ref` points to. +/datum/artifact_effect/spines/proc/fire_volley(datum/weakref/spared_ref) + bristling = FALSE + var/obj/machinery/artifact/artifact = holder + if(istype(artifact) && artifact.suppressed) + return 0 + var/turf/center = source_turf() + if(!center) + return 0 + var/mob/living/spared = spared_ref?.resolve() + var/spared_angle = (spared && get_dist(center, spared) <= 1 && spared.loc != center) ? get_angle(center, spared) : null + var/atom/movable/launcher = get_atom_on_turf(holder) + var/step = 360 / volley + var/offset = rand(0, step - 1) + var/fired = 0 + for(var/i in 0 to volley - 1) + var/angle = (offset + i * step) % 360 + if(!isnull(spared_angle) && abs(closer_angle_difference(angle, spared_angle)) < step * 0.75) + continue + var/obj/projectile/artifact_spine/spine = new(center) + spine.firer = launcher + spine.fired_from = launcher + spine.range = range + 2 + spine.fire(angle) + fired++ + playsound(center, 'sound/items/weapons/pierce.ogg', 60, TRUE) + for(var/mob/living/target in living_in_range(2)) + if(target != spared) + log_harm(target) + return fired + +/// A bone spine. +/obj/projectile/artifact_spine + name = "bone spine" + icon_state = "magspear" + color = "#efe2c4" + damage = 8 + damage_type = BRUTE + armor_flag = BULLET + sharpness = SHARP_POINTY + hit_prone_targets = TRUE + hitsound = 'sound/items/weapons/pierce.ogg' + +#undef ARTIFACT_SPINES_WINDUP diff --git a/voidcrew/modules/xenoarch/effects_polaris/sprint.dm b/voidcrew/modules/xenoarch/effects_polaris/sprint.dm index 541f6ed659d..efac54d7df7 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/sprint.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/sprint.dm @@ -1 +1,25 @@ // Artifact effect: sprint. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/sprinting.dm. +// Voidcrew: uncommon, not common (design catalogue); a short movement-speed status effect with a +// fading afterimage, instead of Polaris' /datum/modifier; doses never stack past a minute. + +/datum/artifact_effect/bestow/sprint + label_name = "Speeds people up" + log_name = "Sprint" + tier = ARTIFACT_TIER_UNCOMMON + helpful = TRUE + possible_kinds = list(ARTIFACT_ENERGY_CONCENTRATED, ARTIFACT_ENERGY_PSIONIC) + status_type = /datum/status_effect/artifact/sprint + touch_duration = 45 SECONDS + pulse_duration = 25 SECONDS + aura_duration = 8 SECONDS + +/datum/artifact_effect/bestow/sprint/on_bestowed(mob/living/target) + if(issilicon(target)) + to_chat(target, span_notice("Your actuators whine up to a higher pitch.")) + else + to_chat(target, span_notice("Your legs fill with a restless spring.")) + playsound(target, 'sound/effects/magic/tail_swing.ogg', 20, TRUE, SILENCED_SOUND_EXTRARANGE) + +/datum/artifact_effect/bestow/sprint/on_renewed(mob/living/target) + to_chat(target, span_notice("Your legs itch to run.")) diff --git a/voidcrew/modules/xenoarch/effects_polaris/status_effects.dm b/voidcrew/modules/xenoarch/effects_polaris/status_effects.dm index d40b809507a..b451b89d0ed 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/status_effects.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/status_effects.dm @@ -1 +1,308 @@ // Status effects applied by artifact effects. +// +// Rewritten for tg from the Polaris (6cd19fe0dec6) and VOREStation (9335d66b9fdf) /datum/modifier +// types the xenoarchaeology effects used (fortify, faraday, sprinting, berserk and its exhaustion, +// feysight). tg has no modifiers, so each is a status effect here. +// +// None of them stack. A fresh dose only tops the time up to that dose's own length, never past +// max_duration, so standing in an aura keeps a buff going but never banks a long one. +// Also here: the shared parent for effects that hand one of these out. + +/// Artifact status effects: refresh to the longer of what is left and the new dose. +/datum/status_effect/artifact + id = "artifact" + status_type = STATUS_EFFECT_REFRESH + duration = 30 SECONDS + tick_interval = STATUS_EFFECT_NO_TICK + alert_type = null + /// Longest one dose can last, in deciseconds + var/max_duration = 2 MINUTES + +/datum/status_effect/artifact/on_creation(mob/living/new_owner, set_duration) + if(isnum(set_duration)) + duration = clamp(set_duration, 1 SECONDS, max_duration) + return ..() + +/datum/status_effect/artifact/refresh(mob/living/new_owner, set_duration) + var/dose = isnum(set_duration) ? clamp(set_duration, 1 SECONDS, max_duration) : initial(duration) + duration = max(duration, world.time + dose) + +// ===== Fortify ===== + +#define ARTIFACT_FORTIFY_DAMAGE_MULT 0.85 + +/datum/status_effect/artifact/fortify + id = "artifact_fortify" + max_duration = 90 SECONDS + alert_type = /atom/movable/screen/alert/status_effect/artifact_fortify + +/datum/status_effect/artifact/fortify/on_apply() + RegisterSignal(owner, COMSIG_MOB_APPLY_DAMAGE_MODIFIERS, PROC_REF(soften_blow)) + owner.add_filter("artifact_fortify", 2, outline_filter(1, "#a7b89a80")) + return TRUE + +/datum/status_effect/artifact/fortify/on_remove() + UnregisterSignal(owner, COMSIG_MOB_APPLY_DAMAGE_MODIFIERS) + owner.remove_filter("artifact_fortify") + to_chat(owner, span_notice("Your skin softens and feels like your own again.")) + +/datum/status_effect/artifact/fortify/proc/soften_blow(mob/living/source, list/damage_mods, damage, damagetype) + SIGNAL_HANDLER + if(damagetype == BRUTE || damagetype == BURN) + damage_mods += ARTIFACT_FORTIFY_DAMAGE_MULT + +/atom/movable/screen/alert/status_effect/artifact_fortify + name = "Hardened Skin" + desc = "Your skin is tight and tough, like old leather." + icon_state = "slime_stoneskin" + +#undef ARTIFACT_FORTIFY_DAMAGE_MULT + +// ===== Faraday ===== + +/datum/status_effect/artifact/faraday + id = "artifact_faraday" + max_duration = 2 MINUTES + alert_type = /atom/movable/screen/alert/status_effect/artifact_faraday + /// Throttles the "it went nowhere" message + COOLDOWN_DECLARE(grounded_message) + +/datum/status_effect/artifact/faraday/on_apply() + RegisterSignal(owner, COMSIG_ATOM_PRE_EMP_ACT, PROC_REF(ground_pulse)) + owner.add_filter("artifact_faraday", 2, outline_filter(1, "#5fd3ff60")) + return TRUE + +/datum/status_effect/artifact/faraday/on_remove() + UnregisterSignal(owner, COMSIG_ATOM_PRE_EMP_ACT) + owner.remove_filter("artifact_faraday") + to_chat(owner, span_notice("The hush around you lifts, and the static comes back.")) + +/// Swallows an EMP whole: the mob, everything it carries, and its wiring. +/datum/status_effect/artifact/faraday/proc/ground_pulse(atom/source, severity) + SIGNAL_HANDLER + if(COOLDOWN_FINISHED(src, grounded_message)) + COOLDOWN_START(src, grounded_message, 5 SECONDS) + to_chat(owner, span_notice("A pulse crackles over your skin and goes nowhere.")) + new /obj/effect/temp_visual/emp(get_turf(owner)) + return EMP_PROTECT_SELF | EMP_PROTECT_CONTENTS | EMP_PROTECT_WIRES + +/atom/movable/screen/alert/status_effect/artifact_faraday + name = "Grounded" + desc = "There is a cold, still hush on your skin. Even your radio sounds far away." + icon_state = "shock_immune" + +// ===== Sprint ===== + +/datum/movespeed_modifier/status_effect/artifact_sprint + multiplicative_slowdown = -0.25 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/status_effect/artifact/sprint + id = "artifact_sprint" + max_duration = 60 SECONDS + alert_type = /atom/movable/screen/alert/status_effect/artifact_sprint + +/datum/status_effect/artifact/sprint/on_apply() + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/artifact_sprint) + RegisterSignal(owner, COMSIG_MOVABLE_MOVED, PROC_REF(leave_afterimage)) + return TRUE + +/datum/status_effect/artifact/sprint/on_remove() + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/artifact_sprint) + UnregisterSignal(owner, COMSIG_MOVABLE_MOVED) + to_chat(owner, span_notice("Your legs feel heavy again.")) + +/// A fading copy of them where they just were. +/datum/status_effect/artifact/sprint/proc/leave_afterimage(atom/movable/source, atom/old_loc, movement_dir, forced) + SIGNAL_HANDLER + if(forced || !isturf(old_loc) || !prob(45)) + return + var/obj/effect/temp_visual/decoy/fading/halfsecond/afterimage = new(old_loc, owner) + afterimage.alpha = 110 + animate(afterimage, alpha = 0, time = 0.5 SECONDS) + +/atom/movable/screen/alert/status_effect/artifact_sprint + name = "Light on Your Feet" + desc = "Your legs feel springy and tireless. The floor seems to rush by." + icon_state = "realignment" + +// ===== Berserk and exhaustion ===== + +#define ARTIFACT_BERSERK_FORCE_MULT 1.25 +#define ARTIFACT_BERSERK_SWING_MULT 0.8 +#define ARTIFACT_EXHAUSTED_SWING_MULT 1.25 + +/datum/mood_event/artifact_berserk + description = "Everything makes me so ANGRY." + mood_change = -3 + timeout = 2 MINUTES + +/datum/status_effect/artifact/berserk + id = "artifact_berserk" + max_duration = 45 SECONDS + alert_type = /atom/movable/screen/alert/status_effect/artifact_berserk + +/datum/status_effect/artifact/berserk/on_apply() + // The fury needs something to burn. A spent body can't hold it. + if(owner.stat == DEAD || owner.has_status_effect(/datum/status_effect/artifact/exhausted)) + return FALSE + ADD_TRAIT(owner, TRAIT_PERFECT_ATTACKER, TRAIT_STATUS_EFFECT(id)) + RegisterSignal(owner, COMSIG_MOB_ITEM_ATTACK, PROC_REF(swing_harder)) + owner.add_filter("artifact_berserk", 2, outline_filter(1, "#c0202080")) + owner.add_mood_event("artifact_berserk", /datum/mood_event/artifact_berserk) + return TRUE + +/datum/status_effect/artifact/berserk/on_remove() + REMOVE_TRAIT(owner, TRAIT_PERFECT_ATTACKER, TRAIT_STATUS_EFFECT(id)) + UnregisterSignal(owner, COMSIG_MOB_ITEM_ATTACK) + owner.remove_filter("artifact_berserk") + if(QDELETED(owner) || owner.stat == DEAD) + return + to_chat(owner, span_warning("The anger drains out of you, and takes your strength with it.")) + owner.apply_status_effect(/datum/status_effect/artifact/exhausted, 25 SECONDS) + +/datum/status_effect/artifact/berserk/nextmove_modifier() + return ARTIFACT_BERSERK_SWING_MULT + +/datum/status_effect/artifact/berserk/proc/swing_harder(mob/living/source, mob/living/target, mob/living/user, list/modifiers, list/attack_modifiers) + SIGNAL_HANDLER + MODIFY_ATTACK_FORCE_MULTIPLIER(attack_modifiers, ARTIFACT_BERSERK_FORCE_MULT) + +/atom/movable/screen/alert/status_effect/artifact_berserk + name = "Seeing Red" + desc = "Your blood is up. Every swing lands, and lands hard." + icon_state = "blooddrunk" + +/datum/movespeed_modifier/status_effect/artifact_exhausted + multiplicative_slowdown = 0.6 + blacklisted_movetypes = (FLYING|FLOATING) + +/// Worn out: after a rage, a life drain, or being dragged back from death. +/datum/status_effect/artifact/exhausted + id = "artifact_exhausted" + max_duration = 60 SECONDS + alert_type = /atom/movable/screen/alert/status_effect/artifact_exhausted + +/datum/status_effect/artifact/exhausted/on_apply() + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/artifact_exhausted) + return TRUE + +/datum/status_effect/artifact/exhausted/on_remove() + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/artifact_exhausted) + +/datum/status_effect/artifact/exhausted/nextmove_modifier() + return ARTIFACT_EXHAUSTED_SWING_MULT + +/atom/movable/screen/alert/status_effect/artifact_exhausted + name = "Drained" + desc = "You feel wrung out. Every step is an effort." + icon_state = "weaken" + +#undef ARTIFACT_BERSERK_FORCE_MULT +#undef ARTIFACT_BERSERK_SWING_MULT +#undef ARTIFACT_EXHAUSTED_SWING_MULT + +// ===== Feysight ===== + +/datum/client_colour/artifact_feysight + priority = CLIENT_COLOR_TEMPORARY_PRIORITY + color = "#d4ffdc" + fade_in = 1 SECONDS + fade_out = 1 SECONDS + +/datum/status_effect/artifact/feysight + id = "artifact_feysight" + max_duration = 45 SECONDS + alert_type = /atom/movable/screen/alert/status_effect/artifact_feysight + +/datum/status_effect/artifact/feysight/on_apply() + ADD_TRAIT(owner, TRAIT_THERMAL_VISION, TRAIT_STATUS_EFFECT(id)) + RegisterSignal(owner, COMSIG_MOB_UPDATE_SIGHT, PROC_REF(tint_sight)) + owner.update_sight() + owner.add_client_colour(/datum/client_colour/artifact_feysight, REF(src)) + return TRUE + +/datum/status_effect/artifact/feysight/on_remove() + REMOVE_TRAIT(owner, TRAIT_THERMAL_VISION, TRAIT_STATUS_EFFECT(id)) + UnregisterSignal(owner, COMSIG_MOB_UPDATE_SIGHT) + owner.update_sight() + owner.remove_client_colour(REF(src)) + to_chat(owner, span_notice("You blink, and the walls are only walls again.")) + +/// A faint green to the dark while the sight lasts. +/datum/status_effect/artifact/feysight/proc/tint_sight(mob/source) + SIGNAL_HANDLER + source.lighting_color_cutoffs = blend_cutoff_colors(source.lighting_color_cutoffs, list(5, 22, 10)) + +/atom/movable/screen/alert/status_effect/artifact_feysight + name = "Second Sight" + desc = "Living things glow through the walls like coals through paper." + icon_state = "moon_hide" + +// ===== Effects that hand one out ===== + +/** + * Shared parent for effects that give people near them a status effect: a touch gives the + * longest dose, a burst a medium one to everyone in range, and a field brushes people now and + * then with a short one. Protective gear shortens every dose. Not rollable itself. + */ +/datum/artifact_effect/bestow + /// The /datum/status_effect/artifact it hands out + var/datum/status_effect/artifact/status_type + var/touch_duration = 60 SECONDS + var/pulse_duration = 30 SECONDS + var/aura_duration = 10 SECONDS + /// Chance per second that the field reaches each person in range + var/aura_chance = 10 + +/datum/artifact_effect/bestow/do_effect_touch(mob/living/user) + bestow(user, touch_duration) + +/datum/artifact_effect/bestow/do_effect_aura(seconds_per_tick) + for(var/mob/living/target in living_in_range()) + if(SPT_PROB(aura_chance, seconds_per_tick)) + bestow(target, aura_duration, quiet = TRUE) + +/datum/artifact_effect/bestow/do_effect_pulse(power) + var/dose = pulse_duration * clamp(power / 25, 0.5, 1.5) + for(var/mob/living/target in living_in_range()) + bestow(target, dose) + +/** + * Gives `target` a dose lasting `duration` (deciseconds), shortened by protective gear. + * `quiet` keeps a field's top-ups from repeating the renewal message. + * Returns TRUE if they have it afterwards. + */ +/datum/artifact_effect/bestow/proc/bestow(mob/living/target, duration, quiet = FALSE) + if(!status_type || !can_bestow(target)) + return FALSE + duration *= artifact_exposure(target) + if(duration < 1 SECONDS) + return FALSE + var/had_it = !!target.has_status_effect(status_type) + target.apply_status_effect(status_type, duration) + if(!target.has_status_effect(status_type)) + on_refused(target) + return FALSE + if(!had_it) + on_bestowed(target) + else if(!quiet) + on_renewed(target) + log_harm(target) + return TRUE + +/// Who it works on. +/datum/artifact_effect/bestow/proc/can_bestow(mob/living/target) + return target.stat != DEAD + +/// Hook: `target` just got their first dose. +/datum/artifact_effect/bestow/proc/on_bestowed(mob/living/target) + return + +/// Hook: `target` already had it and got topped up by a touch or burst. +/datum/artifact_effect/bestow/proc/on_renewed(mob/living/target) + return + +/// Hook: `target` could not take it (the status effect refused). +/datum/artifact_effect/bestow/proc/on_refused(mob/living/target) + return diff --git a/voidcrew/modules/xenoarch/effects_polaris/sweat.dm b/voidcrew/modules/xenoarch/effects_polaris/sweat.dm index d3ee47a123f..9fbc0c6d2ca 100644 --- a/voidcrew/modules/xenoarch/effects_polaris/sweat.dm +++ b/voidcrew/modules/xenoarch/effects_polaris/sweat.dm @@ -1 +1,92 @@ // Artifact effect: sweat. +// Rewritten from Polaris (6cd19fe0dec6) code/modules/xenoarcheaology/effects/sweating_reagents.dm. +// Voidcrew: Polaris could weep any reagent in the game (and blood); this weeps one mild, +// everyday liquid picked from a short list, so it is never a free source of anything worth +// having. It pools into a small puddle that can be mopped or scooped up, and a puddle stops +// growing once it holds a cupful. + +/// A puddle stops growing once it holds this many units +#define ARTIFACT_SWEAT_PUDDLE_CAP 30 + +/datum/artifact_effect/sweat + label_name = "Weeps fluid" + log_name = "Sweat" + tier = ARTIFACT_TIER_COMMON + minor = TRUE + possible_kinds = list(ARTIFACT_ENERGY_ORGANIC, ARTIFACT_ENERGY_SYNTHESIS) + /// What it weeps + var/datum/reagent/reagent_type = /datum/reagent/water + +/datum/artifact_effect/sweat/setup() + var/static/list/weepings = list( + /datum/reagent/water, + /datum/reagent/water/salt, + /datum/reagent/consumable/sugar, + /datum/reagent/consumable/nutriment/fat/oil, + /datum/reagent/consumable/vinegar, + ) + reagent_type = pick(weepings) + +/datum/artifact_effect/sweat/copy_settings_to(datum/artifact_effect/sweat/copy) + copy.reagent_type = reagent_type + +/datum/artifact_effect/sweat/do_effect_touch(mob/living/user) + var/turf/user_turf = get_turf(user) + if(prob(25) && weep(user_turf, 6)) + user.visible_message( + span_warning("[holder] shudders at [user]'s touch and spits a slick of fluid across [user.p_their()] feet!"), + span_warning("[holder] shudders at your touch and spits a slick of fluid across your feet!"), + ) + playsound(user_turf, 'sound/effects/splat.ogg', 35, TRUE) + return + weep(source_turf(), 2) + to_chat(user, span_notice("Your palm comes away slick. It is beaded with moisture where you touched it.")) + +/datum/artifact_effect/sweat/do_effect_aura(seconds_per_tick) + if(SPT_PROB(25, seconds_per_tick) && weep(source_turf(), 2)) + playsound(source_turf(), 'sound/effects/bubbles/bubbles.ogg', 15, TRUE, SILENCED_SOUND_EXTRARANGE) + +/datum/artifact_effect/sweat/do_effect_pulse(power) + var/turf/center = source_turf() + if(!center) + return + var/spilled = weep(center, clamp(power / 4, 2, 10)) + var/list/neighbours = list() + for(var/turf/open/spot in orange(1, center)) + neighbours += spot + for(var/i in 1 to min(3, length(neighbours))) + spilled = weep(pick_n_take(neighbours), clamp(power / 8, 1, 5)) || spilled + if(spilled) + center.visible_message(span_warning("[holder] shudders and spits fluid across the floor.")) + playsound(center, 'sound/effects/splat.ogg', 40, TRUE) + +/// Adds `amount` of its liquid to a puddle on `spot`. Returns TRUE if any went in. +/datum/artifact_effect/sweat/proc/weep(turf/open/spot, amount) + if(!istype(spot) || amount <= 0 || isspaceturf(spot) || isgroundlessturf(spot) || islava(spot)) + return FALSE + var/obj/effect/decal/cleanable/artifact_ooze/puddle = locate() in spot + if(!puddle) + puddle = new(spot) + if(QDELETED(puddle)) + return FALSE + if(!puddle.reagents) + puddle.create_reagents(ARTIFACT_SWEAT_PUDDLE_CAP) + var/room = ARTIFACT_SWEAT_PUDDLE_CAP - puddle.reagents.total_volume + if(room <= 0) + return FALSE + puddle.reagents.add_reagent(reagent_type, min(amount, room)) + puddle.color = initial(reagent_type.color) + return TRUE + +/// A puddle of whatever an artifact wept. Scoop it up with a container, or mop it. +/obj/effect/decal/cleanable/artifact_ooze + name = "slick" + desc = "A small, faintly warm puddle of something thin." + icon = 'icons/effects/blood.dmi' + icon_state = "floor1" + random_icon_states = list("floor1", "floor2", "floor3", "floor4", "floor5", "floor6", "floor7") + alpha = 200 + beauty = -25 + mergeable_decal = FALSE + +#undef ARTIFACT_SWEAT_PUDDLE_CAP From 1da2395544b6b456e7253e77c5ba9e7252b79426 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:55:31 -0800 Subject: [PATCH 09/20] Have Sarge send dig finds round to Boffin Sarge buys none, but now says where to take a find hauled up to her counter. Reword the loaded specimen crate's examine. --- .../unit_tests/voidcrew_xenoarch_trade.dm | 4 +++ voidcrew/modules/xenoarch/trade/buyers.dm | 25 +++++++++++++++++-- .../modules/xenoarch/trade/specimen_crate.dm | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm b/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm index 35bd1273292..8bba8720162 100644 --- a/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm +++ b/voidcrew/modules/unit_tests/voidcrew_xenoarch_trade.dm @@ -63,6 +63,10 @@ find_row.demand = 0 shop.convoy_restock() TEST_ASSERT(find_row.demand > 0, "[shop_type]'s find demand never comes back") + // Sarge buys nothing but points the way + var/datum/outpost_shop/outfitter/depot = allocate(/datum/outpost_shop/outfitter) + TEST_ASSERT_NOTNULL(depot.xenoarch_buyer, "Sarge has nothing to say about a find") + TEST_ASSERT(depot.xenoarch_buyer.line("notice"), "Sarge has nothing to say about a find") TEST_ASSERT_EQUAL(xenoarch_credits_text(1125), "1,125 cr", "credit formatting") TEST_ASSERT_EQUAL(xenoarch_credits_text(250), "250 cr", "credit formatting") TEST_ASSERT_EQUAL(xenoarch_credits_text(1000000), "1,000,000 cr", "credit formatting") diff --git a/voidcrew/modules/xenoarch/trade/buyers.dm b/voidcrew/modules/xenoarch/trade/buyers.dm index 5fb61281f84..02ff921e467 100644 --- a/voidcrew/modules/xenoarch/trade/buyers.dm +++ b/voidcrew/modules/xenoarch/trade/buyers.dm @@ -17,7 +17,8 @@ * xenoarch_mark_curio(); Barnaby and Boffin take them, and only Boffin takes strange objects. * - Each buyer takes XENOARCH_FIND_DEMAND large finds and XENOARCH_CURIO_DEMAND curios at a time, * topped up by the convoy like any other ledger row (shop.dm convoy_restock()). - * - A buyer notices a find being hauled up to the counter and says so, once per find. + * - A buyer notices a find being hauled up to the counter and says so, once per find. Sarge, who + * buys none, points the way to Boffin's stall instead. * - Selling earns no reputation; that comes from jobs (trader_favor.dm). */ @@ -118,6 +119,8 @@ var/datum/outpost_shop/shop /// Vouchers paid on top of credits for a find whose main effect is extreme var/extreme_vouchers = 0 + /// Buys large finds at all (a trader who only points the way to the buyer next door doesn't) + var/buys_finds = TRUE /// Buys curios at all var/buys_curios = TRUE /// Takes tg's strange objects among the curios @@ -165,7 +168,9 @@ /// Ledger rows this buyer adds to their shop. /datum/xenoarch_buyer/proc/ledger_types() - . = list(/datum/shop_buyback/xenoarch_find) + . = list() + if(buys_finds) + . += /datum/shop_buyback/xenoarch_find if(buys_curios) . += /datum/shop_buyback/xenoarch_curio @@ -514,6 +519,19 @@ parts += "
[receipt_signoff]" return parts.Join() +// ----- Sarge: Quartermain Depot's main counter, who sends finds round to Boffin ----- + +/datum/xenoarch_buyer/sarge + buys_finds = FALSE + buys_curios = FALSE + lines = list( + XENOARCH_LINE_NOTICE = list( + "That's not armor. Boffin buys rocks. Skunkworks, round the back.", + "Dig piece? Not my department. Boffin's stall.", + "Don't park that at my counter. Boffin's the one who wants it.", + ), + ) + // ========================================================================= // SHOPS AND TRADERS // ========================================================================= @@ -533,6 +551,9 @@ /datum/outpost_shop/black_market xenoarch_buyer_type = /datum/xenoarch_buyer/vex +/datum/outpost_shop/outfitter + xenoarch_buyer_type = /datum/xenoarch_buyer/sarge + // The buyer's ledger rows go in before the base New() makes the buybacks, so they share the // shop's demand and convoy restock like any other row. /datum/outpost_shop/New(obj/structure/overmap/trader_outpost/outpost) diff --git a/voidcrew/modules/xenoarch/trade/specimen_crate.dm b/voidcrew/modules/xenoarch/trade/specimen_crate.dm index 3bcd9203c23..cecd2daa49f 100644 --- a/voidcrew/modules/xenoarch/trade/specimen_crate.dm +++ b/voidcrew/modules/xenoarch/trade/specimen_crate.dm @@ -40,6 +40,6 @@ var/obj/machinery/artifact/find = locate() in contents if(!find) return - . += "It sits heavy on its straps." + . += "Something heavy is strapped in." if(find.is_dug()) . += "A field tag clipped to the lid reads [find.serial]." From e56c336166660eb497b0c5c03875b6c0613528ed Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 22:01:54 -0800 Subject: [PATCH 10/20] Add the artifact harvester, exotic battery and utilizer The harvester draws one awake effect off an artifact beside it into an exotic battery. Each find gives three harvests; one is spent when the first charge reaches the battery, and the find stays locked for the draw and is released on finish, halt and deletion. A stream of motes in the energy's colour runs from the find to the collector dome while it hums, and its window is a phosphor scope over a glass charge tube. The utilizer runs the battery's effect from the hand: a field or bursts for about six and a half minutes, or ten contact uses. It hums, glows and sounds in the energy's own colour and voice, logs whoever switched it on, and goes dark inside trader outposts. Its window is a single power button ringed by the charge. Batteries and utilizers are items, so ship saves delete them; a saved harvester comes back empty. Both are rated yellow in the gear catalog. Art is Nova's harvester, battery and utilizer sprites with tint masks drawn for the energy colours. --- .../interfaces/AnomalyUtilizer.tsx | 112 ++++ .../interfaces/ArtifactHarvester.tsx | 266 ++++++++++ tools/gear_catalog/categories.py | 2 + tools/gear_catalog/ratings/relics.json | 18 + voidcrew/_DEFINES/xenoarch.dm | 10 + .../unit_tests/voidcrew_xenoarch_use.dm | 249 +++++++++ voidcrew/modules/xenoarch/icons/use.dmi | Bin 0 -> 8602 bytes voidcrew/modules/xenoarch/use/battery.dm | 204 +++++++- voidcrew/modules/xenoarch/use/harvester.dm | 485 +++++++++++++++++- voidcrew/modules/xenoarch/use/utilizer.dm | 367 ++++++++++++- 10 files changed, 1710 insertions(+), 3 deletions(-) create mode 100644 tgui/packages/voidcrew_tgui/interfaces/AnomalyUtilizer.tsx create mode 100644 tgui/packages/voidcrew_tgui/interfaces/ArtifactHarvester.tsx create mode 100644 voidcrew/modules/xenoarch/icons/use.dmi diff --git a/tgui/packages/voidcrew_tgui/interfaces/AnomalyUtilizer.tsx b/tgui/packages/voidcrew_tgui/interfaces/AnomalyUtilizer.tsx new file mode 100644 index 00000000000..628f049a942 --- /dev/null +++ b/tgui/packages/voidcrew_tgui/interfaces/AnomalyUtilizer.tsx @@ -0,0 +1,112 @@ +/** + * Exotic utilizer: one power button ringed by the battery's charge, glowing in the colour of the + * energy it holds. DM side: voidcrew/modules/xenoarch/use/utilizer.dm. + */ +import { Box, Button, Stack } from 'tgui-core/components'; + +import { useBackend } from '../../tgui/backend'; +import { Window } from '../../tgui/layouts'; + +type Cell = { + fill: number; + color: string | null; + serial: string | null; + mode: string | null; +}; + +type Data = { + emitting: number; + cell: Cell | null; +}; + +const RING_R = 52; +const RING_C = 2 * Math.PI * RING_R; + +export const AnomalyUtilizer = (props) => { + const { act, data } = useBackend(); + const { emitting, cell } = data; + const on = !!emitting; + const color = cell?.color || '#4b5563'; + const fill = cell ? Math.max(0, Math.min(1, cell.fill)) : 0; + return ( ++ + ); +}; diff --git a/tgui/packages/voidcrew_tgui/interfaces/ArtifactHarvester.tsx b/tgui/packages/voidcrew_tgui/interfaces/ArtifactHarvester.tsx new file mode 100644 index 00000000000..39c43f0dccd --- /dev/null +++ b/tgui/packages/voidcrew_tgui/interfaces/ArtifactHarvester.tsx @@ -0,0 +1,266 @@ +/** + * Exotic particle harvester: a phosphor scope traces the signal of the find beside the machine, + * in its energy's colour, and a glass tube fills with the battery's colour as it draws. + * DM side: voidcrew/modules/xenoarch/use/harvester.dm. + */ +import { Box, Button, Stack } from 'tgui-core/components'; + +import { useBackend } from '../../tgui/backend'; +import { Window } from '../../tgui/layouts'; + +type Source = { + serial: string; + state: string; + color: string | null; +}; + +type Cell = { + fill: number; + color: string | null; + kind: string | null; + serial: string | null; +}; + +type Data = { + powered: number; + drawing: number; + source: Source | null; + cell: Cell | null; +}; + +const WORDS: Record+ ++ + ++ ++ {cell?.serial ? cell.serial.toUpperCase() : 'NO CELL'} + {cell?.mode ? ` · ${cell.mode.toUpperCase()}` : ''} + ++ + += { + ready: 'SIGNAL', + drawing: 'DRAWING', + quiet: 'NO SIGNAL', + tangled: 'CROSSED', + unfit: 'WILL NOT HOLD', + spent: 'SPENT', + busy: 'ENGAGED', + mismatch: 'CELL MISMATCH', +}; + +const SCREEN_W = 240; +const SCREEN_H = 90; +const PHOSPHOR = '#59d48a'; +/** One period of the base wave in pixels; animated traces only use whole harmonics of it. */ +const PERIOD = 2 * Math.PI * 20; + +/** The trace for a state, twice the screen wide so it can scroll seamlessly. */ +function tracePath(state: string): string { + const points: string[] = []; + for (let x = 0; x <= SCREEN_W * 2; x += 3) { + const t = x / 20; + let y: number; + switch (state) { + case 'ready': + case 'drawing': + y = Math.sin(t) * 22; + break; + case 'tangled': + y = Math.sin(t) * 15 + Math.sin(t * 3 + 1) * 13; + break; + case 'unfit': + y = Math.sin(t * 3) * 26 * Math.exp(-((x % 60) / 16)); + break; + case 'mismatch': + y = Math.sin(t) * 12 + Math.sin(t * 5) * 6; + break; + case 'busy': + y = Math.sign(Math.sin(t * 0.8)) * 14; + break; + default: + y = Math.sin(t * 7) * 1.2; + } + points.push(`${x},${(SCREEN_H / 2 - y).toFixed(1)}`); + } + return `M ${points.join(' L ')}`; +} + +const MOVING = ['ready', 'drawing', 'tangled']; + +function Scope(props: { state: string; color: string; lit: boolean }) { + const { state, color, lit } = props; + return ( + + ); +} + +function Tube(props: { fill: number; color: string | null; live: boolean }) { + const { fill, color, live } = props; + const height = 104; + const level = Math.round(height * Math.max(0, Math.min(1, fill))); + return ( + + + ); +} + +const etched = { + fontFamily: 'monospace', + fontSize: '10px', + letterSpacing: '2px', + color: '#8f98a6', +}; + +export const ArtifactHarvester = (props) => { + const { act, data } = useBackend(); + const { powered, drawing, source, cell } = data; + const state = source ? source.state : 'none'; + const lit = !!powered; + const traceColor = + (state === 'drawing' || state === 'ready') && source?.color + ? source.color + : PHOSPHOR; + const canDraw = + lit && !drawing && !!cell && cell.fill < 1 && state === 'ready'; + return ( ++ + + + ); +}; diff --git a/tools/gear_catalog/categories.py b/tools/gear_catalog/categories.py index 861e0dde54f..13a7ff2bc18 100644 --- a/tools/gear_catalog/categories.py +++ b/tools/gear_catalog/categories.py @@ -191,8 +191,10 @@ ('/obj/item/access_key', 'tools', ITEM), ('/obj/item/airlock_painter', 'tools', ITEM), ('/obj/item/analyzer', 'tools', ITEM), + ('/obj/item/anomaly_battery', 'relics', ITEM), ('/obj/item/anomaly_neutralizer', 'tools', ITEM), ('/obj/item/anomaly_releaser', 'tools', ITEM), + ('/obj/item/anomaly_utilizer', 'relics', ITEM), ('/obj/item/beacon', 'tools', ITEM), ('/obj/item/binoculars', 'tools', ITEM), ('/obj/item/boxcutter', 'tools', ITEM), diff --git a/tools/gear_catalog/ratings/relics.json b/tools/gear_catalog/ratings/relics.json index 66247cc16a8..78f546b4ffb 100644 --- a/tools/gear_catalog/ratings/relics.json +++ b/tools/gear_catalog/ratings/relics.json @@ -9,6 +9,24 @@ "harmless" ], "items": { + "/obj/item/anomaly_battery": { + "confidence": "high", + "group": "parts and upgrades", + "hash": "", + "name": "exotic battery", + "rank": 2, + "reason": "Holds one effect drawn off an artifact for the exotic utilizer and does nothing alone. Rated as what it powers.", + "tier": "yellow" + }, + "/obj/item/anomaly_utilizer": { + "confidence": "medium", + "group": "parts and upgrades", + "hash": "", + "name": "exotic utilizer", + "rank": 2, + "reason": "Runs one harvested artifact effect from an exotic battery: a field or bursts for about 6.5 minutes, or 10 contact uses. Power is the artifact's own; the worst cases are stun or teleport bursts every 10 to 50 s over 2 to 8 tiles, which hit the holder too unless bio-suited. Healing shares the per-person artifact cap. Needs a dug artifact and a harvester to fill.", + "tier": "yellow" + }, "/obj/item/book_of_babel": { "confidence": "high", "group": "harmless", diff --git a/voidcrew/_DEFINES/xenoarch.dm b/voidcrew/_DEFINES/xenoarch.dm index 0981e3337d9..1a0f92e2e57 100644 --- a/voidcrew/_DEFINES/xenoarch.dm +++ b/voidcrew/_DEFINES/xenoarch.dm @@ -132,6 +132,16 @@ // ===== Harvesting (P4 owns the machines) ===== #define ARTIFACT_MAX_HARVESTS 3 +/// Charge an exotic battery holds. One harvest fills one battery. +#define ARTIFACT_BATTERY_CAPACITY 200 +/// Charge per second a harvester draws on tier-1 capacitors: a full battery in 80 seconds. +#define ARTIFACT_HARVEST_DRAW_RATE 2.5 +/// Charge per second a utilizer spends running a field or bursts: a full battery lasts 400 seconds. +#define ARTIFACT_UTILIZER_DRAIN 0.5 +/// Charge per second a utilizer feeds a burst effect's store, twice what an artifact refills. +#define ARTIFACT_UTILIZER_PULSE_FEED 1 +/// Charge one contact use costs: ten from a full battery. +#define ARTIFACT_UTILIZER_TOUCH_COST 20 // ===== Pricing (core function; buyers are P5) ===== /// Base price of a large artifact by stamped band (green, yellow, red). diff --git a/voidcrew/modules/unit_tests/voidcrew_xenoarch_use.dm b/voidcrew/modules/unit_tests/voidcrew_xenoarch_use.dm index 33c4631511f..cf88b2b70ab 100644 --- a/voidcrew/modules/unit_tests/voidcrew_xenoarch_use.dm +++ b/voidcrew/modules/unit_tests/voidcrew_xenoarch_use.dm @@ -1 +1,250 @@ // Xenoarchaeology tests: use. +// +// Test files compile before voidcrew/_DEFINES, so the values below are literals. They mirror +// voidcrew/_DEFINES/xenoarch.dm and the harvester's readout keys: +// ARTIFACT_MAX_HARVESTS 3, ARTIFACT_BATTERY_CAPACITY 200, ARTIFACT_HARVEST_DRAW_RATE 2.5, +// ARTIFACT_UTILIZER_DRAIN 0.5, ARTIFACT_UTILIZER_PULSE_FEED 1, ARTIFACT_UTILIZER_TOUCH_COST 20, +// ARTIFACT_AURA_COST_PER_SECOND 1.5, COMSIG_ARTIFACT_HARVESTED "artifact_harvested", +// release methods "touch", "aura", "pulse"; bands green 1, yellow 2, red 3. +// readout: "ready", "quiet", "tangled", "unfit", "spent", "busy", "mismatch". + +/// A battery fills only from a harvest, only from one source at a time, and a copy of it is empty. +/datum/unit_test/voidcrew_xenoarch_battery/Run() + var/obj/item/anomaly_battery/battery = allocate(/obj/item/anomaly_battery) + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/heal, /datum/artifact_effect/light, 2) + var/datum/artifact_effect/heal = find.main_effect + var/datum/artifact_effect/light = find.second_effect + + TEST_ASSERT_EQUAL(battery.stored_charge, 0, "a new battery came charged") + TEST_ASSERT_EQUAL(battery.add_charge(50), 0, "a battery holding nothing took charge") + TEST_ASSERT(battery.can_take(heal), "an empty battery refused an effect") + + battery.load_from(heal, find.serial) + TEST_ASSERT(istype(battery.held_effect, /datum/artifact_effect/heal), "the battery does not hold a copy of the effect") + TEST_ASSERT(battery.held_effect != heal, "the battery holds the artifact's own effect, not a copy") + TEST_ASSERT_EQUAL(battery.held_effect.holder, battery, "the copy's holder is not the battery") + TEST_ASSERT_EQUAL(battery.source_serial, find.serial, "the battery was not stamped with the find's serial") + TEST_ASSERT_EQUAL(battery.add_charge(250), 200, "a battery took more than its capacity") + TEST_ASSERT(battery.is_full(), "a battery at capacity is not full") + TEST_ASSERT_EQUAL(battery.charge_level(), 100, "a full battery's gauge") + TEST_ASSERT(!battery.can_take(heal), "a full battery took more") + battery.use_charge(199) + TEST_ASSERT_EQUAL(battery.charge_level(), 25, "any charge at all should show a quarter on the gauge") + TEST_ASSERT(battery.can_take(heal), "a part-charged battery refused a top-up from its own source") + TEST_ASSERT(!battery.can_take(light), "a part-charged battery took a second effect") + battery.use_charge(5) + TEST_ASSERT_EQUAL(battery.stored_charge, 0, "spending more than it held left charge behind") + TEST_ASSERT(battery.can_take(light), "an empty battery refused a new effect") + + battery.add_charge(80) + battery.purge() + TEST_ASSERT_EQUAL(battery.stored_charge, 0, "a purged battery kept charge") + TEST_ASSERT_NULL(battery.held_effect, "a purged battery kept its effect") + TEST_ASSERT_NULL(battery.source_serial, "a purged battery kept its stamp") + + // Machines that copy an item (the experimentor) make a new one from its type: always empty. + battery.load_from(heal, find.serial) + battery.add_charge(200) + var/obj/item/anomaly_battery/copy = allocate(battery.type) + TEST_ASSERT_EQUAL(copy.stored_charge, 0, "a battery built from its type came charged") + TEST_ASSERT_NULL(copy.held_effect, "a battery built from its type came holding an effect") + +/// The harvester: the harvest cap, when a harvest is spent, the lock, refusals and cleanup. +/datum/unit_test/voidcrew_xenoarch_harvest + var/harvest_signals = 0 + +/datum/unit_test/voidcrew_xenoarch_harvest/proc/on_harvested(datum/source, datum/artifact_effect/effect, mob/user) + SIGNAL_HANDLER + harvest_signals++ + +/datum/unit_test/voidcrew_xenoarch_harvest/Run() + var/obj/machinery/artifact_harvester/harvester = allocate(/obj/machinery/artifact_harvester) + harvester.set_machine_stat(NONE) + TEST_ASSERT(harvester.is_operational, "the harvester is not operational in the test room") + var/turf/beside = locate(harvester.x + 1, harvester.y, harvester.z) + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, beside, 2) + find.replace_effects(/datum/artifact_effect/heal, null, 2) + RegisterSignal(find, "artifact_harvested", PROC_REF(on_harvested)) + var/price_before = artifact_sale_value(find) + + TEST_ASSERT(!harvester.start_draw(), "it drew with no battery") + var/obj/item/anomaly_battery/battery = allocate(/obj/item/anomaly_battery) + battery.forceMove(harvester) + harvester.battery = battery + + TEST_ASSERT_EQUAL(harvester.find_source(), find, "it did not find the artifact beside it") + TEST_ASSERT_EQUAL(harvester.source_state(find), "quiet", "a sleeping find did not read as quiet") + TEST_ASSERT(!harvester.start_draw(), "it drew from a sleeping find") + + find.main_effect.wake(10 MINUTES) + TEST_ASSERT_EQUAL(harvester.source_state(find), "ready", "an awake, harvestable find did not read as ready") + TEST_ASSERT(harvester.start_draw(), "it would not draw from a ready find") + TEST_ASSERT(harvester.drawing, "it is not drawing") + TEST_ASSERT_EQUAL(find.locked_by?.resolve(), harvester, "it did not lock the find") + TEST_ASSERT_EQUAL(find.harvests_left, 3, "a harvest was spent before any charge arrived") + + harvester.process(2) + TEST_ASSERT_EQUAL(battery.stored_charge, 5, "two seconds on tier-1 parts should draw 5 charge") + TEST_ASSERT_EQUAL(find.harvests_left, 2, "the first charge did not spend a harvest") + TEST_ASSERT_EQUAL(harvest_signals, 1, "the harvest signal was not sent once") + harvester.process(2) + TEST_ASSERT_EQUAL(find.harvests_left, 2, "one draw spent two harvests") + for(var/i in 1 to 50) + if(!harvester.drawing) + break + harvester.process(2) + TEST_ASSERT(!harvester.drawing, "it never finished filling the battery") + TEST_ASSERT(battery.is_full(), "it stopped before the battery was full") + TEST_ASSERT(!find.is_being_used(), "it kept the find locked after finishing") + TEST_ASSERT(istype(battery.held_effect, /datum/artifact_effect/heal), "the battery does not hold the drawn effect") + TEST_ASSERT(artifact_sale_value(find) < price_before, "a harvest did not lower the find's price") + TEST_ASSERT_EQUAL(harvest_signals, 1, "one full draw sent more than one harvest signal") + TEST_ASSERT(!harvester.start_draw(), "it drew into a full battery") + + // Stopping before any charge arrives costs nothing; stopping after costs the harvest. + harvester.purge_battery() + TEST_ASSERT_EQUAL(battery.stored_charge, 0, "purging left charge in the battery") + TEST_ASSERT(harvester.start_draw(), "it would not draw into a purged battery") + harvester.stop_draw() + TEST_ASSERT_EQUAL(find.harvests_left, 2, "a draw stopped before any charge spent a harvest") + TEST_ASSERT(!find.is_being_used(), "a stopped draw kept the find locked") + TEST_ASSERT(harvester.start_draw(), "it would not start again") + harvester.process(2) + harvester.stop_draw() + TEST_ASSERT_EQUAL(find.harvests_left, 1, "a draw stopped after charge arrived did not spend its harvest") + TEST_ASSERT_EQUAL(battery.stored_charge, 5, "a stopped draw lost the charge it had drawn") + + // A part-charged battery only tops up from the effect it holds. + find.main_effect.deactivate(quiet = TRUE) + find.replace_effects(/datum/artifact_effect/heal, /datum/artifact_effect/light, 2) + find.second_effect.wake(10 MINUTES) + TEST_ASSERT_EQUAL(harvester.source_state(find), "mismatch", "a battery holding another effect read as ready") + TEST_ASSERT(!harvester.start_draw(), "a part-charged battery took a second effect") + find.main_effect.wake(10 MINUTES) + TEST_ASSERT_EQUAL(harvester.source_state(find), "tangled", "two awake effects did not read as tangled") + TEST_ASSERT(!harvester.start_draw(), "it drew with two effects awake") + find.second_effect.deactivate(quiet = TRUE) + find.main_effect.harvestable = FALSE + TEST_ASSERT_EQUAL(harvester.source_state(find), "unfit", "an unharvestable effect did not read as unfit") + TEST_ASSERT(!harvester.start_draw(), "it drew an unharvestable effect") + find.main_effect.harvestable = TRUE + harvester.purge_battery() + + // Someone else's lock, and a spent find. + var/datum/other_locker = new + TEST_ASSERT(find.try_lock(other_locker), "could not lock the find for the test") + TEST_ASSERT_EQUAL(harvester.source_state(find), "busy", "a find locked by another machine did not read as busy") + TEST_ASSERT(!harvester.start_draw(), "it drew from a find another machine held") + find.release_lock(other_locker) + qdel(other_locker) + find.harvests_left = 0 + TEST_ASSERT_EQUAL(harvester.source_state(find), "spent", "a find with no harvests left did not read as spent") + TEST_ASSERT(!harvester.start_draw(), "it drew past the harvest cap") + find.harvests_left = 1 + + // Hauling the find away mid-draw stops it and lets go. + TEST_ASSERT(harvester.start_draw(), "it would not draw from the last harvest") + find.forceMove(run_loc_floor_top_right) + harvester.process(2) + TEST_ASSERT(!harvester.drawing, "it kept drawing from a find out of reach") + TEST_ASSERT(!find.is_being_used(), "it kept a find out of reach locked") + TEST_ASSERT_EQUAL(find.harvests_left, 1, "a draw that never reached charge spent a harvest") + + // Deleting it mid-draw releases the find; ejecting hands the battery out. + find.forceMove(beside) + TEST_ASSERT(harvester.start_draw(), "it would not draw again") + harvester.process(2) + TEST_ASSERT_EQUAL(find.harvests_left, 0, "the last harvest was not spent") + harvester.stop_draw() + TEST_ASSERT(harvester.eject_battery(), "it would not eject its battery") + TEST_ASSERT_NULL(harvester.battery, "it kept a reference to the ejected battery") + TEST_ASSERT(!(battery in harvester.component_parts), "the battery counts as a part of the machine, so ship saves would keep it") + battery.forceMove(harvester) + harvester.battery = battery + find.harvests_left = 1 + harvester.purge_battery() + TEST_ASSERT(harvester.start_draw(), "it would not draw before deletion") + qdel(harvester) + TEST_ASSERT(!find.is_being_used(), "a deleted harvester kept the find locked") + TEST_ASSERT(QDELETED(battery), "a deleted harvester left its battery in nullspace") + UnregisterSignal(find, "artifact_harvested") + +/// The utilizer: field drain, healing through the shared cap, bursts, contact uses and cleanup. +/datum/unit_test/voidcrew_xenoarch_utilizer/Run() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact) + find.replace_effects(/datum/artifact_effect/heal, null, 2) + find.main_effect.release_method = "aura" + find.main_effect.range = 3 + var/obj/item/anomaly_battery/battery = allocate(/obj/item/anomaly_battery) + battery.load_from(find.main_effect, find.serial) + battery.add_charge(200) + find.moveToNullspace() + + var/obj/item/anomaly_utilizer/utilizer = allocate(/obj/item/anomaly_utilizer) + TEST_ASSERT(!utilizer.switch_on(), "it switched on with no battery") + battery.forceMove(utilizer) + utilizer.battery = battery + var/datum/artifact_effect/effect = battery.held_effect + + var/mob/living/carbon/human/consistent/patient = allocate(/mob/living/carbon/human/consistent) + patient.adjustBruteLoss(50) + var/damage_before = patient.getBruteLoss() + patient.getFireLoss() + + TEST_ASSERT(utilizer.switch_on(), "it would not switch on") + TEST_ASSERT(effect.activated, "switching on did not wake the battery's effect") + utilizer.process(2) + TEST_ASSERT_EQUAL(battery.stored_charge, 199, "a field should cost 0.5 charge a second") + for(var/i in 1 to 60) + utilizer.process(2) + var/healed = damage_before - (patient.getBruteLoss() + patient.getFireLoss()) + TEST_ASSERT(healed > 0, "a heal field healed nobody") + TEST_ASSERT(healed <= 30.1, "a heal field healed [healed], past the shared cap") + TEST_ASSERT(effect.activated, "the field lapsed while switched on") + + // Running dry switches it off. + battery.stored_charge = 0.5 + utilizer.process(2) + TEST_ASSERT(!utilizer.emitting, "it kept running on an empty battery") + TEST_ASSERT(!effect.activated, "its effect stayed awake after it went dark") + TEST_ASSERT(!utilizer.switch_on(), "it switched on with an empty battery") + + // Bursts build up at the utilizer's own rate and let go when full. + battery.stored_charge = 200 + effect.release_method = "pulse" + effect.maximum_charges = 6 + effect.current_charge = 0 + TEST_ASSERT(utilizer.switch_on(), "it would not switch on for bursts") + utilizer.process(2) + TEST_ASSERT_EQUAL(effect.current_charge, 2, "bursts should build at 1 charge a second") + utilizer.process(2) + utilizer.process(2) + TEST_ASSERT_EQUAL(effect.current_charge, 0, "a full store did not let go") + utilizer.switch_off() + + // Contact: one use per press, paid from the battery, and nothing while switched off. + var/mob/living/carbon/human/consistent/holder = allocate(/mob/living/carbon/human/consistent) + effect.release_method = "touch" + TEST_ASSERT_EQUAL(utilizer.interact_with_atom(patient, holder), NONE, "a switched-off utilizer acted on contact") + TEST_ASSERT(utilizer.switch_on(holder), "it would not switch on for contact") + var/charge_before = battery.stored_charge + utilizer.process(2) + TEST_ASSERT_EQUAL(battery.stored_charge, charge_before, "a contact effect drained while waiting") + TEST_ASSERT_EQUAL(utilizer.interact_with_atom(patient, holder), ITEM_INTERACT_SUCCESS, "pressing it to someone did nothing") + TEST_ASSERT_EQUAL(battery.stored_charge, charge_before - 20, "a contact use should cost 20 charge") + TEST_ASSERT_EQUAL(effect.get_responsible(), holder, "the person pressing it does not answer for it") + TEST_ASSERT_EQUAL(utilizer.interact_with_atom(find, holder), NONE, "it acted on contact with an object") + + // Ejecting while running switches it off; deleting it takes the battery with it. + TEST_ASSERT(utilizer.eject_battery(holder), "it would not eject its battery") + TEST_ASSERT(!utilizer.emitting, "it kept running with its battery out") + TEST_ASSERT(!effect.activated, "the battery's effect stayed awake out of the utilizer") + TEST_ASSERT_NULL(utilizer.battery, "it kept a reference to the ejected battery") + if(battery.loc == holder) + holder.transferItemToLoc(battery, utilizer, force = TRUE) + else + battery.forceMove(utilizer) + utilizer.battery = battery + TEST_ASSERT(utilizer.switch_on(holder), "it would not switch on again") + qdel(utilizer) + TEST_ASSERT(QDELETED(battery), "a deleted utilizer left its battery behind") diff --git a/voidcrew/modules/xenoarch/icons/use.dmi b/voidcrew/modules/xenoarch/icons/use.dmi new file mode 100644 index 0000000000000000000000000000000000000000..a49c5e20d60972d7310e43291d3a899282ea9f37 GIT binary patch literal 8602 zcmcI|XH-*d*XBtG5PCom5s`%cC+ ++ ++ ++ ++ + ++ {source ? source.serial.toUpperCase() : 'NO SOURCE'} + ++ {source ? WORDS[state] || '' : ''} + ++ ++ + CELL + ++ ++ {drawing ? ( + + ) : ( + + )} + ++ + ++ + +xMYH-cTpd>Ob~JLq!B&S-H(f5r-Zn#Jr>#qY-oUhW_dg0OE_knINJ zUJuH4stBd3-(5I^v5Bo;_mnzv %Yx_VJFok ztJZUl)?+dW=Y2V<6DA*B=6M`rX0@01;PANJa^hQAj8AXh$+tsK`^iksVqkW7 7<*`AgZ7yi8R()n}Erf-+(c!2kIO;YpZ zTSc4_#>M2_)bpmx1xJA+O}v94-(b+ggFTY1R$$Mu+zo1KVH0EgNmx1c`VoyB<9H%r zdx}_>IkV!>M3TN$HY@y*<&zmBfuFPn6C&n(+HRJ+K>a1}pr0ezb#76egxEpj{@CuC zbrQ?C>UCw_g^}V(_4R$3DdD`39zJNpD6z3LMMCb6OIvqpGM#{2!Hvk+ST$B*Bki{3 z`~+1)LnTW3qxg$2W*I#W3CGqIo_lsX4P(xI(DUcYcc(0%e;hiyZ>$5^Kbp7W4{KJe zuCBh?=7Ytm_A@l9Gz>y5Ir)tKV5y6{k(8nVop2q^$UL?@eEYk5fzElMP&oYz{^-|T zB?;C)qY4aPla!T!Fb>P)hJ5LRzThjBHakn1zx6)iCe~!G=A04MuL=rUg~x0_4i|hb z_`J|Q7G{P>Zv+|#o|pSpqIBbI-dpk vX}RleFSmzR~1g;hAY=E%%{dg@?# zoN?#!!=|jvLbMR8pg_>jLmlz_e>V6TKkdWl1XS6IjO3LR*TtgJ&sVKhjs+d~{dy;K z^0jn#H 3KybHrl znm62fnMnzyh#*qjZkR=CRjwe{hoRz4pUi_6i-Bj@&AVK+vIm^alTfRZ4C>lvoQLPs zy*0wpnZzc&)cot$!$eb~PCVWV@K-_`|GwY$Q=hCp7f(M1NVA7%As>$|q34%3$p(EQ zg81exK>jR;mpEN5q@X%I*RaN@d-zPYXfI_{>>Rz2P%6>HglIeULS-&(qe2DvV`JF_ zGl`}HvSL`SLnpS-opyH1MgL}}rAkH&Gq0@{Nfqk!_c*sV&ZLB!R4oB79FwI(#Wbsv z3fS;AFyPPS&+QxE0yOZ_@`GQC`U%4q$2mgQgQ+KL5iXoIZ-(&iZs6x6WT}VassBLS z?Dk$w5d34t tz|pCjMtt5)aa&`^0+Zmz9Ftbtg4r!77?D=SNi zag@GzE2=^Ez*uv&YD>doZ`>`llwDp`wK =MRFt?R9t*vQq& z<$N}dBi5SzSE~&`*=RMfJ6W-So}T{72GNT@Cp$Z>6C!9-wLiPCV5#M97%PEu8>t*P zGJW(n9g9ZCy!Wvb68$SSc-CTaSNQSb(APuVLj!AJ{oRg}laakSEXH%hZSaRP=_I%i zd+fnG){_x4f|b!?{#~7&ogH#~d~7@yxy-|O_T$s$P?xf@vcrnm1A_^ ZS zx=;IlpoQsxwysSpRR%qod%fymazhu)OQi6i>*krf;V?0Yl!)CgYk52J?pA?o!VTXh z9zuqOQzZ`W5*BfYX;JXbFIO4a?-`J{L}U{e f z75pVwqHJ=@( tO4B)s%b(rd~gP5g IbSW`HOGX_wGLH>jds^#T4gdQ9@Qm zzmo2=puQ_gxvd&J)X_;ZG81=QIhQeN)J!Pif^d@yEL{KsU5hqPVJX*GVgKZbAL!hE zYGeC?oSgfk!3#n;H1|OAm)`8-ma9%X+CKZM{lcgaFIsC5($cO;52kr$i-#H-8a_5Q zIhDPkYWYr{lJI*kG9iiEmTPvvKkr16_u3-m*2g67v|LJqF<_SnVpj(78({t%Ff7` zhsPQWs^R+Kzo37%xlLTm^Sid_P}F(ASojN$+7Ec`#U)u_v7Jl}@T1UJSEtS5R8k)$ zN+~@>AS!I)OAw&k4p}c!pS6fhz;hhiduQ;c(D|Z&VewsMm?ux3h=__7zY4MrVS1^D zH_N}N2wi9Vvk?_>v9FeBoLx{b>G1o 22tNW4Ol>-vw^XIqwN+=du^;o4wrw6G ~i;L^o&VK)R5t>E~Wbml`>*zviwZ9!h8V|@a`dSb9n|1l9x@}3SEI9TE z{6*rT`VUQeU1nu1{LM~o6MR>!mbT-wi1%F?oi4C3yFK|6DN%CEQaI0b%0gD+Vg!D| zAH;#hV`b&WrTqN-$L#FvqV-L`d|$tQO+R5@3Ur+H6>sl6#fA@!Q&m;fk cDCP%D$nmI`P!ZPL z&3pGQBOl{Zuz;v7H7bS*l}$lGv9EPox2}?_byuc2jMFD4IeDr*-|*`dhgKImu>(;! zDuz?WV|&4-pnA6_NyhX0sC|u4`K)Bw7M5G?CF05BXU_<#wqh6Zout+n@*jxSmtK>W z_9`zeec v8LeRd}rb^ii}aAq%e`~05A69c45`*NAt|E0Y#D2 zW*mi2fV+7enR%xldpUw1F)s<+A-VvIP#7EvgTyBQpWXrQ>A;uSGCf$@!n@R}ii(Pn z<(<_yH9N;}qxV;-SU$|?{Rn<;#!&Y?jW7TzvL%GAmzM#D-@BL?YsEq`6)Z*4jFpXz z=gUA0IG0heFfuYSbaQi4m5!65Xlv{HePd(1B&5-$;ceqSt-8AUxcLx878zf%+wDaE z2Uhm>a&4Vmpl2fCFnAhuz4^mBoq)hV27el0@HQ6$sf4bThG;uQm6en@fBEvo5TxO2 z1Vx+(jEt{AW3s=$M80&(rWA!f=VwCS(u4;8XyCanLI+2{GKI$r{GLlbL47}ag-#U8 z1O*SgB&v-&B{$-n-@$>$4j);~Bqy=kjS7v^W`*A~J}@GG+C2LCX`rQ*l@=XnR9plA zgMWuY`z<~IR460biAU$S^nA3MOsF80KN-&Xed4RHe^@tN!DgB6?_YH7(}dX7tMa 38MwPz#tLj8!-pYH2ZA5r^H@COR(XU({x9bU1tj(|P!?tdro{*U|zn z*t2txOuWGpf%#q*85G)bF!4ZMD|# G1d@#B*=e`;@!pHa0f;1_lO3ciOdNX-?f4grnuk zpNEJicA8^*85w_{>3I>{$pBG+`J>LUu|gV;(cvHa)SQkSkbiud*%>Z@G{nPAO}Uid zhycv}TAq?fFP`uc0ER!PL?Pf~Yg@##ckkY%H8(fk?7L+{*Zx{^#=;j^q?yAB >yPf=zptjGO>XJn;2@91VjroX&AI*c zOq+PF&+Hvmd$F|tb{zL2ZvO7G8O$H=Ot}^LZ7;$88}aMP%1Ss85*oTIceLJ6w%o(e zN)P$TKuc@N!peHz%*-tF`Q$h6BLhc`lCq>A+A{#xG&v&7xZ2~!Wnp1q16)zX`0|dU zpR6bh&KTZ_p|>nR#ZGaU^Yh(e0^uew{r>xf@G3Y`=vpcd6&O*bR**Y-KzKYA6!fe< zmPvA00+ ~$#&sSj$#5#o0VbA%ll|p^Z_H{CxnOU zC!__k3>1B)M^fuiVm5APy4OkKs`V%l 5=k b4aEVgk;<@S4&V(&MzT95}@=Q50h}NNfH~ zxoQxa2qgM*C<7ePaS2^1d*)vHmgZ+F$kK{|#I XN zR8S04&l9{Ugej`@;ok19Y=>gu#>R6O_=87}vgzvR&k@=D5pAO*BNGctOO-do#KgF5 znMCesYximy8J%QKHK1KjWIT5>vw|yTD@~f7cm;rY)K1j)Wj|^my!Y9^$y?mYR<|(! zR*`qt#!U01wWXzaF^D4?1INVCPur@Vo`=KhN3#a}!Dt*h8)?gjzSPjrKv_?Y1LYwc z!G**m0iS!iO8(#IiVAg+Nx^oiSA-jhLZT5LWx2^MZEbVEf!yCeI7oBl80#Z*n*thL ziN+oD?p-=3H4(}orKG0z#u}%V-}V*^CgfRg)(q?xe1i+W(?IppIQqGs0xo}tEC7=g zT)3`V=x#?5zbNlt yW2f)@{9b;S%uG(b4f#cm*(>`QORvqUy@tq1fsT zfvfTt&^QDH1-%wjo I<+ja3R@M(F#EwqJpr<%@sL8 zrTRO!Fk=clxn%D-z!!zIXo_XvEjdj@AtJcfg_q|iq@DgOmkCPSyYfn7lO#^R_RcLO zv{ausv|bV?UMpB0Vo~>3_55kTX%x}}%RsLd_>5KsgU?3<#;wTxF^!1|j!Lq%vpbpU z?!NcH&hE;q-+ccokWz zsH{ODa=UucYpY`tEU*FtFsZ4j#|$8u5j?gPixhD?WMpLejg5^u`uc3vV`cW7^ZZ@Y z$4aK}0R*EQd}<@-VS)MY-@jkc+`C!kSv_%+oA8u(cKf7O+tx-I9cqeQahmUB*>aVa zm;WxCkC$|LO+iUHa7+P()N8K FFm=3I`AJ#=0QJr(%+#~Y(-{TSY_J4Mo z(?osYLFU!81 ZiXYKZQnhlRq~O7}N#YDNZSzFM0kf z53~POu4^Z;z_l5MozU^>T#xQ3_3|e-{!26Io>JA$B|R&vELWBlTm)Vo{<$hIk3jd0 z7N3y7{+#VwT3T8vs9&`j3ci2dS{p7_RabB49i$UIJ0p7i#toMQ6ZSNE`M_wq`|!_q z;aWFDL~8dIACfP><{90)AcsB53kV1h{pw1ntOZ++hIf2Q%F6I`U7DT$)>Y87Qx%Cc z0LnF(PD2DbM-_f>cQYm?Ccm__w9SBT({|Go2bjPq1V6k-GmM^Ih6ttU)4zRp{yhbl z()wdpAJ*+({jLxsR0ktRzQO_WxP!OMNR7L-RPxKq%LCs(Vry!Wc*r1k43TK>MNgKu z9QMtj94VhZDc=AMGgE;gkO&(1J^XX1|MnOH8UF3`M#O6=9zT9;EF>VHH@!vFc%ZBM zj5hsp4D|BE!otG%hpV4zYVbwH#gnbAt@=W3vVjI*s3^xDZ_Rh@fhC(zv>CqH3v6N} zT)K2=VWB5=``1f`Z(x6f_VOf6kq-%5B+Ax$Lgwn~dT?@bBHZSRZ6dhZ%et=Uxp{hi z#e=+AQscfc9rbxhrLU)FLqJN71`%rzYh`@qBiOC@ZIDh7bdOJIBh<=g#4hbmmA*n8 zxv#Jo6_kzALL{9Rx^rH>eEA5*V~A5xRee*xY)%#afIp?fTnT;JS9ygn{UY%FZtwI9 z5Z&-_eW)or1m1a2z>~sVw3+gl93JjX-f|XN8#@K6#edb?Q-So?L3wr_RK%9%Nc0@l zy%8EfYN9hyY7p$*M8qUI@2!q|O>QWHRW gL zS`MK9Mg06|R|GDu7t!{khaOUopnYFXkNI~Y-TewIq@`L>X0V`C&MOrc-{R6f5ZTY4 z??(+Kx=q|RuvQd_RJw=54s>^~Kf6Nk623L@Gfz|&vn4fIp{3Vxk_-JP@FNa1KV)WR zre +mGI?>TH)Iv`Gl9x z5`@g;RzKCQIJ{1|@NV&F3aVphc>M0ij~~roiWeLW!mY@_`hFF!{ych8d8~GsZ#hhy z%ZPTZt$KqpfR_Ai5q`TG&~kjo4pu{og@4_WVFXR(b)LB(H7)g6Vq=x3sv|U`F1cKH zMatRn;6Ie?7H#VJV#S~2?*w3Gxn&MaL|~#W@SAk9eG?i{7EjEF)!JIJcmIO`mc{&c z0sPbnLftbkaJ!jw$gn-NCP({ad~@;ff(5%zx}DtCsKtWLAVR+tTf_(y)Os8(4dm#* zc=3WcCP6S^wA#pi)Rx#91%Y0#mP0_;+Uh^iWDImA$=K*0wo=y~`1< $@NyfW|8oJOaKVM>G#(?S}H_-u v?iOrD z*`K$S8 HaD_)0$HH-e*a6fzK^*>2iT375T>A#PQ>W<-Ge20_g_rV)0z?J>_REGjU zk~CL=MPFGs(80uY$~E$V@DUk~>bCODDvn `Y0=D|?BwLc&6lip=Z@r$wl>bhXBVw&Iz-9jfnGSgdyL#t z4puu+F@>upx2)+PuZ^J3ibJBae8=Z-y}oIjaKG8;TN-hfYKiKI)AGU90AtAfHO#l& zyd(Zb`bhJdy}h$H9}=j2ga&}Zs|WzFrG)_iI~fF^(%O6_9Ar6KggX{q=p`Y5a74k; zcvq@j8+6wvUyY>r&xE(!J @|EA?^fH^ZKTM24eu`xjPi#QRYMlep)^Up1sS8SBWq z)jok$*Gtz5J+aO?!(wDfW~&~@E{zL&?MfzYVurLi#oVw1*);Z-JAK}q+II41wDjuR z2fwanT=6hu*oyAl6 NG23kHt?|Qi`q+4^%S~Ff#P;OcPUGmv8uZX jpn19p?8X->85vv)D^XIWWrc1?wFu9+;sGehm}B%k&1 zWZ7Sv_B)?_p078Q7tLspatjNV$>e+glB;APB#=w(s*}H3+U5Ffx3sX3R4VgpS!`Q0 z?Xjzoni-`=^U;FGkn!#qxr^t@&NW4X=xCWetEMc`H1lM$O}OvArVQ_m>HV2ChDg1V zAbR{%y94ux(az#m+OkBu;TJoFq_|Gutly>DRIT#&wIHm9q+v{6JM*Djh4^29@%1su ztWMeM*O{ry@ZP)niwz-kVRFeaX4mztM;|d`cot(4A2J+nAGgkg-D!1)bU*gpF4UAh z(kLX$HTUUDS5K*|l+>}f>OS>~H7ytj+*b)Cy8h_2saUD?xQtloqI2C{hkpc%jR=X| znw_65!@F6QT0l+4<|>mRVT)$>;lc=s{_EwB11oKg2U+X-cn*;yk;x!9WcQG6(MS4B zw`uO~-P#(TCr$zfnTLxE(QzYhp}S(sBcyURczf`xMm4694A#OLrNNUx04GsrVp&2K zGFtKi%I$lsV0g$01(>*wkkQZQ0==IefN!`EUjXO7KOu+J4K5X;86st0Ic9(WPJY5y zm8E`_t2aSWLu-RyNYB~8on6@wX{ cgJqBf7uov+>Ba&HN4xwHzMexs;b&g&|8BblTpC@`2yM; CnP78 zL Vt}c4CWW+k5*0qa)0WFD}hk!0%I{Rl@ZOq@xq@B4%7toKX mZNkw1%@MUt|IkLuw = capacity + +/// The gauge on its side: 0, 25, 50, 75 or 100. Any charge at all shows a quarter. +/obj/item/anomaly_battery/proc/charge_level() + if(stored_charge <= 0) + return 0 + return clamp(round(charge_fraction() * 100, 25), 25, 100) + +/// The energy kind its core glows with, or null when it holds nothing. +/obj/item/anomaly_battery/proc/held_kind() + if(!held_effect) + return null + return artifact_energy_kind(held_effect.energy_kind) + +/// The kind to show: null while it holds no charge, so an empty core stays dark. +/obj/item/anomaly_battery/proc/lit_kind() + return stored_charge > 0 ? held_kind() : null + +/// Whether it still holds the effect drawn from `source`. +/obj/item/anomaly_battery/proc/holds_from(datum/artifact_effect/source) + return held_effect && source && source_ref?.resolve() == source + +/// Whether a harvester may pour `source`'s energy in: it is empty, or it already holds that same effect. +/obj/item/anomaly_battery/proc/can_take(datum/artifact_effect/source) + if(!source || is_full()) + return FALSE + return stored_charge <= 0 || holds_from(source) + +/// Readies it to take `source`'s energy, copying the effect unless it already holds it. +/obj/item/anomaly_battery/proc/load_from(datum/artifact_effect/source, serial) + if(holds_from(source)) + return + discard_effect() + held_effect = source.make_harvest_copy(src) + source_ref = WEAKREF(source) + source_serial = serial + stored_charge = 0 + update_appearance() + +/// Adds charge, up to capacity. Returns how much went in. +/obj/item/anomaly_battery/proc/add_charge(amount) + if(!held_effect || amount <= 0) + return 0 + var/added = min(amount, capacity - stored_charge) + if(added <= 0) + return 0 + var/old_level = charge_level() + stored_charge += added + if(charge_level() != old_level) + update_appearance() + return added + +/// Spends charge. Returns how much came out. +/obj/item/anomaly_battery/proc/use_charge(amount) + if(amount <= 0) + return 0 + var/used = min(amount, stored_charge) + var/old_level = charge_level() + stored_charge -= used + if(charge_level() != old_level) + update_appearance() + return used + +/// Empties it and lets go of the effect it held. +/obj/item/anomaly_battery/proc/purge() + discard_effect() + source_serial = null + stored_charge = 0 + update_appearance() + +/obj/item/anomaly_battery/proc/discard_effect() + if(held_effect?.activated) + held_effect.deactivate() + QDEL_NULL(held_effect) + source_ref = null + +/obj/item/anomaly_battery/update_icon_state() + icon_state = "[base_icon_state][charge_level()]" + return ..() + +/obj/item/anomaly_battery/update_overlays() + . = ..() + . += anomaly_core_overlays(src, "battery_core", lit_kind(), charge_fraction()) + +/obj/item/anomaly_battery/examine(mob/user) + . = ..() + if(source_serial) + . += "A strip on its side is stamped [source_serial]." + . += anomaly_core_description(lit_kind(), charge_fraction()) + +// ===== Shared with the utilizer and harvester ===== + +/** + * The glowing core of a battery as overlays: the tinted mask and its emissive, brighter with + * more charge. `state` is the mask's icon state on `owner`'s icon. Empty while the core is dark. + */ +/proc/anomaly_core_overlays(atom/owner, state, datum/artifact_energy_kind/kind, fraction) + . = list() + if(!kind || fraction <= 0) + return + var/core_alpha = round(110 + 145 * clamp(fraction, 0, 1)) + var/mutable_appearance/core = mutable_appearance(owner.icon, state, alpha = core_alpha) + core.color = kind.color + . += core + . += emissive_appearance(owner.icon, state, owner, alpha = round(core_alpha * 0.7)) + +/// "Its core glows a steady amber." or "Its core is dark." +/proc/anomaly_core_description(datum/artifact_energy_kind/kind, fraction) + if(!kind || fraction <= 0) + return "Its core is dark." + var/strength = "bright" + if(fraction < 0.34) + strength = "dim" + else if(fraction < 0.67) + strength = "steady" + return "Its core glows a [strength] [anomaly_glow_word(kind.key)]." + +/// A plain colour word for an energy kind's glow. +/proc/anomaly_glow_word(kind_key) + switch(kind_key) + if(ARTIFACT_ENERGY_CONCENTRATED) + return "amber" + if(ARTIFACT_ENERGY_PSIONIC) + return "violet" + if(ARTIFACT_ENERGY_ELECTROMAGNETIC) + return "pale blue" + if(ARTIFACT_ENERGY_PARTICLE) + return "white" + if(ARTIFACT_ENERGY_ORGANIC) + return "rose red" + if(ARTIFACT_ENERGY_BLUESPACE) + return "deep blue" + if(ARTIFACT_ENERGY_SYNTHESIS) + return "green" + return "strange light" + +/datum/design/anomaly_battery + name = "Exotic Battery" + desc = "A cell built to hold what a harvester draws off an alien find." + id = "xenoarch_battery" + build_type = PROTOLATHE | AWAY_LATHE + materials = list( + /datum/material/iron = SHEET_MATERIAL_AMOUNT, + /datum/material/plasma = SHEET_MATERIAL_AMOUNT, + /datum/material/gold = HALF_SHEET_MATERIAL_AMOUNT, + ) + build_path = /obj/item/anomaly_battery + category = list( + RND_CATEGORY_EQUIPMENT + RND_SUBCATEGORY_EQUIPMENT_SCIENCE + ) + departmental_flags = DEPARTMENT_BITFLAG_SCIENCE diff --git a/voidcrew/modules/xenoarch/use/harvester.dm b/voidcrew/modules/xenoarch/use/harvester.dm index 0709c090d39..8de9efea73c 100644 --- a/voidcrew/modules/xenoarch/use/harvester.dm +++ b/voidcrew/modules/xenoarch/use/harvester.dm @@ -1 +1,484 @@ -// The harvester: drains one active effect from a find into a battery. +/** + * # Exotic particle harvester + * + * Draws one awake effect off an alien artifact standing next to it and packs it into an exotic + * battery, which a utilizer can then run. Each artifact gives ARTIFACT_MAX_HARVESTS harvests in + * all, and every harvest taken lowers its sale price (core pricing reads harvests_taken()). + * + * Rewritten from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/machines/artifact_harvester.dm, + * with its HTML window replaced by tgui (ArtifactHarvester.tsx). Voidcrew changes: + * - A harvest is spent the moment the first charge reaches the battery, so stopping early or + * losing power partway never refunds it, and a draw that never started costs nothing. + * Nova copied the effect for free, forever. + * - The find's lock (try_lock()/release_lock()) is held for the whole draw and released on + * finish, on halt and in Destroy(). Nova anchored the find and never let go of it on halt. + * - It reads any find on the eight tiles around it, so it works beside a scan pad or without one. + * - Effects marked unharvestable won't come off; two effects awake at once can't be separated. + * - A battery can be topped up only from the effect it already holds; an empty one takes anything. + * - While it draws, a stream of motes in the energy's colour runs from the find to the dome, the + * find throbs and crackles with its own sound, and the console hums. + * + * Art: Nova's machinery.dmi harvester states (CC BY-SA 3.0, pixel-checked clean against Goon), + * a dome mask drawn for Voidcrew, and tg's drain_life beam made greyscale so it can be tinted. + * + * Ship saves: the harvester is rebuilt from its board with an empty slot (its battery is an item + * and clear_stock() deletes it) and no draw in progress, so a save never copies a charge. + */ + +/// What the readout says about the find beside it. +#define HARVEST_SOURCE_READY "ready" +#define HARVEST_SOURCE_QUIET "quiet" +#define HARVEST_SOURCE_TANGLED "tangled" +#define HARVEST_SOURCE_UNFIT "unfit" +#define HARVEST_SOURCE_SPENT "spent" +#define HARVEST_SOURCE_BUSY "busy" +#define HARVEST_SOURCE_MISMATCH "mismatch" +#define HARVEST_SOURCE_DRAWING "drawing" + +/obj/machinery/artifact_harvester + name = "exotic particle harvester" + desc = "A console wired to a collector dome. It pulls the energy off an alien find and packs it into a battery." + icon = 'voidcrew/modules/xenoarch/icons/use.dmi' + icon_state = "harvester" + base_icon_state = "harvester" + density = TRUE + anchored = TRUE + circuit = /obj/item/circuitboard/machine/artifact_harvester + idle_power_usage = BASE_MACHINE_IDLE_CONSUMPTION + active_power_usage = BASE_MACHINE_ACTIVE_CONSUMPTION * 2 + processing_flags = START_PROCESSING_MANUALLY + // Its window opens unpowered too (dark scope, no draw), so a battery is never stuck inside. + interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_OFFLINE + /// The battery in its slot + var/obj/item/anomaly_battery/battery + /// Drawing right now + var/drawing = FALSE + /// The find it draws from, while it draws + var/datum/weakref/source_ref + /// The effect it draws, while it draws + var/datum/weakref/drawn_ref + /// Whoever started the draw, for the harvest record + var/datum/weakref/operator_ref + /// This draw has already taken one of the find's harvests + var/draw_counted = FALSE + /// Charge per second, from its capacitors + var/draw_rate = ARTIFACT_HARVEST_DRAW_RATE + /// The stream of motes between the find and the dome + var/datum/beam/draw_beam + /// The hum while it draws + var/datum/looping_sound/artifact_harvester/soundloop + /// world.time of the next crackle off the find + var/next_crackle = 0 + +/obj/machinery/artifact_harvester/Initialize(mapload) + . = ..() + soundloop = new(src) + +/obj/machinery/artifact_harvester/Destroy() + stop_draw() + QDEL_NULL(soundloop) + QDEL_NULL(battery) + return ..() + +/obj/machinery/artifact_harvester/RefreshParts() + . = ..() + var/capacitor_tier = max(total_part_rating(/datum/stock_part/capacitor) / 2, 1) + // Tier-1 capacitors fill a battery in 80 seconds, tier-4 in 40. + draw_rate = ARTIFACT_HARVEST_DRAW_RATE * (1 + (capacitor_tier - 1) / 3) + +/obj/machinery/artifact_harvester/examine(mob/user) + . = ..() + if(battery) + . += "An exotic battery is seated under the dome." + if(drawing) + . += span_notice("Its dome hums, and a thin stream of light runs into it.") + +// ===== Battery slot ===== + +/obj/machinery/artifact_harvester/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!istype(tool, /obj/item/anomaly_battery)) + return NONE + if(battery) + balloon_alert(user, "slot's taken!") + return ITEM_INTERACT_BLOCKING + if(!user.transferItemToLoc(tool, src)) + return ITEM_INTERACT_BLOCKING + battery = tool + user.visible_message( + span_notice("[user] seats [tool] under the dome of [src]."), + span_notice("You seat [tool] under the dome of [src]."), + ) + playsound(src, 'sound/machines/terminal/terminal_insert_disc.ogg', 40, TRUE) + update_appearance() + SStgui.update_uis(src) + return ITEM_INTERACT_SUCCESS + +/obj/machinery/artifact_harvester/Exited(atom/movable/gone, direction) + . = ..() + if(gone != battery) + return + battery = null + stop_draw() + if(!QDELETED(src)) + update_appearance() + +/// Hands the battery back, or drops it in front of the harvester. +/obj/machinery/artifact_harvester/proc/eject_battery(mob/living/user) + if(!battery) + return FALSE + if(drawing) + balloon_alert(user, "it's drawing!") + return FALSE + var/obj/item/anomaly_battery/ejected = battery + ejected.forceMove(drop_location()) + if(user && Adjacent(user)) + user.put_in_hands(ejected) + playsound(src, 'sound/machines/terminal/terminal_eject.ogg', 40, TRUE) + return TRUE + +/// Vents the battery: its charge and the effect it held are gone, and it can take anything again. +/obj/machinery/artifact_harvester/proc/purge_battery(mob/living/user) + if(!battery || drawing || !battery.held_effect) + return FALSE + var/datum/artifact_energy_kind/kind = battery.lit_kind() + battery.purge() + if(kind) + visible_message(span_notice("[src]'s dome flares [anomaly_glow_word(kind.key)] and goes dark with a hiss.")) + flick_dome(kind.color) + playsound(src, 'sound/machines/steam_hiss.ogg', 40, TRUE) + update_appearance() + return TRUE + +// ===== Reading the find ===== + +/// The find it would draw from: an artifact on a tile around it, preferring one that is awake. +/obj/machinery/artifact_harvester/proc/find_source() + var/obj/machinery/artifact/fallback + for(var/obj/machinery/artifact/candidate in orange(1, src)) + if(QDELETED(candidate) || !isturf(candidate.loc)) + continue + if(candidate.is_active()) + return candidate + fallback ||= candidate + return fallback + +/// Whether a find is still close enough to draw from. +/obj/machinery/artifact_harvester/proc/in_reach(obj/machinery/artifact/source) + return !QDELETED(source) && isturf(source.loc) && source.z == z && get_dist(src, source) <= 1 + +/// The one awake effect a draw would take, or null when none or both are awake. +/obj/machinery/artifact_harvester/proc/awake_effect(obj/machinery/artifact/source) + var/datum/artifact_effect/found + for(var/datum/artifact_effect/effect as anything in source.effects()) + if(!effect.activated) + continue + if(found) + return null + found = effect + return found + +/// What the readout says about `source` right now (a HARVEST_SOURCE_* key). +/obj/machinery/artifact_harvester/proc/source_state(obj/machinery/artifact/source) + if(source.harvests_left <= 0) + return HARVEST_SOURCE_SPENT + if(source.is_being_used() && source.locked_by?.resolve() != src) + return HARVEST_SOURCE_BUSY + if(source.suppressed) + return HARVEST_SOURCE_QUIET + var/awake = 0 + for(var/datum/artifact_effect/effect as anything in source.effects()) + if(effect.activated) + awake++ + if(awake > 1) + return HARVEST_SOURCE_TANGLED + var/datum/artifact_effect/effect = awake_effect(source) + if(!effect) + return HARVEST_SOURCE_QUIET + if(!effect.harvestable) + return HARVEST_SOURCE_UNFIT + if(battery && !battery.can_take(effect) && !battery.is_full()) + return HARVEST_SOURCE_MISMATCH + return HARVEST_SOURCE_READY + +// ===== Drawing ===== + +/// Starts a draw from the find beside it. Returns TRUE if it started. +/obj/machinery/artifact_harvester/proc/start_draw(mob/living/user) + if(drawing) + return FALSE + if(!is_operational) + return refuse(user, "no power!") + if(!battery) + return refuse(user, "no battery!") + if(battery.is_full()) + return refuse(user, "battery's full!") + var/obj/machinery/artifact/source = find_source() + if(!source) + return refuse(user, "nothing to draw from!") + if(source_state(source) != HARVEST_SOURCE_READY) + return refuse(user, "no clean signal!") + var/datum/artifact_effect/effect = awake_effect(source) + if(!effect || !source.try_lock(src)) + return refuse(user, "no clean signal!") + + battery.load_from(effect, source.serial) + drawing = TRUE + draw_counted = FALSE + source_ref = WEAKREF(source) + drawn_ref = WEAKREF(effect) + operator_ref = user ? WEAKREF(user) : null + next_crackle = world.time + 3 SECONDS + + var/datum/artifact_energy_kind/kind = artifact_energy_kind(effect.energy_kind) + QDEL_NULL(draw_beam) + // The motes run from the find into the collector dome on the right of the sprite. + draw_beam = Beam(source, icon_state = "harvest_draw", icon = 'voidcrew/modules/xenoarch/icons/use.dmi', beam_color = kind.color, override_origin_pixel_x = 7, override_origin_pixel_y = 10) + soundloop.start() + playsound(src, 'sound/machines/terminal/terminal_prompt_confirm.ogg', 40, TRUE) + visible_message(span_notice("[src] hums, and a thin stream of [anomaly_glow_word(kind.key)] light reaches out to [source].")) + update_use_power(ACTIVE_POWER_USE) + begin_processing() + update_appearance() + return TRUE + +/// Buzzes and says why it won't start. Always FALSE. +/obj/machinery/artifact_harvester/proc/refuse(mob/living/user, reason) + playsound(src, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) + if(user) + balloon_alert(user, reason) + return FALSE + +/obj/machinery/artifact_harvester/process(seconds_per_tick) + if(!drawing) + return PROCESS_KILL + var/obj/machinery/artifact/source = source_ref?.resolve() + var/datum/artifact_effect/effect = drawn_ref?.resolve() + if(!is_operational) + stop_draw("[src]'s dome flickers and goes dark.") + return + if(!battery || QDELETED(effect) || !in_reach(source) || !source.try_lock(src)) + stop_draw("[src] whines down as the stream of light snaps.") + return + var/added = battery.add_charge(draw_rate * seconds_per_tick) + if(added > 0 && !draw_counted) + count_harvest(source, effect) + if(world.time >= next_crackle) + next_crackle = world.time + rand(5 SECONDS, 8 SECONDS) + var/datum/artifact_energy_kind/kind = artifact_energy_kind(effect.energy_kind) + playsound(source, kind.pulse_sound, 25, TRUE) + source.throb(1.06) + flick_dome(kind.color) + if(battery.is_full()) + finish_draw() + +/// Takes one of the find's harvests. Runs once per draw, when the first charge arrives. +/obj/machinery/artifact_harvester/proc/count_harvest(obj/machinery/artifact/source, datum/artifact_effect/effect) + draw_counted = TRUE + source.harvests_left = max(source.harvests_left - 1, 0) + var/mob/user = operator_ref?.resolve() + SEND_SIGNAL(source, COMSIG_ARTIFACT_HARVESTED, effect, user) + record_metric( + category = METRIC_RESEARCH, + event = XENOARCH_METRIC_HARVESTED, + zone = xenoarch_band_name(source.origin_band), + subject = "[effect.type]", + details = list( + "serial" = source.serial, + "harvests_taken" = source.harvests_taken(), + "kind" = effect.energy_kind, + "release" = effect.release_method, + "strength" = effect.strength, + ), + actor = user, + location = src, + ) + log_game("[user ? key_name(user) : "Nobody"] drew [effect.log_name] off artifact [source.serial] with [src] at [AREACOORD(src)]; [source.harvests_left] harvests left.") + +/obj/machinery/artifact_harvester/proc/finish_draw() + var/datum/artifact_energy_kind/kind = battery?.held_kind() + stop_draw() + playsound(src, 'sound/machines/chime.ogg', 40, FALSE) + if(kind) + visible_message(span_notice("[src] chimes, and its dome settles to a steady [anomaly_glow_word(kind.key)] glow.")) + else + visible_message(span_notice("[src] chimes.")) + +/** + * Ends a draw: lets go of the find, cuts the stream and the hum. Safe to call when idle and from + * Destroy(). `message` is shown to anyone watching. + */ +/obj/machinery/artifact_harvester/proc/stop_draw(message) + if(!drawing) + return + drawing = FALSE + var/obj/machinery/artifact/source = source_ref?.resolve() + source?.release_lock(src) + source_ref = null + drawn_ref = null + operator_ref = null + draw_counted = FALSE + QDEL_NULL(draw_beam) + soundloop?.stop() + end_processing() + if(QDELETED(src)) + return + update_use_power(IDLE_POWER_USE) + update_appearance() + SStgui.update_uis(src) + if(message) + visible_message(span_warning(message)) + playsound(src, 'sound/machines/terminal/terminal_off.ogg', 40, TRUE) + +// ===== Looks ===== + +/obj/machinery/artifact_harvester/update_icon_state() + if(drawing) + icon_state = "[base_icon_state]_on" + else if(battery) + icon_state = "[base_icon_state]_loaded" + else + icon_state = base_icon_state + return ..() + +/obj/machinery/artifact_harvester/update_overlays() + . = ..() + if(!battery) + return + var/datum/artifact_energy_kind/kind + var/fraction = battery.charge_fraction() + if(drawing) + var/datum/artifact_effect/effect = drawn_ref?.resolve() + kind = effect ? artifact_energy_kind(effect.energy_kind) : battery.held_kind() + // The dome is lit the whole draw, even while the battery is still nearly empty. + fraction = max(fraction, 0.6) + else + kind = battery.lit_kind() + . += anomaly_core_overlays(src, "harvester_dome", kind, fraction) + +/// A brief flare of the dome in `color` that fades back to whatever it shows. +/obj/machinery/artifact_harvester/proc/flick_dome(color) + var/mutable_appearance/flare = mutable_appearance(icon, "harvester_dome") + flare.color = color + var/atom/movable/flare_visual = flick_overlay_view(flare, 0.8 SECONDS) + if(flare_visual) + animate(flare_visual, alpha = 0, time = 0.8 SECONDS, easing = SINE_EASING | EASE_IN) + +// ===== Tools ===== + +/obj/machinery/artifact_harvester/screwdriver_act(mob/living/user, obj/item/tool) + if(drawing) + balloon_alert(user, "it's drawing!") + return ITEM_INTERACT_BLOCKING + if(default_deconstruction_screwdriver(user, icon_state, icon_state, tool)) + update_appearance() + return ITEM_INTERACT_SUCCESS + return NONE + +/obj/machinery/artifact_harvester/crowbar_act(mob/living/user, obj/item/tool) + if(drawing && panel_open) + balloon_alert(user, "it's drawing!") + return ITEM_INTERACT_BLOCKING + if(default_deconstruction_crowbar(tool)) + return ITEM_INTERACT_SUCCESS + return NONE + +// ===== Window ===== + +/obj/machinery/artifact_harvester/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "ArtifactHarvester", name) + ui.open() + +/obj/machinery/artifact_harvester/ui_data(mob/user) + var/list/data = list() + data["powered"] = is_operational + data["drawing"] = drawing + var/obj/machinery/artifact/source = drawing ? source_ref?.resolve() : find_source() + if(source) + var/datum/artifact_effect/effect = drawing ? drawn_ref?.resolve() : awake_effect(source) + var/datum/artifact_energy_kind/kind = effect ? artifact_energy_kind(effect.energy_kind) : null + data["source"] = list( + "serial" = source.serial || "untagged", + "state" = drawing ? HARVEST_SOURCE_DRAWING : source_state(source), + "color" = kind?.color, + ) + else + data["source"] = null + if(battery) + var/datum/artifact_energy_kind/kind = battery.lit_kind() + data["cell"] = list( + "fill" = round(battery.charge_fraction(), 0.01), + "color" = kind?.color, + "kind" = kind?.report_name, + "serial" = battery.source_serial, + ) + else + data["cell"] = null + return data + +/obj/machinery/artifact_harvester/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + var/mob/living/user = ui.user + switch(action) + if("draw") + start_draw(user) + return TRUE + if("halt") + if(drawing) + stop_draw("[src] whines down.") + return TRUE + if("eject") + eject_battery(user) + return TRUE + if("purge") + purge_battery(user) + return TRUE + +// ===== Board, design and sound ===== + +/obj/item/circuitboard/machine/artifact_harvester + name = "Exotic Particle Harvester" + greyscale_colors = CIRCUIT_COLOR_SCIENCE + build_path = /obj/machinery/artifact_harvester + req_components = list( + /datum/stock_part/capacitor = 2, + /datum/stock_part/scanning_module = 1, + /datum/stock_part/micro_laser = 1, + ) + +/datum/design/board/artifact_harvester + name = "Exotic Particle Harvester Board" + desc = "The circuit board for an exotic particle harvester." + id = "xenoarch_harvester" + build_path = /obj/item/circuitboard/machine/artifact_harvester + category = list( + RND_CATEGORY_MACHINE + RND_SUBCATEGORY_MACHINE_RESEARCH + ) + departmental_flags = DEPARTMENT_BITFLAG_SCIENCE + +/datum/looping_sound/artifact_harvester + start_sound = 'sound/machines/gravgen/grav_gen_start.ogg' + start_length = 1 SECONDS + mid_sounds = list( + 'sound/machines/gravgen/grav_gen_mid1.ogg' = 12, + 'sound/machines/gravgen/grav_gen_mid2.ogg' = 1, + ) + mid_length = 1.1 SECONDS + end_sound = 'sound/machines/gravgen/grav_gen_end.ogg' + volume = 30 + extra_range = -4 + falloff_distance = 2 + falloff_exponent = 5 + vary = TRUE + +#undef HARVEST_SOURCE_READY +#undef HARVEST_SOURCE_QUIET +#undef HARVEST_SOURCE_TANGLED +#undef HARVEST_SOURCE_UNFIT +#undef HARVEST_SOURCE_SPENT +#undef HARVEST_SOURCE_BUSY +#undef HARVEST_SOURCE_MISMATCH +#undef HARVEST_SOURCE_DRAWING diff --git a/voidcrew/modules/xenoarch/use/utilizer.dm b/voidcrew/modules/xenoarch/use/utilizer.dm index 9962c143f12..27b7ab9f86f 100644 --- a/voidcrew/modules/xenoarch/use/utilizer.dm +++ b/voidcrew/modules/xenoarch/use/utilizer.dm @@ -1 +1,366 @@ -// The handheld utilizer that runs a harvested effect from its battery. +/** + * # Exotic utilizer + * + * A handheld emitter that runs whatever effect its exotic battery holds. Switched on from its + * own small window (attack_self), never from an action button. + * + * - A field effect runs without a break; a burst effect builds up and lets go on its own rhythm, + * at twice the rate the artifact itself refilled. Either costs ARTIFACT_UTILIZER_DRAIN charge a + * second, so a full battery lasts about six and a half minutes. + * - A contact effect waits until the holder presses the prongs to someone (themselves included), + * at ARTIFACT_UTILIZER_TOUCH_COST a use: ten uses from a full battery. + * - Whoever switched it on answers for the harm it does (set_responsible), and every contact use + * is logged like a weapon hit. Its holder and anyone else in reach are affected alike. + * - It goes dark inside a trader outpost, as artifacts do. + * - Healing, cell charge and air effects run through the effect's own code, so the shared heal + * cap, the cell rules and the planet-air guard all still apply. It makes no charge of its own. + * + * Rewritten from NovaSector (5ce2bd2215c0) modular_nova/modules/xenoarchartifacts/obj/particle_battery.dm + * (/obj/item/xenoarch/xenoarch_utilizer), with its HTML window replaced by tgui (AnomalyUtilizer.tsx) + * and its timer mode dropped. Art: Nova's machinery.dmi utilizer states (CC BY-SA 3.0, pixel-checked + * clean against Goon), with core and prong masks drawn for Voidcrew. Sounds and hums are the + * energy kind's own (core/artifact_energy_kinds.dm). + * + * Ship saves delete it like any item, battery and all, so it can never come back charged. + */ + +/// How long each process keeps the battery's effect awake: well past the next SSobj tick, so it +/// never lapses while on, even when the server lags. Switching off puts it to sleep at once. +#define UTILIZER_WAKE_MARGIN (10 SECONDS) + +/obj/item/anomaly_utilizer + name = "exotic utilizer" + desc = "A pronged emitter on a squat grip, with a slot for an exotic battery." + icon = 'voidcrew/modules/xenoarch/icons/use.dmi' + icon_state = "utilizer" + base_icon_state = "utilizer" + inhand_icon_state = "electronic" + lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi' + righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi' + w_class = WEIGHT_CLASS_SMALL + item_flags = NOBLUDGEON + light_system = OVERLAY_LIGHT + light_range = 2 + light_power = 0.8 + light_on = FALSE + custom_materials = list( + /datum/material/iron = SHEET_MATERIAL_AMOUNT * 2, + /datum/material/glass = SHEET_MATERIAL_AMOUNT, + /datum/material/gold = SHEET_MATERIAL_AMOUNT, + /datum/material/plasma = SHEET_MATERIAL_AMOUNT, + ) + /// The battery in its slot + var/obj/item/anomaly_battery/battery + /// Switched on and giving off its effect + var/emitting = FALSE + /// The energy kind's hum while it runs + var/datum/looping_sound/hum + +/obj/item/anomaly_utilizer/Destroy(force) + switch_off(quiet = TRUE) + QDEL_NULL(battery) + QDEL_NULL(hum) + return ..() + +/// The effect it would run, or null with no battery or an empty one. +/obj/item/anomaly_utilizer/proc/loaded_effect() + return battery?.held_effect + +/// Whether it may run here: never inside a trader outpost. +/obj/item/anomaly_utilizer/proc/is_damped() + return is_trader_outpost_protected(src) + +// ===== Battery slot ===== + +/obj/item/anomaly_utilizer/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!istype(tool, /obj/item/anomaly_battery)) + return NONE + if(battery) + balloon_alert(user, "slot's taken!") + return ITEM_INTERACT_BLOCKING + if(!user.transferItemToLoc(tool, src)) + return ITEM_INTERACT_BLOCKING + battery = tool + to_chat(user, span_notice("You slide [tool] into [src] until it clicks.")) + playsound(src, 'sound/items/weapons/gun/general/magazine_insert_full.ogg', 30, TRUE) + update_appearance() + SStgui.update_uis(src) + return ITEM_INTERACT_SUCCESS + +/obj/item/anomaly_utilizer/Exited(atom/movable/gone, direction) + . = ..() + if(gone != battery) + return + switch_off(quiet = QDELETED(src)) + battery = null + if(!QDELETED(src)) + update_appearance() + SStgui.update_uis(src) + +/obj/item/anomaly_utilizer/proc/eject_battery(mob/living/user) + if(!battery) + return FALSE + var/obj/item/anomaly_battery/ejected = battery + switch_off() + ejected.forceMove(drop_location()) + if(user) + user.put_in_hands(ejected) + playsound(src, 'sound/items/weapons/gun/general/magazine_remove_full.ogg', 30, TRUE) + return TRUE + +// ===== Switching ===== + +/// Switches it on. Returns TRUE if it started. +/obj/item/anomaly_utilizer/proc/switch_on(mob/living/user) + if(emitting) + return FALSE + var/datum/artifact_effect/effect = loaded_effect() + if(!effect || battery.stored_charge <= 0) + playsound(src, 'sound/machines/click.ogg', 30, TRUE) + if(user) + balloon_alert(user, "nothing happens") + return FALSE + if(is_damped()) + playsound(src, 'sound/machines/click.ogg', 30, TRUE) + if(user) + to_chat(user, span_warning("[src] clicks, but its prongs stay dark.")) + return FALSE + emitting = TRUE + effect.set_responsible(user) + effect.wake(UTILIZER_WAKE_MARGIN) + START_PROCESSING(SSobj, src) + + var/datum/artifact_energy_kind/kind = artifact_energy_kind(effect.energy_kind) + playsound(src, 'sound/machines/click.ogg', 30, TRUE) + playsound(src, kind.wake_sound, 40, TRUE) + QDEL_NULL(hum) + if(kind.hum_type) + hum = new kind.hum_type(src) + hum.start() + visible_message(span_notice("[src] hums to life, its prongs glowing [anomaly_glow_word(kind.key)].")) + if(user) + user.log_message("switched on [src] holding [effect.log_name] ([effect.release_method], [effect.strength]).", effect.harmful ? LOG_ATTACK : LOG_GAME) + update_glow() + update_appearance() + SStgui.update_uis(src) + return TRUE + +/// Switches it off. `message` is shown to anyone watching; `quiet` skips sound and updates (deletion). +/obj/item/anomaly_utilizer/proc/switch_off(message, quiet = FALSE) + if(!emitting) + return + emitting = FALSE + STOP_PROCESSING(SSobj, src) + var/datum/artifact_effect/effect = loaded_effect() + effect?.deactivate() + hum?.stop() + if(quiet) + return + if(message) + visible_message(span_notice(message)) + playsound(src, 'sound/effects/stealthoff.ogg', 30, TRUE) + update_glow() + update_appearance() + SStgui.update_uis(src) + +/obj/item/anomaly_utilizer/process(seconds_per_tick) + var/datum/artifact_effect/effect = loaded_effect() + if(!emitting || !effect) + switch_off() + return PROCESS_KILL + if(is_damped()) + switch_off("[src] crackles and goes dark.") + return PROCESS_KILL + var/old_level = battery.charge_level() + switch(effect.release_method) + if(ARTIFACT_RELEASE_AURA) + battery.use_charge(ARTIFACT_UTILIZER_DRAIN * seconds_per_tick) + // The battery pays for a field that never rests. + effect.current_charge = effect.maximum_charges + if(ARTIFACT_RELEASE_PULSE) + battery.use_charge(ARTIFACT_UTILIZER_DRAIN * seconds_per_tick) + effect.current_charge = min(effect.maximum_charges, effect.current_charge + ARTIFACT_UTILIZER_PULSE_FEED * seconds_per_tick) + var/store_before = effect.current_charge + effect.wake(UTILIZER_WAKE_MARGIN) + effect.tick(seconds_per_tick) + if(QDELETED(src)) + return PROCESS_KILL + if(effect.release_method == ARTIFACT_RELEASE_PULSE && effect.current_charge < store_before) + burst_visuals(artifact_energy_kind(effect.energy_kind)) + if(battery.stored_charge <= 0) + switch_off("[src] sputters and goes dark.") + return PROCESS_KILL + if(battery.charge_level() != old_level) + update_appearance() + +// ===== Contact ===== + +/obj/item/anomaly_utilizer/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers) + if(!isliving(interacting_with)) + return NONE + var/datum/artifact_effect/effect = loaded_effect() + if(!emitting || effect?.release_method != ARTIFACT_RELEASE_TOUCH) + return NONE + return touch_with(interacting_with, user) + +/// Presses the prongs to `target`, letting the battery's contact effect act on them. +/obj/item/anomaly_utilizer/proc/touch_with(mob/living/target, mob/living/user) + var/datum/artifact_effect/effect = loaded_effect() + var/datum/artifact_energy_kind/kind = artifact_energy_kind(effect.energy_kind) + user.changeNext_move(CLICK_CD_MELEE) + user.do_attack_animation(target) + effect.set_responsible(user) + effect.current_charge = max(effect.current_charge, effect.touch_cost) + if(target == user) + user.visible_message( + span_warning("[user] presses [src] to [user.p_them()]self. Its prongs flare [anomaly_glow_word(kind.key)]."), + span_warning("You press [src] to yourself. Its prongs flare [anomaly_glow_word(kind.key)]."), + ) + else + user.visible_message( + span_warning("[user] presses [src] against [target]. Its prongs flare [anomaly_glow_word(kind.key)]."), + span_warning("You press [src] against [target]. Its prongs flare [anomaly_glow_word(kind.key)]."), + ignored_mobs = target, + ) + to_chat(target, span_userdanger("[user] presses [src] against you!")) + log_combat(user, target, "touched", src, "([effect.log_name])") + effect.touch(target) + battery?.use_charge(ARTIFACT_UTILIZER_TOUCH_COST) + burst_visuals(kind) + if(!battery || battery.stored_charge <= 0) + switch_off("[src] sputters and goes dark.") + else + update_appearance() + SStgui.update_uis(src) + return ITEM_INTERACT_SUCCESS + +// ===== Looks ===== + +/// The swell and flash of a burst or a contact. +/obj/item/anomaly_utilizer/proc/burst_visuals(datum/artifact_energy_kind/kind) + if(!kind) + return + playsound(src, kind.pulse_sound, 45, TRUE) + var/matrix/swell = matrix() + swell.Scale(1.2) + animate(src, transform = swell, time = 0.12 SECONDS, easing = SINE_EASING | EASE_OUT) + animate(transform = matrix(), time = 0.35 SECONDS, easing = SINE_EASING | EASE_IN) + var/mutable_appearance/flare = mutable_appearance(icon, "utilizer_tips") + flare.color = kind.color + var/atom/movable/flare_visual = flick_overlay_view(flare, 0.6 SECONDS) + if(flare_visual) + flare_visual.add_filter("flare_glow", 1, drop_shadow_filter(0, 0, 3, 0, "[kind.color]cc")) + animate(flare_visual, alpha = 0, time = 0.6 SECONDS, easing = SINE_EASING | EASE_IN) + +/// The breathing glow and light while it runs. +/obj/item/anomaly_utilizer/proc/update_glow() + var/datum/artifact_effect/effect = loaded_effect() + if(!emitting || !effect) + remove_filter("utilizer_glow") + set_light_on(FALSE) + return + var/datum/artifact_energy_kind/kind = artifact_energy_kind(effect.energy_kind) + add_filter("utilizer_glow", 2, drop_shadow_filter(0, 0, 1.5, 0, "[kind.color]40")) + transition_filter_chain("utilizer_glow", -1, \ + FilterChainStep(list("color" = "[kind.color]b0", "size" = 2), 0.8 SECONDS, SINE_EASING), \ + FilterChainStep(list("color" = "[kind.color]40", "size" = 1.5), 0.8 SECONDS, SINE_EASING)) + // A light or darkness effect lights its battery itself; the utilizer stays out of its way. + if(effect.light_override()) + set_light_on(FALSE) + return + set_light_color(kind.color) + set_light_on(TRUE) + +/obj/item/anomaly_utilizer/update_icon_state() + icon_state = battery ? "[base_icon_state][battery.charge_level()]" : base_icon_state + return ..() + +/obj/item/anomaly_utilizer/update_overlays() + . = ..() + if(!battery) + return + var/datum/artifact_energy_kind/kind = battery.lit_kind() + . += anomaly_core_overlays(src, "utilizer_core", kind, battery.charge_fraction()) + if(emitting && kind) + var/mutable_appearance/tips = mutable_appearance(icon, "utilizer_tips") + tips.color = kind.color + . += tips + . += emissive_appearance(icon, "utilizer_tips", src) + +/obj/item/anomaly_utilizer/examine(mob/user) + . = ..() + if(!battery) + . += "Its battery slot is empty." + return + . += "An exotic battery sits in its slot." + . += anomaly_core_description(battery.lit_kind(), battery.charge_fraction()) + if(emitting) + var/datum/artifact_energy_kind/kind = battery.held_kind() + . += span_notice("It hums, its prongs glowing [anomaly_glow_word(kind?.key)].") + +// ===== Window ===== + +/obj/item/anomaly_utilizer/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "AnomalyUtilizer", name) + ui.open() + +/obj/item/anomaly_utilizer/ui_data(mob/user) + var/list/data = list() + data["emitting"] = emitting + if(battery) + var/datum/artifact_effect/effect = loaded_effect() + var/datum/artifact_energy_kind/kind = battery.lit_kind() + var/mode + switch(effect?.release_method) + if(ARTIFACT_RELEASE_AURA) + mode = "field" + if(ARTIFACT_RELEASE_PULSE) + mode = "burst" + if(ARTIFACT_RELEASE_TOUCH) + mode = "contact" + data["cell"] = list( + "fill" = round(battery.charge_fraction(), 0.01), + "color" = kind?.color, + "serial" = battery.source_serial, + "mode" = kind ? mode : null, + ) + else + data["cell"] = null + return data + +/obj/item/anomaly_utilizer/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + var/mob/living/user = ui.user + switch(action) + if("power") + if(emitting) + switch_off("[src] winds down.") + else + switch_on(user) + return TRUE + if("eject") + eject_battery(user) + return TRUE + +/datum/design/anomaly_utilizer + name = "Exotic Utilizer" + desc = "A handheld emitter that runs whatever an exotic battery holds." + id = "xenoarch_utilizer" + build_type = PROTOLATHE | AWAY_LATHE + materials = list( + /datum/material/iron = SHEET_MATERIAL_AMOUNT * 2, + /datum/material/glass = SHEET_MATERIAL_AMOUNT, + /datum/material/gold = SHEET_MATERIAL_AMOUNT, + /datum/material/plasma = SHEET_MATERIAL_AMOUNT, + ) + build_path = /obj/item/anomaly_utilizer + category = list( + RND_CATEGORY_EQUIPMENT + RND_SUBCATEGORY_EQUIPMENT_SCIENCE + ) + departmental_flags = DEPARTMENT_BITFLAG_SCIENCE + +#undef UTILIZER_WAKE_MARGIN From 48a190292f221003b87f974e4c6538cda80de298 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sat, 7 Nov 2026 22:02:20 -0800 Subject: [PATCH 11/20] Add the artifact analyser, scan pad, labeler and xenoarch research The analyser reads a large find standing on its scan pad and prints a stamped report with the find's serial, condition and one line per emission. Its tgui bench shows a phosphor scope that follows the find live, engraved plates for the last reading, and a paper tape of every stimulus the pad sensed while the crew tested it, which can be torn off. A scan takes the find's lock and releases it on finish, halt, power loss, panel open, the find leaving the pad, and Destroy. The first full analysis of a dug find pays research once, as research notes, and records artifact_analysed. The strange object pays once per techweb in the destructive analyzer. The specimen labeler prints the tag a crew presses onto a find, from fixed word lists, and peels it off again. Tagging is logged. Three research nodes on the tier ladder: Xenoarchaeology, Advanced Excavation and Exotic Particles. They list the dig, use and trade designs by id. --- .../interfaces/XenoarchAnalyser.tsx | 544 ++++++++++++++++ .../interfaces/XenoarchLabeler.tsx | 206 ++++++ .../unit_tests/voidcrew_xenoarch_study.dm | 204 ++++++ voidcrew/modules/xenoarch/icons/study.dmi | Bin 0 -> 7887 bytes voidcrew/modules/xenoarch/study/analyser.dm | 586 +++++++++++++++++- voidcrew/modules/xenoarch/study/labeler.dm | 186 +++++- voidcrew/modules/xenoarch/study/research.dm | 62 +- voidcrew/modules/xenoarch/study/scanpad.dm | 179 +++++- voidcrew/modules/xenoarch/study/techweb.dm | 87 ++- 9 files changed, 2049 insertions(+), 5 deletions(-) create mode 100644 tgui/packages/voidcrew_tgui/interfaces/XenoarchAnalyser.tsx create mode 100644 tgui/packages/voidcrew_tgui/interfaces/XenoarchLabeler.tsx create mode 100644 voidcrew/modules/xenoarch/icons/study.dmi diff --git a/tgui/packages/voidcrew_tgui/interfaces/XenoarchAnalyser.tsx b/tgui/packages/voidcrew_tgui/interfaces/XenoarchAnalyser.tsx new file mode 100644 index 00000000000..423624f9b9f --- /dev/null +++ b/tgui/packages/voidcrew_tgui/interfaces/XenoarchAnalyser.tsx @@ -0,0 +1,544 @@ +/** + * The artifact analyser's bench: a phosphor scope that follows the find on the + * scan pad, two engraved plates for the last reading, and the paper tape the + * pad prints while the crew tests the find. + * + * Before a scan the scope shows one green trace for the find as a whole. Once a + * find has been read, each emission gets its own trace in its own colour, and + * the trace's shape follows how it releases. Nothing here explains a rule; it + * only shows what the instrument picks up. + */ +import { type ReactNode, useEffect, useRef } from 'react'; +import { Box, Button, Stack } from 'tgui-core/components'; +import type { BooleanLike } from 'tgui-core/react'; + +import { useBackend } from '../../tgui/backend'; +import { Window } from '../../tgui/layouts'; + +type Channel = { + channel: string; + kind: string; + kind_key: string; + release: string; + release_key: string; + family: string; + awake: BooleanLike; + resting: BooleanLike; +}; + +type Reading = { + serial: string; + name: string; + damaged: BooleanLike; + current: BooleanLike; + channels: Channel[]; +}; + +type Specimen = { + serial: string; + name: string; + awake: BooleanLike; + resting: BooleanLike; + label: string | null; +}; + +type TapeLine = { + time: string; + text: string; + tone: 'note' | 'response' | 'quiet' | 'fault'; + count: number; +}; + +type Data = { + powered: BooleanLike; + pad: 'none' | 'offline' | 'ready'; + scanning: BooleanLike; + progress: number; + specimen: Specimen | null; + reading: Reading | null; + tape: TapeLine[]; + kind_colors: Record ; +}; + +const SCOPE_W = 360; +const SCOPE_H = 190; +const PHOSPHOR = '#7dffa0'; +const SCAN_VIOLET = '#c48cff'; + +/** 0 dormant, 1 resting between runs, 2 awake. */ +const activity = (awake: BooleanLike, resting: BooleanLike) => + awake ? (resting ? 1 : 2) : 0; + +/** + * A trace two screens wide, so scrolling it left by one screen loops cleanly. + * Fields roll, bursts spike, contact emissions blip now and then, and anything + * dormant is just grain. + */ +const wavePath = (shape: string, amp: number, mid: number, seed: number) => { + const period = shape === 'pulse' ? 90 : shape === 'touch' ? 120 : 60; + const points: string[] = []; + for (let x = 0; x <= SCOPE_W * 2; x += 3) { + const t = (x % period) / period; + let y = 0; + if (shape === 'aura') { + y = Math.sin(t * Math.PI * 2); + } else if (shape === 'pulse') { + if (t < 0.08) { + y = Math.sin((t / 0.08) * Math.PI) * 1.4; + } else if (t < 0.16) { + y = -Math.sin(((t - 0.08) / 0.08) * Math.PI) * 0.4; + } + } else if (shape === 'touch' && t > 0.45 && t < 0.55) { + y = Math.sin(((t - 0.45) / 0.1) * Math.PI); + } + const grain = Math.sin(x * 12.9898 + seed) * 43758.5453; + y += (grain - Math.floor(grain) - 0.5) * 0.18; + points.push(`${x},${(mid - y * amp).toFixed(1)}`); + } + return `M${points.join(' L')}`; +}; + +const Trace = (props: { + shape: string; + level: number; + mid: number; + color: string; + seed: number; +}) => { + const { shape, level, mid, color, seed } = props; + const amp = level === 2 ? 34 : level === 1 ? 14 : 3; + return ( + + + ); +}; + +const scopeMessage = (data: Data) => { + if (data.pad === 'none') { + return 'NO PAD'; + } + if (data.pad === 'offline') { + return 'PAD OFFLINE'; + } + if (!data.specimen) { + return 'PAD CLEAR'; + } + return ''; +}; + +const Scope = (props: { data: Data }) => { + const { data } = props; + const { powered, scanning, progress, specimen, reading, kind_colors } = data; + const channels = reading?.current ? reading.channels : null; + const lines: ReactNode[] = []; + if (powered) { + for (let x = 0; x <= SCOPE_W; x += 36) { + lines.push( ++ + , + ); + } + for (let y = 0; y <= SCOPE_H; y += 38) { + lines.push( + , + ); + } + } + const midFor = (index: number, count: number) => + count > 1 ? (index ? 140 : 58) : SCOPE_H / 2; + const message = powered ? scopeMessage(data) : ''; + const sweepX = (SCOPE_W * progress) / 100; + return ( + + + + ); +}; + +/** The specimen's paper card on the bench. */ +const Nameplate = (props: { data: Data }) => { + const { powered, specimen, reading } = props.data; + const shown = powered ? specimen : null; + return ( ++ + ); +}; + +/** An engraved plate holding one emission's reading. */ +const Plate = (props: { + label: string; + channel?: Channel; + color?: string; + empty: string; +}) => { + const { label, channel, color, empty } = props; + return ( ++ {shown ? shown.serial : '- - - -'} + +{shown ? shown.name : ''} + {!!shown && !!reading?.current && !!reading.damaged && ( +fractured + )} + {!!shown?.label && ( ++ Tag: {shown.label} + + )} ++ + ); +}; + +const INK: Record+ {label} + + {channel ? ( + <> +{channel.kind} +{channel.release} +{channel.family} + > + ) : ( +{empty} + )} += { + note: '#3b3a36', + response: '#9b1d1d', + quiet: '#8d8a80', + fault: '#a8561b', +}; + +/** The tape the pad prints on, newest line at the bottom. */ +const Tape = (props: { tape: TapeLine[] }) => { + const { tape } = props; + const roll = useRef (null); + const last = tape[tape.length - 1]; + useEffect(() => { + if (roll.current) { + roll.current.scrollTop = roll.current.scrollHeight; + } + }, [tape.length, last?.text, last?.count]); + return ( + + {tape.map((line, i) => ( ++ ); +}; + +/** A chunky bench key. */ +const Key = (props: { + label: string; + icon?: string; + color: string; + disabled: boolean; + height?: string; + onClick: () => void; +}) => { + const { label, icon, color, disabled, onClick } = props; + const height = props.height ?? '44px'; + return ( + + ); +}; + +export const XenoarchAnalyser = () => { + const { act, data } = useBackend(); + const { powered, pad, scanning, specimen, reading, tape, kind_colors } = data; + const channels = reading?.current ? reading.channels : []; + const read = !!powered && !!reading?.current; + const canScan = !!powered && pad === 'ready' && !!specimen && !scanning; + return ( ++ {line.time} + {' '} + {line.text} + {line.count > 1 ? ` x${line.count}` : ''} ++ ))} ++ + ); +}; diff --git a/tgui/packages/voidcrew_tgui/interfaces/XenoarchLabeler.tsx b/tgui/packages/voidcrew_tgui/interfaces/XenoarchLabeler.tsx new file mode 100644 index 00000000000..f84071aebed --- /dev/null +++ b/tgui/packages/voidcrew_tgui/interfaces/XenoarchLabeler.tsx @@ -0,0 +1,206 @@ +/** + * The specimen labeler: the tag it will print, stamped in purple ink on manila + * card, over the words it knows for each line. Click a line on the tag or a + * tab to choose which line to set, then click a word. + */ +import { useState } from 'react'; +import { Box, Button, Stack } from 'tgui-core/components'; + +import { useBackend } from '../../tgui/backend'; +import { Window } from '../../tgui/layouts'; + +type Field = 'effect' | 'trigger' | 'second'; + +type Data = { + effect: string | null; + trigger: string | null; + second: string | null; + effects: string[]; + triggers: string[]; + none: string; +}; + +const FIELDS: { key: Field; title: string }[] = [ + { key: 'effect', title: 'Effect' }, + { key: 'trigger', title: 'Trigger' }, + { key: 'second', title: 'Second' }, +]; + +const INK = '#5b2a86'; + +/** A manila tag on a string, its three lines stamped in purple. */ +const Tag = (props: { + data: Data; + field: Field; + onField: (field: Field) => void; +}) => { + const { data, field, onField } = props; + return ( ++ ++ ++ ++ ++ ++ + ++ ++ ++ + + +act('scan')} + /> + + +act('halt')} + /> + + ++ ++ ++ + ++ + ++ ++ ++ + ++ ++ + +act('tear')} + /> + + + {FIELDS.map((line) => { + const word = data[line.key]; + return ( ++ ); +}; + +export const XenoarchLabeler = () => { + const { act, data } = useBackend(); + const [field, setField] = useStateonField(line.key)} + style={{ + cursor: 'pointer', + display: 'flex', + alignItems: 'baseline', + padding: '2px 4px', + borderBottom: '1px solid #a88a54', + background: field === line.key ? '#ffffff38' : undefined, + }} + > + + {line.title}: + + + {word ?? '...'} + ++ ); + })} +('effect'); + let words = data.effects; + if (field === 'trigger') { + words = data.triggers; + } else if (field === 'second') { + words = [data.none, ...data.effects]; + } + const chosen = data[field]; + const anySet = !!data.effect || !!data.trigger || !!data.second; + const pick = (word: string) => { + act('set', { field, word }); + // Move on to the next blank line, as a hand would. + const next = FIELDS.find((line) => line.key !== field && !data[line.key]); + if (next) { + setField(next.key); + } + }; + return ( + + + ); +}; diff --git a/voidcrew/modules/unit_tests/voidcrew_xenoarch_study.dm b/voidcrew/modules/unit_tests/voidcrew_xenoarch_study.dm index c4fdeca83f3..586a55130b6 100644 --- a/voidcrew/modules/unit_tests/voidcrew_xenoarch_study.dm +++ b/voidcrew/modules/unit_tests/voidcrew_xenoarch_study.dm @@ -1 +1,205 @@ // Xenoarchaeology tests: study. +// +// Test files compile before voidcrew/_DEFINES, so the values below are literals. They mirror +// voidcrew/_DEFINES/xenoarch.dm (see also the header of voidcrew_xenoarch_core.dm): +// bands (ZONE_*): green 1, yellow 2, red 3 +// tiers: common 1, uncommon 2, rare 3, extreme 4 +// triggers: touch 1, water 2, acid 4 +// research for a first analysis: 100 / 150 / 250 by band, x1.5 for rare or extreme + +/// A scan pad with an analyser beside it, ready for a find. +/datum/unit_test/voidcrew_xenoarch_study + abstract_type = /datum/unit_test/voidcrew_xenoarch_study + var/obj/machinery/artifact_scanpad/pad + var/obj/machinery/artifact_analyser/analyser + +/datum/unit_test/voidcrew_xenoarch_study/proc/build_bench() + pad = allocate(/obj/machinery/artifact_scanpad, run_loc_floor_bottom_left) + analyser = allocate(/obj/machinery/artifact_analyser, get_step(run_loc_floor_bottom_left, EAST)) + analyser.print_delay = 0 + analyser.find_pad() + +/// A yellow-band find with one known effect, standing on the pad. +/datum/unit_test/voidcrew_xenoarch_study/proc/place_find(band = 2) + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, pad.loc, band) + find.replace_effects(/datum/artifact_effect/heal, null, band) + return find + +/// Counts things of a type on a turf. +/datum/unit_test/voidcrew_xenoarch_study/proc/count_on(turf/where, path) + . = 0 + for(var/atom/movable/thing in where) + if(istype(thing, path)) + .++ + +/// The first full analysis of a dug find prints a report and pays research once, ever. +/datum/unit_test/voidcrew_xenoarch_study/research_once/Run() + build_bench() + TEST_ASSERT_EQUAL(analyser.pad, pad, "the analyser didn't find the pad beside it") + TEST_ASSERT_EQUAL(analyser.scan_time, 10 SECONDS, "stock parts should make a ten-second scan") + var/obj/machinery/artifact/find = place_find() + TEST_ASSERT_EQUAL(analyser.watched, find, "the analyser isn't watching the find on its pad") + var/turf/out = analyser.drop_location() + + TEST_ASSERT(analyser.start_scan(), "a scan didn't start") + TEST_ASSERT(find.is_being_used(), "the scan didn't lock the find") + analyser.finish_scan() + TEST_ASSERT(find.research_paid, "the first analysis didn't mark research paid") + TEST_ASSERT_NULL(find.locked_by, "finishing the scan didn't release the lock") + TEST_ASSERT_EQUAL(count_on(out, /obj/item/research_notes), 1, "the first analysis didn't print notes") + var/obj/item/research_notes/notes = locate() in out + TEST_ASSERT_EQUAL(notes.value, 150, "a yellow uncommon find pays 150") + + var/obj/item/paper/artifact_report/report = locate() in out + TEST_ASSERT_NOTNULL(report, "no report was printed") + var/text = report.get_raw_text() + TEST_ASSERT(findtext(text, find.serial), "the report doesn't name the serial") + TEST_ASSERT(findtext(text, find.main_effect.report_line()), "the report doesn't carry the report line") + TEST_ASSERT(findtext(report.name, find.serial), "the report isn't named for its find") + TEST_ASSERT_NOTNULL(analyser.reading, "the screen kept no reading") + + TEST_ASSERT(analyser.start_scan(), "a second scan didn't start") + analyser.finish_scan() + TEST_ASSERT_EQUAL(count_on(out, /obj/item/research_notes), 1, "a second analysis paid research again") + TEST_ASSERT_EQUAL(count_on(out, /obj/item/paper/artifact_report), 2, "a second analysis printed no report") + +/// A find that never came out of a dig site pays nothing, but still reads. +/datum/unit_test/voidcrew_xenoarch_study/undug_pays_nothing/Run() + build_bench() + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, pad.loc) + find.replace_effects(/datum/artifact_effect/heal, null, null) + TEST_ASSERT(!find.is_dug(), "a find made without a band was stamped") + TEST_ASSERT(analyser.start_scan(), "a scan didn't start") + analyser.finish_scan() + TEST_ASSERT(!find.research_paid, "an undug find was marked paid") + TEST_ASSERT_EQUAL(count_on(analyser.drop_location(), /obj/item/research_notes), 0, "an undug find paid research") + TEST_ASSERT_EQUAL(count_on(analyser.drop_location(), /obj/item/paper/artifact_report), 1, "an undug find printed no report") + TEST_ASSERT_EQUAL(xenoarch_claim_analysis(find, analyser, null), 0, "claiming an undug find paid") + +/// Halting, losing the find, losing power or deleting the analyser always lets go of the lock. +/datum/unit_test/voidcrew_xenoarch_study/lock_release/Run() + build_bench() + var/obj/machinery/artifact/find = place_find() + + TEST_ASSERT(analyser.start_scan(), "a scan didn't start") + analyser.abort_scan("Scan halted.") + TEST_ASSERT_NULL(find.locked_by, "halting didn't release the lock") + TEST_ASSERT(!pad.beam_on, "halting left the beam on") + + TEST_ASSERT(analyser.start_scan(), "a scan didn't restart after a halt") + find.forceMove(get_step(pad.loc, NORTH)) + TEST_ASSERT_NULL(analyser.scan_target, "moving the find off the pad didn't stop the scan") + TEST_ASSERT_NULL(find.locked_by, "moving the find off the pad didn't release the lock") + TEST_ASSERT_NULL(analyser.watched, "the analyser kept watching a find that left the pad") + TEST_ASSERT(!find.research_paid, "an aborted scan paid research") + + find.forceMove(pad.loc) + TEST_ASSERT_EQUAL(analyser.watched, find, "the analyser didn't notice the find coming back") + TEST_ASSERT(analyser.start_scan(), "a scan didn't start on the returned find") + analyser.set_is_operational(FALSE) + TEST_ASSERT_NULL(find.locked_by, "losing power didn't release the lock") + analyser.set_is_operational(TRUE) + + TEST_ASSERT(analyser.start_scan(), "a scan didn't start after power came back") + qdel(analyser) + TEST_ASSERT_NULL(find.locked_by, "deleting the analyser mid-scan didn't release the lock") + TEST_ASSERT(!pad.beam_on, "deleting the analyser left the beam on") + +/// A find another machine holds can't be scanned until it lets go. +/datum/unit_test/voidcrew_xenoarch_study/lock_respected/Run() + build_bench() + var/obj/machinery/artifact/find = place_find() + var/obj/machinery/artifact_analyser/other = allocate(/obj/machinery/artifact_analyser, get_step(run_loc_floor_bottom_left, NORTHEAST)) + TEST_ASSERT(find.try_lock(other), "another machine couldn't take the lock") + TEST_ASSERT(!analyser.start_scan(), "a scan started on a find another machine holds") + find.release_lock(other) + TEST_ASSERT(analyser.start_scan(), "a scan didn't start once the other machine let go") + analyser.abort_scan() + +/// Deleting a find mid-scan stops the scan cleanly. +/datum/unit_test/voidcrew_xenoarch_study/find_deleted/Run() + build_bench() + var/obj/machinery/artifact/find = place_find() + TEST_ASSERT(analyser.start_scan(), "a scan didn't start") + qdel(find) + TEST_ASSERT_NULL(analyser.scan_target, "the scan outlived its find") + TEST_ASSERT_NULL(analyser.watched, "the analyser kept a deleted find") + TEST_ASSERT(!pad.beam_on, "the beam outlived the find") + +/// The tape records each stimulus and whether the find answered it. +/datum/unit_test/voidcrew_xenoarch_study/tape/Run() + build_bench() + var/obj/machinery/artifact/find = place_find() + find.main_effect.trigger = 2 // water + find.stimulate(4) // acid + find.stimulate(2) // water + var/list/texts = list() + for(var/list/line as anything in analyser.tape) + texts += line["text"] + TEST_ASSERT("Acid. No response." in texts, "the tape didn't record a stimulus that woke nothing") + TEST_ASSERT("Water. Response." in texts, "the tape didn't record a stimulus that woke the find") + var/before = length(analyser.tape) + find.stimulate(4) + find.stimulate(4) + TEST_ASSERT(length(analyser.tape) <= before + 1, "repeated stimuli each took a new line") + TEST_ASSERT(analyser.tear_tape(null), "the tape couldn't be torn off") + TEST_ASSERT(!length(analyser.tape), "tearing the tape left lines on it") + TEST_ASSERT_EQUAL(count_on(analyser.drop_location(), /obj/item/paper/artifact_tape), 1, "tearing the tape left no slip") + find.main_effect.deactivate(quiet = TRUE) + +/// The labeler takes only words from its lists, and a tag made from the right words reads as right. +/datum/unit_test/voidcrew_xenoarch_study/labeler/Run() + var/obj/item/artifact_labeler/labeler = allocate(/obj/item/artifact_labeler) + TEST_ASSERT_NULL(labeler.make_label(), "a blank labeler made a tag") + TEST_ASSERT(!labeler.set_word("effect", "Turns lead into gold"), "the labeler took a word it doesn't know") + TEST_ASSERT(!labeler.set_word("trigger", "Heals"), "the labeler took an effect word as a trigger") + TEST_ASSERT(!labeler.set_word("colour", "Heals"), "the labeler took a field it doesn't have") + var/obj/machinery/artifact/find = allocate(/obj/machinery/artifact, run_loc_floor_bottom_left, 1) + find.replace_effects(/datum/artifact_effect/heal, null, 1) + TEST_ASSERT(labeler.set_word("effect", "Heals"), "the labeler refused an effect word") + TEST_ASSERT(labeler.set_word("trigger", artifact_trigger_name(find.main_effect.trigger)), "the labeler refused a trigger word") + TEST_ASSERT_NULL(labeler.make_label(), "a labeler with a blank line made a tag") + TEST_ASSERT(labeler.set_word("second", "None"), "the labeler refused None for the second line") + var/datum/artifact_label/tag = labeler.make_label() + TEST_ASSERT_NOTNULL(tag, "a full labeler made no tag") + find.apply_label(tag) + TEST_ASSERT_EQUAL(find.label_accuracy(), 1, "a tag with every word right didn't read as right") + TEST_ASSERT(labeler.set_word("second", "Light"), "the labeler refused an effect word for the second line") + find.apply_label(labeler.make_label()) + TEST_ASSERT_EQUAL(find.label_accuracy(), 0.8, "a wrong second line should cost a fifth") + +/// The three research nodes sit on the price ladder and unlock every study design. +/datum/unit_test/voidcrew_xenoarch_study_nodes/Run() + var/list/expected = list( + "xenoarchaeology" = list(40, list("xenoarch_analyser", "xenoarch_scanpad", "xenoarch_labeler")), + "xenoarch_excavation" = list(80, list()), + "xenoarch_exotic_particles" = list(120, list()), + ) + for(var/node_id in expected) + var/datum/techweb_node/node = SSresearch.techweb_node_by_id(node_id) + TEST_ASSERT(node && node.id == node_id, "research node [node_id] is missing") + var/list/costs = node.research_costs + TEST_ASSERT_EQUAL(costs[TECHWEB_POINT_TYPE_GENERIC], expected[node_id][1], "[node_id] is off the price ladder") + for(var/design_id in expected[node_id][2]) + TEST_ASSERT_NOTNULL(SSresearch.techweb_designs[design_id], "design [design_id] is missing") + TEST_ASSERT(design_id in node.design_ids, "[node_id] doesn't unlock [design_id]") + var/datum/design/board/analyser_board = SSresearch.techweb_designs["xenoarch_analyser"] + TEST_ASSERT_EQUAL(analyser_board.build_path, /obj/item/circuitboard/machine/artifact_analyser, "the analyser design prints the wrong board") + var/list/curio_points = SSresearch.techweb_point_items[/obj/item/relic] + TEST_ASSERT_EQUAL(curio_points?[TECHWEB_POINT_TYPE_GENERIC], 60, "the strange object pays no research in the destructive analyzer") + +/** + * Every design the xenoarchaeology nodes list exists. The dig, use and trade parts define most of + * them, so this only passes once all the parts are together; a failure names the id to rename. + */ +/datum/unit_test/voidcrew_xenoarch_study_node_designs/Run() + var/list/expected = list( + "xenoarchaeology" = list("xenoarch_analyser", "xenoarch_scanpad", "xenoarch_labeler", "xenoarch_stabiliser", "xenoarch_spectrometer", "xenoarch_specimen_crate"), + "xenoarch_excavation" = list("xenoarch_scanner_advanced", "xenoarch_brush_quick"), + "xenoarch_exotic_particles" = list("xenoarch_harvester", "xenoarch_battery", "xenoarch_utilizer"), + ) + for(var/node_id in expected) + var/datum/techweb_node/node = SSresearch.techweb_node_by_id(node_id) + for(var/design_id in expected[node_id]) + TEST_ASSERT_NOTNULL(SSresearch.techweb_designs[design_id], "[node_id] lists design [design_id], which no part defines") + TEST_ASSERT(design_id in node?.design_ids, "[node_id] lost design [design_id]") diff --git a/voidcrew/modules/xenoarch/icons/study.dmi b/voidcrew/modules/xenoarch/icons/study.dmi new file mode 100644 index 0000000000000000000000000000000000000000..93bb8673886716e17fc6d2cdfd75950db68900e5 GIT binary patch literal 7887 zcmd6Mc|4Te`~Phh2?-&FB4sUW_CZ3nR477a%PvG>%t$3IsO;O=_kB&4u@seM?2M%; zVleixWX8<=#(19JXZb$=eE<8->oqg?eeSu=xz0J)`+C2xGm+O!_1ReXSpWcFGc>q- z9RO&A58lj-005i_FN0COww~O)<$u}9&%xK#$KTc43jiLcmVPi|X}`b$9_u}?Gkvvk z;;DdgmI3b*2ELUVwmd__r!y-i#Qvw}ue<{%9`Po9;Iu7MMn#p?@u_4F8nb-LFjNp} zdp?&}_1)v@Q+ ++ ++ ++ + ++ {FIELDS.map((tab) => ( + ++ + + ))} ++ ++ {words.map((word) => ( + pick(word)} + style={{ + display: 'inline-block', + cursor: 'pointer', + margin: '3px', + padding: '3px 8px', + borderRadius: '2px', + fontFamily: 'monospace', + fontSize: '12px', + background: word === chosen ? INK : '#e9e1cd', + color: word === chosen ? '#fff' : '#3a3631', + boxShadow: '0 1px 0 #0006', + }} + > + {word} + + ))} + ++ ++ ++ + +eSX7gIbQf8*Ou^Co V-Y(@tTf)`?1BhcOjA$781JFO|`sNh#aEHpN7 9`JCVGR*BST_7on~;0+uCy!nRUKna z1rd&>yZ{f}{S!)ovnL%cD8*d*W9icK7!!q=>q%1a>+~aOIrgS?Yhbi6Nf>p%`JN;{ ziBF$CF$2KOyY$4n1T?Ycgx=lV6gA1LoCwWjc5=5Dv3T8`=HiA)%A~8K<1K^z76Sjm zdS-b071+UZcceeD_{4WU0Jsm(Fat3^G&7c#_^Z#0(HaSGFLaRB5ifd1wa`Fp_gn#C z%UtAPu#own4rnKW>{L(MW6VGjp1gbj$)QX9cIK)z_4g&Ch*p~lz1KMZrQZ)lHrRSg zbrv(&2_59E0%#b`*O||eN#PIhzd+`@5r||QYNEcNL6Lvw@r_bw^(W2YHK%y{+LnY~ zi^WMI4IbA`3Zr@8JJXrk)2tbs`&P$#>w_t_CtP`5G!q#tWw;nD$iC&B^Me$peMa~; z*PFJi)NRaEz5Zo2OY3(7v93eBG iEy {l26ejD0H z%#b|YE%}CXumHrcfP@lW*MMh7y=T_9bGFjpdfN?5r(fNnnW4v5Xzj}eZ%3;EDr)fe zj0d-CR!POsOlz=ta;AADHlmp~%Eq3dKZ2Mdw*Z}r{$*oreIDQH^>7)#EPv+Ptl^El zOm>3H7cwnfKNu=I=Z<|Q=i-`83mFHItP)Uoi~y|81M==BwIN{z@A9}AJQ}=XT%vQ& z?p64~PN`+<5#^iggkR5U99O&dLp+SSeIr>Uh8>#7mY2?)wZfFqe?d{D&~%!GiE#_R zM&FSM1E#xkXOfRm{cqex)-%*NZ?jmB#$ i0x|AXeJw#;NoyQrK%9CiVk= z61x3~eu6K@Q9-S#Uo_#!8<`bhPd){ItnX9sK&OkdQ-{gXBjN;)Xeiq1@%HVS8`%i# zjwZcWc}?|yEMXDPJAOptX3xO2jZ?ufoek1vT!+!*msAS9a@>LD^4ZQ8)LDJl!@G!H z Te-{;lSm5D atCEP`fs1Wm@u|K^=!K?J*5@tlT$+V7`Bh7xb5aeu!8T&jitzhu#H}Q$JqJ zhxN5Tkw&>ugPiy@-3EARgD&qej71w>17b?oES)idRo!d6fFo9UdIV=9qf&@lb7B%A ze$U{HDLLYNWMa%QFf>3YR-^RmgYOl1FYK4DLgZ0*B5HS &&x1%mR~ED^rE zX=CHk@S#5t7cRQp2wBoSjt|`ydDG$!+&_}c(mVB3dmwR+yOa4eJ~WCWqQwA+DMWGs zj!QUtAPKKd1J2VlqcovEb5hy}ikI6L{Max1I}7E}c4|*-b BlZ4?mC27q>CwpU+%{pULhyh6Mydo?u30C z_V%sR9VD&ok}H{nlRCKv%v6C(+aHbrUUT)J*B)w*