From 9a04744ab623fa164c8c5b0fb23cfda4af28173e Mon Sep 17 00:00:00 2001 From: Mechoid Date: Sun, 15 Oct 2017 13:35:29 -0700 Subject: [PATCH] Turrets detect targets through metal foam. --- code/_helpers/mobs.dm | 9 +++++++++ code/game/machinery/portable_turret.dm | 13 ++++++++++--- code/game/machinery/turret_control.dm | 6 ++++++ code/game/objects/effects/chem/foam.dm | 6 ++++-- code/modules/projectiles/projectile.dm | 2 ++ 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/code/_helpers/mobs.dm b/code/_helpers/mobs.dm index 8ac42dc0b9..eb1ef73eb7 100644 --- a/code/_helpers/mobs.dm +++ b/code/_helpers/mobs.dm @@ -24,6 +24,15 @@ return mobs +/proc/mobs_in_xray_view(var/range, var/source) + var/list/mobs = list() + for(var/atom/movable/AM in orange(range, source)) + var/M = AM.get_mob() + if(M) + mobs += M + + return mobs + proc/random_hair_style(gender, species = "Human") var/h_style = "Bald" diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index 8eba407e72..1b181aebb5 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -45,6 +45,7 @@ var/check_access = 1 //if this is active, the turret shoots everything that does not meet the access requirements var/check_anomalies = 1 //checks if it can shoot at unidentified lifeforms (ie xenos) var/check_synth = 0 //if active, will shoot at anything not an AI or cyborg + var/check_all = 0 //If active, will fire on anything, including synthetics. var/ailock = 0 // AI cannot use this var/attacked = 0 //if set to 1, the turret gets pissed off and shoots at people nearby (unless they have sec access!) @@ -71,6 +72,7 @@ check_records = 1 check_weapons = 1 check_anomalies = 1 + check_all = 0 /obj/machinery/porta_turret/stationary ailock = 1 @@ -229,6 +231,7 @@ var/list/turret_icons settings[++settings.len] = list("category" = "Check Arrest Status", "setting" = "check_arrest", "value" = check_arrest) settings[++settings.len] = list("category" = "Check Access Authorization", "setting" = "check_access", "value" = check_access) settings[++settings.len] = list("category" = "Check misc. Lifeforms", "setting" = "check_anomalies", "value" = check_anomalies) + settings[++settings.len] = list("category" = "Neutralize All Entities", "setting" = "check_all", "value" = check_all) data["settings"] = settings ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) @@ -278,6 +281,8 @@ var/list/turret_icons check_access = value else if(href_list["command"] == "check_anomalies") check_anomalies = value + else if(href_list["command"] == "check_all") + check_all = value return 1 @@ -465,7 +470,7 @@ var/list/turret_icons var/list/targets = list() //list of primary targets var/list/secondarytargets = list() //targets that are least important - for(var/mob/M in mobs_in_view(world.view, src)) + for(var/mob/M in mobs_in_xray_view(world.view, src)) assess_and_assign(M, targets, secondarytargets) if(!tryToShootAt(targets)) @@ -496,7 +501,7 @@ var/list/turret_icons if(!L) return TURRET_NOT_TARGET - if(!emagged && issilicon(L)) // Don't target silica + if(!emagged && issilicon(L) && check_all == 0) // Don't target silica, unless told to neutralize everything. return TURRET_NOT_TARGET if(L.stat && !emagged) //if the perp is dead/dying, no need to bother really @@ -514,7 +519,7 @@ var/list/turret_icons if(lethal && locate(/mob/living/silicon/ai) in get_turf(L)) //don't accidentally kill the AI! return TURRET_NOT_TARGET - if(check_synth) //If it's set to attack all non-silicons, target them! + if(check_synth || check_all) //If it's set to attack all non-silicons or everything, target them! if(L.lying) return lethal ? TURRET_SECONDARY_TARGET : TURRET_NOT_TARGET return TURRET_PRIORITY_TARGET @@ -671,6 +676,7 @@ var/list/turret_icons var/check_arrest var/check_weapons var/check_anomalies + var/check_all var/ailock /obj/machinery/porta_turret/proc/setState(var/datum/turret_checks/TC) @@ -686,6 +692,7 @@ var/list/turret_icons check_arrest = TC.check_arrest check_weapons = TC.check_weapons check_anomalies = TC.check_anomalies + check_all = TC.check_all ailock = TC.ailock power_change() diff --git a/code/game/machinery/turret_control.dm b/code/game/machinery/turret_control.dm index 17797e2a68..4f33f1703f 100644 --- a/code/game/machinery/turret_control.dm +++ b/code/game/machinery/turret_control.dm @@ -24,6 +24,7 @@ var/check_access = 1 //if this is active, the turret shoots everything that does not meet the access requirements var/check_anomalies = 1 //checks if it can shoot at unidentified lifeforms (ie xenos) var/check_synth = 0 //if active, will shoot at anything not an AI or cyborg + var/check_all = 0 //If active, will shoot at anything. var/ailock = 0 //Silicons cannot use this req_access = list(access_ai_upload) @@ -130,6 +131,8 @@ settings[++settings.len] = list("category" = "Check Arrest Status", "setting" = "check_arrest", "value" = check_arrest) settings[++settings.len] = list("category" = "Check Access Authorization", "setting" = "check_access", "value" = check_access) settings[++settings.len] = list("category" = "Check misc. Lifeforms", "setting" = "check_anomalies", "value" = check_anomalies) + settings[++settings.len] = list("category" = "Neutralize All Entities", "setting" = "check_all", "value" = check_all) + data["settings"] = settings ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) @@ -161,6 +164,8 @@ check_access = value else if(href_list["command"] == "check_anomalies") check_anomalies = value + else if(href_list["command"] == "check_all") + check_all = value updateTurrets() return 1 @@ -175,6 +180,7 @@ TC.check_arrest = check_arrest TC.check_weapons = check_weapons TC.check_anomalies = check_anomalies + TC.check_all = check_all TC.ailock = ailock if(istype(control_area)) diff --git a/code/game/objects/effects/chem/foam.dm b/code/game/objects/effects/chem/foam.dm index 2c28dd7ecb..03f743db6b 100644 --- a/code/game/objects/effects/chem/foam.dm +++ b/code/game/objects/effects/chem/foam.dm @@ -150,8 +150,10 @@ /obj/structure/foamedmetal/ex_act(severity) qdel(src) -/obj/structure/foamedmetal/bullet_act() - if(metal == 1 || prob(50)) +/obj/structure/foamedmetal/bullet_act(var/obj/item/projectile/P) + if(istype(P, /obj/item/projectile/test)) + return + else if(metal == 1 || prob(50)) qdel(src) /obj/structure/foamedmetal/attack_hand(var/mob/user) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 76c4249092..896378116c 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -410,6 +410,8 @@ return //cannot shoot yourself if(istype(A, /obj/item/projectile)) return + if(istype(A, /obj/structure/foamedmetal)) //Turrets can detect through foamed metal, but will have to blast through it. Similar to windows, if someone runs behind it, a person should probably just not shoot. + return if(istype(A, /mob/living) || istype(A, /obj/mecha) || istype(A, /obj/vehicle)) result = 2 //We hit someone, return 1! return