Skip to content

Commit

Permalink
Moved body null check to /datum/ai can_process().
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Mar 22, 2024
1 parent 96dad00 commit b0c4ca8
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 26 deletions.
2 changes: 1 addition & 1 deletion code/datums/ai/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
. = ..()

/datum/ai/proc/can_process()
if(!body || ((body.client || body.mind) && !(body.status_flags & ENABLE_AI)))
if(!body || !body.loc || ((body.client || body.mind) && !(body.status_flags & ENABLE_AI)))
return FALSE
if(wait_for > world.time)
return FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ai/monkey.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)

/datum/ai/monkey/do_process(var/time_elapsed)
if(body.incapacitated() || !body.loc)
if(body.incapacitated())
return

if(prob(33) && isturf(body.loc) && !LAZYLEN(body.grabbed_by)) //won't move if being pulled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
expected_type = /mob/living/simple_animal/hostile/retaliate/goat

/datum/ai/goat/do_process(time_elapsed)
if(!body.loc)
return
//chance to go crazy and start wacking stuff
var/mob/living/simple_animal/hostile/retaliate/goat/goat = body
if(!length(goat.enemies) && prob(1))
Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/living/simple_animal/friendly/mouse.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

/datum/ai/mouse/do_process()
..()
if(!body.loc)
return
var/mob/living/simple_animal/mouse/mouse = body
if(prob(mouse.speak_chance))
playsound(mouse.loc, 'sound/effects/mousesqueek.ogg', 50)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/friendly/possum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
expected_type = /mob/living/simple_animal/opossum
/datum/ai/opossum/do_process(time_elapsed)
. = ..()
if(!prob(1) || !body.loc)
if(!prob(1))
return
var/mob/living/simple_animal/opossum/poss = body
poss.resting = (poss.stat == UNCONSCIOUS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

/datum/ai/commanded/do_process(time_elapsed)
..()
if(!body.loc)
return
var/mob/living/simple_animal/hostile/commanded/com = body
while(com.command_buffer.len > 1)
var/mob/speaker = com.command_buffer[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

/datum/ai/nanomachines/do_process(time_elapsed)
. = ..()
if(!body.loc)
return
var/mob/living/simple_animal/hostile/commanded/nanomachine/swarm = body
switch(swarm.stance)
if(COMMANDED_HEAL)
Expand Down
6 changes: 0 additions & 6 deletions code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@
expected_type = /mob/living/simple_animal/hostile/giant_spider

/datum/ai/giant_spider/do_process()
if(!body.loc)
return
var/mob/living/simple_animal/hostile/giant_spider/spooder = body
if(spooder.stance == HOSTILE_STANCE_IDLE)
//chance to skitter madly away
Expand Down Expand Up @@ -209,8 +207,6 @@ Guard caste procs

/datum/ai/giant_spider/guard/do_process(time_elapsed)
. = ..()
if(!body.loc)
return
var/mob/living/simple_animal/hostile/giant_spider/guard/spooder = body
if(spooder.berserking)
return
Expand Down Expand Up @@ -316,8 +312,6 @@ Nurse caste procs

/datum/ai/giant_spider/nurse/do_process(time_elapsed)
. = ..()
if(!body.loc)
return
var/mob/living/simple_animal/hostile/giant_spider/nurse/spooder = body
if(spooder.stance != HOSTILE_STANCE_IDLE)
spooder.busy = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
expected_type = /mob/living/simple_animal/hostile/retaliate/beast

/datum/ai/beast/do_process(time_elapsed)
if(!body.loc)
return
var/mob/living/simple_animal/hostile/retaliate/beast/beast = body
var/nut = beast.get_nutrition()
var/max_nut = beast.get_max_nutrition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

/datum/ai/giant_crab/do_process(time_elapsed)
. = ..()
if(!body.loc)
return
var/mob/living/simple_animal/hostile/retaliate/giant_crab/crab = body
if((crab.current_health > crab.get_max_health() / 1.5) && length(crab.enemies) && prob(10))
if(crab.victim)
Expand Down
3 changes: 0 additions & 3 deletions mods/content/xenobiology/slime/slime_AI.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@

/datum/ai/slime/do_process(time_elapsed)
. = ..()
if(!body.loc)
return

if(attacked > 0)
attacked = clamp(attacked--, 0, 50)

Expand Down
2 changes: 0 additions & 2 deletions mods/mobs/dionaea/datums/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
var/wander_prob = 44

/datum/ai/nymph/do_process(var/time_elapsed)
if(!body.loc)
return
if(body.stat != CONSCIOUS)
return
if(prob(wander_prob) && !LAZYLEN(body.grabbed_by) && isturf(body.loc)) //won't move if being pulled
Expand Down

0 comments on commit b0c4ca8

Please sign in to comment.