Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Latejoin scaling to Vendors and ASRS #4939

Merged
merged 29 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b642244
Adds latejoin scaling to vendors
fira Nov 16, 2023
cd273c2
fixes
fira Nov 16, 2023
4099d46
fix OD linter oopsie
fira Nov 16, 2023
d208459
reduce ASRS points
fira Nov 16, 2023
2278042
further nerf reqs. :(((
fira Nov 17, 2023
05e636d
unscrews ASRS buget. woops.
fira Nov 17, 2023
5fedd54
Merge branch 'master' into f-smooth-vendors-scaling
fira Nov 24, 2023
9226294
buff powerloader cert apperance rate so it needs 66 players instead o…
fira Nov 24, 2023
44eae50
Merge branch 'master' into f-smooth-vendors-scaling
fira Nov 25, 2023
21c34ae
nerf latejoin scaling to 60%
fira Nov 26, 2023
3b0b252
globbification fixes
fira Nov 27, 2023
fd7a1a8
one more
fira Nov 27, 2023
9defeb7
missed one again..
fira Nov 27, 2023
ad92ca3
Merge branch 'master' into f-smooth-vendors-scaling
fira Nov 28, 2023
9e71b28
fixes prep attachies vendor scaling conflicted
fira Nov 28, 2023
a62125d
DEBUG
fira Dec 1, 2023
1ddb7d6
buff roundstart due to bugfix nerfs
fira Dec 1, 2023
71da1cf
iteration - diminishing latejoin returns by time
fira Dec 1, 2023
19f1fb3
fix
fira Dec 1, 2023
da3cc84
--debug
fira Dec 2, 2023
e962b23
WAY TOO MUCH
fira Dec 2, 2023
c6ab800
going nuclear
fira Dec 2, 2023
b693043
further nerf vendor scaling i guess. we'll gettem boys...
fira Dec 2, 2023
7dca3f9
buff roundstart nerf latejoin :(
fira Dec 2, 2023
6aa416c
Jsut keep testing like this
fira Dec 2, 2023
8df1d4e
buff back up 33.3%... we'll get there eventually i swear
fira Dec 2, 2023
4b8fd02
eventually............
fira Dec 2, 2023
98a822d
machete pouch buff
fira Dec 2, 2023
23c24bc
Merge branch 'master' into f-smooth-vendors-scaling
realforest2001 Dec 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__DEFINES/mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@


//Number of marine players against which the Marine's gear scales
#define MARINE_GEAR_SCALING_NORMAL 30
#define MARINE_GEAR_SCALING_NORMAL 40

#define RESOURCE_NODE_SCALE 95 //How many players minimum per extra set of resource nodes
#define RESOURCE_NODE_QUANTITY_PER_POP 11 //How many resources total per pop
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/vendors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@
//Whether or not to load ammo boxes depending on ammo loaded into the vendor
//Only relevant in big vendors, like Requisitions or Squad Prep
#define VEND_LOAD_AMMO_BOXES (1<<9)
/// Vendors with this flag will fill retroactively based on latejoining players,
/// and expect a scale multiplier instead of amount of items
#define VEND_STOCK_DYNAMIC (1<<10)
35 changes: 28 additions & 7 deletions code/game/gamemodes/cm_initialize.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Additional game mode variables.
var/list/monkey_types = list() //What type of monkeys do we spawn
var/latejoin_tally = 0 //How many people latejoined Marines
var/latejoin_larva_drop = LATEJOIN_MARINES_PER_LATEJOIN_LARVA //A larva will spawn in once the tally reaches this level. If set to 0, no latejoin larva drop
/// Amount of latejoin_tally already awarded as larvas
var/latejoin_larva_used = 0
/// Multiplier to the amount of gear awarded so far - increases only
var/gear_scale = 1
/// Roundstart gear scale to base off current gear_scale, for latejoin calculations
var/gear_scale_init = 1

//Role Authority set up.
/// List of role titles to override to different roles when starting game
Expand Down Expand Up @@ -914,23 +920,38 @@ Additional game mode variables.

//We do NOT want to initilialize the gear before everyone is properly spawned in
/datum/game_mode/proc/initialize_post_marine_gear_list()
var/scale = get_scaling_value()
init_gear_scale()

//Set up attachment vendor contents related to Marine count
for(var/i in GLOB.cm_vending_vendors)
var/obj/structure/machinery/cm_vending/sorted/CVS = i
CVS.populate_product_list_and_boxes(scale)
CVS.populate_product_list_and_boxes(gear_scale)

//Scale the amount of cargo points through a direct multiplier
supply_controller.points = round(supply_controller.points * scale)
supply_controller.points += round(supply_controller.points_scale * gear_scale)

/datum/game_mode/proc/get_scaling_value()
///Returns a multiplier to the amount of gear that is to be distributed roundstart, stored in [/datum/game_mode/var/gear_scale]
/datum/game_mode/proc/init_gear_scale()
//We take the number of marine players, deduced from other lists, and then get a scale multiplier from it, to be used in arbitrary manners to distribute equipment
//This might count players who ready up but get kicked back to the lobby
var/marine_pop_size = length(GLOB.alive_human_list)
var/marine_pop_size = 0
for(var/mob/living/carbon/human/human as anything in GLOB.alive_human_list)
if(human.faction == FACTION_USCM)
var/datum/job/job = GET_MAPPED_ROLE(human.job)
marine_pop_size += RoleAuthority.calculate_role_weight(job)

//This gives a decimal value representing a scaling multiplier. Cannot go below 1
return max(marine_pop_size / MARINE_GEAR_SCALING_NORMAL, 1)
gear_scale = max(marine_pop_size / MARINE_GEAR_SCALING_NORMAL, 1)
gear_scale_init = gear_scale
return gear_scale

///Updates the [/datum/game_mode/var/gear_scale] multiplier based on joining marines in [/datum/game_mode/var/latejoin_tally]
/datum/game_mode/proc/update_gear_scale()
var/new_gear_scale = gear_scale_init + latejoin_tally / MARINE_GEAR_SCALING_NORMAL
if(new_gear_scale > gear_scale)
for(var/obj/structure/machinery/cm_vending/sorted/vendor as anything in GLOB.cm_vending_vendors)
vendor.update_dynamic_stock(new_gear_scale)
supply_controller.points += round((new_gear_scale - gear_scale) * supply_controller.points_scale)
gear_scale = new_gear_scale

// for the toolbox
/datum/game_mode/proc/end_round_message()
Expand Down
2 changes: 2 additions & 0 deletions code/game/jobs/role_authority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
* survivors and the number of roundstart Squad Rifleman slots.
*/
/datum/authority/branch/role/proc/calculate_role_weight(datum/job/J)
if(!J)
return 0
if(ROLES_MARINES.Find(J.title))
return 1
if(ROLES_XENO.Find(J.title))
Expand Down
7 changes: 4 additions & 3 deletions code/game/machinery/cryopod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ GLOBAL_LIST_INIT(frozen_items, list(SQUAD_MARINE_1 = list(), SQUAD_MARINE_2 = li
dept_console += A
A.moveToNullspace()

var/datum/job/job = GET_MAPPED_ROLE(occupant.job)
if(ishuman(occupant))
var/mob/living/carbon/human/H = occupant
if(H.assigned_squad)
var/datum/squad/S = H.assigned_squad
S.forget_marine_in_squad(H)
var/datum/job/J = GET_MAPPED_ROLE(H.job)
if(istype(J, /datum/job/marine/specialist))
if(istype(job, /datum/job/marine/specialist))
//we make the set this specialist took if any available again
if(H.skills)
var/set_name
Expand All @@ -346,7 +346,8 @@ GLOBAL_LIST_INIT(frozen_items, list(SQUAD_MARINE_1 = list(), SQUAD_MARINE_2 = li
if(set_name && !available_specialist_sets.Find(set_name))
available_specialist_sets += set_name

SSticker.mode.latejoin_tally-- //Cryoing someone out removes someone from the Marines, blocking further larva spawns until accounted for
//Cryoing someone out removes someone from the Marines, blocking further larva spawns until accounted for
SSticker.mode.latejoin_tally -= RoleAuthority.calculate_role_weight(job)

//Handle job slot/tater cleanup.
RoleAuthority.free_role(GET_MAPPED_ROLE(occupant.job), TRUE)
Expand Down
41 changes: 37 additions & 4 deletions code/game/machinery/vending/cm_vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,11 @@ GLOBAL_LIST_EMPTY(vending_products)
vend_flags = VEND_CLUTTER_PROTECTION | VEND_LIMITED_INVENTORY | VEND_TO_HAND
show_points = FALSE

//this here is made to provide ability to restock vendors with different subtypes of same object, like handmade and manually filled ammo boxes.
///this here is made to provide ability to restock vendors with different subtypes of same object, like handmade and manually filled ammo boxes.
var/list/corresponding_types_list
///If using [VEND_STOCK_DYNAMIC], assoc list of product entry to list of (product multiplier, awarded objects) - as seen in [/obj/structure/machinery/cm_vending/sorted/proc/populate_product_list]
///This allows us to backtrack and refill the stocks when new players latejoin
var/list/list/dynamic_stock_multipliers

/obj/structure/machinery/cm_vending/sorted/Initialize()
. = ..()
Expand All @@ -861,14 +864,44 @@ GLOBAL_LIST_EMPTY(vending_products)
GLOB.cm_vending_vendors -= src
return ..()

//this proc, well, populates product list based on roundstart amount of players
///this proc, well, populates product list based on roundstart amount of players
/obj/structure/machinery/cm_vending/sorted/proc/populate_product_list_and_boxes(scale)
populate_product_list(scale)
if(vend_flags & VEND_STOCK_DYNAMIC)
populate_product_list(1.0)
dynamic_stock_multipliers = list()
for(var/list/vendspec in listed_products)
var/multiplier = vendspec[2]
if(multiplier > 0)
var/awarded = round(vendspec[2] * scale) // Starting amount
//Record the multiplier and how many have actually been given out
dynamic_stock_multipliers[vendspec] = list(vendspec[2], awarded)
vendspec[2] = awarded // Override starting amount
else
populate_product_list(scale)

if(vend_flags & VEND_LOAD_AMMO_BOXES)
populate_ammo_boxes()
return

//this proc, well, populates product list based on roundstart amount of players
///Updates the vendor stock when the [/datum/game_mode/var/marine_tally] has changed and we're using [VEND_STOCK_DYNAMIC]
///Assumes the scale can only increase!!! Don't take their items away!
/obj/structure/machinery/cm_vending/sorted/proc/update_dynamic_stock(new_scale)
if(!(vend_flags & VEND_STOCK_DYNAMIC))
return
for(var/list/vendspec in dynamic_stock_multipliers)
var/list/metadata = dynamic_stock_multipliers[vendspec]
var/multiplier = metadata[1] // How much do we multiply scales by
var/previous_max_amount = metadata[2] // How many we already handed out at old scale
var/projected_max_amount = round(new_scale * multiplier) // How much we would have had total now in total
var/amount_to_add = round(projected_max_amount - previous_max_amount) // Rounding just in case
if(amount_to_add > 0)
metadata[2] += amount_to_add
vendspec[2] += amount_to_add
update_derived_ammo_and_boxes_on_add(vendspec)

///this proc, well, populates product list based on roundstart amount of players
///do not rely on scale here if you use VEND_STOCK_DYNAMIC because it's already taken into account
///this is here for historical reasons and should ONLY be called by populate_product_list_and_boxes if you want dynamic stocks and ammoboxes to work
/obj/structure/machinery/cm_vending/sorted/proc/populate_product_list(scale)
return

Expand Down
Loading