mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 21:48:39 +01:00
[MIRROR] ice demon basic mobs [MDB IGNORE] (#24188)
* ice demon basic mobs * Modular updates * Modular updates --------- Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
This commit is contained in:
co-authored by
Ben10Omintrix
Giz
parent
afa41aae57
commit
ade3fb2813
@@ -8,6 +8,8 @@
|
||||
var/maximum_distance = 6
|
||||
/// How far do we look for our target?
|
||||
var/view_distance = 10
|
||||
/// the run away behavior we will use
|
||||
var/run_away_behavior = /datum/ai_behavior/step_away
|
||||
|
||||
/datum/ai_planning_subtree/maintain_distance/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
|
||||
. = ..()
|
||||
@@ -16,12 +18,15 @@
|
||||
return // Don't run away from cucumbers, they're not snakes
|
||||
var/range = get_dist(controller.pawn, target)
|
||||
if (range < minimum_distance)
|
||||
controller.queue_behavior(/datum/ai_behavior/step_away, target_key)
|
||||
controller.queue_behavior(run_away_behavior, target_key, minimum_distance)
|
||||
return
|
||||
if (range > maximum_distance)
|
||||
controller.queue_behavior(/datum/ai_behavior/pursue_to_range, target_key, maximum_distance)
|
||||
return
|
||||
|
||||
/datum/ai_planning_subtree/maintain_distance/cover_minimum_distance
|
||||
run_away_behavior = /datum/ai_behavior/cover_minimum_distance
|
||||
|
||||
/// Take one step away
|
||||
/datum/ai_behavior/step_away
|
||||
behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION
|
||||
@@ -80,3 +85,32 @@
|
||||
if (!QDELETED(current_target) && get_dist(controller.pawn, current_target) > range)
|
||||
return
|
||||
finish_action(controller, succeeded = TRUE)
|
||||
|
||||
///instead of taking a single step, we cover the entire distance
|
||||
/datum/ai_behavior/cover_minimum_distance
|
||||
behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION
|
||||
required_distance = 0
|
||||
action_cooldown = 0.2 SECONDS
|
||||
|
||||
/datum/ai_behavior/cover_minimum_distance/setup(datum/ai_controller/controller, target_key, minimum_distance)
|
||||
. = ..()
|
||||
var/atom/target = controller.blackboard[target_key]
|
||||
if(QDELETED(target))
|
||||
return FALSE
|
||||
var/required_distance = minimum_distance - get_dist(controller.pawn, target) //the distance we need to move
|
||||
var/distance = 0
|
||||
var/turf/chosen_turf
|
||||
for(var/turf/open/potential_turf in oview(required_distance, controller.pawn))
|
||||
var/new_distance_from_target = get_dist(potential_turf, target)
|
||||
if(potential_turf.is_blocked_turf())
|
||||
continue
|
||||
if(new_distance_from_target > distance)
|
||||
chosen_turf = potential_turf
|
||||
distance = new_distance_from_target
|
||||
if(isnull(chosen_turf))
|
||||
return FALSE
|
||||
set_movement_target(controller, target = chosen_turf)
|
||||
|
||||
/datum/ai_behavior/cover_minimum_distance/perform(seconds_per_tick, datum/ai_controller/controller, target_key)
|
||||
. = ..()
|
||||
finish_action(controller, succeeded = TRUE)
|
||||
|
||||
Reference in New Issue
Block a user