Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom, crew-buildable vendors #28009

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions code/game/machinery/machine_frame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ to destroy them and players will be able to make replacements.
"HydroDrobe" = /obj/machinery/economy/vending/hydrodrobe,
"JaniDrobe" = /obj/machinery/economy/vending/janidrobe,
"LawDrobe" = /obj/machinery/economy/vending/lawdrobe,
"TrainDrobe" = /obj/machinery/economy/vending/traindrobe)
"TrainDrobe" = /obj/machinery/economy/vending/traindrobe,
"CrewVend 3000" = /obj/machinery/economy/vending/custom)
var/static/list/unique_vendors = list(
"ShadyCigs Ultra" = /obj/machinery/economy/vending/cigarette/beach,
"SyndiMed Plus" = /obj/machinery/economy/vending/wallmed/syndicate)
Expand All @@ -338,7 +339,10 @@ to destroy them and players will be able to make replacements.
build_path = typepath
board_name = "[type] Vendor"
format_board_name()
req_components = list(initial(typepath.refill_canister) = 1)
if(initial(typepath.refill_canister))
req_components = list(initial(typepath.refill_canister) = 1)
else
req_components = list()

/obj/item/circuitboard/slot_machine
board_name = "Slot Machine"
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/merch_vendor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
var/pp = replacetext(replacetext("[merch.typepath]", "/obj/item/", ""), "/", "-")
imagelist[pp] = "[icon2base64(icon(initial(I.icon), initial(I.icon_state), SOUTH, 1))]"

/obj/machinery/economy/merch/attackby__legacy__attackchain(obj/item/I, mob/user)
/obj/machinery/economy/merch/item_interaction(mob/living/user, obj/item/I, list/modifiers)
if(isspacecash(I))
insert_cash(I, user)
return TRUE
return ITEM_INTERACT_COMPLETE

return ..()

Expand Down
73 changes: 73 additions & 0 deletions code/game/machinery/vendors/custom_vendors.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/obj/machinery/economy/vending/custom
name = "\improper CrewVend 3000"
refill_canister = null
always_deconstruct = TRUE
var/obj/item/eftpos/linked_pos

/obj/machinery/economy/vending/custom/Destroy()
if(!isnull(linked_pos))
linked_pos.linked_vendors -= src
linked_pos = null
return ..()

/obj/machinery/economy/vending/custom/locked()
return isnull(linked_pos) || linked_pos.transaction_locked

/obj/machinery/economy/vending/custom/get_vendor_account()
return linked_pos?.linked_account || ..()

/obj/machinery/economy/vending/custom/item_interaction(mob/living/user, obj/item/used, list/modifiers)
if(istype(used, /obj/item/eftpos))
visible_message("[src] beeps as [user] links it to [used].", "You hear something beep.")
if(!isnull(linked_pos))
linked_pos.linked_vendors -= src
linked_pos = used
var/obj/item/eftpos/pos = used
pos.linked_vendors += src
return ITEM_INTERACT_COMPLETE
else if(isnull(linked_pos))
to_chat(user, "<span style='warning'>You need to link a point of sale device first!</span>")
return ITEM_INTERACT_COMPLETE
else if(locked())
return ..()
else if(used.tool_behaviour == TOOL_CROWBAR)
return ..()
if(!user.canUnEquip(used, FALSE))
to_chat(user, "<span style='warning'>\The [used] is stuck to your hand!</span>")
return ITEM_INTERACT_COMPLETE

for(var/datum/data/vending_product/physical/record in physical_product_records)
if(record.get_amount_left() == 0)
physical_product_records -= record
qdel(record)
else if(isitem(record.items[1]))
var/obj/item/existing = record.items[1]
if(existing.should_stack_with(used))
record.items += used
user.unequip_to(used, null, TRUE, TRUE)
user.visible_message("[user] puts [used] into [src].", "You put [used] into [src].")
return ITEM_INTERACT_COMPLETE

var/price = tgui_input_number(user, "How much do you want to sell [used] for?")
if(isnum(price))
var/datum/data/vending_product/physical/record = new(used.name, used.icon, used.icon_state)
record.items += used
record.price = price
physical_product_records += record
SStgui.update_uis(src, TRUE)
user.unequip_to(used, null, TRUE, TRUE)
user.visible_message("[user] puts [used] into [src].", "You put [used] into [src].")
return ITEM_INTERACT_COMPLETE

/obj/machinery/economy/vending/custom/crowbar_act(mob/user, obj/item/I)
if(!isnull(linked_pos) && linked_pos.transaction_locked)
user.visible_message("[user] tries to pry [src] apart, but fails.", "The lock on [src] resists your efforts to pry it apart.")
return TRUE
return ..()

/obj/machinery/economy/vending/custom/delayed_vend(datum/data/vending_product/R, mob/user)
. = ..()
if(istype(R, /datum/data/vending_product/physical) && R.get_amount_left() == 0)
physical_product_records -= R
physical_hidden_records -= R
SStgui.update_uis(src, TRUE)
18 changes: 3 additions & 15 deletions code/game/machinery/vendors/generic_vendors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -156,29 +156,17 @@
return TRUE

/obj/machinery/economy/vending/coffee/do_vend(datum/data/vending_product/R, mob/user)
if(..())
var/obj/item/reagent_containers/drinks/vended = ..()
if(!istype(vended))
return
var/obj/item/reagent_containers/drinks/vended = new R.product_path()

if(istype(vended, /obj/item/reagent_containers/drinks/mug))
var/put_on_turf = TRUE
if(user && iscarbon(user) && user.Adjacent(src))
if(user.put_in_hands(vended))
put_on_turf = FALSE
if(put_on_turf)
var/turf/T = get_turf(src)
vended.forceMove(T)
return

vended.reagents.trans_to(inserted_item, vended.reagents.total_volume)
if(vended.reagents.total_volume)
var/put_on_turf = TRUE
if(user && iscarbon(user) && user.Adjacent(src))
if(user.put_in_hands(vended))
put_on_turf = FALSE
if(put_on_turf)
var/turf/T = get_turf(src)
vended.forceMove(T)
user.put_in_hands(vended)
else
qdel(vended)

Expand Down
Loading
Loading