mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-19 22:23:11 +00:00
You no longer have to sacrifice your soul to give a mouse sentience. (#72782) ## About The Pull Request Some Manuel shift I didn't take note of the round ID for. A player ahelps because they LITERALLY VANISH. They think it's a genetic meltdown. I check the logs and I don't think it is. The player mentions they got attacked by a mouse just before they died. I check the logs and what do we have, but the same game tick the player gets yeeted into the void that a mouse gains sentience. ``` Line 11801: [2023-01-17 23:39:00.036] ACCESS: Mob Login: Cheeseromancer/(Lemmiwinks) was assigned to a /mob/living/basic/mouse/white Line 11802: [2023-01-17 23:39:00.052] GAME: Cheeseromancer/(Lemmiwinks) Client Cheeseromancer/(Lemmiwinks) has taken ownership of mob Lemmiwinks(/mob/living/basic/mouse/white) (Medbay Treatment Center (155,85,2)) Line 11804: [2023-01-17 23:39:00.068] ACCESS: Mob Login: Super17andre/(Carter Wolfe) was assigned to a /mob/dead/observer Line 11806: [2023-01-17 23:39:00.111] GAME: Cheeseromancer/(Lemmiwinks) has gained antag datum �Sentient Creature(/datum/antagonist/sentient_creature). ``` There's other chatter IC about sentience potions, which narrows down the investigation. Long story short, 20 month ago arm couldn't code and 20 month ago maintainers couldn't review code. On this blessed day, we're all complicit. `on_tame` signal handler proc. Without source parameter. Signal handler. Without source parameter.  This leads to your classic offset-by-1 arg error. The signal's source is the mouse. The tamer is the player that used the intelligence potion. There is no food. But because the signal handler omits source, the tamer is the mouse and the food is the tamer. Makes perfect sense in my head. The food then, obviously, gets qdeleted in the later after_tame callback invocation. Meaning the player using the sentience potion gets sent to the Shadow Realm with no log entries suggesting cause of death. Add in the missing source param, pass the source arg in the really, really bad signal handler proc being called directly. And we feex.  ## Why It's Good For The Game Players being randomly qdeleted leads to admins crying. In the future I'm going to log qdeletions of cliented mobs. March. Because I have time off work then. ## Changelog 🆑 fix: Mice given sentience through intelligence potions no longer immediately consume the body and soul of the person whom uplifted them. /🆑 Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
76 lines
2.7 KiB
Plaintext
76 lines
2.7 KiB
Plaintext
///This component lets you make specific mobs tameable by feeding them
|
|
/datum/component/tameable
|
|
///If true, this atom can only be domesticated by one person
|
|
var/unique
|
|
///What the mob eats, typically used for taming or animal husbandry.
|
|
var/list/food_types
|
|
///Starting success chance for taming.
|
|
var/tame_chance
|
|
///Added success chance after every failed tame attempt.
|
|
var/bonus_tame_chance
|
|
///Current chance to tame on interaction
|
|
var/current_tame_chance
|
|
///For effects once soemthing is tamed
|
|
var/datum/callback/after_tame
|
|
|
|
/datum/component/tameable/Initialize(food_types, tame_chance, bonus_tame_chance, datum/callback/after_tame, unique = TRUE)
|
|
if(!isatom(parent)) //yes, you could make a tameable toolbox.
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
if(food_types)
|
|
src.food_types = food_types
|
|
if(tame_chance)
|
|
src.tame_chance = tame_chance
|
|
src.current_tame_chance = tame_chance
|
|
if(bonus_tame_chance)
|
|
src.bonus_tame_chance = bonus_tame_chance
|
|
if(after_tame)
|
|
src.after_tame = after_tame
|
|
src.unique = unique
|
|
|
|
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(try_tame))
|
|
RegisterSignal(parent, COMSIG_SIMPLEMOB_SENTIENCEPOTION, PROC_REF(on_tame)) //Instantly succeeds
|
|
RegisterSignal(parent, COMSIG_SIMPLEMOB_TRANSFERPOTION, PROC_REF(on_tame)) //Instantly succeeds
|
|
|
|
/datum/component/tameable/proc/try_tame(datum/source, obj/item/food, mob/living/attacker, params)
|
|
SIGNAL_HANDLER
|
|
if(!is_type_in_list(food, food_types))
|
|
return
|
|
if(isliving(source))
|
|
var/mob/living/potentially_dead_horse = source
|
|
if(potentially_dead_horse.stat == DEAD)
|
|
to_chat(attacker, span_warning("[parent] is dead!"))
|
|
return COMPONENT_CANCEL_ATTACK_CHAIN
|
|
|
|
var/atom/atom_parent = source
|
|
atom_parent.balloon_alert(attacker, "fed")
|
|
if(unique || !already_friends(attacker))
|
|
if(prob(current_tame_chance)) //note: lack of feedback message is deliberate, keep them guessing!
|
|
on_tame(source, attacker, food)
|
|
else
|
|
current_tame_chance += bonus_tame_chance
|
|
|
|
qdel(food)
|
|
return COMPONENT_CANCEL_ATTACK_CHAIN
|
|
|
|
/// Check if the passed mob is already considered one of our friends
|
|
/datum/component/tameable/proc/already_friends(mob/living/potential_friend)
|
|
if(!isliving(parent))
|
|
return FALSE // Figure this out when we actually need it
|
|
var/mob/living/living_parent = parent
|
|
return living_parent.faction.Find(REF(potential_friend))
|
|
|
|
///Ran once taming succeeds
|
|
/datum/component/tameable/proc/on_tame(datum/source, mob/living/tamer, atom/food)
|
|
SIGNAL_HANDLER
|
|
after_tame?.Invoke(tamer, food)//Run custom behavior if needed
|
|
|
|
if(isliving(parent) && isliving(tamer))
|
|
var/mob/living/tamed = parent
|
|
INVOKE_ASYNC(tamed, TYPE_PROC_REF(/mob/living, befriend), tamer)
|
|
|
|
if(unique)
|
|
qdel(src)
|
|
else
|
|
current_tame_chance = tame_chance
|