Mitigates (autolathe) recycling exploits by minimizing what can be recycled, adding unit tests and fixing the recipes (#10375)

* Mitigates research recycling exploits by minimizing what can be recycled

* Moves the research design check into a new unit test

* Adds unit test for stack material recipes costs and fixes these costs

* Instead of changing recipes the resulting materials are worth less

* Crap fix
This commit is contained in:
Jiří Barouš
2020-10-30 12:20:59 +01:00
committed by GitHub
parent 821d790332
commit 524bf9c417
32 changed files with 205 additions and 81 deletions
+1 -2
View File
@@ -12,5 +12,4 @@
throw_speed = 3
matter = list(DEFAULT_WALL_MATERIAL = 50, MATERIAL_GLASS = 20)
origin_tech = list(TECH_MAGNET = 1, TECH_ENGINEERING = 1)
origin_tech = list(TECH_MAGNET = 1, TECH_ENGINEERING = 1)
+1
View File
@@ -5,6 +5,7 @@
icon_state = "jar_lid"
w_class = ITEMSIZE_SMALL
matter = list(MATERIAL_GLASS = 200)
recyclable = TRUE
flags = NOBLUDGEON
var/list/accept_mobs = list(/mob/living/simple_animal/lizard, /mob/living/simple_animal/rat)
var/contains = 0 // 0 = nothing, 1 = money, 2 = animal, 3 = spiderling
+2 -1
View File
@@ -29,7 +29,8 @@ var/global/list/datum/stack_recipe/rod_recipes = list(
throw_range = 20
drop_sound = 'sound/items/drop/metalweapon.ogg'
pickup_sound = 'sound/items/pickup/metalweapon.ogg'
matter = list(DEFAULT_WALL_MATERIAL = 1875)
matter = list(DEFAULT_WALL_MATERIAL = 937.5)
recyclable = TRUE
max_amount = 60
attack_verb = list("hit", "bludgeoned", "whacked")
lock_picking_level = 3
+26 -18
View File
@@ -155,23 +155,7 @@
return
if (use(required))
var/atom/O
if(recipe.use_material)
O = new recipe.result_type(user.loc, recipe.use_material)
else
O = new recipe.result_type(user.loc)
O.set_dir(user.dir)
O.add_fingerprint(user)
if (istype(O, /obj/item/stack))
var/obj/item/stack/S = O
S.amount = produced
S.update_icon()
S.add_to_stacks(user)
if (istype(O, /obj/item/storage)) //BubbleWrap - so newly formed boxes are empty
for (var/obj/item/I in O)
qdel(I)
recipe.Produce(produced, user.loc, user.dir, user)
/obj/item/stack/Topic(href, href_list)
..()
@@ -388,6 +372,30 @@
src.on_floor = on_floor
src.use_material = supplied_material
/datum/stack_recipe/proc/Produce(var/amount = 1, var/loc = null, var/dir = NORTH, var/user = null)
if(amount < 1)
return null
var/atom/O
if(use_material)
O = new result_type(loc, use_material)
else
O = new result_type(loc)
O.set_dir(dir)
O.add_fingerprint(user)
if (istype(O, /obj/item/stack))
var/obj/item/stack/S = O
S.amount = amount
S.update_icon()
if(user)
S.add_to_stacks(user)
if (istype(O, /obj/item/storage)) //BubbleWrap - so newly formed boxes are empty
for (var/obj/item/I in O)
qdel(I)
return O
/*
* Recipe list datum
*/
@@ -397,4 +405,4 @@
/datum/stack_recipe_list/New(new_title, new_recipes)
src.title = new_title
src.recipes = new_recipes
src.recipes = new_recipes
@@ -6,12 +6,15 @@
* Carpet
*/
#define TILE_MATERIAL_AMOUNT 468
/obj/item/stack/tile
name = "tile"
singular_name = "tile"
desc = "A non-descript floor tile"
w_class = ITEMSIZE_NORMAL
max_amount = 60
recyclable = TRUE
icon = 'icons/obj/stacks/tiles.dmi'
item_icons = list(
slot_l_hand_str = 'icons/mob/items/stacks/lefthand_tiles.dmi',
@@ -139,7 +142,7 @@
flags = 0
drop_sound = 'sound/items/drop/cloth.ogg'
pickup_sound = 'sound/items/pickup/cloth.ogg'
matter = list(MATERIAL_PLASTIC = 937.5)
matter = list(MATERIAL_PLASTIC = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/lino_grey
name = "linoleum"
@@ -153,7 +156,7 @@
flags = 0
drop_sound = 'sound/items/drop/cloth.ogg'
pickup_sound = 'sound/items/pickup/cloth.ogg'
matter = list(MATERIAL_PLASTIC = 937.5)
matter = list(MATERIAL_PLASTIC = TILE_MATERIAL_AMOUNT)
/*
* Circuits
@@ -165,7 +168,7 @@
desc = "An advanced tile covered in various circuitry and wiring."
icon_state = "tile_bcircuit"
force = 6.0
matter = list(DEFAULT_WALL_MATERIAL = 937.5, MATERIAL_GLASS = 937.5)
matter = list(DEFAULT_WALL_MATERIAL = TILE_MATERIAL_AMOUNT, MATERIAL_GLASS = TILE_MATERIAL_AMOUNT)
throwforce = 15.0
throw_speed = 5
throw_range = 20
@@ -177,7 +180,7 @@
desc = "An advanced tile covered in various circuitry and wiring."
icon_state = "tile_gcircuit"
force = 6.0
matter = list(DEFAULT_WALL_MATERIAL = 937.5, MATERIAL_GLASS = 937.5)
matter = list(DEFAULT_WALL_MATERIAL = TILE_MATERIAL_AMOUNT, MATERIAL_GLASS = TILE_MATERIAL_AMOUNT)
throwforce = 15.0
throw_speed = 5
throw_range = 20
@@ -193,7 +196,7 @@
desc = "Those could work as a pretty decent throwing weapon" //why?
icon_state = "tile"
force = 6.0
matter = list(DEFAULT_WALL_MATERIAL = 937.5)
matter = list(DEFAULT_WALL_MATERIAL = TILE_MATERIAL_AMOUNT)
throwforce = 15.0
throw_speed = 5
throw_range = 20
@@ -209,13 +212,13 @@
name = "steel floor tile"
singular_name = "steel floor tile"
icon_state = "tile_steel"
matter = list(MATERIAL_PLASTEEL = 937.5)
matter = list(MATERIAL_PLASTEEL = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/floor_white
name = "white floor tile"
singular_name = "white floor tile"
icon_state = "tile_white"
matter = list(MATERIAL_PLASTIC = 937.5)
matter = list(MATERIAL_PLASTIC = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/floor_yellow
name = "yellow floor tile"
@@ -227,43 +230,43 @@
name = "dark floor tile"
singular_name = "dark floor tile"
icon_state = "fr_tile"
matter = list(MATERIAL_PLASTEEL = 937.5)
matter = list(MATERIAL_PLASTEEL = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/floor_freezer
name = "freezer floor tile"
singular_name = "freezer floor tile"
icon_state = "tile_freezer"
matter = list(MATERIAL_PLASTIC = 937.5)
matter = list(MATERIAL_PLASTIC = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/silver
name = "silver floor tile"
singular_name = "silver floor tile"
icon_state = "tile_silver"
matter = list(MATERIAL_SILVER = 937.5)
matter = list(MATERIAL_SILVER = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/gold
name = "golden floor tile"
singular_name = "golden floor tile"
icon_state = "tile_gold"
matter = list(MATERIAL_GOLD = 937.5)
matter = list(MATERIAL_GOLD = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/uranium
name = "uranium floor tile"
singular_name = "uranium floor tile"
icon_state = "tile_uranium"
matter = list(MATERIAL_URANIUM = 937.5)
matter = list(MATERIAL_URANIUM = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/phoron
name = "phoron floor tile"
singular_name = "phoron floor tile"
icon_state = "tile_plasma"
matter = list(MATERIAL_PHORON = 937.5)
matter = list(MATERIAL_PHORON = TILE_MATERIAL_AMOUNT)
/obj/item/stack/tile/diamond
name = "diamond floor tile"
singular_name = "diamond floor tile"
icon_state = "tile_diamond"
matter = list(MATERIAL_DIAMOND = 937.5)
matter = list(MATERIAL_DIAMOND = TILE_MATERIAL_AMOUNT)
/*
* Cyborg modules
@@ -320,3 +323,5 @@
charge_costs = list(250)
stacktype = /obj/item/stack/tile/carpet
build_type = /obj/item/stack/tile/carpet
#undef TILE_MATERIAL_AMOUNT
+2 -1
View File
@@ -141,7 +141,8 @@
item_state = "rfdammo"
w_class = ITEMSIZE_SMALL
origin_tech = list(TECH_MATERIAL = 2)
matter = list(DEFAULT_WALL_MATERIAL = 30000, MATERIAL_GLASS = 15000)
matter = list(DEFAULT_WALL_MATERIAL = 2000, MATERIAL_GLASS = 2000)
recyclable = TRUE
/*
RFD Construction-Class
@@ -12,6 +12,7 @@
throw_range = 5
origin_tech = list(TECH_MATERIAL = 1)
matter = list(DEFAULT_WALL_MATERIAL = 500)
recyclable = TRUE
var/elastic
var/dispenser = 0
var/breakouttime = 1200 //Deciseconds = 120s = 2 minutes
@@ -8,6 +8,7 @@
randpixel = 8
sharp = 1
edge = 1
recyclable = TRUE
w_class = ITEMSIZE_SMALL
force_divisor = 0.2 // 6 with hardness 30 (glass)
thrown_force_divisor = 0.4 // 4 with weight 15 (glass)
@@ -15,6 +15,7 @@
var/rigged = 0 // true if rigged to explode
var/minor_fault = 0 //If not 100% reliable, it will build up faults.
matter = list(DEFAULT_WALL_MATERIAL = 700, MATERIAL_GLASS = 50)
recyclable = TRUE
//currently only used by energy-type guns, that may change in the future.
/obj/item/cell/device
@@ -94,7 +95,7 @@
origin_tech = list(TECH_POWER = 6)
icon_state = "hpcell"
maxcharge = 30000
matter = list(DEFAULT_WALL_MATERIAL = 700, MATERIAL_GLASS = 80)
matter = list(DEFAULT_WALL_MATERIAL = 200, MATERIAL_GOLD = 50, MATERIAL_SILVER = 50, MATERIAL_GLASS = 40)
/obj/item/cell/hyper/empty/Initialize()
. = ..()
@@ -37,6 +37,7 @@
slot_r_hand_str = 'icons/mob/items/weapons/righthand_shield.dmi'
)
var/base_block_chance = 50
recyclable = TRUE
/obj/item/shield/handle_shield(mob/user, var/on_back, var/damage, atom/damage_source = null, mob/attacker = null, var/def_zone = null, var/attack_text = "the attack")
if(user.incapacitated())
@@ -8,7 +8,7 @@
* Circular Saw
* Tray
*/
/obj/item/surgery/
/obj/item/surgery
name = "surgery tool"
desc = "hey, you aren't supposed to have this"
icon = 'icons/obj/surgery.dmi'
@@ -19,6 +19,7 @@
slot_l_hand_str = 'icons/mob/items/lefthand_medical.dmi',
slot_r_hand_str = 'icons/mob/items/righthand_medical.dmi',
)
recyclable = TRUE
/*
* Retractor
@@ -140,7 +140,7 @@ Frequency:
/obj/item/hand_tele/Initialize()
. = ..()
if(ismob(loc) || ismob(loc.loc))
if(get(loc, /mob))
maptext = held_maptext
/obj/item/hand_tele/attack_self(mob/user)