better ways to do things

This commit is contained in:
Verkister
2020-05-08 23:47:30 +03:00
parent a66eafb5cd
commit 0ff0f19d0a
4 changed files with 19 additions and 7 deletions

View File

@@ -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()

View File

@@ -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.