mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-17 11:05:16 +01:00
Moneybots are no longer capable of crashing the economy (or your game) (#90814)
## About The Pull Request 1. Moneybots round to the nearest 1 credit. 2. Moneybots have a 0.5 second cooldown between being able to dispense credits. 3. Moneybots won't dispense more than 50 credits on a tile. ## Why It's Good For The Game The economy, fools! ## Changelog 🆑 Melbert qol: Moneybots round to the nearest 1 credit. qol: Moneybots have a 0.5 second cooldown between being able to dispense credits. qol: Moneybots won't dispense more than 50 credits on a tile. /🆑
This commit is contained in:
@@ -43,6 +43,15 @@
|
||||
desc = "Used to dispense money from the money bot. Money is taken from the internal storage of money."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/// CD before next dispense
|
||||
COOLDOWN_DECLARE(dispense_cd)
|
||||
|
||||
/// CD between allowing money to be dispensed
|
||||
var/dispense_cd_length = 0.5 SECONDS
|
||||
|
||||
/// The maximum amount of chips to dispense in one tile
|
||||
var/max_chips = 50
|
||||
|
||||
/// The amount of money to dispense
|
||||
var/datum/port/input/dispense_amount
|
||||
|
||||
@@ -55,6 +64,11 @@
|
||||
dispense_amount = add_input_port("Amount", PORT_TYPE_NUMBER)
|
||||
on_fail = add_output_port("On Failed", PORT_TYPE_SIGNAL)
|
||||
|
||||
/obj/item/circuit_component/money_dispenser/get_ui_notices()
|
||||
. = ..()
|
||||
. += create_ui_notice("Dispense Cooldown: [DisplayTimeText(dispense_cd_length)]", "orange", FA_ICON_STOPWATCH)
|
||||
. += create_ui_notice("Dispense Limit: [max_chips] Holochips (per tile)", "orange", FA_ICON_MONEY_BILL_TRANSFER)
|
||||
|
||||
/obj/item/circuit_component/money_dispenser/register_shell(atom/movable/shell)
|
||||
. = ..()
|
||||
if(istype(shell, /obj/structure/money_bot))
|
||||
@@ -64,18 +78,35 @@
|
||||
attached_bot = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/money_dispenser/pre_input_received(datum/port/input/port)
|
||||
dispense_amount.set_value(floor(dispense_amount.value))
|
||||
|
||||
/obj/item/circuit_component/money_dispenser/input_received(datum/port/input/port)
|
||||
|
||||
if(!attached_bot)
|
||||
return
|
||||
|
||||
if(!COOLDOWN_FINISHED(src, dispense_cd))
|
||||
on_fail.set_output(COMPONENT_SIGNAL)
|
||||
return
|
||||
|
||||
var/to_dispense = clamp(dispense_amount.value, 0, attached_bot.stored_money)
|
||||
if(!to_dispense)
|
||||
on_fail.set_output(COMPONENT_SIGNAL)
|
||||
return
|
||||
|
||||
COOLDOWN_START(src, dispense_cd, dispense_cd_length)
|
||||
var/atom/droploc = attached_bot.drop_location()
|
||||
var/num_on_tile = 0
|
||||
for(var/obj/item/holochip/chip in droploc)
|
||||
num_on_tile++
|
||||
// at this point, clearly no one's jumping for the cash. so let's stop dispensing
|
||||
if(num_on_tile > max_chips)
|
||||
on_fail.set_output(COMPONENT_SIGNAL)
|
||||
return
|
||||
|
||||
attached_bot.add_money(-to_dispense)
|
||||
new /obj/item/holochip(drop_location(), to_dispense)
|
||||
new /obj/item/holochip(droploc, to_dispense)
|
||||
|
||||
/obj/item/circuit_component/money_bot
|
||||
display_name = "Money Bot"
|
||||
|
||||
Reference in New Issue
Block a user