From 9b095413ecf12a2b29fed5c28f1a2126c822914f Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:49:57 +0300 Subject: [PATCH 1/3] a --- code/datums/entities/predround_chance.dm | 22 ++++++++++++++++++++++ code/game/jobs/role_authority.dm | 23 +++++++++++++++++++++-- colonialmarines.dme | 1 + maps/Nightmare/scenario.json | 1 - 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 code/datums/entities/predround_chance.dm diff --git a/code/datums/entities/predround_chance.dm b/code/datums/entities/predround_chance.dm new file mode 100644 index 000000000000..cf5d92e8f757 --- /dev/null +++ b/code/datums/entities/predround_chance.dm @@ -0,0 +1,22 @@ +/datum/entity/predround_chance + var/chance + + +/datum/entity_meta/predround_chance + entity_type = /datum/entity/predround_chance + table_name = "predround_chance" + field_types = list( + "chance"=DB_FIELDTYPE_BIGINT, + ) + +/datum/view_record/predround_chance + var/id + var/chance + +/datum/entity_view_meta/stickyban + root_record_type = /datum/entity/predround_chance + destination_entity = /datum/view_record/predround_chance + fields = list( + "id", + "chance" + ) diff --git a/code/game/jobs/role_authority.dm b/code/game/jobs/role_authority.dm index b4894eda4d24..3fb9fd146cf9 100644 --- a/code/game/jobs/role_authority.dm +++ b/code/game/jobs/role_authority.dm @@ -209,13 +209,27 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou if(istype(CO_surv_job)) CO_surv_job.set_spawn_positions(GLOB.players_preassigned) - if(SSnightmare.get_scenario_value("predator_round") && !Check_WO()) + var/chance + var/pred_round = FALSE + var/datum/view_record/predround_chance/meta = locate() in DB_VIEW(/datum/view_record/predround_chance, DB_COMP("id", DB_EQUALS, 1)) + if(!meta) + var/datum/entity/predround_chance/entity = DB_ENTITY(/datum/entity/predround_chance, 1) + entity.chance = 0 // This is 0 instead of 20 because it is going to get increased in modify_pred_round_chance + chance = 20 + entity.save() + else + chance = meta.chance + + if(prob(chance) && !Check_WO()) + pred_round = TRUE SSticker.mode.flags_round_type |= MODE_PREDATOR // Set predators starting amount based on marines assigned var/datum/job/PJ = temp_roles_for_mode[JOB_PREDATOR] if(istype(PJ)) PJ.set_spawn_positions(GLOB.players_preassigned) - REDIS_PUBLISH("byond.round", "type" = "predator-round", "map" = SSmapping.configs[GROUND_MAP].map_name) + REDIS_PUBLISH("byond.round", "type" = "predator-round", "map" = SSmapping.configs[GROUND_MAP].map_name) + + DB_FILTER(/datum/entity/predround_chance, DB_COMP("id", DB_EQUALS, 1), CALLBACK(src, PROC_REF(modify_pred_round_chance), pred_round)) // Assign the roles, this time for real, respecting limits we have established. var/list/roles_left = assign_roles(temp_roles_for_mode, unassigned_players) @@ -823,3 +837,8 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou if(new_squad.num_tl >= new_squad.max_tl) return TRUE return FALSE + +/datum/authority/branch/role/proc/modify_pred_round_chance(pred_round, list/datum/entity/predround_chance/entities) + var/datum/entity/predround_chance/entity = locate() in entities + entity.chance = pred_round ? 20 : entity.chance + 20 + entity.save() diff --git a/colonialmarines.dme b/colonialmarines.dme index 9fff0d7db91b..7af974d6c715 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -563,6 +563,7 @@ #include "code\datums\entities\player_stat.dm" #include "code\datums\entities\player_sticky_ban.dm" #include "code\datums\entities\player_times.dm" +#include "code\datums\entities\predround_chance.dm" #include "code\datums\entities\ticket.dm" #include "code\datums\entities\logs\player_times_log.dm" #include "code\datums\factions\clf.dm" diff --git a/maps/Nightmare/scenario.json b/maps/Nightmare/scenario.json index 4cfa6462d4b7..0d4f101c7a37 100644 --- a/maps/Nightmare/scenario.json +++ b/maps/Nightmare/scenario.json @@ -1,3 +1,2 @@ [ - { "type": "def", "values": { "predator_round": true }, "chance": 0.2 } ] From fb3cbf793676844e7dcab1b1235881d6f420de7f Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:02:49 +0300 Subject: [PATCH 2/3] linter my beloved --- code/datums/entities/predround_chance.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/entities/predround_chance.dm b/code/datums/entities/predround_chance.dm index cf5d92e8f757..3db1ad708533 100644 --- a/code/datums/entities/predround_chance.dm +++ b/code/datums/entities/predround_chance.dm @@ -18,5 +18,5 @@ destination_entity = /datum/view_record/predround_chance fields = list( "id", - "chance" + "chance", ) From f0a1eb06dc2e5bdc7ee67f1dbbd0fe55c03a11dd Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:30:40 +0100 Subject: [PATCH 3/3] Update code/datums/entities/predround_chance.dm --- code/datums/entities/predround_chance.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/entities/predround_chance.dm b/code/datums/entities/predround_chance.dm index 3db1ad708533..dbec67daf83e 100644 --- a/code/datums/entities/predround_chance.dm +++ b/code/datums/entities/predround_chance.dm @@ -6,7 +6,7 @@ entity_type = /datum/entity/predround_chance table_name = "predround_chance" field_types = list( - "chance"=DB_FIELDTYPE_BIGINT, + "chance" = DB_FIELDTYPE_BIGINT, ) /datum/view_record/predround_chance