From 6355c9917e512dd7de4cfce3cb0972ca899bd2ae Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 17 Dec 2020 08:02:12 +0100 Subject: [PATCH] [MIRROR] Export scanner doesn't need to link + old bounty code is gone (#2197) * Export scanner doesn't need to link + old bounty code is gone (#55504) Removes the Export scanner's need to link with a console and cleans up the old bounty code * Export scanner doesn't need to link + old bounty code is gone Co-authored-by: spessbro <51048066+spessbro@users.noreply.github.com> --- code/modules/cargo/bounties/item.dm | 7 -- code/modules/cargo/bounties/mech.dm | 3 - code/modules/cargo/bounties/reagent.dm | 18 --- code/modules/cargo/bounties/special.dm | 21 ---- code/modules/cargo/bounties/virus.dm | 9 -- code/modules/cargo/bounty.dm | 115 ------------------ code/modules/cargo/export_scanner.dm | 41 ++----- code/modules/cargo/exports.dm | 23 ++-- code/modules/cargo/exports/civilain_bounty.dm | 2 +- code/modules/cargo/exports/organs.dm | 1 - code/modules/cargo/exports/seeds.dm | 2 +- code/modules/cargo/exports/sheets.dm | 3 - code/modules/clothing/neck/_neck.dm | 2 +- code/modules/events/pirates.dm | 5 +- code/modules/shuttle/supply.dm | 6 - 15 files changed, 25 insertions(+), 233 deletions(-) diff --git a/code/modules/cargo/bounties/item.dm b/code/modules/cargo/bounties/item.dm index 1c2331e9f16..b5f4a2dc336 100644 --- a/code/modules/cargo/bounties/item.dm +++ b/code/modules/cargo/bounties/item.dm @@ -24,10 +24,6 @@ wanted_types[i_type] = TRUE wanted_types = string_assoc_list(wanted_types) - -/datum/bounty/item/completion_string() - return {"[shipped_count]/[required_count]"} - /datum/bounty/item/can_claim() return ..() && shipped_count >= required_count @@ -46,6 +42,3 @@ shipped_count += O_is_a_stack.amount else shipped_count += 1 - -/datum/bounty/item/compatible_with(datum/other_bounty) - return type != other_bounty.type diff --git a/code/modules/cargo/bounties/mech.dm b/code/modules/cargo/bounties/mech.dm index 60561b165ac..f80056adb6b 100644 --- a/code/modules/cargo/bounties/mech.dm +++ b/code/modules/cargo/bounties/mech.dm @@ -10,9 +10,6 @@ M.wreckage = null // So the mech doesn't explode. ..() -/datum/bounty/item/mech/mark_high_priority(scale_reward) - return ..(max(scale_reward * 0.7, 1.2)) - /datum/bounty/item/mech/ripleymk2 name = "APLU MK-II \"Ripley\"" reward = CARGO_CRATE_VALUE * 26 diff --git a/code/modules/cargo/bounties/reagent.dm b/code/modules/cargo/bounties/reagent.dm index 49abec1a55d..7d03a8aabe6 100644 --- a/code/modules/cargo/bounties/reagent.dm +++ b/code/modules/cargo/bounties/reagent.dm @@ -3,9 +3,6 @@ var/shipped_volume = 0 var/datum/reagent/wanted_reagent -/datum/bounty/reagent/completion_string() - return {"[round(shipped_volume)]/[required_volume] Units"} - /datum/bounty/reagent/can_claim() return ..() && shipped_volume >= required_volume @@ -25,12 +22,6 @@ if(shipped_volume > required_volume) shipped_volume = required_volume -/datum/bounty/reagent/compatible_with(other_bounty) - if(!istype(other_bounty, /datum/bounty/reagent)) - return TRUE - var/datum/bounty/reagent/R = other_bounty - return wanted_reagent.type != R.wanted_reagent.type - /datum/bounty/reagent/simple_drink name = "Simple Drink" reward = CARGO_CRATE_VALUE * 3 @@ -199,9 +190,6 @@ /// minimum volume of chemical needed, gets randomized on new() var/wanted_vol = 30 -/datum/bounty/pill/completion_string() - return {"[shipped_ammount]/[required_ammount] pills"} - /datum/bounty/pill/can_claim() return ..() && shipped_ammount >= required_ammount @@ -219,12 +207,6 @@ if(shipped_ammount > required_ammount) shipped_ammount = required_ammount -/datum/bounty/pill/compatible_with(other_bounty) - if(!istype(other_bounty, /datum/bounty/pill/simple_pill)) - return TRUE - var/datum/bounty/pill/simple_pill/P = other_bounty - return (wanted_reagent.type == P.wanted_reagent.type) && (wanted_vol == P.wanted_vol) - /datum/bounty/pill/simple_pill name = "Simple Pill" reward = CARGO_CRATE_VALUE * 20 diff --git a/code/modules/cargo/bounties/special.dm b/code/modules/cargo/bounties/special.dm index c5add64ac04..2876492f8fd 100644 --- a/code/modules/cargo/bounties/special.dm +++ b/code/modules/cargo/bounties/special.dm @@ -32,24 +32,3 @@ reward = CARGO_CRATE_VALUE * 2 required_count = 10 wanted_types = list(/obj/item/trash) - -/datum/bounty/more_bounties - name = "More Bounties" - description = "Complete enough bounties and CentCom will issue new ones!" - reward = 5 // number of bounties - var/required_bounties = 5 - -/datum/bounty/more_bounties/can_claim() - return ..() && completed_bounty_count() >= required_bounties - -/datum/bounty/more_bounties/completion_string() - return "[min(required_bounties, completed_bounty_count())]/[required_bounties] Bounties" - -/datum/bounty/more_bounties/reward_string() - return "Up to [reward] new bounties" - -/datum/bounty/more_bounties/claim() - if(can_claim()) - claimed = TRUE - for(var/i = 0; i < reward; ++i) - try_add_bounty(random_bounty()) diff --git a/code/modules/cargo/bounties/virus.dm b/code/modules/cargo/bounties/virus.dm index fad2ee3e538..daa41fbea81 100644 --- a/code/modules/cargo/bounties/virus.dm +++ b/code/modules/cargo/bounties/virus.dm @@ -13,9 +13,6 @@ description = "Nanotrasen is interested in a virus with a [stat_name] stat of exactly [stat_value]. Central Command will pay handsomely for such a virus." reward += rand(0, 4) * CARGO_CRATE_VALUE -/datum/bounty/virus/completion_string() - return shipped ? "Shipped" : "Not Shipped" - /datum/bounty/virus/can_claim() return ..() && shipped @@ -41,12 +38,6 @@ return shipped = TRUE -/datum/bounty/virus/compatible_with(datum/other_bounty) - if(!istype(other_bounty, /datum/bounty/virus)) - return TRUE - var/datum/bounty/virus/V = other_bounty - return type != V.type || stat_value != V.stat_value - /datum/bounty/virus/proc/accepts_virus(V) return TRUE diff --git a/code/modules/cargo/bounty.dm b/code/modules/cargo/bounty.dm index f03f4c75ca0..712cf05f205 100644 --- a/code/modules/cargo/bounty.dm +++ b/code/modules/cargo/bounty.dm @@ -1,5 +1,3 @@ -GLOBAL_LIST_EMPTY(bounties_list) - /datum/bounty var/name var/description @@ -7,14 +5,6 @@ GLOBAL_LIST_EMPTY(bounties_list) var/claimed = FALSE var/high_priority = FALSE -/// Displayed on bounty UI screen. -/datum/bounty/proc/completion_string() - return "" - -/// Displayed on bounty UI screen. -/datum/bounty/proc/reward_string() - return "[reward] Credits" - /datum/bounty/proc/can_claim() return !claimed @@ -34,49 +24,6 @@ GLOBAL_LIST_EMPTY(bounties_list) /datum/bounty/proc/ship(obj/O) return -/** When randomly generating the bounty list, duplicate bounties must be avoided. - * This proc is used to determine if two bounties are duplicates, or incompatible in general. - */ -/datum/bounty/proc/compatible_with(other_bounty) - return TRUE - -/datum/bounty/proc/mark_high_priority(scale_reward = 2) - if(high_priority) - return - high_priority = TRUE - reward = round(reward * scale_reward) - -/** This proc is called when the shuttle docks at CentCom. - * It handles items shipped for bounties. - */ -/proc/bounty_ship_item_and_contents(atom/movable/AM, dry_run=FALSE) - if(!GLOB.bounties_list.len) - setup_bounties() - - var/list/matched_one = FALSE - for(var/thing in reverseRange(AM.GetAllContents())) - var/matched_this = FALSE - for(var/datum/bounty/B in GLOB.bounties_list) - if(B.applies_to(thing)) - matched_one = TRUE - matched_this = TRUE - if(!dry_run) - B.ship(thing) - if(!dry_run && matched_this) - qdel(thing) - return matched_one - -/// Returns FALSE if the bounty is incompatible with the current bounties. -/proc/try_add_bounty(datum/bounty/new_bounty) - if(!new_bounty || !new_bounty.name || !new_bounty.description) - return FALSE - for(var/i in GLOB.bounties_list) - var/datum/bounty/B = i - if(!B.compatible_with(new_bounty) || !new_bounty.compatible_with(B)) - return FALSE - GLOB.bounties_list += new_bounty - return TRUE - /** Returns a new bounty of random type, but does not add it to GLOB.bounties_list. * * *Guided determines what specific catagory of bounty should be chosen. @@ -130,65 +77,3 @@ GLOBAL_LIST_EMPTY(bounties_list) var/subtype = pick(subtypesof(/datum/bounty/item/botany)) return new subtype -// Called lazily at startup to populate GLOB.bounties_list with random bounties. -/proc/setup_bounties() - - var/pick // instead of creating it a bunch let's go ahead and toss it here, we know we're going to use it for dynamics and subtypes! - - /********************************Subtype Gens********************************/ - var/list/easy_add_list_subtypes = list(/datum/bounty/item/assistant = 2, - /datum/bounty/item/mech = 1, - /datum/bounty/item/chef = 2, - /datum/bounty/item/security = 1, - /datum/bounty/virus = 1, - /datum/bounty/item/engineering = 1, - /datum/bounty/item/mining = 2, - /datum/bounty/item/medical = 2, - /datum/bounty/item/botany = 2) - - for(var/the_type in easy_add_list_subtypes) - for(var/i in 1 to easy_add_list_subtypes[the_type]) - pick = pick(subtypesof(the_type)) - try_add_bounty(new pick) - - /********************************Strict Type Gens********************************/ - var/list/easy_add_list_strict_types = list(/datum/bounty/reagent/simple_drink = 1, - /datum/bounty/reagent/complex_drink = 1, - /datum/bounty/reagent/chemical_simple = 1, - /datum/bounty/reagent/chemical_complex = 1, - /datum/bounty/pill/simple_pill = 1) - - for(var/the_strict_type in easy_add_list_strict_types) - for(var/i in 1 to easy_add_list_strict_types[the_strict_type]) - try_add_bounty(new the_strict_type) - - /********************************Dynamic Gens********************************/ - - for(var/i in 0 to 1) - if(prob(50)) - pick = pick(subtypesof(/datum/bounty/item/slime)) - else - pick = pick(subtypesof(/datum/bounty/item/science)) - try_add_bounty(new pick) - - /********************************Cutoff for Non-Low Priority Bounties********************************/ - var/datum/bounty/B = pick(GLOB.bounties_list) - B.mark_high_priority() - - /********************************Low Priority Gens********************************/ - var/list/low_priority_strict_type_list = list( /datum/bounty/item/alien_organs, - /datum/bounty/item/syndicate_documents, - /datum/bounty/item/adamantine, - /datum/bounty/item/trash, - /datum/bounty/more_bounties) - - for(var/low_priority_bounty in low_priority_strict_type_list) - try_add_bounty(new low_priority_bounty) - -/proc/completed_bounty_count() - var/count = 0 - for(var/i in GLOB.bounties_list) - var/datum/bounty/B = i - if(B.claimed) - ++count - return count diff --git a/code/modules/cargo/export_scanner.dm b/code/modules/cargo/export_scanner.dm index 071929052bc..048a4429033 100644 --- a/code/modules/cargo/export_scanner.dm +++ b/code/modules/cargo/export_scanner.dm @@ -1,6 +1,6 @@ /obj/item/export_scanner name = "export scanner" - desc = "A device used to check objects against Nanotrasen exports and bounty database." + desc = "A device used to check objects against Nanotrasen exports database." icon = 'icons/obj/device.dmi' icon_state = "export_scanner" inhand_icon_state = "radio" @@ -8,38 +8,19 @@ righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi' item_flags = NOBLUDGEON w_class = WEIGHT_CLASS_SMALL - siemens_coefficient = 1 - var/obj/machinery/computer/cargo/cargo_console = null - -/obj/item/export_scanner/examine(user) - . = ..() - if(!cargo_console) - . += "[src] is not currently linked to a cargo console." /obj/item/export_scanner/afterattack(obj/O, mob/user, proximity) . = ..() if(!istype(O) || !proximity) return - - if(istype(O, /obj/machinery/computer/cargo)) - var/obj/machinery/computer/cargo/C = O - if(!C.requestonly) - cargo_console = C - to_chat(user, "Scanner linked to [C].") - else if(!istype(cargo_console)) - to_chat(user, "You must link [src] to a cargo console first!") + // Before you fix it: + // yes, checking manifests is a part of intended functionality. + + var/datum/export_report/ex = export_item_and_contents(O, dry_run=TRUE) + var/price = 0 + for(var/x in ex.total_amount) + price += ex.total_value[x] + if(price) + to_chat(user, "Scanned [O], value: [price] credits[O.contents.len ? " (contents included)" : ""].") else - // Before you fix it: - // yes, checking manifests is a part of intended functionality. - - var/datum/export_report/ex = export_item_and_contents(O, cargo_console.get_export_categories(), dry_run=TRUE) - var/price = 0 - for(var/x in ex.total_amount) - price += ex.total_value[x] - - if(price) - to_chat(user, "Scanned [O], value: [price] credits[O.contents.len ? " (contents included)" : ""].") - else - to_chat(user, "Scanned [O], no export value.") - if(bounty_ship_item_and_contents(O, dry_run=TRUE)) - to_chat(user, "Scanned item is eligible for one or more bounties.") + to_chat(user, "Scanned [O], no export value.") diff --git a/code/modules/cargo/exports.dm b/code/modules/cargo/exports.dm index 9db1ec2832e..a58894544d8 100644 --- a/code/modules/cargo/exports.dm +++ b/code/modules/cargo/exports.dm @@ -27,7 +27,7 @@ Then the player gets the profit from selling his own wasted time. var/list/exported_atoms_ref = list() //if they're not deleted they go in here for use. // external_report works as "transaction" object, pass same one in if you're doing more than one export in single go -/proc/export_item_and_contents(atom/movable/AM, allowed_categories = EXPORT_CARGO, apply_elastic = TRUE, delete_unsold = TRUE, dry_run=FALSE, datum/export_report/external_report) +/proc/export_item_and_contents(atom/movable/AM, apply_elastic = TRUE, delete_unsold = TRUE, dry_run=FALSE, datum/export_report/external_report) if(!GLOB.exports_list.len) setupExports() @@ -50,8 +50,8 @@ Then the player gets the profit from selling his own wasted time. for(var/datum/export/E in GLOB.exports_list) if(!E) continue - if(E.applies_to(thing, allowed_categories, apply_elastic)) - sold = E.sell_object(thing, report, dry_run, allowed_categories , apply_elastic, profit_ratio) + if(E.applies_to(thing, apply_elastic)) + sold = E.sell_object(thing, report, dry_run, apply_elastic, profit_ratio) report.exported_atoms += " [thing.name]" if(!QDELETED(thing)) report.exported_atoms_ref += thing @@ -75,8 +75,7 @@ Then the player gets the profit from selling his own wasted time. //cost includes elasticity, this does not. var/init_cost - //All these need to be present in export call parameter for this to apply. - var/export_category = EXPORT_CARGO + /datum/export/New() ..() @@ -96,7 +95,7 @@ Then the player gets the profit from selling his own wasted time. cost = init_cost // Checks the cost. 0 cost items are skipped in export. -/datum/export/proc/get_cost(obj/O, allowed_categories = NONE, apply_elastic = TRUE) +/datum/export/proc/get_cost(obj/O, apply_elastic = TRUE) var/amount = get_amount(O) if(apply_elastic) if(k_elasticity!=0) @@ -112,14 +111,12 @@ Then the player gets the profit from selling his own wasted time. return 1 // Checks if the item is fit for export datum. -/datum/export/proc/applies_to(obj/O, allowed_categories = NONE, apply_elastic = TRUE) - if((allowed_categories & export_category) != export_category) - return FALSE +/datum/export/proc/applies_to(obj/O, apply_elastic = TRUE) if(!is_type_in_typecache(O, export_types)) return FALSE if(include_subtypes && is_type_in_typecache(O, exclude_types)) return FALSE - if(!get_cost(O, allowed_categories , apply_elastic)) + if(!get_cost(O, apply_elastic)) return FALSE if(O.flags_1 & HOLOGRAM_1) return FALSE @@ -133,9 +130,9 @@ Then the player gets the profit from selling his own wasted time. * get_cost, get_amount and applies_to do not neccesary mean a successful sale. * */ -/datum/export/proc/sell_object(obj/O, datum/export_report/report, dry_run = TRUE, allowed_categories = EXPORT_CARGO , apply_elastic = TRUE) +/datum/export/proc/sell_object(obj/O, datum/export_report/report, dry_run = TRUE, apply_elastic = TRUE) ///This is the value of the object, as derived from export datums. - var/the_cost = get_cost(O, allowed_categories , apply_elastic) + var/the_cost = get_cost(O, apply_elastic) ///Quantity of the object in question. var/amount = get_amount(O) ///Utilized in the pricetag component. Splits the object's profit when it has a pricetag by the specified amount. @@ -144,7 +141,7 @@ Then the player gets the profit from selling his own wasted time. if(amount <=0 || the_cost <=0) return FALSE if(dry_run == FALSE) - if(SEND_SIGNAL(O, COMSIG_ITEM_SOLD, item_value = get_cost(O, allowed_categories , apply_elastic)) & COMSIG_ITEM_SPLIT_VALUE) + if(SEND_SIGNAL(O, COMSIG_ITEM_SOLD, item_value = get_cost(O, apply_elastic)) & COMSIG_ITEM_SPLIT_VALUE) profit_ratio = SEND_SIGNAL(O, COMSIG_ITEM_SPLIT_PROFIT_DRY) the_cost = the_cost * ((100 - profit_ratio) * 0.01) else diff --git a/code/modules/cargo/exports/civilain_bounty.dm b/code/modules/cargo/exports/civilain_bounty.dm index 3d443fbad02..3062694becd 100644 --- a/code/modules/cargo/exports/civilain_bounty.dm +++ b/code/modules/cargo/exports/civilain_bounty.dm @@ -4,5 +4,5 @@ unit_name = "completed bounty cube" export_types = list(/obj/item/bounty_cube) -/datum/export/bounty_box/get_cost(obj/item/bounty_cube/cube, allowed_categories, apply_elastic) +/datum/export/bounty_box/get_cost(obj/item/bounty_cube/cube, apply_elastic) return cube.bounty_value diff --git a/code/modules/cargo/exports/organs.dm b/code/modules/cargo/exports/organs.dm index 771c783ce10..d3a877061c2 100644 --- a/code/modules/cargo/exports/organs.dm +++ b/code/modules/cargo/exports/organs.dm @@ -1,6 +1,5 @@ /datum/export/organ include_subtypes = FALSE //CentCom doesn't need organs from non-humans. - export_category = EXPORT_CONTRABAND /datum/export/organ/heart cost = CARGO_CRATE_VALUE * 0.2 //For the man who has everything and nothing. diff --git a/code/modules/cargo/exports/seeds.dm b/code/modules/cargo/exports/seeds.dm index a6b505d4d7b..067ee6af8b8 100644 --- a/code/modules/cargo/exports/seeds.dm +++ b/code/modules/cargo/exports/seeds.dm @@ -14,7 +14,7 @@ return 0 return ..() * S.rarity // That's right, no bonus for potency. Send a crappy sample first to "show improvement" later. -/datum/export/seed/sell_object(obj/O, datum/export_report/report, dry_run, allowed_categories, apply_elastic) +/datum/export/seed/sell_object(obj/O, datum/export_report/report, dry_run, apply_elastic) . = ..() if(. && !dry_run) var/obj/item/seeds/S = O diff --git a/code/modules/cargo/exports/sheets.dm b/code/modules/cargo/exports/sheets.dm index b6ad34571f5..aa88cafd792 100644 --- a/code/modules/cargo/exports/sheets.dm +++ b/code/modules/cargo/exports/sheets.dm @@ -16,7 +16,6 @@ /datum/export/stack/skin/human cost = CARGO_CRATE_VALUE * 0.5 - export_category = EXPORT_CONTRABAND unit_name = "piece" message = "of human skin" export_types = list(/obj/item/stack/sheet/animalhide/human) @@ -28,13 +27,11 @@ /datum/export/stack/skin/cat cost = CARGO_CRATE_VALUE * 0.75 - export_category = EXPORT_CONTRABAND unit_name = "cat hide" export_types = list(/obj/item/stack/sheet/animalhide/cat) /datum/export/stack/skin/corgi cost = CARGO_CRATE_VALUE - export_category = EXPORT_CONTRABAND unit_name = "corgi hide" export_types = list(/obj/item/stack/sheet/animalhide/corgi) diff --git a/code/modules/clothing/neck/_neck.dm b/code/modules/clothing/neck/_neck.dm index 71142d8c2f3..ec80b053499 100644 --- a/code/modules/clothing/neck/_neck.dm +++ b/code/modules/clothing/neck/_neck.dm @@ -208,7 +208,7 @@ . = ..() if(!proximity) return - var/datum/export_report/ex = export_item_and_contents(I, allowed_categories = (ALL), dry_run=TRUE) + var/datum/export_report/ex = export_item_and_contents(I, dry_run=TRUE) var/price = 0 for(var/x in ex.total_amount) price += ex.total_value[x] diff --git a/code/modules/events/pirates.dm b/code/modules/events/pirates.dm index 731a2c05e89..6a4f3e16ead 100644 --- a/code/modules/events/pirates.dm +++ b/code/modules/events/pirates.dm @@ -328,7 +328,7 @@ for(var/atom/movable/AM in get_turf(pad)) if(AM == pad) continue - export_item_and_contents(AM, EXPORT_PIRATE | EXPORT_CARGO | EXPORT_CONTRABAND | EXPORT_EMAG, apply_elastic = FALSE, dry_run = TRUE, external_report = ex) + export_item_and_contents(AM, apply_elastic = FALSE, dry_run = TRUE, external_report = ex) for(var/datum/export/E in ex.total_amount) status_report += E.total_printout(ex,notes = FALSE) @@ -398,9 +398,6 @@ pad.icon_state = pad.idle_state deltimer(sending_timer) -/datum/export/pirate - export_category = EXPORT_PIRATE - //Attempts to find the thing on station /datum/export/pirate/proc/find_loot() return diff --git a/code/modules/shuttle/supply.dm b/code/modules/shuttle/supply.dm index 502d0a9a222..94e8fdfc8bb 100644 --- a/code/modules/shuttle/supply.dm +++ b/code/modules/shuttle/supply.dm @@ -195,7 +195,6 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( setupExports() var/msg = "" - var/matched_bounty = FALSE var/datum/export_report/ex = new @@ -204,17 +203,12 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( for(var/atom/movable/AM in shuttle_area) if(iscameramob(AM)) continue - if(bounty_ship_item_and_contents(AM, dry_run = FALSE)) - matched_bounty = TRUE if(!AM.anchored || istype(AM, /obj/vehicle/sealed/mecha)) export_item_and_contents(AM, export_categories , dry_run = FALSE, external_report = ex) if(ex.exported_atoms) ex.exported_atoms += "." //ugh - if(matched_bounty) - msg += "Bounty items received. An update has been sent to all bounty consoles. " - for(var/datum/export/E in ex.total_amount) var/export_text = E.total_printout(ex) if(!export_text)