mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-21 20:27:42 +01:00
Makes soft vendors work again Conflict Resolution II Fixes Shelter Capsule Vendor Note to self remember quotations Bad Lynx stop forgetting quotes!
223 lines
6.9 KiB
Plaintext
223 lines
6.9 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 = 'icons/obj/machines/ar_elements.dmi'
|
|
icon_state = "proj"
|
|
|
|
products = list()
|
|
contraband = list()
|
|
premium = list()
|
|
var/global/list/starting_legal_nifsoft
|
|
var/global/list/starting_illegal_nifsoft
|
|
|
|
density = 0
|
|
opacity = 0
|
|
var/datum/entopic/entopic
|
|
|
|
/obj/machinery/vending/nifsoft_shop/Initialize()
|
|
. = ..()
|
|
entopic = new(aholder = src, aicon = icon, aicon_state = "beacon")
|
|
|
|
/obj/machinery/vending/nifsoft_shop/Destroy()
|
|
QDEL_NULL(entopic)
|
|
return ..()
|
|
|
|
/obj/machinery/vending/nifsoft_shop/power_change()
|
|
..()
|
|
if(!entopic) return //Early APC init(), ignore
|
|
if(stat & BROKEN)
|
|
icon_state = "[initial(icon_state)]-broken"
|
|
entopic.hide()
|
|
else
|
|
if(!(stat & NOPOWER))
|
|
icon_state = initial(icon_state)
|
|
entopic.show()
|
|
else
|
|
spawn(rand(0, 15))
|
|
icon_state = "[initial(icon_state)]-off"
|
|
entopic.hide()
|
|
|
|
/obj/machinery/vending/nifsoft_shop/malfunction()
|
|
stat |= BROKEN
|
|
icon_state = "[initial(icon_state)]-broken"
|
|
entopic.hide()
|
|
return
|
|
|
|
// 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_state]-deny",entopic.my_image)
|
|
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)
|
|
to_chat(usr, "There is no coin in this machine.")
|
|
return
|
|
|
|
coin.forceMove(src.loc)
|
|
if(!usr.get_active_hand())
|
|
usr.put_in_hands(coin)
|
|
to_chat(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
|
|
to_chat(usr, "<span class='warning'>Access denied.</span>") //Unless emagged of course
|
|
flick("[icon_state]-deny",entopic.my_image)
|
|
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)
|
|
to_chat(usr, "<span class='warning'>You aren't authorized to buy [initial(path.name)].</span>")
|
|
flick("[icon_state]-deny",entopic.my_image)
|
|
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.
|
|
to_chat(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)
|
|
SSnanoui.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
|
|
to_chat(usr, "<span class='warning'>Purchase not allowed.</span>") //Unless emagged of course
|
|
flick("[icon_state]-deny",entopic.my_image)
|
|
return
|
|
vend_ready = 0 //One thing at a time!!
|
|
status_message = "Installing..."
|
|
status_error = 0
|
|
SSnanoui.update_uis(src)
|
|
|
|
if(R.category & CAT_COIN)
|
|
if(!coin)
|
|
to_chat(user, "<span class='notice'>You need to insert a coin to get this item.</span>")
|
|
return
|
|
if(coin.string_attached)
|
|
if(prob(50))
|
|
to_chat(user, "<span class='notice'>You successfully pull the coin out before \the [src] could swallow it.</span>")
|
|
else
|
|
to_chat(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_state]-vend",entopic.my_image)
|
|
if(has_logs)
|
|
do_logging(R, user, 1)
|
|
|
|
status_message = ""
|
|
status_error = 0
|
|
vend_ready = 1
|
|
currently_vending = null
|
|
SSnanoui.update_uis(src)
|
|
return 1
|
|
|
|
//Can't throw intangible software at people.
|
|
/obj/machinery/vending/nifsoft_shop/throw_item()
|
|
//TODO: Make it throw disks at people with random software? That might be fun. EVEN THE ILLEGAL ONES? ;o
|
|
return 0
|