Speeds up simple_animals/hostile/proc/CanAttack()
This commit is contained in:
committed by
CitadelStationBot
parent
aaa2a214cb
commit
e8a1ceffcb
@@ -46,9 +46,15 @@
|
||||
var/search_objects_timer_id //Timer for regaining our old search_objects value after being attacked
|
||||
var/search_objects_regain_time = 30 //the delay between being attacked and gaining our old search_objects value back
|
||||
var/list/wanted_objects = list() //A typecache of objects types that will be checked against to attack, should we have search_objects enabled
|
||||
<<<<<<< HEAD
|
||||
var/stat_attack = CONSCIOUS //Mobs with stat_attack to UNCONSCIOUS will attempt to attack things that are unconscious, Mobs with stat_attack set to 2 will attempt to attack the dead.
|
||||
var/stat_exclusive = FALSE //Mobs with this set to TRUE 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/stat_attack = CONSCIOUS //Mobs with stat_attack to UNCONSCIOUS will attempt to attack things that are unconscious, Mobs with stat_attack set to DEAD will attempt to attack the dead.
|
||||
var/stat_exclusive = FALSE //Mobs with this set to TRUE will exclusively attack things defined by stat_attack, stat_attack DEAD means they will only attack corpses
|
||||
var/attack_same = 0 //Set us to 1 to allow us to attack our own faction
|
||||
>>>>>>> a719b48... Speeds up simple_animals/hostile/proc/CanAttack() (#31141)
|
||||
var/AIStatus = AI_ON //The Status of our AI, can be set to AI_ON (On, usual processing), AI_IDLE (Will not process, but will return to AI_ON if an enemy comes near), AI_OFF (Off, Not processing ever)
|
||||
var/atom/targets_from = null //all range/attack/etc. calculations should be done from this atom, defaults to the mob itself, useful for Vehicles and such
|
||||
var/attack_all_objects = FALSE //if true, equivalent to having a wanted_objects list containing ALL objects.
|
||||
@@ -164,56 +170,55 @@
|
||||
var/chosen_target = pick(Targets)//Pick the remaining targets (if any) at random
|
||||
return chosen_target
|
||||
|
||||
/mob/living/simple_animal/hostile/CanAttack(atom/the_target)//Can we actually attack a possible target?
|
||||
if(!the_target)
|
||||
return 0
|
||||
// Please do not add one-off mob AIs here, but override this function for your mob
|
||||
/mob/living/simple_animal/hostile/CanAttack(atom/the_target)//Can we actually attack a possible target?
|
||||
if(isturf(the_target) || !the_target || the_target.type == /atom/movable/lighting_object) // bail out on invalids
|
||||
return FALSE
|
||||
|
||||
if(see_invisible < the_target.invisibility)//Target's invisible to us, forget it
|
||||
return 0
|
||||
return FALSE
|
||||
if(search_objects < 2)
|
||||
if(isliving(the_target))
|
||||
var/mob/living/L = the_target
|
||||
var/faction_check = faction_check_mob(L)
|
||||
if(robust_searching)
|
||||
if(L.stat > stat_attack || L.stat != stat_attack && stat_exclusive)
|
||||
return 0
|
||||
if(faction_check && !attack_same || !faction_check && attack_same == 2)
|
||||
return 0
|
||||
if(L in friends)
|
||||
return 0
|
||||
else
|
||||
if(L.stat)
|
||||
return 0
|
||||
if(faction_check && !attack_same)
|
||||
return 0
|
||||
return 1
|
||||
return FALSE
|
||||
if(L.stat > stat_attack)
|
||||
return FALSE
|
||||
if(L in friends)
|
||||
return FALSE
|
||||
else
|
||||
if((faction_check && !attack_same) || L.stat)
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
if(istype(the_target, /obj/mecha))
|
||||
var/obj/mecha/M = the_target
|
||||
if(M.occupant)//Just so we don't attack empty mechs
|
||||
if(CanAttack(M.occupant))
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(istype(the_target, /obj/machinery/porta_turret))
|
||||
var/obj/machinery/porta_turret/P = the_target
|
||||
if(P.faction in faction)
|
||||
return 0
|
||||
return FALSE
|
||||
if(P.has_cover &&!P.raised) //Don't attack invincible turrets
|
||||
return 0
|
||||
return FALSE
|
||||
if(P.stat & BROKEN) //Or turrets that are already broken
|
||||
return 0
|
||||
return 1
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
if(istype(the_target, /obj/structure/destructible/clockwork/ocular_warden))
|
||||
var/obj/structure/destructible/clockwork/ocular_warden/OW = the_target
|
||||
if(OW.target != src)
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
|
||||
if(isobj(the_target))
|
||||
if(attack_all_objects || is_type_in_typecache(the_target, wanted_objects))
|
||||
return 1
|
||||
return 0
|
||||
return TRUE
|
||||
|
||||
return FALSE
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/GiveTarget(new_target)//Step 4, give us our selected target
|
||||
target = new_target
|
||||
|
||||
@@ -45,6 +45,25 @@
|
||||
udder = new()
|
||||
. = ..()
|
||||
|
||||
/mob/living/simple_animal/hostile/asteroid/gutlunch/CanAttack(atom/the_target) // Gutlunch-specific version of CanAttack to handle stupid stat_exclusive = true crap so we don't have to do it for literally every single simple_animal/hostile except the two that spawn in lavaland
|
||||
if(isturf(the_target) || !the_target || the_target.type == /atom/movable/lighting_object) // bail out on invalids
|
||||
return FALSE
|
||||
|
||||
if(see_invisible < the_target.invisibility)//Target's invisible to us, forget it
|
||||
return FALSE
|
||||
|
||||
if(isliving(the_target))
|
||||
var/mob/living/L = the_target
|
||||
|
||||
if(faction_check_mob(L) && !attack_same)
|
||||
return FALSE
|
||||
if(L.stat > stat_attack || L.stat != stat_attack && stat_exclusive)
|
||||
return FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
return FALSE
|
||||
|
||||
/mob/living/simple_animal/hostile/asteroid/gutlunch/Destroy()
|
||||
QDEL_NULL(udder)
|
||||
return ..()
|
||||
|
||||
@@ -62,6 +62,25 @@
|
||||
health = maxHealth
|
||||
. = ..()
|
||||
|
||||
/mob/living/simple_animal/hostile/mushroom/CanAttack(atom/the_target) // Mushroom-specific version of CanAttack to handle stupid attack_same = 2 crap so we don't have to do it for literally every single simple_animal/hostile because this shit never gets spawned
|
||||
if(!the_target || isturf(the_target) || istype(the_target, /atom/movable/lighting_object))
|
||||
return FALSE
|
||||
|
||||
if(see_invisible < the_target.invisibility)//Target's invisible to us, forget it
|
||||
return FALSE
|
||||
|
||||
if(isliving(the_target))
|
||||
var/mob/living/L = the_target
|
||||
|
||||
if (!faction_check_mob(L) && attack_same == 2)
|
||||
return FALSE
|
||||
if(L.stat > stat_attack)
|
||||
return FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
return FALSE
|
||||
|
||||
/mob/living/simple_animal/hostile/mushroom/adjustHealth(amount, updating_health = TRUE, forced = FALSE) //Possibility to flee from a fight just to make it more visually interesting
|
||||
if(!retreat_distance && prob(33))
|
||||
retreat_distance = 5
|
||||
|
||||
Reference in New Issue
Block a user