From 505f857eb82a8cb37ce5934696503dca3533d1ba Mon Sep 17 00:00:00 2001 From: Kelenius Date: Tue, 2 Sep 2014 09:59:32 +0400 Subject: [PATCH] Stack update --- code/TriDimension/Turfs.dm | 16 ++--- .../research_to_ripleys_directive.dm | 2 +- code/game/gamemodes/newobjective.dm | 18 +++-- code/game/gamemodes/objective.dm | 6 +- code/game/machinery/alarm.dm | 41 +++++------ code/game/machinery/autolathe.dm | 2 +- code/game/machinery/bots/ed209bot.dm | 22 +++--- code/game/machinery/bots/floorbot.dm | 25 ++++--- code/game/machinery/camera/camera_assembly.dm | 4 +- code/game/machinery/computer/ai_core.dm | 36 ++++++---- .../game/machinery/computer/buildandrepair.dm | 39 +++++----- code/game/machinery/constructable_frame.dm | 22 +++--- code/game/machinery/deployable.dm | 18 ++--- code/game/machinery/kitchen/microwave.dm | 5 +- code/game/machinery/portable_turret.dm | 24 +++---- code/game/machinery/robot_fabricator.dm | 12 ++-- code/game/machinery/seed_extractor.dm | 6 +- .../telecomms/machine_interactions.dm | 18 +++-- code/game/mecha/mecha.dm | 3 +- code/game/mecha/mecha_construction_paths.dm | 18 +++-- .../objects/items/devices/lightreplacer.dm | 23 +++--- code/game/objects/items/robot/robot_parts.dm | 19 ++--- .../game/objects/items/stacks/sheets/glass.dm | 34 +++++---- .../game/objects/items/stacks/sheets/light.dm | 16 ++--- code/game/objects/items/stacks/stack.dm | 14 ++-- code/game/objects/items/weapons/handcuffs.dm | 12 ++-- .../objects/items/weapons/table_rack_parts.dm | 12 ++-- .../structures/crates_lockers/crates.dm | 10 +-- code/game/objects/structures/door_assembly.dm | 36 +++++----- code/game/objects/structures/girders.dm | 71 +++++++++---------- code/game/objects/structures/grille.dm | 29 ++++---- .../objects/structures/windoor_assembly.dm | 41 +++++------ code/game/supplyshuttle.dm | 4 +- code/game/turfs/simulated/floor.dm | 55 +++++++------- code/game/turfs/space/space.dm | 16 ++--- code/modules/clothing/gloves/stungloves.dm | 2 +- code/modules/clothing/spacesuits/breaches.dm | 6 +- code/modules/mining/coins.dm | 23 +++--- code/modules/mining/mint.dm | 12 ++-- .../modules/mob/living/silicon/robot/robot.dm | 10 +-- .../mob/living/simple_animal/simple_animal.dm | 6 +- code/modules/mob/living/simple_animal/worm.dm | 2 +- code/modules/power/apc.dm | 32 ++++----- code/modules/power/lighting.dm | 18 ++--- code/modules/power/smes.dm | 2 +- code/modules/power/solar.dm | 5 +- .../projectiles/guns/projectile/crossbow.dm | 26 +++---- .../projectiles/guns/projectile/pneumatic.dm | 3 +- .../reagent_containers/food/snacks/grown.dm | 5 +- code/modules/research/protolathe.dm | 4 +- code/modules/research/rdconsole.dm | 4 +- .../machinery/geosample_scanner.dm | 2 +- code/modules/shieldgen/emergency_shield.dm | 13 ++-- 53 files changed, 447 insertions(+), 457 deletions(-) diff --git a/code/TriDimension/Turfs.dm b/code/TriDimension/Turfs.dm index adc51d2fa8e..b68884a6349 100644 --- a/code/TriDimension/Turfs.dm +++ b/code/TriDimension/Turfs.dm @@ -102,20 +102,20 @@ if(L) return var/obj/item/stack/rods/R = C - user << "\blue Constructing support lattice ..." - playsound(src.loc, 'sound/weapons/Genhit.ogg', 50, 1) - ReplaceWithLattice() - R.use(1) + if (R.use(1)) + user << "\blue Constructing support lattice ..." + playsound(src.loc, 'sound/weapons/Genhit.ogg', 50, 1) + ReplaceWithLattice() return if (istype(C, /obj/item/stack/tile/plasteel)) var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) if(L) var/obj/item/stack/tile/plasteel/S = C - del(L) - playsound(src.loc, 'sound/weapons/Genhit.ogg', 50, 1) - S.build(src) - S.use(1) + if (S.use(1)) + del(L) + playsound(src.loc, 'sound/weapons/Genhit.ogg', 50, 1) + S.build(src) return else user << "\red The plating is going to need some support." diff --git a/code/game/gamemodes/mutiny/directives/research_to_ripleys_directive.dm b/code/game/gamemodes/mutiny/directives/research_to_ripleys_directive.dm index 1f252d3df57..f3a463e6f9c 100644 --- a/code/game/gamemodes/mutiny/directives/research_to_ripleys_directive.dm +++ b/code/game/gamemodes/mutiny/directives/research_to_ripleys_directive.dm @@ -74,6 +74,6 @@ datum/directive/research_to_ripleys/get_remaining_orders() for(var/atom/A in sold) if(istype(A, /obj/item/stack/sheet/mineral) || istype(A, /obj/item/stack/sheet/metal)) var/obj/item/stack/S = A - D.materials_shipped += S.amount + D.materials_shipped += S.get_amount() return 1 diff --git a/code/game/gamemodes/newobjective.dm b/code/game/gamemodes/newobjective.dm index e58801a329d..70901add189 100644 --- a/code/game/gamemodes/newobjective.dm +++ b/code/game/gamemodes/newobjective.dm @@ -928,8 +928,10 @@ datum var/target_amount = 10 var/found_amount = 0.0//Always starts as zero. for(var/obj/item/I in owner.current.get_contents()) - if(!istype(I, steal_target)) continue//If it's not actually that item. - found_amount += I:amount + if(!istype(I, steal_target)) + continue//If it's not actually that item. + var/obj/item/stack/sheet/diamond/D = I + found_amount += D.get_amount() return found_amount>=target_amount gold @@ -957,8 +959,10 @@ datum var/target_amount = 50 var/found_amount = 0.0//Always starts as zero. for(var/obj/item/I in owner.current.get_contents()) - if(!istype(I, steal_target)) continue//If it's not actually that item. - found_amount += I:amount + if(!istype(I, steal_target)) + continue//If it's not actually that item. + var/obj/item/stack/sheet/gold/G = I + found_amount += G.get_amount() return found_amount>=target_amount uranium @@ -986,8 +990,10 @@ datum var/target_amount = 25 var/found_amount = 0.0//Always starts as zero. for(var/obj/item/I in owner.current.get_contents()) - if(!istype(I, steal_target)) continue//If it's not actually that item. - found_amount += I:amount + if(!istype(I, steal_target)) + continue//If it's not actually that item. + var/obj/item/stack/sheet/uranium/U = I + found_amount += U.get_amount() return found_amount>=target_amount diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index 82619c2796f..9ff5608e2df 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -894,12 +894,12 @@ datum/objective/heist/salvage if(istype(O,/obj/item/stack/sheet)) if(O.name == target) S = O - total_amount += S.amount + total_amount += S.get_amount() for(var/obj/I in O.contents) if(istype(I,/obj/item/stack/sheet)) if(I.name == target) S = I - total_amount += S.amount + total_amount += S.get_amount() var/datum/game_mode/heist/H = ticker.mode for(var/datum/mind/raider in H.raiders) @@ -908,7 +908,7 @@ datum/objective/heist/salvage if(istype(O,/obj/item/stack/sheet)) if(O.name == target) var/obj/item/stack/sheet/S = O - total_amount += S.amount + total_amount += S.get_amount() if(total_amount >= target_amount) return 1 return 0 diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm index c3ef78a1492..874d66560a1 100644 --- a/code/game/machinery/alarm.dm +++ b/code/game/machinery/alarm.dm @@ -1125,20 +1125,16 @@ table tr:first-child th:first-child { border: none;} if(1) if(istype(W, /obj/item/stack/cable_coil)) - var/obj/item/stack/cable_coil/coil = W - if(coil.amount < 5) - user << "You need more cable for this!" + var/obj/item/stack/cable_coil/C = W + if (C.use(5)) + user << "You wire \the [src]." + buildstage = 2 + update_icon() + first_run() + return + else + user << "You need 5 pieces of cable to do wire \the [src]." return - - user << "You wire \the [src]!" - coil.amount -= 5 - if(!coil.amount) - del(coil) - - buildstage = 2 - update_icon() - first_run() - return else if(istype(W, /obj/item/weapon/crowbar)) user << "You start prying out the circuit." @@ -1316,19 +1312,14 @@ FIRE ALARM user.visible_message("\red [user] has disconnected [src]'s detecting unit!", "You have disconnected [src]'s detecting unit.") if(1) if(istype(W, /obj/item/stack/cable_coil)) - var/obj/item/stack/cable_coil/coil = W - if(coil.amount < 5) - user << "You need more cable for this!" + var/obj/item/stack/cable_coil/C = W + if (C.use(5)) + user << "You wire \the [src]." + buildstage = 2 + return + else + user << "You need 5 pieces of cable to do wire \the [src]." return - - coil.amount -= 5 - if(!coil.amount) - del(coil) - - buildstage = 2 - user << "You wire \the [src]!" - update_icon() - else if(istype(W, /obj/item/weapon/crowbar)) user << "You pry out the circuit!" playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 5df804d84b4..c24d07a2eda 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -152,7 +152,7 @@ //If it's a stack, we eat multiple sheets. if(istype(eating,/obj/item/stack)) var/obj/item/stack/stack = eating - total_material *= stack.amount + total_material *= stack.get_amount() if(stored_material[material] + total_material > storage_capacity[material]) total_material = storage_capacity[material] - stored_material[material] diff --git a/code/game/machinery/bots/ed209bot.dm b/code/game/machinery/bots/ed209bot.dm index ec02d10e808..9b0e5339796 100644 --- a/code/game/machinery/bots/ed209bot.dm +++ b/code/game/machinery/bots/ed209bot.dm @@ -959,16 +959,18 @@ Auto Patrol: []"}, icon_state = "[lasercolor]ed209_prox" if(6) - if( istype(W, /obj/item/stack/cable_coil) ) - var/obj/item/stack/cable_coil/coil = W - var/turf/T = get_turf(user) - user << "You start to wire [src]..." - sleep(40) - if(get_turf(user) == T && build_step == 6) - coil.use(1) - build_step++ - user << "You wire the ED-209 assembly." - name = "wired ED-209 assembly" + if(istype(W, /obj/item/stack/cable_coil)) + var/obj/item/stack/cable_coil/C = W + if (C.get_amount() < 1) + user << "You need one coil of wire to do wire [src]." + return + user << "You start to wire [src]." + if (do_after(user, 40) && build_step == 6) + if (C.use(1)) + build_step++ + user << "You wire the ED-209 assembly." + name = "wired ED-209 assembly" + return if(7) switch(lasercolor) diff --git a/code/game/machinery/bots/floorbot.dm b/code/game/machinery/bots/floorbot.dm index 69fc5afd3f3..0691a74e541 100644 --- a/code/game/machinery/bots/floorbot.dm +++ b/code/game/machinery/bots/floorbot.dm @@ -103,7 +103,7 @@ var/obj/item/stack/tile/plasteel/T = W if(src.amount >= 50) return - var/loaded = min(50-src.amount, T.amount) + var/loaded = min(50-src.amount, T.get_amount()) T.use(loaded) src.amount += loaded user << "You load [loaded] tiles into the floorbot. He now contains [src.amount] tiles." @@ -325,12 +325,12 @@ src.target = null src.repairing = 0 return - if(src.amount + T.amount > 50) + if(src.amount + T.get_amount() > 50) var/i = 50 - src.amount src.amount += i - T.amount -= i + T.use(i) else - src.amount += T.amount + src.amount += T.get_amount() del(T) src.updateicon() src.target = null @@ -339,7 +339,7 @@ /obj/machinery/bot/floorbot/proc/maketile(var/obj/item/stack/sheet/metal/M) if(!istype(M, /obj/item/stack/sheet/metal)) return - if(M.amount > 1) + if(M.get_amount() > 1) return visible_message("\red [src] begins to create tiles.") src.repairing = 1 @@ -400,12 +400,15 @@ return if(user.s_active) user.s_active.close(user) - del(T) - var/obj/item/weapon/toolbox_tiles/B = new /obj/item/weapon/toolbox_tiles - user.put_in_hands(B) - user << "You add the tiles into the empty toolbox. They protrude from the top." - user.drop_from_inventory(src) - del(src) + if (T.use(10)) + var/obj/item/weapon/toolbox_tiles/B = new /obj/item/weapon/toolbox_tiles + user.put_in_hands(B) + user << "You add the tiles into the empty toolbox. They protrude from the top." + user.drop_from_inventory(src) + del(src) + else + user << "You need 10 floortiles for a floorbot." + return /obj/item/weapon/toolbox_tiles/attackby(var/obj/item/W, mob/user as mob) ..() diff --git a/code/game/machinery/camera/camera_assembly.dm b/code/game/machinery/camera/camera_assembly.dm index 6b5249c6931..097c4f9a27e 100644 --- a/code/game/machinery/camera/camera_assembly.dm +++ b/code/game/machinery/camera/camera_assembly.dm @@ -58,8 +58,10 @@ if(iscoil(W)) var/obj/item/stack/cable_coil/C = W if(C.use(2)) - user << "You add wires to the assembly." + user << "You add wires to the assembly." state = 3 + else + user << "You need 2 coils of wire to wire the assembly." return else if(iswelder(W)) diff --git a/code/game/machinery/computer/ai_core.dm b/code/game/machinery/computer/ai_core.dm index 5351b08d77a..5e3c29996f1 100644 --- a/code/game/machinery/computer/ai_core.dm +++ b/code/game/machinery/computer/ai_core.dm @@ -63,14 +63,18 @@ state = 1 icon_state = "1" if(istype(P, /obj/item/stack/cable_coil)) - if(P:amount >= 5) - playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) - if(do_after(user, 20)) - P:amount -= 5 - if(!P:amount) del(P) - user << "\blue You add cables to the frame." + var/obj/item/stack/cable_coil/C = P + if (C.get_amount() < 5) + user << "You need five coils of wire to add them to the frame." + return + user << "You start to add cables to the frame." + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + if (do_after(user, 20) && state == 2) + if (C.use(5)) state = 3 icon_state = "3" + user << "You add cables to the frame." + return if(3) if(istype(P, /obj/item/weapon/wirecutters)) if (brain) @@ -84,15 +88,17 @@ A.amount = 5 if(istype(P, /obj/item/stack/sheet/rglass)) - if(P:amount >= 2) - playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) - if(do_after(user, 20)) - if (P) - P:amount -= 2 - if(!P:amount) del(P) - user << "\blue You put in the glass panel." - state = 4 - icon_state = "4" + var/obj/item/stack/sheet/rglass/RG = P + if (RG.get_amount() < 2) + user << "You need two sheets of glass to put in the glass panel." + return + user << "You start to put in the glass panel." + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + if (do_after(user, 20) && state == 3) + if(RG.use(2)) + user << "You put in the glass panel." + state = 4 + icon_state = "4" if(istype(P, /obj/item/weapon/aiModule/asimov)) laws.add_inherent_law("You may not injure a human being or, through inaction, allow a human being to come to harm.") diff --git a/code/game/machinery/computer/buildandrepair.dm b/code/game/machinery/computer/buildandrepair.dm index 8dc84807b8e..50eb026b933 100644 --- a/code/game/machinery/computer/buildandrepair.dm +++ b/code/game/machinery/computer/buildandrepair.dm @@ -403,15 +403,17 @@ src.state = 1 src.icon_state = "1" if(istype(P, /obj/item/stack/cable_coil)) - if(P:amount >= 5) - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) - if(do_after(user, 20)) - if(P) - P:amount -= 5 - if(!P:amount) del(P) - user << "\blue You add cables to the frame." - src.state = 3 - src.icon_state = "3" + var/obj/item/stack/cable_coil/C = P + if (C.get_amount() < 5) + user << "You need five coils of wire to add them to the frame." + return + user << "You start to add cables to the frame." + playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + if(do_after(user, 20) && state == 2) + if (C.use(5)) + user << "You add cables to the frame." + state = 3 + icon_state = "3" if(3) if(istype(P, /obj/item/weapon/wirecutters)) playsound(src.loc, 'sound/items/Wirecutter.ogg', 50, 1) @@ -422,14 +424,17 @@ A.amount = 5 if(istype(P, /obj/item/stack/sheet/glass)) - if(P:amount >= 2) - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) - if(do_after(user, 20)) - if(P) - P:use(2) - user << "\blue You put in the glass panel." - src.state = 4 - src.icon_state = "4" + var/obj/item/stack/sheet/glass/G = P + if (G.get_amount() < 2) + user << "You need two sheets of glass to put in the glass panel." + return + playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + user << "You start to put in the glass panel." + if(do_after(user, 20) && state == 3) + if (G.use(2)) + user << "You put in the glass panel." + src.state = 4 + src.icon_state = "4" if(4) if(istype(P, /obj/item/weapon/crowbar)) playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index d1440b05dd5..8a7060ac7ea 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -36,16 +36,16 @@ if(1) if(istype(P, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/C = P - if(C.amount >= 5) - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) - user << "\blue You start to add cables to the frame." - if(do_after(user, 20)) - if(C) - C.amount -= 5 - if(!C.amount) del(C) - user << "\blue You add cables to the frame." - state = 2 - icon_state = "box_1" + if (C.get_amount() < 5) + user << "You need five lengths of cable to add them to the frame." + return + playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + user << "You start to add cables to the frame." + if(do_after(user, 20) && state == 1) + if(C.use(5)) + user << "You add cables to the frame." + state = 2 + icon_state = "box_1" else if(istype(P, /obj/item/weapon/wrench)) playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1) @@ -134,7 +134,7 @@ playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) if(istype(P, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/CP = P - if(CP.amount > 1) + if(CP.get_amount() > 1) var/camt = min(CP.amount, req_components[I]) // amount of cable to take, idealy amount required, but limited by amount provided var/obj/item/stack/cable_coil/CC = new /obj/item/stack/cable_coil(src) CC.amount = camt diff --git a/code/game/machinery/deployable.dm b/code/game/machinery/deployable.dm index 42b23c5d7f7..d6eff496d08 100644 --- a/code/game/machinery/deployable.dm +++ b/code/game/machinery/deployable.dm @@ -67,15 +67,17 @@ for reference: attackby(obj/item/W as obj, mob/user as mob) if (istype(W, /obj/item/stack/sheet/wood)) - if (src.health < src.maxhealth) - visible_message("\red [user] begins to repair \the [src]!") - if(do_after(user,20)) - src.health = src.maxhealth - W:use(1) - visible_message("\red [user] repairs \the [src]!") + var/obj/item/stack/sheet/wood/D = W + if (health < maxhealth) + if (D.get_amount() < 1) + user << "You need one plank of wood to repair \the [src]." + return + visible_message("[user] begins to repair \the [src].") + if(do_after(user,20) && health < maxhealth) + if (D.use(1)) + health = maxhealth + visible_message("[user] repairs \the [src].") return - else - return return else switch(W.damtype) diff --git a/code/game/machinery/kitchen/microwave.dm b/code/game/machinery/kitchen/microwave.dm index 8113cf5985a..0ade94a93f5 100644 --- a/code/game/machinery/kitchen/microwave.dm +++ b/code/game/machinery/kitchen/microwave.dm @@ -104,9 +104,10 @@ if (contents.len>=max_n_of_items) user << "\red This [src] is full of ingredients, you cannot put more." return 1 - if (istype(O,/obj/item/stack) && O:amount>1) + if(istype(O, /obj/item/stack) && O:get_amount() > 1) // This is bad, but I can't think of how to change it + var/obj/item/stack/S = O new O.type (src) - O:use(1) + S.use(1) user.visible_message( \ "\blue [user] has added one of [O] to \the [src].", \ "\blue You add one of [O] to \the [src].") diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index b7a9a781d8e..dabdebb3806 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -707,14 +707,14 @@ Status: []
"}, if(1) if(istype(W, /obj/item/stack/sheet/metal)) - if(W:amount>=2) // requires 2 metal sheets - user << "\blue You add some metal armor to the interior frame." + var/obj/item/stack/sheet/metal/M = W + if (M.use(2)) + user << "You add some metal armor to the interior frame." build_step = 2 - W:amount -= 2 icon_state = "turret_frame2" - if(W:amount <= 0) - del(W) - return + else + user << "You need two sheets of metal to add armor ot the frame." + return else if(istype(W, /obj/item/weapon/wrench)) playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1) @@ -784,13 +784,13 @@ Status: []
"}, if(6) if(istype(W, /obj/item/stack/sheet/metal)) - if(W:amount>=2) - user << "\blue You add some metal armor to the exterior frame." + var/obj/item/stack/sheet/metal/M = W + if (M.use(2)) + user << "You add some metal armor to the exterior frame." build_step = 7 - W:amount -= 2 - if(W:amount <= 0) - del(W) - return + else + user << "You need two sheets of metal to add armor to the frame." + return else if(istype(W, /obj/item/weapon/screwdriver)) playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1) diff --git a/code/game/machinery/robot_fabricator.dm b/code/game/machinery/robot_fabricator.dm index bf02e31fdda..085f455deb1 100644 --- a/code/game/machinery/robot_fabricator.dm +++ b/code/game/machinery/robot_fabricator.dm @@ -13,21 +13,19 @@ /obj/machinery/robotic_fabricator/attackby(var/obj/item/O as obj, var/mob/user as mob) if (istype(O, /obj/item/stack/sheet/metal)) + var/obj/item/stack/sheet/metal/M = O if (src.metal_amount < 150000.0) var/count = 0 src.overlays += "fab-load-metal" spawn(15) - if(O) - if(!O:amount) + if(M) + if(!M.get_amount()) return - while(metal_amount < 150000 && O:amount) + while(metal_amount < 150000 && M.amount) src.metal_amount += O.matter["metal"] /*O:height * O:width * O:length * 100000.0*/ - O:amount-- + M.use(1) count++ - if (O:amount < 1) - del(O) - user << "You insert [count] metal sheet\s into the fabricator." src.overlays -= "fab-load-metal" updateDialog() diff --git a/code/game/machinery/seed_extractor.dm b/code/game/machinery/seed_extractor.dm index dbb5a9d2712..e850058df90 100644 --- a/code/game/machinery/seed_extractor.dm +++ b/code/game/machinery/seed_extractor.dm @@ -36,8 +36,8 @@ obj/machinery/seed_extractor/attackby(var/obj/item/O as obj, var/mob/user as mob //Grass. else if(istype(O, /obj/item/stack/tile/grass)) var/obj/item/stack/tile/grass/S = O - user << "You extract some seeds from the [S.name]." - S.use(1) - new /obj/item/seeds/grassseed(loc) + if (S.use(1)) + user << "You extract some seeds from the [S.name]." + new /obj/item/seeds/grassseed(loc) return \ No newline at end of file diff --git a/code/game/machinery/telecomms/machine_interactions.dm b/code/game/machinery/telecomms/machine_interactions.dm index 5a78c9bd4f5..581ae59ab48 100644 --- a/code/game/machinery/telecomms/machine_interactions.dm +++ b/code/game/machinery/telecomms/machine_interactions.dm @@ -26,9 +26,9 @@ if(istype(P, /obj/item/stack/nanopaste)) var/obj/item/stack/nanopaste/T = P if (integrity < 100) //Damaged, let's repair! - integrity = between(0, integrity + rand(10,20), 100) - T.use(1) - usr << "You apply the Nanopaste to [src], repairing some of the damage." + if (T.use(1)) + integrity = between(0, integrity + rand(10,20), 100) + usr << "You apply the Nanopaste to [src], repairing some of the damage." else usr << "This machine is already in perfect condition." return @@ -64,14 +64,12 @@ if(3) if(istype(P, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/A = P - if(A.amount >= 5) - user << "You insert the cables." - A.amount -= 5 - if(A.amount <= 0) - user.drop_item() - del(A) - construct_op -- + if (A.use(5)) + user << "You insert the cables." + construct_op-- stat &= ~BROKEN // the machine's not borked anymore! + else + user << "You need five coils of wire for this." if(istype(P, /obj/item/weapon/crowbar)) user << "You begin prying out the circuit board other components..." playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 0a1d40d652d..43592ae2cb9 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -700,8 +700,7 @@ else if(istype(W, /obj/item/stack/cable_coil)) if(state == 3 && hasInternalDamage(MECHA_INT_SHORT_CIRCUIT)) var/obj/item/stack/cable_coil/CC = W - if(CC.amount > 1) - CC.use(2) + if(CC.use(2)) clearInternalDamage(MECHA_INT_SHORT_CIRCUIT) user << "You replace the fused wires." else diff --git a/code/game/mecha/mecha_construction_paths.dm b/code/game/mecha/mecha_construction_paths.dm index bd1762db678..233415cba80 100644 --- a/code/game/mecha/mecha_construction_paths.dm +++ b/code/game/mecha/mecha_construction_paths.dm @@ -20,15 +20,14 @@ else if(istype(used_atom, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/C = used_atom - if(C.amount<4) + if(C.use(4)) + playsound(holder, 'sound/items/Deconstruct.ogg', 50, 1) + else user << ("There's not enough cable to finish the task.") return 0 - else - C.use(4) - playsound(holder, 'sound/items/Deconstruct.ogg', 50, 1) else if(istype(used_atom, /obj/item/stack)) var/obj/item/stack/S = used_atom - if(S.amount < 5) + if(S.get_amount() < 5) user << ("There's not enough material in this stack.") return 0 else @@ -53,15 +52,14 @@ else if(istype(used_atom, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/C = used_atom - if(C.amount<4) + if(C.use(4)) + playsound(holder, 'sound/items/Deconstruct.ogg', 50, 1) + else user << ("There's not enough cable to finish the task.") return 0 - else - C.use(4) - playsound(holder, 'sound/items/Deconstruct.ogg', 50, 1) else if(istype(used_atom, /obj/item/stack)) var/obj/item/stack/S = used_atom - if(S.amount < 5) + if(S.get_amount() < 5) user << ("There's not enough material in this stack.") return 0 else diff --git a/code/game/objects/items/devices/lightreplacer.dm b/code/game/objects/items/devices/lightreplacer.dm index 15dfc43a7db..628ed696e4a 100644 --- a/code/game/objects/items/devices/lightreplacer.dm +++ b/code/game/objects/items/devices/lightreplacer.dm @@ -55,10 +55,6 @@ var/uses = 0 var/emagged = 0 var/failmsg = "" - // How much to increase per each glass? - var/increment = 5 - // How much to take from the glass? - var/decrement = 1 var/charge = 1 /obj/item/device/lightreplacer/New() @@ -78,18 +74,15 @@ if(istype(W, /obj/item/stack/sheet/glass)) var/obj/item/stack/sheet/glass/G = W - if(G.amount - decrement >= 0 && uses < max_uses) - var/remaining = max(G.amount - decrement, 0) - if(!remaining && !(G.amount - decrement) == 0) - user << "There isn't enough glass." - return - G.amount = remaining - if(!G.amount) - user.drop_item() - del(G) - AddUses(increment) - user << "You insert a piece of glass into the [src.name]. You have [uses] lights remaining." + if(uses >= max_uses) + user << "[src.name] is full." return + else if(G.use(1)) + AddUses(5) + user << "You insert a piece of glass into the [src.name]. You have [uses] lights remaining." + return + else + user << "You need one sheet of glass to replace lights." if(istype(W, /obj/item/weapon/light)) var/obj/item/weapon/light/L = W diff --git a/code/game/objects/items/robot/robot_parts.dm b/code/game/objects/items/robot/robot_parts.dm index 83b0b299688..1c9bec63e98 100644 --- a/code/game/objects/items/robot/robot_parts.dm +++ b/code/game/objects/items/robot/robot_parts.dm @@ -104,14 +104,17 @@ /obj/item/robot_parts/robot_suit/attackby(obj/item/W as obj, mob/user as mob) ..() if(istype(W, /obj/item/stack/sheet/metal) && !l_arm && !r_arm && !l_leg && !r_leg && !chest && !head) - var/obj/item/weapon/ed209_assembly/B = new /obj/item/weapon/ed209_assembly - B.loc = get_turf(src) - user << "You armed the robot frame" - W:use(1) - if (user.get_inactive_hand()==src) - user.before_take_item(src) - user.put_in_inactive_hand(B) - del(src) + var/obj/item/stack/sheet/metal/M = W + if (M.use(1)) + var/obj/item/weapon/ed209_assembly/B = new /obj/item/weapon/ed209_assembly + B.loc = get_turf(src) + user << "You armed the robot frame." + if (user.get_inactive_hand()==src) + user.before_take_item(src) + user.put_in_inactive_hand(B) + del(src) + else + user << "You need one sheet of metal to arm the robot frame." if(istype(W, /obj/item/robot_parts/l_leg)) if(src.l_leg) return user.drop_item() diff --git a/code/game/objects/items/stacks/sheets/glass.dm b/code/game/objects/items/stacks/sheets/glass.dm index f784183bd8d..88a0decc2b3 100644 --- a/code/game/objects/items/stacks/sheets/glass.dm +++ b/code/game/objects/items/stacks/sheets/glass.dm @@ -34,25 +34,29 @@ ..() if(istype(W,/obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/CC = W - if(CC.amount < 5) - user << "\b There is not enough wire in this coil. You need 5 lengths." + if (get_amount() < 1 || CC.get_amount() < 5) + user << "You attach wire to the [name]." new /obj/item/stack/light_w(user.loc) - src.use(1) - else if( istype(W, /obj/item/stack/rods) ) + else if(istype(W, /obj/item/stack/rods)) var/obj/item/stack/rods/V = W - var/obj/item/stack/sheet/rglass/RG = new (user.loc) - RG.add_fingerprint(user) - RG.add_to_stacks(user) - V.use(1) - var/obj/item/stack/sheet/glass/G = src - src = null - var/replace = (user.get_inactive_hand()==G) - G.use(1) - if (!G && !RG && replace) - user.put_in_hands(RG) + if (V.get_amount() >= 1 && get_amount() >= 1) + var/obj/item/stack/sheet/rglass/RG = new (user.loc) + RG.add_fingerprint(user) + RG.add_to_stacks(user) + var/obj/item/stack/sheet/glass/G = src + src = null + var/replace = (user.get_inactive_hand()==G) + V.use(1) + G.use(1) + if (!G && replace) + user.put_in_hands(RG) + else + user << "You need one rod and one sheet of glass to make reinforced glass." + return else return ..() diff --git a/code/game/objects/items/stacks/sheets/light.dm b/code/game/objects/items/stacks/sheets/light.dm index 170f792e4d8..cf6bb1e7dcb 100644 --- a/code/game/objects/items/stacks/sheets/light.dm +++ b/code/game/objects/items/stacks/sheets/light.dm @@ -24,12 +24,10 @@ if(istype(O,/obj/item/stack/sheet/metal)) var/obj/item/stack/sheet/metal/M = O - M.amount-- - if(M.amount <= 0) - user.drop_from_inventory(M) - del(M) - amount-- - new/obj/item/stack/tile/light(user.loc) - if(amount <= 0) - user.drop_from_inventory(src) - del(src) + if (M.use(1)) + use(1) + new/obj/item/stack/tile/light(user.loc) + user << "You make a light tile." + else + user << "You need one metal sheet to finish the light tile." + return diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 72e088c42cf..8e8fb395294 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -8,6 +8,7 @@ /* * Stacks */ + /obj/item/stack gender = PLURAL origin_tech = "materials=1" @@ -19,11 +20,11 @@ /obj/item/stack/New(var/loc, var/amount=null) ..() if (amount) - src.amount=amount + src.amount = amount return /obj/item/stack/Del() - if (src && usr && usr.machine==src) + if (src && usr && usr.machine == src) usr << browse(null, "window=stack") ..() @@ -69,12 +70,6 @@ var/title as text var/can_build = 1 can_build = can_build && (max_multiplier>0) - /* - if (R.one_per_turf) - can_build = can_build && !(locate(R.result_type) in usr.loc) - if (R.on_floor) - can_build = can_build && istype(usr.loc, /turf/simulated/floor) - */ if (R.res_amount>1) title+= "[R.res_amount]x [R.title]\s" else @@ -181,6 +176,9 @@ amount += extra return 1 +/obj/item/stack/proc/get_amount() + return amount + /obj/item/stack/proc/add_to_stacks(mob/usr as mob) var/obj/item/stack/oldsrc = src src = null diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm index e7e2ed1a962..4e3235ecf9a 100644 --- a/code/game/objects/items/weapons/handcuffs.dm +++ b/code/game/objects/items/weapons/handcuffs.dm @@ -132,13 +132,13 @@ var/last_chew = 0 ..() if(istype(I, /obj/item/stack/rods)) var/obj/item/stack/rods/R = I - var/obj/item/weapon/wirerod/W = new /obj/item/weapon/wirerod - R.use(1) + if (R.use(1)) + var/obj/item/weapon/wirerod/W = new /obj/item/weapon/wirerod - user.put_in_hands(W) - user << "You wrap the cable restraint around the top of the rod." - del(src) - update_icon(user) + user.put_in_hands(W) + user << "You wrap the cable restraint around the top of the rod." + del(src) + update_icon(user) /obj/item/weapon/handcuffs/cyborg diff --git a/code/game/objects/items/weapons/table_rack_parts.dm b/code/game/objects/items/weapons/table_rack_parts.dm index 042efc84203..d79fa0d7a68 100644 --- a/code/game/objects/items/weapons/table_rack_parts.dm +++ b/code/game/objects/items/weapons/table_rack_parts.dm @@ -18,13 +18,13 @@ //SN src = null del(src) if (istype(W, /obj/item/stack/rods)) - if (W:amount >= 4) - new /obj/item/weapon/table_parts/reinforced( user.loc ) - user << "\blue You reinforce the [name]." - W:use(4) + var/obj/item/stack/rods/R = W + if (R.use(4)) + new /obj/item/weapon/table_parts/reinforced(user.loc) + user << "You reinforce the [name]." del(src) - else if (W:amount < 4) - user << "\red You need at least four rods to do this." + else + user << "You need at least four rods to reinforce the [name]." /obj/item/weapon/table_parts/attack_self(mob/user as mob) new /obj/structure/table( user.loc ) diff --git a/code/game/objects/structures/crates_lockers/crates.dm b/code/game/objects/structures/crates_lockers/crates.dm index 342b386958e..df7b63a1995 100644 --- a/code/game/objects/structures/crates_lockers/crates.dm +++ b/code/game/objects/structures/crates_lockers/crates.dm @@ -76,14 +76,14 @@ else if(istype(W, /obj/item/weapon/packageWrap)) return else if(istype(W, /obj/item/stack/cable_coil)) + var/obj/item/stack/cable_coil/C = W if(rigged) user << "[src] is already rigged!" return - user << "You rig [src]." - user.drop_item() - del(W) - rigged = 1 - return + if (C.use(1)) + user << "You rig [src]." + rigged = 1 + return else if(istype(W, /obj/item/device/radio/electropack)) if(rigged) user << "You attach [W] to [src]." diff --git a/code/game/objects/structures/door_assembly.dm b/code/game/objects/structures/door_assembly.dm index 480f2ebb838..8e63a00a1e4 100644 --- a/code/game/objects/structures/door_assembly.dm +++ b/code/game/objects/structures/door_assembly.dm @@ -184,14 +184,16 @@ obj/structure/door_assembly user << "\blue You [anchored? "un" : ""]secured the airlock assembly!" anchored = !anchored - else if(istype(W, /obj/item/stack/cable_coil) && state == 0 && anchored ) - var/obj/item/stack/cable_coil/coil = W + else if(istype(W, /obj/item/stack/cable_coil) && state == 0 && anchored) + var/obj/item/stack/cable_coil/C = W + if (C.get_amount() < 1) + user << "You need one length of coil to wire the airlock assembly." + return user.visible_message("[user] wires the airlock assembly.", "You start to wire the airlock assembly.") - if(do_after(user, 40)) - if(!src) return - coil.use(1) - src.state = 1 - user << "\blue You wire the Airlock!" + if(do_after(user, 40) && state == 0 && anchored) + if (C.use(1)) + src.state = 1 + user << "You wire the airlock." else if(istype(W, /obj/item/weapon/wirecutters) && state == 1 ) playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1) @@ -236,23 +238,23 @@ obj/structure/door_assembly else if(istype(W, /obj/item/stack/sheet) && !glass) var/obj/item/stack/sheet/S = W if (S) - if (S.amount>=1) + if (S.get_amount() >= 1) if(istype(S, /obj/item/stack/sheet/rglass)) playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1) user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.") - if(do_after(user, 40)) - user << "\blue You installed reinforced glass windows into the airlock assembly!" - S.use(1) - glass = 1 + if(do_after(user, 40) && !glass) + if (S.use(1)) + user << "You installed reinforced glass windows into the airlock assembly." + glass = 1 else if(istype(S, /obj/item/stack/sheet/mineral) && S.sheettype) var/M = S.sheettype - if(S.amount>=2) + if(S.get_amount() >= 2) playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1) user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.") - if(do_after(user, 40)) - user << "\blue You installed [M] plating into the airlock assembly!" - S.use(2) - glass = "[M]" + if(do_after(user, 40) && !glass) + if (S.use(2)) + user << "You installed [M] plating into the airlock assembly." + glass = "[M]" else if(istype(W, /obj/item/weapon/screwdriver) && state == 2 ) playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1) diff --git a/code/game/objects/structures/girders.dm b/code/game/objects/structures/girders.dm index 286c28f37ed..fa6b52c4acf 100644 --- a/code/game/objects/structures/girders.dm +++ b/code/game/objects/structures/girders.dm @@ -81,55 +81,50 @@ if(/obj/item/stack/sheet/metal, /obj/item/stack/sheet/metal/cyborg) if(!anchored) - if(S.amount < 2) return - S.use(2) - user << "\blue You create a false wall! Push on it to open or close the passage." - new /obj/structure/falsewall (src.loc) - del(src) - else - if(S.amount < 2) return ..() - user << "\blue Now adding plating..." - if (do_after(user,40)) - if(!src || !S || S.amount < 2) return - S.use(2) - user << "\blue You added the plating!" - var/turf/Tsrc = get_turf(src) - Tsrc.ChangeTurf(/turf/simulated/wall) - for(var/turf/simulated/wall/X in Tsrc.loc) - if(X) X.add_hiddenprint(usr) + if(S.use(2)) + user << "You create a false wall! Push on it to open or close the passage." + new /obj/structure/falsewall (src.loc) del(src) + else + if(S.get_amount() < 2) return ..() + user << "Now adding plating..." + if (do_after(user,40)) + if (S.use(2)) + user << "You added the plating!" + var/turf/Tsrc = get_turf(src) + Tsrc.ChangeTurf(/turf/simulated/wall) + for(var/turf/simulated/wall/X in Tsrc.loc) + if(X) X.add_hiddenprint(usr) + del(src) return if(/obj/item/stack/sheet/plasteel) if(!anchored) - if(S.amount < 2) return - S.use(2) - user << "\blue You create a false wall! Push on it to open or close the passage." - new /obj/structure/falserwall (src.loc) - del(src) + if(S.use(2)) + user << "\blue You create a false wall! Push on it to open or close the passage." + new /obj/structure/falserwall (src.loc) + del(src) else if (src.icon_state == "reinforced") //I cant believe someone would actually write this line of code... - if(S.amount < 1) return ..() - user << "\blue Now finalising reinforced wall." + if(S.get_amount() < 1) return ..() + user << "Now finalising reinforced wall." if(do_after(user, 50)) - if(!src || !S || S.amount < 1) return - S.use(1) - user << "\blue Wall fully reinforced!" - var/turf/Tsrc = get_turf(src) - Tsrc.ChangeTurf(/turf/simulated/wall/r_wall) - for(var/turf/simulated/wall/r_wall/X in Tsrc.loc) - if(X) X.add_hiddenprint(usr) - del(src) + if (S.use(1)) + user << "Wall fully reinforced!" + var/turf/Tsrc = get_turf(src) + Tsrc.ChangeTurf(/turf/simulated/wall/r_wall) + for(var/turf/simulated/wall/r_wall/X in Tsrc.loc) + if(X) X.add_hiddenprint(usr) + del(src) return else - if(S.amount < 1) return ..() - user << "\blue Now reinforcing girders" + if(S.get_amount() < 1) return ..() + user << "Now reinforcing girders..." if (do_after(user,60)) - if(!src || !S || S.amount < 1) return - S.use(1) - user << "\blue Girders reinforced!" - new/obj/structure/girder/reinforced( src.loc ) - del(src) + if(S.use(1)) + user << "Girders reinforced!" + new/obj/structure/girder/reinforced( src.loc ) + del(src) return if(S.sheettype) diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 595a7d903be..630ed6687c8 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -121,7 +121,8 @@ return //window placing begin - else if( istype(W,/obj/item/stack/sheet/rglass) || istype(W,/obj/item/stack/sheet/glass) ) + else if(istype(W,/obj/item/stack/sheet/rglass) || istype(W,/obj/item/stack/sheet/glass)) + var/obj/item/stack/sheet/ST = W var/dir_to_set = 1 if(loc == user.loc) dir_to_set = user.dir @@ -146,24 +147,22 @@ return user << "You start placing the window." if(do_after(user,20)) - if(!src) return //Grille destroyed while waiting for(var/obj/structure/window/WINDOW in loc) if(WINDOW.dir == dir_to_set)//checking this for a 2nd time to check if a window was made while we were waiting. user << "There is already a window facing this way there." return - var/obj/structure/window/WD - if(istype(W,/obj/item/stack/sheet/rglass)) - WD = new/obj/structure/window/reinforced(loc) //reinforced window - else - WD = new/obj/structure/window/basic(loc) //normal window - WD.dir = dir_to_set - WD.ini_dir = dir_to_set - WD.anchored = 0 - WD.state = 0 - var/obj/item/stack/ST = W - ST.use(1) - user << "You place the [WD] on [src]." - WD.update_icon() + if (ST.use(1)) + var/obj/structure/window/WD + if(istype(W, /obj/item/stack/sheet/rglass)) + WD = new/obj/structure/window/reinforced(loc) //reinforced window + else + WD = new/obj/structure/window/basic(loc) //normal window + WD.dir = dir_to_set + WD.ini_dir = dir_to_set + WD.anchored = 0 + WD.state = 0 + user << "You place the [WD] on [src]." + WD.update_icon() return //window placing end diff --git a/code/game/objects/structures/windoor_assembly.dm b/code/game/objects/structures/windoor_assembly.dm index 34d90c31a31..ac2bac7e1bb 100644 --- a/code/game/objects/structures/windoor_assembly.dm +++ b/code/game/objects/structures/windoor_assembly.dm @@ -109,36 +109,33 @@ obj/structure/windoor_assembly/Del() //Adding plasteel makes the assembly a secure windoor assembly. Step 2 (optional) complete. else if(istype(W, /obj/item/stack/rods) && !secure) var/obj/item/stack/rods/R = W - if(R.amount < 4) - user << "\red You need more rods to do this." + if(R.get_amount() < 4) + user << "You need more rods to do this." return - user << "\blue You start to reinforce the windoor with rods." + user << "You start to reinforce the windoor with rods." - if(do_after(user,40)) - if(!src) return - - R.use(4) - user << "\blue You reinforce the windoor." - src.secure = "secure_" - if(src.anchored) - src.name = "Secure Anchored Windoor Assembly" - else - src.name = "Secure Windoor Assembly" + if(do_after(user,40) && !secure) + if (R.use(4)) + user << "You reinforce the windoor." + src.secure = "secure_" + if(src.anchored) + src.name = "Secure Anchored Windoor Assembly" + else + src.name = "Secure Windoor Assembly" //Adding cable to the assembly. Step 5 complete. else if(istype(W, /obj/item/stack/cable_coil) && anchored) user.visible_message("[user] wires the windoor assembly.", "You start to wire the windoor assembly.") + var/obj/item/stack/cable_coil/CC = W if(do_after(user, 40)) - if(!src) return - var/obj/item/stack/cable_coil/CC = W - CC.use(1) - user << "\blue You wire the windoor!" - src.state = "02" - if(src.secure) - src.name = "Secure Wired Windoor Assembly" - else - src.name = "Wired Windoor Assembly" + if (CC.use(1)) + user << "You wire the windoor!" + src.state = "02" + if(src.secure) + src.name = "Secure Wired Windoor Assembly" + else + src.name = "Wired Windoor Assembly" else ..() diff --git a/code/game/supplyshuttle.dm b/code/game/supplyshuttle.dm index 1ef29b5065e..80850522f4a 100644 --- a/code/game/supplyshuttle.dm +++ b/code/game/supplyshuttle.dm @@ -213,12 +213,12 @@ var/list/mechtoys = list( // Sell phoron if(istype(A, /obj/item/stack/sheet/mineral/phoron)) var/obj/item/stack/sheet/mineral/phoron/P = A - phoron_count += P.amount + phoron_count += P.get_amount() // Sell platinum if(istype(A, /obj/item/stack/sheet/mineral/platinum)) var/obj/item/stack/sheet/mineral/platinum/P = A - plat_count += P.amount + plat_count += P.get_amount() del(MA) diff --git a/code/game/turfs/simulated/floor.dm b/code/game/turfs/simulated/floor.dm index 1dcbfca15a2..85dbfa16c5a 100644 --- a/code/game/turfs/simulated/floor.dm +++ b/code/game/turfs/simulated/floor.dm @@ -490,15 +490,16 @@ turf/simulated/floor/proc/update_icon() if(istype(C, /obj/item/stack/rods)) var/obj/item/stack/rods/R = C if (is_plating()) - if (R.amount >= 2) - user << "\blue Reinforcing the floor..." - if(do_after(user, 30) && R && R.amount >= 2 && is_plating()) + if (R.get_amount() < 2) + user << "You need more rods." + return + user << "\blue Reinforcing the floor..." + if(do_after(user, 30) && is_plating()) + if (R.use(2)) ChangeTurf(/turf/simulated/floor/engine) playsound(src, 'sound/items/Deconstruct.ogg', 80, 1) - R.use(2) - return + return else - user << "\red You need more rods." else user << "\red You must remove the plating first." return @@ -507,27 +508,27 @@ turf/simulated/floor/proc/update_icon() if(is_plating()) if(!broken && !burnt) var/obj/item/stack/tile/T = C - floor_tile = new T.type - intact = 1 - if(istype(T,/obj/item/stack/tile/light)) - var/obj/item/stack/tile/light/L = T - var/obj/item/stack/tile/light/F = floor_tile - F.state = L.state - F.on = L.on - if(istype(T,/obj/item/stack/tile/grass)) - for(var/direction in cardinal) - if(istype(get_step(src,direction),/turf/simulated/floor)) - var/turf/simulated/floor/FF = get_step(src,direction) - FF.update_icon() //so siding gets updated properly - else if(istype(T,/obj/item/stack/tile/carpet)) - for(var/direction in list(1,2,4,8,5,6,9,10)) - if(istype(get_step(src,direction),/turf/simulated/floor)) - var/turf/simulated/floor/FF = get_step(src,direction) - FF.update_icon() //so siding gets updated properly - T.use(1) - update_icon() - levelupdate() - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + if (T.use(1)) + floor_tile = new T.type + intact = 1 + if(istype(T,/obj/item/stack/tile/light)) + var/obj/item/stack/tile/light/L = T + var/obj/item/stack/tile/light/F = floor_tile + F.state = L.state + F.on = L.on + if(istype(T,/obj/item/stack/tile/grass)) + for(var/direction in cardinal) + if(istype(get_step(src,direction),/turf/simulated/floor)) + var/turf/simulated/floor/FF = get_step(src,direction) + FF.update_icon() //so siding gets updated properly + else if(istype(T,/obj/item/stack/tile/carpet)) + for(var/direction in list(1,2,4,8,5,6,9,10)) + if(istype(get_step(src,direction),/turf/simulated/floor)) + var/turf/simulated/floor/FF = get_step(src,direction) + FF.update_icon() //so siding gets updated properly + update_icon() + levelupdate() + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) else user << "\blue This section is too damaged to support a tile. Use a welder to fix the damage." diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index d99dc066773..2ebb88fc9ef 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -38,20 +38,20 @@ if(L) return var/obj/item/stack/rods/R = C - user << "\blue Constructing support lattice ..." - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - ReplaceWithLattice() - R.use(1) + if (R.use(1)) + user << "\blue Constructing support lattice ..." + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + ReplaceWithLattice() return if (istype(C, /obj/item/stack/tile/plasteel)) var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) if(L) var/obj/item/stack/tile/plasteel/S = C - del(L) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - S.build(src) - S.use(1) + if (S.use(1)) + del(L) + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + S.build(src) return else user << "\red The plating is going to need some support." diff --git a/code/modules/clothing/gloves/stungloves.dm b/code/modules/clothing/gloves/stungloves.dm index a97237a8fad..c40ff3e80c8 100644 --- a/code/modules/clothing/gloves/stungloves.dm +++ b/code/modules/clothing/gloves/stungloves.dm @@ -15,7 +15,7 @@ user << "The [src] are already wired." return - if(C.amount < 2) + if(C.get_amount() < 2) user << "There is not enough wire to cover the [src]." return diff --git a/code/modules/clothing/spacesuits/breaches.dm b/code/modules/clothing/spacesuits/breaches.dm index 19f795561c0..036e1f4b52c 100644 --- a/code/modules/clothing/spacesuits/breaches.dm +++ b/code/modules/clothing/spacesuits/breaches.dm @@ -186,9 +186,9 @@ var/global/list/breach_burn_descriptors = list( return var/obj/item/stack/sheet/P = W - if(P.amount < 3) - P.use(P.amount) - repair_breaches(BURN, ( istype(P,/obj/item/stack/sheet/mineral/plastic) ? P.amount : (P.amount*2) ), user) + if(P.get_amount() < 3) + P.use(P.get_amount()) + repair_breaches(BURN, ( istype(P,/obj/item/stack/sheet/mineral/plastic) ? P.get_amount() : (P.get_amount()*2) ), user) else P.use(3) repair_breaches(BURN, ( istype(P,/obj/item/stack/sheet/mineral/plastic) ? 3 : 5), user) diff --git a/code/modules/mining/coins.dm b/code/modules/mining/coins.dm index 91de0e2d070..c9942112b73 100644 --- a/code/modules/mining/coins.dm +++ b/code/modules/mining/coins.dm @@ -44,22 +44,19 @@ icon_state = "coin_adamantine" /obj/item/weapon/coin/attackby(obj/item/weapon/W as obj, mob/user as mob) - if(istype(W,/obj/item/stack/cable_coil) ) + if(istype(W,/obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/CC = W if(string_attached) - user << "\blue There already is a string attached to this coin." + user << "There already is a string attached to this coin." return - - if(CC.amount <= 0) - user << "\blue This cable coil appears to be empty." - del(CC) - return - - overlays += image('icons/obj/items.dmi',"coin_string_overlay") - string_attached = 1 - user << "\blue You attach a string to the coin." - CC.use(1) - else if(istype(W,/obj/item/weapon/wirecutters) ) + if (CC.use(1)) + overlays += image('icons/obj/items.dmi',"coin_string_overlay") + string_attached = 1 + user << "You attach a string to the coin." + else + user << "This cable coil appears to be empty." + return + else if(istype(W,/obj/item/weapon/wirecutters)) if(!string_attached) ..() return diff --git a/code/modules/mining/mint.dm b/code/modules/mining/mint.dm index d17b4aa0943..59857424e67 100644 --- a/code/modules/mining/mint.dm +++ b/code/modules/mining/mint.dm @@ -41,22 +41,22 @@ O = locate(/obj/item/stack/sheet, input.loc) if(O) if (istype(O,/obj/item/stack/sheet/mineral/gold)) - amt_gold += 100 * O.amount + amt_gold += 100 * O.get_amount() del(O) if (istype(O,/obj/item/stack/sheet/mineral/silver)) - amt_silver += 100 * O.amount + amt_silver += 100 * O.get_amount() del(O) if (istype(O,/obj/item/stack/sheet/mineral/diamond)) - amt_diamond += 100 * O.amount + amt_diamond += 100 * O.get_amount() del(O) if (istype(O,/obj/item/stack/sheet/mineral/phoron)) - amt_phoron += 100 * O.amount + amt_phoron += 100 * O.get_amount() del(O) if (istype(O,/obj/item/stack/sheet/mineral/uranium)) - amt_uranium += 100 * O.amount + amt_uranium += 100 * O.get_amount() del(O) if (istype(O,/obj/item/stack/sheet/metal)) - amt_iron += 100 * O.amount + amt_iron += 100 * O.get_amount() del(O) /obj/machinery/mineral/mint/attack_hand(user as mob) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index c540e0b2dbf..df755d21eb1 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -618,11 +618,11 @@ user << "Nothing to fix here!" return var/obj/item/stack/cable_coil/coil = W - adjustFireLoss(-30) - updatehealth() - coil.use(1) - for(var/mob/O in viewers(user, null)) - O.show_message(text("\red [user] has fixed some of the burnt wires on [src]!"), 1) + if (coil.use(1)) + adjustFireLoss(-30) + updatehealth() + for(var/mob/O in viewers(user, null)) + O.show_message(text("\red [user] has fixed some of the burnt wires on [src]!"), 1) else if (istype(W, /obj/item/weapon/crowbar)) // crowbar means open or close the cover if(opened) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 0fb08d08688..e5f91363627 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -351,11 +351,9 @@ if(stat != DEAD) var/obj/item/stack/medical/MED = O if(health < maxHealth) - if(MED.amount >= 1) + if(MED.get_amount() >= 1) adjustBruteLoss(-MED.heal_brute) - MED.amount -= 1 - if(MED.amount <= 0) - del(MED) + MED.use(1) for(var/mob/M in viewers(src, null)) if ((M.client && !( M.blinded ))) M.show_message("\blue [user] applies the [MED] on [src]") diff --git a/code/modules/mob/living/simple_animal/worm.dm b/code/modules/mob/living/simple_animal/worm.dm index 0e803545e2e..387ac33bf2d 100644 --- a/code/modules/mob/living/simple_animal/worm.dm +++ b/code/modules/mob/living/simple_animal/worm.dm @@ -178,7 +178,7 @@ if(istype(stomachContent,/obj/item/stack)) //converts to plasma, keeping the stack value if(!istype(stomachContent,/obj/item/stack/sheet/mineral/phoron)) var/obj/item/stack/oldStack = stomachContent - new /obj/item/stack/sheet/mineral/phoron(src, oldStack.amount) + new /obj/item/stack/sheet/mineral/phoron(src, oldStack.get_amount()) del(oldStack) continue else if(istype(stomachContent,/obj/item)) //converts to plasma, keeping the w_class diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index db4a8bcf99a..df5e2a59df9 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -496,17 +496,17 @@ update_icon() else user << "You fail to [ locked ? "unlock" : "lock"] the APC interface." - else if (istype(W, /obj/item/stack/cable_coil) && !terminal && opened && has_electronics!=2) + else if (istype(W, /obj/item/stack/cable_coil) && !terminal && opened && has_electronics != 2) if (src.loc:intact) user << "\red You must remove the floor plating in front of the APC first." return var/obj/item/stack/cable_coil/C = W - if(C.amount < 10) - user << "\red You need more wires." + if(C.get_amount() < 10) + user << "You need more wires." return user << "You start adding cables to the APC frame..." playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) - if(do_after(user, 20) && C.amount >= 10) + if(do_after(user, 20) && !terminal && opened && has_electronics != 2) var/turf/T = get_turf(src) var/obj/structure/cable/N = T.get_cable_node() if (prob(50) && electrocute_mob(usr, N, N)) @@ -514,12 +514,12 @@ s.set_up(5, 1, src) s.start() return - C.use(10) - user.visible_message(\ - "\red [user.name] has added cables to the APC frame!",\ - "You add cables to the APC frame.") - make_terminal() - terminal.connect_to_network() + if (C.use(10)) + user.visible_message(\ + "\red [user.name] has added cables to the APC frame!",\ + "You add cables to the APC frame.") + make_terminal() + terminal.connect_to_network() else if (istype(W, /obj/item/weapon/wirecutters) && terminal && opened && has_electronics!=2) if (src.loc:intact) user << "\red You must remove the floor plating in front of the APC first." @@ -1199,7 +1199,7 @@ if(cell && !shorted) //var/cell_charge = cell.charge var/cell_maxcharge = cell.maxcharge - + // Calculate how much power the APC will try to get from the grid. var/target_draw = lastused_total if (src.attempt_charging()) @@ -1210,14 +1210,14 @@ var/power_drawn = 0 if (src.avail()) power_drawn = add_load(target_draw) //get some power from the powernet - + //figure out how much power is left over after meeting demand power_excess = power_drawn - lastused_total - + if (power_excess < 0) //couldn't get enough power from the grid, we will need to take from the power cell. - + charging = 0 - + var/required_power = -power_excess if(cell.charge >= required_power*CELLRATE) // can we draw enough from cell to cover what's left over? cell.use(required_power*CELLRATE) @@ -1229,7 +1229,7 @@ lighting = autoset(lighting, 0) environ = autoset(environ, 0) autoflag = 0 - + //Set external power status if (!power_drawn) main_status = 0 diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index aebe60c5f96..067b207d132 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -137,15 +137,15 @@ if(istype(W, /obj/item/stack/cable_coil)) if (src.stage != 1) return var/obj/item/stack/cable_coil/coil = W - coil.use(1) - switch(fixture_type) - if ("tube") - src.icon_state = "tube-construct-stage2" - if("bulb") - src.icon_state = "bulb-construct-stage2" - src.stage = 2 - user.visible_message("[user.name] adds wires to [src].", \ - "You add wires to [src].") + if (coil.use(1)) + switch(fixture_type) + if ("tube") + src.icon_state = "tube-construct-stage2" + if("bulb") + src.icon_state = "bulb-construct-stage2" + src.stage = 2 + user.visible_message("[user.name] adds wires to [src].", \ + "You add wires to [src].") return if(istype(W, /obj/item/weapon/screwdriver)) diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index c7b0e096a56..ff8fef2c25c 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -217,7 +217,7 @@ if(istype(W, /obj/item/stack/cable_coil) && !terminal && !building_terminal) building_terminal = 1 var/obj/item/stack/cable_coil/CC = W - if (CC.amount < 10) + if (CC.get_amount() < 10) user << "You need more cables." building_terminal = 0 return diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index 1fd0c090089..768cdfc205e 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -232,15 +232,16 @@ var/list/solars_list = list() if(istype(W, /obj/item/stack/sheet/glass) || istype(W, /obj/item/stack/sheet/rglass)) var/obj/item/stack/sheet/S = W - if(S.amount >= 2) + if(S.use(2)) glass_type = W.type - S.use(2) playsound(src.loc, 'sound/machines/click.ogg', 50, 1) user.visible_message("[user] places the glass on the solar assembly.") if(tracker) new /obj/machinery/power/tracker(get_turf(src), src) else new /obj/machinery/power/solar(get_turf(src), src) + else + user << "You need two sheets of glass to put them on the solar assembly." return 1 if(!tracker) diff --git a/code/modules/projectiles/guns/projectile/crossbow.dm b/code/modules/projectiles/guns/projectile/crossbow.dm index 41635b6397c..4ae688d0d96 100644 --- a/code/modules/projectiles/guns/projectile/crossbow.dm +++ b/code/modules/projectiles/guns/projectile/crossbow.dm @@ -141,13 +141,13 @@ return else if(istype(W,/obj/item/stack/rods)) var/obj/item/stack/rods/R = W - R.use(1) - in_chamber = new /obj/item/weapon/arrow/rod(src) - in_chamber.fingerprintslast = src.fingerprintslast - in_chamber.loc = src - icon_state = "crossbow-nocked" - user.visible_message("[user] jams [in_chamber] into [src].","You jam [in_chamber] into [src].") - superheat_rod(user) + if (R.use(1)) + in_chamber = new /obj/item/weapon/arrow/rod(src) + in_chamber.fingerprintslast = src.fingerprintslast + in_chamber.loc = src + icon_state = "crossbow-nocked" + user.visible_message("[user] jams [in_chamber] into [src].","You jam [in_chamber] into [src].") + superheat_rod(user) return if(istype(W, /obj/item/weapon/cell)) @@ -210,8 +210,7 @@ if(istype(W,/obj/item/stack/rods)) if(buildstate == 0) var/obj/item/stack/rods/R = W - if(R.amount >= 3) - R.use(3) + if(R.use(3)) user << "\blue You assemble a backbone of rods around the wooden stock." buildstate++ update_icon() @@ -231,8 +230,7 @@ else if(istype(W,/obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/C = W if(buildstate == 2) - if(C.amount >= 5) - C.use(5) + if(C.use(5)) user << "\blue You wire a crude cell mount into the top of the crossbow." buildstate++ update_icon() @@ -240,8 +238,7 @@ user << "\blue You need at least five segments of cable coil to complete this task." return else if(buildstate == 4) - if(C.amount >= 5) - C.use(5) + if(C.use(5)) user << "\blue You string a steel cable across the crossbow's lath." buildstate++ update_icon() @@ -251,8 +248,7 @@ else if(istype(W,/obj/item/stack/sheet/mineral/plastic)) if(buildstate == 3) var/obj/item/stack/sheet/mineral/plastic/P = W - if(P.amount >= 3) - P.use(3) + if(P.use(3)) user << "\blue You assemble and install a heavy plastic lath onto the crossbow." buildstate++ update_icon() diff --git a/code/modules/projectiles/guns/projectile/pneumatic.dm b/code/modules/projectiles/guns/projectile/pneumatic.dm index 6d1855b8a7d..9b4efd58d03 100644 --- a/code/modules/projectiles/guns/projectile/pneumatic.dm +++ b/code/modules/projectiles/guns/projectile/pneumatic.dm @@ -166,8 +166,7 @@ else if(istype(W,/obj/item/stack/sheet/metal)) if(buildstate == 2) var/obj/item/stack/sheet/metal/M = W - if(M.amount >= 5) - M.use(5) + if(M.use(5)) user << "\blue You assemble a chassis around the cannon frame." buildstate++ update_icon() diff --git a/code/modules/reagents/reagent_containers/food/snacks/grown.dm b/code/modules/reagents/reagent_containers/food/snacks/grown.dm index 9c887171bbf..f09c6c0c139 100644 --- a/code/modules/reagents/reagent_containers/food/snacks/grown.dm +++ b/code/modules/reagents/reagent_containers/food/snacks/grown.dm @@ -85,9 +85,8 @@ /obj/item/weapon/reagent_containers/food/snacks/grown/potato/attackby(obj/item/weapon/W as obj, mob/user as mob) ..() if(istype(W, /obj/item/stack/cable_coil)) - if(W:amount >= 5) - W:amount -= 5 - if(!W:amount) del(W) + var/obj/item/stack/cable_coil/C = W + if(C.use(5)) user << "You add some cable to the potato and slide it inside the battery encasing." var/obj/item/weapon/cell/potato/pocell = new /obj/item/weapon/cell/potato(user.loc) pocell.maxcharge = src.potency * 10 diff --git a/code/modules/research/protolathe.dm b/code/modules/research/protolathe.dm index df45b56f0ad..03544cb5fbd 100644 --- a/code/modules/research/protolathe.dm +++ b/code/modules/research/protolathe.dm @@ -135,8 +135,8 @@ Note: Must be placed west/left of and R&D console to function. amount = 0 if(amount == 0) return - if(amount > stack.amount) - amount = stack.amount + if(amount > stack.get_amount()) + amount = stack.get_amount() if(max_material_storage - TotalMaterials() < (amount*stack.perunit))//Can't overfill amount = min(stack.amount, round((max_material_storage-TotalMaterials())/stack.perunit)) diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm index 63a33fc5b5c..c740beebba4 100644 --- a/code/modules/research/rdconsole.dm +++ b/code/modules/research/rdconsole.dm @@ -270,8 +270,8 @@ won't update every console in existence) but it's more of a hassle to do. Also, M.death() if(istype(I,/obj/item/stack/sheet))//Only deconsturcts one sheet at a time instead of the entire stack var/obj/item/stack/sheet/S = I - if(S.amount > 1) - S.amount-- + if(S.get_amount() > 1) + S.use(1) linked_destroy.loaded_item = S else del(S) diff --git a/code/modules/research/xenoarchaeology/machinery/geosample_scanner.dm b/code/modules/research/xenoarchaeology/machinery/geosample_scanner.dm index 6a44fbe72d7..378848e26ea 100644 --- a/code/modules/research/xenoarchaeology/machinery/geosample_scanner.dm +++ b/code/modules/research/xenoarchaeology/machinery/geosample_scanner.dm @@ -71,7 +71,7 @@ var/choice = alert("What do you want to do with the nanopaste?","Radiometric Scanner","Scan nanopaste","Fix seal integrity") if(choice == "Fix seal integrity") var/obj/item/stack/nanopaste/N = I - var/amount_used = min(N.amount, 10 - scanner_seal_integrity / 10) + var/amount_used = min(N.get_amount(), 10 - scanner_seal_integrity / 10) N.use(amount_used) scanner_seal_integrity = round(scanner_seal_integrity + amount_used * 10) return diff --git a/code/modules/shieldgen/emergency_shield.dm b/code/modules/shieldgen/emergency_shield.dm index 20c5df5c4d5..d9cfba912e9 100644 --- a/code/modules/shieldgen/emergency_shield.dm +++ b/code/modules/shieldgen/emergency_shield.dm @@ -301,15 +301,14 @@ else if(istype(W, /obj/item/stack/cable_coil) && malfunction && is_open) var/obj/item/stack/cable_coil/coil = W - user << "\blue You begin to replace the wires." + user << "You begin to replace the wires." //if(do_after(user, min(60, round( ((maxhealth/health)*10)+(malfunction*10) ))) //Take longer to repair heavier damage if(do_after(user, 30)) - if(!src || !coil) return - coil.use(1) - health = max_health - malfunction = 0 - user << "\blue You repair the [src]!" - update_icon() + if (coil.use(1)) + health = max_health + malfunction = 0 + user << "You repair the [src]!" + update_icon() else if(istype(W, /obj/item/weapon/wrench)) if(locked)