diff --git a/code/controllers/subsystems/ai.dm b/code/controllers/subsystems/ai.dm index a1bd5b542d..5ebbb22a2f 100644 --- a/code/controllers/subsystems/ai.dm +++ b/code/controllers/subsystems/ai.dm @@ -26,8 +26,6 @@ SUBSYSTEM_DEF(ai) --currentrun.len if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick continue - if(A.holder.client && !A.autopilot) - continue A.handle_strategicals() if(MC_TICK_CHECK) diff --git a/code/controllers/subsystems/aifast.dm b/code/controllers/subsystems/aifast.dm index ce8cc612dd..f045a7fd35 100644 --- a/code/controllers/subsystems/aifast.dm +++ b/code/controllers/subsystems/aifast.dm @@ -26,8 +26,6 @@ SUBSYSTEM_DEF(aifast) --currentrun.len if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick continue - if(A.holder.client && !A.autopilot) - continue A.handle_tactics() if(MC_TICK_CHECK) diff --git a/code/modules/ai/ai_holder.dm b/code/modules/ai/ai_holder.dm index d4686e1537..3cabb3ffde 100644 --- a/code/modules/ai/ai_holder.dm +++ b/code/modules/ai/ai_holder.dm @@ -27,6 +27,16 @@ QDEL_NULL(ai_holder) return ..() +/mob/living/Login() + if(!stat && ai_holder) + ai_holder.manage_processing(AI_NO_PROCESS) + return ..() + +/mob/living/Logout() + if(!stat && !key && ai_holder) + ai_holder.manage_processing(AI_PROCESSING) + return ..() + /datum/ai_holder var/mob/living/holder = null // The mob this datum is going to control. var/stance = STANCE_IDLE // Determines if the mob should be doing a specific thing, e.g. attacking, following, standing around, etc. @@ -145,11 +155,15 @@ // 'Tactical' processes such as moving a step, meleeing an enemy, firing a projectile, and other fairly cheap actions that need to happen quickly. /datum/ai_holder/proc/handle_tactics() + if(holder.key && !autopilot) + return handle_special_tactic() handle_stance_tactical() // 'Strategical' processes that are more expensive on the CPU and so don't get run as often as the above proc, such as A* pathfinding or robust targeting. /datum/ai_holder/proc/handle_strategicals() + if(holder.key && !autopilot) + return handle_special_strategical() handle_stance_strategical() @@ -160,6 +174,8 @@ // For setting the stance WITHOUT processing it /datum/ai_holder/proc/set_stance(var/new_stance) + if(holder.key && !autopilot) + return if(stance == new_stance) ai_log("set_stance() : Ignoring change stance to same stance request.", AI_LOG_INFO) return @@ -277,11 +293,11 @@ if(STANCE_IDLE) if(speak_chance) // In the long loop since otherwise it wont shut up. handle_idle_speaking() - + if(hostile) ai_log("handle_stance_strategical() : STANCE_IDLE, going to find_target().", AI_LOG_TRACE) find_target() - + if(should_go_home()) ai_log("handle_stance_tactical() : STANCE_IDLE, going to go home.", AI_LOG_TRACE) go_home() diff --git a/code/modules/ai/ai_holder_disabled.dm b/code/modules/ai/ai_holder_disabled.dm index 64a7cf3cc4..d68e2ecf5d 100644 --- a/code/modules/ai/ai_holder_disabled.dm +++ b/code/modules/ai/ai_holder_disabled.dm @@ -5,7 +5,7 @@ // If our holder is able to do anything. /datum/ai_holder/proc/can_act() - if(!holder || (holder.client && !autopilot)) // Holder missing or occupied. + if(!holder) // Holder missing. manage_processing(AI_NO_PROCESS) return FALSE if(holder.stat) // Dead or unconscious.