You begin righting \the [src].")
if(do_after(user, 50, target=src))
untilt(user)
return
return ..()
/obj/machinery/vending/ui_interact(mob/user)
var/dat = ""
switch(menu)
if(1)
dat += "Select an item
"
if(!credits)
dat += "Inserted credits: $[credits] remove"
else
dat += "Inserted credits: $[credits] remove"
dat += "
"
if(!product_records.len)
dat += "
No product loaded!"
else
var/list/display_records = product_records
if(extended_inventory) //hacking shows all inventory now since coins arent worth anything.
display_records = product_records + hidden_records + coin_records
else
display_records = product_records + coin_records
dat += "
"
for (var/datum/data/vending_product/R in display_records)
dat += "]) | "
dat += "$[R.price] | "
dat += "[sanitize(R.name)] | "
if(R.amount > 0)
dat += "[R.amount] | [!R.price ? "Vend" : "Buy"] | "
else
dat += "0 | Vend | "
dat += "
"
dat += "
"
dat += "
"
if(istype(src, /obj/machinery/vending/snack))
dat += "Chef's Food Selection
"
dat += ""
for (var/O in dish_quants)
if(dish_quants[O] > 0)
var/N = dish_quants[O]
dat += "
Dispense "
dat += "
[capitalize(O)]: [N]"
dat += "
"
if(2) //hyper economy purchase item menu
dat += ""
if(buying)
dat += "Purchase [buying.name]
"
else
dat += "
Purchase Item
"
dat += "Inserted credits: $[credits]
"
dat += "Not enough credits to purchase, please insert credits or swipe your card to purchase!
"
dat += "Pay-By-Card"
dat += "Return"
dat += "
"
var/datum/browser/popup = new(user, "vending", (name))
popup.set_content(dat)
popup.set_title_image(user.browse_rsc_icon(icon, icon_state))
popup.open()
/obj/machinery/vending/proc/GetIconForProduct(datum/data/vending_product/P)
if(vending_cache[P.product_path])
return vending_cache[P.product_path]
var/product = new P.product_path()
vending_cache[P.product_path] = icon2base64(getFlatIcon(product, no_anim = TRUE))
qdel(product)
return vending_cache[P.product_path]
/obj/machinery/vending/Topic(href, href_list)
if(..())
return
if(href_list["remove_coin"])
if(!(coin || bill))
to_chat(usr, "There is no money in this machine.")
return
if(coin)
usr.put_in_hands(coin)
to_chat(usr, "You remove [coin] from [src].")
coin = null
if(bill)
usr.put_in_hands(bill)
to_chat(usr, "You remove [bill] from [src].")
bill = null
if(href_list["removecredits"])
var/obj/item/stack/credits/C = new /obj/item/stack/credits/(loc)
C.amount = credits
credits = 0 //empty the machine
if(usr.put_in_hands(C))
to_chat(usr, "You take [C] out of the ATM.")
usr.set_machine(src)
if((href_list["dispense"]) && (vend_ready))
var/N = href_list["dispense"]
if(dish_quants[N] <= 0) // Sanity check, there are probably ways to press the button when it shouldn't be possible.
return
vend_ready = 0
use_power(5)
dish_quants[N] = max(dish_quants[N] - 1, 0)
for(var/obj/O in contents)
if(O.name == N)
O.forceMove(drop_location())
break
vend_ready = 1
updateUsrDialog()
return
if(href_list["idpay"])
var/obj/item/card/id/I = usr.get_idcard(TRUE)
if(I)
if(I.registered_account)
bankid = I.registered_account
else
to_chat(usr, "The vending machine fails to read your bank account!")
else
to_chat(usr, "The vending machine fails to read your card!")
if(href_list["return"])
menu = 1
vend_ready = 1
updateUsrDialog()
return
if((href_list["vend"]) && (vend_ready))
if(panel_open)
to_chat(usr, "The vending machine cannot dispense products while its service panel is open!")
return
if((!allowed(usr)) && !(obj_flags & EMAGGED) && scan_id) //For SECURE VENDING MACHINES YEAH
to_chat(usr, "Access denied." )
flick(icon_deny,src)
return
vend_ready = 0 //One thing at a time!!
var/datum/data/vending_product/R = locate(href_list["vend"])
buying = R
if(!R || !istype(R) || !R.product_path)
vend_ready = 1
return
//check if they can afford it, if not open the next menu
if(R.price > credits)
menu = 2 //second menu
updateUsrDialog()
vend_ready = 1
if(bankid && R == buying) //if we have a bank id, and we are trying to buy the same thing!
if(bankid.account_balance >= R.price)
bankid.account_balance -= R.price //take the money from the account.
menu = 1
to_chat(usr, "You [R.name] via the provided bank account!")
bankid = null //so noone can buy from your account after youve purchased stuff
else
to_chat(usr, "You do not have enough money in the bank account to purchase [R.name]!")
return
else
return
else
credits -= R.price
menu = 1
if(R in hidden_records)
if(!extended_inventory)
vend_ready = 1
return
if (R.amount <= 0)
to_chat(usr, "Sold out.")
vend_ready = 1
return
else
R.amount--
if(((last_reply + 200) <= world.time) && vend_reply)
speak(vend_reply)
last_reply = world.time
use_power(5)
if(icon_vend) //Show the vending animation if needed
flick(icon_vend,src)
var/vended = new R.product_path(get_turf(src))
playsound(src, 'sound/items/vending.ogg', 50, 1, -1)
if(usr.CanReach(src))
if(usr.put_in_hands(vended))
to_chat(usr, "You take [R.name] out of the slot.")
else
to_chat(usr, "[capitalize(R.name)] falls onto the floor!")
else
to_chat(usr, "[capitalize(R.name)] falls onto the floor!")
SSblackbox.record_feedback("nested tally", "vending_machine_usage", 1, list("[type]", "[R.product_path]"))
vend_ready = 1
updateUsrDialog()
return
else if(href_list["togglevoice"] && panel_open)
shut_up = !shut_up
updateUsrDialog()
/obj/machinery/vending/process()
if(stat & (BROKEN|NOPOWER))
return
if(!active)
return
if(seconds_electrified > 0)
seconds_electrified--
//Pitch to the people! Really sell it!
if(last_slogan + slogan_delay <= world.time && slogan_list.len > 0 && !shut_up && prob(5))
var/slogan = pick(slogan_list)
speak(slogan)
last_slogan = world.time
/* no freebies
if(shoot_inventory && prob(shoot_inventory_chance))
throw_item()
*/
/obj/machinery/vending/proc/speak(message)
if(stat & (BROKEN|NOPOWER))
return
if(!message)
return
say(message)
/obj/machinery/vending/power_change()
if(stat & BROKEN)
icon_state = "[initial(icon_state)]-broken"
else
if(powered())
icon_state = initial(icon_state)
stat &= ~NOPOWER
else
icon_state = "[initial(icon_state)]-off"
stat |= NOPOWER
//Somebody cut an important wire and now we're following a new definition of "pitch."
/obj/machinery/vending/proc/throw_item()
var/obj/throw_item = null
var/mob/living/target = locate() in view(7,src)
if(!target)
return 0
for(var/datum/data/vending_product/R in shuffle(product_records))
if(R.amount <= 0) //Try to use a record that actually has something to dump.
continue
var/dump_path = R.product_path
if(!dump_path)
continue
R.amount--
throw_item = new dump_path(loc)
break
if(!throw_item)
return 0
pre_throw(throw_item)
throw_item.throw_at(target, 16, 3)
visible_message("[src] launches [throw_item] at [target]!")
return 1
/obj/machinery/vending/proc/pre_throw(obj/item/I)
return
/obj/machinery/vending/proc/shock(mob/user, prb)
if(stat & (BROKEN|NOPOWER)) // unpowered, no shock
return FALSE
if(!prob(prb))
return FALSE
do_sparks(5, TRUE, src)
var/check_range = TRUE
if(electrocute_mob(user, get_area(src), src, 0.7, check_range))
return TRUE
else
return FALSE
/obj/machinery/vending/onTransitZ()
return