Turrets vs Hostile lifeforms. Plus turret upgrade (#6183)

This commit is contained in:
Mykhailo Bykhovtsev
2019-05-25 13:52:32 +02:00
committed by Werner
parent d8f2b7cc3a
commit ba2a601b92
13 changed files with 357 additions and 185 deletions
@@ -67,29 +67,15 @@
return ..()
/mob/living/simple_animal/hostile/carp/AttackingTarget()
setClickCooldown(attack_delay)
if(!Adjacent(target_mob))
. = ..()
if(.)
return
if(isliving(target_mob))
var/mob/living/L = target_mob
if(prob(15))
L.Weaken(3)
L.visible_message("<span class='danger'>\the [src] knocks down \the [L]!</span>")
L.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return L
if(istype(target_mob,/obj/mecha))
var/obj/mecha/M = target_mob
M.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return M
if(istype(target_mob,/obj/machinery/bot))
var/obj/machinery/bot/B = target_mob
B.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
return B
if(istype(target_mob, /obj/effect/energy_field))
var/obj/effect/energy_field/e = target_mob
e.Stress(rand(1,2))
visible_message("<span class='danger'>\the [src] has attacked [e]!</span>")
src.do_attack_animation(e)
return e
/mob/living/simple_animal/hostile/carp/DestroySurroundings(var/bypass_prob = FALSE)
if(prob(break_stuff_probability) || bypass_prob)
@@ -32,6 +32,7 @@
target_type_validator_map[/mob/living] = CALLBACK(src, .proc/validator_living)
target_type_validator_map[/obj/mecha] = CALLBACK(src, .proc/validator_mecha)
target_type_validator_map[/obj/machinery/bot] = CALLBACK(src, .proc/validator_bot)
target_type_validator_map[/obj/machinery/porta_turret] = CALLBACK(src, .proc/validator_turret)
/mob/living/simple_animal/hostile/Destroy()
friends = null
@@ -166,16 +167,22 @@ mob/living/simple_animal/hostile/hitby(atom/movable/AM as mob|obj,var/speed = TH
LoseTarget()
if(isliving(target_mob))
var/mob/living/L = target_mob
L.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
L.attack_generic(src, rand(melee_damage_lower, melee_damage_upper), attacktext)
return L
if(istype(target_mob,/obj/mecha))
if(istype(target_mob, /obj/mecha))
var/obj/mecha/M = target_mob
M.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
M.attack_generic(src, rand(melee_damage_lower, melee_damage_upper), attacktext)
return M
if(istype(target_mob,/obj/machinery/bot))
if(istype(target_mob, /obj/machinery/bot))
var/obj/machinery/bot/B = target_mob
B.attack_generic(src,rand(melee_damage_lower,melee_damage_upper),attacktext)
B.attack_generic(src, rand(melee_damage_lower, melee_damage_upper), attacktext)
return B
if(istype(target_mob, /obj/machinery/porta_turret))
var/obj/machinery/porta_turret/T = target_mob
src.do_attack_animation(T)
T.take_damage(max(melee_damage_lower, melee_damage_upper) / 2)
visible_message("<span class='danger'>[src] [attacktext] \the [T]!</span>")
return T
/mob/living/simple_animal/hostile/proc/LoseTarget()
stance = HOSTILE_STANCE_IDLE
@@ -366,3 +373,8 @@ mob/living/simple_animal/hostile/hitby(atom/movable/AM as mob|obj,var/speed = TH
return TRUE
else
return FALSE
/mob/living/simple_animal/hostile/proc/validator_turret(var/obj/machinery/porta_turret/T, var/atom/current)
if(isliving(current)) // We prefer mobs over anything else
return FALSE
return !(T.health <= 0)
@@ -509,14 +509,20 @@ mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj)
var/mob/living/L = target_mob
if(!L.stat)
return (0)
if (istype(target_mob,/obj/mecha))
if (istype(target_mob, /obj/mecha))
var/obj/mecha/M = target_mob
if (M.occupant)
return (0)
if (istype(target_mob,/obj/machinery/bot))
if (istype(target_mob, /obj/machinery/bot))
var/obj/machinery/bot/B = target_mob
if(B.health > 0)
return (0)
if(istype(target_mob, /obj/machinery/porta_turret/))
var/obj/machinery/porta_turret/T = target_mob
if(T.health > 0)
return (0)
if(istype(target_mob, /obj/effect/energy_field))
return (0)
return 1
/mob/living/simple_animal/say(var/message)