Files
vgstation13/code/modules/blacksmithing/blacksmithing.dm
jellyveggie2 00c0026ce4 Make plastic sortable for recycling, and make a multitude of items recyclable (#31593)
* Most plastic items are now recyclable, under the label "miscellaneous". Amounts to be balanced, currently same as recipe.

* Mineral tiles can be recycled

* Gold teeth and collection plates can be recycled

* Recycling sorter will now empty out crates and closets before sorting, if possible

* New recycling material category for the sorter, plastic. Many items updated to be considered such.

* derp recycling sorter fixes

* derp what was the point in creating a category otherwise

* just in case

* dorf recycling

* Smithing recycling? It's been a while and I don't remember what I was up to.

* Fix #28612 (You cannot recycle coins into their base metal)

* Blacksmithing recycling nearly done now,
Just some weirdness with tower shields left, plasteel component doesn't transfer materials correctly.

* All sheets with materials defined should actually have a .materials now, so I can grab an alloy sheet and use it's materials to decide what's being transferred instead of trying to guess of it's material type/hoping it has a material type at all. Fixes tower shields not having plasma from plasteel.
There's still a TODO in how materials are transferred to blacksmithing products, and a bug that predates my changes, but I've no idea how to go about either and this whole PR feels unatomic enough as it already is. I just wanted to be able to recycle plastic bags man, not overhaul crafting.

* Sorter will now consider crates it can't open as non-recyclable, since the recycler simply can't deal with those and it wouldn't make sense to create another way to unlock locked crates anyway. No more clogged recycling because of a closed crate.

* Update boomerang materials

Co-authored-by: Jellyveggie <39123109+Jellyveggie@users.noreply.github.com>
2021-12-20 10:59:06 -06:00

138 lines
4.8 KiB
Plaintext

/**
Put /obj/smithing_placeholder into a heatsource that is 90% of the melting temperature of that material to heat it up temporarily (spawn 10 seconds)
If struck by a blunt object (preferably a hammer, but a toolbox can work) enough times before it cools, it will make the object.
Can then choose to keep striking it to potentially increase its quality, but each time doubles the chance of failure per swing.
**/
/obj/item/smithing_placeholder
name = "placeholder"
desc = "An incomplete object, that requires forging and striking."
w_type = RECYK_METAL
starting_materials = list()
var/obj/result
var/malleable = FALSE
var/strikes_required
var/strikes
/obj/item/smithing_placeholder/Destroy()
result = null
materials = null
..()
/obj/item/smithing_placeholder/New(loc, var/obj/item/stack/S, var/obj/R, var/required_strikes)
..()
// Copy materials from result
material_type = R.material_type
materials.addFrom(R.materials)
//Stores recipe result in...
result = R
R.forceMove(null) //...nullspace?
// Makes it look like a metal sheet
var/obj/item/stack/sheet/mineral/M = material_type.sheettype
appearance = initial(M.appearance)
desc = initial(desc)
strikes_required = required_strikes
/obj/item/smithing_placeholder/examine(mob/user)
..()
to_chat(user, "<span class = 'notice'>[strikes?"It looks like it has been struck [strikes] times.":"It has not been struck yet."]<br>It is [malleable?"malleable":"not malleable"].[strikes_required<strikes?"<br>It looks to be finished, and just needs quenching.":""]")
/obj/item/smithing_placeholder/afterattack(atom/A, mob/user, proximity_flag, click_parameters)
if(!proximity_flag)
return
if(isobj(A))
var/obj/O = A
if(O.is_hot())
heat(O.is_hot(), O, user)
if(O.is_open_container() && O.reagents.has_reagent(WATER, 60))
quench(O, user)
if(istype(A, /mob/living/simple_animal/hostile/asteroid/magmaw)) //Until we have flameslimes, lavalizards, crimson pyromancers, or flaming skeletons, this will be hardcoded
var/mob/living/simple_animal/hostile/asteroid/magmaw/M = A
if(M.isDead())
return
var/temperature
switch(M.fire_extremity)
if(0)
temperature = MELTPOINT_GOLD
if(1)
temperature = MELTPOINT_STEEL
if(2)
temperature = MELTPOINT_MYTHRIL
heat(temperature, M, user)
/obj/item/smithing_placeholder/attackby(obj/item/I, mob/user)
if(ishammer(I))
strike(I, user)
user.delayNextAttack(1 SECONDS)
else if (I.is_hot())
heat(I.is_hot(), I, user)
/obj/item/smithing_placeholder/attempt_heating(var/atom/A, mob/user)
if(user)
to_chat(user, "<span class = 'notice'>You attempt to heat \the [src] with \the [A].</span>")
heat(A.is_hot(), A, user)
/obj/item/smithing_placeholder/proc/heat(var/temperature, var/atom/A, mob/user)
if(malleable)
return
if(temperature < ((material_type.melt_temperature/10)*9))
if(user)
to_chat(user, "<span class = 'warning'>\The [A] is not hot enough.</span>")
return
else if(!user)
visible_message("<span class='notice'>\The [src] begins heating up.</span>")
if(user)
to_chat(user, "<span class = 'notice'>You heat \the [src].</span>")
if(iswelder(A) && user)
var/obj/item/tool/weldingtool/W = A
if(!W.do_weld(user, src, 4 SECONDS/(temperature/material_type.melt_temperature), 5))
return
else if(user && !do_after(user, A, 4 SECONDS/(temperature/material_type.melt_temperature)))
return
malleable = TRUE
spawn(2 MINUTES)
malleable = FALSE
/obj/item/smithing_placeholder/proc/strike(var/obj/A, mob/user)
if(!malleable)
to_chat(user, "<span class = 'warning'>\The [src] has gone cool. It can not be manipulated in this state.</span>")
return
if(!hasanvil(loc))
to_chat(user, "<span class = 'warning'>There is no anvil to shape \the [src] over.</span>")
return
playsound(loc, 'sound/items/hammer_strike.ogg', 50, 1)
if(strikes > strikes_required)
if(prob(5*(strikes/strikes_required)))
to_chat(user, "<span class = 'warning'>\The [src] becomes brittle and unmalleable.</span>")
var/obj/item/stack/ore/slag/S = drop_stack(/obj/item/stack/ore/slag, get_turf(src))
recycle(S.mats)
result.recycle(S.mats)
qdel(result)
qdel(src)
return
if(istype(A,/obj/item/weapon/hammer))
strikes+=max(1, round(A.quality/2, 1))
else if(istype(A,/obj/item/weapon/storage/toolbox))
strikes+=0.25
if(strikes == strikes_required)
to_chat(user, "<span class = 'notice'>\The [src] seems to have taken shape nicely.</span>")
/obj/item/smithing_placeholder/proc/quench(obj/O, mob/user)
if(strikes < strikes_required)
to_chat(user, "<span class = 'warning'>\The [src] is not finished yet!</span>")
return 0
playsound(loc, 'sound/machines/hiss.ogg', 50, 1)
O.reagents.remove_reagent(WATER, 20)
var/datum/material/mat = material_type
if(mat)
result.dorfify(mat, strikes>strikes_required?(strikes/strikes_required):0)
result.forceMove(get_turf(src))
qdel(src)