267 lines
8.2 KiB
Plaintext
267 lines
8.2 KiB
Plaintext
#define WORKPIECE_PRESENT 1
|
|
#define WORKPIECE_INPROGRESS 2
|
|
#define WORKPIECE_FINISHED 3
|
|
#define WORKPIECE_SLAG 5
|
|
|
|
#define RECIPE_SMALLPICK "dbp" //draw bend punch
|
|
#define RECIPE_LARGEPICK "ddbp" //draw draw bend punch
|
|
#define RECIPE_SHOVEL "dfup" //draw fold upset punch
|
|
#define RECIPE_HAMMER "sfp" //shrink fold punch
|
|
#define RECIPE_AXE "ufp" //upset fold punch
|
|
|
|
|
|
#define RECIPE_SMALLKNIFE "sdd" //shrink draw draw
|
|
#define RECIPE_SHORTSWORD "dff" //draw fold fold
|
|
#define RECIPE_BROADSWORD "dfufd" //draw fold upset fold draw
|
|
#define RECIPE_KATANA "fffff" //fold fold fold fold fold
|
|
|
|
|
|
#define RECIPE_SCYTHE "bdf" //bend draw fold
|
|
#define RECIPE_COGHEAD "bsf" //bend shrink fold.
|
|
|
|
|
|
#define RECIPE_JAVELIN "dbf" //draw bend fold
|
|
#define RECIPE_HALBERD "duffp" //draw upset fold fold punch
|
|
#define RECIPE_GLAIVE "usfp" //upset shrink fold punch
|
|
|
|
/obj/structure/anvil
|
|
name = "anvil"
|
|
desc = "Base class of anvil. This shouldn't exist, but is useable."
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
density = TRUE
|
|
anchored = TRUE
|
|
var/workpiece_state = FALSE
|
|
var/datum/material/workpiece_material
|
|
var/anvilquality = 0
|
|
var/currentquality = 0 //lolman? what the fuck do these vars do?
|
|
var/currentsteps = 0 //even i don't know
|
|
var/outrightfailchance = 1 //todo: document this shit
|
|
var/stepsdone = ""
|
|
var/rng = FALSE
|
|
var/list/smithrecipes = list(RECIPE_AXE = /obj/item/smithing/axehead,
|
|
RECIPE_HAMMER = /obj/item/smithing/hammerhead,
|
|
RECIPE_SCYTHE = /obj/item/smithing/scytheblade,
|
|
RECIPE_SHOVEL = /obj/item/smithing/shovelhead,
|
|
RECIPE_COGHEAD = /obj/item/smithing/cogheadclubhead,
|
|
RECIPE_JAVELIN = /obj/item/smithing/javelinhead,
|
|
RECIPE_LARGEPICK = /obj/item/smithing/pickaxehead,
|
|
RECIPE_SMALLPICK = /obj/item/smithing/prospectingpickhead,
|
|
RECIPE_SHORTSWORD = /obj/item/smithing/shortswordblade,
|
|
RECIPE_SMALLKNIFE = /obj/item/smithing/knifeblade,
|
|
RECIPE_BROADSWORD = /obj/item/smithing/broadblade,
|
|
RECIPE_HALBERD = /obj/item/smithing/halberdhead,
|
|
RECIPE_GLAIVE = /obj/item/smithing/glaivehead,
|
|
RECIPE_KATANA = /obj/item/smithing/katanablade)
|
|
|
|
/obj/structure/anvil/Initialize()
|
|
..()
|
|
currentquality = anvilquality
|
|
|
|
/obj/structure/anvil/attackby(obj/item/I, mob/user)
|
|
if(istype(I, /obj/item/ingot))
|
|
var/obj/item/ingot/notsword = I
|
|
if(workpiece_state)
|
|
to_chat(user, "There's already a workpiece! Finish it or take it off.")
|
|
return FALSE
|
|
if(notsword.workability == "shapeable")
|
|
workpiece_state = WORKPIECE_PRESENT
|
|
workpiece_material = notsword.custom_materials
|
|
to_chat(user, "You place the [notsword] on the [src].")
|
|
currentquality = anvilquality
|
|
var/skillmod = 0
|
|
if(user.mind.skill_holder)
|
|
skillmod = user.mind.get_skill_level(/datum/skill/level/dorfy/blacksmithing)/2
|
|
currentquality += skillmod
|
|
qdel(notsword)
|
|
else
|
|
to_chat(user, "The ingot isn't workable yet!")
|
|
return FALSE
|
|
return
|
|
else if(istype(I, /obj/item/melee/smith/hammer))
|
|
var/obj/item/melee/smith/hammer/hammertime = I
|
|
if(workpiece_state == WORKPIECE_PRESENT || workpiece_state == WORKPIECE_INPROGRESS)
|
|
do_shaping(user, hammertime.qualitymod)
|
|
return
|
|
else
|
|
to_chat(user, "You can't work an empty anvil!")
|
|
return FALSE
|
|
return ..()
|
|
|
|
/obj/structure/anvil/wrench_act(mob/living/user, obj/item/I)
|
|
..()
|
|
default_unfasten_wrench(user, I, 5)
|
|
return TRUE
|
|
|
|
|
|
/obj/structure/anvil/proc/do_shaping(mob/user, var/qualitychange)
|
|
currentquality += qualitychange
|
|
var/list/shapingsteps = list("weak hit", "strong hit", "heavy hit", "fold", "draw", "shrink", "bend", "punch", "upset") //weak/strong/heavy hit affect strength. All the other steps shape.
|
|
workpiece_state = WORKPIECE_INPROGRESS
|
|
var/stepdone = input(user, "How would you like to work the metal?") in shapingsteps
|
|
switch(stepdone)
|
|
if("weak hit")
|
|
currentsteps += 1
|
|
outrightfailchance += 10
|
|
currentquality += 1
|
|
if("strong hit")
|
|
currentsteps += 2
|
|
outrightfailchance += 17.5
|
|
currentquality += 2
|
|
if("heavy hit")
|
|
currentsteps += 3
|
|
outrightfailchance += 25
|
|
currentquality += 3
|
|
if("fold")
|
|
stepsdone += "f"
|
|
currentsteps += 1
|
|
currentquality -= 1
|
|
if("draw")
|
|
stepsdone += "d"
|
|
currentsteps += 1
|
|
currentquality -= 1
|
|
if("shrink")
|
|
stepsdone += "s"
|
|
currentsteps += 1
|
|
currentquality -= 1
|
|
if("bend")
|
|
stepsdone += "b"
|
|
currentsteps += 1
|
|
currentquality -= 1
|
|
if("punch")
|
|
stepsdone += "p"
|
|
currentsteps += 1
|
|
currentquality -= 1
|
|
if("upset")
|
|
stepsdone += "u"
|
|
currentsteps += 1
|
|
currentquality -= 1
|
|
to_chat(user, "You [stepdone] the metal.")
|
|
to_chat(user, stepsdone)
|
|
if(length(stepsdone) >= 3)
|
|
tryfinish(user)
|
|
|
|
/obj/structure/anvil/proc/tryfinish(mob/user)
|
|
if(currentsteps > 12 || (rng && prob(outrightfailchance)))
|
|
to_chat(user, "You overwork the metal, causing it to turn into useless slag!")
|
|
var/turf/T = get_turf(user)
|
|
workpiece_state = FALSE
|
|
new /obj/item/stack/ore/slag(T)
|
|
currentquality = anvilquality
|
|
stepsdone = ""
|
|
currentsteps = 0
|
|
outrightfailchance = 1
|
|
if(user.mind.skill_holder)
|
|
user.mind.auto_gain_experience(/datum/skill/level/dorfy/blacksmithing, 25, 400, silent = FALSE)
|
|
for(var/i in smithrecipes)
|
|
to_chat(user, "comparing [i] to [stepsdone]")
|
|
if(i == stepsdone)
|
|
var/turf/T = get_turf(user)
|
|
var/obj/item/smithing/create = smithrecipes[stepsdone]
|
|
var/obj/item/smithing/finisheditem = new create(T)
|
|
to_chat(user, "You finish your [finisheditem]!")
|
|
workpiece_state = FALSE
|
|
finisheditem.quality = currentquality
|
|
finisheditem.set_custom_materials(workpiece_material)
|
|
currentquality = anvilquality
|
|
stepsdone = ""
|
|
currentsteps = 0
|
|
outrightfailchance = 1
|
|
break
|
|
|
|
/obj/structure/anvil/debugsuper
|
|
name = "super ultra epic anvil of debugging."
|
|
desc = "WOW. A DEBUG <del>ITEM</DEL> STRUCTURE. EPIC."
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = 10
|
|
outrightfailchance = 0
|
|
|
|
/obj/structure/anvil/obtainable
|
|
name = "anvil"
|
|
desc = "Base class of anvil. This shouldn't exist, but is useable."
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = 0
|
|
outrightfailchance = 5
|
|
rng = TRUE
|
|
|
|
/obj/structure/anvil/obtainable/table
|
|
name = "table anvil"
|
|
desc = "A slightly reinforced table. Good luck."
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = -2
|
|
|
|
|
|
/obj/structure/anvil/obtainable/table/do_shaping(mob/user, var/qualitychange)
|
|
if(prob(5))
|
|
to_chat(user, "The [src] breaks under the strain!")
|
|
take_damage(max_integrity)
|
|
return FALSE
|
|
else
|
|
..()
|
|
|
|
/obj/structure/anvil/obtainable/bronze
|
|
name = "slab of bronze"
|
|
desc = "A big block of bronze. Useable as an anvil."
|
|
custom_materials = list(/datum/material/bronze=8000)
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = -1
|
|
|
|
/obj/structure/anvil/obtainable/sandstone
|
|
name = "sandstone brick anvil"
|
|
desc = "A big block of sandstone. Useable as an anvil."
|
|
custom_materials = list(/datum/material/sandstone=8000)
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = -1
|
|
|
|
/obj/structure/anvil/obtainable/basalt
|
|
name = "basalt brick anvil"
|
|
desc = "A big block of basalt. Useable as an anvil, better than sandstone. Igneous!"
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = -0.5
|
|
|
|
/obj/structure/anvil/obtainable/basic
|
|
name = "anvil"
|
|
desc = "An anvil. It's got wheels bolted to the bottom."
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = 0
|
|
|
|
/obj/structure/anvil/obtainable/ratvar
|
|
name = "brass anvil"
|
|
desc = "A big block of what appears to be brass. Useable as an anvil, if whatever's holding the brass together lets you."
|
|
custom_materials = list(/datum/material/bronze=8000)
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = 1
|
|
|
|
/obj/structure/anvil/obtainable/ratvar/attackby(obj/item/I, mob/user)
|
|
if(is_servant_of_ratvar(user))
|
|
return ..()
|
|
else
|
|
to_chat(user, "<span class='neovgre'>KNPXWN, QNJCQNW!</span>") //rot13 then rot22 if anyone wants to decode
|
|
|
|
/obj/structure/anvil/obtainable/narsie
|
|
name = "runic anvil"
|
|
desc = "An anvil made of a strange, runic metal."
|
|
custom_materials = list(/datum/material/runedmetal=8000)
|
|
icon = 'icons/obj/smith.dmi'
|
|
icon_state = "anvil"
|
|
anvilquality = 1
|
|
|
|
/obj/structure/anvil/obtainable/narsie/attackby(obj/item/I, mob/user)
|
|
if(iscultistr(user))
|
|
return ..()
|
|
else
|
|
to_chat(user, "<span class='narsiesmall'>That is not yours to use!</span>")
|
|
|
|
#undef WORKPIECE_PRESENT
|
|
#undef WORKPIECE_INPROGRESS
|
|
#undef WORKPIECE_FINISHED
|
|
#undef WORKPIECE_SLAG
|