[MIRROR] Player-controlled Regal Rats now lick or scratch based on their combat mode [MDB IGNORE] (#19941)

* Player-controlled Regal Rats now lick or scratch based on their combat mode (#74040)

## About The Pull Request
This updates Regal Rats to now check for a user's combat mode when
determining whether to lick or scratch a living target (Lick = combat
off, and Scratch = combat on). It also Closes #68621.

Additionally, it allows for player movement during the licking
interaction to properly cancel that action. Previously, it would attempt
a lick, the player would cancel it, and then the player would attack
their target instead (this was due to an oversight in the code).

Edit: It now also prevents NPC Regal rats from licking entirely, and
fixes their logic so that they move on to a new target after completing
a kill.

## Why It's Good For The Game
It allows players to control what their Regal rat does according to
their combat mode, which matches the behavior for other
player-controlled creatures (such as humans). Plus, this allows Regal
rats control over when to harm living creatures, making them much less
vulnerable than they were before.

Edit: As for NPC Regal rats, it allows them to be a bit more dangerous,
since they'll now only attack creatures that are alive. Moreover,
removing the ability to lick from NPCs helps avoid the strange scenario
where players could belong to a faction which is led by an NPC. (How can
one serve a King that lacks a sentient mind? Spacemen aren't ready for
that type of philosophical dilemma.)

## Changelog
🆑
fix: Player-controlled Regal Rats now lick or claw based on their combat
mode.
fix: NPC Regal rats now properly claw at enemies, moving on to new
targets after completing kills.
/🆑

---------

Co-authored-by: san7890 <the@ san7890.com>

* Player-controlled Regal Rats now lick or scratch based on their combat mode

---------

Co-authored-by: Antonio Tosti <5588048+atosti@users.noreply.github.com>
Co-authored-by: san7890 <the@ san7890.com>
This commit is contained in:
SkyratBot
2023-03-18 03:13:17 -07:00
committed by GitHub
co-authored by san7890 Antonio Tosti
parent 27f3faf02f
commit 6a75ebc943
@@ -99,7 +99,8 @@
/mob/living/simple_animal/hostile/regalrat/CanAttack(atom/the_target)
if(isliving(the_target))
var/mob/living/living_target = the_target
return !living_target.faction_check_mob(src, exact_match = TRUE)
if (living_target.stat != DEAD)
return !living_target.faction_check_mob(src, exact_match = TRUE)
return ..()
@@ -126,27 +127,19 @@
#define REGALRAT_INTERACTION "regalrat"
/mob/living/simple_animal/hostile/regalrat/AttackingTarget()
if (DOING_INTERACTION(src, REGALRAT_INTERACTION))
return
if (QDELETED(target))
if (DOING_INTERACTION(src, REGALRAT_INTERACTION) || QDELETED(target))
return
if(istype(target, /obj/machinery/door/airlock) && !opening_airlock)
pry_door(target)
return
if (target.reagents && target.is_injectable(src, allowmobs = TRUE) && !istype(target, /obj/item/food/cheese))
if (src.mind && !src.combat_mode && target.reagents && target.is_injectable(src, allowmobs = TRUE) && !istype(target, /obj/item/food/cheese))
src.visible_message(span_warning("[src] starts licking [target] passionately!"),span_notice("You start licking [target]..."))
if (do_after(src, 2 SECONDS, target, interaction_key = REGALRAT_INTERACTION))
target.reagents.add_reagent(/datum/reagent/rat_spit,rand(1,3),no_react = TRUE)
to_chat(src, span_notice("You finish licking [target]."))
return
return
else
SEND_SIGNAL(target, COMSIG_RAT_INTERACT, src)
if(QDELETED(target))
return
if (DOING_INTERACTION(src, REGALRAT_INTERACTION)) // check again in case we started interacting
return
return ..()
#undef REGALRAT_INTERACTION