diff --git a/code/game/objects/items/devices/lightreplacer.dm b/code/game/objects/items/devices/lightreplacer.dm index 6c58b4e1414..94731757895 100644 --- a/code/game/objects/items/devices/lightreplacer.dm +++ b/code/game/objects/items/devices/lightreplacer.dm @@ -41,160 +41,160 @@ /obj/item/lightreplacer name = "light replacer" - desc = "A device to automatically replace lights. Refill with working lightbulbs." + desc = "A device to automatically replace lights. Refill with broken or working light bulbs, or sheets of glass." icon = 'icons/obj/janitor.dmi' icon_state = "lightreplacer0" item_state = "electronic" - + w_class = WEIGHT_CLASS_SMALL flags = CONDUCT slot_flags = SLOT_BELT origin_tech = "magnets=3;engineering=4" + force = 8 + var/emagged = FALSE var/max_uses = 20 - var/uses = 0 - var/shards = 0 - var/recycle = 3 - var/emagged = 0 - var/failmsg = "" + var/uses = 10 // 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/lightreplacer/New() - uses = max_uses / 2 - failmsg = "The [name]'s refill light blinks red." - ..() + // Eating used bulbs gives us bulb shards + var/bulb_shards = 0 + // when we get this many shards, we get a free bulb. + var/shards_required = 4 + /obj/item/lightreplacer/examine(mob/user) - if(..(user, 2)) - to_chat(user, "It has [uses] lights and [shards] shards remaining.") + ..() + to_chat(user, status_string()) -/obj/item/lightreplacer/attackby(obj/item/W, mob/user, params) - 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) - to_chat(user, "There isn't enough glass.") - return - G.amount = remaining - if(!G.amount) - user.drop_item() - qdel(G) - AddUses(increment) - to_chat(user, "You insert a piece of glass into the [src.name]. You have [uses] lights remaining.") +/obj/item/lightreplacer/attackby(obj/item/I, mob/user, params) + if(istype(I, /obj/item/stack/sheet/glass)) + var/obj/item/stack/sheet/glass/G = I + if(uses >= max_uses) + to_chat(user, "[src] is full.") return + else if(G.use(decrement)) + AddUses(increment) + to_chat(user, "You insert a piece of glass into [src]. You have [uses] light\s remaining.") + return + else + to_chat(user, "You need one sheet of glass to replace lights!") + return - if(istype(W, /obj/item/light)) - var/obj/item/light/L = W + if(istype(I, /obj/item/shard)) + if(uses >= max_uses) + to_chat(user, "[src] is full.") + return + if(!user.unEquip(I)) + return + AddUses(round(increment * 0.75)) + to_chat(user, "You insert a shard of glass into [src]. You have [uses] light\s remaining.") + qdel(I) + return + + if(istype(I, /obj/item/light)) + var/obj/item/light/L = I if(L.status == 0) // LIGHT OKAY - if(!user.drop_item()) - to_chat(user, "[L] is stuck to your hand!") - return if(uses < max_uses) + if(!user.unEquip(L)) + return AddUses(1) - to_chat(user, "You insert the [L.name] into the [src.name]. You have [uses] lights remaining.") - user.drop_item() - qdel(L) - return - else if(L.status == 2 || L.status == 3) - if(!user.drop_item()) - to_chat(user, "[L] is stuck to your hand!") - return - else - AddShards(1) - to_chat(user, "You insert [L] into [src]. You have [shards] shards remaining.") - user.drop_item() qdel(L) + else + if(!user.unEquip(L)) return + to_chat(user, "You insert [L] into [src].") + AddShards(1, user) + qdel(L) + return - if(istype(W, /obj/item/storage)) - var/obj/item/storage/S = W - var/found_lightbulbs = 0 + if(istype(I, /obj/item/storage)) + var/obj/item/storage/S = I + var/found_lightbulbs = FALSE + var/replaced_something = TRUE - for(var/obj/item/I in S.contents) - if(istype(I,/obj/item/light)) - var/obj/item/light/L = I - found_lightbulbs = 1 + for(var/obj/item/IT in S.contents) + if(istype(IT, /obj/item/light)) + var/obj/item/light/L = IT + found_lightbulbs = TRUE if(uses >= max_uses) - to_chat(user, "[src] is full!") break - if(L.status == 0) + if(L.status == LIGHT_OK) + replaced_something = TRUE AddUses(1) qdel(L) - else if(L.status == 2 || L.status == 3) - AddShards(1) + + else if(L.status == LIGHT_BROKEN || L.status == LIGHT_BURNED) + replaced_something = TRUE + AddShards(1, user) qdel(L) - to_chat(user, "You fill [src] with lights from [S].") + if(!found_lightbulbs) to_chat(user, "[S] contains no bulbs.") return + if(!replaced_something && uses == max_uses) + to_chat(user, "[src] is full!") + return + + to_chat(user, "You fill [src] with lights from [S]. " + status_string() + "") + return + return ..() + /obj/item/lightreplacer/emag_act(user as mob) if(!emagged) Emag() /obj/item/lightreplacer/attack_self(mob/user) - /* // This would probably be a bit OP. If you want it though, uncomment the code. - if(isrobot(user)) - var/mob/living/silicon/robot/R = user - if(R.emagged) - src.Emag() - to_chat(usr, "You shortcircuit the [src].") - return - */ - to_chat(usr, "It has [uses] lights remaining.") + for(var/obj/machinery/light/target in user.loc) + ReplaceLight(target, user) + to_chat(user, status_string()) /obj/item/lightreplacer/update_icon() icon_state = "lightreplacer[emagged]" +/obj/item/lightreplacer/proc/status_string() + return "It has [uses] light\s remaining (plus [bulb_shards] fragment\s)." -/obj/item/lightreplacer/proc/Use(var/mob/user) - - playsound(src.loc, 'sound/machines/click.ogg', 50, 1) +/obj/item/lightreplacer/proc/Use(mob/user) + playsound(loc, 'sound/machines/click.ogg', 50, TRUE) AddUses(-1) return 1 // Negative numbers will subtract -/obj/item/lightreplacer/proc/AddUses(var/amount = 1) - uses = min(max(uses + amount, 0), max_uses) +/obj/item/lightreplacer/proc/AddUses(amount = 1) + uses = Clamp(uses + amount, 0, max_uses) -/obj/item/lightreplacer/proc/AddShards(amount = 1) - shards += amount - var/recycled_lights = round(shards / recycle) - if(recycled_lights > 0) - AddUses(recycled_lights) - shards = shards % recycle - return recycled_lights +/obj/item/lightreplacer/proc/AddShards(amount = 1, user) + bulb_shards += amount + var/new_bulbs = round(bulb_shards / shards_required) + if(new_bulbs > 0) + AddUses(new_bulbs) + bulb_shards = bulb_shards % shards_required + if(new_bulbs != 0) + to_chat(user, "[src] has fabricated a new bulb from the broken glass it has stored. It now has [uses] uses.") + playsound(loc, 'sound/machines/ding.ogg', 50, TRUE) + return new_bulbs /obj/item/lightreplacer/proc/Charge(var/mob/user) charge += 1 - if(charge > 7) + if(charge > 3) AddUses(1) charge = 1 -/obj/item/lightreplacer/proc/ReplaceLight(var/obj/machinery/light/target, var/mob/living/U) - +/obj/item/lightreplacer/proc/ReplaceLight(obj/machinery/light/target, mob/living/U) if(target.status != LIGHT_OK) if(CanUse(U)) - if(!Use(U)) return - to_chat(U, "You replace the [target.fitting] with the [src].") + if(!Use(U)) + return + to_chat(U, "You replace [target.fitting] with [src].") if(target.status != LIGHT_EMPTY) - - var/obj/item/light/L1 = new target.light_type(target.loc) - L1.status = target.status - L1.rigged = target.rigged - L1.brightness_range = target.brightness_range - L1.brightness_power = target.brightness_power - L1.brightness_color = target.brightness_color - L1.switchcount = target.switchcount - target.switchcount = 0 - L1.update() - + AddShards(1, U) target.status = LIGHT_EMPTY target.update() @@ -215,37 +215,54 @@ return else - to_chat(U, failmsg) + to_chat(U, "[src]'s refill light blinks red.") return else - to_chat(U, "There is a working [target.fitting] already inserted.") + to_chat(U, "There is a working [target.fitting] already inserted!") return /obj/item/lightreplacer/proc/Emag() emagged = !emagged - playsound(src.loc, "sparks", 100, 1) + playsound(loc, "sparks", 100, TRUE) if(emagged) - name = "Shortcircuited [initial(name)]" + name = "shortcircuited [initial(name)]" else name = initial(name) update_icon() -//Can you use it? +/obj/item/lightreplacer/proc/CanUse(mob/living/user) + add_fingerprint(user) + if(uses > 0) + return 1 + else + return 0 + +/obj/item/lightreplacer/afterattack(atom/T, mob/U, proximity) + if(!proximity) + return + if(!isturf(T)) + return + + var/used = FALSE + for(var/atom/A in T) + if(!CanUse(U)) + break + used = TRUE + if(istype(A, /obj/machinery/light)) + ReplaceLight(A, U) + + if(!used) + to_chat(U, "[src]'s refill light blinks red.") /obj/item/lightreplacer/proc/janicart_insert(mob/user, obj/structure/janitorialcart/J) J.put_in_cart(src, user) J.myreplacer = src J.update_icon() -/obj/item/lightreplacer/proc/CanUse(var/mob/living/user) - src.add_fingerprint(user) - //Not sure what else to check for. Maybe if clumsy? - if(uses > 0) - return 1 - else - return 0 +/obj/item/lightreplacer/cyborg/janicart_insert(mob/user, obj/structure/janitorialcart/J) + return #undef LIGHT_OK #undef LIGHT_EMPTY #undef LIGHT_BROKEN -#undef LIGHT_BURNED +#undef LIGHT_BURNED \ No newline at end of file diff --git a/code/game/objects/items/weapons/shards.dm b/code/game/objects/items/weapons/shards.dm index 4c8697da247..e2fc07712bf 100644 --- a/code/game/objects/items/weapons/shards.dm +++ b/code/game/objects/items/weapons/shards.dm @@ -1,27 +1,30 @@ // Glass shards /obj/item/shard - name = "glass shard" + name = "shard" + desc = "A nasty looking shard of glass." icon = 'icons/obj/shards.dmi' icon_state = "large" - sharp = TRUE - desc = "Could probably be used as ... a throwing weapon?" w_class = WEIGHT_CLASS_TINY force = 5 throwforce = 10 item_state = "shard-glass" - materials = list(MAT_GLASS=MINERAL_MATERIAL_AMOUNT) + materials = list(MAT_GLASS = MINERAL_MATERIAL_AMOUNT) attack_verb = list("stabbed", "slashed", "sliced", "cut") hitsound = 'sound/weapons/bladeslice.ogg' armor = list("melee" = 100, "bullet" = 0, "laser" = 0, "energy" = 100, "bomb" = 0, "bio" = 0, "rad" = 0) + sharp = TRUE + var/cooldown = 0 + var/icon_prefix + var/obj/item/stack/sheet/welded_type = /obj/item/stack/sheet/glass /obj/item/shard/suicide_act(mob/user) to_chat(viewers(user), pick("[user] is slitting [user.p_their()] wrists with [src]! It looks like [user.p_theyre()] trying to commit suicide.", "[user] is slitting [user.p_their()] throat with [src]! It looks like [user.p_theyre()] trying to commit suicide.")) return BRUTELOSS -/obj/item/shard/New() - ..() +/obj/item/shard/Initialize(mapload) + . = ..() icon_state = pick("large", "medium", "small") switch(icon_state) if("small") @@ -33,6 +36,8 @@ if("large") pixel_x = rand(-5, 5) pixel_y = rand(-5, 5) + if(icon_prefix) + icon_state = "[icon_prefix][icon_state]" /obj/item/shard/afterattack(atom/movable/AM, mob/user, proximity) if(!proximity || !(src in user)) @@ -48,15 +53,17 @@ if(affecting.is_robotic()) return to_chat(H, "[src] cuts into your hand!") - if(affecting.receive_damage(force*0.5)) + if(affecting.receive_damage(force * 0.5)) H.UpdateDamageIcon() /obj/item/shard/attackby(obj/item/I, mob/user, params) if(iswelder(I)) var/obj/item/weldingtool/WT = I if(WT.remove_fuel(0, user)) - var/obj/item/stack/sheet/glass/NG = new (user.loc) - for(var/obj/item/stack/sheet/glass/G in user.loc) + var/obj/item/stack/sheet/NG = new welded_type(user.loc) + for(var/obj/item/stack/sheet/G in user.loc) + if(!istype(G, welded_type)) + continue if(G == NG) continue if(G.amount >= G.max_amount) @@ -64,64 +71,48 @@ G.attackby(NG, user) to_chat(user, "You add the newly-formed glass to the stack. It now contains [NG.amount] sheet\s.") qdel(src) - else - return ..() + return + if(istype(I, /obj/item/lightreplacer)) + I.attackby(src, user) + return + return ..() -/obj/item/shard/Crossed(AM as mob|obj, oldloc) - if(isliving(AM)) - var/mob/living/M = AM - if(M.incorporeal_move || M.flying || M.throwing)//you are incorporal or flying or being thrown ..no shard stepping! +/obj/item/shard/Crossed(mob/living/L, oldloc) + if(istype(L) && has_gravity(loc)) + if(L.incorporeal_move || L.flying) return - to_chat(M, "You step on \the [src]!") - playsound(loc, 'sound/effects/glass_step.ogg', 50, 1) // not sure how to handle metal shards with sounds - if(ishuman(M)) - var/mob/living/carbon/human/H = M + playsound(loc, 'sound/effects/glass_step.ogg', 50, TRUE) + if(ishuman(L)) + var/mob/living/carbon/human/H = L + var/obj/item/organ/external/affecting = H.get_organ(pick("l_foot", "r_foot")) + if(!affecting) + return + if(affecting.is_robotic()) + return + var/feetCover = (H.wear_suit && H.wear_suit.body_parts_covered & FEET) || (H.w_uniform && H.w_uniform.body_parts_covered & FEET) + if(H.shoes || feetCover || H.buckled) + return + if(affecting.receive_damage(force, 0)) + H.UpdateDamageIcon() - if( !H.shoes && ( !H.wear_suit || !(H.wear_suit.body_parts_covered & FEET) ) ) - var/obj/item/organ/external/affecting = H.get_organ(pick("l_foot", "r_foot")) - if(!affecting) - return - if(affecting.is_robotic()) - return - H.Weaken(3) - if(affecting.receive_damage(5, 0)) - H.UpdateDamageIcon() - ..() + if(cooldown < world.time - 10) //cooldown to avoid message spam. + if(!H.incapacitated(ignore_restraints = TRUE)) + H.visible_message("[H] steps on [src]!", \ + "You step on [src]!") + else + H.visible_message("[H] slides on [src]!", \ + "You slide on [src]!") + + cooldown = world.time + H.Weaken(3) + return ..() /obj/item/shard/plasma name = "plasma shard" desc = "A shard of plasma glass. Considerably tougher then normal glass shards. Apparently not tough enough to be a window." - force = 8 - throwforce = 15 + force = 6 + throwforce = 11 icon_state = "plasmalarge" - sharp = TRUE - -/obj/item/shard/plasma/New() - ..() - icon_state = pick("plasmalarge", "plasmamedium", "plasmasmall") - switch(icon_state) - if("plasmasmall") - pixel_x = rand(-12, 12) - pixel_y = rand(-12, 12) - if("plasmamedium") - pixel_x = rand(-8, 8) - pixel_y = rand(-8, 8) - if("plasmalarge") - pixel_x = rand(-5, 5) - pixel_y = rand(-5, 5) - -/obj/item/shard/plasma/attackby(obj/item/W, mob/user, params) - if(iswelder(W)) - var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) - var/obj/item/stack/sheet/plasmaglass/NG = new (user.loc) - for(var/obj/item/stack/sheet/plasmaglass/G in user.loc) - if(G == NG) - continue - if(G.amount >= G.max_amount) - continue - G.attackby(NG, user, params) - to_chat(usr, "You add the newly-formed plasma glass to the stack. It now contains [NG.amount] sheets.") - qdel(src) - else - return ..() + materials = list(MAT_PLASMA = MINERAL_MATERIAL_AMOUNT * 0.5, MAT_GLASS = MINERAL_MATERIAL_AMOUNT) + icon_prefix = "plasma" + welded_type = /obj/item/stack/sheet/plasmaglass \ No newline at end of file diff --git a/code/game/objects/items/weapons/twohanded.dm b/code/game/objects/items/weapons/twohanded.dm index 15456386541..0f0a657f0ab 100644 --- a/code/game/objects/items/weapons/twohanded.dm +++ b/code/game/objects/items/weapons/twohanded.dm @@ -337,14 +337,23 @@ sharp = TRUE no_spin_thrown = TRUE var/obj/item/grenade/explosive = null + var/icon_prefix = "spearglass" /obj/item/twohanded/spear/update_icon() - if(explosive) - icon_state = "spearbomb[wielded]" - else - icon_state = "spearglass[wielded]" + icon_state = "[icon_prefix][wielded]" + +/obj/item/twohanded/spear/CheckParts(list/parts_list) + var/obj/item/shard/tip = locate() in parts_list + if(istype(tip, /obj/item/shard/plasma)) + force_wielded = 19 + force_unwielded = 11 + throwforce = 21 + icon_prefix = "spearplasma" + update_icon() + qdel(tip) ..() + /obj/item/twohanded/spear/afterattack(atom/movable/AM, mob/user, proximity) if(!proximity) return @@ -370,9 +379,7 @@ force_wielded = 20 //I have no idea how to balance throwforce = 22 armour_penetration = 15 //Enhanced armor piercing - -/obj/item/twohanded/spear/bonespear/update_icon() - icon_state = "bone_spear[wielded]" + icon_prefix = "bone_spear" //GREY TIDE /obj/item/twohanded/spear/grey_tide diff --git a/code/game/objects/items/weapons/weaponry.dm b/code/game/objects/items/weapons/weaponry.dm index 501f1780a0b..56a692e7645 100644 --- a/code/game/objects/items/weapons/weaponry.dm +++ b/code/game/objects/items/weapons/weaponry.dm @@ -105,7 +105,12 @@ ..() if(istype(I, /obj/item/shard)) var/obj/item/twohanded/spear/S = new /obj/item/twohanded/spear - + if(istype(I, /obj/item/shard/plasma)) + S.force_wielded = 19 + S.force_unwielded = 11 + S.throwforce = 21 + S.icon_prefix = "spearplasma" + S.update_icon() if(!remove_item_from_storage(user)) user.unEquip(src) user.unEquip(I) diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index 699376c927f..76c7f5bc1af 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -252,7 +252,7 @@ modules += new /obj/item/soap/nanotrasen(src) modules += new /obj/item/storage/bag/trash/cyborg(src) modules += new /obj/item/mop/advanced/cyborg(src) - modules += new /obj/item/lightreplacer(src) + modules += new /obj/item/lightreplacer/cyborg(src) modules += new /obj/item/holosign_creator(src) emag = new /obj/item/reagent_containers/spray(src) @@ -544,7 +544,7 @@ modules += new /obj/item/crowbar/cyborg(src) modules += new /obj/item/wirecutters/cyborg(src) modules += new /obj/item/multitool/cyborg(src) - modules += new /obj/item/lightreplacer(src) + modules += new /obj/item/lightreplacer/cyborg(src) modules += new /obj/item/gripper(src) modules += new /obj/item/matter_decompiler(src) modules += new /obj/item/reagent_containers/spray/cleaner/drone(src) @@ -562,10 +562,6 @@ /obj/item/robot_module/drone/respawn_consumable(mob/living/silicon/robot/R) var/obj/item/reagent_containers/spray/cleaner/C = locate() in modules C.reagents.add_reagent("cleaner", 3) - - var/obj/item/lightreplacer/LR = locate() in modules - LR.Charge(R) - ..() diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index b186e862f01..6b4b5f05e82 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -303,10 +303,7 @@ //Light replacer code if(istype(W, /obj/item/lightreplacer)) var/obj/item/lightreplacer/LR = W - if(isliving(user)) - var/mob/living/U = user - LR.ReplaceLight(src, U) - return + LR.ReplaceLight(src, user) // attempt to insert light if(istype(W, /obj/item/light)) diff --git a/icons/mob/inhands/items_lefthand.dmi b/icons/mob/inhands/items_lefthand.dmi index 10eef3b0337..7d0961fc449 100644 Binary files a/icons/mob/inhands/items_lefthand.dmi and b/icons/mob/inhands/items_lefthand.dmi differ diff --git a/icons/mob/inhands/items_righthand.dmi b/icons/mob/inhands/items_righthand.dmi index 926e04b28bf..5850e4d8d8c 100644 Binary files a/icons/mob/inhands/items_righthand.dmi and b/icons/mob/inhands/items_righthand.dmi differ diff --git a/icons/obj/items.dmi b/icons/obj/items.dmi index 463e135d35f..35f0fb7349d 100644 Binary files a/icons/obj/items.dmi and b/icons/obj/items.dmi differ