mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
better ways to do things
This commit is contained in:
@@ -26,8 +26,6 @@ SUBSYSTEM_DEF(ai)
|
|||||||
--currentrun.len
|
--currentrun.len
|
||||||
if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
|
if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
|
||||||
continue
|
continue
|
||||||
if(A.holder.client && !A.autopilot)
|
|
||||||
continue
|
|
||||||
A.handle_strategicals()
|
A.handle_strategicals()
|
||||||
|
|
||||||
if(MC_TICK_CHECK)
|
if(MC_TICK_CHECK)
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ SUBSYSTEM_DEF(aifast)
|
|||||||
--currentrun.len
|
--currentrun.len
|
||||||
if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
|
if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
|
||||||
continue
|
continue
|
||||||
if(A.holder.client && !A.autopilot)
|
|
||||||
continue
|
|
||||||
A.handle_tactics()
|
A.handle_tactics()
|
||||||
|
|
||||||
if(MC_TICK_CHECK)
|
if(MC_TICK_CHECK)
|
||||||
|
|||||||
@@ -27,6 +27,16 @@
|
|||||||
QDEL_NULL(ai_holder)
|
QDEL_NULL(ai_holder)
|
||||||
return ..()
|
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
|
/datum/ai_holder
|
||||||
var/mob/living/holder = null // The mob this datum is going to control.
|
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.
|
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.
|
// '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()
|
/datum/ai_holder/proc/handle_tactics()
|
||||||
|
if(holder.key && !autopilot)
|
||||||
|
return
|
||||||
handle_special_tactic()
|
handle_special_tactic()
|
||||||
handle_stance_tactical()
|
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.
|
// '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()
|
/datum/ai_holder/proc/handle_strategicals()
|
||||||
|
if(holder.key && !autopilot)
|
||||||
|
return
|
||||||
handle_special_strategical()
|
handle_special_strategical()
|
||||||
handle_stance_strategical()
|
handle_stance_strategical()
|
||||||
|
|
||||||
@@ -160,6 +174,8 @@
|
|||||||
|
|
||||||
// For setting the stance WITHOUT processing it
|
// For setting the stance WITHOUT processing it
|
||||||
/datum/ai_holder/proc/set_stance(var/new_stance)
|
/datum/ai_holder/proc/set_stance(var/new_stance)
|
||||||
|
if(holder.key && !autopilot)
|
||||||
|
return
|
||||||
if(stance == new_stance)
|
if(stance == new_stance)
|
||||||
ai_log("set_stance() : Ignoring change stance to same stance request.", AI_LOG_INFO)
|
ai_log("set_stance() : Ignoring change stance to same stance request.", AI_LOG_INFO)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// If our holder is able to do anything.
|
// If our holder is able to do anything.
|
||||||
/datum/ai_holder/proc/can_act()
|
/datum/ai_holder/proc/can_act()
|
||||||
if(!holder || (holder.client && !autopilot)) // Holder missing or occupied.
|
if(!holder) // Holder missing.
|
||||||
manage_processing(AI_NO_PROCESS)
|
manage_processing(AI_NO_PROCESS)
|
||||||
return FALSE
|
return FALSE
|
||||||
if(holder.stat) // Dead or unconscious.
|
if(holder.stat) // Dead or unconscious.
|
||||||
|
|||||||
Reference in New Issue
Block a user