Skip to content

Commit

Permalink
Custom, crew-buildable vendors (#28009)
Browse files Browse the repository at this point in the history
* Buildable vendors.

* Lint.

* I think this is right?

* It's already IN their hands.

* Lint, re-check item after prompting for price.

* Fixes.

* Review fixes, working dissassembly again.

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Restrict appearance to buildable vendor sprites.

* tyop fix

---------

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
  • Loading branch information
FunnyMan3595 and Burzah authored Jan 28, 2025
1 parent 0c5de8b commit a6d347e
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 116 deletions.
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
84 changes: 84 additions & 0 deletions code/game/machinery/vendors/custom_vendors.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/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("<span class='notice'>[src] beeps as [user] links it to [used].</span>", "<span class='notice'>You hear something beep.</span>")
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 class='warning'>You need to link a point of sale device first!</span>")
return ITEM_INTERACT_COMPLETE
else if(locked())
return ..()
if(!user.canUnEquip(used, FALSE))
to_chat(user, "<span class='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(used)
used.moveToNullspace()
user.visible_message("<span class='notice'>[user] puts [used] into [src].</span>", "<span class='notice>'You put [used] into [src].</span>")
return ITEM_INTERACT_COMPLETE

var/price = tgui_input_number(user, "How much do you want to sell [used] for?")
if(!isnum(price))
return ITEM_INTERACT_COMPLETE
if(!Adjacent(user))
to_chat(user, "<span class='warning'>You can't reach [src] from here!</span>")
return ITEM_INTERACT_COMPLETE
if(!user.is_holding(used))
to_chat(user, "<span class='warning'>\The [used] isn't in your hand anymore!</span>")
return ITEM_INTERACT_COMPLETE
if(!user.canUnEquip(used, FALSE))
to_chat(user, "<span class='warning'>\The [used] is stuck to your hand!</span>")
return ITEM_INTERACT_COMPLETE

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(used)
used.moveToNullspace()
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("<span class='notice'>[user] tries to pry [src] apart, but fails.</span>", "<span class='notice'>The lock on [src] resists your efforts to pry it apart.</span>")
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)
21 changes: 3 additions & 18 deletions code/game/machinery/vendors/generic_vendors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -156,30 +156,15 @@
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)
else
if(!vended.reagents.total_volume)
qdel(vended)


Expand Down
Loading

0 comments on commit a6d347e

Please sign in to comment.