Files
CHOMPStation2/code/modules/nifsoft/nif_softshop.dm

184 lines
5.8 KiB
Plaintext

//Custom vendors
/obj/machinery/vending/nifsoft_shop
name = "NIFSoft Shop"
desc = "For all your mindware and mindware accessories."
product_ads = "Let us get into your head!;Looking for an upgrade?;Surpass Humanity!;Why be normal when you can be SUPERnormal?;Jack in with NIFSoft!"
icon_state = "nifsoft"
icon_vend = "nifsoft-purchase"
icon_deny = "nifsoft-problem"
products = list()
contraband = list()
premium = list()
var/global/list/starting_legal_nifsoft
var/global/list/starting_illegal_nifsoft
// Special Treatment!
/obj/machinery/vending/nifsoft_shop/build_inventory()
//Firsties
if(!starting_legal_nifsoft)
starting_legal_nifsoft = list()
starting_illegal_nifsoft = list()
for(var/P in (subtypesof(/datum/nifsoft) - typesof(/datum/nifsoft/package)))
var/datum/nifsoft/NS = P
if(initial(NS.vended))
switch(initial(NS.illegal))
if(TRUE)
starting_illegal_nifsoft += NS
if(FALSE)
starting_legal_nifsoft += NS
products = starting_legal_nifsoft.Copy()
contraband = starting_illegal_nifsoft.Copy()
var/list/all_products = list(
list(products, CAT_NORMAL),
list(contraband, CAT_HIDDEN),
list(premium, CAT_COIN))
for(var/current_list in all_products)
var/category = current_list[2]
for(var/entry in current_list[1])
var/datum/nifsoft/NS = entry
var/applies_to = initial(NS.applies_to)
var/context = ""
if(!(applies_to & NIF_SYNTHETIC))
context = " (Org Only)"
else if(!(applies_to & NIF_ORGANIC))
context = " (Syn Only)"
var/name = "[initial(NS.name)][context]"
var/datum/stored_item/vending_product/product = new/datum/stored_item/vending_product(src, entry, name)
product.price = initial(NS.cost)
product.amount = 10
product.category = category
product_records.Add(product)
/obj/machinery/vending/nifsoft_shop/allowed(mob/user)
if(!ishuman(user))
return FALSE
var/mob/living/carbon/human/H = user
if(!H.nif || !H.nif.stat == NIF_WORKING)
to_chat(H,"<span class='warning'>[src] seems unable to connect to your NIF...</span>")
flick(icon_deny,src)
return FALSE
return ..()
//Had to override this too
/obj/machinery/vending/nifsoft_shop/Topic(href, href_list)
if(stat & (BROKEN|NOPOWER))
return
if(usr.stat || usr.restrained())
return
if(href_list["remove_coin"] && !istype(usr,/mob/living/silicon))
if(!coin)
usr << "There is no coin in this machine."
return
coin.forceMove(src.loc)
if(!usr.get_active_hand())
usr.put_in_hands(coin)
usr << "<span class='notice'>You remove \the [coin] from \the [src]</span>"
coin = null
categories &= ~CAT_COIN
if((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))))
if((href_list["vend"]) && (vend_ready) && (!currently_vending))
if((!allowed(usr)) && !emagged && scan_id) //For SECURE VENDING MACHINES YEAH
usr << "<span class='warning'>Access denied.</span>" //Unless emagged of course
flick(icon_deny,src)
return
var/key = text2num(href_list["vend"])
var/datum/stored_item/vending_product/R = product_records[key]
// This should not happen unless the request from NanoUI was bad
if(!(R.category & categories))
return
//Specific soft access checking
var/datum/nifsoft/path = R.item_path
if(initial(path.access))
var/list/soft_access = list(initial(path.access))
var/list/usr_access = usr.GetAccess()
if(!has_access(soft_access, list(), usr_access) && !emagged)
usr << "<span class='warning'>You aren't authorized to buy [initial(path.name)].</span>"
flick(icon_deny,src)
return
if(R.price <= 0)
vend(R, usr)
else if(istype(usr,/mob/living/silicon)) //If the item is not free, provide feedback if a synth is trying to buy something.
usr << "<span class='danger'>Artificial unit recognized. Artificial units cannot complete this transaction. Purchase canceled.</span>"
return
else
currently_vending = R
if(!vendor_account || vendor_account.suspended)
status_message = "This machine is currently unable to process payments due to problems with the associated account."
status_error = 1
else
status_message = "[initial(path.desc)]<br><br><b>Please swipe a card or insert cash to pay for the item.</b>"
status_error = 0
else if(href_list["cancelpurchase"])
currently_vending = null
else if((href_list["togglevoice"]) && (panel_open))
shut_up = !shut_up
add_fingerprint(usr)
nanomanager.update_uis(src)
// Also special treatment!
/obj/machinery/vending/nifsoft_shop/vend(datum/stored_item/vending_product/R, mob/user)
var/mob/living/carbon/human/H = user
if((!allowed(usr)) && !emagged && scan_id && istype(H)) //For SECURE VENDING MACHINES YEAH
usr << "<span class='warning'>Purchase not allowed.</span>" //Unless emagged of course
flick(icon_deny,src)
return
vend_ready = 0 //One thing at a time!!
status_message = "Installing..."
status_error = 0
nanomanager.update_uis(src)
if(R.category & CAT_COIN)
if(!coin)
user << "<span class='notice'>You need to insert a coin to get this item.</span>"
return
if(coin.string_attached)
if(prob(50))
user << "<span class='notice'>You successfully pull the coin out before \the [src] could swallow it.</span>"
else
user << "<span class='notice'>You weren't able to pull the coin out fast enough, the machine ate it, string and all.</span>"
qdel(coin)
coin = null
categories &= ~CAT_COIN
else
qdel(coin)
coin = null
categories &= ~CAT_COIN
if(((last_reply + (vend_delay + 200)) <= world.time) && vend_reply)
spawn(0)
speak(vend_reply)
last_reply = world.time
use_power(vend_power_usage) //actuators and stuff
spawn(vend_delay)
R.amount--
new R.item_path(H.nif)
flick(icon_vend,src)
if(has_logs)
do_logging(R, user, 1)
status_message = ""
status_error = 0
vend_ready = 1
currently_vending = null
nanomanager.update_uis(src)
return 1