diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 566a587b8a0..9ca77defe8f 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -15,6 +15,10 @@ var/global/list/chemical_reactions_list //list of all /datum/chemical_reactio var/global/list/chemical_reagents_list //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff var/global/list/landmarks_list = list() //list of all landmarks created var/global/list/surgery_steps = list() //list of all surgery steps |BS12 +var/global/list/mechas_list = list() //list of all mechs. Used by hostile mobs target tracking. + +var/global/list/portals = list() //for use by portals + //Preferences stuff //Hairstyles var/global/list/hair_styles_list = list() //stores /datum/sprite_accessory/hair indexed by name diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index d70512148c6..9d8291733cb 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -86,10 +86,12 @@ removeVerb(/atom/movable/verb/pull) log_message("[src.name] created.") loc.Entered(src) + mechas_list += src //global mech list return /obj/mecha/Del() src.go_out() + mechas_list -= src //global mech list ..() return diff --git a/code/modules/mob/living/simple_animal/hostile/bear.dm b/code/modules/mob/living/simple_animal/hostile/bear.dm index c9f52de2be2..6fd7db5d10e 100644 --- a/code/modules/mob/living/simple_animal/hostile/bear.dm +++ b/code/modules/mob/living/simple_animal/hostile/bear.dm @@ -61,7 +61,7 @@ stop_automated_movement = 1 stance_step++ if(stance_step >= 10) //rests for 10 ticks - if(target_mob && target_mob in ListTargets()) + if(target_mob && target_mob in ListTargets(10)) stance = HOSTILE_STANCE_ATTACK //If the mob he was chasing is still nearby, resume the attack, otherwise go idle. else stance = HOSTILE_STANCE_IDLE @@ -69,7 +69,7 @@ if(HOSTILE_STANCE_ALERT) stop_automated_movement = 1 var/found_mob = 0 - if(target_mob && target_mob in ListTargets()) + if(target_mob && target_mob in ListTargets(10)) if(!(SA_attackable(target_mob))) stance_step = max(0, stance_step) //If we have not seen a mob in a while, the stance_step will be negative, we need to reset it to 0 as soon as we see a mob again. stance_step++ diff --git a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm index 669541687f2..3b82b645409 100644 --- a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm +++ b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm @@ -100,7 +100,7 @@ ..() if(!stat) if(stance == HOSTILE_STANCE_IDLE) - var/list/can_see = ListTargets() + var/list/can_see = view(src, 10) //30% chance to stop wandering and do something if(!busy && prob(30)) //first, check for potential food nearby to cocoon diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index b8c5d4150bd..c0ce321c4dc 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -18,7 +18,7 @@ var/atom/T = null stop_automated_movement = 0 - for(var/atom/A in ListTargets()) + for(var/atom/A in ListTargets(10)) if(A == src) continue @@ -40,6 +40,8 @@ T = L break + else + if (can_see(src, A, 10)) if(istype(A, /obj/mecha)) var/obj/mecha/M = A if (M.occupant) @@ -63,7 +65,7 @@ stop_automated_movement = 1 if(!target_mob || SA_attackable(target_mob)) stance = HOSTILE_STANCE_IDLE - if(target_mob in ListTargets()) + if(target_mob in ListTargets(10)) if(ranged) if(get_dist(src, target_mob) <= 6) OpenFire(target_mob) @@ -79,7 +81,7 @@ if(!target_mob || SA_attackable(target_mob)) LoseTarget() return 0 - if(!(target_mob in ListTargets())) + if(!(target_mob in ListTargets(10))) LostTarget() return 0 if(get_dist(src, target_mob) <= 1) //Attacking @@ -109,8 +111,10 @@ walk(src, 0) -/mob/living/simple_animal/hostile/proc/ListTargets() - return view(src, 10) +/mob/living/simple_animal/hostile/proc/ListTargets(var/dist = 7) + var/list/L = hearers(src, dist) + L += mechas_list + return L /mob/living/simple_animal/hostile/Die() ..() diff --git a/code/modules/mob/living/simple_animal/hostile/mimic.dm b/code/modules/mob/living/simple_animal/hostile/mimic.dm index a910e74f5fe..fb1d63ca348 100644 --- a/code/modules/mob/living/simple_animal/hostile/mimic.dm +++ b/code/modules/mob/living/simple_animal/hostile/mimic.dm @@ -77,7 +77,7 @@ /mob/living/simple_animal/hostile/mimic/crate/ListTargets() if(attempt_open) - return view(src, 10) + return ..() return view(src, 1) /mob/living/simple_animal/hostile/mimic/crate/FindTarget() @@ -149,7 +149,8 @@ var/global/list/protected_objects = list(/obj/structure/table, /obj/structure/ca /mob/living/simple_animal/hostile/mimic/copy/ListTargets() // Return a list of targets that isn't the creator - return view(src, 7) - creator + . = ..() + return . - creator /mob/living/simple_animal/hostile/mimic/copy/proc/CopyObject(var/obj/O, var/mob/living/creator)