Files
Paradise/code/game/objects/items/devices/enginepicker.dm
warriorstar-orion 525c68d617 Attack chain, initial setup. (pull *immediately* for *any* TM issues) (#26834)
* refactor: Attack chain, initial setup.

* migrate curtain to make dreamchecker happy

* update thurible

* don't call attacked_by separately for legacy attack chain

* remove duplicate proc

* condense similar code, put allowances for legacy code in new procs

* update docs, include diagram source

* add comment on how to update diagram

* fix admonition

* mindflayer updates

* remove commented out code

* clarify all steps

* after_attack should be overridable

* whoops

* retrofit recent changes

* duh, can't restrict this yet because of tool_acts

* i hate ore bags with the fire of a thousand suns

* return correct value for object attack logic

* Various cleanups.

We don't want to attempt to pull stuff out of `/obj/item/attackby`,
because those pieces are part of the related objects' migrations, not
`/obj/item` itself. Attempting to do this causes knockon effects where
things expected to call e.g. `/obj/item/storage/attackby` in the call
chain were not ferried over to the new item interaction code, because
the related objects hadn't actually been migrated over yet.

I've used refactoring /obj/vehicle as the example for migrating
`attackby` methods instead.

* simplify some argument names

* fuck it

* make it do the thing

* Rename CI module call

* Prove that CI works

* improve test output

* aaand fix it again

* fix curtain tool interactions

* fix compile error

* fix compile error

* Better docs, introduce migration plan tool.
2024-12-02 23:36:36 +00:00

99 lines
3.4 KiB
Plaintext

/*
//////////
Item meant to spawn one of the three (Tesla / Singularity / Supermatter) engines on-station at round-start.
Should be found in the CE's office. Not access-restricted.
//////////
*/
/obj/item/enginepicker
name = "Bluespace Engine Delivery Device"
desc = "A per-station bluespace-based delivery system for a unique engine Engineering Department's choice. Only one option can be chosen. Device self-destructs on use."
icon = 'icons/obj/device.dmi'
icon_state = "enginepicker"
var/list/list_enginebeacons = list()
var/isactive = FALSE
/obj/item/enginepicker/Destroy()
list_enginebeacons.Cut()
return ..()
/obj/item/enginepicker/attack_self__legacy__attackchain(mob/living/carbon/user)
if(user.incapacitated())
return
if(!isactive)
isactive = TRUE //Self-attack spam exploit prevention
else
return
locatebeacons()
var/E = tgui_input_list(user, "Select the station's Engine", "[src]", list_enginebeacons)
if(E)
processchoice(E, user)
else
isactive = FALSE
return
//This proc re-assigns all of engine beacons in the global list to a local list.
/obj/item/enginepicker/proc/locatebeacons()
LAZYCLEARLIST(list_enginebeacons)
for(var/obj/item/beacon/engine/B in GLOB.engine_beacon_list)
if(B && !QDELETED(B)) //This ensures that the input pop-up won't have any qdeleted beacons
list_enginebeacons += B
//Spawns and logs / announces the appropriate engine based on the choice made
/obj/item/enginepicker/proc/processchoice(obj/item/beacon/engine/choice, mob/living/carbon/user)
var/issuccessful = FALSE //Check for a successful choice
var/engtype //Engine type
var/G //Generator that will be spawned
var/turf/T = get_turf(choice)
if(length(choice.enginetype) > 1) //If the beacon has multiple engine types
var/E = tgui_input_list(user, "You have selected a combined beacon, which option would you prefer?", "[src]", choice.enginetype)
if(E)
engtype = E
issuccessful = TRUE
else
isactive = FALSE
return
if(!engtype) //If it has only one type
engtype = DEFAULTPICK(choice.enginetype, null) //This should(?) account for a possibly scrambled list with a single entry
switch(engtype)
if(ENGTYPE_TESLA)
G = /obj/machinery/the_singularitygen/tesla
if(ENGTYPE_SING)
G = /obj/machinery/the_singularitygen
if(G) //This can only be not-null if the switch operation was successful
issuccessful = TRUE
if(issuccessful)
clearturf(T) //qdels all items / gibs all mobs on the turf. Let's not have an SM shard spawn on top of a poor sod.
new G(T) //Spawns the switch-selected engine on the chosen beacon's turf
var/ailist[] = list()
for(var/mob/living/silicon/ai/A in GLOB.alive_mob_list)
ailist += A
if(length(ailist))
var/mob/living/silicon/ai/announcer = pick(ailist)
announcer.say(";Engine delivery detected. Type: [engtype].") //Let's announce the terrible choice to everyone
visible_message("<span class='notice'>\The [src] begins to violently vibrate and hiss, then promptly disintegrates!</span>")
qdel(src) //Self-destructs to prevent crew from spawning multiple engines.
else
visible_message("<span class='notice'>\The [src] buzzes! No beacon found or selected!</span>")
isactive = FALSE
return
//Deletes objects and mobs from the beacon's turf.
/obj/item/enginepicker/proc/clearturf(turf/T)
for(var/obj/item/I in T)
I.visible_message("\The [I] gets crushed to dust!")
qdel(I)
for(var/mob/living/M in T)
M.visible_message("\The [M] gets obliterated!")
M.gib()