-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mobs * somemore * more ai * Update stonekeep.dme * Update bloodcrawl.dm
- Loading branch information
Showing
19 changed files
with
839 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* # Targeted Mob Ability | ||
* Attempts to use a mob's cooldown ability on a target | ||
*/ | ||
/datum/ai_behavior/targeted_mob_ability | ||
|
||
/datum/ai_behavior/targeted_mob_ability/perform(seconds_per_tick, datum/ai_controller/controller, ability_key, target_key) | ||
var/obj/effect/proc_holder/spell/ability = controller.blackboard[ability_key] | ||
var/mob/living/target = controller.blackboard[target_key] | ||
if(QDELETED(ability) || QDELETED(target)) | ||
finish_action(controller, FALSE, ability_key, target_key) | ||
return | ||
var/mob/pawn = controller.pawn | ||
pawn.face_atom(target) | ||
var/result = ability.perform(targets = list(target), user = controller.pawn) | ||
finish_action(controller, result, ability_key, target_key) | ||
|
||
/datum/ai_behavior/targeted_mob_ability/finish_action(datum/ai_controller/controller, succeeded, ability_key, target_key) | ||
. = ..() | ||
var/atom/target = controller.blackboard[target_key] | ||
if (QDELETED(target)) | ||
controller.clear_blackboard_key(target_key) | ||
|
||
/** | ||
* # Try Mob Ability and clear target | ||
* Attempts to use a mob's cooldown ability on a target and releases the target when the action completes | ||
*/ | ||
/datum/ai_behavior/targeted_mob_ability/and_clear_target | ||
|
||
/datum/ai_behavior/targeted_mob_ability/and_clear_target/finish_action(datum/ai_controller/controller, succeeded, ability_key, target_key) | ||
. = ..() | ||
controller.clear_blackboard_key(target_key) | ||
|
||
/datum/ai_behavior/targeted_mob_ability/proc/get_ability_to_use(datum/ai_controller/controller, ability_key) | ||
return controller.blackboard[ability_key] | ||
|
||
/** | ||
* Attempts to move into the provided range and then use a mob's cooldown ability on a target | ||
*/ | ||
/datum/ai_behavior/targeted_mob_ability/min_range | ||
required_distance = 6 | ||
behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | ||
var/datum/ai_movement/new_movement | ||
|
||
/datum/ai_behavior/targeted_mob_ability/min_range/setup(datum/ai_controller/controller, ability_key, target_key) | ||
. = ..() | ||
var/atom/target = controller.blackboard[target_key] | ||
if(QDELETED(target)) | ||
return FALSE | ||
set_movement_target(controller, target, new_movement) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// Attempts to use a mob ability on a target | ||
/datum/ai_planning_subtree/targeted_mob_ability | ||
/// Blackboard key for the ability | ||
var/ability_key = BB_TARGETED_ACTION | ||
/// Blackboard key for where the target ref is stored | ||
var/target_key = BB_BASIC_MOB_CURRENT_TARGET | ||
/// Behaviour to perform using ability | ||
var/use_ability_behaviour = /datum/ai_behavior/targeted_mob_ability | ||
/// If true we terminate planning after trying to use the ability. | ||
var/finish_planning = TRUE | ||
|
||
/datum/ai_planning_subtree/targeted_mob_ability/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) | ||
if (!ability_key) | ||
CRASH("You forgot to tell this mob where to find its ability") | ||
|
||
if (!(target_key in controller.blackboard)) | ||
return | ||
|
||
var/obj/effect/proc_holder/spell/using_action = controller.blackboard[ability_key] | ||
if (!using_action?.recharging) | ||
return | ||
|
||
controller.queue_behavior(use_ability_behaviour, ability_key, target_key) | ||
if (finish_planning) | ||
return SUBTREE_RETURN_FINISH_PLANNING | ||
|
||
/datum/ai_planning_subtree/targeted_mob_ability/continue_planning | ||
finish_planning = FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.