Skip to content

Commit

Permalink
[MIRROR] Export scanner no longer shows shipping manifest value + man…
Browse files Browse the repository at this point in the history
…ifest error changes [MDB IGNORE] (#24478)

* Export scanner no longer shows shipping manifest value + manifest error changes (#78923)

## About The Pull Request

Adds a variable to exports called `scannable`. If you are trying to scan
it and its set to false, then it won't show the value. When the actual
sale is done, the value will still be added/subtracted.

I also reorganized the message the scanner sends because I didn't want
to put multiple inline if statements.

Lastly, made it so that locked crates and private order lockboxes can't
get the shipping manifest contents error by adding a new trait
`TRAIT_NO_MANIFEST_CONTENTS_ERROR`. For departmental orders, I just
entirely disabled the manifests having errors by setting it to
`MANIFEST_CAN_FAIL` to false.

This PR conflicts with #78911, sorry but that PR was what reminded me to
fix this bug.

## Why It's Good For The Game

Some may call it tedium but having to read paperwork is part of the
cargo experience. Since it is harder to determine the crates value,
there has been a few balance changes. The penalty for incorrect manifest
is half the crates price or 500 credits, whichever is less.

![image](https://github.com/tgstation/tgstation/assets/47338680/b7549d11-eb49-43a2-8bb2-70ca8817e04d)

Let me know if you have any suggestions for how the message is worded,
it might be too long.

Locked crates and private orders can no longer get the shipping manifest
contents error because it is basically impossible to get someone to tell
you all the contents of their purchase. It's only a 5% chance of being
wrong and if they're not in cargo they probably don't care about the
cargo budget.

## Changelog
:cl:
balance: Export scanner no longer shows value of shipping manifests, now
you actually have to read them.
balance: Shipping manifest penalty is now only half crate cost as well
as capped to 500 credits.
balance: Shipping manifests for private orders or locked crates can no
longer have the incorrect contents error. Shipping manifests for
departmental orders can n longer have any error.
/:cl:

---------

Co-authored-by: Jacquerel <hnevard@ gmail.com>
Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>

* Export scanner no longer shows shipping manifest value + manifest error changes

---------

Co-authored-by: BlueMemesauce <[email protected]>
Co-authored-by: Jacquerel <hnevard@ gmail.com>
Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>
  • Loading branch information
4 people authored and FFMirrorBot committed Oct 21, 2023
1 parent 524d40b commit a500843
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 24 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/station.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@

/// The data file that future station traits forced by an admin are stored in
#define FUTURE_STATION_TRAITS_FILE "data/future_station_traits.json"

/// The amount of time until the station charter can no longer be used to rename the station
#define STATION_RENAME_TIME_LIMIT 5 MINUTES
4 changes: 3 additions & 1 deletion code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,10 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
// cargo traits
///If the item will block the cargo shuttle from flying to centcom
#define TRAIT_BANNED_FROM_CARGO_SHUTTLE "banned_from_cargo_shuttle"
///If the item's contents are immune to the missing item manifest error
///If the crate's contents are immune to the missing item manifest error
#define TRAIT_NO_MISSING_ITEM_ERROR "no_missing_item_error"
///If the crate is immune to the wrong content in manifest error
#define TRAIT_NO_MANIFEST_CONTENTS_ERROR "no_manifest_contents_error"

///SSeconomy trait, if the market is crashing and people can't withdraw credits from ID cards.
#define TRAIT_MARKET_CRASHING "market_crashing"
Expand Down
4 changes: 0 additions & 4 deletions code/game/objects/items/charter.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define STATION_RENAME_TIME_LIMIT 3000

/obj/item/station_charter
name = "station charter"
icon = 'icons/obj/scrolls.dmi'
Expand Down Expand Up @@ -119,5 +117,3 @@
SSblackbox.record_feedback("text", "station_renames", 1, "[station_name()]")
if(!unlimited_uses)
used = TRUE

#undef STATION_RENAME_TIME_LIMIT
1 change: 1 addition & 0 deletions code/game/objects/items/storage/lockbox.dm
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
. = ..()
buyer_account = _buyer_account
ADD_TRAIT(src, TRAIT_NO_MISSING_ITEM_ERROR, TRAIT_GENERIC)
ADD_TRAIT(src, TRAIT_NO_MANIFEST_CONTENTS_ERROR, TRAIT_GENERIC)

//SKYRAT EDIT START
if(istype(buyer_account, /datum/bank_account/department))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/obj/structure/closet/crate/secure/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_NO_MISSING_ITEM_ERROR, TRAIT_GENERIC)
ADD_TRAIT(src, TRAIT_NO_MANIFEST_CONTENTS_ERROR, TRAIT_GENERIC)

/obj/structure/closet/crate/secure/take_damage(damage_amount, damage_type = BRUTE, damage_flag = "", sound_effect = TRUE, attack_dir, armour_penetration = 0)
if(prob(tamperproof) && damage_amount >= DAMAGE_PRECISION)
Expand Down
12 changes: 11 additions & 1 deletion code/modules/cargo/department_order.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,17 @@ GLOBAL_LIST_INIT(department_order_cooldowns, list(
say("ERROR: No more then [CARGO_MAX_ORDER] of any pack may be ordered at once")
return

department_order = new(pack, name, rank, ckey, "", null, chosen_delivery_area, null)
department_order = new(
pack = pack,
orderer = name,
orderer_rank = rank,
orderer_ckey = ckey,
reason = "",
paying_account = null,
department_destination = chosen_delivery_area,
coupon = null,
manifest_can_fail = FALSE,
)
SSshuttle.shopping_list += department_order
if(!already_signalled)
RegisterSignal(SSshuttle, COMSIG_SUPPLY_SHUTTLE_BUY, PROC_REF(finalize_department_order))
Expand Down
8 changes: 8 additions & 0 deletions code/modules/cargo/exports.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Then the player gets the profit from selling his own wasted time.
var/list/total_amount = list()
///export instance => total value of sold objects
var/list/total_value = list()
///set to false if any objects in a dry run were unscannable
var/all_contents_scannable = TRUE

/*
* Handles exporting a movable atom and its contents
Expand Down Expand Up @@ -56,6 +58,10 @@ Then the player gets the profit from selling his own wasted time.
if(export.applies_to(thing, apply_elastic))
if(!dry_run && (SEND_SIGNAL(thing, COMSIG_ITEM_PRE_EXPORT) & COMPONENT_STOP_EXPORT))
break
//Don't add value of unscannable items for a dry run report
if(dry_run && !export.scannable)
report.all_contents_scannable = FALSE
break
sold = export.sell_object(thing, report, dry_run, apply_elastic)
report.exported_atoms += " [thing.name]"
break
Expand Down Expand Up @@ -89,6 +95,8 @@ Then the player gets the profit from selling his own wasted time.
var/include_subtypes = TRUE
/// Types excluded from export
var/list/exclude_types = list()
/// Set to false if the cost shouldn't be determinable by an export scanner
var/scannable = TRUE

/// cost includes elasticity, this does not.
var/init_cost
Expand Down
19 changes: 13 additions & 6 deletions code/modules/cargo/exports/manifest.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#define MAX_MANIFEST_PENALTY CARGO_CRATE_VALUE * 2.5

// Approved manifest.
// +80 credits flat.
/datum/export/manifest_correct
cost = CARGO_CRATE_VALUE * 0.4
k_elasticity = 0
unit_name = "approved manifest"
export_types = list(/obj/item/paper/fluff/jobs/cargo/manifest)
scannable = FALSE

/datum/export/manifest_correct/applies_to(obj/O)
if(!..())
Expand All @@ -16,12 +19,13 @@
return FALSE

// Correctly denied manifest.
// Refunds the package cost minus the cost of crate.
// Refunds package cost minus the value of the crate.
/datum/export/manifest_error_denied
cost = -CARGO_CRATE_VALUE
k_elasticity = 0
unit_name = "correctly denied manifest"
export_types = list(/obj/item/paper/fluff/jobs/cargo/manifest)
scannable = FALSE

/datum/export/manifest_error_denied/applies_to(obj/O)
if(!..())
Expand All @@ -38,12 +42,13 @@


// Erroneously approved manifest.
// Substracts the package cost.
// Subtracts half the package cost. (max -500 credits)
/datum/export/manifest_error
unit_name = "erroneously approved manifest"
k_elasticity = 0
export_types = list(/obj/item/paper/fluff/jobs/cargo/manifest)
allow_negative_cost = TRUE
scannable = FALSE

/datum/export/manifest_error/applies_to(obj/O)
if(!..())
Expand All @@ -56,17 +61,17 @@

/datum/export/manifest_error/get_cost(obj/O)
var/obj/item/paper/fluff/jobs/cargo/manifest/M = O
return -M.order_cost
return -min(M.order_cost * 0.5, MAX_MANIFEST_PENALTY)


// Erroneously denied manifest.
// Substracts the package cost minus the cost of crate.
// Subtracts half the package cost. (max -500 credits)
/datum/export/manifest_correct_denied
cost = -CARGO_CRATE_VALUE
k_elasticity = 0
unit_name = "erroneously denied manifest"
export_types = list(/obj/item/paper/fluff/jobs/cargo/manifest)
allow_negative_cost = TRUE
scannable = FALSE

/datum/export/manifest_correct_denied/applies_to(obj/O)
if(!..())
Expand All @@ -79,4 +84,6 @@

/datum/export/manifest_correct_denied/get_cost(obj/O)
var/obj/item/paper/fluff/jobs/cargo/manifest/M = O
return ..() - M.order_cost
return -min(M.order_cost * 0.5, MAX_MANIFEST_PENALTY)

#undef MAX_MANIFEST_PENALTY
18 changes: 11 additions & 7 deletions code/modules/cargo/order.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
if(!manifest_can_fail)
return

if(prob(MANIFEST_ERROR_CHANCE))
if(prob(MANIFEST_ERROR_CHANCE) && (world.time-SSticker.round_start_time > STATION_RENAME_TIME_LIMIT)) //Too confusing if station name gets changed
errors |= MANIFEST_ERROR_NAME
investigate_log("Supply order #[order_id] generated a manifest with an incorrect station name.", INVESTIGATE_CARGO)
if(prob(MANIFEST_ERROR_CHANCE))
errors |= MANIFEST_ERROR_CONTENTS
investigate_log("Supply order #[order_id] generated a manifest missing listed contents.", INVESTIGATE_CARGO)
if(prob(MANIFEST_ERROR_CHANCE))
else if(prob(MANIFEST_ERROR_CHANCE)) //Content and item errors could remove the same items, so only one at a time
errors |= MANIFEST_ERROR_ITEM
investigate_log("Supply order #[order_id] generated with incorrect contents shipped.", INVESTIGATE_CARGO)

Expand Down Expand Up @@ -136,11 +136,15 @@
for(var/atom/movable/AM in container.contents - manifest_paper)
container_contents[AM.name]++
if((manifest_paper.errors & MANIFEST_ERROR_CONTENTS) && container_contents)
for(var/i = 1 to rand(1, round(container.contents.len * 0.5))) // Remove anywhere from one to half of the items
var/missing_item = pick(container_contents)
container_contents[missing_item]--
if(container_contents[missing_item] == 0) // To avoid 0s and negative values on the manifest
container_contents -= missing_item
if(HAS_TRAIT(container, TRAIT_NO_MANIFEST_CONTENTS_ERROR))
manifest_paper.errors &= ~MANIFEST_ERROR_CONTENTS
else
for(var/iteration in 1 to rand(1, round(container.contents.len * 0.5))) // Remove anywhere from one to half of the items
var/missing_item = pick(container_contents)
container_contents[missing_item]--
if(container_contents[missing_item] == 0) // To avoid 0s and negative values on the manifest
container_contents -= missing_item


for(var/item in container_contents)
manifest_text += "<li> [container_contents[item]] [item][container_contents[item] == 1 ? "" : "s"]</li>"
Expand Down
32 changes: 27 additions & 5 deletions code/modules/cargo/universal_scanner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,39 @@
* Scans an object, target, and provides it's export value based on selling to the cargo shuttle, to mob/user.
*/
/obj/item/universal_scanner/proc/export_scan(obj/target, mob/user)
// Before you fix it:
// yes, checking manifests is a part of intended functionality.
var/datum/export_report/report = export_item_and_contents(target, dry_run = TRUE)
var/price = 0
for(var/exported_datum in report.total_amount)
price += report.total_value[exported_datum]

var/message = "Scanned [target]"
var/warning = FALSE
if(length(target.contents))
message = "Scanned [target] and its contents"
if(price)
message += ", total value: <b>[price]</b> credits"
else
message += ", no export values"
warning = TRUE
if(!report.all_contents_scannable)
message += " (Undeterminable value detected, final value may differ)"
message += "."
else
if(!report.all_contents_scannable)
message += ", unable to determine value."
warning = TRUE
else if(price)
message += ", value: <b>[price]</b> credits."
else
message += ", no export value."
warning = TRUE
if(warning)
to_chat(user, span_warning(message))
else
to_chat(user, span_notice(message))

if(price)
to_chat(user, span_notice("Scanned [target], value: <b>[price]</b> credits[target.contents.len ? " (contents included)" : ""]."))
playsound(src, 'sound/machines/terminal_select.ogg', 50, vary = TRUE)
else
to_chat(user, span_warning("Scanned [target], no export value."))

if(ishuman(user))
var/mob/living/carbon/human/scan_human = user
Expand Down

0 comments on commit a500843

Please sign in to comment.