Skip to content

Commit

Permalink
this is better
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapu1178 committed Sep 23, 2024
1 parent dc19494 commit 7c6a934
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 13 additions & 1 deletion code/datums/ai/_ai_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ multiple modular subtrees with behaviors
set_ai_status(AI_STATUS_ON)

RegisterSignal(pawn, COMSIG_MOB_LOGIN, PROC_REF(on_sentience_gained))
RegisterSignal(pawn, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_change))

///Abstract proc for initializing the pawn to the new controller
/datum/ai_controller/proc/TryPossessPawn(atom/new_pawn)
return

///Proc for deinitializing the pawn to the old controller
/datum/ai_controller/proc/UnpossessPawn(destroy)
UnregisterSignal(pawn, list(COMSIG_MOB_LOGIN, COMSIG_MOB_LOGOUT))
UnregisterSignal(pawn, list(COMSIG_MOB_LOGIN, COMSIG_MOB_LOGOUT, COMSIG_MOB_STATCHANGE))
if(ai_movement.moving_controllers[src])
ai_movement.stop_moving_towards(src)
pawn.ai_controller = null
Expand Down Expand Up @@ -364,6 +365,17 @@ multiple modular subtrees with behaviors
set_ai_status(AI_STATUS_ON) //Can't do anything while player is connected
RegisterSignal(pawn, COMSIG_MOB_LOGIN, PROC_REF(on_sentience_gained))

/datum/ai_controller/proc/on_stat_change(datum/source, new_stat, old_stat)
SIGNAL_HANDLER

switch(new_stat)
if(CONSCIOUS)
REMOVE_TRAIT(pawn, TRAIT_AI_PAUSED, STAT_TRAIT)
REMOVE_TRAIT(pawn, TRAIT_AI_DISABLE_PLANNING, STAT_TRAIT)
else
ADD_TRAIT(pawn, TRAIT_AI_PAUSED, STAT_TRAIT)
ADD_TRAIT(pawn, TRAIT_AI_DISABLE_PLANNING, STAT_TRAIT)

/// Use this proc to define how your controller defines what access the pawn has for the sake of pathfinding, likely pointing to whatever ID slot is relevant
/datum/ai_controller/proc/get_access()
if(!isliving(pawn))
Expand Down
4 changes: 0 additions & 4 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1770,8 +1770,6 @@ GLOBAL_LIST_EMPTY(fire_appearances)
ADD_TRAIT(src, TRAIT_HANDS_BLOCKED, STAT_TRAIT)
ADD_TRAIT(src, TRAIT_INCAPACITATED, STAT_TRAIT)
ADD_TRAIT(src, TRAIT_FLOORED, STAT_TRAIT)
ADD_TRAIT(src, TRAIT_AI_PAUSED, STAT_TRAIT)
ADD_TRAIT(src, TRAIT_AI_DISABLE_PLANNING, STAT_TRAIT)

if(UNCONSCIOUS)
cure_blind(UNCONSCIOUS_TRAIT)
Expand All @@ -1790,8 +1788,6 @@ GLOBAL_LIST_EMPTY(fire_appearances)
REMOVE_TRAIT(src, TRAIT_INCAPACITATED, STAT_TRAIT)
REMOVE_TRAIT(src, TRAIT_FLOORED, STAT_TRAIT)
REMOVE_TRAIT(src, TRAIT_NO_SPRINT, STAT_TRAIT)
REMOVE_TRAIT(src, TRAIT_AI_PAUSED, STAT_TRAIT)
REMOVE_TRAIT(src, TRAIT_AI_DISABLE_PLANNING, STAT_TRAIT)
if(UNCONSCIOUS)
become_blind(UNCONSCIOUS_TRAIT)
ADD_TRAIT(src, TRAIT_DEAF, STAT_TRAIT)
Expand Down

0 comments on commit 7c6a934

Please sign in to comment.