From 0dd89d484ac652a981b050ad4f9a8f452eba3f0a Mon Sep 17 00:00:00 2001 From: oranges Date: Sun, 14 Feb 2016 07:58:10 +0000 Subject: [PATCH 1/3] Rearrange turret files to split out functionality Add defines for the turret construction phases Tweak syndicate turret targeting to remove uncessary faction check --- .../{ => porta_turret}/portable_turret.dm | 291 +----------------- .../porta_turret/portable_turret_construct.dm | 201 ++++++++++++ .../porta_turret/portable_turret_cover.dm | 86 ++++++ tgstation.dme | 4 +- 4 files changed, 294 insertions(+), 288 deletions(-) rename code/game/machinery/{ => porta_turret}/portable_turret.dm (72%) create mode 100644 code/game/machinery/porta_turret/portable_turret_construct.dm create mode 100644 code/game/machinery/porta_turret/portable_turret_cover.dm diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm similarity index 72% rename from code/game/machinery/portable_turret.dm rename to code/game/machinery/porta_turret/portable_turret.dm index 6c629db9149..688ecdeeeb3 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -601,8 +601,6 @@ return threatcount -/obj/machinery/porta_turret/ai/assess_perp(mob/living/carbon/human/perp) - return 10 //AI turrets shoot at everything not in their faction /obj/machinery/porta_turret/proc/in_faction(mob/target) if(!(faction in target.faction)) @@ -666,287 +664,6 @@ src.power_change() -/obj/machinery/porta_turret_construct - name = "turret frame" - icon = 'icons/obj/turrets.dmi' - icon_state = "turret_frame" - density=1 - var/build_step = 0 //the current step in the building process - var/finish_name="turret" //the name applied to the product turret - var/installation = null //the gun type installed - var/gun_charge = 0 //the gun charge of the gun type installed - - -/obj/machinery/porta_turret_construct/attackby(obj/item/I, mob/user, params) - //this is a bit unwieldy but self-explanatory - switch(build_step) - if(0) //first step - if(istype(I, /obj/item/weapon/wrench) && !anchored) - playsound(loc, 'sound/items/Ratchet.ogg', 100, 1) - user << "You secure the external bolts." - anchored = 1 - build_step = 1 - return - - else if(istype(I, /obj/item/weapon/crowbar) && !anchored) - playsound(loc, 'sound/items/Crowbar.ogg', 75, 1) - user << "You dismantle the turret construction." - new /obj/item/stack/sheet/metal( loc, 5) - qdel(src) - return - - if(1) - if(istype(I, /obj/item/stack/sheet/metal)) - var/obj/item/stack/sheet/metal/M = I - if(M.use(2)) - user << "You add some metal armor to the interior frame." - build_step = 2 - icon_state = "turret_frame2" - else - user << "You need two sheets of metal to continue construction!" - return - - else if(istype(I, /obj/item/weapon/wrench)) - playsound(loc, 'sound/items/Ratchet.ogg', 75, 1) - user << "You unfasten the external bolts." - anchored = 0 - build_step = 0 - return - - - if(2) - if(istype(I, /obj/item/weapon/wrench)) - playsound(loc, 'sound/items/Ratchet.ogg', 100, 1) - user << "You bolt the metal armor into place." - build_step = 3 - return - - else if(istype(I, /obj/item/weapon/weldingtool)) - var/obj/item/weapon/weldingtool/WT = I - if(!WT.isOn()) - return - if(WT.get_fuel() < 5) //uses up 5 fuel. - user << "You need more fuel to complete this task!" - return - - playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) - user << "You start to remove the turret's interior metal armor..." - if(do_after(user, 20/I.toolspeed, target = src)) - if(!src || !WT.remove_fuel(5, user)) return - build_step = 1 - user << "You remove the turret's interior metal armor." - new /obj/item/stack/sheet/metal( loc, 2) - return - - - if(3) - if(istype(I, /obj/item/weapon/gun/energy)) //the gun installation part - - if(isrobot(user)) - return - var/obj/item/weapon/gun/energy/E = I //typecasts the item to an energy gun - if(!user.unEquip(I)) - user << "\the [I] is stuck to your hand, you cannot put it in \the [src]!" - return - installation = I.type //installation becomes I.type - gun_charge = E.power_supply.charge //the gun's charge is stored in gun_charge - user << "You add [I] to the turret." - build_step = 4 - qdel(I) //delete the gun :( - return - - else if(istype(I, /obj/item/weapon/wrench)) - playsound(loc, 'sound/items/Ratchet.ogg', 100, 1) - user << "You remove the turret's metal armor bolts." - build_step = 2 - return - - if(4) - if(isprox(I)) - build_step = 5 - if(!user.unEquip(I)) - user << "\the [I] is stuck to your hand, you cannot put it in \the [src]!" - return - user << "You add the proximity sensor to the turret." - qdel(I) - return - - - if(5) - if(istype(I, /obj/item/weapon/screwdriver)) - playsound(loc, 'sound/items/Screwdriver.ogg', 100, 1) - build_step = 6 - user << "You close the internal access hatch." - return - - - if(6) - if(istype(I, /obj/item/stack/sheet/metal)) - var/obj/item/stack/sheet/metal/M = I - if(M.use(2)) - user << "You add some metal armor to the exterior frame." - build_step = 7 - else - user << "You need two sheets of metal to continue construction!" - return - - else if(istype(I, /obj/item/weapon/screwdriver)) - playsound(loc, 'sound/items/Screwdriver.ogg', 100, 1) - build_step = 5 - user << "You open the internal access hatch." - return - - if(7) - if(istype(I, /obj/item/weapon/weldingtool)) - var/obj/item/weapon/weldingtool/WT = I - if(!WT.isOn()) return - if(WT.get_fuel() < 5) - user << "You need more fuel to complete this task!" - - playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) - user << "You begin to weld the turret's armor down..." - if(do_after(user, 30/I.toolspeed, target = src)) - if(!src || !WT.remove_fuel(5, user)) - return - build_step = 8 - user << "You weld the turret's armor down." - - //The final step: create a full turret - var/obj/machinery/porta_turret/Turret = new/obj/machinery/porta_turret(loc) - Turret.name = finish_name - Turret.installation = installation - Turret.gun_charge = gun_charge - Turret.setup() - - qdel(src) - - else if(istype(I, /obj/item/weapon/crowbar)) - playsound(loc, 'sound/items/Crowbar.ogg', 75, 1) - user << "You pry off the turret's exterior armor." - new /obj/item/stack/sheet/metal(loc, 2) - build_step = 6 - return - - if(istype(I, /obj/item/weapon/pen)) //you can rename turrets like bots! - var/t = stripped_input(user, "Enter new turret name", name, finish_name) - if(!t) - return - if(!in_range(src, usr) && loc != usr) - return - - finish_name = t - return - ..() - - -/obj/machinery/porta_turret_construct/attack_hand(mob/user) - switch(build_step) - if(4) - if(!installation) - return - build_step = 3 - - var/obj/item/weapon/gun/energy/Gun = new installation(loc) - Gun.power_supply.charge = gun_charge - Gun.update_icon() - installation = null - gun_charge = 0 - user << "You remove [Gun] from the turret frame." - - if(5) - user << "You remove the prox sensor from the turret frame." - new /obj/item/device/assembly/prox_sensor(loc) - build_step = 4 - -/obj/machinery/porta_turret_construct/attack_ai() - return - - -/************************ -* PORTABLE TURRET COVER * -************************/ - -/obj/machinery/porta_turret_cover - name = "turret" - icon = 'icons/obj/turrets.dmi' - icon_state = "turretCover" - anchored = 1 - layer = 3.5 - density = 0 - var/obj/machinery/porta_turret/Parent_Turret = null - - -//The below code is pretty much just recoded from the initial turret object. It's necessary but uncommented because it's exactly the same! -//>necessary -//I'm not fixing it because i'm fucking bored of this code already, but someone should just reroute these to the parent turret's procs. - -/obj/machinery/porta_turret_cover/attack_ai(mob/user) - . = ..() - if(.) - return - - return Parent_Turret.attack_ai(user) - - -/obj/machinery/porta_turret_cover/attack_hand(mob/user) - . = ..() - if(.) - return - - return Parent_Turret.attack_hand(user) - - -/obj/machinery/porta_turret_cover/attackby(obj/item/I, mob/user, params) - if(istype(I, /obj/item/weapon/wrench) && !Parent_Turret.on) - if(Parent_Turret.raised) return - - if(!Parent_Turret.anchored) - Parent_Turret.anchored = 1 - Parent_Turret.invisibility = INVISIBILITY_OBSERVER - Parent_Turret.icon_state = "grey_target_prism" - user << "You secure the exterior bolts on the turret." - else - Parent_Turret.anchored = 0 - user << "You unsecure the exterior bolts on the turret." - Parent_Turret.icon_state = "turretCover" - Parent_Turret.invisibility = 0 - qdel(src) - - else if(istype(I, /obj/item/weapon/card/id)||istype(I, /obj/item/device/pda)) - if(Parent_Turret.allowed(user)) - Parent_Turret.locked = !Parent_Turret.locked - user << "Controls are now [Parent_Turret.locked ? "locked" : "unlocked"]." - updateUsrDialog() - else - user << "Access denied." - else if(istype(I,/obj/item/device/multitool) && !Parent_Turret.locked) - var/obj/item/device/multitool/M = I - M.buffer = Parent_Turret - user << "You add [Parent_Turret] to multitool buffer." - else - user.changeNext_move(CLICK_CD_MELEE) - Parent_Turret.health -= I.force * 0.5 - if(Parent_Turret.health <= 0) - Parent_Turret.die() - if(I.force * 0.5 > 2) - if(!Parent_Turret.attacked && !Parent_Turret.emagged) - Parent_Turret.attacked = 1 - spawn() - sleep(30) - Parent_Turret.attacked = 0 - ..() - -/obj/machinery/porta_turret_cover/can_be_overridden() - . = 0 - -/obj/machinery/porta_turret_cover/emag_act(mob/user) - if(!Parent_Turret.emagged) - user << "You short out [Parent_Turret]'s threat assessment circuits." - visible_message("[Parent_Turret] hums oddly...") - Parent_Turret.emagged = 1 - Parent_Turret.on = 0 - sleep(40) - Parent_Turret.on = 1 /obj/machinery/porta_turret/stationary emagged = 1 @@ -975,19 +692,19 @@ 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 + return 10 //Syndicate turrets shoot everything not in their faction /obj/machinery/porta_turret/syndicate/pod health = 40 projectile = /obj/item/projectile/bullet/weakbullet3 eprojectile = /obj/item/projectile/bullet/weakbullet3 -//Blame MSO /obj/machinery/porta_turret/ai faction = "silicon" +/obj/machinery/porta_turret/ai/assess_perp(mob/living/carbon/human/perp) + return 10 //AI turrets shoot at everything not in their faction + //////////////////////// //Turret Control Panel// //////////////////////// diff --git a/code/game/machinery/porta_turret/portable_turret_construct.dm b/code/game/machinery/porta_turret/portable_turret_construct.dm new file mode 100644 index 00000000000..f80f3fbb017 --- /dev/null +++ b/code/game/machinery/porta_turret/portable_turret_construct.dm @@ -0,0 +1,201 @@ +#define PTURRET_UNSECURED = 0 +#define PTURRET_BOLTED = 1 +#define PTURRET_START_INTERNAL_ARMOUR = 2 +#define PTURRET_INTERNAL_ARMOUR_ON = 3 +#define PTURRET_GUN_EQUIPPED = 4 +#define PTURRET_SENSORS_ON = 5 +#define PTURRET_CLOSED = 6 +#define PTURRET_START_EXTERNAL_ARMOUR = 7 +#define PTURRET_EXTERNAL_ARMOUR_ON = 8 +/obj/machinery/porta_turret_construct + name = "turret frame" + icon = 'icons/obj/turrets.dmi' + icon_state = "turret_frame" + density=1 + var/build_step = PTURRET_UNSECURED //the current step in the building process + var/finish_name="turret" //the name applied to the product turret + var/installation = null //the gun type installed + var/gun_charge = 0 //the gun charge of the gun type installed + + +/obj/machinery/porta_turret_construct/attackby(obj/item/I, mob/user, params) + //this is a bit unwieldy but self-explanatory + switch(build_step) + if(PTURRET_UNSECURED) //first step + if(istype(I, /obj/item/weapon/wrench) && !anchored) + playsound(loc, 'sound/items/Ratchet.ogg', 100, 1) + user << "You secure the external bolts." + anchored = 1 + build_step = PTURRET_BOLTED + return + + else if(istype(I, /obj/item/weapon/crowbar) && !anchored) + playsound(loc, 'sound/items/Crowbar.ogg', 75, 1) + user << "You dismantle the turret construction." + new /obj/item/stack/sheet/metal( loc, 5) + qdel(src) + return + + if(PTURRET_BOLTED) + if(istype(I, /obj/item/stack/sheet/metal)) + var/obj/item/stack/sheet/metal/M = I + if(M.use(2)) + user << "You add some metal armor to the interior frame." + build_step = PTURRET_START_INTERNAL_ARMOUR + icon_state = "turret_frame2" + else + user << "You need two sheets of metal to continue construction!" + return + + else if(istype(I, /obj/item/weapon/wrench)) + playsound(loc, 'sound/items/Ratchet.ogg', 75, 1) + user << "You unfasten the external bolts." + anchored = 0 + build_step = PTURRET_UNSECURED + return + + + if(PTURRET_START_INTERNAL_ARMOUR) + if(istype(I, /obj/item/weapon/wrench)) + playsound(loc, 'sound/items/Ratchet.ogg', 100, 1) + user << "You bolt the metal armor into place." + build_step = PTURRET_INTERNAL_ARMOUR_ON + return + + else if(istype(I, /obj/item/weapon/weldingtool)) + var/obj/item/weapon/weldingtool/WT = I + if(!WT.isOn()) + return + if(WT.get_fuel() < 5) //uses up 5 fuel. + user << "You need more fuel to complete this task!" + return + + playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) + user << "You start to remove the turret's interior metal armor..." + if(do_after(user, 20/I.toolspeed, target = src)) + if(!src || !WT.remove_fuel(5, user)) return + build_step = PTURRET_BOLTED + user << "You remove the turret's interior metal armor." + new /obj/item/stack/sheet/metal( loc, 2) + return + + + if(PTURRET_INTERNAL_ARMOUR_ON) + if(istype(I, /obj/item/weapon/gun/energy)) //the gun installation part + + if(isrobot(user)) + return + var/obj/item/weapon/gun/energy/E = I //typecasts the item to an energy gun + if(!user.unEquip(I)) + user << "\the [I] is stuck to your hand, you cannot put it in \the [src]!" + return + installation = I.type //installation becomes I.type + gun_charge = E.power_supply.charge //the gun's charge is stored in gun_charge + user << "You add [I] to the turret." + build_step = PTURRET_GUN_EQUIPPED + qdel(I) //delete the gun :( + return + + else if(istype(I, /obj/item/weapon/wrench)) + playsound(loc, 'sound/items/Ratchet.ogg', 100, 1) + user << "You remove the turret's metal armor bolts." + build_step = PTURRET_START_INTERNAL_ARMOUR + return + + if(PTURRET_GUN_EQUIPPED) + if(isprox(I)) + build_step = PTURRET_SENSORS_ON + if(!user.unEquip(I)) + user << "\the [I] is stuck to your hand, you cannot put it in \the [src]!" + return + user << "You add the proximity sensor to the turret." + qdel(I) + return + + + if(PTURRET_SENSORS_ON) + if(istype(I, /obj/item/weapon/screwdriver)) + playsound(loc, 'sound/items/Screwdriver.ogg', 100, 1) + build_step = PTURRET_CLOSED + user << "You close the internal access hatch." + return + + + if(PTURRET_CLOSED) + if(istype(I, /obj/item/stack/sheet/metal)) + var/obj/item/stack/sheet/metal/M = I + if(M.use(2)) + user << "You add some metal armor to the exterior frame." + build_step = PTURRET_START_EXTERNAL_ARMOUR + else + user << "You need two sheets of metal to continue construction!" + return + + else if(istype(I, /obj/item/weapon/screwdriver)) + playsound(loc, 'sound/items/Screwdriver.ogg', 100, 1) + build_step = PTURRET_SENSORS_ON + user << "You open the internal access hatch." + return + + if(PTURRET_START_EXTERNAL_ARMOUR) + if(istype(I, /obj/item/weapon/weldingtool)) + var/obj/item/weapon/weldingtool/WT = I + if(!WT.isOn()) return + if(WT.get_fuel() < 5) + user << "You need more fuel to complete this task!" + + playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) + user << "You begin to weld the turret's armor down..." + if(do_after(user, 30/I.toolspeed, target = src)) + if(!src || !WT.remove_fuel(5, user)) + return + build_step = PTURRET_EXTERNAL_ARMOUR_ON + user << "You weld the turret's armor down." + + //The final step: create a full turret + var/obj/machinery/porta_turret/Turret = new/obj/machinery/porta_turret(loc) + Turret.name = finish_name + Turret.installation = installation + Turret.gun_charge = gun_charge + Turret.setup() + + qdel(src) + + else if(istype(I, /obj/item/weapon/crowbar)) + playsound(loc, 'sound/items/Crowbar.ogg', 75, 1) + user << "You pry off the turret's exterior armor." + new /obj/item/stack/sheet/metal(loc, 2) + build_step = PTURRET_CLOSED + return + + if(istype(I, /obj/item/weapon/pen)) //you can rename turrets like bots! + var/t = stripped_input(user, "Enter new turret name", name, finish_name) + if(!t) + return + if(!in_range(src, usr) && loc != usr) + return + + finish_name = t + return + ..() + + +/obj/machinery/porta_turret_construct/attack_hand(mob/user) + switch(build_step) + if(PTURRET_GUN_EQUIPPED) + build_step = PTURRET_INTERNAL_ARMOUR_ON + + var/obj/item/weapon/gun/energy/Gun = new installation(loc) + Gun.power_supply.charge = gun_charge + Gun.update_icon() + installation = null + gun_charge = 0 + user << "You remove [Gun] from the turret frame." + + if(PTURRET_SENSORS_ON) + user << "You remove the prox sensor from the turret frame." + new /obj/item/device/assembly/prox_sensor(loc) + build_step = PTURRET_GUN_EQUIPPED + +/obj/machinery/porta_turret_construct/attack_ai() + return diff --git a/code/game/machinery/porta_turret/portable_turret_cover.dm b/code/game/machinery/porta_turret/portable_turret_cover.dm new file mode 100644 index 00000000000..da25c30f983 --- /dev/null +++ b/code/game/machinery/porta_turret/portable_turret_cover.dm @@ -0,0 +1,86 @@ + +/************************ +* PORTABLE TURRET COVER * +************************/ + +/obj/machinery/porta_turret_cover + name = "turret" + icon = 'icons/obj/turrets.dmi' + icon_state = "turretCover" + anchored = 1 + layer = 3.5 + density = 0 + var/obj/machinery/porta_turret/Parent_Turret = null + + +//The below code is pretty much just recoded from the initial turret object. It's necessary but uncommented because it's exactly the same! +//>necessary +//I'm not fixing it because i'm fucking bored of this code already, but someone should just reroute these to the parent turret's procs. + +/obj/machinery/porta_turret_cover/attack_ai(mob/user) + . = ..() + if(.) + return + + return Parent_Turret.attack_ai(user) + + +/obj/machinery/porta_turret_cover/attack_hand(mob/user) + . = ..() + if(.) + return + + return Parent_Turret.attack_hand(user) + + +/obj/machinery/porta_turret_cover/attackby(obj/item/I, mob/user, params) + if(istype(I, /obj/item/weapon/wrench) && !Parent_Turret.on) + if(Parent_Turret.raised) return + + if(!Parent_Turret.anchored) + Parent_Turret.anchored = 1 + Parent_Turret.invisibility = INVISIBILITY_OBSERVER + Parent_Turret.icon_state = "grey_target_prism" + user << "You secure the exterior bolts on the turret." + else + Parent_Turret.anchored = 0 + user << "You unsecure the exterior bolts on the turret." + Parent_Turret.icon_state = "turretCover" + Parent_Turret.invisibility = 0 + qdel(src) + + else if(istype(I, /obj/item/weapon/card/id)||istype(I, /obj/item/device/pda)) + if(Parent_Turret.allowed(user)) + Parent_Turret.locked = !Parent_Turret.locked + user << "Controls are now [Parent_Turret.locked ? "locked" : "unlocked"]." + updateUsrDialog() + else + user << "Access denied." + else if(istype(I,/obj/item/device/multitool) && !Parent_Turret.locked) + var/obj/item/device/multitool/M = I + M.buffer = Parent_Turret + user << "You add [Parent_Turret] to multitool buffer." + else + user.changeNext_move(CLICK_CD_MELEE) + Parent_Turret.health -= I.force * 0.5 + if(Parent_Turret.health <= 0) + Parent_Turret.die() + if(I.force * 0.5 > 2) + if(!Parent_Turret.attacked && !Parent_Turret.emagged) + Parent_Turret.attacked = 1 + spawn() + sleep(30) + Parent_Turret.attacked = 0 + ..() + +/obj/machinery/porta_turret_cover/can_be_overridden() + . = 0 + +/obj/machinery/porta_turret_cover/emag_act(mob/user) + if(!Parent_Turret.emagged) + user << "You short out [Parent_Turret]'s threat assessment circuits." + visible_message("[Parent_Turret] hums oddly...") + Parent_Turret.emagged = 1 + Parent_Turret.on = 0 + sleep(40) + Parent_Turret.on = 1 diff --git a/tgstation.dme b/tgstation.dme index 2fb7c791662..d4cf4bd45cd 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -374,7 +374,9 @@ #include "code\game\machinery\newscaster.dm" #include "code\game\machinery\overview.dm" #include "code\game\machinery\PDApainter.dm" -#include "code\game\machinery\portable_turret.dm" +#include "code\game\machinery\porta_turret\portable_turret.dm" +#include "code\game\machinery\porta_turret\portable_turret_cover.dm" +#include "code\game\machinery\porta_turret\portable_turret_construct.dm" #include "code\game\machinery\recharger.dm" #include "code\game\machinery\rechargestation.dm" #include "code\game\machinery\recycler.dm" From 913d46f32d587d2e497f81e22d494856bbb4f547 Mon Sep 17 00:00:00 2001 From: oranges Date: Sun, 14 Feb 2016 08:06:48 +0000 Subject: [PATCH 2/3] Remove old workaround check This looks to be a check from before nodrop functionality to prevent robots using their gun on the turret --- .../machinery/porta_turret/portable_turret_construct.dm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/code/game/machinery/porta_turret/portable_turret_construct.dm b/code/game/machinery/porta_turret/portable_turret_construct.dm index f80f3fbb017..1685c1202fd 100644 --- a/code/game/machinery/porta_turret/portable_turret_construct.dm +++ b/code/game/machinery/porta_turret/portable_turret_construct.dm @@ -82,18 +82,15 @@ if(PTURRET_INTERNAL_ARMOUR_ON) if(istype(I, /obj/item/weapon/gun/energy)) //the gun installation part - - if(isrobot(user)) - return - var/obj/item/weapon/gun/energy/E = I //typecasts the item to an energy gun + var/obj/item/weapon/gun/energy/E = I if(!user.unEquip(I)) user << "\the [I] is stuck to your hand, you cannot put it in \the [src]!" return - installation = I.type //installation becomes I.type + installation = I.type gun_charge = E.power_supply.charge //the gun's charge is stored in gun_charge user << "You add [I] to the turret." build_step = PTURRET_GUN_EQUIPPED - qdel(I) //delete the gun :( + qdel(I) return else if(istype(I, /obj/item/weapon/wrench)) From f2d4a60c748c6a8808086bd74be9a57f01c20d61 Mon Sep 17 00:00:00 2001 From: oranges Date: Mon, 15 Feb 2016 22:55:31 +1300 Subject: [PATCH 3/3] Fix a lot of issues as pointed out by review Update the defines to be the correct syntax --- .../machinery/porta_turret/portable_turret.dm | 6 +- .../porta_turret/portable_turret_construct.dm | 48 +++++++-------- .../porta_turret/portable_turret_cover.dm | 61 ++++++++++--------- 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 688ecdeeeb3..768f3cb6792 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -71,7 +71,7 @@ if(has_cover) cover = new /obj/machinery/porta_turret_cover(loc) - cover.Parent_Turret = src + cover.parent_turret = src setup() if(!has_cover) popUp() @@ -293,7 +293,7 @@ user << "You secure the exterior bolts on the turret." 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 + cover.parent_turret = src //make the cover's parent src else if(anchored) anchored = 0 user << "You unsecure the exterior bolts on the turret." @@ -445,7 +445,7 @@ 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.parent_turret = src //assign the cover its parent_turret, which would be this (src) if(stat & (NOPOWER|BROKEN)) if(!always_up) diff --git a/code/game/machinery/porta_turret/portable_turret_construct.dm b/code/game/machinery/porta_turret/portable_turret_construct.dm index 1685c1202fd..9cc8e06148e 100644 --- a/code/game/machinery/porta_turret/portable_turret_construct.dm +++ b/code/game/machinery/porta_turret/portable_turret_construct.dm @@ -1,19 +1,19 @@ -#define PTURRET_UNSECURED = 0 -#define PTURRET_BOLTED = 1 -#define PTURRET_START_INTERNAL_ARMOUR = 2 -#define PTURRET_INTERNAL_ARMOUR_ON = 3 -#define PTURRET_GUN_EQUIPPED = 4 -#define PTURRET_SENSORS_ON = 5 -#define PTURRET_CLOSED = 6 -#define PTURRET_START_EXTERNAL_ARMOUR = 7 -#define PTURRET_EXTERNAL_ARMOUR_ON = 8 +#define PTURRET_UNSECURED 0 +#define PTURRET_BOLTED 1 +#define PTURRET_START_INTERNAL_ARMOUR 2 +#define PTURRET_INTERNAL_ARMOUR_ON 3 +#define PTURRET_GUN_EQUIPPED 4 +#define PTURRET_SENSORS_ON 5 +#define PTURRET_CLOSED 6 +#define PTURRET_START_EXTERNAL_ARMOUR 7 +#define PTURRET_EXTERNAL_ARMOUR_ON 8 /obj/machinery/porta_turret_construct name = "turret frame" icon = 'icons/obj/turrets.dmi' icon_state = "turret_frame" - density=1 + density = 1 var/build_step = PTURRET_UNSECURED //the current step in the building process - var/finish_name="turret" //the name applied to the product turret + var/finish_name = "turret" //the name applied to the product turret var/installation = null //the gun type installed var/gun_charge = 0 //the gun charge of the gun type installed @@ -73,7 +73,8 @@ playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) user << "You start to remove the turret's interior metal armor..." if(do_after(user, 20/I.toolspeed, target = src)) - if(!src || !WT.remove_fuel(5, user)) return + if(!WT.isOn() || !WT.remove_fuel(5, user)) + return build_step = PTURRET_BOLTED user << "You remove the turret's interior metal armor." new /obj/item/stack/sheet/metal( loc, 2) @@ -83,8 +84,7 @@ if(PTURRET_INTERNAL_ARMOUR_ON) if(istype(I, /obj/item/weapon/gun/energy)) //the gun installation part var/obj/item/weapon/gun/energy/E = I - if(!user.unEquip(I)) - user << "\the [I] is stuck to your hand, you cannot put it in \the [src]!" + if(!user.drop_item()) return installation = I.type gun_charge = E.power_supply.charge //the gun's charge is stored in gun_charge @@ -102,8 +102,7 @@ if(PTURRET_GUN_EQUIPPED) if(isprox(I)) build_step = PTURRET_SENSORS_ON - if(!user.unEquip(I)) - user << "\the [I] is stuck to your hand, you cannot put it in \the [src]!" + if(!user.drop_item()) return user << "You add the proximity sensor to the turret." qdel(I) @@ -137,24 +136,25 @@ if(PTURRET_START_EXTERNAL_ARMOUR) if(istype(I, /obj/item/weapon/weldingtool)) var/obj/item/weapon/weldingtool/WT = I - if(!WT.isOn()) return + if(!WT.isOn()) + return if(WT.get_fuel() < 5) user << "You need more fuel to complete this task!" playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) user << "You begin to weld the turret's armor down..." if(do_after(user, 30/I.toolspeed, target = src)) - if(!src || !WT.remove_fuel(5, user)) + if(!WT.isOn() || !WT.remove_fuel(5, user)) return build_step = PTURRET_EXTERNAL_ARMOUR_ON user << "You weld the turret's armor down." //The final step: create a full turret - var/obj/machinery/porta_turret/Turret = new/obj/machinery/porta_turret(loc) - Turret.name = finish_name - Turret.installation = installation - Turret.gun_charge = gun_charge - Turret.setup() + var/obj/machinery/porta_turret/turret = new/obj/machinery/porta_turret(loc) + turret.name = finish_name + turret.installation = installation + turret.gun_charge = gun_charge + turret.setup() qdel(src) @@ -169,7 +169,7 @@ var/t = stripped_input(user, "Enter new turret name", name, finish_name) if(!t) return - if(!in_range(src, usr) && loc != usr) + if(!Adjacent(user)) return finish_name = t diff --git a/code/game/machinery/porta_turret/portable_turret_cover.dm b/code/game/machinery/porta_turret/portable_turret_cover.dm index da25c30f983..d96b9dce955 100644 --- a/code/game/machinery/porta_turret/portable_turret_cover.dm +++ b/code/game/machinery/porta_turret/portable_turret_cover.dm @@ -10,7 +10,7 @@ anchored = 1 layer = 3.5 density = 0 - var/obj/machinery/porta_turret/Parent_Turret = null + var/obj/machinery/porta_turret/parent_turret = null //The below code is pretty much just recoded from the initial turret object. It's necessary but uncommented because it's exactly the same! @@ -22,7 +22,7 @@ if(.) return - return Parent_Turret.attack_ai(user) + return parent_turret.attack_ai(user) /obj/machinery/porta_turret_cover/attack_hand(mob/user) @@ -30,57 +30,58 @@ if(.) return - return Parent_Turret.attack_hand(user) + return parent_turret.attack_hand(user) /obj/machinery/porta_turret_cover/attackby(obj/item/I, mob/user, params) - if(istype(I, /obj/item/weapon/wrench) && !Parent_Turret.on) - if(Parent_Turret.raised) return + if(istype(I, /obj/item/weapon/wrench) && !parent_turret.on) + if(parent_turret.raised) + return - if(!Parent_Turret.anchored) - Parent_Turret.anchored = 1 - Parent_Turret.invisibility = INVISIBILITY_OBSERVER - Parent_Turret.icon_state = "grey_target_prism" + if(!parent_turret.anchored) + parent_turret.anchored = 1 + parent_turret.invisibility = INVISIBILITY_OBSERVER + parent_turret.icon_state = "grey_target_prism" user << "You secure the exterior bolts on the turret." else - Parent_Turret.anchored = 0 + parent_turret.anchored = 0 user << "You unsecure the exterior bolts on the turret." - Parent_Turret.icon_state = "turretCover" - Parent_Turret.invisibility = 0 + parent_turret.icon_state = "turretCover" + parent_turret.invisibility = 0 qdel(src) else if(istype(I, /obj/item/weapon/card/id)||istype(I, /obj/item/device/pda)) - if(Parent_Turret.allowed(user)) - Parent_Turret.locked = !Parent_Turret.locked - user << "Controls are now [Parent_Turret.locked ? "locked" : "unlocked"]." + if(parent_turret.allowed(user)) + parent_turret.locked = !parent_turret.locked + user << "Controls are now [parent_turret.locked ? "locked" : "unlocked"]." updateUsrDialog() else user << "Access denied." - else if(istype(I,/obj/item/device/multitool) && !Parent_Turret.locked) + else if(istype(I,/obj/item/device/multitool) && !parent_turret.locked) var/obj/item/device/multitool/M = I - M.buffer = Parent_Turret - user << "You add [Parent_Turret] to multitool buffer." + M.buffer = parent_turret + user << "You add [parent_turret] to multitool buffer." else user.changeNext_move(CLICK_CD_MELEE) - Parent_Turret.health -= I.force * 0.5 - if(Parent_Turret.health <= 0) - Parent_Turret.die() + parent_turret.health -= I.force * 0.5 + if(parent_turret.health <= 0) + parent_turret.die() if(I.force * 0.5 > 2) - if(!Parent_Turret.attacked && !Parent_Turret.emagged) - Parent_Turret.attacked = 1 + if(!parent_turret.attacked && !parent_turret.emagged) + parent_turret.attacked = 1 spawn() sleep(30) - Parent_Turret.attacked = 0 + parent_turret.attacked = 0 ..() /obj/machinery/porta_turret_cover/can_be_overridden() . = 0 /obj/machinery/porta_turret_cover/emag_act(mob/user) - if(!Parent_Turret.emagged) - user << "You short out [Parent_Turret]'s threat assessment circuits." - visible_message("[Parent_Turret] hums oddly...") - Parent_Turret.emagged = 1 - Parent_Turret.on = 0 + if(!parent_turret.emagged) + user << "You short out [parent_turret]'s threat assessment circuits." + visible_message("[parent_turret] hums oddly...") + parent_turret.emagged = 1 + parent_turret.on = 0 sleep(40) - Parent_Turret.on = 1 + parent_turret.on = 1