Files
Bubberstation/code/datums/ai/robot_customer/robot_customer_controller.dm
SkyratBot bdc2b2d3c9 [MIRROR] Revives PR #58579; Sligh refactor to AI datums that allows for basic support of subtrees (#7214)
* Revives PR #58579; Sligh refactor to AI datums that allows for basic support of subtrees (#60249)

Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
Co-authored-by: coiax <yellowbounder@ gmail.com>
Co-authored-by: Watermelon914 <37270891+Watermelon914@ users.noreply.github.com>
Co-authored-by: Rohesie <rohesie@ gmail.com>
Co-authored-by: Matthew J. <12817816+ZephyrTFA@ users.noreply.github.com>
Co-authored-by: AnturK <AnturK@ users.noreply.github.com>
Co-authored-by: Jonathan Rubenstein <jrubcop@ gmail.com>
Co-authored-by: Kylerace <kylerlumpkin1@ gmail.com>
Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
Co-authored-by: tralezab <40974010+tralezab@ users.noreply.github.com>
Co-authored-by: Jordan Brown <Cyberboss@ users.noreply.github.com>
Co-authored-by: Fikou <piotrbryla@ onet.pl>
Co-authored-by: Emmanuel S. <emmanuelssr@ gmail.com>

* Revives PR #58579; Sligh refactor to AI datums that allows for basic support of subtrees

Co-authored-by: ma44 <guyonleagueoflegends@gmail.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
Co-authored-by: coiax <yellowbounder@ gmail.com>
Co-authored-by: Watermelon914 <37270891+Watermelon914@ users.noreply.github.com>
Co-authored-by: Rohesie <rohesie@ gmail.com>
Co-authored-by: Matthew J. <12817816+ZephyrTFA@ users.noreply.github.com>
Co-authored-by: AnturK <AnturK@ users.noreply.github.com>
Co-authored-by: Jonathan Rubenstein <jrubcop@ gmail.com>
Co-authored-by: Kylerace <kylerlumpkin1@ gmail.com>
Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
Co-authored-by: tralezab <40974010+tralezab@ users.noreply.github.com>
Co-authored-by: Jordan Brown <Cyberboss@ users.noreply.github.com>
Co-authored-by: Fikou <piotrbryla@ onet.pl>
Co-authored-by: Emmanuel S. <emmanuelssr@ gmail.com>
2021-07-29 11:11:03 +01:00

97 lines
3.5 KiB
Plaintext

/datum/ai_controller/robot_customer
ai_movement = /datum/ai_movement/basic_avoidance
movement_delay = 0.8 SECONDS
blackboard = list(BB_CUSTOMER_CURRENT_ORDER = null,
BB_CUSTOMER_MY_SEAT = null,
BB_CUSTOMER_PATIENCE = 999,
BB_CUSTOMER_CUSTOMERINFO = null,
BB_CUSTOMER_EATING = FALSE,
BB_CUSTOMER_LEAVING = FALSE,
BB_CUSTOMER_ATTENDING_VENUE = null,
BB_CUSTOMER_SAID_CANT_FIND_SEAT_LINE = FALSE)
planning_subtrees = list(/datum/ai_planning_subtree/robot_customer)
/datum/ai_controller/robot_customer/TryPossessPawn(atom/new_pawn)
if(!istype(new_pawn, /mob/living/simple_animal/robot_customer))
return AI_CONTROLLER_INCOMPATIBLE
RegisterSignal(new_pawn, COMSIG_PARENT_ATTACKBY, .proc/on_attackby)
RegisterSignal(new_pawn, COMSIG_LIVING_GET_PULLED, .proc/on_get_pulled)
RegisterSignal(new_pawn, COMSIG_ATOM_ATTACK_HAND, .proc/on_get_punched)
return ..() //Run parent at end
/datum/ai_controller/robot_customer/UnpossessPawn(destroy)
UnregisterSignal(pawn, list(COMSIG_PARENT_ATTACKBY, COMSIG_LIVING_GET_PULLED, COMSIG_ATOM_ATTACK_HAND))
return ..() //Run parent at end
/datum/ai_controller/robot_customer/proc/on_attackby(datum/source, obj/item/I, mob/living/user)
SIGNAL_HANDLER
var/datum/venue/attending_venue = blackboard[BB_CUSTOMER_ATTENDING_VENUE]
if(attending_venue.is_correct_order(I, blackboard[BB_CUSTOMER_CURRENT_ORDER]))
to_chat(user, span_notice("You hand [I] to [pawn]"))
eat_order(I, attending_venue)
return COMPONENT_NO_AFTERATTACK
else
INVOKE_ASYNC(src, .proc/warn_greytider, user)
/datum/ai_controller/robot_customer/proc/eat_order(obj/item/order_item, datum/venue/attending_venue)
if(!blackboard[BB_CUSTOMER_EATING])
blackboard[BB_CUSTOMER_EATING] = TRUE
attending_venue.on_get_order(pawn, order_item)
///Called when
/datum/ai_controller/robot_customer/proc/on_get_pulled(datum/source, mob/living/puller)
SIGNAL_HANDLER
INVOKE_ASYNC(src, .proc/async_on_get_pulled, source, puller)
/datum/ai_controller/robot_customer/proc/async_on_get_pulled(datum/source, mob/living/puller)
var/mob/living/simple_animal/robot_customer/customer = pawn
var/datum/customer_data/customer_data = blackboard[BB_CUSTOMER_CUSTOMERINFO]
var/datum/venue/attending_venue = blackboard[BB_CUSTOMER_ATTENDING_VENUE]
var/obj/item/card/id/used_id = puller.get_idcard(TRUE)
if(used_id && (attending_venue.req_access in used_id?.GetAccess()))
customer.say(customer_data.friendly_pull_line)
return
warn_greytider(puller)
customer.resist()
/datum/ai_controller/robot_customer/proc/warn_greytider(mob/living/greytider)
var/mob/living/simple_animal/robot_customer/customer = pawn
var/datum/venue/attending_venue = blackboard[BB_CUSTOMER_ATTENDING_VENUE]
var/datum/customer_data/customer_data = blackboard[BB_CUSTOMER_CUSTOMERINFO]
attending_venue.mob_blacklist[greytider] += 1
switch(attending_venue.mob_blacklist[greytider])
if(1)
customer.say(customer_data.first_warning_line)
return
if(2)
customer.say(customer_data.second_warning_line)
return
if(3)
customer.say(customer_data.self_defense_line)
blackboard[BB_CUSTOMER_CURRENT_TARGET] = greytider
CancelActions()
/datum/ai_controller/robot_customer/proc/on_get_punched(datum/source, mob/living/living_hitter)
SIGNAL_HANDLER
var/datum/venue/attending_venue = blackboard[BB_CUSTOMER_ATTENDING_VENUE]
var/obj/item/card/id/used_id = living_hitter.get_idcard(hand_first = TRUE)
if(used_id && (attending_venue.req_access in used_id?.GetAccess()))
return
if(living_hitter.combat_mode)
INVOKE_ASYNC(src, .proc/warn_greytider, living_hitter)