-Cleaned up sacrificing again so it didn't rely on hasvar()

-Made a variation of hasvar(), creatively named has_var(), intended for objects versus datums, and the var name is case sensitive
-Clean up mech fabricator code considerably, the terrible switches are all gone, and I was able to make it more robust at the same time. Now, if a junk item is added to the mech fab then it will remove it in 1 of 2 places, either when you call for the queue to be displayed (Will throw it out then rebuild the queue) or when it is processing the queue (Will throw it out then reprocess the building), so now you won't even see the shit that finds its way in there.
-Made the add_part_to_set() useful, now instead of dumping everything in the "Exosuit Equipment" category, it checks if the design's category matches one of the part sets, then adds it to said set if it does (All others get dumped into "Misc"). Right now there isn't much through, mostly just moving MMIs, cells, etc... to the "Misc" set, but this would be easy to use with any other system that handles designs
-Little bit of OCD here, but I noticed that the cells on the map were all 'crap' cells, even though they had 1.5x the charge of a high-capacity cell, so I changed them all to high-capacity cells with the added capacity

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4395 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
sieve32@gmail.com
2012-08-13 18:53:28 +00:00
parent f657677a99
commit c62bdf0a6e
5 changed files with 128 additions and 217 deletions

View File

@@ -758,6 +758,10 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl
if(A.vars.Find(lowertext(varname))) return 1
else return 0
/proc/has_var(var/atom/A, var/varname)//Object, non case-sensitive version
if(A.vars.Find(varname)) return 1
else return 0
//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all areas of that type in the world.
/proc/get_areas(var/areatype)

View File

@@ -538,15 +538,18 @@ var/list/sacrificed = list()
var/list/mob/living/carbon/human/cultsinrange = list()
var/list/mob/living/carbon/human/victims = list()
for(var/mob/living/carbon/human/V in src.loc)//Checks for non-cultist humans to sacrifice
if(ishuman(V) || isbrain(V) || issilicon(V))// || istype(V,/obj/item/device/mmi))
if(ishuman(V))
if(!(iscultist(V)))
victims += V//Checks for cult status and mob type
for(var/obj/item/I in src.loc)//Checks for MMIs/brains/Intellicards
if(istype(I,/obj/item/brain) || istype(I,/obj/item/device/mmi))
if(hasvar(I,"brainmob"))//Makes sure it has a brainmob
victims += I:brainmob
if(istype(I,/obj/item/device/aicard))
for(var/mob/living/silicon/ai/A in I)//Because AIs are just stored inside the card and not attached to a var
if(istype(I,/obj/item/brain))
var/obj/item/brain/B = I
victims += B.brainmob
else if(istype(I,/obj/item/device/mmi))
var/obj/item/device/mmi/B = I
victims += B.brainmob
else if(istype(I,/obj/item/device/aicard))
for(var/mob/living/silicon/ai/A in I)
victims += A
for(var/mob/living/carbon/C in orange(1,src))
if(iscultist(C) && !C.stat)

View File

@@ -313,47 +313,10 @@
/obj/machinery/mecha_part_fabricator/proc/output_part_cost(var/obj/item/part)
var/i = 0
var/output
//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects
if(istype(part,/obj/item/robot_parts))
var/obj/item/robot_parts/P = part
for(var/c in P.construction_cost)
if(has_var(part,"construction_time") && has_var(part,"construction_cost"))//The most efficient way to go about this. Not all objects have these vars, but if they don't then they CANNOT be made by the mech fab. Doing it this way reduces a major amount of typecasting and switches, while cutting down maintenece for them as well -Sieve
for(var/c in part:construction_cost)//The has_var should ensure that anything without the var doesn't make it to this point
if(c in resources)
output += "[i?" | ":null][get_resource_cost_w_coeff(P,c)] [c]"
i++
return output
else if(istype(part,/obj/item/mecha_parts))
var/obj/item/mecha_parts/P = part
for(var/c in P.construction_cost)
if(c in resources)
output += "[i?" | ":null][get_resource_cost_w_coeff(P,c)] [c]"
i++
return output
else if(istype(part,/obj/item/borg/upgrade))
var/obj/item/borg/upgrade/P = part
for(var/c in P.construction_cost)
if(c in resources)
output += "[i?" | ":null][get_resource_cost_w_coeff(P,c)] [c]"
i++
return output
else if(istype(part,/obj/item/device/mmi))
var/obj/item/device/mmi/P = part
for(var/c in P.construction_cost)
if(c in resources)
output += "[i?" | ":null][get_resource_cost_w_coeff(P,c)] [c]"
i++
return output
else if(istype(part,/obj/item/device/flash/synthetic))
var/obj/item/device/flash/synthetic/P = part
for(var/c in P.construction_cost)
if(c in resources)
output += "[i?" | ":null][get_resource_cost_w_coeff(P,c)] [c]"
i++
return output
else if(istype(part,/obj/item/weapon/cell))
var/obj/item/weapon/cell/P = part
for(var/c in P.construction_cost)
if(c in resources)
output += "[i?" | ":null][get_resource_cost_w_coeff(P,c)] [c]"
output += "[i?" | ":null][get_resource_cost_w_coeff(part,c)] [c]"
i++
return output
else
@@ -371,82 +334,20 @@
/obj/machinery/mecha_part_fabricator/proc/remove_resources(var/obj/item/part)
//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects
if(istype(part,/obj/item/robot_parts))
var/obj/item/robot_parts/P = part
for(var/resource in P.construction_cost)
if(has_var(part,"construction_time") && has_var(part,"construction_cost"))
for(var/resource in part:construction_cost)
if(resource in src.resources)
src.resources[resource] -= get_resource_cost_w_coeff(P,resource)
else if(istype(part,/obj/item/mecha_parts))
var/obj/item/mecha_parts/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
src.resources[resource] -= get_resource_cost_w_coeff(P,resource)
else if(istype(part,/obj/item/borg/upgrade))
var/obj/item/borg/upgrade/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
src.resources[resource] -= get_resource_cost_w_coeff(P,resource)
else if(istype(part,/obj/item/device/mmi))
var/obj/item/device/mmi/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
src.resources[resource] -= get_resource_cost_w_coeff(P,resource)
else if(istype(part,/obj/item/device/flash/synthetic))
var/obj/item/device/flash/synthetic/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
src.resources[resource] -= get_resource_cost_w_coeff(P,resource)
else if(istype(part,/obj/item/weapon/cell))
var/obj/item/weapon/cell/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
src.resources[resource] -= get_resource_cost_w_coeff(P,resource)
src.resources[resource] -= get_resource_cost_w_coeff(part,resource)
else
return
/obj/machinery/mecha_part_fabricator/proc/check_resources(var/obj/item/part)
// if(istype(part, /obj/item/robot_parts) || istype(part, /obj/item/mecha_parts) || istype(part,/obj/item/borg/upgrade))
//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects
if(istype(part,/obj/item/robot_parts))
var/obj/item/robot_parts/P = part
for(var/resource in P.construction_cost)
if(has_var(part,"construction_time") && has_var(part,"construction_cost"))
for(var/resource in part:construction_cost)
if(resource in src.resources)
if(src.resources[resource] < get_resource_cost_w_coeff(P,resource))
return 0
return 1
else if(istype(part,/obj/item/mecha_parts))
var/obj/item/mecha_parts/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
if(src.resources[resource] < get_resource_cost_w_coeff(P,resource))
return 0
return 1
else if(istype(part,/obj/item/borg/upgrade))
var/obj/item/borg/upgrade/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
if(src.resources[resource] < get_resource_cost_w_coeff(P,resource))
return 0
return 1
else if(istype(part,/obj/item/device/mmi))
var/obj/item/device/mmi/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
if(src.resources[resource] < get_resource_cost_w_coeff(P,resource))
return 0
return 1
else if(istype(part,/obj/item/device/flash/synthetic))
var/obj/item/device/flash/synthetic/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
if(src.resources[resource] < get_resource_cost_w_coeff(P,resource))
return 0
return 1
else if(istype(part,/obj/item/weapon/cell))
var/obj/item/weapon/cell/P = part
for(var/resource in P.construction_cost)
if(resource in src.resources)
if(src.resources[resource] < get_resource_cost_w_coeff(P,resource))
if(src.resources[resource] < get_resource_cost_w_coeff(part,resource))
return 0
return 1
else
@@ -498,6 +399,9 @@
/obj/machinery/mecha_part_fabricator/proc/process_queue()
var/part = listgetindex(src.queue, 1)
if(!(has_var(part,"construction_time")) || !(has_var(part,"construction_cost")))//If it shouldn't be printed
remove_from_queue(1)//Take it out of the quene
return process_queue()//Then reprocess it
temp = null
while(part)
if(stat&(NOPOWER|BROKEN))
@@ -522,7 +426,11 @@
for(var/i=1;i<=queue.len;i++)
var/obj/item/part = listgetindex(src.queue, i)
if(istype(part))
output += "<li[!check_resources(part)?" style='color: #f00;'":null]>[part.name] - [i>1?"<a href='?src=\ref[src];queue_move=-1;index=[i]' class='arrow'>&uarr;</a>":null] [i<queue.len?"<a href='?src=\ref[src];queue_move=+1;index=[i]' class='arrow'>&darr;</a>":null] <a href='?src=\ref[src];remove_from_queue=[i]'>Remove</a></li>"
if(has_var(part,"construction_time") && has_var(part,"construction_cost"))//Prevents junk items from even appearing in the list, and they will be silently removed when the fab processes
output += "<li[!check_resources(part)?" style='color: #f00;'":null]>[part.name] - [i>1?"<a href='?src=\ref[src];queue_move=-1;index=[i]' class='arrow'>&uarr;</a>":null] [i<queue.len?"<a href='?src=\ref[src];queue_move=+1;index=[i]' class='arrow'>&darr;</a>":null] <a href='?src=\ref[src];remove_from_queue=[i]'>Remove</a></li>"
else
remove_from_queue(i)//Trash it
return list_queue()//Rebuild it
output += "</ol>"
output += "\[<a href='?src=\ref[src];process_queue=1'>Process queue</a> | <a href='?src=\ref[src];clear_queue=1'>Clear queue</a>\]"
return output
@@ -532,8 +440,12 @@
var/i = 0
for(var/datum/design/D in files.known_designs)
if(D.build_type&16)
if(add_part_to_set("Exosuit Equipment", text2path(D.build_path)))
i++
if(D.category in part_sets)//Checks if it's a valid category
if(add_part_to_set(D.category, text2path(D.build_path)))//Adds it to said category
i++
else
if(add_part_to_set("Misc", text2path(D.build_path)))//If in doubt, chunk it into the Misc
i++
return i
/obj/machinery/mecha_part_fabricator/proc/update_tech()
@@ -598,47 +510,15 @@
/obj/machinery/mecha_part_fabricator/proc/get_resource_cost_w_coeff(var/obj/item/part as obj,var/resource as text, var/roundto=1)
//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects
if(istype(part,/obj/item/robot_parts))
var/obj/item/robot_parts/P = part
return round(P.construction_cost[resource]*resource_coeff, roundto)
else if(istype(part,/obj/item/mecha_parts))
var/obj/item/mecha_parts/P = part
return round(P.construction_cost[resource]*resource_coeff, roundto)
else if(istype(part,/obj/item/borg/upgrade))
var/obj/item/borg/upgrade/P = part
return round(P.construction_cost[resource]*resource_coeff, roundto)
else if(istype(part,/obj/item/device/mmi))
var/obj/item/device/mmi/P = part
return round(P.construction_cost[resource]*resource_coeff, roundto)
else if(istype(part,/obj/item/device/flash/synthetic))
var/obj/item/device/flash/synthetic/P = part
return round(P.construction_cost[resource]*resource_coeff, roundto)
else if(istype(part,/obj/item/weapon/cell))
var/obj/item/weapon/cell/P = part
return round(P.construction_cost[resource]*resource_coeff, roundto)
if(has_var(part,"construction_time") && has_var(part,"construction_cost"))
return round(part:construction_cost[resource]*resource_coeff, roundto)
else
return 0
/obj/machinery/mecha_part_fabricator/proc/get_construction_time_w_coeff(var/obj/item/part as obj, var/roundto=1)
//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects
if(istype(part,/obj/item/robot_parts))
var/obj/item/robot_parts/P = part
return round(P.construction_time*time_coeff, roundto)
else if(istype(part,/obj/item/mecha_parts))
var/obj/item/mecha_parts/P = part
return round(P.construction_time*time_coeff, roundto)
else if(istype(part,/obj/item/borg/upgrade))
var/obj/item/borg/upgrade/P = part
return round(P.construction_time*time_coeff, roundto)
else if(istype(part,/obj/item/device/mmi))
var/obj/item/device/mmi/P = part
return round(P.construction_time*time_coeff, roundto)
else if(istype(part,/obj/item/device/flash/synthetic))
var/obj/item/device/flash/synthetic/P = part
return round(P.construction_time*time_coeff, roundto)
else if(istype(part,/obj/item/weapon/cell))
var/obj/item/weapon/cell/P = part
return round(P.construction_time*time_coeff, roundto)
if(has_var(part,"construction_time") && has_var(part,"construction_cost"))
return round(part:construction_time*time_coeff, roundto)
else
return 0

View File

@@ -51,6 +51,7 @@ datum/design //Datum for object designs, used in construction
var/list/materials = list() //List of materials. Format: "id" = amount.
var/build_path = "" //The file path of the object that gets created
var/locked = 0 //If true it will spawn inside a lockbox with currently sec access
var/category = null //Primarily used for Mech Fabricators, but can be used for anything
//A proc to calculate the reliability of a design based on tech levels and innate modifiers.
@@ -718,6 +719,7 @@ datum/design/mech_scattershot
build_type = MECHFAB
req_tech = list("combat" = 4)
build_path = "/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/scattershot"
category = "Exosuit Equipment"
datum/design/mech_laser
name = "Exosuit Weapon Design (CH-PS \"Immolator\" Laser)"
@@ -726,6 +728,7 @@ datum/design/mech_laser
build_type = MECHFAB
req_tech = list("combat" = 3, "magnets" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/weapon/energy/laser"
category = "Exosuit Equipment"
datum/design/mech_laser_heavy
name = "Exosuit Weapon Design (CH-LC \"Solaris\" Laser Cannon)"
@@ -734,6 +737,7 @@ datum/design/mech_laser_heavy
build_type = MECHFAB
req_tech = list("combat" = 4, "magnets" = 4)
build_path = "/obj/item/mecha_parts/mecha_equipment/weapon/energy/laser/heavy"
category = "Exosuit Equipment"
datum/design/mech_grenade_launcher
name = "Exosuit Weapon Design (SGL-6 Grenade Launcher)"
@@ -742,6 +746,7 @@ datum/design/mech_grenade_launcher
build_type = MECHFAB
req_tech = list("combat" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack/flashbang"
category = "Exosuit Equipment"
datum/design/mech_wormhole_gen
name = "Exosuit Module Design (Localized Wormhole Generator)"
@@ -750,6 +755,7 @@ datum/design/mech_wormhole_gen
build_type = MECHFAB
req_tech = list("bluespace" = 3, "magnets" = 2)
build_path = "/obj/item/mecha_parts/mecha_equipment/wormhole_generator"
category = "Exosuit Equipment"
datum/design/mech_teleporter
name = "Exosuit Module Design (Teleporter Module)"
@@ -758,6 +764,7 @@ datum/design/mech_teleporter
build_type = MECHFAB
req_tech = list("bluespace" = 10, "magnets" = 5)
build_path = "/obj/item/mecha_parts/mecha_equipment/teleporter"
category = "Exosuit Equipment"
datum/design/mech_rcd
name = "Exosuit Module Design (RCD Module)"
@@ -766,6 +773,7 @@ datum/design/mech_rcd
build_type = MECHFAB
req_tech = list("materials" = 4, "bluespace" = 3, "magnets" = 4, "powerstorage"=4, "engineering" = 4)
build_path = "/obj/item/mecha_parts/mecha_equipment/tool/rcd"
category = "Exosuit Equipment"
datum/design/mech_gravcatapult
name = "Exosuit Module Design (Gravitational Catapult Module)"
@@ -774,6 +782,7 @@ datum/design/mech_gravcatapult
build_type = MECHFAB
req_tech = list("bluespace" = 2, "magnets" = 3, "engineering" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/gravcatapult"
category = "Exosuit Equipment"
datum/design/mech_repair_droid
name = "Exosuit Module Design (Repair Droid Module)"
@@ -782,6 +791,7 @@ datum/design/mech_repair_droid
build_type = MECHFAB
req_tech = list("magnets" = 3, "programming" = 3, "engineering" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/repair_droid"
category = "Exosuit Equipment"
datum/design/mech_plasma_generator
name = "Exosuit Module Design (Plasma Converter Module)"
@@ -790,6 +800,7 @@ datum/design/mech_plasma_generator
build_type = MECHFAB
req_tech = list("plasmatech" = 2, "powerstorage"= 2, "engineering" = 2)
build_path = "/obj/item/mecha_parts/mecha_equipment/plasma_generator"
category = "Exosuit Equipment"
datum/design/mech_energy_relay
name = "Exosuit Module Design (Tesla Energy Relay)"
@@ -798,6 +809,7 @@ datum/design/mech_energy_relay
build_type = MECHFAB
req_tech = list("magnets" = 4, "syndicate" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/tesla_energy_relay"
category = "Exosuit Equipment"
datum/design/mech_ccw_armor
name = "Exosuit Module Design(Reactive Armor Booster Module)"
@@ -806,6 +818,7 @@ datum/design/mech_ccw_armor
build_type = MECHFAB
req_tech = list("materials" = 5, "combat" = 4)
build_path = "/obj/item/mecha_parts/mecha_equipment/anticcw_armor_booster"
category = "Exosuit Equipment"
datum/design/mech_proj_armor
name = "Exosuit Module Design(Reflective Armor Booster Module)"
@@ -814,6 +827,7 @@ datum/design/mech_proj_armor
build_type = MECHFAB
req_tech = list("materials" = 5, "combat" = 5, "engineering"=3)
build_path = "/obj/item/mecha_parts/mecha_equipment/antiproj_armor_booster"
category = "Exosuit Equipment"
datum/design/mech_syringe_gun
name = "Exosuit Module Design(Syringe Gun)"
@@ -822,6 +836,7 @@ datum/design/mech_syringe_gun
build_type = MECHFAB
req_tech = list("materials" = 3, "biotech"=4, "magnets"=4, "programming"=3)
build_path = "/obj/item/mecha_parts/mecha_equipment/tool/syringe_gun"
category = "Exosuit Equipment"
datum/design/mech_diamond_drill
name = "Exosuit Module Design (Diamond Mining Drill)"
@@ -830,6 +845,7 @@ datum/design/mech_diamond_drill
build_type = MECHFAB
req_tech = list("materials" = 4, "engineering" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/tool/drill/diamonddrill"
category = "Exosuit Equipment"
datum/design/mech_generator_nuclear
name = "Exosuit Module Design (ExoNuclear Reactor)"
@@ -838,6 +854,7 @@ datum/design/mech_generator_nuclear
build_type = MECHFAB
req_tech = list("powerstorage"= 3, "engineering" = 3, "materials" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/generator/nuclear"
category = "Exosuit Equipment"
////////////////////////////////////////
@@ -1082,6 +1099,7 @@ datum/design/basic_cell
build_type = PROTOLATHE | AUTOLATHE |MECHFAB
materials = list("$metal" = 700, "$glass" = 50)
build_path = "/obj/item/weapon/cell"
category = "Misc"
datum/design/high_cell
name = "High-Capacity Power Cell"
@@ -1091,6 +1109,7 @@ datum/design/high_cell
build_type = PROTOLATHE | AUTOLATHE | MECHFAB
materials = list("$metal" = 700, "$glass" = 60)
build_path = "/obj/item/weapon/cell/high"
category = "Misc"
datum/design/super_cell
name = "Super-Capacity Power Cell"
@@ -1101,6 +1120,7 @@ datum/design/super_cell
build_type = PROTOLATHE | MECHFAB
materials = list("$metal" = 700, "$glass" = 70)
build_path = "/obj/item/weapon/cell/super"
category = "Misc"
datum/design/hyper_cell
name = "Hyper-Capacity Power Cell"
@@ -1111,6 +1131,7 @@ datum/design/hyper_cell
build_type = PROTOLATHE | MECHFAB
materials = list("$metal" = 400, "$gold" = 150, "$silver" = 150, "$glass" = 70)
build_path = "/obj/item/weapon/cell/hyper"
category = "Misc"
datum/design/light_replacer
name = "Light Replacer"
@@ -1257,6 +1278,7 @@ datum/design/mmi
materials = list("$metal" = 1000, "$glass" = 500)
reliability_base = 76
build_path = "/obj/item/device/mmi"
category = "Misc"
datum/design/mmi_radio
name = "Radio-enabled Man-Machine Interface"
@@ -1267,6 +1289,7 @@ datum/design/mmi_radio
materials = list("$metal" = 1200, "$glass" = 500)
reliability_base = 74
build_path = "/obj/item/device/mmi/radio_enabled"
category = "Misc"
datum/design/synthetic_flash
name = "Synthetic Flash"
@@ -1277,6 +1300,7 @@ datum/design/synthetic_flash
materials = list("$metal" = 750, "$glass" = 750)
reliability_base = 76
build_path = "/obj/item/device/flash/synthetic"
category = "Misc"
/////////////////////////////////////////
/////////////////Weapons/////////////////