mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 23:27:34 +01:00
* Simple animals will now consider invisibility when attacking and choosing targets.
* Renamed SA_attackable to CanAttack(). Moved relevant code into there. Should make mobs more responsive with their targets.
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
stop_automated_movement = 1
|
||||
var/found_mob = 0
|
||||
if(target && target in ListTargets())
|
||||
if(!(SA_attackable(target)))
|
||||
if(CanAttack(target))
|
||||
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++
|
||||
found_mob = 1
|
||||
|
||||
@@ -25,16 +25,12 @@
|
||||
T = F
|
||||
break
|
||||
|
||||
if(!CanAttack(A))
|
||||
continue
|
||||
|
||||
if(isliving(A))
|
||||
var/mob/living/L = A
|
||||
if(L.faction == src.faction && !attack_same)
|
||||
continue
|
||||
else if(L in friends)
|
||||
continue
|
||||
else
|
||||
if(!L.stat)
|
||||
T = L
|
||||
break
|
||||
T = A
|
||||
break
|
||||
|
||||
else if(istype(A, /obj/mecha)) // Our line of sight stuff was already done in ListTargets().
|
||||
var/obj/mecha/M = A
|
||||
@@ -44,6 +40,17 @@
|
||||
|
||||
return T
|
||||
|
||||
/mob/living/simple_animal/hostile/CanAttack(var/atom/the_target)
|
||||
if(!..())
|
||||
return 0
|
||||
if(isliving(the_target))
|
||||
var/mob/living/L = the_target
|
||||
if(L.faction == src.faction && !attack_same)
|
||||
return 0
|
||||
else if(L in friends)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/GiveTarget(var/new_target)
|
||||
target = new_target
|
||||
if(target != null)
|
||||
@@ -58,7 +65,7 @@
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/MoveToTarget()
|
||||
stop_automated_movement = 1
|
||||
if(!target || SA_attackable(target))
|
||||
if(!target || !CanAttack(target))
|
||||
LoseTarget()
|
||||
if(target in ListTargets())
|
||||
if(ranged)
|
||||
@@ -73,7 +80,7 @@
|
||||
/mob/living/simple_animal/hostile/proc/AttackTarget()
|
||||
|
||||
stop_automated_movement = 1
|
||||
if(!target || SA_attackable(target))
|
||||
if(!target || !CanAttack(target))
|
||||
LoseTarget()
|
||||
return 0
|
||||
if(!(target in ListTargets()))
|
||||
|
||||
@@ -461,13 +461,15 @@
|
||||
if(health < 1 && stat != DEAD)
|
||||
Die()
|
||||
|
||||
/mob/living/simple_animal/proc/SA_attackable(target)
|
||||
if (isliving(target))
|
||||
var/mob/living/L = target
|
||||
if(!L.stat)
|
||||
/mob/living/simple_animal/proc/CanAttack(var/atom/the_target)
|
||||
if(see_invisible < the_target.invisibility)
|
||||
return 0
|
||||
if (isliving(the_target))
|
||||
var/mob/living/L = the_target
|
||||
if(L.stat != CONSCIOUS)
|
||||
return 0
|
||||
if (istype(target,/obj/mecha))
|
||||
var/obj/mecha/M = target
|
||||
if (istype(the_target, /obj/mecha))
|
||||
var/obj/mecha/M = the_target
|
||||
if (M.occupant)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user