Skip to content

Commit

Permalink
ASRS Supply Pools -- Crates Carryover and MessTech supply (#5018)
Browse files Browse the repository at this point in the history
# About the pull request

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

Code refactor aside this has two main effects:
* Adds ASRS supply pools. These are categories of ASRS spawned gear that
run in parallel of each other, that is to say not taking away from the
military operation pool of crates. Right now they're hardcoded to give
only one crate, and send a crate of food ingredients every roughly 30
minutes as proof of concept, to resupply the MessTech.
* Adds smooth scaling to amount of crates given by ASRS. The legacy
formula is `floor(sqrt(xenos/3))` which is rough as for example once the
Xeno count goes below 27 you immediately go from 3 crates awarded to 2.
To provide a more consistent and reliable supply flow, it's no longer
floored - instead the decimal part carries over. **To make up for this,
the divider factor of 3 got increasded to 4, reducing available supply
by effectively around 15%.** It is still expected to be an overall
supply buff and could be increased.

Current supply "curve":

![image](https://github.com/cmss13-devs/cmss13/assets/604624/75a698a3-558c-46ea-b43a-eaa004633560)

overall supply curve with changes:

![image](https://github.com/cmss13-devs/cmss13/assets/604624/c1198694-d483-43c4-89be-6d46185ef1e3)

And the relative effect of both changes to flooring and factor per Xeno
count vs current:

![image](https://github.com/cmss13-devs/cmss13/assets/604624/ab8af08e-488a-4383-adf8-c09c460a9ee5)

# Explain why it's good for the game
As explained above this aims to fix two main issues. 

The first is lack of supply for shipside roles, you have to budget them
which many Reqs won't do - now they can get some supplies regardless.
More can still be ordered as needed. In both cases this is additional
player interaction shipside.

The second is the amount of ASRS crates being highly variable and
dropping off suddenly. Carrying over "partial" crates should give a more
consistent supply flow.

# Testing Photographs and Procedure

![image](https://github.com/cmss13-devs/cmss13/assets/604624/edc14437-7726-431e-aa32-292a76d38c94)

Alternate food pool spawning in in parallel - here with boosted
frequency for testing


# Changelog
:cl:
add: Introduced ASRS supply pools. As proof of concept, ASRS now spawns
a crate of food ingredients every 30 minutes, in addition to regular
gear.
balance: ASRS now keeps track of partial crates awarded. This means if
you should receive 2.5 then 2.5 crates, you now get 2 then 3, rather
than 2 and 2. This is intended to result in smoother, more reliable
transitions and scaling with varying amount of Xenos on map.
balance: Amount of ASRS crates awarded was reduced by about 15.5% to
make up for crates carrying over. Overall this should result in an about
5-10% reduction in highpop crates, and ~10% increase in lowpop. Pop
being based on xeno count.
code: Refactored part of ASRS supply code to be less of a painful,
antique artifact.
fix: Fixed incorrect weighting in the ASRS supply code, effects on crate
distributions are unknown.
fix: Fixed HPR ammo ASRS packs failing to spawn and ending up as MK1s
instead.
fix: Fixed ASRS order numbers not increasing the order IDs... This whole
time..
/:cl:
  • Loading branch information
fira authored Dec 7, 2023
1 parent 69852c0 commit c2ca910
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 168 deletions.
17 changes: 17 additions & 0 deletions code/__DEFINES/supply.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//We use the cost to determine the spawn chance this equals out the crates that spawn later in the round.
#define ASRS_HIGHEST_WEIGHT 0 //warning this weight wont change.
#define ASRS_VERY_HIGH_WEIGHT 5
#define ASRS_HIGH_WEIGHT 15
#define ASRS_MEDIUM_WEIGHT 25
#define ASRS_LOW_WEIGHT 35
#define ASRS_VERY_LOW_WEIGHT 50
#define ASRS_LOWEST_WEIGHT 100

// List of pools of supply packs, rolled individually by the ASRS system
/// Main pool of ASRS supplies, dispensing military supplies such as ammo
#define ASRS_POOL_MAIN "Main"
/// Secondary ASRS pool dispening food related items for MessTech
#define ASRS_POOL_FOOD "Food"

/// Divider to the amount of xeno forces on the planet to ASRS provided crates. It is used as such sqrt(xenos/ASRS_XENO_CRATES_DIVIDER))
#define ASRS_XENO_CRATES_DIVIDER 4
2 changes: 1 addition & 1 deletion code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ SUBSYSTEM_DEF(ticker)
if(GLOB.round_statistics)
to_chat_spaced(world, html = FONT_SIZE_BIG(SPAN_ROLE_BODY("<B>Welcome to [GLOB.round_statistics.round_name]</B>")))

GLOB.supply_controller.process() //Start the supply shuttle regenerating points -- TLE
GLOB.supply_controller.start_processing()

for(var/i in GLOB.closet_list) //Set up special equipment for lockers and vendors, depending on gamemode
var/obj/structure/closet/C = i
Expand Down
146 changes: 62 additions & 84 deletions code/datums/ASRS.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,138 +2,116 @@
//These are non orderable packs that get in automaticly though the ARSR system.
//Note these should never show up to buy and some will only show up later in the round.
//BIG NOTE: Don't add living things to crates, that's bad, it will break the shuttle.
//We use the cost to determine the spawn chance this equals out the crates that spawn later in the round.
#define ASRS_HIGHEST_WEIGHT 0 //warning this weight wont change.
#define ASRS_VERY_HIGH_WEIGHT 5
#define ASRS_HIGH_WEIGHT 15
#define ASRS_MEDIUM_WEIGHT 25
#define ASRS_LOW_WEIGHT 35
#define ASRS_VERY_LOW_WEIGHT 50
#define ASRS_LOWEST_WEIGHT 100


/datum/supply_packs_asrs
/// How likely we are to select this pack over others
var/cost = ASRS_MEDIUM_WEIGHT
/// Which pool of ASRS automatically dispensed supplies this belongs to
var/pool = ASRS_POOL_MAIN
/// What supply pack would this dispense
var/datum/supply_packs/reference_package

//===================================
// Rounds
/datum/supply_packs/ammo_rounds_box_rifle/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_rounds_box_rifle
reference_package = /datum/supply_packs/ammo_rounds_box_rifle
cost = ASRS_MEDIUM_WEIGHT

/datum/supply_packs/ammo_rounds_box_rifle_ap/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_rounds_box_rifle_ap
reference_package = /datum/supply_packs/ammo_rounds_box_rifle_ap
cost = ASRS_LOW_WEIGHT

/datum/supply_packs/ammo_rounds_box_xm88/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_rounds_box_xm88
reference_package = /datum/supply_packs/ammo_rounds_box_xm88
cost = ASRS_LOW_WEIGHT

//===================================
// Magazines
/datum/supply_packs/gun/ammo_hpr/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/gun/ammo_hpr
reference_package = /datum/supply_packs/ammo_hpr
cost = ASRS_LOWEST_WEIGHT

/datum/supply_packs/ammo_m4a3_mag_box/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_m4a3_mag_box
reference_package = /datum/supply_packs/ammo_m4a3_mag_box
cost = ASRS_LOW_WEIGHT

/datum/supply_packs/ammo_m4a3_mag_box_ap/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_m4a3_mag_box_ap
reference_package = /datum/supply_packs/ammo_m4a3_mag_box_ap
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_mag_box/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_mag_box
reference_package = /datum/supply_packs/ammo_mag_box
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_mag_box_ap/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_mag_box_ap
reference_package = /datum/supply_packs/ammo_mag_box_ap

/datum/supply_packs/ammo_m4ra_mag_box/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_m4ra_mag_box
reference_package = /datum/supply_packs/ammo_m4ra_mag_box
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_m4ra_mag_box_ap/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_m4ra_mag_box_ap
reference_package = /datum/supply_packs/ammo_m4ra_mag_box_ap

/datum/supply_packs/ammo_shell_box/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_shell_box
reference_package = /datum/supply_packs/ammo_shell_box
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_shell_box_buck/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_shell_box_buck
reference_package = /datum/supply_packs/ammo_shell_box_buck
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_shell_box_flechette/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_shell_box_flechette
reference_package = /datum/supply_packs/ammo_shell_box_flechette
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_smartgun/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_smartgun
reference_package = /datum/supply_packs/ammo_smartgun

/datum/supply_packs/ammo_napalm/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_napalm
reference_package = /datum/supply_packs/ammo_napalm
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_napalm_gel/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_napalm_gel
reference_package = /datum/supply_packs/ammo_napalm_gel
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ammo_flamer_mixed/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_flamer_mixed
reference_package = /datum/supply_packs/ammo_flamer_mixed
cost = ASRS_VERY_LOW_WEIGHT

//===================================
// Mortar ammo
/datum/supply_packs/ammo_mortar_he/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_mortar_he
reference_package = /datum/supply_packs/ammo_mortar_he

/datum/supply_packs/ammo_mortar_incend/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_mortar_incend
reference_package = /datum/supply_packs/ammo_mortar_incend

/datum/supply_packs/ammo_mortar_flare/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/ammo_mortar_flare
reference_package = /datum/supply_packs/ammo_mortar_flare

//===================================
// Misc supplies
/datum/supply_packs/flares/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/flares
reference_package = /datum/supply_packs/flares
cost = ASRS_LOW_WEIGHT

/datum/supply_packs/mre/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/mre
reference_package = /datum/supply_packs/mre
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/flashlights/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/flashlights
reference_package = /datum/supply_packs/flashlights
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/batteries/asrs
buyable = 0
group = "ASRS"
/datum/supply_packs_asrs/batteries
reference_package = /datum/supply_packs/batteries
cost = ASRS_VERY_LOW_WEIGHT

/datum/supply_packs/ingredient/asrs
buyable = 0
group = "ASRS"
cost = ASRS_LOW_WEIGHT
// ============================
// FOOD POOL - for Mess Tech gradual supplies throughout the round
/datum/supply_packs_asrs/ingredient
reference_package = /datum/supply_packs/ingredient
pool = ASRS_POOL_FOOD
1 change: 0 additions & 1 deletion code/datums/supply_packs/_supply_packs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
var/group = null
var/buyable = 1 ///Can this pack be bought? These packs don't show up at all - they have to be spawned externally (fe: DEFCON ASRS)
var/randomised_num_contained = 0 //Randomly picks X of items out of the contains list instead of using all.
var/iteration_needed = 0
/// How many W-Y dollars are deducted from the supply controller. Only use for contraband.
var/dollar_cost = 0
/// How much "heat" this crate adds, too much heat will send an investigation. Only use for contraband.
Expand Down
6 changes: 0 additions & 6 deletions code/datums/supply_packs/operations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
containername = "OB Ammo Crate (Incendiary x2)"
buyable = 0
group = "Operations"
iteration_needed = null

/datum/supply_packs/ob_explosive
contains = list(
Expand All @@ -48,7 +47,6 @@
containername = "OB Ammo Crate (HE x2)"
buyable = 0
group = "Operations"
iteration_needed = null

/datum/supply_packs/ob_cluster
contains = list(
Expand All @@ -72,7 +70,6 @@
containername = "OB Ammo Crate (Cluster x2)"
buyable = 0
group = "Operations"
iteration_needed = null

/datum/supply_packs/telecommsparts
name = "Replacement Telecommunications Parts"
Expand All @@ -99,15 +96,13 @@
containertype = /obj/structure/machinery/nuclearbomb
buyable = 0
group = "Operations"
iteration_needed = null

/datum/supply_packs/technuclearbomb
name = "Encrypted Operational Nuke"
cost = 0
containertype = /obj/structure/machinery/nuclearbomb/tech
buyable = 0
group = "Operations"
iteration_needed = null

/datum/supply_packs/spec_kits
name = "Weapons Specialist Kits"
Expand All @@ -122,4 +117,3 @@
containername = "weapons specialist kits crate"
buyable = 0
group = "Operations"
iteration_needed = null
Loading

0 comments on commit c2ca910

Please sign in to comment.