Slime Clean-up (#9515)

This commit is contained in:
Geeves
2020-08-02 16:02:58 +02:00
committed by GitHub
parent 43d0d84642
commit 164066be9e
9 changed files with 64 additions and 43 deletions
@@ -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
@@ -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)
+19 -23
View File
@@ -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
+2 -14
View File
@@ -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()
+4 -4
View File
@@ -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)))
..()
return ..()
@@ -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