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("Automatic Portable Turret Installation[dat]", "window=autosec") - onclose(user, "autosec") + + return Parent_Turret.attack_ai(user) /obj/machinery/porta_turret_cover/attack_hand(mob/user) . = ..() 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"]" ) - - if(!Parent_Turret.locked) - 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 - if(istype(user,/mob/living/carbon/human)) - var/mob/living/carbon/human/H = user - if(Parent_Turret.lasercolor == "b" && istype(H.wear_suit, /obj/item/clothing/suit/redtag)) - return - if(Parent_Turret.lasercolor == "r" && istype(H.wear_suit, /obj/item/clothing/suit/bluetag)) - return - dat += text({" - Automatic Portable Turret Installation

- Status: []
"}, - - "[Parent_Turret.on ? "On" : "Off"]" ) - - user << browse("Automatic Portable Turret Installation[dat]", "window=autosec") - onclose(user, "autosec") - - -/obj/machinery/porta_turret_cover/Topic(href, href_list) - if(..()) - return - usr.set_machine(src) - Parent_Turret.add_fingerprint(usr) - add_fingerprint(usr) - if(href_list["power"] && !Parent_Turret.locked) - if(Parent_Turret.anchored) - if(Parent_Turret.on) - Parent_Turret.on = 0 - else - Parent_Turret.on = 1 - else - usr << "It has to be secured first!" - - updateUsrDialog() - return - - switch(href_list["operation"]) - if("authweapon") - Parent_Turret.auth_weapons = !Parent_Turret.auth_weapons - if("checkrecords") - Parent_Turret.check_records = !Parent_Turret.check_records - if("shootcrooks") - Parent_Turret.criminals = !Parent_Turret.criminals - if("shootall") - Parent_Turret.stun_all = !Parent_Turret.stun_all - if("checkxenos") - Parent_Turret.check_anomalies = !Parent_Turret.check_anomalies - - updateUsrDialog() + return Parent_Turret.attack_hand(user) /obj/machinery/porta_turret_cover/attackby(obj/item/I, mob/user, params) @@ -1014,7 +937,7 @@ Status: []
"}, ..() /obj/machinery/porta_turret_cover/emag_act(mob/user) - if(!emagged) + if(!Parent_Turret.emagged) user << "You short out [Parent_Turret]'s threat assessment circuits." visible_message("[Parent_Turret] hums oddly...") Parent_Turret.emagged = 1 @@ -1025,10 +948,33 @@ Status: []
"}, /obj/machinery/porta_turret/stationary emagged = 1 - New() +/obj/machinery/porta_turret/stationary/New() installation = new/obj/item/weapon/gun/energy/laser(loc) ..() + +/obj/machinery/porta_turret/syndicate + installation = null + always_up = 1 + use_power = 0 + has_cover = 0 + scan_range = 9 + projectile = /obj/item/projectile/bullet + eprojectile = /obj/item/projectile/bullet + shot_sound = 'sound/weapons/Gunshot.ogg' + eshot_sound = 'sound/weapons/Gunshot.ogg' + base_icon_state = "syndie" + active_state = "Bullet" + faction = "syndicate" + +/obj/machinery/porta_turret/syndicate/setup() + return + +/obj/machinery/porta_turret/syndicate/assess_perp(mob/living/carbon/human/perp) + if(faction in perp.faction) //Shoot all non syndies + return 0 + return 10 + //////////////////////// //Turret Control Panel// //////////////////////// diff --git a/code/game/machinery/turrets.dm b/code/game/machinery/turrets.dm deleted file mode 100644 index 188f7e9c3be..00000000000 --- a/code/game/machinery/turrets.dm +++ /dev/null @@ -1,158 +0,0 @@ -////////////// -//Gun Turret// -////////////// - -/obj/machinery/gun_turret //related to turrets but work way differentely because of being mounted on a moving ship. - name = "machine gun turret" - desc = "Syndicate defense turret. It really packs a punch." - density = 1 - anchored = 1 - var/state = 0 //Like stat on mobs, 0 is alive, 1 is damaged, 2 is dead - var/faction = "syndicate" - var/atom/cur_target = null - var/scan_range = 9 //You will never see them coming - var/health = 200 //Because it lacks a cover, and is mostly to keep people from touching the syndie shuttle. - var/base_icon_state = "syndieturret" - var/projectile_type = /obj/item/projectile/bullet - var/fire_sound = 'sound/weapons/Gunshot.ogg' - var/atom/base = null //where do to range calculations, firing projectiles, etc. from. allows for turrets inside of things to work - icon = 'icons/obj/turrets.dmi' - icon_state = "syndieturret0" - -/obj/machinery/gun_turret/New() - ..() - if(!base) - base = src - take_damage(0) //check your health - icon_state = "[base_icon_state]" + "0" - - -/obj/machinery/gun_turret/ex_act(severity, target) - switch(severity) - if(1) - die() - if(2) - take_damage(100) - if(3) - take_damage(50) - return - -/obj/machinery/gun_turret/emp_act() //Can't emp an mechanical turret. - return - -/obj/machinery/gun_turret/update_icon() - if(state > 2 || state < 0) //someone fucked up the vars so fix them - take_damage(0) - icon_state = "[base_icon_state]" + "[state]" - return - - -/obj/machinery/gun_turret/proc/take_damage(damage) - health -= damage - switch(health) - if(101 to INFINITY) - state = 0 - if(1 to 100) - state = 1 - if(-INFINITY to 0) - if(state != 2) - die() - return - state = 2 - - update_icon() - return - - -/obj/machinery/gun_turret/bullet_act(obj/item/projectile/Proj) - take_damage(Proj.damage) - return - -/obj/machinery/gun_turret/proc/die() - state = 2 - update_icon() - -/obj/machinery/gun_turret/attack_hand(mob/user) - return - -/obj/machinery/gun_turret/attack_ai(mob/user) - return attack_hand(user) - - -/obj/machinery/gun_turret/attack_alien(mob/living/user) - user.changeNext_move(CLICK_CD_MELEE) - user.do_attack_animation(src) - user.visible_message("[user] slashes at [src]!", "You slash at [src]!") - take_damage(15) - return - - -/obj/machinery/gun_turret/proc/should_target(atom/target) - if(ismob(target)) - var/mob/M = target - if(!M.stat && !(faction in M.faction)) - return 1 - else if(istype(target, /obj/mecha)) - var/obj/mecha/M = target - if(M.occupant && should_target(M.occupant)) - return 1 - return 0 - - -/obj/machinery/gun_turret/proc/validate_target(atom/target) - if(get_dist(target, base)>scan_range) - return 0 - if(should_target(target)) - return 1 - return 0 - - -/obj/machinery/gun_turret/process() - if(state == 2) - return - if(cur_target && !validate_target(cur_target)) - cur_target = null - if(!cur_target) - cur_target = get_target() - if(cur_target) - fire(cur_target) - return - - -/obj/machinery/gun_turret/proc/get_target() - var/list/pos_targets = list() - var/target = null - for(var/mob/living/M in view(scan_range,base)) - if(!should_target(M)) - continue - pos_targets += M - for(var/obj/mecha/M in oview(scan_range, base)) - if(!should_target(M)) - continue - pos_targets += M - if(pos_targets.len) - target = pick(pos_targets) - return target - - -/obj/machinery/gun_turret/proc/fire(atom/target) - if(!target) - cur_target = null - return - src.dir = get_dir(base,target) - var/turf/targloc = get_turf(target) - if(!src) - return - var/turf/curloc = get_turf(base) - if (!targloc || !curloc) - return - if (targloc == curloc) - return - playsound(src, fire_sound, 50, 1) - var/obj/item/projectile/A = new projectile_type(curloc) - A.current = curloc - A.yo = targloc.y - curloc.y - A.xo = targloc.x - curloc.x - A.fire() - return - diff --git a/icons/obj/turrets.dmi b/icons/obj/turrets.dmi index fa8dad72c36..88dbac93829 100644 Binary files a/icons/obj/turrets.dmi and b/icons/obj/turrets.dmi differ diff --git a/tgstation.dme b/tgstation.dme index c8e8d14641e..128acf25a6c 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -450,7 +450,6 @@ #include "code\game\machinery\syndicatebomb.dm" #include "code\game\machinery\teleporter.dm" #include "code\game\machinery\transformer.dm" -#include "code\game\machinery\turrets.dm" #include "code\game\machinery\vending.dm" #include "code\game\machinery\washing_machine.dm" #include "code\game\machinery\wishgranter.dm"