Files
Polaris/code/game/objects/structures/ghost_pods/ghost_pods.dm
MistakeNot4892 b22a0568a3 Sideports a couple of init unit tests from Neb. (#7893)
* Sideports a couple of init unit tests from Neb.

* Trying to unfuck initialize logic.

* Removing del()s.

* Adjusting return values to Initialize().

* Moving some dangerous object logic from obj onto the two types that use it.

* Rolling back some init changes and commenting out initialized atom unit test.

* this comment formatting is a minor war crime

* Removed sleep() from signaler circuit Initialize().

* Additional Init fixes post-rebase.

* Uncomments subsystem test since that's passing.
2021-02-21 12:03:34 -09:00

91 lines
3.4 KiB
Plaintext

// These are used to spawn a specific mob when triggered, with the mob controlled by a player pulled from the ghost pool, hense its name.
/obj/structure/ghost_pod
name = "Base Ghost Pod"
desc = "If you can read me, someone don goofed."
icon = 'icons/obj/structures.dmi'
var/ghost_query_type = null
var/icon_state_opened = null // Icon to switch to when 'used'.
var/used = FALSE
var/busy = FALSE // Don't spam ghosts by spamclicking.
var/needscharger //For drone pods that want their pod to turn into a charger.
// Call this to get a ghost volunteer.
/obj/structure/ghost_pod/proc/trigger(var/alert, var/adminalert)
if(!ghost_query_type)
return FALSE
if(busy)
return FALSE
visible_message(alert)
log_and_message_admins(adminalert)
busy = TRUE
var/datum/ghost_query/Q = new ghost_query_type()
var/list/winner = Q.query()
busy = FALSE
if(winner.len)
var/mob/observer/dead/D = winner[1]
create_occupant(D)
icon_state = icon_state_opened
if(needscharger)
new /obj/machinery/recharge_station/ghost_pod_recharger(src.loc)
qdel(src)
return TRUE
else
return FALSE
// Override this to create whatever mob you need. Be sure to call ..() if you don't want it to make infinite mobs.
/obj/structure/ghost_pod/proc/create_occupant(var/mob/M)
used = TRUE
return TRUE
// This type is triggered manually by a player discovering the pod and deciding to open it.
/obj/structure/ghost_pod/manual
var/confirm_before_open = FALSE // Recommended to be TRUE if the pod contains a surprise.
/obj/structure/ghost_pod/manual/attack_hand(var/mob/living/user)
if(!used)
if(confirm_before_open)
if(alert(user, "Are you sure you want to touch \the [src]?", "Confirm", "No", "Yes") == "No")
return
trigger()
/obj/structure/ghost_pod/manual/attack_ai(var/mob/living/silicon/user)
if(Adjacent(user))
attack_hand(user) // Borgs can open pods.
// This type is triggered on a timer, as opposed to needing another player to 'open' the pod. Good for away missions.
/obj/structure/ghost_pod/automatic
var/delay_to_self_open = 10 MINUTES // How long to wait for first attempt. Note that the timer by default starts when the pod is created.
var/delay_to_try_again = 20 MINUTES // How long to wait if first attempt fails. Set to 0 to never try again.
/obj/structure/ghost_pod/automatic/Initialize()
. = ..()
addtimer(CALLBACK(src, .proc/trigger), delay_to_self_open)
/obj/structure/ghost_pod/automatic/trigger()
. = ..()
if(. == FALSE) // If we failed to get a volunteer, try again later if allowed to.
if(delay_to_try_again)
addtimer(CALLBACK(src, .proc/trigger), delay_to_try_again)
// This type is triggered by a ghost clicking on it, as opposed to a living player. A ghost query type isn't needed.
/obj/structure/ghost_pod/ghost_activated
description_info = "A ghost can click on this to return to the round as whatever is contained inside this object."
/obj/structure/ghost_pod/ghost_activated/attack_ghost(var/mob/observer/dead/user)
if(used)
to_chat(user, "<span class='warning'>Another spirit appears to have gotten to \the [src] before you. Sorry.</span>")
return
var/choice = input(user, "Are you certain you wish to activate this pod?", "Control Pod") as null|anything in list("Yes", "No")
if(!choice || choice == "No")
return
else if(used)
to_chat(user, "<span class='warning'>Another spirit appears to have gotten to \the [src] before you. Sorry.</span>")
return
create_occupant(user)