mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-28 18:41:37 +00:00
* Fixes the supply console not inheriting contraband and emag status from its circuit (#54177) Added an abstract proc for circuits intended to be used to allow a circuit to configure a machine. Overrode this proc for supply console boards (behaviour inherited by express boards) Call this proc in supply console on_construction (behaviour inherited by express supply consoles) Allows all supply consoles to inherit their circuit's emag and contraband status. Doesn't look like any other circuits use this sort of functionality, but if they do I'll fix 'em up too. * Fixes the supply console not inheriting contraband and emag status from its circuit Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
283 lines
8.8 KiB
Plaintext
283 lines
8.8 KiB
Plaintext
/obj/machinery/computer/cargo
|
|
name = "supply console"
|
|
desc = "Used to order supplies, approve requests, and control the shuttle."
|
|
icon_screen = "supply"
|
|
circuit = /obj/item/circuitboard/computer/cargo
|
|
light_color = COLOR_BRIGHT_ORANGE
|
|
|
|
var/requestonly = FALSE
|
|
var/contraband = FALSE
|
|
var/self_paid = FALSE
|
|
var/safety_warning = "For safety reasons, the automated supply shuttle \
|
|
cannot transport live organisms, human remains, classified nuclear weaponry, \
|
|
homing beacons or machinery housing any form of artificial intelligence."
|
|
var/blockade_warning = "Bluespace instability detected. Shuttle movement impossible."
|
|
/// radio used by the console to send messages on supply channel
|
|
var/obj/item/radio/headset/radio
|
|
/// var that tracks message cooldown
|
|
var/message_cooldown
|
|
var/list/loaded_coupons
|
|
|
|
|
|
/obj/machinery/computer/cargo/request
|
|
name = "supply request console"
|
|
desc = "Used to request supplies from cargo."
|
|
icon_screen = "request"
|
|
circuit = /obj/item/circuitboard/computer/cargo/request
|
|
requestonly = TRUE
|
|
|
|
/obj/machinery/computer/cargo/Initialize()
|
|
. = ..()
|
|
radio = new /obj/item/radio/headset/headset_cargo(src)
|
|
|
|
/obj/machinery/computer/cargo/Destroy()
|
|
QDEL_NULL(radio)
|
|
..()
|
|
|
|
/obj/machinery/computer/cargo/proc/get_export_categories()
|
|
. = EXPORT_CARGO
|
|
if(contraband)
|
|
. |= EXPORT_CONTRABAND
|
|
if(obj_flags & EMAGGED)
|
|
. |= EXPORT_EMAG
|
|
|
|
/obj/machinery/computer/cargo/emag_act(mob/user)
|
|
if(obj_flags & EMAGGED)
|
|
return
|
|
if(user)
|
|
user.visible_message("<span class='warning'>[user] swipes a suspicious card through [src]!</span>",
|
|
"<span class='notice'>You adjust [src]'s routing and receiver spectrum, unlocking special supplies and contraband.</span>")
|
|
|
|
obj_flags |= EMAGGED
|
|
contraband = TRUE
|
|
|
|
// This also permamently sets this on the circuit board
|
|
var/obj/item/circuitboard/computer/cargo/board = circuit
|
|
board.contraband = TRUE
|
|
board.obj_flags |= EMAGGED
|
|
update_static_data(user)
|
|
|
|
/obj/machinery/computer/cargo/on_construction()
|
|
. = ..()
|
|
circuit.configure_machine(src)
|
|
|
|
/obj/machinery/computer/cargo/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "Cargo", name)
|
|
ui.open()
|
|
|
|
/obj/machinery/computer/cargo/ui_data()
|
|
var/list/data = list()
|
|
data["location"] = SSshuttle.supply.getStatusText()
|
|
var/datum/bank_account/D = SSeconomy.get_dep_account(ACCOUNT_CAR)
|
|
if(D)
|
|
data["points"] = D.account_balance
|
|
data["away"] = SSshuttle.supply.getDockedId() == "supply_away"
|
|
data["self_paid"] = self_paid
|
|
data["docked"] = SSshuttle.supply.mode == SHUTTLE_IDLE
|
|
data["loan"] = !!SSshuttle.shuttle_loan
|
|
data["loan_dispatched"] = SSshuttle.shuttle_loan && SSshuttle.shuttle_loan.dispatched
|
|
var/message = "Remember to stamp and send back the supply manifests."
|
|
if(SSshuttle.centcom_message)
|
|
message = SSshuttle.centcom_message
|
|
if(SSshuttle.supplyBlocked)
|
|
message = blockade_warning
|
|
data["message"] = message
|
|
data["cart"] = list()
|
|
for(var/datum/supply_order/SO in SSshuttle.shoppinglist)
|
|
data["cart"] += list(list(
|
|
"object" = SO.pack.name,
|
|
"cost" = SO.pack.cost,
|
|
"id" = SO.id,
|
|
"orderer" = SO.orderer,
|
|
"paid" = !isnull(SO.paying_account) //paid by requester
|
|
))
|
|
|
|
data["requests"] = list()
|
|
for(var/datum/supply_order/SO in SSshuttle.requestlist)
|
|
data["requests"] += list(list(
|
|
"object" = SO.pack.name,
|
|
"cost" = SO.pack.cost,
|
|
"orderer" = SO.orderer,
|
|
"reason" = SO.reason,
|
|
"id" = SO.id
|
|
))
|
|
|
|
return data
|
|
|
|
/obj/machinery/computer/cargo/ui_static_data(mob/user)
|
|
var/list/data = list()
|
|
data["requestonly"] = requestonly
|
|
data["supplies"] = list()
|
|
for(var/pack in SSshuttle.supply_packs)
|
|
var/datum/supply_pack/P = SSshuttle.supply_packs[pack]
|
|
if(!data["supplies"][P.group])
|
|
data["supplies"][P.group] = list(
|
|
"name" = P.group,
|
|
"packs" = list()
|
|
)
|
|
if((P.hidden && !(obj_flags & EMAGGED)) || (P.contraband && !contraband) || (P.special && !P.special_enabled) || P.DropPodOnly)
|
|
continue
|
|
data["supplies"][P.group]["packs"] += list(list(
|
|
"name" = P.name,
|
|
"cost" = P.cost,
|
|
"id" = pack,
|
|
"desc" = P.desc || P.name, // If there is a description, use it. Otherwise use the pack's name.
|
|
"goody" = P.goody,
|
|
"access" = P.access
|
|
))
|
|
return data
|
|
|
|
/obj/machinery/computer/cargo/ui_act(action, params, datum/tgui/ui)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
switch(action)
|
|
if("send")
|
|
if(!SSshuttle.supply.canMove())
|
|
say(safety_warning)
|
|
return
|
|
if(SSshuttle.supplyBlocked)
|
|
say(blockade_warning)
|
|
return
|
|
if(SSshuttle.supply.getDockedId() == "supply_home")
|
|
SSshuttle.supply.export_categories = get_export_categories()
|
|
SSshuttle.moveShuttle("supply", "supply_away", TRUE)
|
|
say("The supply shuttle is departing.")
|
|
investigate_log("[key_name(usr)] sent the supply shuttle away.", INVESTIGATE_CARGO)
|
|
else
|
|
investigate_log("[key_name(usr)] called the supply shuttle.", INVESTIGATE_CARGO)
|
|
say("The supply shuttle has been called and will arrive in [SSshuttle.supply.timeLeft(600)] minutes.")
|
|
SSshuttle.moveShuttle("supply", "supply_home", TRUE)
|
|
. = TRUE
|
|
if("loan")
|
|
if(!SSshuttle.shuttle_loan)
|
|
return
|
|
if(SSshuttle.supplyBlocked)
|
|
say(blockade_warning)
|
|
return
|
|
else if(SSshuttle.supply.mode != SHUTTLE_IDLE)
|
|
return
|
|
else if(SSshuttle.supply.getDockedId() != "supply_away")
|
|
return
|
|
else
|
|
SSshuttle.shuttle_loan.loan_shuttle()
|
|
say("The supply shuttle has been loaned to CentCom.")
|
|
investigate_log("[key_name(usr)] accepted a shuttle loan event.", INVESTIGATE_CARGO)
|
|
log_game("[key_name(usr)] accepted a shuttle loan event.")
|
|
. = TRUE
|
|
if("add")
|
|
var/id = text2path(params["id"])
|
|
var/datum/supply_pack/pack = SSshuttle.supply_packs[id]
|
|
if(!istype(pack))
|
|
return
|
|
if((pack.hidden && !(obj_flags & EMAGGED)) || (pack.contraband && !contraband) || pack.DropPodOnly)
|
|
return
|
|
|
|
var/name = "*None Provided*"
|
|
var/rank = "*None Provided*"
|
|
var/ckey = usr.ckey
|
|
if(ishuman(usr))
|
|
var/mob/living/carbon/human/H = usr
|
|
name = H.get_authentification_name()
|
|
rank = H.get_assignment(hand_first = TRUE)
|
|
else if(issilicon(usr))
|
|
name = usr.real_name
|
|
rank = "Silicon"
|
|
|
|
var/datum/bank_account/account
|
|
if(self_paid && ishuman(usr))
|
|
var/mob/living/carbon/human/H = usr
|
|
var/obj/item/card/id/id_card = H.get_idcard(TRUE)
|
|
if(!istype(id_card))
|
|
say("No ID card detected.")
|
|
return
|
|
if(istype(id_card, /obj/item/card/id/departmental_budget))
|
|
say("The [src] rejects [id_card].")
|
|
return
|
|
account = id_card.registered_account
|
|
if(!istype(account))
|
|
say("Invalid bank account.")
|
|
return
|
|
|
|
var/reason = ""
|
|
if(requestonly && !self_paid)
|
|
reason = stripped_input("Reason:", name, "")
|
|
if(isnull(reason) || ..())
|
|
return
|
|
|
|
if(pack.goody && !self_paid)
|
|
playsound(src, 'sound/machines/buzz-sigh.ogg', 50, FALSE)
|
|
say("ERROR: Small crates may only be purchased by private accounts.")
|
|
return
|
|
|
|
var/obj/item/coupon/applied_coupon
|
|
for(var/i in loaded_coupons)
|
|
var/obj/item/coupon/coupon_check = i
|
|
if(pack.type == coupon_check.discounted_pack)
|
|
say("Coupon found! [round(coupon_check.discount_pct_off * 100)]% off applied!")
|
|
coupon_check.moveToNullspace()
|
|
applied_coupon = coupon_check
|
|
break
|
|
|
|
var/turf/T = get_turf(src)
|
|
var/datum/supply_order/SO = new(pack, name, rank, ckey, reason, account, applied_coupon)
|
|
SO.generateRequisition(T)
|
|
if(requestonly && !self_paid)
|
|
SSshuttle.requestlist += SO
|
|
else
|
|
SSshuttle.shoppinglist += SO
|
|
if(self_paid)
|
|
say("Order processed. The price will be charged to [account.account_holder]'s bank account on delivery.")
|
|
if(requestonly && message_cooldown < world.time)
|
|
radio.talk_into(src, "A new order has been requested.", RADIO_CHANNEL_SUPPLY)
|
|
message_cooldown = world.time + 30 SECONDS
|
|
. = TRUE
|
|
if("remove")
|
|
var/id = text2num(params["id"])
|
|
for(var/datum/supply_order/SO in SSshuttle.shoppinglist)
|
|
if(SO.id == id)
|
|
if(SO.applied_coupon)
|
|
say("Coupon refunded.")
|
|
SO.applied_coupon.forceMove(get_turf(src))
|
|
SSshuttle.shoppinglist -= SO
|
|
. = TRUE
|
|
break
|
|
if("clear")
|
|
SSshuttle.shoppinglist.Cut()
|
|
. = TRUE
|
|
if("approve")
|
|
var/id = text2num(params["id"])
|
|
for(var/datum/supply_order/SO in SSshuttle.requestlist)
|
|
if(SO.id == id)
|
|
SSshuttle.requestlist -= SO
|
|
SSshuttle.shoppinglist += SO
|
|
. = TRUE
|
|
break
|
|
if("deny")
|
|
var/id = text2num(params["id"])
|
|
for(var/datum/supply_order/SO in SSshuttle.requestlist)
|
|
if(SO.id == id)
|
|
SSshuttle.requestlist -= SO
|
|
. = TRUE
|
|
break
|
|
if("denyall")
|
|
SSshuttle.requestlist.Cut()
|
|
. = TRUE
|
|
if("toggleprivate")
|
|
self_paid = !self_paid
|
|
. = TRUE
|
|
if(.)
|
|
post_signal("supply")
|
|
|
|
/obj/machinery/computer/cargo/proc/post_signal(command)
|
|
|
|
var/datum/radio_frequency/frequency = SSradio.return_frequency(FREQ_STATUS_DISPLAYS)
|
|
|
|
if(!frequency)
|
|
return
|
|
|
|
var/datum/signal/status_signal = new(list("command" = command))
|
|
frequency.post_signal(src, status_signal)
|