-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathmod.dm
49 lines (41 loc) · 1.89 KB
/
mod.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/// An AI controller for the MODsuit pathfinder module. It's activated by implant and attaches itself to the user.
/datum/ai_controller/mod
blackboard = list(
BB_MOD_TARGET,
BB_MOD_IMPLANT,
)
max_target_distance = MOD_AI_RANGE //a little spicy but its one specific item that summons it, and it doesnt run otherwise
ai_movement = /datum/ai_movement/jps/modsuit
///ID card generated from the suit's required access. Used for pathing.
var/obj/item/card/id/advanced/id_card
/datum/ai_controller/mod/TryPossessPawn(atom/new_pawn)
if(!istype(new_pawn, /obj/item/mod/control))
return AI_CONTROLLER_INCOMPATIBLE
var/obj/item/mod/control/mod = new_pawn
id_card = new /obj/item/card/id/advanced/simple_bot()
if(length(mod.req_access))
id_card.set_access(mod.req_access)
return ..() //Run parent at end
/datum/ai_controller/mod/UnpossessPawn(destroy)
QDEL_NULL(id_card)
return ..() //Run parent at end
/datum/ai_controller/mod/ProcessBehaviorSelection(delta_time)
current_behaviors = list()
if(blackboard[BB_MOD_TARGET] && blackboard[BB_MOD_IMPLANT])
queue_behavior(/datum/ai_behavior/mod_attach)
/datum/ai_controller/mod/get_access()
return id_card.GetAccess()
/datum/ai_behavior/mod_attach
behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT|AI_BEHAVIOR_MOVE_AND_PERFORM
/datum/ai_behavior/mod_attach/perform(delta_time, datum/ai_controller/controller)
. = ..()
if(!controller.pawn.Adjacent(controller.blackboard[BB_MOD_TARGET]))
return BEHAVIOR_PERFORM_COOLDOWN
var/obj/item/implant/mod/implant = controller.blackboard[BB_MOD_IMPLANT]
implant.module.attach(controller.blackboard[BB_MOD_TARGET])
return BEHAVIOR_PERFORM_COOLDOWN | BEHAVIOR_PERFORM_SUCCESS
/datum/ai_behavior/mod_attach/finish_action(datum/ai_controller/controller, succeeded)
. = ..()
controller.set_blackboard_key(BB_MOD_TARGET, null)
var/obj/item/implant/mod/implant = controller.blackboard[BB_MOD_IMPLANT]
implant.end_recall(succeeded)