mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 09:05:11 +01:00
event based incapicated and able_to_run (#86031)
## About The Pull Request this is a revival of #82635 . i got permission from potato to reopen this, he did almost all the work. i only just solved the conflicts and fixed all the bugs that were preventing the original from being merged (but it should be TMed first) ## Why It's Good For The Game slightly improves the performance of basic mob AI ## Changelog 🆑 LemonInTheDark refactor: able_to_run and incapacitated have been refactored to be event based /🆑 --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: ZephyrTFA <matthew@tfaluc.com>
This commit is contained in:
@@ -12,17 +12,29 @@
|
||||
|
||||
return ..() //Run parent at end
|
||||
|
||||
|
||||
/datum/ai_controller/basic_controller/able_to_run()
|
||||
/datum/ai_controller/basic_controller/on_stat_changed(mob/living/source, new_stat)
|
||||
. = ..()
|
||||
if(!isliving(pawn))
|
||||
return
|
||||
var/mob/living/living_pawn = pawn
|
||||
var/incap_flags = NONE
|
||||
if (ai_traits & CAN_ACT_IN_STASIS)
|
||||
incap_flags |= IGNORE_STASIS
|
||||
if(!(ai_traits & CAN_ACT_WHILE_DEAD) && (living_pawn.incapacitated(incap_flags) || living_pawn.stat))
|
||||
update_able_to_run()
|
||||
|
||||
/datum/ai_controller/basic_controller/setup_able_to_run()
|
||||
. = ..()
|
||||
RegisterSignal(pawn, COMSIG_MOB_INCAPACITATE_CHANGED, PROC_REF(update_able_to_run))
|
||||
|
||||
/datum/ai_controller/basic_controller/clear_able_to_run()
|
||||
UnregisterSignal(pawn, list(COMSIG_MOB_INCAPACITATE_CHANGED, COMSIG_MOB_STATCHANGE))
|
||||
return ..()
|
||||
|
||||
/datum/ai_controller/basic_controller/get_able_to_run()
|
||||
. = ..()
|
||||
if(!.)
|
||||
return FALSE
|
||||
var/mob/living/living_pawn = pawn
|
||||
if(!(ai_traits & CAN_ACT_WHILE_DEAD))
|
||||
// Unroll for flags here
|
||||
if (ai_traits & CAN_ACT_IN_STASIS && (living_pawn.stat || INCAPACITATED_IGNORING(living_pawn, INCAPABLE_STASIS)))
|
||||
return FALSE
|
||||
else if(IS_DEAD_OR_INCAP(living_pawn))
|
||||
return FALSE
|
||||
if(ai_traits & PAUSE_DURING_DO_AFTER && LAZYLEN(living_pawn.do_afters))
|
||||
return FALSE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user