mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-14 02:43:16 +00:00
Simple_animals / mobs are the biggest lie in this code-base. They're far from simple and have an extreme god-object problem. Especially when you get to /hostile, where there is so many procs, vars, and what not, that you can't make any interesting additions without snowflaking the hell out of the code. This PR hopes to help kill this problem by introducing a new /living subtype, /living/basic. The idea of this refactor is to slowly start moving all old simple_animals to this new system, moving over behaviors like charging and more extravagant mobs like megafauna over bit by bit similar to how newfood was implemented. One of the other big goals of this refactor is to move many of the fringe simple animal behaviors into either AI datums, or components/elements. (Some of which still needs to be done in this PR). As a proof of concept, I created the base mob/living/basic, and moved cockroaches over to the system. Since cockroaches have both a passive, melee and ranged mob. This PR does slightly affect balance as the behavior isn't 1-on-1 due to it no longer running on the janky /hostile behavior, but I tried to keep the effects to a minimum, and the glockroach and hauberoach are not spawnable through many means as far as I know.
27 lines
1.3 KiB
Plaintext
27 lines
1.3 KiB
Plaintext
///Abstract class for an action an AI can take, can range from movement to grabbing a nearby weapon.
|
|
/datum/ai_behavior
|
|
///What distance you need to be from the target to perform the action
|
|
var/required_distance = 1
|
|
///Flags for extra behavior
|
|
var/behavior_flags = NONE
|
|
///Cooldown between actions performances, defaults to the value of CLICK_CD_MELEE because that seemed like a nice standard for the speed of AI behavior
|
|
var/action_cooldown = CLICK_CD_MELEE
|
|
|
|
/// Called by the ai controller when first being added. Additional arguments depend on the behavior type.
|
|
/// Return FALSE to cancel
|
|
/datum/ai_behavior/proc/setup(datum/ai_controller/controller, ...)
|
|
return TRUE
|
|
|
|
///Called by the AI controller when this action is performed
|
|
/datum/ai_behavior/proc/perform(delta_time, datum/ai_controller/controller, ...)
|
|
controller.behavior_cooldowns[src] = world.time + action_cooldown
|
|
return
|
|
|
|
///Called when the action is finished. This needs the same args as perform besides the default ones
|
|
/datum/ai_behavior/proc/finish_action(datum/ai_controller/controller, succeeded, ...)
|
|
LAZYREMOVE(controller.current_behaviors, src)
|
|
controller.behavior_args -= type
|
|
if(behavior_flags & AI_BEHAVIOR_REQUIRE_MOVEMENT) //If this was a movement task, reset our movement target.
|
|
controller.current_movement_target = null
|
|
controller.ai_movement.stop_moving_towards(controller)
|