Merge pull request #12255 from Fox-McCloud/shards-glass-lights

Refactors Shards, Improved Light Replacer, Adds Plasmaspear
This commit is contained in:
variableundefined
2019-09-11 10:10:18 -04:00
committed by GitHub
9 changed files with 199 additions and 186 deletions
+123 -106
View File
@@ -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, "<span class='warning'>[src] is full.</span>")
return
else if(G.use(decrement))
AddUses(increment)
to_chat(user, "<span class='notice'>You insert a piece of glass into [src]. You have [uses] light\s remaining.</span>")
return
else
to_chat(user, "<span class='warning'>You need one sheet of glass to replace lights!</span>")
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, "<span class='warning'>[src] is full.</span>")
return
if(!user.unEquip(I))
return
AddUses(round(increment * 0.75))
to_chat(user, "<span class='notice'>You insert a shard of glass into [src]. You have [uses] light\s remaining.</span>")
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, "<span class='notice'>You insert [L] into [src].</span>")
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, "<span class='warning'>[src] is full!</span>")
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, "<span class='notice'>You fill [src] with lights from [S].")
if(!found_lightbulbs)
to_chat(user, "<span class='warning'>[S] contains no bulbs.</span>")
return
if(!replaced_something && uses == max_uses)
to_chat(user, "<span class='warning'>[src] is full!</span>")
return
to_chat(user, "<span class='notice'>You fill [src] with lights from [S]. " + status_string() + "</span>")
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, "<span class='notice'>[src] has fabricated a new bulb from the broken glass it has stored. It now has [uses] uses.</span>")
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, "<span class='notice'>You replace the [target.fitting] with the [src].</span>")
if(!Use(U))
return
to_chat(U, "<span class='notice'>You replace [target.fitting] with [src].</span>")
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, "<span class='warning'>There is a working [target.fitting] already inserted!</span>")
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
+53 -62
View File
@@ -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("<span class='danger'>[user] is slitting [user.p_their()] wrists with [src]! It looks like [user.p_theyre()] trying to commit suicide.</span>",
"<span class='danger'>[user] is slitting [user.p_their()] throat with [src]! It looks like [user.p_theyre()] trying to commit suicide.</span>"))
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, "<span class='warning'>[src] cuts into your hand!</span>")
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, "<span class='notice'>You add the newly-formed glass to the stack. It now contains [NG.amount] sheet\s.</span>")
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, "<span class='danger'>You step on \the [src]!</span>")
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("<span class='danger'>[H] steps on [src]!</span>", \
"<span class='userdanger'>You step on [src]!</span>")
else
H.visible_message("<span class='danger'>[H] slides on [src]!</span>", \
"<span class='userdanger'>You slide on [src]!</span>")
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
+14 -7
View File
@@ -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
+6 -1
View File
@@ -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)