mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-14 19:03:21 +00:00
Hostile mobs no longer run all their hostile targeting/hunting code if there is nobody (or item, for those that hunt items) near them, they simply move to a simpler loop that decides whether to let the main loop continue.
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
var/stat_exclusive = 0 //Mobs with this set to 1 will exclusively attack things defined by stat_attack, stat_attack 2 means they will only attack corpses
|
||||
var/attack_same = 0 //Set us to 1 to allow us to attack our own faction, or 2, to only ever attack our own faction
|
||||
|
||||
var/AIStatus = AI_ON //The Status of our AI, can be set to AI_ON (On, usual processing), AI_SLEEP (Will not process, but will return to AI_ON if an enemy comes near), AI_OFF (Off, Not processing ever)
|
||||
|
||||
/mob/living/simple_animal/hostile/Life()
|
||||
|
||||
. = ..()
|
||||
@@ -40,6 +42,8 @@
|
||||
ranged_cooldown--
|
||||
if(client)
|
||||
return 0
|
||||
if(!AICanContinue())
|
||||
return 0
|
||||
if(!stat)
|
||||
switch(stance)
|
||||
if(HOSTILE_STANCE_IDLE)
|
||||
@@ -56,6 +60,9 @@
|
||||
AttackTarget()
|
||||
DestroySurroundings()
|
||||
|
||||
if(AIShouldSleep())
|
||||
AIStatus = AI_SLEEP
|
||||
|
||||
|
||||
//////////////HOSTILE MOB TARGETTING AND AGGRESSION////////////
|
||||
|
||||
@@ -313,4 +320,33 @@
|
||||
if(ranged && ranged_cooldown <= 0)
|
||||
target = A
|
||||
OpenFire(A)
|
||||
..()
|
||||
..()
|
||||
|
||||
|
||||
|
||||
////// AI Status ///////
|
||||
/mob/living/simple_animal/hostile/proc/AICanContinue()
|
||||
switch(AIStatus)
|
||||
if(AI_ON)
|
||||
. = 1
|
||||
if(AI_SLEEP)
|
||||
if(AIShouldWake())
|
||||
. = 1
|
||||
AIStatus = AI_ON //Wake up for more than one Life() cycle.
|
||||
else
|
||||
. = 0
|
||||
if(AI_OFF)
|
||||
. = 0
|
||||
|
||||
|
||||
//Returns 1 if the AI should wake up
|
||||
//Returns 0 if the AI should remain asleep
|
||||
/mob/living/simple_animal/hostile/proc/AIShouldWake()
|
||||
. = 0
|
||||
if(FindTarget())
|
||||
. = 1
|
||||
|
||||
|
||||
//Convenience
|
||||
/mob/living/simple_animal/hostile/proc/AIShouldSleep()
|
||||
. = !(AIShouldWake())
|
||||
Reference in New Issue
Block a user