From 070b3b7acba1c71ac69c5ee87f5d10753e3d3d30 Mon Sep 17 00:00:00 2001 From: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Date: Wed, 15 Nov 2023 05:28:47 +0200 Subject: [PATCH] ppokp --- code/datums/components/listen_and_repeat.dm | 6 ------ code/datums/diseases/parrotpossession.dm | 13 +++++++------ code/modules/mob/living/basic/pets/parrot/parrot.dm | 9 +++++++++ .../pets/parrot/parrot_ai/parrot_controller.dm | 8 +++++++- .../basic/pets/parrot/parrot_ai/parroting_action.dm | 7 ++++--- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/code/datums/components/listen_and_repeat.dm b/code/datums/components/listen_and_repeat.dm index 64d220ea5bc80..093557ec03b82 100644 --- a/code/datums/components/listen_and_repeat.dm +++ b/code/datums/components/listen_and_repeat.dm @@ -30,12 +30,6 @@ RegisterSignal(parent, COMSIG_MOVABLE_PRE_HEAR, PROC_REF(on_hear)) RegisterSignal(parent, COMSIG_NEEDS_NEW_PHRASE, PROC_REF(set_new_blackboard_phrase)) RegisterSignal(parent, COMSIG_LIVING_WRITE_MEMORY, PROC_REF(on_write_memory)) - RegisterSignal(parent, COMSIG_MOB_LOGIN, PROC_REF(on_login)) - -/// Called if a client logs in- don't want to be forced speaking while under their control (sadly) -/datum/component/listen_and_repeat/proc/on_login(datum/source) - SIGNAL_HANDLER - qdel(src) /// Called when we hear something. /datum/component/listen_and_repeat/proc/on_hear(datum/source, list/passed_arguments) diff --git a/code/datums/diseases/parrotpossession.dm b/code/datums/diseases/parrotpossession.dm index c2828fc6bb22f..2041810581305 100644 --- a/code/datums/diseases/parrotpossession.dm +++ b/code/datums/diseases/parrotpossession.dm @@ -15,18 +15,18 @@ bypasses_immunity = TRUE //2spook ///chance we speak var/speak_chance = 5 - ///list of words we can use - var/list/speech_list = null + ///controller we speak from + var/datum/ai_controller/basic_controller/parrot_controller /datum/disease/parrot_possession/stage_act(seconds_per_tick, times_fired) . = ..() - if(!.) + if(!. || isnull(parrot_controller)) return - if(LAZYLEN(speech_list) && SPT_PROB(speak_chance, seconds_per_tick)) // I'm not going to dive into polycode trying to adjust that probability. Enjoy doubled ghost parrot speach - affected_mob.say(pick(speech_list), forced = "parrot possession") + if(SPT_PROB(speak_chance, seconds_per_tick) && !isnull(parrot_controller.blackboard[BB_PARROT_REPEAT_STRING])) // I'm not going to dive into polycode trying to adjust that probability. Enjoy doubled ghost parrot speach + affected_mob.say(parrot_controller.blackboard[BB_PARROT_REPEAT_STRING], forced = "parrot possession") /datum/disease/parrot_possession/cure() @@ -35,10 +35,11 @@ UnregisterSignal(inside_parrot, list(COMSIG_PREQDELETED, COMSIG_MOVABLE_MOVED)) inside_parrot.forceMove(affected_mob.drop_location()) affected_mob.visible_message(span_danger("[inside_parrot] is violently driven out of [affected_mob]!"), span_userdanger("[inside_parrot] bursts out of your chest!")) + parrot_controller = null return ..() /datum/disease/parrot_possession/proc/set_parrot(mob/living/parrot) - speech_list = parrot.ai_controller?.blackboard[BB_EXPORTABLE_STRING_BUFFER_LIST] + parrot_controller = parrot.ai_controller RegisterSignals(parrot, list(COMSIG_PREQDELETED, COMSIG_MOVABLE_MOVED), PROC_REF(on_parrot_exit)) /datum/disease/parrot_possession/proc/on_parrot_exit(datum/source) diff --git a/code/modules/mob/living/basic/pets/parrot/parrot.dm b/code/modules/mob/living/basic/pets/parrot/parrot.dm index 27c2af0bbf8b9..df36b0210edc5 100644 --- a/code/modules/mob/living/basic/pets/parrot/parrot.dm +++ b/code/modules/mob/living/basic/pets/parrot/parrot.dm @@ -98,6 +98,7 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list( RegisterSignal(src, COMSIG_MOB_CLICKON, PROC_REF(on_click)) RegisterSignal(src, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attacked)) // this means we could have a peaceful interaction, like getting a cracker RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_injured)) // this means we got hurt and it's go time + RegisterSignal(src, COMSIG_KB_MOB_DROPITEM_DOWN, PROC_REF(drop_held_item)) /mob/living/basic/parrot/Destroy() // should have cleaned these up on death, but let's be super safe in case that didn't happen @@ -399,3 +400,11 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list( /mob/living/basic/parrot/proc/tamed() new /obj/effect/temp_visual/heart(drop_location()) + +/mob/living/basic/parrot/proc/drop_held_item(mob/living/user) + SIGNAL_HANDLER + + if(isnull(held_item)) + return + dropItemToGround(held_item) + return COMSIG_KB_ACTIVATED diff --git a/code/modules/mob/living/basic/pets/parrot/parrot_ai/parrot_controller.dm b/code/modules/mob/living/basic/pets/parrot/parrot_ai/parrot_controller.dm index 63f2ed7ed5bac..43f6de54ad8a7 100644 --- a/code/modules/mob/living/basic/pets/parrot/parrot_ai/parrot_controller.dm +++ b/code/modules/mob/living/basic/pets/parrot/parrot_ai/parrot_controller.dm @@ -26,6 +26,9 @@ return ..() ///subtree to steal items +/datum/ai_planning_subtree/hoard_items + var/theft_chance = 5 + /datum/ai_planning_subtree/hoard_items/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) var/mob/living/living_pawn = controller.pawn @@ -45,8 +48,11 @@ controller.queue_behavior(/datum/ai_behavior/basic_melee_attack/interact_once, BB_HOARD_ITEM_TARGET, BB_TARGETING_STRATEGY) return SUBTREE_RETURN_FINISH_PLANNING + if(!SPT_PROB(theft_chance, seconds_per_tick)) + return controller.queue_behavior(/datum/ai_behavior/find_and_set/hoard_item, BB_HOARD_ITEM_TARGET) +/datum/ai_behavior/find_and_set/hoard_location /datum/ai_behavior/find_and_set/hoard_location/search_tactic(datum/ai_controller/controller, locate_path, search_range) for(var/turf/open/candidate in oview(search_range, controller.pawn)) @@ -215,7 +221,7 @@ ///subtree to possess humans /datum/ai_planning_subtree/possess_humans ///chance we go possess humans - var/possess_chance = 2 + var/possess_chance = 80 /datum/ai_planning_subtree/possess_humans/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) var/mob/living/living_pawn = controller.pawn diff --git a/code/modules/mob/living/basic/pets/parrot/parrot_ai/parroting_action.dm b/code/modules/mob/living/basic/pets/parrot/parrot_ai/parroting_action.dm index 10e680e03ac0e..d1488a60b3bb9 100644 --- a/code/modules/mob/living/basic/pets/parrot/parrot_ai/parroting_action.dm +++ b/code/modules/mob/living/basic/pets/parrot/parrot_ai/parroting_action.dm @@ -3,15 +3,16 @@ operational_datums = list(/datum/component/listen_and_repeat) /datum/ai_planning_subtree/parrot_as_in_repeat/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - if(!SPT_PROB(controller.blackboard[BB_PARROT_REPEAT_PROBABILITY], seconds_per_tick)) - return - var/atom/speaking_pawn = controller.pawn + var/switch_up_probability = controller.blackboard[BB_PARROT_PHRASE_CHANGE_PROBABILITY] if(SPT_PROB(switch_up_probability, seconds_per_tick) || isnull(controller.blackboard[BB_PARROT_REPEAT_STRING])) if(SEND_SIGNAL(speaking_pawn, COMSIG_NEEDS_NEW_PHRASE) & NO_NEW_PHRASE_AVAILABLE) return + if(!SPT_PROB(controller.blackboard[BB_PARROT_REPEAT_PROBABILITY], seconds_per_tick)) + return + var/potential_string = controller.blackboard[BB_PARROT_REPEAT_STRING] if(isnull(potential_string)) stack_trace("Parrot As In Repeat Subtree somehow is getting a null potential string while not getting `NO_NEW_PHRASE_AVAILABLE`!")