Changes on how some simple hostile mobs search for targets, they now make a list of mobs at sight with the heareable() proc and add the mechs of a new global list instead of checking all the atoms in a radius of 21x21.

The new global list is called mechas_list, it contains all the mechs (sadly the 8 mechs of centcomm are added to this list, just to avoid problems with other servers with different maps)
Clowns, goats and spiders still use the old way to track targets (the view() proc).

The goal of this commit is to reduce lag, it will be really noticeable on the carp migration event, they should be 70% less laggy.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5820 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
aranclanos@hotmail.com
2013-03-08 07:22:34 +00:00
committed by Spamcat
parent 69e1cce5d3
commit 3035bf565c
6 changed files with 21 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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