Refactors pay stands + custom vendors (#63889)

I am disgruntled by the way pay stations work. They're not intuitive, they're a pain to build and have no interface. Basically: They don't get made, and the potential is lost.

Pay stands => Holopay

    Summoned by right clicking your ID
    Disappears if the card is out of range.
    New TGUI window that offers more customization

Other bundled fixes:

    Custom vendors become more user friendly
    Code improvement
    Lots of documentation + refactoring
    New bundled number input will likely take place of animated number in tgui input number

Why It's Good For The Game

More RP opportunity for players, plus bug fixes. It's now much easier for players to start their own in game business selling substances clown shoes.
Changelog

cl
code: Created a new input component that accepts only integers. More usage to come.
refactor: Pay stands are now holographic. It's 2562! Create one by right-clicking your ID.
del: Circuit boards for pay stands.
refactor: Pay stands now have their own TGUI.
fix: Custom vendors now alert you when someone makes a purchase.
fix: Custom vendors now place items in your hand when you make a purchase.
/cl
This commit is contained in:
Jeremiah
2022-02-01 09:47:28 +13:00
committed by GitHub
parent 631fefb946
commit cdfd5df7be
18 changed files with 853 additions and 245 deletions
+124 -4
View File
@@ -7,6 +7,9 @@
/// Fallback time if none of the config entries are set for USE_LOW_LIVING_HOUR_INTERN
#define INTERN_THRESHOLD_FALLBACK_HOURS 15
/// Max time interval between projecting holopays
#define HOLOPAY_PROJECTION_INTERVAL 7 SECONDS
/* Cards
* Contains:
* DATA CARD
@@ -59,8 +62,28 @@
var/registered_name = null
/// Linked bank account.
var/datum/bank_account/registered_account
/// Linked paystand.
var/obj/machinery/paystand/my_store
/// Linked holopay.
var/datum/weakref/holopay_ref
/// Cooldown between projecting holopays
COOLDOWN_DECLARE(last_holopay_projection)
/// List of logos available for holopay customization - via font awesome 5
var/static/list/available_logos = list("angry", "ankh", "bacon", "band-aid", "cannabis", "cat", "cocktail", "coins", "comments-dollar",
"cross", "cut", "dog", "donate", "dna", "fist-raised", "flask", "glass-cheers", "glass-martini-alt", "hamburger", "hand-holding-usd",
"hat-wizard", "head-side-cough-slash", "heart", "heart-broken", "laugh-beam", "leaf", "money-check-alt", "music", "piggy-bank",
"pizza-slice", "prescription-bottle-alt", "radiation", "robot", "smile", "skull-crossbones", "smoking", "space-shuttle", "tram",
"trash", "user-ninja", "utensils", "wrench")
/// Replaces the "pay whatever" functionality with a set amount when non-zero.
var/holopay_fee = 0
/// The holopay icon chosen by the user
var/holopay_logo = "donate"
/// Maximum forced fee. It's unlikely for a user to encounter this type of money, much less pay it willingly.
var/holopay_max_fee = 5000
/// Minimum forced fee for holopay stations. Registers as "pay what you want."
var/holopay_min_fee = 0
/// The holopay name chosen by the user
var/holopay_name = "holographic pay stand"
/// Registered owner's age.
var/registered_age = 30
@@ -94,8 +117,8 @@
/obj/item/card/id/Destroy()
if (registered_account)
registered_account.bank_cards -= src
if (my_store && my_store.my_card == src)
my_store.my_card = null
if (holopay_ref)
QDEL_NULL(holopay_ref)
return ..()
/obj/item/card/id/get_id_examine_strings(mob/user)
@@ -383,6 +406,103 @@
user.visible_message(span_notice("[user] shows you: [icon2html(src, viewers(user))] [src.name][minor]."), span_notice("You show \the [src.name][minor]."))
add_fingerprint(user)
/obj/item/card/id/attack_hand_secondary(mob/user, list/modifiers)
. = ..()
if(. == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return
/// Sanity checks
var/obj/structure/holopay/my_store = holopay_ref?.resolve()
if(my_store)
my_store.dissapate()
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
if(!COOLDOWN_FINISHED(src, last_holopay_projection))
balloon_alert(user, "still recharging")
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
if(!registered_account || !registered_account.account_job)
balloon_alert(user, "no account")
to_chat(user, span_warning("You need a valid bank account to do this."))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/// Determines where the holopay will be placed based on tile contents
var/turf/projection
var/turf/step_ahead = get_step(user, user.dir)
var/turf/user_loc = user.loc
if(can_proj_holopay(step_ahead))
projection = step_ahead
else if(can_proj_holopay(user_loc))
projection = user_loc
if(!projection)
balloon_alert(user, "no space")
to_chat(user, span_warning("You need to be standing on or near an open tile to do this."))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/// Success: Valid tile for holopay placement
var/obj/structure/holopay/new_store = new(projection)
if(new_store?.assign_card(projection, src))
COOLDOWN_START(src, last_holopay_projection, HOLOPAY_PROJECTION_INTERVAL)
playsound(projection, "sound/effects/empulse.ogg", 40, TRUE)
holopay_ref = WEAKREF(new_store)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/**
* Determines whether a new holopay can be placed on the given turf.
* Checks if there are dense contents, too many contents, or another
* holopay already exists on the turf.
*
* Arguments:
* * turf/target - The target turf to be checked for dense contents
* Returns:
* * TRUE if the target is a valid holopay location, FALSE otherwise.
*/
/obj/item/card/id/proc/can_proj_holopay(turf/target)
if(!isfloorturf(target))
return FALSE
if(target.density)
return FALSE
if(length(target.contents) > 5)
return FALSE
for(var/obj/checked_obj in target.contents)
if(checked_obj.density)
return FALSE
if(istype(checked_obj, /obj/structure/holopay))
return FALSE
return TRUE
/**
* Setter for the shop logo on linked holopays
*
* Arguments:
* * new_logo - The new logo to be set.
*/
/obj/item/card/id/proc/set_holopay_logo(new_logo)
if(!available_logos.Find(new_logo))
CRASH("User input a holopay shop logo that didn't exist.")
holopay_logo = new_logo
/**
* Setter for changing the force fee on a holopay.
*
* Arguments:
* * new_fee - The new fee to be set.
*/
/obj/item/card/id/proc/set_holopay_fee(new_fee)
if(!isnum(new_fee))
CRASH("User input a non number into the holopay fee field.")
if(new_fee < holopay_min_fee || new_fee > holopay_max_fee)
CRASH("User input a number outside of the valid range into the holopay fee field.")
holopay_fee = new_fee
/**
* Setter for changing the holopay name.
*
* Arguments:
* * new_name - The new name to be set.
*/
/obj/item/card/id/proc/set_holopay_name(name)
if(length(name) < 3 || length(name) > MAX_NAME_LEN)
to_chat(usr, span_warning("Must be between 3 - 42 characters."))
else
holopay_name = html_encode(trim(name, MAX_NAME_LEN))
/obj/item/card/id/vv_edit_var(var_name, var_value)
. = ..()
if(.)
@@ -397,12 +397,6 @@
/obj/item/stock_parts/manipulator = 1)
def_components = list(/obj/item/stack/ore/bluespace_crystal = /obj/item/stack/ore/bluespace_crystal/artificial)
/obj/item/circuitboard/machine/paystand
name = "Pay Stand (Machine Board)"
greyscale_colors = CIRCUIT_COLOR_GENERIC
build_path = /obj/machinery/paystand
req_components = list()
/obj/item/circuitboard/machine/protolathe
name = "Protolathe (Machine Board)"
greyscale_colors = CIRCUIT_COLOR_GENERIC