From 4339f27affe133a1e7ace514dcf0562074bf110a Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 30 Jan 2025 20:54:04 -0800 Subject: [PATCH 1/6] marine death tracking --- .../statistics/entities/marine_death.dm | 71 +++++++++++++++++++ .../datums/statistics/entities/round_stats.dm | 4 ++ code/datums/statistics/entities/xeno_death.dm | 2 +- code/modules/mob/living/carbon/human/death.dm | 3 + colonialmarines.dme | 1 + 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 code/datums/statistics/entities/marine_death.dm diff --git a/code/datums/statistics/entities/marine_death.dm b/code/datums/statistics/entities/marine_death.dm new file mode 100644 index 000000000000..b4dc37ed1eb7 --- /dev/null +++ b/code/datums/statistics/entities/marine_death.dm @@ -0,0 +1,71 @@ +/datum/entity/marine_death + /// What map this death happened on + var/map_name + /// X coord of the death + var/x + /// Y coord of the death + var/y + /// Z coord of the death + var/z + /// What minute this death happened at, rounded down + var/death_minute + /// What role this marine was + var/role + /// How many minutes the marine had been alive for, rounded down + var/minutes_alive + /// Ckey of the player who died + var/ckey + /// How much damage this marine + var/damage_taken + /// What killed this marine ("Ravager") + var/killed_by + /// Round ID that this marine died in + var/round_id + /// The primary weapon (as best we can find) of the marine + var/primary_weapon + /// The armor the marine was wearing on death + var/armor + +/datum/entity/marine_death/proc/load_data(mob/living/carbon/human/dead_marine, datum/cause_data/death_cause) + map_name = SSmapping.configs[GROUND_MAP]?.map_name || "Unknown Map" + x = dead_marine.x || -1 + y = dead_marine.y || -1 + z = dead_marine.z || -1 + death_minute = floor((world.time * 0.1) / 60) + role = dead_marine.job + ckey = dead_marine.ckey || dead_marine.persistent_ckey || "" + damage_taken = dead_marine.life_damage_taken_total || 0 + killed_by = strip_improper(death_cause?.cause_name) || "Unknown" + round_id = GLOB.round_id || -1 + if(isgun(dead_marine.s_store)) + primary_weapon = strip_improper(dead_marine.s_store.name) + else if(isgun(dead_marine.back)) + primary_weapon = strip_improper(dead_marine.back.name) + else + var/obj/item/weapon/gun/found_gun = locate(/obj/item/weapon/gun) in dead_marine.contents + if(found_gun) + primary_weapon = strip_improper(found_gun.name) + + if(istype(dead_marine.wear_suit, /obj/item/clothing/suit)) + armor = strip_improper(dead_marine.wear_suit.name) + + SSticker?.mode?.round_stats?.marine_deaths += src + save() + +/datum/entity_meta/marine_death + entity_type = /datum/entity/marine_death + table_name = "marine_deaths" + field_types = list( + "map_name" = DB_FIELDTYPE_STRING_MEDIUM, + "x" = DB_FIELDTYPE_INT, + "y" = DB_FIELDTYPE_INT, + "z" = DB_FIELDTYPE_INT, + "death_minute" = DB_FIELDTYPE_INT, + "role" = DB_FIELDTYPE_STRING_MEDIUM, + "ckey" = DB_FIELDTYPE_STRING_MEDIUM, + "damage_taken" = DB_FIELDTYPE_INT, + "killed_by" = DB_FIELDTYPE_STRING_MEDIUM, + "round_id" = DB_FIELDTYPE_INT, + "primary_weapon" = DB_FIELDTYPE_STRING_MEDIUM, + "armor" = DB_FIELDTYPE_STRING_MEDIUM, + ) diff --git a/code/datums/statistics/entities/round_stats.dm b/code/datums/statistics/entities/round_stats.dm index 7ff793336619..cdc59eabd29b 100644 --- a/code/datums/statistics/entities/round_stats.dm +++ b/code/datums/statistics/entities/round_stats.dm @@ -41,6 +41,9 @@ /// A list of all player xenomorph deaths, type /datum/entity/xeno_death var/list/xeno_deaths = list() + /// A list of all marine deaths, type /datum/entity/marine_death + var/list/marine_deaths = list() + // nanoui data var/list/round_data = list() var/list/death_data = list() @@ -50,6 +53,7 @@ QDEL_NULL(current_map) QDEL_LIST(death_stats_list) QDEL_LIST(xeno_deaths) + QDEL_LIST(marine_deaths) QDEL_LIST_ASSOC_VAL(castes_evolved) QDEL_LIST_ASSOC_VAL(abilities_used) QDEL_LIST_ASSOC_VAL(final_participants) diff --git a/code/datums/statistics/entities/xeno_death.dm b/code/datums/statistics/entities/xeno_death.dm index e416e014182b..644aa169824d 100644 --- a/code/datums/statistics/entities/xeno_death.dm +++ b/code/datums/statistics/entities/xeno_death.dm @@ -33,7 +33,7 @@ x = dead_xeno.x || -1 y = dead_xeno.y || -1 z = dead_xeno.z || -1 - death_minute = floor((world.time * 0.1) / 60) || -1 + death_minute = floor((world.time * 0.1) / 60) hive = dead_xeno.hive.name || "Unknown Hive" caste = dead_xeno.caste.caste_type || "Unknown" strain = dead_xeno.strain?.name || "None" diff --git a/code/modules/mob/living/carbon/human/death.dm b/code/modules/mob/living/carbon/human/death.dm index 795de20367d2..a0c32f684a59 100644 --- a/code/modules/mob/living/carbon/human/death.dm +++ b/code/modules/mob/living/carbon/human/death.dm @@ -73,6 +73,9 @@ give_action(src, /datum/action/ghost) + var/datum/entity/marine_death/death_entry = DB_ENTITY(/datum/entity/marine_death) + death_entry.load_data(src, cause) + if(!gibbed && species.death_sound) playsound(loc, species.death_sound, 50, 1) diff --git a/colonialmarines.dme b/colonialmarines.dme index 5ff78ebca305..6b1b649fc668 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -670,6 +670,7 @@ #include "code\datums\statistics\entities\human_stats.dm" #include "code\datums\statistics\entities\job_stats.dm" #include "code\datums\statistics\entities\map_stats.dm" +#include "code\datums\statistics\entities\marine_death.dm" #include "code\datums\statistics\entities\medal_stats.dm" #include "code\datums\statistics\entities\panel_stats.dm" #include "code\datums\statistics\entities\player_entity.dm" From 2ef286e901462ea689f8b0d924e0d68d341f167b Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 30 Jan 2025 20:55:21 -0800 Subject: [PATCH 2/6] sanity checks ish --- code/modules/mob/living/carbon/human/death.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/human/death.dm b/code/modules/mob/living/carbon/human/death.dm index a0c32f684a59..334406270138 100644 --- a/code/modules/mob/living/carbon/human/death.dm +++ b/code/modules/mob/living/carbon/human/death.dm @@ -73,8 +73,9 @@ give_action(src, /datum/action/ghost) - var/datum/entity/marine_death/death_entry = DB_ENTITY(/datum/entity/marine_death) - death_entry.load_data(src, cause) + if(!should_block_game_interaction(src) && istype(SSticker.mode, /datum/game_mode/colonialmarines) && !(datum_flags & DF_VAR_EDITED)) + var/datum/entity/marine_death/death_entry = DB_ENTITY(/datum/entity/marine_death) + death_entry.load_data(src, cause) if(!gibbed && species.death_sound) playsound(loc, species.death_sound, 50, 1) From 86b32385af08a92db7b2ba2f4bf609ad5b8e02c6 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 30 Jan 2025 21:42:41 -0800 Subject: [PATCH 3/6] only count ckey'd humans --- code/modules/mob/living/carbon/human/death.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/human/death.dm b/code/modules/mob/living/carbon/human/death.dm index 334406270138..51530efb8d93 100644 --- a/code/modules/mob/living/carbon/human/death.dm +++ b/code/modules/mob/living/carbon/human/death.dm @@ -73,7 +73,7 @@ give_action(src, /datum/action/ghost) - if(!should_block_game_interaction(src) && istype(SSticker.mode, /datum/game_mode/colonialmarines) && !(datum_flags & DF_VAR_EDITED)) + if(!should_block_game_interaction(src) && istype(SSticker.mode, /datum/game_mode/colonialmarines) && !(datum_flags & DF_VAR_EDITED) && ckey) var/datum/entity/marine_death/death_entry = DB_ENTITY(/datum/entity/marine_death) death_entry.load_data(src, cause) From d7c67e8a966ad038f310e0d3e27dd7b0ec681502 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 30 Jan 2025 21:44:54 -0800 Subject: [PATCH 4/6] use initial values --- code/datums/statistics/entities/marine_death.dm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/datums/statistics/entities/marine_death.dm b/code/datums/statistics/entities/marine_death.dm index b4dc37ed1eb7..246bf220446d 100644 --- a/code/datums/statistics/entities/marine_death.dm +++ b/code/datums/statistics/entities/marine_death.dm @@ -38,16 +38,16 @@ killed_by = strip_improper(death_cause?.cause_name) || "Unknown" round_id = GLOB.round_id || -1 if(isgun(dead_marine.s_store)) - primary_weapon = strip_improper(dead_marine.s_store.name) + primary_weapon = strip_improper(dead_marine.s_store::name) else if(isgun(dead_marine.back)) - primary_weapon = strip_improper(dead_marine.back.name) + primary_weapon = strip_improper(dead_marine.back::name) else var/obj/item/weapon/gun/found_gun = locate(/obj/item/weapon/gun) in dead_marine.contents if(found_gun) - primary_weapon = strip_improper(found_gun.name) + primary_weapon = strip_improper(found_gun::name) if(istype(dead_marine.wear_suit, /obj/item/clothing/suit)) - armor = strip_improper(dead_marine.wear_suit.name) + armor = strip_improper(dead_marine.wear_suit::name) SSticker?.mode?.round_stats?.marine_deaths += src save() From 45aa4c6635518ead519902229e020b8945e32e4b Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 30 Jan 2025 21:47:25 -0800 Subject: [PATCH 5/6] track kill count too because why not --- code/datums/statistics/entities/marine_death.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/datums/statistics/entities/marine_death.dm b/code/datums/statistics/entities/marine_death.dm index 246bf220446d..13e45c41017c 100644 --- a/code/datums/statistics/entities/marine_death.dm +++ b/code/datums/statistics/entities/marine_death.dm @@ -25,6 +25,8 @@ var/primary_weapon /// The armor the marine was wearing on death var/armor + /// How many kills this marine got + var/kill_count /datum/entity/marine_death/proc/load_data(mob/living/carbon/human/dead_marine, datum/cause_data/death_cause) map_name = SSmapping.configs[GROUND_MAP]?.map_name || "Unknown Map" @@ -37,6 +39,7 @@ damage_taken = dead_marine.life_damage_taken_total || 0 killed_by = strip_improper(death_cause?.cause_name) || "Unknown" round_id = GLOB.round_id || -1 + kill_count = dead_marine.life_kills_total || 0 if(isgun(dead_marine.s_store)) primary_weapon = strip_improper(dead_marine.s_store::name) else if(isgun(dead_marine.back)) @@ -68,4 +71,5 @@ "round_id" = DB_FIELDTYPE_INT, "primary_weapon" = DB_FIELDTYPE_STRING_MEDIUM, "armor" = DB_FIELDTYPE_STRING_MEDIUM, + "kill_count" = DB_FIELDTYPE_INT, ) From 1b40968c7bf58d6605a6b19526a5e6d1adb688ed Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 30 Jan 2025 22:01:33 -0800 Subject: [PATCH 6/6] squad name too --- code/datums/statistics/entities/marine_death.dm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/datums/statistics/entities/marine_death.dm b/code/datums/statistics/entities/marine_death.dm index 13e45c41017c..535510e691bf 100644 --- a/code/datums/statistics/entities/marine_death.dm +++ b/code/datums/statistics/entities/marine_death.dm @@ -27,6 +27,8 @@ var/armor /// How many kills this marine got var/kill_count + /// What squad this player belongs to, if any + var/squad /datum/entity/marine_death/proc/load_data(mob/living/carbon/human/dead_marine, datum/cause_data/death_cause) map_name = SSmapping.configs[GROUND_MAP]?.map_name || "Unknown Map" @@ -52,6 +54,9 @@ if(istype(dead_marine.wear_suit, /obj/item/clothing/suit)) armor = strip_improper(dead_marine.wear_suit::name) + if(dead_marine.assigned_squad) + squad = dead_marine.assigned_squad.name + SSticker?.mode?.round_stats?.marine_deaths += src save() @@ -72,4 +77,5 @@ "primary_weapon" = DB_FIELDTYPE_STRING_MEDIUM, "armor" = DB_FIELDTYPE_STRING_MEDIUM, "kill_count" = DB_FIELDTYPE_INT, + "squad" = DB_FIELDTYPE_STRING_SMALL, )