From c7f33669c6b400e5e2a7ab95fb2ec84f5095ce4e Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Mon, 28 Oct 2024 15:17:26 -0500 Subject: [PATCH] Adds a few more feedback stats and fixes some others (#3655) Now that I have the statbus working to show off feedback stats properly, I figured I'd touch up our feedback stat logging and add a little bit more. - Makes adjust_money() use defines mostly for consistency - Adds feedback for ordering crates from outposts - Records ship renames - Records encounter spawns (to see what people go to the most) - Records mission stats (successes, failures, etc) Lets coders get a better read on what players are doing, allows me to add even more stuff to statbus :cl: server: Logs a few more stats for use in the Statbus at https://shiptest.net/stats /:cl: --- code/__DEFINES/economy.dm | 26 ++++++++----------- code/controllers/subsystem/overmap.dm | 1 + code/controllers/subsystem/shuttle.dm | 2 +- code/game/machinery/bank_machine.dm | 4 +-- code/game/machinery/roulette_machine.dm | 2 +- code/game/objects/items/bank_card.dm | 6 ++--- .../antagonists/traitor/syndicate_contract.dm | 2 +- code/modules/cargo/bounty.dm | 2 +- code/modules/cargo/console.dm | 8 +++--- code/modules/cargo/order.dm | 2 ++ code/modules/economy/account.dm | 8 +++--- code/modules/economy/pay_stand.dm | 4 +-- code/modules/economy/selling_pad.dm | 4 +-- code/modules/jobs/job_types/_job.dm | 2 +- .../mob/living/simple_animal/bot/secbot.dm | 1 - .../modular_computers/laptop_vendor.dm | 2 +- code/modules/overmap/missions.dm | 6 ++++- .../overmap/ships/controlled_ship_datum.dm | 1 + code/modules/vending/_vending.dm | 26 ++++++++++++------- 19 files changed, 59 insertions(+), 50 deletions(-) diff --git a/code/__DEFINES/economy.dm b/code/__DEFINES/economy.dm index c31bffa08bf3..700d8f1db693 100644 --- a/code/__DEFINES/economy.dm +++ b/code/__DEFINES/economy.dm @@ -1,16 +1,12 @@ -#define ACCOUNT_CIV "CIV" -#define ACCOUNT_CIV_NAME "Civil Budget" -#define ACCOUNT_ENG "ENG" -#define ACCOUNT_ENG_NAME "Engineering Budget" -#define ACCOUNT_SCI "SCI" -#define ACCOUNT_SCI_NAME "Scientific Budget" -#define ACCOUNT_MED "MED" -#define ACCOUNT_MED_NAME "Medical Budget" -#define ACCOUNT_SRV "SRV" -#define ACCOUNT_SRV_NAME "Service Budget" -#define ACCOUNT_CAR "CAR" -#define ACCOUNT_CAR_NAME "Cargo Budget" -#define ACCOUNT_SEC "SEC" -#define ACCOUNT_SEC_NAME "Defense Budget" +#define CREDIT_LOG_WITHDRAW "cash" +#define CREDIT_LOG_TRANSFER_IN "transfer" +#define CREDIT_LOG_TRANSFER_OUT "transfer_out" +#define CREDIT_LOG_DEPOSIT "deposit" +#define CREDIT_LOG_STARTING_MONEY "starting_money" +#define CREDIT_LOG_VENDOR_PURCHASE "vendor_purchase" +#define CREDIT_LOG_MISSION "mission" +#define CREDIT_LOG_CARGO "cargo_purchase" +#define CREDIT_LOG_BOUNTY "bounty" +#define CREDIT_LOG_SYNDICATE_CONTRACT "syndicate_contract" +#define CREDIT_LOG_SELLING_PAD "selling_pad" -#define NO_FREEBIES "commies go home" diff --git a/code/controllers/subsystem/overmap.dm b/code/controllers/subsystem/overmap.dm index d65cccab920b..66c886c9664a 100644 --- a/code/controllers/subsystem/overmap.dm +++ b/code/controllers/subsystem/overmap.dm @@ -270,6 +270,7 @@ SUBSYSTEM_DEF(overmap) var/datum/map_generator/mapgen = new dynamic_datum.mapgen var/datum/map_template/ruin/used_ruin = ispath(ruin_type) ? (new ruin_type) : ruin_type + SSblackbox.record_feedback("tally", "encounter_spawned", 1, "[dynamic_datum.mapgen]") // name is random but PROBABLY unique var/encounter_name = dynamic_datum.planet_name || "\improper Uncharted Space [dynamic_datum.x]/[dynamic_datum.y]-[rand(1111, 9999)]" diff --git a/code/controllers/subsystem/shuttle.dm b/code/controllers/subsystem/shuttle.dm index 19df8eaf236c..8414e75d82fc 100644 --- a/code/controllers/subsystem/shuttle.dm +++ b/code/controllers/subsystem/shuttle.dm @@ -491,7 +491,7 @@ SUBSYSTEM_DEF(shuttle) user.forceMove(new_ship.get_jump_to_turf()) message_admins("[key_name_admin(user)] loaded [new_ship] ([S]) with the shuttle manipulator.") log_admin("[key_name(user)] loaded [new_ship] ([S]) with the shuttle manipulator.") - SSblackbox.record_feedback("text", "shuttle_manipulator", 1, "[S]") + SSblackbox.record_feedback("tally", "shuttle_manipulator_spawned", 1, "[S]") if("edit_template") if(S) diff --git a/code/game/machinery/bank_machine.dm b/code/game/machinery/bank_machine.dm index 83f3e366e8a3..cdcccc307a85 100644 --- a/code/game/machinery/bank_machine.dm +++ b/code/game/machinery/bank_machine.dm @@ -33,7 +33,7 @@ if(value) var/datum/bank_account/ship_account = ship_account_ref.resolve() if(ship_account) - ship_account.adjust_money(value, "deposit") + ship_account.adjust_money(value, CREDIT_LOG_DEPOSIT) to_chat(user, "You deposit [I]. The [ship_account.account_holder] Budget is now [ship_account.account_balance] cr.") qdel(I) return @@ -53,7 +53,7 @@ playsound(src, 'sound/items/poster_being_created.ogg', 100, TRUE) syphoning_credits += 200 - ship_account.adjust_money(-200) + ship_account.adjust_money(-200, "siphon") if(next_warning < world.time && prob(15)) var/area/A = get_area(loc) var/message = "Unauthorized credit withdrawal underway in [initial(A.name)]!!" diff --git a/code/game/machinery/roulette_machine.dm b/code/game/machinery/roulette_machine.dm index a36bf79a41b3..098cd5ea3868 100644 --- a/code/game/machinery/roulette_machine.dm +++ b/code/game/machinery/roulette_machine.dm @@ -235,7 +235,7 @@ var/remaining_payout = payout - my_card.registered_account.adjust_money(-payout) + my_card.registered_account.adjust_money(-payout, CREDIT_LOG_WITHDRAW) for(var/cash_type in cash_values) //Loop through all bundles from most valuable to least valuable. Try to give as much of that bundle as possible until you can't anymore, then move to the next. var/value = cash_values[cash_type] //Change this to use initial value once we change to the right bundle diff --git a/code/game/objects/items/bank_card.dm b/code/game/objects/items/bank_card.dm index 4a7f2f9d2f21..ecc418030008 100644 --- a/code/game/objects/items/bank_card.dm +++ b/code/game/objects/items/bank_card.dm @@ -47,7 +47,7 @@ to_chat(user, "[src] doesn't have a linked account to deposit [I] into!") return - registered_account.adjust_money(cash_money) + registered_account.adjust_money(cash_money, CREDIT_LOG_DEPOSIT) SSblackbox.record_feedback("amount", "credits_inserted", cash_money) log_econ("[cash_money] credits were inserted into [src] owned by [src.registered_name]") if(physical_currency) @@ -69,7 +69,7 @@ total += cash_money - registered_account.adjust_money(cash_money) + registered_account.adjust_money(cash_money, CREDIT_LOG_DEPOSIT) SSblackbox.record_feedback("amount", "credits_inserted", total) log_econ("[total] credits were inserted into [src] owned by [src.registered_name]") QDEL_LIST(money) @@ -132,7 +132,7 @@ return if(!alt_click_can_use_id(user)) return - if(registered_account.adjust_money(-amount_to_remove)) + if(registered_account.adjust_money(-amount_to_remove, CREDIT_LOG_WITHDRAW)) var/obj/item/holochip/holochip = new (user.drop_location(), amount_to_remove) user.put_in_hands(holochip) to_chat(user, "You withdraw [amount_to_remove] credits into a holochip.") diff --git a/code/modules/antagonists/traitor/syndicate_contract.dm b/code/modules/antagonists/traitor/syndicate_contract.dm index d6bbba359303..f90d0fb72185 100644 --- a/code/modules/antagonists/traitor/syndicate_contract.dm +++ b/code/modules/antagonists/traitor/syndicate_contract.dm @@ -149,7 +149,7 @@ C = H.get_bankcard() if(C && C.registered_account) - C.registered_account.adjust_money(ransom * 0.35, "syndicate_contract") + C.registered_account.adjust_money(ransom * 0.35, CREDIT_LOG_SYNDICATE_CONTRACT) C.registered_account.bank_card_talk("We've processed the ransom, agent. Here's your cut - your balance is now \ [C.registered_account.account_balance] cr.", TRUE) diff --git a/code/modules/cargo/bounty.dm b/code/modules/cargo/bounty.dm index 96d5218e551e..ddc07ddab611 100644 --- a/code/modules/cargo/bounty.dm +++ b/code/modules/cargo/bounty.dm @@ -21,7 +21,7 @@ GLOBAL_LIST_EMPTY(bounties_list) // Called when the claim button is clicked. Override to provide fancy rewards. /datum/bounty/proc/claim(datum/bank_account/claimer_account) if(can_claim() && claimer_account) - claimer_account.adjust_money(reward, "bounty") + claimer_account.adjust_money(reward, CREDIT_LOG_BOUNTY) claimed = TRUE // If an item sent in the cargo shuttle can satisfy the bounty. diff --git a/code/modules/cargo/console.dm b/code/modules/cargo/console.dm index 246d98da6636..e52f0b04a944 100644 --- a/code/modules/cargo/console.dm +++ b/code/modules/cargo/console.dm @@ -180,7 +180,7 @@ // no giving yourself money if(!charge_account || !val || val <= 0) return - if(charge_account.adjust_money(-val)) + if(charge_account.adjust_money(-val, CREDIT_LOG_WITHDRAW)) var/obj/item/holochip/cash_chip = new /obj/item/holochip(drop_location(), val) if(ishuman(usr)) var/mob/living/carbon/human/user = usr @@ -215,7 +215,7 @@ if (beacon) beacon.update_status(SP_READY) //turns on the beacon's ready light if("printBeacon") - if(charge_account?.adjust_money(-BEACON_COST)) + if(charge_account?.adjust_money(-BEACON_COST, "cargo_beacon")) cooldown = 10//a ~ten second cooldown for printing beacons to prevent spam var/obj/item/supplypod_beacon/C = new /obj/item/supplypod_beacon(drop_location()) C.link_console(src, usr)//rather than in beacon's Initialize(), we can assign the computer to the beacon by reusing this proc) @@ -251,7 +251,7 @@ // note that, because of CHECK_TICK above, we aren't sure if we can // afford the pack, even though we checked earlier. luckily adjust_money // returns false if the account can't afford the price - if(landing_turf && charge_account.adjust_money(-pack.cost)) + if(landing_turf && charge_account.adjust_money(-pack.cost, CREDIT_LOG_CARGO)) var/name = "*None Provided*" var/rank = "*None Provided*" if(ishuman(usr)) @@ -324,7 +324,7 @@ /obj/machinery/computer/cargo/attackby(obj/item/W, mob/living/user, params) var/value = W.get_item_credit_value() if(value && charge_account) - charge_account.adjust_money(value) + charge_account.adjust_money(value, CREDIT_LOG_DEPOSIT) to_chat(user, "You deposit [W]. The Vessel Budget is now [charge_account.account_balance] cr.") qdel(W) return TRUE diff --git a/code/modules/cargo/order.dm b/code/modules/cargo/order.dm index e802bf1aa274..49e01139bd5b 100644 --- a/code/modules/cargo/order.dm +++ b/code/modules/cargo/order.dm @@ -24,6 +24,8 @@ src.orderer_ckey = orderer_ckey src.reason = reason src.paying_account = paying_account + if(pack && paying_account) + SSblackbox.record_feedback("tally", "crate_ordered", 1, pack.name) /datum/supply_order/proc/generateRequisition(turf/T) var/obj/item/paper/requisition_paper = new(T) diff --git a/code/modules/economy/account.dm b/code/modules/economy/account.dm index 4213ae91376b..367b299107e7 100644 --- a/code/modules/economy/account.dm +++ b/code/modules/economy/account.dm @@ -29,7 +29,7 @@ /datum/bank_account/proc/has_money(amt) return account_balance >= amt -/datum/bank_account/proc/adjust_money(amt, reason = "cash") +/datum/bank_account/proc/adjust_money(amt, reason = CREDIT_LOG_WITHDRAW) if((amt < 0 && has_money(-amt)) || amt > 0) SSblackbox.record_feedback("tally", "credits", amt, reason) SSeconomy.bank_money += amt @@ -39,10 +39,10 @@ /datum/bank_account/proc/transfer_money(datum/bank_account/from, amount) if(from.has_money(amount)) - adjust_money(amount, "transfer") + adjust_money(amount, CREDIT_LOG_TRANSFER_IN) SSblackbox.record_feedback("amount", "credits_transferred", amount) log_econ("[amount] credits were transferred from [from.account_holder]'s account to [src.account_holder]") - from.adjust_money(-amount, "transfer_out") + from.adjust_money(-amount, CREDIT_LOG_TRANSFER_OUT) return TRUE return FALSE @@ -83,4 +83,4 @@ /datum/bank_account/ship/New(newname, budget) account_holder = newname - adjust_money(budget, "starting_money") + adjust_money(budget, CREDIT_LOG_STARTING_MONEY) diff --git a/code/modules/economy/pay_stand.dm b/code/modules/economy/pay_stand.dm index 9382a03d062e..1007f25fe40b 100644 --- a/code/modules/economy/pay_stand.dm +++ b/code/modules/economy/pay_stand.dm @@ -54,7 +54,7 @@ if(momsdebitcard < 1) to_chat(user, "ERROR: Invalid amount designated.") return - if(vbucks.registered_account.adjust_money(-momsdebitcard, "transfer")) + if(vbucks.registered_account.adjust_money(-momsdebitcard, CREDIT_LOG_TRANSFER_IN)) purchase(vbucks.registered_account.account_holder, momsdebitcard) to_chat(user, "Thanks for purchasing! The vendor has been informed.") return @@ -117,7 +117,7 @@ return ..() /obj/machinery/paystand/proc/purchase(buyer, price) - my_card.registered_account.adjust_money(price, "transfer") + my_card.registered_account.adjust_money(price, CREDIT_LOG_TRANSFER_IN) my_card.registered_account.bank_card_talk("Purchase made at your vendor by [buyer] for [price] credits.") amount_deposited = amount_deposited + price if(signaler && amount_deposited >= signaler_threshold) diff --git a/code/modules/economy/selling_pad.dm b/code/modules/economy/selling_pad.dm index cf155ad251bd..e70dab4dcb77 100644 --- a/code/modules/economy/selling_pad.dm +++ b/code/modules/economy/selling_pad.dm @@ -36,7 +36,7 @@ /obj/machinery/computer/selling_pad_control/attackby(obj/item/I, mob/user) var/value = I.get_item_credit_value() if(value) - sell_account.adjust_money(value, "selling_pad") + sell_account.adjust_money(value, CREDIT_LOG_SELLING_PAD) to_chat(user, "You deposit [I]. The Vessel Budget is now [sell_account.account_balance] cr.") qdel(I) return TRUE @@ -150,7 +150,7 @@ total_report.total_amount[E] += ex.total_amount[E] total_report.total_value[E] += ex.total_value[E] - sell_account.adjust_money(value, "selling_pad") + sell_account.adjust_money(value, CREDIT_LOG_SELLING_PAD) if(!value) status_report += "Nothing" diff --git a/code/modules/jobs/job_types/_job.dm b/code/modules/jobs/job_types/_job.dm index ee953b0fb74d..0ac783477e79 100644 --- a/code/modules/jobs/job_types/_job.dm +++ b/code/modules/jobs/job_types/_job.dm @@ -123,7 +123,7 @@ return FALSE if(!visualsOnly) var/datum/bank_account/bank_account = new(H.real_name, H.age) - bank_account.adjust_money(officer ? 250 : 100, "starting_money") //just a little bit of money for you + bank_account.adjust_money(officer ? 250 : 100, CREDIT_LOG_STARTING_MONEY) //just a little bit of money for you H.account_id = bank_account.account_id //Equip the rest of the gear diff --git a/code/modules/mob/living/simple_animal/bot/secbot.dm b/code/modules/mob/living/simple_animal/bot/secbot.dm index df2508c5f4a0..1445eab16fbe 100644 --- a/code/modules/mob/living/simple_animal/bot/secbot.dm +++ b/code/modules/mob/living/simple_animal/bot/secbot.dm @@ -40,7 +40,6 @@ var/fair_market_price_arrest = 25 // On arrest, charges the violator this much. If they don't have that much in their account, the securitron will beat them instead var/fair_market_price_detain = 5 // Charged each time the violator is stunned on detain var/weapon_force = 20 // Only used for NAP violation beatdowns on non-grievous securitrons - var/payment_department = ACCOUNT_SEC /mob/living/simple_animal/bot/secbot/beepsky name = "Commander Beep O'sky" diff --git a/code/modules/modular_computers/laptop_vendor.dm b/code/modules/modular_computers/laptop_vendor.dm index b1ec3d3edc16..5ad3a674e334 100644 --- a/code/modules/modular_computers/laptop_vendor.dm +++ b/code/modules/modular_computers/laptop_vendor.dm @@ -254,7 +254,7 @@ var/obj/item/card/bank/ID = I var/datum/bank_account/account = ID.registered_account var/target_credits = total_price - credits - if(!account.adjust_money(-target_credits, "laptop_vendor")) + if(!account.adjust_money(-target_credits, CREDIT_LOG_VENDOR_PURCHASE)) say("Insufficient credits on card to purchase!") return credits += target_credits diff --git a/code/modules/overmap/missions.dm b/code/modules/overmap/missions.dm index 8baff21de865..e484a0d292c0 100644 --- a/code/modules/overmap/missions.dm +++ b/code/modules/overmap/missions.dm @@ -39,6 +39,7 @@ return ..() /datum/mission/proc/accept(datum/overmap/ship/controlled/acceptor, turf/accept_loc) + SSblackbox.record_feedback("tally", "mission_accepted", 1, name) accepted = TRUE servant = acceptor LAZYREMOVE(source_outpost.missions, src) @@ -63,10 +64,13 @@ return ..() /datum/mission/proc/turn_in() - servant.ship_account.adjust_money(value, "mission") + SSblackbox.record_feedback("tally", "mission_succeeded", 1, name) + SSblackbox.record_feedback("tally", "mission_payout", value, name) + servant.ship_account.adjust_money(value, CREDIT_LOG_MISSION) qdel(src) /datum/mission/proc/give_up() + SSblackbox.record_feedback("tally", "mission_abandoned", 1, name) qdel(src) /datum/mission/proc/can_complete() diff --git a/code/modules/overmap/ships/controlled_ship_datum.dm b/code/modules/overmap/ships/controlled_ship_datum.dm index 12782eef4ea0..4305a6b6e8c2 100644 --- a/code/modules/overmap/ships/controlled_ship_datum.dm +++ b/code/modules/overmap/ships/controlled_ship_datum.dm @@ -78,6 +78,7 @@ return FALSE message_admins("[key_name_admin(usr)] renamed vessel '[oldname]' to '[new_name]'") log_admin("[key_name(src)] has renamed vessel '[oldname]' to '[new_name]'") + SSblackbox.record_feedback("text", "ship_renames", 1, new_name) shuttle_port?.name = new_name ship_account.account_holder = new_name if(shipkey) diff --git a/code/modules/vending/_vending.dm b/code/modules/vending/_vending.dm index 67165e33abf6..ee1ff9b15e97 100644 --- a/code/modules/vending/_vending.dm +++ b/code/modules/vending/_vending.dm @@ -815,16 +815,22 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C // else // account.adjust_money(-price_to_use, "vendor_purchase") // SSblackbox.record_feedback("amount", "vending_spent", price_to_use) // CELADON-EDIT - ORIGINAL - var/datum/bank_account/account = C.registered_account - if(price_to_use) - if(account.has_money(price_to_use)) - var/datum/bank_account/owner = private_a - if(owner) - owner.transfer_money(account, price_to_use) - else - account.adjust_money(-price_to_use, "vendor_purchase") - SSblackbox.record_feedback("amount", "vending_spent", price_to_use) + // var/datum/bank_account/account = C.registered_account + // if(price_to_use) + // if(account.has_money(price_to_use)) + // var/datum/bank_account/owner = private_a + // if(owner) + // owner.transfer_money(account, price_to_use) + // else + // account.adjust_money(-price_to_use, "vendor_purchase") + // SSblackbox.record_feedback("amount", "vending_spent", price_to_use) // НАШЕ // [/CELADON-EDIT] + var/datum/bank_account/payment_account = payment_account_ref.resolve() + if(payment_account) + payment_account.transfer_money(account, price_to_use) + else + account.adjust_money(-price_to_use, CREDIT_LOG_VENDOR_PURCHASE) + SSblackbox.record_feedback("amount", "vending_spent", price_to_use) log_econ("[price_to_use] credits were inserted into [src] by [H] to buy [R].") if(last_shopper != REF(usr) || purchase_message_cooldown < world.time) say("Thank you for shopping with [src]!") @@ -1088,7 +1094,7 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C if(owner) owner.transfer_money(account, S.custom_price) else - account.adjust_money(-S.custom_price, "vendor_purchase") + account.adjust_money(-S.custom_price, CREDIT_LOG_VENDOR_PURCHASE) SSblackbox.record_feedback("amount", "vending_spent", S.custom_price) log_econ("[S.custom_price] credits were spent on [src] buying a [S] by [owner.account_holder], owned by [private_a.account_holder].") vending_machine_input[N] = max(vending_machine_input[N] - 1, 0)