Fixed stacks sometimes having the wrong amount if created on another stack

This commit is contained in:
Tad Hardesty
2018-05-10 23:23:51 -07:00
committed by letterjay
parent 20ac9089a7
commit 021f30f0c0
24 changed files with 174 additions and 112 deletions
+1 -2
View File
@@ -104,8 +104,7 @@
to_chat(user, "<span class='warning'>There is another network terminal here!</span>")
return
else
var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(T)
C.amount = 10
new /obj/item/stack/cable_coil(T, 10)
to_chat(user, "<span class='notice'>You cut the cables and disassemble the unused power terminal.</span>")
qdel(E)
return TRUE
@@ -211,10 +211,9 @@ GLOBAL_LIST_INIT(sinew_recipes, list ( \
if(W.is_sharp())
playsound(loc, 'sound/weapons/slice.ogg', 50, 1, -1)
user.visible_message("[user] starts cutting hair off \the [src].", "<span class='notice'>You start cutting the hair off \the [src]...</span>", "<span class='italics'>You hear the sound of a knife rubbing against flesh.</span>")
if(do_after(user,50, target = src))
if(do_after(user, 50, target = src))
to_chat(user, "<span class='notice'>You cut the hair from this [src.singular_name].</span>")
var/obj/item/stack/sheet/hairlesshide/HS = new(user.loc)
HS.amount = 1
new /obj/item/stack/sheet/hairlesshide(user.drop_location(), 1)
use(1)
else
return ..()
@@ -228,21 +227,11 @@ GLOBAL_LIST_INIT(sinew_recipes, list ( \
if(exposed_temperature >= drying_threshold_temperature)
wetness--
if(wetness == 0)
//Try locating an exisitng stack on the tile and add to there if possible
for(var/obj/item/stack/sheet/leather/HS in src.loc)
if(HS.amount < 50)
HS.amount++
src.use(1)
wetness = initial(wetness)
break
//If it gets to here it means it did not find a suitable stack on the tile.
var/obj/item/stack/sheet/leather/HS = new(src.loc)
HS.amount = 1
new /obj/item/stack/sheet/leather(drop_location(), 1)
wetness = initial(wetness)
src.use(1)
use(1)
/obj/item/stack/sheet/wetleather/microwave_act(obj/machinery/microwave/MW)
..()
var/obj/item/stack/sheet/leather/L = new(loc)
L.amount = amount
new /obj/item/stack/sheet/leather(drop_location(), amount)
qdel(src)
@@ -14,13 +14,12 @@
grind_results = list("silicon" = 20, "copper" = 5)
/obj/item/stack/light_w/attackby(obj/item/O, mob/user, params)
var/atom/Tsec = user.drop_location()
if(istype(O, /obj/item/wirecutters))
var/obj/item/stack/cable_coil/CC = new (user.loc)
CC.amount = 5
var/obj/item/stack/cable_coil/CC = new (Tsec, 5)
CC.add_fingerprint(user)
amount--
var/obj/item/stack/sheet/glass/G = new (user.loc)
var/obj/item/stack/sheet/glass/G = new (Tsec)
G.add_fingerprint(user)
if(amount <= 0)
qdel(src)
@@ -28,7 +27,6 @@
else if(istype(O, /obj/item/stack/sheet/metal))
var/obj/item/stack/sheet/metal/M = O
if (M.use(1))
use(1)
var/obj/item/L = new /obj/item/stack/tile/light(user.loc)
to_chat(user, "<span class='notice'>You make a light tile.</span>")
L.add_fingerprint(user)
@@ -121,6 +121,9 @@ GLOBAL_LIST_INIT(metal_recipes, list ( \
/obj/item/stack/sheet/metal/twenty
amount = 20
/obj/item/stack/sheet/metal/ten
amount = 10
/obj/item/stack/sheet/metal/five
amount = 5
+5 -2
View File
@@ -33,10 +33,13 @@
return
return TRUE
/obj/item/stack/Initialize(mapload, new_amount=null , merge = TRUE)
/obj/item/stack/Initialize(mapload, new_amount, merge = TRUE)
. = ..()
if(new_amount)
if(new_amount != null)
amount = new_amount
while(amount > max_amount)
amount -= max_amount
new type(loc, max_amount, FALSE)
if(!merge_type)
merge_type = type
if(merge)
+1 -2
View File
@@ -147,8 +147,7 @@
to_chat(user, "<span class='notice'>You remove the cables.</span>")
state = SCREWED_CORE
update_icon()
var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc )
A.amount = 5
new /obj/item/stack/cable_coil(drop_location(), 5)
return
if(istype(P, /obj/item/stack/sheet/rglass))
@@ -1,3 +1,4 @@
<<<<<<< HEAD
/obj/structure/closet/syndicate
name = "armory closet"
desc = "Why is this here?"
@@ -113,3 +114,120 @@
for(var/res in resources)
var/obj/item/stack/R = new res(src)
R.amount = R.max_amount
=======
/obj/structure/closet/syndicate
name = "armory closet"
desc = "Why is this here?"
icon_state = "syndicate"
/obj/structure/closet/syndicate/personal
desc = "It's a personal storage unit for operative gear."
/obj/structure/closet/syndicate/personal/PopulateContents()
..()
new /obj/item/clothing/under/syndicate(src)
new /obj/item/clothing/shoes/sneakers/black(src)
new /obj/item/radio/headset/syndicate(src)
new /obj/item/ammo_box/magazine/m10mm(src)
new /obj/item/storage/belt/military(src)
new /obj/item/crowbar/red(src)
new /obj/item/clothing/glasses/night(src)
/obj/structure/closet/syndicate/nuclear
desc = "It's a storage unit for a Syndicate boarding party."
/obj/structure/closet/syndicate/nuclear/PopulateContents()
for(var/i in 1 to 5)
new /obj/item/ammo_box/magazine/m10mm(src)
new /obj/item/storage/box/flashbangs(src)
new /obj/item/storage/box/teargas(src)
new /obj/item/storage/backpack/duffelbag/syndie/med(src)
new /obj/item/pda/syndicate(src)
/obj/structure/closet/syndicate/resources
desc = "An old, dusty locker."
/obj/structure/closet/syndicate/resources/PopulateContents()
..()
var/common_min = 30 //Minimum amount of minerals in the stack for common minerals
var/common_max = 50 //Maximum amount of HONK in the stack for HONK common minerals
var/rare_min = 5 //Minimum HONK of HONK in the stack HONK HONK rare minerals
var/rare_max = 20 //Maximum HONK HONK HONK in the HONK for HONK rare HONK
var/pickednum = rand(1, 50)
//Sad trombone
if(pickednum == 1)
var/obj/item/paper/P = new /obj/item/paper(src)
P.name = "\improper IOU"
P.info = "Sorry man, we needed the money so we sold your stash. It's ok, we'll double our money for sure this time!"
//Metal (common ore)
if(pickednum >= 2)
new /obj/item/stack/sheet/metal(src, rand(common_min, common_max))
//Glass (common ore)
if(pickednum >= 5)
new /obj/item/stack/sheet/glass(src, rand(common_min, common_max))
//Plasteel (common ore) Because it has a million more uses then plasma
if(pickednum >= 10)
new /obj/item/stack/sheet/plasteel(src, rand(common_min, common_max))
//Plasma (rare ore)
if(pickednum >= 15)
new /obj/item/stack/sheet/mineral/plasma(src, rand(rare_min, rare_max))
//Silver (rare ore)
if(pickednum >= 20)
new /obj/item/stack/sheet/mineral/silver(src, rand(rare_min, rare_max))
//Gold (rare ore)
if(pickednum >= 30)
new /obj/item/stack/sheet/mineral/gold(src, rand(rare_min, rare_max))
//Uranium (rare ore)
if(pickednum >= 40)
new /obj/item/stack/sheet/mineral/uranium(src, rand(rare_min, rare_max))
//Titanium (rare ore)
if(pickednum >= 40)
new /obj/item/stack/sheet/mineral/titanium(src, rand(rare_min, rare_max))
//Plastitanium (rare ore)
if(pickednum >= 40)
new /obj/item/stack/sheet/mineral/plastitanium(src, rand(rare_min, rare_max))
//Diamond (rare HONK)
if(pickednum >= 45)
new /obj/item/stack/sheet/mineral/diamond(src, rand(rare_min, rare_max))
//Jetpack (You hit the jackpot!)
if(pickednum == 50)
new /obj/item/tank/jetpack/carbondioxide(src)
/obj/structure/closet/syndicate/resources/everything
desc = "It's an emergency storage closet for repairs."
/obj/structure/closet/syndicate/resources/everything/PopulateContents()
var/list/resources = list(
/obj/item/stack/sheet/metal,
/obj/item/stack/sheet/glass,
/obj/item/stack/sheet/mineral/gold,
/obj/item/stack/sheet/mineral/silver,
/obj/item/stack/sheet/mineral/plasma,
/obj/item/stack/sheet/mineral/uranium,
/obj/item/stack/sheet/mineral/diamond,
/obj/item/stack/sheet/mineral/bananium,
/obj/item/stack/sheet/plasteel,
/obj/item/stack/sheet/mineral/titanium,
/obj/item/stack/sheet/mineral/plastitanium,
/obj/item/stack/rods
)
for(var/i = 0, i<2, i++)
for(var/res in resources)
var/obj/item/stack/R = res
new res(src, initial(R.max_amount))
>>>>>>> e8304c1... Merge pull request #37760 from YPOQ/stackfix