More typecaching hostile mob targetting

This commit is contained in:
MrStonedOne
2016-11-22 08:05:47 -08:00
parent d4fa53d9ca
commit 2aa349a8a1
4 changed files with 11 additions and 9 deletions
@@ -125,7 +125,7 @@
if(istype(A, /obj/machinery/hydroponics))
var/obj/machinery/hydroponics/Hydro = A
if(Hydro.myseed && !Hydro.dead && !Hydro.recent_bee_visit)
wanted_objects |= /obj/machinery/hydroponics //so we only hunt them while they're alive/seeded/not visisted
wanted_objects |= typecacheof(/obj/machinery/hydroponics) //so we only hunt them while they're alive/seeded/not visisted
return 1
if(isliving(A))
var/mob/living/H = A
@@ -142,7 +142,7 @@
var/obj/structure/beebox/BB = target
loc = BB
target = null
wanted_objects -= /obj/structure/beebox //so we don't attack beeboxes when not going home
wanted_objects -= typecacheof(/obj/structure/beebox) //so we don't attack beeboxes when not going home
else
if(beegent && isliving(target))
var/mob/living/L = target
@@ -165,7 +165,7 @@
return
target = null //so we pick a new hydro tray next FindTarget(), instead of loving the same plant for eternity
wanted_objects -= /obj/machinery/hydroponics //so we only hunt them while they're alive/seeded/not visisted
wanted_objects -= typecacheof(/obj/machinery/hydroponics) //so we only hunt them while they're alive/seeded/not visisted
Hydro.recent_bee_visit = TRUE
spawn(BEE_TRAY_RECENT_VISIT)
if(Hydro)
@@ -200,7 +200,7 @@
idle = max(0, --idle)
if(idle <= BEE_IDLE_GOHOME && prob(BEE_PROB_GOHOME))
if(!FindTarget())
wanted_objects += /obj/structure/beebox //so we don't attack beeboxes when not going home
wanted_objects |= typecacheof(/obj/structure/beebox) //so we don't attack beeboxes when not going home
target = beehome
if(!beehome) //add outselves to a beebox (of the same reagent) if we have no home
for(var/obj/structure/beebox/BB in view(vision_range, src))
@@ -40,7 +40,7 @@
var/aggro_vision_range = 9 //If a mob is aggro, we search in this radius. Defaults to 9 to keep in line with original simple mob aggro radius
var/idle_vision_range = 9 //If a mob is just idling around, it's vision range is limited to this. Defaults to 9 to keep in line with original simple mob aggro radius
var/search_objects = 0 //If we want to consider objects when searching around, set this to 1. If you want to search for objects while also ignoring mobs until hurt, set it to 2. To completely ignore mobs, even when attacked, set it to 3
var/list/wanted_objects = list() //A list of objects that will be checked against to attack, should we have search_objects enabled
var/list/wanted_objects = list() //A typecache of objects types that will be checked against to attack, should we have search_objects enabled
var/stat_attack = 0 //Mobs with stat_attack to 1 will attempt to attack things that are unconscious, Mobs with stat_attack set to 2 will attempt to attack the dead.
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
@@ -50,9 +50,11 @@
/mob/living/simple_animal/hostile/New()
..()
if(!targets_from)
targets_from = src
environment_target_typecache = typecacheof(environment_target_typecache)
wanted_objects = typecacheof(wanted_objects)
/mob/living/simple_animal/hostile/Destroy()
@@ -197,7 +199,7 @@
if(isobj(the_target))
if(is_type_in_list(the_target, wanted_objects))
if(is_type_in_typecache(the_target, wanted_objects))
return 1
return 0
@@ -41,7 +41,7 @@
/mob/living/simple_animal/hostile/syndicate/mecha_pilot/no_mech/New()
..()
wanted_objects = subtypesof(/obj/mecha/combat)
wanted_objects = typecacheof(/obj/mecha/combat, ignore_root_path=TRUE)
/mob/living/simple_animal/hostile/syndicate/mecha_pilot/nanotrasen //nanotrasen are syndies! no it's just a weird path.
name = "Nanotrasen Mecha Pilot"
@@ -101,7 +101,7 @@
targets_from = src
//Find a new mecha
wanted_objects = subtypesof(/obj/mecha/combat)
wanted_objects = typecacheof(/obj/mecha/combat, ignore_root_path=TRUE)
var/search_aggressiveness = 2
for(var/obj/mecha/combat/C in range(vision_range,src))
if(is_valid_mecha(C))
@@ -917,7 +917,7 @@
..()
/mob/living/simple_animal/hostile/asteroid/gutlunch/AttackingTarget()
if(is_type_in_list(target,wanted_objects)) //we eats
if(is_type_in_typecache(target,wanted_objects)) //we eats
udder.generateMilk()
regenerate_icons()
visible_message("<span class='notice'>[src] slurps up [target].</span>")