diff --git a/code/game/gamemodes/handofgod/structures.dm b/code/game/gamemodes/handofgod/structures.dm
index ed4264e5fe6..9ba634ca0f0 100644
--- a/code/game/gamemodes/handofgod/structures.dm
+++ b/code/game/gamemodes/handofgod/structures.dm
@@ -444,12 +444,12 @@
maxhealth = 150
metal_cost = 25
glass_cost = 30
- var/obj/machinery/gun_turret/defensepylon_internal_turret/pylon_gun
+ var/obj/machinery/porta_turret/defensepylon_internal_turret/pylon_gun
/obj/structure/divine/defensepylon/New()
..()
- pylon_gun = new()
+ pylon_gun = new(src)
pylon_gun.base = src
pylon_gun.faction = list("[side] god")
@@ -474,49 +474,50 @@
pylon_gun.on = !pylon_gun.on
icon_state = (pylon_gun.on) ? "defensepylon-[side]" : "defensepylon"
-
//This sits inside the defensepylon, to avoid copypasta
-/obj/machinery/gun_turret/defensepylon_internal_turret
+/obj/machinery/porta_turret/defensepylon_internal_turret
name = "defense pylon"
desc = "A plyon which is blessed to withstand many blows, and fire strong bolts at nonbelievers."
icon = 'icons/obj/hand_of_god_structures.dmi'
- icon_state = "defensepylon"
+ installation = null
+ always_up = 1
+ use_power = 0
+ has_cover = 0
health = 200
+ projectile = /obj/item/projectile/beam/pylon_bolt
+ eprojectile = /obj/item/projectile/beam/pylon_bolt
+ shot_sound = 'sound/weapons/emitter2.ogg'
+ eshot_sound = 'sound/weapons/emitter2.ogg'
base_icon_state = "defensepylon"
- scan_range = 7
+ active_state = ""
+ off_state = ""
faction = null
- projectile_type = /obj/item/projectile/beam/pylon_bolt
- fire_sound = 'sound/weapons/emitter2.ogg'
var/side = "neutral"
- var/on = 1
-/obj/machinery/gun_turret/defensepylon_internal_turret/process()
- if(on)
- ..()
+/obj/machinery/porta_turret/defensepylon_internal_turret/setup()
+ return
-/obj/machinery/gun_turret/defensepylon_internal_turret/fire(atom/target)
+/obj/machinery/porta_turret/defensepylon_internal_turret/shootAt(atom/movable/target)
var/obj/item/projectile/A = ..()
if(A)
A.color = side
-/obj/machinery/gun_turret/defensepylon_internal_turret/validate_target(atom/target)
- . = ..()
- if(.)
- if(ishuman(target))
- var/mob/living/carbon/human/H = target
- if(H.handcuffed) //dishonourable to kill somebody who might be converted.
- return 0
-
- var/badtarget = 0
- switch(side)
- if("blue")
- badtarget = is_handofgod_bluecultist(target)
- if("red")
- badtarget = is_handofgod_redcultist(target)
- else
- badtarget = 1
- if(badtarget)
- return 0
+/obj/machinery/porta_turret/defensepylon_internal_turret/assess_perp(mob/living/carbon/human/perp)
+=
+ if(H.handcuffed) //dishonourable to kill somebody who might be converted.
+ return 0
+ var/badtarget = 0
+ switch(side)
+ if("blue")
+ badtarget = is_handofgod_bluecultist(perp)
+ if("red")
+ badtarget = is_handofgod_redcultist(perp)
+ else
+ badtarget = 1
+ if(badtarget)
+ return 0
+ return 10
+
/obj/item/projectile/beam/pylon_bolt
diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm
index 31929f6e94f..c81bfdf5c26 100644
--- a/code/game/machinery/portable_turret.dm
+++ b/code/game/machinery/portable_turret.dm
@@ -17,6 +17,13 @@
req_access = list(access_security)
power_channel = EQUIP //drains power from the EQUIPMENT channel
+ var/base_icon_state = "grey"
+ var/active_state = "Taser" // "Taser"/"Laser/"Bullet" ,blue/red/no glow on active turret
+ var/off_state = "Off"
+
+ var/scan_range = 7
+ var/atom/base = null //for turrets inside other objects
+
var/lasercolor = "" //Something to do with lasertag turrets, blame Sieve for not adding a comment.
var/raised = 0 //if the turret cover is "open" and the turret is raised
var/raising= 0 //if the turret is currently opening or closing its cover
@@ -29,8 +36,9 @@
var/projectile = null //holder for bullettype
var/eprojectile = null //holder for the shot when emagged
var/reqpower = 500 //holder for power needed
- var/iconholder = null //holder for the icon_state. 1 for orange sprite, null for blue.
var/egun = null //holder to handle certain guns switching bullettypes
+ var/always_up = 0 //Will stay active
+ var/has_cover = 1 //Hides the cover
var/obj/machinery/porta_turret_cover/cover = null //the cover that is covering this turret
var/last_fired = 0 //1: if the turret is cooling down from a shot, 0: turret is ready to fire
@@ -57,19 +65,35 @@
/obj/machinery/porta_turret/New()
..()
- icon_state = "[lasercolor]grey_target_prism"
+ if(!base)
+ base = src
+ icon_state = "[base_icon_state][off_state]"
//Sets up a spark system
spark_system = new /datum/effect_system/spark_spread
spark_system.set_up(5, 0, src)
spark_system.attach(src)
- cover = new /obj/machinery/porta_turret_cover(loc)
- cover.Parent_Turret = src
+ if(has_cover)
+ cover = new /obj/machinery/porta_turret_cover(loc)
+ cover.Parent_Turret = src
setup()
+ if(!has_cover)
+ popUp()
+
+
+/obj/machinery/porta_turret/proc/get_base_icon()
+ if(installation)
+ switch(installation)
+ if(/obj/item/weapon/gun/energy/laser/bluetag)
+ return "blue"
+ if(/obj/item/weapon/gun/energy/laser/redtag)
+ return "red"
+ return "grey"
+
/obj/machinery/porta_turret/proc/setup()
- var/obj/item/weapon/gun/energy/E=new installation //All energy-based weapons are applicable
+ var/obj/item/weapon/gun/energy/E= new installation //All energy-based weapons are applicable
var/obj/item/ammo_casing/shottype = E.ammo_type[1]
projectile = shottype.projectile_type
@@ -99,27 +123,20 @@
stun_all = 0
check_anomalies = 0
shot_delay = 30
- iconholder = 1
+ active_state = "Laser"
if(/obj/item/weapon/gun/energy/laser/practice)
- iconholder = 1
+ active_state = "Laser"
eprojectile = /obj/item/projectile/beam
-// if(/obj/item/weapon/gun/energy/laser/practice/sc_laser)
-// iconholder = 1
-// eprojectile = /obj/item/projectile/beam
-
if(/obj/item/weapon/gun/energy/laser/retro)
- iconholder = 1
-
-// if(/obj/item/weapon/gun/energy/laser/retro/sc_retro)
-// iconholder = 1
+ active_state = "Laser"
if(/obj/item/weapon/gun/energy/laser/captain)
- iconholder = 1
+ active_state = "Laser"
if(/obj/item/weapon/gun/energy/lasercannon)
- iconholder = 1
+ active_state = "Laser"
if(/obj/item/weapon/gun/energy/gun/advtaser)
eprojectile = /obj/item/projectile/beam
@@ -140,6 +157,8 @@
eshot_sound = 'sound/weapons/Laser.ogg'
egun = 1
+ base_icon_state = get_base_icon()
+
/obj/machinery/porta_turret/Destroy()
//deletes its own cover with it
qdel(cover)
@@ -229,22 +248,17 @@
icon_state = "turretCover"
return
if(stat & BROKEN)
- icon_state = "[lasercolor]destroyed_target_prism"
+ icon_state = "[base_icon_state]Broken"
else
if( powered() )
if(on)
- if(iconholder)
- //lasers have a orange icon
- icon_state = "[lasercolor]orange_target_prism"
- else
- //almost everything has a blue icon
- icon_state = "[lasercolor]target_prism"
+ icon_state = "[base_icon_state][active_state]"
else
- icon_state = "[lasercolor]grey_target_prism"
+ icon_state = "[base_icon_state][off_state]"
stat &= ~NOPOWER
else
spawn(rand(0, 15))
- icon_state = "[lasercolor]grey_target_prism"
+ icon_state = "[base_icon_state][off_state]"
stat |= NOPOWER
@@ -277,10 +291,11 @@
if(!anchored && !isinspace())
anchored = 1
invisibility = INVISIBILITY_LEVEL_TWO
- icon_state = "[lasercolor]grey_target_prism"
+ icon_state = "[base_icon_state][off_state]"
user << "You secure the exterior bolts on the turret."
- cover = new /obj/machinery/porta_turret_cover(loc) //create a new turret. While this is handled in process(), this is to workaround a bug where the turret becomes invisible for a split second
- cover.Parent_Turret = src //make the cover's parent src
+ if(has_cover)
+ cover = new /obj/machinery/porta_turret_cover(loc) //create a new turret. While this is handled in process(), this is to workaround a bug where the turret becomes invisible for a split second
+ cover.Parent_Turret = src //make the cover's parent src
else if(anchored)
anchored = 0
user << "You unsecure the exterior bolts on the turret."
@@ -339,7 +354,7 @@
user << "You short out [src]'s threat assessment circuits."
visible_message("[src] hums oddly...")
emagged = 1
- iconholder = 1
+ active_state = "Laser"
controllock = 1
on = 0 //turns off the turret temporarily
sleep(60) //6 seconds for the traitor to gtfo of the area before the turret decides to ruin his shit
@@ -412,7 +427,7 @@
health = 0
density = 0
stat |= BROKEN //enables the BROKEN bit
- icon_state = "[lasercolor]destroyed_target_prism"
+ icon_state = "[base_icon_state]Broken"
invisibility = 0
spark_system.start() //creates some sparks because they look cool
density = 1
@@ -429,22 +444,22 @@
if(stat & BROKEN) //if the turret is borked
qdel(cover) //delete its cover, assuming it has one. Workaround for a pesky little bug
else
+ if(has_cover)
+ cover = new /obj/machinery/porta_turret_cover(loc) //if the turret has no cover and is anchored, give it a cover
+ cover.Parent_Turret = src //assign the cover its Parent_Turret, which would be this (src)
- cover = new /obj/machinery/porta_turret_cover(loc) //if the turret has no cover and is anchored, give it a cover
- cover.Parent_Turret = src //assign the cover its Parent_Turret, which would be this (src)
-
- if(stat & (NOPOWER|BROKEN))
+ if(stat & (NOPOWER|BROKEN) && !always_up)
//if the turret has no power or is broken, make the turret pop down if it hasn't already
popDown()
return
- if(!on)
+ if(!on && !always_up)
//if the turret is off, make it pop down
popDown()
return
var/list/targets = list() //list of primary targets
- var/turretview = view(7, src)
+ var/turretview = view(scan_range, base)
if(check_anomalies) //if it's set to check for xenos/simpleanimals
for(var/mob/living/simple_animal/SA in turretview)
@@ -476,12 +491,13 @@
for(var/obj/mecha/M in turretview)
if(M.occupant)
- if(ai || emagged) // we target all occupied mechs if we're emagged or set to attack all non silicons.
+ if(ai || emagged || assess_perp(M.occupant) >= 4) // we target all occupied mechs if we're emagged or set to attack all non silicons.
targets += M
if(!tryToShootAt(targets))
- spawn()
- popDown() // no valid targets, close the cover
+ if(!always_up)
+ spawn()
+ popDown() // no valid targets, close the cover
/obj/machinery/porta_turret/proc/tryToShootAt(list/atom/movable/targets)
@@ -501,10 +517,12 @@
return
invisibility = 0
raising = 1
- flick("popup", cover)
+ if(cover)
+ flick("popup", cover)
sleep(10)
raising = 0
- cover.icon_state = "openTurretCover"
+ if(cover)
+ cover.icon_state = "openTurretCover"
raised = 1
layer = 4
@@ -517,13 +535,15 @@
return
layer = 3
raising = 1
- flick("popdown", cover)
+ if(cover)
+ flick("popdown", cover)
sleep(10)
raising = 0
- cover.icon_state = "turretCover"
+ if(cover)
+ cover.icon_state = "turretCover"
raised = 0
invisibility = 2
- icon_state = "[lasercolor]grey_target_prism"
+ icon_state = "[base_icon_state][off_state]"
/obj/machinery/porta_turret/proc/assess_perp(mob/living/carbon/human/perp)
@@ -585,7 +605,7 @@
if(target)
spawn()
popUp() //pop the turret up if it's not already up.
- dir = get_dir(src, target) //even if you can't shoot, follow the target
+ dir = get_dir(base, target) //even if you can't shoot, follow the target
spawn()
shootAt(target)
return 1
@@ -609,34 +629,34 @@
return
//any emagged turrets will shoot extremely fast! This not only is deadly, but drains a lot power!
- if(iconholder)
- icon_state = "[lasercolor]orange_target_prism"
- else
- icon_state = "[lasercolor]target_prism"
+ icon_state = "[base_icon_state][active_state]"
var/obj/item/projectile/A
if(emagged)
- A = new eprojectile(loc)
+ A = new eprojectile(T)
playsound(loc, eshot_sound, 75, 1)
else
- A = new projectile(loc)
+ A = new projectile(T)
playsound(loc, shot_sound, 75, 1)
A.original = target
if(!emagged)
use_power(reqpower)
else
use_power(reqpower * 2)
- //Shooting Code:
+ //Shooting Code:
A.current = T
A.yo = U.y - T.y
A.xo = U.x - T.x
A.fire()
+ return A
+
/obj/machinery/porta_turret/proc/setState(on, emagged)
if(controllock)
return
src.on = on
src.emagged = emagged
- src.iconholder = emagged
+ if(emagged)
+ src.active_state = "Laser"
src.power_change()
/*
@@ -867,113 +887,16 @@
. = ..()
if(.)
return
- var/dat
- if(!(Parent_Turret.lasercolor))
- dat += text({"
-Automatic Portable Turret Installation
-Status: []
-Behaviour controls are [Parent_Turret.locked ? "locked" : "unlocked"]"},
-
-"[Parent_Turret.on ? "On" : "Off"]" )
-
-
- dat += text({"
-Check for Weapon Authorization: []
-Check Security Records: []
-Neutralize Identified Criminals: []
-Neutralize All Non-Security and Non-Command Personnel: []
-Neutralize All Unidentified Life Signs: []
"},
-
-"[Parent_Turret.auth_weapons ? "Yes" : "No"]",
-"[Parent_Turret.check_records ? "Yes" : "No"]",
-"[Parent_Turret.criminals ? "Yes" : "No"]",
-"[Parent_Turret.stun_all ? "Yes" : "No"]" ,
-"[Parent_Turret.check_anomalies ? "Yes" : "No"]" )
- else
- dat += text({"
-Automatic Portable Turret Installation
-Status: []
"},
-
-"[Parent_Turret.on ? "On" : "Off"]" )
-
- user << browse("