From 869c25010b2db4d247b003147af4fd98fe65db71 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Tue, 21 Nov 2023 18:33:44 +0000 Subject: [PATCH 1/4] refactors /mob/.../xenomorph/Initialise() --- .../mob/living/carbon/xenomorph/Xenomorph.dm | 199 +++++++++--------- 1 file changed, 100 insertions(+), 99 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm b/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm index 7beaaab8a04e..cea7dff49c20 100644 --- a/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm +++ b/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm @@ -347,157 +347,158 @@ var/atom/movable/vis_obj/xeno_wounds/wound_icon_holder var/atom/movable/vis_obj/xeno_pack/backpack_icon_holder -/mob/living/carbon/xenomorph/Initialize(mapload, mob/living/carbon/xenomorph/oldXeno, h_number) - var/area/A = get_area(src) - if(A && A.statistic_exempt) - statistic_exempt = TRUE +/mob/living/carbon/xenomorph/Initialize(mapload, mob/living/carbon/xenomorph/old_xeno, hivenumber) + + if(old_xeno && old_xeno.hivenumber) + src.hivenumber = old_xeno.hivenumber + else if(hivenumber) + src.hivenumber = hivenumber + + var/datum/hive_status/hive = GLOB.hive_datum[src.hivenumber] + + if(hive) + hive.add_xeno(src) wound_icon_holder = new(null, src) vis_contents += wound_icon_holder - if(oldXeno) - set_movement_intent(oldXeno.m_intent) - hivenumber = oldXeno.hivenumber - nicknumber = oldXeno.nicknumber - life_kills_total = oldXeno.life_kills_total - life_damage_taken_total = oldXeno.life_damage_taken_total - evolution_stored = oldXeno.evolution_stored - if(oldXeno.iff_tag) - iff_tag = oldXeno.iff_tag - iff_tag.forceMove(src) - oldXeno.iff_tag = null - else if (h_number) - hivenumber = h_number - set_languages(list(LANGUAGE_XENOMORPH, LANGUAGE_HIVEMIND)) - if(oldXeno) - for(var/datum/language/L in oldXeno.languages) - add_language(L.name)//Make sure to keep languages (mostly for event Queens that know English) - // Well, not yet, technically - var/datum/hive_status/in_hive = GLOB.hive_datum[hivenumber] - if(in_hive) - in_hive.add_xeno(src) - // But now we are! + ///Handle transferring things from the old Xeno if we have one in the case of evolve, devolve etc. + if(old_xeno) + src.nicknumber = old_xeno.nicknumber + src.life_kills_total = old_xeno.life_kills_total + src.life_damage_taken_total = old_xeno.life_damage_taken_total + src.evolution_stored = old_xeno.evolution_stored - for(var/T in in_hive.hive_inherant_traits) - ADD_TRAIT(src, T, TRAIT_SOURCE_HIVE) + for(var/datum/language/language in old_xeno.languages) + add_language(language.name)//Make sure to keep languages (mostly for event Queens that know English) + + //Carry over intents & targeted limb to the new Xeno + set_movement_intent(old_xeno.m_intent) + a_intent_change(old_xeno.a_intent) + + //We are hiding, let's keep hiding if we can! + if(old_xeno.layer == XENO_HIDING_LAYER) + for(var/datum/action/xeno_action/onclick/xenohide/hide in actions) + if(istype(hide)) + layer = XENO_HIDING_LAYER + hide.button.icon_state = "template_active" + + //If we're holding things drop them + for(var/obj/item/item in old_xeno.contents) //Drop stuff + old_xeno.drop_inv_item_on_ground(item) + old_xeno.empty_gut() + + //Set leader to the new mob + if(hive && IS_XENO_LEADER(old_xeno)) + hive.replace_hive_leader(old_xeno, src) + + if(old_xeno.iff_tag) + iff_tag = old_xeno.iff_tag + iff_tag.forceMove(src) + old_xeno.iff_tag = null + + if(hive) + for(var/trait in hive.hive_inherant_traits) + ADD_TRAIT(src, trait, TRAIT_SOURCE_HIVE) mutators.xeno = src + //Set caste stuff if(caste_type && GLOB.xeno_datum_list[caste_type]) caste = GLOB.xeno_datum_list[caste_type] - else - to_world("something went very wrong") - return - update_icon_source() + //Fire immunity signals + if (caste.fire_immunity != FIRE_IMMUNITY_NONE) + if(caste.fire_immunity & FIRE_IMMUNITY_NO_IGNITE) + RegisterSignal(src, COMSIG_LIVING_PREIGNITION, PROC_REF(fire_immune)) - acid_splash_cooldown = caste.acid_splash_cooldown + RegisterSignal(src, list(COMSIG_LIVING_FLAMER_CROSSED, COMSIG_LIVING_FLAMER_FLAMED), PROC_REF(flamer_crossed_immune)) + else + UnregisterSignal(src, list( + COMSIG_LIVING_PREIGNITION, + COMSIG_LIVING_FLAMER_CROSSED, + COMSIG_LIVING_FLAMER_FLAMED + )) - if (caste.fire_immunity != FIRE_IMMUNITY_NONE) - if(caste.fire_immunity & FIRE_IMMUNITY_NO_IGNITE) - RegisterSignal(src, COMSIG_LIVING_PREIGNITION, PROC_REF(fire_immune)) - RegisterSignal(src, list( - COMSIG_LIVING_FLAMER_CROSSED, - COMSIG_LIVING_FLAMER_FLAMED, - ), PROC_REF(flamer_crossed_immune)) - else - UnregisterSignal(src, list( - COMSIG_LIVING_PREIGNITION, - COMSIG_LIVING_FLAMER_CROSSED, - COMSIG_LIVING_FLAMER_FLAMED, - )) + if(caste.spit_types && length(caste.spit_types)) + ammo = GLOB.ammo_list[caste.spit_types[1]] - recalculate_everything() + acid_splash_cooldown = caste.acid_splash_cooldown + + if(caste.adjust_size_x != 1) + var/matrix/matrix = matrix() + matrix.Scale(caste.adjust_size_x, caste.adjust_size_y) + apply_transform(matrix) + + behavior_delegate = new caste.behavior_delegate_type() + behavior_delegate.bound_xeno = src + behavior_delegate.add_to_xeno() + resin_build_order = caste.resin_build_order + + job = caste.caste_type // Used for tracking the caste playtime + + else + CRASH("Attempted to create a new xenomorph [src] without caste datum.") if(mob_size < MOB_SIZE_BIG) mob_flags |= SQUEEZE_UNDER_VEHICLES + // More setup stuff for names, abilities etc + update_icon_source() generate_name() + add_inherent_verbs() + add_abilities() + create_reagents(100) + regenerate_icons() + toggle_xeno_mobhud() //This is a verb, but fuck it, it just werks + toggle_xeno_hostilehud() + recalculate_everything() - if(isqueen(src)) - SStracking.set_leader("hive_[hivenumber]", src) + //Begin SStracking SStracking.start_tracking("hive_[hivenumber]", src) . = ..() + + GLOB.living_xeno_list += src + GLOB.xeno_mob_list += src + //WO GAMEMODE if(SSticker?.mode?.hardcore) hardcore = 1 //Prevents healing and queen evolution time_of_birth = world.time - add_inherent_verbs() - add_abilities() - recalculate_actions() - + //Minimap if(z) INVOKE_NEXT_TICK(src, PROC_REF(add_minimap_marker)) + //Sight sight |= SEE_MOBS see_invisible = SEE_INVISIBLE_LIVING see_in_dark = 12 + if(client) set_lighting_alpha_from_prefs(client) else lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE - if(caste && caste.spit_types && caste.spit_types.len) - ammo = GLOB.ammo_list[caste.spit_types[1]] - - create_reagents(100) - - GLOB.living_xeno_list += src - GLOB.xeno_mob_list += src - - if(caste && caste.adjust_size_x != 1) - var/matrix/M = matrix() - M.Scale(caste.adjust_size_x, caste.adjust_size_y) - apply_transform(M) - - if(caste) - behavior_delegate = new caste.behavior_delegate_type() - behavior_delegate.bound_xeno = src - behavior_delegate.add_to_xeno() - resin_build_order = caste.resin_build_order - else - CRASH("Xenomorph [src] has no caste datum! Tell the devs!") - - regenerate_icons() - toggle_xeno_mobhud() //This is a verb, but fuck it, it just werks - toggle_xeno_hostilehud() - - if(oldXeno) - a_intent_change(oldXeno.a_intent)//Keep intent - - if(oldXeno.layer == XENO_HIDING_LAYER) - //We are hiding, let's keep hiding if we can! - for(var/datum/action/xeno_action/onclick/xenohide/hide in actions) - if(istype(hide)) - layer = XENO_HIDING_LAYER - hide.button.icon_state = "template_active" - - for(var/obj/item/W in oldXeno.contents) //Drop stuff - oldXeno.drop_inv_item_on_ground(W) - - oldXeno.empty_gut() - - if(IS_XENO_LEADER(oldXeno)) - hive.replace_hive_leader(oldXeno, src) - // Only handle free slots if the xeno is not in tdome - if(!is_admin_level(z)) + if(hive && !is_admin_level(z)) var/selected_caste = GLOB.xeno_datum_list[caste_type]?.type hive.used_slots[selected_caste]++ + //Statistics + var/area/current_area = get_area(src) + if(current_area && current_area.statistic_exempt) + statistic_exempt = TRUE if(round_statistics && !statistic_exempt) round_statistics.track_new_participant(faction, 1) - generate_name() // This can happen if a xeno gets made before the game starts if (hive && hive.hive_ui) hive.hive_ui.update_all_xeno_data() - job = caste.caste_type // Used for tracking the caste playtime Decorate() RegisterSignal(src, COMSIG_MOB_SCREECH_ACT, PROC_REF(handle_screech_act)) From cdb956adb23f3c5b2bd46c21db9f3492073b2f08 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Tue, 21 Nov 2023 19:27:25 +0000 Subject: [PATCH 2/4] queen --- code/modules/mob/living/carbon/xenomorph/castes/Queen.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm b/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm index b83b33e2eee5..3748ff5b1124 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm @@ -389,6 +389,7 @@ /mob/living/carbon/xenomorph/queen/Initialize() . = ..() + SStracking.set_leader("hive_[hivenumber]", src) if(!is_admin_level(z))//so admins can safely spawn Queens in Thunderdome for tests. xeno_message(SPAN_XENOANNOUNCE("A new Queen has risen to lead the Hive! Rejoice!"),3,hivenumber) notify_ghosts(header = "New Queen", message = "A new Queen has risen.", source = src, action = NOTIFY_ORBIT) From b40e603e25409bccf745597b972ef18c8c5858a7 Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Fri, 24 Nov 2023 18:54:27 +0000 Subject: [PATCH 3/4] fixes leader tracker bug --- .../mob/living/carbon/xenomorph/Xenomorph.dm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm b/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm index cea7dff49c20..64dd4b677ee6 100644 --- a/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm +++ b/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm @@ -390,10 +390,6 @@ old_xeno.drop_inv_item_on_ground(item) old_xeno.empty_gut() - //Set leader to the new mob - if(hive && IS_XENO_LEADER(old_xeno)) - hive.replace_hive_leader(old_xeno, src) - if(old_xeno.iff_tag) iff_tag = old_xeno.iff_tag iff_tag.forceMove(src) @@ -452,15 +448,20 @@ add_abilities() create_reagents(100) regenerate_icons() - toggle_xeno_mobhud() //This is a verb, but fuck it, it just werks + toggle_xeno_hostilehud() recalculate_everything() - - //Begin SStracking - SStracking.start_tracking("hive_[hivenumber]", src) + toggle_xeno_mobhud() //This is a verb, but fuck it, it just werks . = ..() + //Set leader to the new mob + if(old_xeno && hive && IS_XENO_LEADER(old_xeno)) + hive.replace_hive_leader(old_xeno, src) + + //Begin SStracking + SStracking.start_tracking("hive_[src.hivenumber]", src) + GLOB.living_xeno_list += src GLOB.xeno_mob_list += src From 6988cc5c91ba2eeafdc67e6f89cb2ae181d47a3b Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Mon, 27 Nov 2023 22:27:21 +0000 Subject: [PATCH 4/4] harry's changes --- code/modules/mob/living/carbon/xenomorph/Xenomorph.dm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm b/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm index eda775db9b53..645ade04ea4f 100644 --- a/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm +++ b/code/modules/mob/living/carbon/xenomorph/Xenomorph.dm @@ -371,7 +371,7 @@ src.life_damage_taken_total = old_xeno.life_damage_taken_total src.evolution_stored = old_xeno.evolution_stored - for(var/datum/language/language in old_xeno.languages) + for(var/datum/language/language as anything in old_xeno.languages) add_language(language.name)//Make sure to keep languages (mostly for event Queens that know English) //Carry over intents & targeted limb to the new Xeno @@ -381,9 +381,8 @@ //We are hiding, let's keep hiding if we can! if(old_xeno.layer == XENO_HIDING_LAYER) for(var/datum/action/xeno_action/onclick/xenohide/hide in actions) - if(istype(hide)) - layer = XENO_HIDING_LAYER - hide.button.icon_state = "template_active" + layer = XENO_HIDING_LAYER + hide.button.icon_state = "template_active" //If we're holding things drop them for(var/obj/item/item in old_xeno.contents) //Drop stuff