From 164066be9e33aa5df5b15a82fe882d403aed5442 Mon Sep 17 00:00:00 2001 From: Geeves Date: Sun, 2 Aug 2020 16:02:58 +0200 Subject: [PATCH] Slime Clean-up (#9515) --- aurorastation.dme | 1 + code/game/objects/effects/portals.dm | 2 +- code/modules/mob/living/carbon/slime/death.dm | 4 ++ .../mob/living/carbon/slime/helpers.dm | 23 ++++++++++ code/modules/mob/living/carbon/slime/life.dm | 42 +++++++++---------- .../modules/mob/living/carbon/slime/powers.dm | 16 +------ code/modules/mob/living/carbon/slime/say.dm | 8 ++-- code/modules/mob/living/carbon/slime/slime.dm | 2 +- html/changelogs/geeves-slime_cleanup.yml | 9 ++++ 9 files changed, 64 insertions(+), 43 deletions(-) create mode 100644 code/modules/mob/living/carbon/slime/helpers.dm create mode 100644 html/changelogs/geeves-slime_cleanup.yml diff --git a/aurorastation.dme b/aurorastation.dme index a2a7ed25954..335b7aa7a0c 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -1938,6 +1938,7 @@ #include "code\modules\mob\living\carbon\slime\death.dm" #include "code\modules\mob\living\carbon\slime\emote.dm" #include "code\modules\mob\living\carbon\slime\examine.dm" +#include "code\modules\mob\living\carbon\slime\helpers.dm" #include "code\modules\mob\living\carbon\slime\hud.dm" #include "code\modules\mob\living\carbon\slime\items.dm" #include "code\modules\mob\living\carbon\slime\life.dm" diff --git a/code/game/objects/effects/portals.dm b/code/game/objects/effects/portals.dm index 8eaf82fd6f0..7e6b6ceb2b6 100644 --- a/code/game/objects/effects/portals.dm +++ b/code/game/objects/effects/portals.dm @@ -120,7 +120,7 @@ /obj/effect/portal/spawner/phoron num_of_spawns = 3 spawn_things = list( - "/obj/item/stack/material/phoron" = 10 + "/obj/item/stack/material/phoron" = 3 ) /obj/effect/portal/spawner/monkey_cube diff --git a/code/modules/mob/living/carbon/slime/death.dm b/code/modules/mob/living/carbon/slime/death.dm index 2e581494b5a..a0ce0c594fd 100644 --- a/code/modules/mob/living/carbon/slime/death.dm +++ b/code/modules/mob/living/carbon/slime/death.dm @@ -2,6 +2,10 @@ if(stat == DEAD) return + if(victim) + step_away(src, victim) + victim = null + if(!gibbed && is_adult) var/mob/living/carbon/slime/M = new /mob/living/carbon/slime(loc, colour) M.rabid = TRUE diff --git a/code/modules/mob/living/carbon/slime/helpers.dm b/code/modules/mob/living/carbon/slime/helpers.dm new file mode 100644 index 00000000000..8294bbc02fc --- /dev/null +++ b/code/modules/mob/living/carbon/slime/helpers.dm @@ -0,0 +1,23 @@ +/mob/living/carbon/slime/proc/is_friend(var/mob/potential_friend) + if(!friends[potential_friend]) // zero or null + return FALSE + return TRUE + +/mob/living/carbon/slime/proc/increase_friendship(var/mob/friend) + if(is_friend(friend)) + friends[friend] += 1 + else + friends[friend] = 1 + +/mob/living/carbon/slime/proc/decrease_friendship(var/mob/friend) + if(is_friend(friend)) + friends[friend] = max(0, friends[friend] - 1) + +// this block handles becoming more friendly with the person that fed the slime +// LAssailant is a softref to the last person who grabbed a mob, thus, if you grab and pull a monkey +// before feeding them to the slime, they will become more friendly with you, even if you're out of sight. Bluespace! +/mob/living/carbon/slime/proc/check_friendship_increase() + if(victim && !rabid && !attacked && victim.LAssailant && victim.LAssailant != victim) + var/real_assailant = victim.LAssailant.resolve() + if(real_assailant) + increase_friendship(real_assailant) \ No newline at end of file diff --git a/code/modules/mob/living/carbon/slime/life.dm b/code/modules/mob/living/carbon/slime/life.dm index ce9fd53cb8f..c0d5e6a907b 100644 --- a/code/modules/mob/living/carbon/slime/life.dm +++ b/code/modules/mob/living/carbon/slime/life.dm @@ -191,7 +191,7 @@ return // if it's eating someone already, continue eating! if(target) - --target_patience + target_patience-- if(target_patience <= 0 || SStun || discipline || attacked) // Tired of chasing or something draws out attention target_patience = 0 target = null @@ -204,14 +204,10 @@ hungry = 1 if(hungry == 2 && !client) // if a slime is starving, it starts losing its friends - if(friends.len > 0 && prob(1)) + if(length(friends) && prob(1)) var/mob/nofriend = pick(friends) if(nofriend && friends[nofriend]) - friends[nofriend] -= 1 - if (friends[nofriend] <= 0) - friends[nofriend] = null - friends -= nofriend - friends -= null + friends[nofriend] = max(0, friends[nofriend] - 1) if(!target) if(will_hunt(hungry) || attacked || rabid) // Only add to the list if we need to @@ -222,7 +218,7 @@ continue if(isskrell(L)) // we do not attack skrell - lore reason. continue - if(L in friends) // No eating friends! + if(is_friend(L)) // No eating friends! continue if(issilicon(L) && (rabid || attacked)) // They can't eat silicons, but they can glomp them in defence @@ -243,7 +239,7 @@ targets += L // Possible target found! - if(targets.len > 0) + if(length(targets)) if(attacked || rabid || hungry == 2) target = targets[1] // I am attacked and am fighting back or so hungry I don't even care else @@ -392,10 +388,10 @@ //Speech understanding starts here var/to_say - if(speech_buffer.len > 0) + if(length(speech_buffer)) var/who = speech_buffer[1] // Who said it? var/phrase = speech_buffer[2] // What did they say? - if((findtext(phrase, num2text(number)) || findtext(phrase, "slimes"))) // Talking to us + if(findtext(phrase, num2text(number)) || findtext(phrase, "slime")) // Talking to us if(findtext(phrase, "hello") || findtext(phrase, "hi")) to_say = pick("Hello...", "Hi...") else if(findtext(phrase, "follow")) @@ -419,7 +415,7 @@ victim = null target = null if(friends[who] < 7) - --friends[who] + decrease_friendship(friends[who]) to_say = "Grrr..." // I'm angry but I do it else to_say = "Fine..." @@ -427,7 +423,7 @@ if(friends[who] > 3) target = null if(friends[who] < 6) - --friends[who] + decrease_friendship(friends[who]) to_say = "Grrr..." // I'm angry but I do it else to_say = "Fine..." @@ -465,23 +461,23 @@ else if(prob(1)) emote(pick("bounce","sway","light","vibrate","jiggle")) else - var/t = 10 + var/phrase_probability = 10 var/slimes_near = -1 // Don't count myself var/dead_slimes = 0 var/friends_near = list() - for(var/mob/living/carbon/M in view(7,src)) + for(var/mob/living/carbon/M in view(7, src)) if(isslime(M)) - ++slimes_near + slimes_near++ if(M.stat == DEAD) - ++dead_slimes - if(M in friends) - t += 20 + dead_slimes++ + if(is_friend(M)) + phrase_probability += 20 friends_near += M if(nutrition < get_hunger_nutrition()) - t += 10 + phrase_probability += 10 if(nutrition < get_starve_nutrition()) - t += 10 - if(prob(2) && prob(t)) + phrase_probability += 10 + if(prob(2) && prob(phrase_probability)) var/phrases = list() if(target) phrases += "[target]... looks tasty..." @@ -565,7 +561,7 @@ /mob/living/carbon/slime/proc/will_hunt(var/hunger) // Check for being stopped from feeding and chasing if(hunger == 2 || rabid || attacked) return TRUE - if(nutrition == get_max_nutrition()) + if(nutrition > get_max_nutrition() * 0.8) return FALSE if(leader) return FALSE diff --git a/code/modules/mob/living/carbon/slime/powers.dm b/code/modules/mob/living/carbon/slime/powers.dm index 326656446d8..5431d03d35f 100644 --- a/code/modules/mob/living/carbon/slime/powers.dm +++ b/code/modules/mob/living/carbon/slime/powers.dm @@ -86,8 +86,9 @@ if(victim) victim.updatehealth() - if(nutrition == get_max_nutrition()) + if(nutrition >= get_max_nutrition()) visible_message(SPAN_WARNING("\The [src] releases [victim], content and full."), SPAN_WARNING("You are full.")) + check_friendship_increase() // increase our friendship with the person who fed us break sleep(30) // Deal damage every 3 seconds @@ -97,19 +98,6 @@ canmove = TRUE anchored = FALSE - if(M && invalidFeedTarget(M)) // This means that the slime drained the victim - if(!client) - if(victim && !rabid && !attacked && victim.LAssailant && victim.LAssailant != victim && prob(50)) - var/real_assailant = victim.LAssailant.resolve() - if(real_assailant) - if(!(real_assailant in friends)) - friends[real_assailant] = TRUE - else - ++friends[real_assailant] - - else - to_chat(src, SPAN_NOTICE("This subject does not have a strong enough life energy anymore...")) - victim = null /mob/living/carbon/slime/proc/Feedstop() diff --git a/code/modules/mob/living/carbon/slime/say.dm b/code/modules/mob/living/carbon/slime/say.dm index 058c3bccc39..509f77e4a4b 100644 --- a/code/modules/mob/living/carbon/slime/say.dm +++ b/code/modules/mob/living/carbon/slime/say.dm @@ -25,15 +25,15 @@ return ..() /mob/living/carbon/slime/hear_say(var/message, var/verb = "says", var/datum/language/language = null, var/alt_name = "", var/italics = 0, var/mob/speaker = null, var/sound/speech_sound, var/sound_vol) - if(speaker in friends) + if(is_friend(speaker)) speech_buffer = list() speech_buffer.Add(speaker) speech_buffer.Add(lowertext(html_decode(message))) - ..() + return ..() /mob/living/carbon/slime/hear_radio(var/message, var/verb="says", var/datum/language/language=null, var/part_a, var/part_b, var/mob/speaker = null, var/hard_to_hear = 0, var/vname ="") - if(speaker in friends) + if(is_friend(speaker)) speech_buffer = list() speech_buffer.Add(speaker) speech_buffer.Add(lowertext(html_decode(message))) - ..() \ No newline at end of file + return ..() \ No newline at end of file diff --git a/code/modules/mob/living/carbon/slime/slime.dm b/code/modules/mob/living/carbon/slime/slime.dm index 57c15d82b97..13c41953b25 100644 --- a/code/modules/mob/living/carbon/slime/slime.dm +++ b/code/modules/mob/living/carbon/slime/slime.dm @@ -41,7 +41,7 @@ var/holding_still = 0 // AI variable, cooloff-ish for how long it's going to stay in one place var/target_patience = 0 // AI variable, cooloff-ish for how long it's going to follow its target - var/list/friends = list() // A list of friends; they are not considered targets for feeding; passed down after splitting + var/list/friends = list() // A list of friends; the higher their number value, the more we consider them a friend, people at 0 are no longer friends var/list/speech_buffer = list() // Last phrase said near it and person who said it diff --git a/html/changelogs/geeves-slime_cleanup.yml b/html/changelogs/geeves-slime_cleanup.yml new file mode 100644 index 00000000000..60f608dc12e --- /dev/null +++ b/html/changelogs/geeves-slime_cleanup.yml @@ -0,0 +1,9 @@ +author: Geeves + +delete-after: True + +changes: + - bugfix: "Killing a slime attached to someone will now detach it." + - tweak: "Slimes will not hunt if their nutrition is more than 80% of their max nutrition, and they aren't rabid or attacked." + - bugfix: "Fixed slime friendship." + - rscadd: "Slime friendship is now guaranteed if you feed them." \ No newline at end of file