Monkeys and dogs no longer yoink items they can't reach. (#60150)

* Monkeys and dogs no longer yoink items they can't reach.

Title. More ai behavior botherations.
This commit is contained in:
Ghom
2021-07-12 08:46:55 +02:00
committed by GitHub
parent 4a8a9d57bf
commit ffbda0f748
2 changed files with 7 additions and 9 deletions
+3 -6
View File
@@ -10,15 +10,12 @@
var/mob/living/living_pawn = controller.pawn
var/obj/item/fetch_thing = controller.blackboard[BB_FETCH_TARGET]
if(fetch_thing.anchored || !isturf(fetch_thing.loc) || IS_EDIBLE(fetch_thing)) //either we can't pick it up, or we'd rather eat it, so stop trying.
//either we can't pick it up, or we'd rather eat it, so stop trying.
if(fetch_thing.anchored || !isturf(fetch_thing.loc) || IS_EDIBLE(fetch_thing) || !living_pawn.CanReach(fetch_thing))
finish_action(controller, FALSE)
return
if(in_range(living_pawn, fetch_thing))
finish_action(controller, TRUE)
return
finish_action(controller, FALSE)
finish_action(controller, TRUE)
/datum/ai_behavior/fetch/finish_action(datum/ai_controller/controller, success)
. = ..()
+4 -3
View File
@@ -79,12 +79,13 @@
var/obj/item/target = controller.blackboard[BB_MONKEY_PICKUPTARGET]
var/mob/living/victim = target.loc
var/mob/living/living_pawn = controller.pawn
if(!istype(victim))
if(!istype(victim) || !living_pawn.CanReach(victim))
finish_action(controller, FALSE)
return
var/mob/living/living_pawn = controller.pawn
victim.visible_message(span_warning("[living_pawn] starts trying to take [target] from [victim]!"), span_danger("[living_pawn] tries to take [target]!"))
@@ -92,7 +93,7 @@
var/success = FALSE
if(do_mob(living_pawn, victim, MONKEY_ITEM_SNATCH_DELAY) && target)
if(do_mob(living_pawn, victim, MONKEY_ITEM_SNATCH_DELAY) && target && living_pawn.CanReach(victim))
for(var/obj/item/I in victim.held_items)
if(I == target)