Merge pull request #4075 from Citadel-Station-13/upstream-merge-32699
[MIRROR] Fixes hostile mobs attacking surrounding tiles when trying to attack someone: the stunning finale
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
var/mob/living/L = target
|
||||
if(prob(80))
|
||||
var/atom/throw_target = get_edge_target_turf(L, dir)
|
||||
L.throw_at(throw_target, rand(1,2), 7, src)
|
||||
L.throw_at(throw_target, rand(1,2), 7, src)
|
||||
else
|
||||
L.Knockdown(20)
|
||||
visible_message("<span class='danger'>[src] knocks [L] down!</span>")
|
||||
@@ -76,9 +76,11 @@
|
||||
var/list/parts = target_bodyparts(target)
|
||||
return ..() && !istype(the_target, /mob/living/carbon/monkey) && (!parts || parts.len > 3)
|
||||
|
||||
|
||||
/mob/living/simple_animal/hostile/gorilla/CanSmashTurfs(turf/T)
|
||||
return iswallturf(T)
|
||||
|
||||
|
||||
/mob/living/simple_animal/hostile/gorilla/gib(no_brain)
|
||||
if(!no_brain)
|
||||
var/mob/living/brain/B = new(drop_location())
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
var/list/emote_taunt = list()
|
||||
var/taunt_chance = 0
|
||||
|
||||
//typecache of things this mob will attack in DestroySurroundings() if it has environment_smash
|
||||
//typecache of things this mob will attack in DestroyPathToTarget() if it has environment_smash
|
||||
var/list/environment_target_typecache = list(
|
||||
/obj/machinery/door/window,
|
||||
/obj/structure/window,
|
||||
@@ -84,7 +84,8 @@
|
||||
EscapeConfinement()
|
||||
|
||||
if(AICanContinue(possible_targets))
|
||||
DestroySurroundings()
|
||||
if(!QDELETED(target) && !targets_from.Adjacent(target))
|
||||
DestroyPathToTarget()
|
||||
if(!MoveToTarget(possible_targets)) //if we lose our target
|
||||
if(AIShouldSleep(possible_targets)) // we try to acquire a new one
|
||||
toggle_ai(AI_IDLE) // otherwise we go idle
|
||||
@@ -371,24 +372,45 @@
|
||||
P.preparePixelProjectile(targeted_atom, src)
|
||||
P.fire()
|
||||
return P
|
||||
|
||||
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/CanSmashTurfs(turf/T)
|
||||
return iswallturf(T) || ismineralturf(T)
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/DestroySurroundings()
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/DestroyObjectsInDirection(direction)
|
||||
var/turf/T = get_step(targets_from, direction)
|
||||
if(T.Adjacent(targets_from))
|
||||
if(CanSmashTurfs(T))
|
||||
T.attack_animal(src)
|
||||
for(var/a in T)
|
||||
var/atom/A = a
|
||||
if(is_type_in_typecache(A, environment_target_typecache) && !A.IsObscured())
|
||||
A.attack_animal(src)
|
||||
return
|
||||
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/DestroyPathToTarget()
|
||||
if(environment_smash)
|
||||
EscapeConfinement()
|
||||
var/dir_to_target = get_dir(targets_from, target)
|
||||
var/dir_list = list()
|
||||
if(dir_to_target in GLOB.diagonals) //it's diagonal, so we need two directions to hit
|
||||
for(var/direction in GLOB.cardinals)
|
||||
if(direction & dir_to_target)
|
||||
dir_list += direction
|
||||
else
|
||||
dir_list += dir_to_target
|
||||
for(var/direction in dir_list) //now we hit all of the directions we got in this fashion, since it's the only directions we should actually need
|
||||
DestroyObjectsInDirection(direction)
|
||||
|
||||
|
||||
mob/living/simple_animal/hostile/proc/DestroySurroundings() // for use with megafauna destroying everything around them
|
||||
if(environment_smash)
|
||||
EscapeConfinement()
|
||||
for(var/dir in GLOB.cardinals)
|
||||
var/turf/T = get_step(targets_from, dir)
|
||||
if(CanSmashTurfs(T))
|
||||
if(T.Adjacent(targets_from))
|
||||
T.attack_animal(src)
|
||||
for(var/a in T)
|
||||
var/atom/A = a
|
||||
if(!A.Adjacent(targets_from))
|
||||
continue
|
||||
if(is_type_in_typecache(A, environment_target_typecache) && !A.IsObscured())
|
||||
A.attack_animal(src)
|
||||
DestroyObjectsInDirection(dir)
|
||||
|
||||
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/EscapeConfinement()
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
for(var/obj/item/I in loc)
|
||||
I.loc = src
|
||||
|
||||
/mob/living/simple_animal/hostile/mimic/crate/DestroySurroundings()
|
||||
/mob/living/simple_animal/hostile/mimic/crate/DestroyPathToTarget()
|
||||
..()
|
||||
if(prob(90))
|
||||
icon_state = "[initial(icon_state)]open"
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
else
|
||||
return ..()
|
||||
|
||||
/mob/living/simple_animal/hostile/statue/DestroySurroundings()
|
||||
/mob/living/simple_animal/hostile/statue/DestroyPathToTarget()
|
||||
if(!can_be_seen(get_turf(loc)))
|
||||
..()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user