SHARE
TWEET

Untitled

a guest Feb 18th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /obj/structure/destructible/dwarven/workshop
  2.     name = "Dwarven workshop"
  3.     icon_state = "workshop"
  4.     var/state = 0
  5.     custom_materials = list(/datum/material/wood = 20000)
  6.  
  7. /obj/structure/destructible/dwarven/workshop/Initialize()
  8.     . = ..()
  9.     AddComponent(/datum/component/material_container,
  10.     list(/datum/material/iron,
  11.     /datum/material/glass,
  12.     /datum/material/gold,
  13.     /datum/material/silver,
  14.     /datum/material/diamond,
  15.     /datum/material/uranium,
  16.     /datum/material/plasma,
  17.     /datum/material/bluespace,
  18.     /datum/material/bananium,
  19.     /datum/material/titanium,
  20.     /datum/material/runite,
  21.     /datum/material/plastic,
  22.     /datum/material/adamantine,
  23.     /datum/material/mythril,
  24.     /datum/material/wood
  25.     ), 20000, TRUE, /obj/item/stack, null, null)
  26.  
  27. /obj/structure/destructible/dwarven/workshop/examine(mob/user)
  28.     . = ..()
  29.     . += "<span class='notice'>Alt click to change the function</span>"
  30.     . += "<span class='notice'>Click with mats to put them inside of the workshop</span>"
  31.     . += "<span class='notice'>Click with a hand to retrieve all mats</span>"
  32.     . += "<span class='notice'>Click with a mallet to activate the function</span>"
  33.     . += "<span class='notice'>Current function is : [state]</span>"
  34.  
  35.  
  36. /obj/structure/destructible/dwarven/workshop/AltClick(mob/user)
  37.     if(!istype(user) || !user.canUseTopic(src, BE_CLOSE))
  38.         return
  39.  
  40.     if(state == 2)
  41.         state = 0
  42.     else
  43.         state++
  44.  
  45. /obj/structure/destructible/dwarven/workshop/attack_hand(mob/user)
  46.     var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
  47.     materials.retrieve_all()
  48.     . = ..()
  49.  
  50.  
  51. /obj/structure/destructible/dwarven/workshop/attacked_by(obj/item/I, mob/living/user)
  52.     if(istype(I,/obj/item/dwarven/mallet))
  53.         handle_mallet(user)
  54.         return
  55.     . = ..()
  56.  
  57. /obj/structure/destructible/dwarven/workshop/proc/handle_mallet(mob/user)
  58.     var/efficiency = user?.mind.get_skill_modifier(/datum/skill/operating, SKILL_EFFICIENCY_MODIFIER)
  59.     to_chat(user,"<span class='notice'>You start looking through design notes...</span>")
  60.     if(!do_after(user, 15, target = src))
  61.         return FALSE
  62.     if(!prob(efficiency))
  63.         user?.mind.adjust_experience(/datum/skill/operating, 1)
  64.         to_chat(user,"<span class='notice'>You cannot find anything of value.</span>")
  65.         return
  66.     user?.mind.adjust_experience(/datum/skill/operating, 2)
  67.     to_chat(user,"<span class='notice'>You find something useful!</span>")
  68.     switch(state)
  69.         if(1)
  70.             handle_create_blueprints(user)
  71.         if(2)
  72.             handle_create_pickaxe(user)
  73.         //if(3) //upgrades this will require dwarven metal datum
  74.         //  handle_create_pickaxe(user)
  75.     return
  76.  
  77. /obj/structure/destructible/dwarven/workshop/proc/handle_create_blueprints(mob/user)
  78.     var/obj/structure/destructible/dwarven/wanted_structure
  79.     var/choice
  80.     choice = alert("What structure do you wish to design?",,"Lava forge","Workbench","Dwarven Anvil","Dwarven Gringer")
  81.     switch(choice)
  82.         if("Lava forge")
  83.             wanted_structure = /obj/structure/destructible/dwarven/lava_forge
  84.         if("Workbench")
  85.             wanted_structure = /obj/structure/destructible/dwarven/workshop
  86.         if("Dwarven Anvil")
  87.             wanted_structure = /obj/structure/destructible/dwarven/workshop //todo
  88.         if("Dwarven Gringer")
  89.             wanted_structure = /obj/structure/destructible/dwarven/workshop // todo
  90.  
  91.     var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
  92.     for(var/i in wanted_structure.custom_materials)
  93.         var/datum/material/M = i
  94.         if(!materials.has_enough_of_material(M))
  95.             return
  96.     materials.use_materials(wanted_structure.custom_materials)
  97.     new /obj/item/dwarven/blueprint(drop_location(),wanted_structure)
  98.  
  99. /obj/structure/destructible/dwarven/workshop/proc/handle_create_pickaxe(mob/user)
  100.     var/obj/item/pickaxe/wanted_pickaxe
  101.     var/choice
  102.     choice = alert("What pickaxe do you wish to create?",,"Iron","Silver","Diamond")
  103.     switch(choice)
  104.         if("Iron")
  105.             wanted_pickaxe = /obj/item/pickaxe
  106.         if("Silver")
  107.             wanted_pickaxe = /obj/item/pickaxe/silver
  108.         if("Diamond")
  109.             wanted_pickaxe = /obj/item/pickaxe/diamond
  110.  
  111.     var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
  112.     for(var/i in wanted_pickaxe.custom_materials)
  113.         var/datum/material/M = i
  114.         if(!materials.has_enough_of_material(M))
  115.             return
  116.     materials.use_materials(wanted_pickaxe.custom_materials)
  117.     new wanted_pickaxe(drop_location())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top