From ced0a88007aee3c8c6c6fb31bac65c5c0755ae2f Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 29 Sep 2020 12:35:03 +0200 Subject: [PATCH] [MIRROR] Turns simple mob vars into string lists and fixes string assoc lists (#1047) * Merge pull request #53937 from Rohesie/damage Turns simple mob vars into string lists and fixes string assoc lists * Turns simple mob vars into string lists and fixes string assoc lists Co-authored-by: nemvar <47324920+nemvar@users.noreply.github.com> --- code/__HELPERS/string_assoc_lists.dm | 17 +++++++-------- code/__HELPERS/string_lists.dm | 10 ++++----- code/datums/dog_fashion.dm | 8 +++---- code/modules/events/brand_intelligence.dm | 2 +- .../living/simple_animal/guardian/guardian.dm | 2 +- .../mob/living/simple_animal/simple_animal.dm | 21 +++++++++++++++++-- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/code/__HELPERS/string_assoc_lists.dm b/code/__HELPERS/string_assoc_lists.dm index e269da7da5e..4e9087b4366 100644 --- a/code/__HELPERS/string_assoc_lists.dm +++ b/code/__HELPERS/string_assoc_lists.dm @@ -1,18 +1,17 @@ GLOBAL_LIST_EMPTY(string_assoc_lists) - /** * Caches associative lists with non-numeric stringify-able index keys and stringify-able values (text/typepath -> text/path/number). */ /datum/proc/string_assoc_list(list/values) - var/list/string_id = list() - for(var/val in values) - string_id += "[val]_[values[val]]" - string_id.Join("-") + var/list/string_id = list() + for(var/val in values) + string_id += "[val]_[values[val]]" + string_id = string_id.Join("-") - . = GLOB.string_assoc_lists[string_id] + . = GLOB.string_assoc_lists[string_id] - if(.) - return + if(.) + return - return GLOB.string_assoc_lists[string_id] = values + return GLOB.string_assoc_lists[string_id] = values diff --git a/code/__HELPERS/string_lists.dm b/code/__HELPERS/string_lists.dm index 069f9b6dc41..df01d8a8490 100644 --- a/code/__HELPERS/string_lists.dm +++ b/code/__HELPERS/string_lists.dm @@ -4,11 +4,11 @@ GLOBAL_LIST_EMPTY(string_lists) * Caches lists with non-numeric stringify-able values (text or typepath). */ /datum/proc/string_list(list/values) - var/string_id = values.Join("-") + var/string_id = values.Join("-") - . = GLOB.string_lists[string_id] + . = GLOB.string_lists[string_id] - if(.) - return + if(.) + return - return GLOB.string_lists[string_id] = values + return GLOB.string_lists[string_id] = values diff --git a/code/datums/dog_fashion.dm b/code/datums/dog_fashion.dm index fc192beeb0e..65b403bb12e 100644 --- a/code/datums/dog_fashion.dm +++ b/code/datums/dog_fashion.dm @@ -23,13 +23,13 @@ if(desc) D.desc = desc if(emote_see) - D.emote_see = emote_see + D.emote_see = string_list(emote_see) if(emote_hear) - D.emote_hear = emote_hear + D.emote_hear = string_list(emote_hear) if(speak) - D.speak = speak + D.speak = string_list(speak) if(speak_emote) - D.speak_emote = speak_emote + D.speak_emote = string_list(speak_emote) /datum/dog_fashion/proc/get_overlay(dir) if(icon_file && obj_icon_state) diff --git a/code/modules/events/brand_intelligence.dm b/code/modules/events/brand_intelligence.dm index 5c0637b036c..cf3138ec4eb 100644 --- a/code/modules/events/brand_intelligence.dm +++ b/code/modules/events/brand_intelligence.dm @@ -59,7 +59,7 @@ if(prob(70) && !QDELETED(upriser)) var/mob/living/simple_animal/hostile/mimic/copy/M = new(upriser.loc, upriser, null, 1) // it will delete upriser on creation and override any machine checks M.faction = list("profit") - M.speak = rampant_speeches.Copy() + M.speak = string_list(rampant_speeches.Copy()) M.speak_chance = 7 else explosion(upriser.loc, -1, 1, 2, 4, 0) diff --git a/code/modules/mob/living/simple_animal/guardian/guardian.dm b/code/modules/mob/living/simple_animal/guardian/guardian.dm index fd37176fe7e..7f17ff9f032 100644 --- a/code/modules/mob/living/simple_animal/guardian/guardian.dm +++ b/code/modules/mob/living/simple_animal/guardian/guardian.dm @@ -120,7 +120,7 @@ GLOBAL_LIST_EMPTY(parasites) //all currently existing/living guardians icon_state = "holocarp" icon_living = "holocarp" icon_dead = "holocarp" - speak_emote = list("gnashes") + speak_emote = string_list(list("gnashes")) desc = "A mysterious fish that stands by its charge, ever vigilant." attack_verb_continuous = "bites" attack_verb_simple = "bite" diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index fd49daadd9d..01e4ba71320 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -173,6 +173,20 @@ if(dextrous) AddComponent(/datum/component/personal_crafting) + if(speak) + speak = string_list(speak) + if(speak_emote) + speak_emote = string_list(speak_emote) + if(emote_hear) + emote_hear = string_list(emote_hear) + if(emote_see) + emote_see = string_list(emote_hear) + if(atmos_requirements) + atmos_requirements = string_assoc_list(atmos_requirements) + if(damage_coeff) + damage_coeff = string_assoc_list(damage_coeff) + + /mob/living/simple_animal/Destroy() GLOB.simple_animals[AIStatus] -= src if (SSnpcpool.state == SS_PAUSED && LAZYLEN(SSnpcpool.currentrun)) @@ -188,6 +202,7 @@ return ..() + /mob/living/simple_animal/attackby(obj/item/O, mob/user, params) if(!is_type_in_list(O, food_type)) ..() @@ -384,10 +399,12 @@ if(icon_gib) new /obj/effect/temp_visual/gib_animation/animal(loc, icon_gib) + /mob/living/simple_animal/say_mod(input, list/message_mods = list()) - if(speak_emote && speak_emote.len) + if(length(speak_emote)) verb_say = pick(speak_emote) - . = ..() + return ..() + /mob/living/simple_animal/emote(act, m_type=1, message = null, intentional = FALSE) if(stat)