mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-18 21:53:22 +00:00
* Fixes Pathfinder module AGAIN, General JPS Tweak (#84348) ## About The Pull Request 1. Fixes the modsuit pathfinder module's pathfinding for the second time. This time AI idling broke it, we just make it not idle. 2. Changes the heuristic used by JPS nodes from Chebyshev distance to Euclidean distance. I have no real logical explanation, it just appeared to produce a more optimal path. CC @ LemonInTheDark 3. Renames `get_dist_euclidian()` to `get_dist_euclidean()`. Red line: Euclidean dist JPS path (roughly) Green line: Chebyshev dist JPS path (roughly)  ## Changelog 🆑 fix: MODsuit pathfinder module works. Again. code: AI pathfinding should produce slightly better paths. /🆑 * Fixes Pathfinder module AGAIN, General JPS Tweak * Update goldeneye.dm --------- Co-authored-by: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Co-authored-by: SpaceLoveSs13 <68121607+SpaceLoveSs13@users.noreply.github.com>
49 lines
1.9 KiB
Plaintext
49 lines
1.9 KiB
Plaintext
/// 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,
|
|
)
|
|
can_idle = FALSE
|
|
max_target_distance = MOD_AI_RANGE //a little spicy but its one specific item that summons it, and it doesn't 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/SelectBehaviors(seconds_per_tick)
|
|
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(seconds_per_tick, datum/ai_controller/controller)
|
|
if(!controller.pawn.Adjacent(controller.blackboard[BB_MOD_TARGET]))
|
|
return AI_BEHAVIOR_DELAY
|
|
var/obj/item/implant/mod/implant = controller.blackboard[BB_MOD_IMPLANT]
|
|
implant.module.attach(controller.blackboard[BB_MOD_TARGET])
|
|
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED
|
|
|
|
/datum/ai_behavior/mod_attach/finish_action(datum/ai_controller/controller, succeeded)
|
|
. = ..()
|
|
controller.clear_blackboard_key(BB_MOD_TARGET)
|
|
var/obj/item/implant/mod/implant = controller.blackboard[BB_MOD_IMPLANT]
|
|
implant.end_recall(succeeded)
|