Skip to content

Commit

Permalink
ppokp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben10Omintrix committed Nov 15, 2023
1 parent 482b53d commit 070b3b7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
6 changes: 0 additions & 6 deletions code/datums/components/listen_and_repeat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions code/datums/diseases/parrotpossession.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions code/modules/mob/living/basic/pets/parrot/parrot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`!")
Expand Down

0 comments on commit 070b3b7

Please sign in to comment.