Files
Bubberstation/code/modules/paperwork/ticketmachine.dm
Useroth cca7f8ee4c Some missed mirrors (#13415)
* Refactors firestacks into status effects (#66573)

This PR refactors firestacks into two status effects: fire_stacks, which behave like normal firestacks you have right now, and wet_stacks, which are your negative fire stacks right now. This allows for custom fires with custom behaviors and icons to be made.

Some fire related is moved away from species(what the fuck was it even doing there) into these as well.
Oh and I fixed the bug where monkeys on fire had a human fire overlay, why wasn't this fixed already, it's like ancient.

Also changed some related proc names to be snake_case like everything should be.

This allows for custom fire types with custom behaviours, like freezing freon fire or radioactive tritium fire. Removing vars from living and moving them to status effects for modularity is also good.
Nothing to argue about since there's nothing player-facing

* Hud Image Culling By Z Level: Theft edition (#65189)

* makes hud images only apply by z level

* makes some of the atom_hud procs have better names

* fixes warning with the hud_user list and adds better documentation

* better docs for hud_images

* removes TODOs

* docs for hud_list

* adds support for linked z levels so mobs can see lower ones

* fixes merge conflict and shittily makes only shocked airlocks get added

* adds support for setting images in the hud as active and inactive

* gets rid of unatomic spatial grid change

* maybe i should actually try COMPILING my changes

* fixes merge skew and makes it compile again

* fixes huds refusing to remove from users who changed z level

* improves z level and registration logic

* fixes antag huds not appearing

* Fixes antag huds not properly setting. We now use hud_list in init, so it needs to be set before the new call, not after. Not sure why the use of appearance key was split like this, but none else knows either so none can stop me

* Ensures that hiding a basic appearance also hides the atom's active list too

* Fixes antag huds going poof

Ensures that remove_atom_from_hud will return false if the passed atom
isn't managed by it

This fixes antag huds disappearing randomly, since they assumed that if
the parent call of remove_atom_from_hud returned true, we should delete
ourselves. This is a safe assumption for them to make, since they should
only ever have one atom.

Does kinda bork if we call remove_atom_from_hud in a way that is unsure
if the passed atom is actually in that list. We were forced into doing
this by how atom huds use the qdeleting signal.

* makes basic alternate_appearance's only update themselves when setting their hud image to active and makes them not add themselves to the global huds_by_category list

* fixes mistake with hud_users list being set non associatively (bad)

* as anything in bot path loops

* Fixes merge skew problems

* Makes bot paths non global

This way they can show themselves to only the bot that "owns" them, ya
feel me?

* Fixes huds not showing up sometimes, cleans up some code

Post Kapu's limb refactor, we were calling prepare_huds twice in a human
init call chain. What was happening was this:

call prepare_huds() // Human
I gained a new hud image
I set active hud icons to mirror it
call prepare_huds() // Living
I overwrote the new hud image
I attempted to set active hud icons, which failed because it assumes
this can never happen

*cries*

* Renames add_hud_to_atom to show_to

My hope is this will make understanding hud code a bit easier, by tying
the behavior to a "verb" more closely. Also renamed a few vars

* remove_hud_from_mob -> hide_from

* Nitpicks a few comments

* Whoops/fuck/shit/damn it all/hhhhhhhhhhhh

* Moves check down, improves stack trace a bit

Co-authored-by: KylerAce <kylerlumpkin1@gmail.com>

* small touch-up

* this should do it

Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: KylerAce <kylerlumpkin1@gmail.com>
2022-05-08 03:59:40 +01:00

246 lines
8.7 KiB
Plaintext

//Bureaucracy machine!
//Simply set this up in the hopline and you can serve people based on ticket numbers
/obj/machinery/ticket_machine
name = "ticket machine"
icon = 'icons/obj/bureaucracy.dmi'
icon_state = "ticketmachine"
base_icon_state = "ticketmachine"
desc = "A marvel of bureaucratic engineering encased in an efficient plastic shell. It can be refilled with a hand labeler refill roll and linked to buttons with a multitool."
density = FALSE
maptext_height = 26
maptext_width = 32
maptext_x = 7
maptext_y = 10
layer = HIGH_OBJ_LAYER
var/ticket_number = 0 //Increment the ticket number whenever the HOP presses his button
var/current_number = 0 //What ticket number are we currently serving?
var/max_number = 100 //At this point, you need to refill it.
var/cooldown = 50
var/ready = TRUE
var/id = "ticket_machine_default" //For buttons
var/list/ticket_holders = list()
var/list/obj/item/ticket_machine_ticket/tickets = list()
/obj/machinery/ticket_machine/Initialize(mapload)
. = ..()
update_appearance()
/obj/machinery/ticket_machine/Destroy()
for(var/obj/item/ticket_machine_ticket/ticket in tickets)
ticket.source = null
tickets.Cut()
return ..()
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
/obj/machinery/ticket_machine/multitool_act(mob/living/user, obj/item/I)
if(!multitool_check_buffer(user, I)) //make sure it has a data buffer
return
var/obj/item/multitool/M = I
M.buffer = src
to_chat(user, span_notice("You store linkage information in [I]'s buffer."))
return TRUE
/obj/machinery/ticket_machine/emag_act(mob/user) //Emag the ticket machine to dispense burning tickets, as well as randomize its number to destroy the HoP's mind.
if(obj_flags & EMAGGED)
return
to_chat(user, span_warning("You overload [src]'s bureaucratic logic circuitry to its MAXIMUM setting."))
ticket_number = rand(0,max_number)
current_number = ticket_number
obj_flags |= EMAGGED
if(tickets.len)
for(var/obj/item/ticket_machine_ticket/ticket in tickets)
ticket.audible_message(span_notice("\the [ticket] disperses!"))
qdel(ticket)
tickets.Cut()
update_appearance()
/obj/machinery/ticket_machine/proc/increment()
if(current_number > ticket_number)
return
if(current_number && !(obj_flags & EMAGGED) && tickets[current_number])
tickets[current_number].audible_message(span_notice("\the [tickets[current_number]] disperses!"))
qdel(tickets[current_number])
if(current_number < ticket_number)
current_number ++ //Increment the one we're serving.
playsound(src, 'sound/misc/announce_dig.ogg', 50, FALSE)
say("Now serving ticket #[current_number]!")
if(!(obj_flags & EMAGGED) && tickets[current_number])
tickets[current_number].audible_message(span_notice("\the [tickets[current_number]] vibrates!"))
update_appearance() //Update our icon here rather than when they take a ticket to show the current ticket number being served
/obj/machinery/button/ticket_machine
name = "increment ticket counter"
desc = "Use this button after you've served someone to tell the next person to come forward."
device_type = /obj/item/assembly/control/ticket_machine
req_access = list()
id = "ticket_machine_default"
/obj/machinery/button/ticket_machine/Initialize(mapload)
. = ..()
if(device)
var/obj/item/assembly/control/ticket_machine/ours = device
ours.id = id
/obj/machinery/button/ticket_machine/multitool_act(mob/living/user, obj/item/I)
. = ..()
if(I.tool_behaviour == TOOL_MULTITOOL)
var/obj/item/multitool/M = I
if(M.buffer && !istype(M.buffer, /obj/machinery/ticket_machine))
return
var/obj/item/assembly/control/ticket_machine/controller = device
controller.linked = WEAKREF(M.buffer)
id = null
controller.id = null
to_chat(user, span_warning("You've linked [src] to [M.buffer]."))
/obj/item/assembly/control/ticket_machine
name = "ticket machine controller"
desc = "A remote controller for the HoP's ticket machine."
var/datum/weakref/linked //To whom are we linked?
/obj/item/assembly/control/ticket_machine/Initialize(mapload)
..()
return INITIALIZE_HINT_LATELOAD
/obj/item/assembly/control/ticket_machine/LateInitialize()
find_machine()
/obj/item/assembly/control/ticket_machine/proc/find_machine() //Locate the one to which we're linked
for(var/obj/machinery/ticket_machine/ticketsplease in GLOB.machines)
if(ticketsplease.id == id)
linked = WEAKREF(ticketsplease)
if(linked)
return TRUE
else
return FALSE
/obj/item/assembly/control/ticket_machine/activate()
if(cooldown)
return
if(!linked)
return
var/obj/machinery/ticket_machine/machine = linked.resolve()
if(!machine)
return
cooldown = TRUE
machine.increment()
addtimer(VARSET_CALLBACK(src, cooldown, FALSE), 10)
/obj/machinery/ticket_machine/update_icon()
. = ..()
handle_maptext()
/obj/machinery/ticket_machine/update_icon_state()
switch(ticket_number) //Gives you an idea of how many tickets are left
if(0 to 49)
icon_state = "[base_icon_state]_100"
if(50 to 99)
icon_state = "[base_icon_state]_50"
if(100)
icon_state = "[base_icon_state]_0"
return ..()
/obj/machinery/ticket_machine/proc/handle_maptext()
switch(ticket_number) //This is here to handle maptext offsets so that the numbers align.
if(0 to 9)
maptext_x = 13
if(10 to 99)
maptext_x = 10
if(100)
maptext_x = 8
maptext = MAPTEXT(current_number) //Finally, apply the maptext
/obj/machinery/ticket_machine/attackby(obj/item/I, mob/user, params)
..()
if(istype(I, /obj/item/hand_labeler_refill))
if(!(ticket_number >= max_number))
to_chat(user, span_notice("[src] refuses [I]! There [max_number-ticket_number==1 ? "is" : "are"] still [max_number-ticket_number] ticket\s left!"))
return
to_chat(user, span_notice("You start to refill [src]'s ticket holder (doing this will reset its ticket count!)."))
if(do_after(user, 30, target = src))
to_chat(user, span_notice("You insert [I] into [src] as it whirs nondescriptly."))
qdel(I)
ticket_number = 0
current_number = 0
if(tickets.len)
for(var/obj/item/ticket_machine_ticket/ticket in tickets)
ticket.audible_message(span_notice("\the [ticket] disperses!"))
qdel(ticket)
tickets.Cut()
max_number = initial(max_number)
update_appearance()
return
/obj/machinery/ticket_machine/proc/reset_cooldown()
ready = TRUE
/obj/machinery/ticket_machine/attack_hand(mob/living/carbon/user, list/modifiers)
. = ..()
if(!ready)
to_chat(user,span_warning("You press the button, but nothing happens..."))
return
if(ticket_number >= max_number)
to_chat(user,span_warning("Ticket supply depleted, please refill this unit with a hand labeller refill cartridge!"))
return
var/user_ref = REF(user)
if((user_ref in ticket_holders) && !(obj_flags & EMAGGED))
to_chat(user, span_warning("You already have a ticket!"))
return
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 100, FALSE)
ticket_number++
to_chat(user, span_notice("You take a ticket from [src], looks like you're ticket number #[ticket_number]..."))
var/obj/item/ticket_machine_ticket/theirticket = new /obj/item/ticket_machine_ticket(get_turf(src))
theirticket.name = "Ticket #[ticket_number]"
theirticket.maptext = MAPTEXT(ticket_number)
theirticket.saved_maptext = MAPTEXT(ticket_number)
theirticket.source = src
theirticket.owner_ref = user_ref
user.put_in_hands(theirticket)
ticket_holders += user_ref
tickets += theirticket
if(obj_flags & EMAGGED) //Emag the machine to destroy the HOP's life.
ready = FALSE
addtimer(CALLBACK(src, .proc/reset_cooldown), cooldown)//Small cooldown to prevent piles of flaming tickets
theirticket.fire_act()
user.dropItemToGround(theirticket)
user.adjust_fire_stacks(1)
user.ignite_mob()
return
/obj/item/ticket_machine_ticket
name = "Ticket"
desc = "A ticket which shows your place in the Head of Personnel's line. Made from Nanotrasen patented NanoPaper®. Though solid, its form seems to shimmer slightly. Feels (and burns) just like the real thing."
icon = 'icons/obj/bureaucracy.dmi'
icon_state = "ticket"
maptext_x = 7
maptext_y = 10
w_class = WEIGHT_CLASS_TINY
resistance_flags = FLAMMABLE
max_integrity = 50
var/saved_maptext = null
var/owner_ref // A ref to our owner. Doesn't need to be weak because mobs have unique refs
var/obj/machinery/ticket_machine/source
/obj/item/ticket_machine_ticket/attack_hand(mob/user, list/modifiers)
. = ..()
maptext = saved_maptext //For some reason, storage code removes all maptext off objs, this stops its number from being wiped off when taken out of storage.
/obj/item/ticket_machine_ticket/attackby(obj/item/P, mob/living/carbon/human/user, params) //Stolen from papercode
if(burn_paper_product_attackby_check(P, user))
return
return ..()
/obj/item/paper/extinguish()
..()
update_appearance()
/obj/item/ticket_machine_ticket/Destroy()
if(source)
source.ticket_holders -= owner_ref
source.tickets -= src
source = null
return ..()