One HoP ticket per person, old tickets delete (#45813)

* One HoP ticket per person, old tickets deleted

* does a lot look at it

* Pleases Travis. Doesn't try to sell the nanite paper thing too hard, who cares if the stupes don't get it

* Update ticketmachine.dm

* it works fine now

* adds cooldown to emag_act
This commit is contained in:
cacogen
2019-08-17 03:14:26 +12:00
committed by moo
parent f21f5c4948
commit 1ca0f3aa9b
+59 -26
View File
@@ -13,11 +13,13 @@
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 customer are we currently serving?
var/max_number = 999 //To stop the text going fucky. At this point, you need to refill it.
var/cooldown = 50 //Small cooldown, stops the clown from immediately breaking it.
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/multitool_act(mob/living/user, obj/item/I)
if(!multitool_check_buffer(user, I)) //make sure it has a data buffer
@@ -27,12 +29,19 @@
to_chat(user, "<span class='notice'>You store linkage information in [I]'s buffer.</span>")
return TRUE
/obj/machinery/ticket_machine/emag_act(mob/user) //Emag the ticket machine to dispense burning tickets, as well as randomize its customer number to destroy the HOP's mind.
/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 class='warning'>You overload [src]'s bureaucratic logic circuitry to its MAXIMUM setting.</span>")
ticket_number = rand(0,999)
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.visible_message("<span class='notice'>\the [ticket] disperses!</span>")
qdel(ticket)
tickets.Cut()
update_icon()
/obj/machinery/ticket_machine/Initialize()
. = ..()
@@ -42,13 +51,18 @@
if(current_number >= ticket_number)
return
playsound(src, 'sound/misc/announce_dig.ogg', 50, 0)
say("Next customer, please!")
if(current_number && !(obj_flags & EMAGGED) && tickets[current_number])
tickets[current_number].visible_message("<span class='notice'>\the [tickets[current_number]] disperses!</span>")
qdel(tickets[current_number])
current_number ++ //Increment the one we're serving.
say("Now serving ticket #[current_number]!")
if(!(obj_flags & EMAGGED) && tickets[current_number])
tickets[current_number].visible_message("<span class='notice'>\the [tickets[current_number]] vibrates!</span>")
update_icon() //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 when you've served a customer to tell the next one to come forward."
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"
@@ -73,7 +87,7 @@
/obj/item/assembly/control/ticket_machine
name = "ticket machine controller"
desc = "A remote controller for the HOP's ticket machine."
desc = "A remote controller for the HoP's ticket machine."
var/obj/machinery/ticket_machine/linked //To whom are we linked?
/obj/item/assembly/control/ticket_machine/Initialize()
@@ -103,11 +117,11 @@
/obj/machinery/ticket_machine/update_icon()
switch(ticket_number) //Gives you an idea of how many tickets are left
if(0 to 200)
if(0 to 49)
icon_state = "ticketmachine_100"
if(201 to 800)
if(50 to 99)
icon_state = "ticketmachine_50"
if(801 to 999)
if(100)
icon_state = "ticketmachine_0"
handle_maptext()
@@ -117,30 +131,30 @@
maptext_x = 13
if(10 to 99)
maptext_x = 10
if(100 to 999)
if(100)
maptext_x = 8
maptext = "[current_number]" //Finally, apply the maptext
/obj/machinery/ticket_machine/attackby(obj/item/I, mob/user, params)
..()
if(ticket_number >= max_number)
to_chat(user, "<span class='notice'>[src] refuses [I]!, perhaps it's already full?.</span>")
return
if(istype(I, /obj/item/hand_labeler_refill))
if(!(ticket_number >= max_number))
to_chat(user, "<span class='notice'>[src] refuses [I]! There [max_number-ticket_number==1 ? "is" : "are"] still [max_number-ticket_number] ticket\s left!</span>")
return
to_chat(user, "<span class='notice'>You start to refill [src]'s ticket holder (doing this will reset its ticket count!).</span>")
if(do_after(user, 30, target = src))
to_chat(user, "<span class='notice'>You insert [I] into [src] as it whirrs nondescriptly.</span>")
to_chat(user, "<span class='notice'>You insert [I] into [src] as it whirs nondescriptly.</span>")
qdel(I)
ticket_number = 0
current_number = 0
if(tickets.len)
for(var/obj/item/ticket_machine_ticket/ticket in tickets)
ticket.visible_message("<span class='notice'>\the [ticket] disperses!</span>")
qdel(ticket)
tickets.Cut()
max_number = initial(max_number)
update_icon()
return
if(istype(I, /obj/item/ticket_machine_ticket))
to_chat(user, "<span class='warning'>You start to cram [I] into [src]'s recycling bin.</span>")
if(do_after(user, 20, target = src)) //Slight delay so they don't accidentally dispose of their ticket and move to the BACK OF THE LINE
qdel(I)
return
/obj/machinery/ticket_machine/proc/reset_cooldown()
ready = TRUE
@@ -148,22 +162,30 @@
/obj/machinery/ticket_machine/attack_hand(mob/living/carbon/user)
. = ..()
if(!ready)
to_chat(user,"Temporarily unable to dispense ticket, please be patient!")
to_chat(user,"You press the button, but nothing happens...")
return
if(ticket_number >= max_number)
to_chat(user,"Ticket supply depleted, please refill this unit with a hand labeller refill cartridge!")
return
ready = FALSE
if((user in ticket_holders) && !(obj_flags & EMAGGED))
to_chat(user, "You already have a ticket!")
return
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 100, 0)
addtimer(CALLBACK(src, .proc/reset_cooldown), cooldown)//Small cooldown to prevent the clown from ripping out every ticket
ticket_number ++
to_chat(user, "<span class='notice'>You take a ticket from [src], looks like you're customer #[ticket_number]...</span>")
to_chat(user, "<span class='notice'>You take a ticket from [src], looks like you're ticket number #[ticket_number]...</span>")
var/obj/item/ticket_machine_ticket/theirticket = new /obj/item/ticket_machine_ticket(get_turf(src))
theirticket.name = "Ticket #[ticket_number]"
theirticket.maptext = "<font color='#000000'>[ticket_number]</font>"
theirticket.saved_maptext = "<font color='#000000'>[ticket_number]</font>"
theirticket.ticket_number = ticket_number
theirticket.source = src
theirticket.owner = user
user.put_in_hands(theirticket)
ticket_holders += user
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)
@@ -172,7 +194,7 @@
/obj/item/ticket_machine_ticket
name = "Ticket"
desc = "A ticket which shows your place in the line, you can put it back into the ticket machine when youre done with it."
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
@@ -181,6 +203,9 @@
resistance_flags = FLAMMABLE
max_integrity = 50
var/saved_maptext = null
var/mob/living/carbon/owner
var/obj/machinery/ticket_machine/source
var/ticket_number
/obj/item/ticket_machine_ticket/attack_hand(mob/user)
. = ..()
@@ -202,3 +227,11 @@
/obj/item/paper/extinguish()
..()
update_icon()
/obj/item/ticket_machine_ticket/Destroy()
if(owner && source)
source.ticket_holders -= owner
source.tickets[ticket_number] = null
owner = null
source = null
return ..()