WIP: Changing the balance designs of mechanic.

This commit is contained in:
ComicIronic
2014-11-13 23:30:15 +00:00
parent dbf9fbf60c
commit 04d45bfbc5
7 changed files with 90 additions and 100 deletions

View File

@@ -11,6 +11,8 @@
var/perunit = 3750
var/sheettype = null //this is used for girders in the creation of walls/false walls
mech_flags = MECH_SCAN_FAIL
// Since the sheetsnatcher was consolidated into weapon/storage/bag we now use
// item/attackby() properly, making this unnecessary

View File

@@ -396,7 +396,7 @@
//build_time is a var unique to each fabricator. It's mostly one, but bigger machines get higher build_time
//time_coeff is set by the machine components
/obj/machinery/r_n_d/fabricator/proc/get_construction_time_w_coeff(var/datum/design/part as obj, var/roundto=1)
return round(/*TechTotal(part)*/(MatTotal(part)/FAB_MAT_BASEMOD)*build_time*time_coeff, roundto)
return round(/*TechTotal(part)*/(part.MatTotal()/FAB_MAT_BASEMOD)*build_time*time_coeff, roundto)
/obj/machinery/r_n_d/fabricator/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
if(stat & (BROKEN|NOPOWER))

View File

@@ -68,14 +68,12 @@
var/list/techlist
if(istype(O, /obj/machinery))
// Objects that can only be scanned with the syndi-scanner.
if(syndi_filter && (O.mech_flags & MECH_SCAN_ILLEGAL)==MECH_SCAN_ILLEGAL)
return -1 //safety response
var/obj/machinery/M = O
if(M.component_parts)
for(var/obj/item/weapon/circuitboard/CB in M.component_parts) //fetching the circuit by looking in the parts
if(istype(CB))
techlist = ConvertReqString2List(CB.origin_tech)
break
else if(istype(M, /obj/machinery/computer))
var/obj/machinery/computer/C = M
if(C.circuit)
@@ -83,20 +81,15 @@
techlist = ConvertReqString2List(initial(comp_circuit.origin_tech))
else if(istype(O, /obj/item))
if(FindDesign(O)) //prioritizes the fail message over the illegal message
// Objects that can only be scanned with the syndi-scanner.
if(syndi_filter && (O.mech_flags & MECH_SCAN_ILLEGAL)==MECH_SCAN_ILLEGAL)
return -1 //safety response
return 1
else
return 0
/*
var/obj/item/I = O
techlist = ConvertReqString2List(I.origin_tech) //our tech is simply the item requirement
*/
if(!I.origin_tech)
return 0
techlist = ConvertReqString2List(I.origin_tech)
if(!techlist) //this don't fly
return 0
if(techlist && techlist["syndicate"] && src.syndi_filter)
return -1 //special negative return case
if(src.syndi_filter)
if((techlist && techlist["syndicate"]) || (O.mech_flags & MECH_SCAN_ILLEGAL))
return -1 //special negative return case
return 1

View File

@@ -89,49 +89,6 @@ obj/machinery/r_n_d/fabricator/mechanic_fab/flatpacker/build_part(var/datum/desi
src.busy = 0
return 1
//returns the required materials for the parts of a machine design
/obj/machinery/r_n_d/fabricator/mechanic_fab/flatpacker/Gen_Mat_Reqs(var/obj/machinery/machine, var/datum/design/mechanic_design/design)
if(!machine)
message_admins("We couldn't find something in part checking, how did this happen?")
return
if(machine in typesof(/obj/machinery/computer)) //istype does not work. Since it's a path, this does
design.materials["$iron"] += 15000
var/datum/design/circuit_design = FindDesign(design.connected_circuit)
if(circuit_design)
//message_admins("Found the circuit design")
circuit_design = new circuit_design
for(var/matID in circuit_design.materials)
if(copytext(matID,1,2) == "$")
design.materials[matID] += circuit_design.materials[matID]
del(circuit_design)
else
design.materials["$glass"] += 2000
//message_admins("Couldn't find the board")
return 1
var/obj/machinery/test_machine = new machine
//why do we instance?
//because components are generated in New()
design.materials["$iron"] += 15000 //base costs, the best costs
for(var/obj/item/thispart in test_machine.component_parts)
//message_admins("We're trying to find the design for [thispart]")
var/datum/design/part_design = FindDesign(thispart)
if(!part_design)
design.materials["$iron"] += rand(50, 500)
design.materials["$glass"] += rand(20, 300)
continue
//message_admins("We found the design!")
part_design = new part_design
var/list/fetched_materials = part_design.materials
for(var/matID in fetched_materials)
if(copytext(matID,1,2) == "$")
design.materials[matID] += fetched_materials[matID]
del(part_design)
qdel(test_machine)
return 1
/obj/machinery/r_n_d/fabricator/mechanic_fab/flatpacker/attackby(var/obj/item/O as obj, var/mob/user as mob)
..()
if (O.is_open_container())

View File

@@ -31,19 +31,88 @@
connected_circuit = text2path(C.circuit)
if(connected_circuit) //our tech is the circuit's requirement
req_tech = ConvertReqString2List(initial(connected_circuit.origin_tech))
Gen_Mach_Reqs(M.type)
Gen_Tech_Mats(1.5)//consider using M.component_parts.len for this in the future
else if(istype(O, /obj/item))
var/found_design = FindDesign(O)
var/obj/item/I = O
var/found_design = FindDesign(I)
category = "Items"
design_type = "item"
if(found_design)
var/datum/design/D = new found_design
//message_admins("Found the [D]")
category = "Items"
design_type = "item"
req_tech = D.req_tech //our tech is simply the item requirement
materials = D.materials
del(D)
else
req_tech = ConvertReqString2List(I.origin_tech)
Gen_Tech_Mats(1)
if(!category)
category = "Misc"
return src
/datum/design/mechanic_design/proc/Gen_Tech_Mats(var/modifier = 1)
if(modifier < 0) //fuck off
return
var/techtotal = src.TechTotal() / 2
materials["$iron"] = techtotal * round(rand(300, 1500), 100) * modifier
materials["$glass"] = techtotal * round(rand(150, 300), 50) * modifier
materials["$plastic"] = techtotal * 1000 * modifier //pretty much a sheet of plastic per two tech levels
if(prob(techtotal * 15)) //let's add an extra cost of some medium-rare material - sure a lot of items
materials[pick("$plasma", "$uranium", "$gold", "$silver")] = techtotal * round(rand(50, 250), 10) * modifier
if(prob(techtotal * 5))//and another cost, because we can - can proc for some items
materials[pick("$plasma", "$uranium", "$gold", "$silver")] = techtotal * round(rand(50, 250), 10) * modifier
if(techtotal >= 6) //let's add something REALLY rare - bananium and phazon removed for now
materials[/*pick(*/"$diamond"/*, "$clown", "$phazon")*/] = techtotal * round(rand(10, 150), 10) * modifier
//returns the required materials for the parts of a machine design
/datum/design/mechanic_design/proc/Gen_Mach_Reqs(var/obj/machinery/machine)
if(!machine)
message_admins("We couldn't find something in part checking, how did this happen?")
return
materials["$iron"] += 15000 //base costs, the best costs
if(istype(machine, /obj/machinery/computer))
var/datum/design/circuit_design = FindDesign(connected_circuit)
if(circuit_design)
//message_admins("Found the circuit design")
circuit_design = new circuit_design
for(var/matID in circuit_design.materials)
if(copytext(matID,1,2) == "$")
materials[matID] += circuit_design.materials[matID]
del(circuit_design)
else
materials["$glass"] += 2000
//message_admins("Couldn't find the board")
return 1
else
var/obj/machinery/test_machine = new machine
//why do we instance?
//because components are generated in New()
for(var/obj/item/thispart in test_machine.component_parts)
//message_admins("We're trying to find the design for [thispart]")
var/datum/design/part_design = FindDesign(thispart)
if(!part_design)
materials["$iron"] += round(rand(50, 500), 10)
materials["$glass"] += round(rand(20, 300), 10)
continue
//message_admins("We found the design!")
part_design = new part_design
var/list/fetched_materials = part_design.materials
for(var/matID in fetched_materials)
if(copytext(matID,1,2) == "$")
materials[matID] += fetched_materials[matID]
del(part_design)
//gets rid of the instancing
qdel(test_machine)
return 1
proc/ConvertReqString2List(var/list/source_list) //shamelessly ripped from the code for research machines. Shoot me - Comic
var/list/temp_list = params2list(source_list)
for(var/O in temp_list)

View File

@@ -130,42 +130,11 @@
/obj/machinery/r_n_d/fabricator/mechanic_fab/proc/AddMechanicDesign(var/datum/design/mechanic_design/design)
if(istype(design))
if(!design.materials.len)
if(!Gen_Mat_Reqs(design.build_path, design)) //makes the material cost for the design. Weird to have here, I know, but it's the best place
return 0
return 0
add_part_to_set(design.category, design)
return 1
return 0
//returns the required materials for the parts of a machine design
/obj/machinery/r_n_d/fabricator/mechanic_fab/proc/Gen_Mat_Reqs(var/obj/O, var/datum/design/mechanic_design/design)
if(!O)
message_admins("We couldn't find something in part checking, how did this happen?")
return 0
/*
var/datum/design/part_design = FindDesign(O)
if(part_design)
part_design = new part_design
design.materials = part_design.materials
del(part_design)
return 1
*/
if(!design.materials.len)
return 0
return 1
/* Yes, because making diamond sheets out of fucking metal makes sense. - N3X
var/techtotal = TechTotal(design)
design.materials["$iron"] = techtotal * round(rand(500, 1500), 100)
design.materials["$glass"] = techtotal * round(rand(250, 1000), 50)
if(prob(techtotal * 5)) //let's add an extra cost of some medium-rare material
design.materials[pick("$plasma", "$uranium", "$gold", "$silver")] = techtotal * round(rand(100, 500), 10)
if(prob(techtotal * 2)) //and another cost, because we can
design.materials[pick("$plasma", "$uranium", "$gold", "$silver")] = techtotal * round(rand(50, 250), 10)
if(techtotal >= 15 && prob(techtotal)) //let's add something REALLY rare
design.materials[pick("$diamond", "$clown", "$phazon")] = techtotal * round(rand(10, 150), 10)
*/
/obj/machinery/r_n_d/fabricator/mechanic_fab/attackby(var/obj/item/O as obj, var/mob/user as mob)
..()
if (O.is_open_container())

View File

@@ -302,17 +302,17 @@
return
//sum of the required tech of a design
/obj/machinery/r_n_d/proc/TechTotal(var/datum/design/part)
/datum/design/proc/TechTotal()
var/total = 0
for(var/tech in part.req_tech)
total += part.req_tech[tech]
for(var/tech in src.req_tech)
total += src.req_tech[tech]
return total
//sum of the required materials of a design
//do not confuse this with Total_Materials. That gets the machine's materials, this gets design materials
/obj/machinery/r_n_d/proc/MatTotal(var/datum/design/part)
/datum/design/proc/MatTotal()
var/total = 0
for(var/matID in part.materials)
total += part.materials[matID]
for(var/matID in src.materials)
total += src.materials[matID]
//log_admin("[total] for [part.name]")
return total