Retaliate Fix and Tweak (#10992)

Animals that only attack when attacked now properly add the person who attacks them to their target list.
    Retaliating animals now only attack the person who attacked them.
This commit is contained in:
Geeves
2021-01-23 23:00:04 +02:00
committed by GitHub
parent 4ff6d6648c
commit 5a1069baed
3 changed files with 40 additions and 23 deletions

View File

@@ -15,28 +15,36 @@
enemies -= L
/mob/living/simple_animal/hostile/retaliate/ListTargets()
if(!enemies.len)
if(!length(enemies))
return list()
var/list/see = ..()
see &= enemies // Remove all entries that aren't in enemies
return see
/mob/living/simple_animal/hostile/retaliate/proc/Retaliate()
var/list/around = view(src, 7)
/mob/living/simple_animal/hostile/retaliate/proc/Retaliate(var/mob/M)
enemies |= M
targets |= M
for(var/atom/movable/A in around)
if(A == src)
continue
if(isliving(A))
var/mob/living/M = A
if(!attack_same && M.faction != faction)
enemies |= M
for(var/mob/living/simple_animal/hostile/retaliate/H in view(world.view, get_turf(src)))
if(H.faction == faction)
H.enemies |= M
for(var/mob/living/simple_animal/hostile/retaliate/H in around)
if(!attack_same && !H.attack_same && H.faction == faction)
H.enemies |= enemies
return 0
/mob/living/simple_animal/hostile/retaliate/attack_hand(mob/living/carbon/human/M)
. = ..()
if(M.a_intent in list(I_DISARM, I_GRAB, I_HURT))
Retaliate(M)
/mob/living/simple_animal/hostile/retaliate/adjustBruteLoss(var/damage)
..(damage)
Retaliate()
/mob/living/simple_animal/hostile/retaliate/attacked_with_item(obj/item/O, mob/user, var/proximity)
. = ..()
if(.)
Retaliate(user)
/mob/living/simple_animal/hostile/retaliate/hitby(atom/movable/AM, speed)
. = ..()
if(ismob(AM.thrower))
Retaliate(AM.thrower)
/mob/living/simple_animal/hostile/retaliate/bullet_act(obj/item/projectile/P, def_zone)
. = ..()
if(ismob(P.firer))
Retaliate(P.firer)

View File

@@ -498,6 +498,12 @@ mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj)
..()
poke()
else if(istype(O, brush) && canbrush) //Brushing animals
visible_message("<b>\The [user]</b> gently brushes \the [src] with \the [O].")
if(prob(15) && !istype(src, /mob/living/simple_animal/hostile)) //Aggressive animals don't purr before biting your face off.
visible_message("<b>[capitalize_first_letters(src.name)]</b> [speak_emote.len ? pick(speak_emote) : "rumbles"].") //purring
return
else if(meat_type && (stat == DEAD)) //if the animal has a meat, and if it is dead.
if(istype(O, /obj/item/material/knife) || istype(O, /obj/item/material/kitchen/utensil/knife)|| istype(O, /obj/item/material/hatchet))
harvest(user)
@@ -508,13 +514,8 @@ mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj)
/mob/living/simple_animal/proc/attacked_with_item(obj/item/O, mob/user, var/proximity)
if(istype(O, /obj/item/trap/animal) || istype(O, /obj/item/gun))
O.attack(src, user)
return
return TRUE
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
if(istype(O, brush) && canbrush) //Brushing animals
visible_message("<b>\The [user]</b> gently brushes \the [src] with \the [O].")
if(prob(15) && !istype(src, /mob/living/simple_animal/hostile)) //Aggressive animals don't purr before biting your face off.
visible_message("<b>[capitalize_first_letters(src.name)]</b> [speak_emote.len ? pick(speak_emote) : "rumbles"].") //purring
return
if(istype(O, /obj/item/glass_jar))
return FALSE
if(!O.force)
@@ -538,6 +539,7 @@ mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj)
visible_message(SPAN_DANGER("\The [src] has been attacked with \the [O] by \the [user]."))
user.do_attack_animation(src)
return TRUE
/mob/living/simple_animal/apply_damage(damage, damagetype, def_zone, blocked, used_weapon, damage_flags)
. = ..()