Files
Bubberstation/code/datums/elements/deliver_first.dm
SkyratBot 270a8253bf [MIRROR] Routine Cargo Departmental Deliveries [MDB IGNORE] (#9405)
* Routine Cargo Departmental Deliveries (#61992)

About The Pull Request

Document: https://hackmd.io/@ bazelart/HkY-SO9VF

Each department's request console is upgraded. Instead of making requests, they are only able to see crates related to their department that helps the department. They can order one for free (so not out of anyone's wallet) and it will arrive at cargo. Cargo gets the price of the ordered crate for bringing it to the department that ordered it (via an area check, of which the crate will remain locked until satisfied, emitter cracking aside).

Ordering a crate puts the console on a cooldown depending on the price of the crate ordered. The time ranges from 10 minutes at the lowest value, to capped at 20 minutes at 4x the default crate's price. the price in time follows a ease in out circular function, where the time increases slowly as the time goes up, but a lot in the middle. towards the higher end it slows down again.

Cargo will start with far less money, but this is countered by the new source of income.

Finish Mapping it
Finish tgui panel for department orders
Testmerge it for balance and feedback who cares

    Maybe give multiple destination areas, just in case one area gets obliterated who cares!

Why It's Good For The Game

Cargo starts with a budget to spend on themselves, which lets them order their department rewards before doing anything. There is no inherent reward to delivering to other departments other than social expectations of filling the job, which means cargo will simply ignore deliveries and requests if there are more self-important things going on, since those deliveries both cost cargo and do not help cargo in any way
Changelog

cl
add: replaced the request consoles in each department with department order consoles, which order for free on a cooldown. cargo gets these orders and delivers the crates, which are locked until delivery. upon delivery, cargo gets paid the value of the crate, and can then sell the crate back on the shuttle.
balance: cargo doesn't start with a budget, other departments get what their budget was split up amongst them
/cl

* Routine Cargo Departmental Deliveries

Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com>
Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
2021-11-14 12:04:29 -05:00

98 lines
4.2 KiB
Plaintext

/**
* # deliver first element!
*
* bespoke element (1 per set of specific arguments in existence) that makes crates unable to be sold UNTIL they are opened once (to where this element, and the block, are removed)
* Used for non-cargo orders to not get turned into a quick buck
*
* for the future coders or just me: please convert this into a component to allow for more feedback on the crate's status (clicking when unlocked, overlays, etc)
*/
/datum/element/deliver_first
element_flags = ELEMENT_DETACH | ELEMENT_BESPOKE
id_arg_index = 2
///typepath of the area we will be allowed to be opened in
var/goal_area_type
///how much is earned on delivery of the crate
var/payment
/datum/element/deliver_first/Attach(datum/target, goal_area_type, payment)
. = ..()
if(!istype(target, /obj/structure/closet))
return ELEMENT_INCOMPATIBLE
src.goal_area_type = goal_area_type
src.payment = payment
RegisterSignal(target, COMSIG_PARENT_EXAMINE, .proc/on_examine)
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/on_moved)
RegisterSignal(target, COMSIG_ATOM_EMAG_ACT, .proc/on_emag)
RegisterSignal(target, COMSIG_CLOSET_POST_OPEN, .proc/on_post_open)
ADD_TRAIT(target, TRAIT_BANNED_FROM_CARGO_SHUTTLE, src)
//registers pre_open when appropriate
area_check(target)
/datum/element/deliver_first/Detach(datum/target)
. = ..()
REMOVE_TRAIT(target, TRAIT_BANNED_FROM_CARGO_SHUTTLE, src)
UnregisterSignal(target, list(
COMSIG_PARENT_EXAMINE,
COMSIG_MOVABLE_MOVED,
COMSIG_ATOM_EMAG_ACT,
COMSIG_CLOSET_PRE_OPEN,
COMSIG_CLOSET_POST_OPEN,
))
///signal sent from examining target
/datum/element/deliver_first/proc/on_examine(obj/structure/closet/target, mob/user, list/examine_list)
SIGNAL_HANDLER
examine_list += span_warning("An electronic delivery lock prevents this from opening until it reaches its destination, [GLOB.areas_by_type[goal_area_type]].")
examine_list += span_warning("This crate cannot be sold until it is opened.")
///registers the signal that blocks target from opening when outside of the valid area, returns if it is now unlocked
/datum/element/deliver_first/proc/area_check(obj/structure/closet/target)
var/area/target_area = get_area(target)
if(target_area.type == goal_area_type)
UnregisterSignal(target, COMSIG_CLOSET_PRE_OPEN)
return TRUE
else
RegisterSignal(target, COMSIG_CLOSET_PRE_OPEN, .proc/on_pre_open, override = TRUE) //very purposefully overriding
return FALSE
/datum/element/deliver_first/proc/on_moved(obj/structure/closet/target, atom/oldloc, direction)
SIGNAL_HANDLER
area_check(target)
/datum/element/deliver_first/proc/on_emag(obj/structure/closet/target, mob/emagger)
SIGNAL_HANDLER
emagger.balloon_alert(emagger, "delivery lock bypassed")
remove_lock(target)
///signal called before opening target, blocks opening
/datum/element/deliver_first/proc/on_pre_open(obj/structure/closet/target, mob/living/user, force)
SIGNAL_HANDLER
if(force)
return
if(istype(target, /obj/structure/closet/crate))
var/obj/structure/closet/crate/opening_crate = target
if(opening_crate.manifest) //we don't want to send feedback if they're just tearing off the manifest
return BLOCK_OPEN
if(user)
target.balloon_alert(user, "access denied until delivery!")
playsound(target, 'sound/machines/buzz-two.ogg', 30, TRUE)
return BLOCK_OPEN
///signal called by successfully opening target
/datum/element/deliver_first/proc/on_post_open(obj/structure/closet/target, force)
SIGNAL_HANDLER
if(area_check(target))
//noice, delivered!
var/datum/bank_account/cargo_account = SSeconomy.get_dep_account(ACCOUNT_CAR)
cargo_account.adjust_money(payment)
remove_lock(target)
///called to remove the element in a flavorful way, either from delivery or from emagging/breaking open the crate
/datum/element/deliver_first/proc/remove_lock(obj/structure/closet/target)
target.visible_message(span_notice("[target]'s delivery lock self destructs, spewing sparks from the mechanism!"))
var/datum/effect_system/spark_spread/spark_system = new /datum/effect_system/spark_spread()
spark_system.set_up(4, 0, target.loc)
spark_system.start()
playsound(src, "sparks", 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
target.RemoveElement(/datum/element/deliver_first, goal_area_type, payment)