Make stack amount var private

This commit is contained in:
Chompstation Bot
2021-08-26 15:39:04 +00:00
parent 145f8172f4
commit af0d7a0f6b
72 changed files with 935 additions and 287 deletions

View File

@@ -238,9 +238,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(stored_material[material_name] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(min(ejected, amount)))
return
stored_material[material_name] -= ejected * S.perunit
if(recursive && stored_material[material_name] >= S.perunit)
@@ -256,7 +254,7 @@
var/max_res_amount = storage_capacity[S.material.name]
if(stored_material[S.material.name] + S.perunit <= max_res_amount)
var/count = 0
while(stored_material[S.material.name] + S.perunit <= max_res_amount && S.amount >= 1)
while(stored_material[S.material.name] + S.perunit <= max_res_amount && S.get_amount() >= 1)
stored_material[S.material.name] += S.perunit
S.use(1)
count++

View File

@@ -135,7 +135,7 @@
LAZYADDASSOCLIST(.["instances"], item.type, item)
if(istype(item, /obj/item/stack))
var/obj/item/stack/stack = item
.["other"][item.type] += stack.amount
.["other"][item.type] += stack.get_amount()
else if(item.tool_qualities)
.["tool_qualities"] |= item.tool_qualities
.["other"][item.type] += 1
@@ -297,20 +297,20 @@
var/obj/item/stack/SD
while(amt > 0)
S = locate(path_key) in surroundings
if(S.amount >= amt)
if(S.get_amount() >= amt)
if(!locate(S.type) in Deletion)
SD = new S.type()
Deletion += SD
S.use(amt)
SD = locate(S.type) in Deletion
SD.amount += amt
SD.add(amt)
continue main_loop
else
amt -= S.amount
amt -= S.get_amount()
if(!locate(S.type) in Deletion)
Deletion += S
else
data = S.amount
data = S.get_amount()
S = locate(S.type) in Deletion
S.add(data)
surroundings -= S
@@ -334,8 +334,8 @@
continue
else if(istype(part, /obj/item/stack))
var/obj/item/stack/ST = locate(part) in Deletion
if(ST.amount > partlist[part])
ST.amount = partlist[part]
if(ST.get_amount() > partlist[part])
ST.set_amount(partlist[part])
. += ST
Deletion -= ST
continue

View File

@@ -70,7 +70,7 @@
if(.)
var/obj/item/stack/S = product
if(istype(S))
amount += S.amount
amount += S.get_amount()
/datum/stored_item/stack/get_product(var/product_location, var/count)
if(!LAZYLEN(instances))

View File

@@ -9,8 +9,7 @@
var/on = 0
/obj/machinery/cablelayer/New()
cable = new(src)
cable.amount = 100
cable = new(src, 100)
..()
/obj/machinery/cablelayer/Moved(atom/old_loc, direction, forced = FALSE)
@@ -36,32 +35,32 @@
return
if(O.is_wirecutter())
if(cable && cable.amount)
var/m = round(input(usr,"Please specify the length of cable to cut","Cut cable",min(cable.amount,30)) as num, 1)
m = min(m, cable.amount)
if(cable && cable.get_amount())
var/m = round(input(usr, "Please specify the length of cable to cut", "Cut cable", min(cable.get_amount(), 30)) as num, 1)
m = min(m, cable.get_amount())
m = min(m, 30)
if(m)
playsound(src, O.usesound, 50, 1)
use_cable(m)
var/obj/item/stack/cable_coil/CC = new (get_turf(src))
CC.amount = m
CC.set_amount(m)
else
to_chat(usr, "<span class='warning'>There's no more cable on the reel.</span>")
/obj/machinery/cablelayer/examine(mob/user)
. = ..()
. += "[src]'s cable reel has [cable.amount] length\s left."
. += "[src]'s cable reel has [cable.get_amount()] length\s left."
/obj/machinery/cablelayer/proc/load_cable(var/obj/item/stack/cable_coil/CC)
if(istype(CC) && CC.amount)
var/cur_amount = cable? cable.amount : 0
if(istype(CC) && CC.get_amount())
var/cur_amount = cable ? cable.get_amount() : 0
var/to_load = max(max_cable - cur_amount,0)
if(to_load)
to_load = min(CC.amount, to_load)
to_load = min(CC.get_amount(), to_load)
if(!cable)
cable = new(src)
cable.amount = 0
cable.amount += to_load
cable = new(src, to_load)
else
cable.add(to_load)
CC.use(to_load)
return to_load
else
@@ -69,7 +68,7 @@
return
/obj/machinery/cablelayer/proc/use_cable(amount)
if(!cable || cable.amount<1)
if(!cable || cable.get_amount() < 1)
visible_message("A red light flashes on \the [src].")
return
cable.use(amount)

View File

@@ -223,7 +223,7 @@
if(multiplier > 1)
if(istype(I, /obj/item/stack))
var/obj/item/stack/S = I
S.amount = multiplier
S.set_amount(multiplier)
else
for(multiplier; multiplier > 1; --multiplier) // Create multiple items if it's not a stack.
I = new making.path(src.loc)

View File

@@ -183,8 +183,7 @@
points -= cost
if(ispath(bi.equipment_path, /obj/item/stack))
var/obj/item/stack/S = new bi.equipment_path(loc)
S.amount = bi.equipment_amt
new bi.equipment_path(loc, bi.equipment_amt)
playsound(src, 'sound/machines/vending/vending_drop.ogg', 100, 1)
return TRUE

View File

@@ -1,3 +1,4 @@
<<<<<<< HEAD:code/game/machinery/casino_prize_dispenser_ch.dm
// Use this define to register a prize!
// * n - The proper name of the purchasable
// * o - The object type path of the purchasable to spawn
@@ -354,5 +355,615 @@
return
/obj/machinery/casino_prize_dispenser/process() //Might not need this, but just to be safe for now
if(stat & (BROKEN|NOPOWER))
||||||| parent of e5c108269d... Merge pull request #11454 from VOREStation/Arokha/stacks:code/modules/casino/casino_prize_vendor.dm
//Original Casino Code created by Shadowfire117#1269 - Ported from CHOMPstation
//Modified by GhostActual#2055 for use with VOREstation
// Use this define to register a prize!
// * n - The proper name of the purchasable
// * o - The object type path of the purchasable to spawn
// * r - The amount to dispense
// * p - The price of the purchasable in chips
// * l - The restriction of the item
#define CASINO_PRIZE(n, o, r, p, l) n = new /datum/data/casino_prize(n, o, r, p, l)
/datum/data/casino_prize
var/equipment_path = null
var/equipment_amt = 1
var/cost = 0
var/category = null
var/restriction = null
/datum/data/casino_prize/New(name, path, amt, cost, restriction)
src.name = name
src.equipment_path = path
src.equipment_amt = amt
src.cost = cost
src.category = category
src.restriction = restriction
/obj/machinery/casino_prize_dispenser
name = "Casino Prize Exchanger"
desc = "Exchange your chips to obtain wonderful prizes! Hoepfully you'll get to keep some of them for a while."
icon = 'icons/obj/casino.dmi'
icon_state ="casino_prize_dispenser"
var/icon_vend ="casino_prize_dispenser-vend"
anchored = 1
density = 1
opacity = 0
var/list/item_list
clicksound = "button"
var/vending_sound = "machines/vending/vending_drop.ogg"
// Power
use_power = USE_POWER_IDLE
idle_power_usage = 10
var/vend_power_usage = 150 //actuators and stuff
// Vending-related
var/datum/data/casino_prize/currently_vending = null // What we're requesting payment for right now
var/list/log = list() //Log only SS13 staff is allowed to look at, CKEYS are listed here for record keeping of prizes and players for events!
var/category_weapons = 1 //For listing categories, if false then prizes of this categories cant be obtained nor bought for post-shift enjoyment
var/category_gear = 1 //If 1 prizes will be only logged
var/category_clothing = 1 //If 2 prizes will both be logged and spawned
var/category_misc = 1
var/category_drinks = 1
var/category_implants = 1
var/category_event = 1 //For special events, holidays, etc
/obj/machinery/casino_prize_dispenser/Initialize()
. = ..()
power_change()
item_list = list()
item_list["Weapons"] = list(
CASINO_PRIZE("Scepter", /obj/item/weapon/scepter, 1, 500, "weapons"),
CASINO_PRIZE("Chain of Command", /obj/item/weapon/melee/chainofcommand, 1, 250, "weapons"),
CASINO_PRIZE("Size Gun", /obj/item/weapon/gun/energy/sizegun, 1, 100, "weapons"),
CASINO_PRIZE("Advanced Particle Rifle", /obj/item/weapon/gun/energy/particle/advanced, 1, 500, "weapons"),
CASINO_PRIZE("Temperature Gun", /obj/item/weapon/gun/energy/temperature, 1, 250, "weapons"),
CASINO_PRIZE("Alien Pistol", /obj/item/weapon/gun/energy/alien, 1, 1000, "weapons"),
CASINO_PRIZE("Floral Gun", /obj/item/weapon/gun/energy/floragun, 1, 250, "weapons"),
CASINO_PRIZE("Net Gun", /obj/item/weapon/gun/energy/netgun, 1, 500, "weapons"),
)
item_list["Gear"] = list(
CASINO_PRIZE("Experimental Welder", /obj/item/weapon/weldingtool/experimental, 1, 500, "gear"),
CASINO_PRIZE("Chameleon Tie", /obj/item/clothing/accessory/chameleon, 1, 250, "gear"),
CASINO_PRIZE("Chemsprayer", /obj/item/weapon/reagent_containers/spray/chemsprayer, 1, 250, "gear"),
CASINO_PRIZE("Bluespace Beaker", /obj/item/weapon/reagent_containers/glass/beaker/bluespace, 1, 200, "gear"),
CASINO_PRIZE("Cryo Beaker", /obj/item/weapon/reagent_containers/glass/beaker/noreact, 1, 200, "gear"),
)
item_list["Clothing"] = list(
CASINO_PRIZE("Shark mask", /obj/item/clothing/mask/shark, 1, 50, "clothing"),
CASINO_PRIZE("Pig mask", /obj/item/clothing/mask/pig, 1, 50, "clothing"),
CASINO_PRIZE("Luchador mask", /obj/item/clothing/mask/luchador, 1, 50, "clothing"),
CASINO_PRIZE("Horse mask", /obj/item/clothing/mask/horsehead, 1, 50, "clothing"),
CASINO_PRIZE("Goblin mask", /obj/item/clothing/mask/goblin, 1, 50, "clothing"),
CASINO_PRIZE("Fake moustache", /obj/item/clothing/mask/fakemoustache, 1, 50, "clothing"),
CASINO_PRIZE("Dolphin mask", /obj/item/clothing/mask/dolphin, 1, 50, "clothing"),
CASINO_PRIZE("Demon mask", /obj/item/clothing/mask/demon, 1, 50, "clothing"),
CASINO_PRIZE("Chameleon mask", /obj/item/clothing/under/chameleon, 1, 250, "clothing"),
CASINO_PRIZE("Ian costume", /obj/item/clothing/suit/storage/hooded/ian_costume, 1, 50, "clothing"),
CASINO_PRIZE("Carp costume", /obj/item/clothing/suit/storage/hooded/carp_costume, 1, 50, "clothing"),
)
item_list["Miscellaneous"] = list(
CASINO_PRIZE("Toy sword", /obj/item/toy/sword, 1, 50, "misc"),
CASINO_PRIZE("Waterflower", /obj/item/weapon/reagent_containers/spray/waterflower, 1, 50, "misc"),
CASINO_PRIZE("Horse stick", /obj/item/toy/stickhorse, 1, 50, "misc"),
CASINO_PRIZE("Katana", /obj/item/toy/katana, 1, 50, "misc"),
CASINO_PRIZE("Conch", /obj/item/toy/eight_ball/conch, 1, 50, "misc"),
CASINO_PRIZE("Eight ball", /obj/item/toy/eight_ball, 1, 50, "misc"),
CASINO_PRIZE("Foam sword", /obj/item/weapon/material/sword/foam, 1, 50, "misc"),
CASINO_PRIZE("Whistle", /obj/item/toy/bosunwhistle, 1, 50, "misc"),
CASINO_PRIZE("Golden cup", /obj/item/weapon/reagent_containers/food/drinks/golden_cup, 1, 50, "misc"),
CASINO_PRIZE("Quality cigars", /obj/item/weapon/storage/fancy/cigar/havana, 1, 50, "misc"),
CASINO_PRIZE("Casino wallet (kept after event)", /obj/item/weapon/storage/wallet/casino, 1, 50, "misc"),
CASINO_PRIZE("Casino cards", /obj/item/weapon/deck/cards/casino, 1, 50, "misc"),
)
item_list["Drinks"] = list(
CASINO_PRIZE("Redeemer's brew", /obj/item/weapon/reagent_containers/food/drinks/bottle/redeemersbrew, 1, 50, "drinks"),
CASINO_PRIZE("Poison wine", /obj/item/weapon/reagent_containers/food/drinks/bottle/pwine, 1, 50, "drinks"),
CASINO_PRIZE("Patron", /obj/item/weapon/reagent_containers/food/drinks/bottle/patron, 1, 50, "drinks"),
CASINO_PRIZE("Holy water", /obj/item/weapon/reagent_containers/food/drinks/bottle/holywater, 1, 50, "drinks"),
CASINO_PRIZE("Goldschlager", /obj/item/weapon/reagent_containers/food/drinks/bottle/goldschlager, 1, 50, "drinks"),
CASINO_PRIZE("Champagne", /obj/item/weapon/reagent_containers/food/drinks/bottle/champagne, 1, 50, "drinks"),
CASINO_PRIZE("Bottle of Nothing", /obj/item/weapon/reagent_containers/food/drinks/bottle/bottleofnothing, 1, 50, "drinks"),
CASINO_PRIZE("Whiskey bliss", /obj/item/weapon/reagent_containers/food/drinks/bottle/specialwhiskey, 1, 50, "drinks"),
)
item_list["Implants"] = list(
CASINO_PRIZE("Implanter (Remember to get one unless you want to borrow from station!)", /obj/item/weapon/implanter, 1, 100, "implants"),
CASINO_PRIZE("Implant: Tazer", /obj/item/weapon/implantcase/taser, 1, 1000, "implants"),
CASINO_PRIZE("Implant: Medkit", /obj/item/weapon/implantcase/medkit, 1, 500, "implants"),
CASINO_PRIZE("Implant: Shades", /obj/item/weapon/implantcase/shades, 1, 750, "implants"),
CASINO_PRIZE("Implant: Sprinter", /obj/item/weapon/implantcase/sprinter, 1, 1500, "implants"),
CASINO_PRIZE("Implant: Toolkit", /obj/item/weapon/implantcase/toolkit, 1, 500, "implants"),
CASINO_PRIZE("Implant: Language", /obj/item/weapon/implantcase/vrlanguage, 1, 1000, "implants"),
CASINO_PRIZE("Implant: Analyzer", /obj/item/weapon/implantcase/analyzer, 1, 500, "implants"),
CASINO_PRIZE("Implant: Size control", /obj/item/weapon/implant/sizecontrol , 1, 500, "implants"),
)
item_list["Event"] = list(
)
/obj/machinery/casino_prize_dispenser/power_change()
..()
if(stat & BROKEN)
icon_state = "[initial(icon_state)]-broken"
else
if(!(stat & NOPOWER))
icon_state = initial(icon_state)
else
spawn(rand(0, 15))
icon_state = "[initial(icon_state)]-off"
/obj/machinery/casino_prize_dispenser/attack_hand(mob/user as mob)
if(stat & (BROKEN|NOPOWER))
return
tgui_interact(user)
/obj/machinery/casino_prize_dispenser/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(currently_vending)
if(istype(W, /obj/item/weapon/spacecasinocash))
to_chat(usr, "<span class='warning'>Please select prize on display with sufficient amount of chips.</span>")
else
SStgui.update_uis(src)
return // don't smack that machine with your 2 chips
if(istype(W, /obj/item/weapon/spacecasinocash))
attack_hand(user)
return
..()
/obj/machinery/casino_prize_dispenser/proc/pay_with_chips(var/obj/item/weapon/spacecasinocash/cashmoney, mob/user, var/price)
//"cashmoney_:[cashmoney] user:[user] currently_vending:[currently_vending]"
if(price > cashmoney.worth)
to_chat(usr, "\icon[cashmoney] <span class='warning'>That is not enough chips.</span>")
return 0
if(istype(cashmoney, /obj/item/weapon/spacecasinocash))
visible_message("<span class='info'>\The [usr] inserts some chips into \the [src].</span>")
cashmoney.worth -= price
if(cashmoney.worth <= 0)
usr.drop_from_inventory(cashmoney)
qdel(cashmoney)
else
cashmoney.update_icon()
return 1
/obj/machinery/casino_prize_dispenser/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/spritesheet/vending),
)
/obj/machinery/casino_prize_dispenser/tgui_data(mob/user)
var/list/data[0]
data["items"] = list()
for(var/cat in item_list)
var/list/cat_items = list()
for(var/prize_name in item_list[cat])
var/datum/data/casino_prize/prize = item_list[cat][prize_name]
cat_items[prize_name] = list("name" = prize_name, "price" = prize.cost, "restriction" = prize.restriction)
data["items"][cat] = cat_items
return data
/obj/machinery/casino_prize_dispenser/tgui_interact(mob/user, datum/tgui/ui = null)
// Open the window
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "CasinoPrizeDispenser", name)
ui.open()
/obj/machinery/casino_prize_dispenser/tgui_act(action, params)
if(stat & (BROKEN|NOPOWER))
return
if(usr.stat || usr.restrained())
return
if(..())
return TRUE
. = TRUE
switch(action)
if("purchase")
var/paid = FALSE
var/category = params["cat"]
var/restriction_category = params["restriction"]
var/restriction_check = 0
var/item_given = FALSE
var/name = params["name"]
var/price = params["price"]
var/datum/data/casino_prize/bi = item_list[category][name]
switch(restriction_category)
if("weapons")
restriction_check = category_weapons
if("gear")
restriction_check = category_gear
if("clothing")
restriction_check = category_clothing
if("misc")
restriction_check = category_misc
if("drinks")
restriction_check = category_drinks
if("implants")
restriction_check = category_implants
if("event")
restriction_check = category_event
else
to_chat(usr, "<span class='warning'>Prize checkout error has occured, purchase cancelled.</span>")
return FALSE
if(restriction_check < 1)
to_chat(usr, "<span class='warning'>[name] is restricted, this prize can't be bought.</span>")
return FALSE
if(restriction_check > 1)
item_given = TRUE
if(price <= 0 && item_given == TRUE)
vend(bi, usr)
return TRUE
currently_vending = bi
if(istype(usr.get_active_hand(), /obj/item/weapon/spacecasinocash))
var/obj/item/weapon/spacecasinocash/cash = usr.get_active_hand()
paid = pay_with_chips(cash, usr, price)
else
to_chat(usr, "<span class='warning'>Payment failure: Improper payment method, please provide chips.</span>")
return TRUE // we set this because they shouldn't even be able to get this far, and we want the UI to update.
if(paid)
if(item_given == TRUE)
vend(bi, usr)
speak("Thank you for your purchase, your [bi] has been logged.")
do_logging(currently_vending, usr, bi)
. = TRUE
else
to_chat(usr, "<span class='warning'>Payment failure: unable to process payment.</span>")
/obj/machinery/casino_prize_dispenser/proc/vend(datum/data/casino_prize/bi, mob/user)
SStgui.update_uis(src)
if(ispath(bi.equipment_path, /obj/item/stack))
var/obj/item/stack/S = new bi.equipment_path(loc)
S.amount = bi.equipment_amt
playsound(src, 'sound/machines/vending/vending_drop.ogg', 100, 1)
return TRUE
for(var/i in 1 to bi.equipment_amt)
new bi.equipment_path(loc)
playsound(src, 'sound/machines/vending/vending_drop.ogg', 100, 1)
currently_vending = null
use_power(vend_power_usage) //actuators and stuff
flick("[icon_state]-vend",src)
/obj/machinery/casino_prize_dispenser/proc/do_logging(item, mob/user, datum/data/casino_prize/bi)
var/prize_log = "{ckey:[user.ckey]character_name:[user.name]item_path: [bi.equipment_path]}"
log[++log.len] = prize_log
//Currently doesnt have an ingame way to show. Can only be viewed through View-Variables, to ensure theres no chance of players ckeys exposed - Jack
/obj/machinery/casino_prize_dispenser/proc/speak(var/message)
if(stat & NOPOWER)
return
if(!message)
return
for(var/mob/O in hearers(src, null))
O.show_message("<span class='game say'><span class='name'>\The [src]</span> beeps, \"[message]\"</span>",2)
return
/obj/machinery/casino_prize_dispenser/process() //Might not need this, but just to be safe for now
if(stat & (BROKEN|NOPOWER))
=======
//Original Casino Code created by Shadowfire117#1269 - Ported from CHOMPstation
//Modified by GhostActual#2055 for use with VOREstation
// Use this define to register a prize!
// * n - The proper name of the purchasable
// * o - The object type path of the purchasable to spawn
// * r - The amount to dispense
// * p - The price of the purchasable in chips
// * l - The restriction of the item
#define CASINO_PRIZE(n, o, r, p, l) n = new /datum/data/casino_prize(n, o, r, p, l)
/datum/data/casino_prize
var/equipment_path = null
var/equipment_amt = 1
var/cost = 0
var/category = null
var/restriction = null
/datum/data/casino_prize/New(name, path, amt, cost, restriction)
src.name = name
src.equipment_path = path
src.equipment_amt = amt
src.cost = cost
src.category = category
src.restriction = restriction
/obj/machinery/casino_prize_dispenser
name = "Casino Prize Exchanger"
desc = "Exchange your chips to obtain wonderful prizes! Hoepfully you'll get to keep some of them for a while."
icon = 'icons/obj/casino.dmi'
icon_state ="casino_prize_dispenser"
var/icon_vend ="casino_prize_dispenser-vend"
anchored = 1
density = 1
opacity = 0
var/list/item_list
clicksound = "button"
var/vending_sound = "machines/vending/vending_drop.ogg"
// Power
use_power = USE_POWER_IDLE
idle_power_usage = 10
var/vend_power_usage = 150 //actuators and stuff
// Vending-related
var/datum/data/casino_prize/currently_vending = null // What we're requesting payment for right now
var/list/log = list() //Log only SS13 staff is allowed to look at, CKEYS are listed here for record keeping of prizes and players for events!
var/category_weapons = 1 //For listing categories, if false then prizes of this categories cant be obtained nor bought for post-shift enjoyment
var/category_gear = 1 //If 1 prizes will be only logged
var/category_clothing = 1 //If 2 prizes will both be logged and spawned
var/category_misc = 1
var/category_drinks = 1
var/category_implants = 1
var/category_event = 1 //For special events, holidays, etc
/obj/machinery/casino_prize_dispenser/Initialize()
. = ..()
power_change()
item_list = list()
item_list["Weapons"] = list(
CASINO_PRIZE("Scepter", /obj/item/weapon/scepter, 1, 500, "weapons"),
CASINO_PRIZE("Chain of Command", /obj/item/weapon/melee/chainofcommand, 1, 250, "weapons"),
CASINO_PRIZE("Size Gun", /obj/item/weapon/gun/energy/sizegun, 1, 100, "weapons"),
CASINO_PRIZE("Advanced Particle Rifle", /obj/item/weapon/gun/energy/particle/advanced, 1, 500, "weapons"),
CASINO_PRIZE("Temperature Gun", /obj/item/weapon/gun/energy/temperature, 1, 250, "weapons"),
CASINO_PRIZE("Alien Pistol", /obj/item/weapon/gun/energy/alien, 1, 1000, "weapons"),
CASINO_PRIZE("Floral Gun", /obj/item/weapon/gun/energy/floragun, 1, 250, "weapons"),
CASINO_PRIZE("Net Gun", /obj/item/weapon/gun/energy/netgun, 1, 500, "weapons"),
)
item_list["Gear"] = list(
CASINO_PRIZE("Experimental Welder", /obj/item/weapon/weldingtool/experimental, 1, 500, "gear"),
CASINO_PRIZE("Chameleon Tie", /obj/item/clothing/accessory/chameleon, 1, 250, "gear"),
CASINO_PRIZE("Chemsprayer", /obj/item/weapon/reagent_containers/spray/chemsprayer, 1, 250, "gear"),
CASINO_PRIZE("Bluespace Beaker", /obj/item/weapon/reagent_containers/glass/beaker/bluespace, 1, 200, "gear"),
CASINO_PRIZE("Cryo Beaker", /obj/item/weapon/reagent_containers/glass/beaker/noreact, 1, 200, "gear"),
)
item_list["Clothing"] = list(
CASINO_PRIZE("Shark mask", /obj/item/clothing/mask/shark, 1, 50, "clothing"),
CASINO_PRIZE("Pig mask", /obj/item/clothing/mask/pig, 1, 50, "clothing"),
CASINO_PRIZE("Luchador mask", /obj/item/clothing/mask/luchador, 1, 50, "clothing"),
CASINO_PRIZE("Horse mask", /obj/item/clothing/mask/horsehead, 1, 50, "clothing"),
CASINO_PRIZE("Goblin mask", /obj/item/clothing/mask/goblin, 1, 50, "clothing"),
CASINO_PRIZE("Fake moustache", /obj/item/clothing/mask/fakemoustache, 1, 50, "clothing"),
CASINO_PRIZE("Dolphin mask", /obj/item/clothing/mask/dolphin, 1, 50, "clothing"),
CASINO_PRIZE("Demon mask", /obj/item/clothing/mask/demon, 1, 50, "clothing"),
CASINO_PRIZE("Chameleon mask", /obj/item/clothing/under/chameleon, 1, 250, "clothing"),
CASINO_PRIZE("Ian costume", /obj/item/clothing/suit/storage/hooded/ian_costume, 1, 50, "clothing"),
CASINO_PRIZE("Carp costume", /obj/item/clothing/suit/storage/hooded/carp_costume, 1, 50, "clothing"),
)
item_list["Miscellaneous"] = list(
CASINO_PRIZE("Toy sword", /obj/item/toy/sword, 1, 50, "misc"),
CASINO_PRIZE("Waterflower", /obj/item/weapon/reagent_containers/spray/waterflower, 1, 50, "misc"),
CASINO_PRIZE("Horse stick", /obj/item/toy/stickhorse, 1, 50, "misc"),
CASINO_PRIZE("Katana", /obj/item/toy/katana, 1, 50, "misc"),
CASINO_PRIZE("Conch", /obj/item/toy/eight_ball/conch, 1, 50, "misc"),
CASINO_PRIZE("Eight ball", /obj/item/toy/eight_ball, 1, 50, "misc"),
CASINO_PRIZE("Foam sword", /obj/item/weapon/material/sword/foam, 1, 50, "misc"),
CASINO_PRIZE("Whistle", /obj/item/toy/bosunwhistle, 1, 50, "misc"),
CASINO_PRIZE("Golden cup", /obj/item/weapon/reagent_containers/food/drinks/golden_cup, 1, 50, "misc"),
CASINO_PRIZE("Quality cigars", /obj/item/weapon/storage/fancy/cigar/havana, 1, 50, "misc"),
CASINO_PRIZE("Casino wallet (kept after event)", /obj/item/weapon/storage/wallet/casino, 1, 50, "misc"),
CASINO_PRIZE("Casino cards", /obj/item/weapon/deck/cards/casino, 1, 50, "misc"),
)
item_list["Drinks"] = list(
CASINO_PRIZE("Redeemer's brew", /obj/item/weapon/reagent_containers/food/drinks/bottle/redeemersbrew, 1, 50, "drinks"),
CASINO_PRIZE("Poison wine", /obj/item/weapon/reagent_containers/food/drinks/bottle/pwine, 1, 50, "drinks"),
CASINO_PRIZE("Patron", /obj/item/weapon/reagent_containers/food/drinks/bottle/patron, 1, 50, "drinks"),
CASINO_PRIZE("Holy water", /obj/item/weapon/reagent_containers/food/drinks/bottle/holywater, 1, 50, "drinks"),
CASINO_PRIZE("Goldschlager", /obj/item/weapon/reagent_containers/food/drinks/bottle/goldschlager, 1, 50, "drinks"),
CASINO_PRIZE("Champagne", /obj/item/weapon/reagent_containers/food/drinks/bottle/champagne, 1, 50, "drinks"),
CASINO_PRIZE("Bottle of Nothing", /obj/item/weapon/reagent_containers/food/drinks/bottle/bottleofnothing, 1, 50, "drinks"),
CASINO_PRIZE("Whiskey bliss", /obj/item/weapon/reagent_containers/food/drinks/bottle/specialwhiskey, 1, 50, "drinks"),
)
item_list["Implants"] = list(
CASINO_PRIZE("Implanter (Remember to get one unless you want to borrow from station!)", /obj/item/weapon/implanter, 1, 100, "implants"),
CASINO_PRIZE("Implant: Tazer", /obj/item/weapon/implantcase/taser, 1, 1000, "implants"),
CASINO_PRIZE("Implant: Medkit", /obj/item/weapon/implantcase/medkit, 1, 500, "implants"),
CASINO_PRIZE("Implant: Shades", /obj/item/weapon/implantcase/shades, 1, 750, "implants"),
CASINO_PRIZE("Implant: Sprinter", /obj/item/weapon/implantcase/sprinter, 1, 1500, "implants"),
CASINO_PRIZE("Implant: Toolkit", /obj/item/weapon/implantcase/toolkit, 1, 500, "implants"),
CASINO_PRIZE("Implant: Language", /obj/item/weapon/implantcase/vrlanguage, 1, 1000, "implants"),
CASINO_PRIZE("Implant: Analyzer", /obj/item/weapon/implantcase/analyzer, 1, 500, "implants"),
CASINO_PRIZE("Implant: Size control", /obj/item/weapon/implant/sizecontrol , 1, 500, "implants"),
)
item_list["Event"] = list(
)
/obj/machinery/casino_prize_dispenser/power_change()
..()
if(stat & BROKEN)
icon_state = "[initial(icon_state)]-broken"
else
if(!(stat & NOPOWER))
icon_state = initial(icon_state)
else
spawn(rand(0, 15))
icon_state = "[initial(icon_state)]-off"
/obj/machinery/casino_prize_dispenser/attack_hand(mob/user as mob)
if(stat & (BROKEN|NOPOWER))
return
tgui_interact(user)
/obj/machinery/casino_prize_dispenser/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(currently_vending)
if(istype(W, /obj/item/weapon/spacecasinocash))
to_chat(usr, "<span class='warning'>Please select prize on display with sufficient amount of chips.</span>")
else
SStgui.update_uis(src)
return // don't smack that machine with your 2 chips
if(istype(W, /obj/item/weapon/spacecasinocash))
attack_hand(user)
return
..()
/obj/machinery/casino_prize_dispenser/proc/pay_with_chips(var/obj/item/weapon/spacecasinocash/cashmoney, mob/user, var/price)
//"cashmoney_:[cashmoney] user:[user] currently_vending:[currently_vending]"
if(price > cashmoney.worth)
to_chat(usr, "\icon[cashmoney] <span class='warning'>That is not enough chips.</span>")
return 0
if(istype(cashmoney, /obj/item/weapon/spacecasinocash))
visible_message("<span class='info'>\The [usr] inserts some chips into \the [src].</span>")
cashmoney.worth -= price
if(cashmoney.worth <= 0)
usr.drop_from_inventory(cashmoney)
qdel(cashmoney)
else
cashmoney.update_icon()
return 1
/obj/machinery/casino_prize_dispenser/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/spritesheet/vending),
)
/obj/machinery/casino_prize_dispenser/tgui_data(mob/user)
var/list/data[0]
data["items"] = list()
for(var/cat in item_list)
var/list/cat_items = list()
for(var/prize_name in item_list[cat])
var/datum/data/casino_prize/prize = item_list[cat][prize_name]
cat_items[prize_name] = list("name" = prize_name, "price" = prize.cost, "restriction" = prize.restriction)
data["items"][cat] = cat_items
return data
/obj/machinery/casino_prize_dispenser/tgui_interact(mob/user, datum/tgui/ui = null)
// Open the window
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "CasinoPrizeDispenser", name)
ui.open()
/obj/machinery/casino_prize_dispenser/tgui_act(action, params)
if(stat & (BROKEN|NOPOWER))
return
if(usr.stat || usr.restrained())
return
if(..())
return TRUE
. = TRUE
switch(action)
if("purchase")
var/paid = FALSE
var/category = params["cat"]
var/restriction_category = params["restriction"]
var/restriction_check = 0
var/item_given = FALSE
var/name = params["name"]
var/price = params["price"]
var/datum/data/casino_prize/bi = item_list[category][name]
switch(restriction_category)
if("weapons")
restriction_check = category_weapons
if("gear")
restriction_check = category_gear
if("clothing")
restriction_check = category_clothing
if("misc")
restriction_check = category_misc
if("drinks")
restriction_check = category_drinks
if("implants")
restriction_check = category_implants
if("event")
restriction_check = category_event
else
to_chat(usr, "<span class='warning'>Prize checkout error has occured, purchase cancelled.</span>")
return FALSE
if(restriction_check < 1)
to_chat(usr, "<span class='warning'>[name] is restricted, this prize can't be bought.</span>")
return FALSE
if(restriction_check > 1)
item_given = TRUE
if(price <= 0 && item_given == TRUE)
vend(bi, usr)
return TRUE
currently_vending = bi
if(istype(usr.get_active_hand(), /obj/item/weapon/spacecasinocash))
var/obj/item/weapon/spacecasinocash/cash = usr.get_active_hand()
paid = pay_with_chips(cash, usr, price)
else
to_chat(usr, "<span class='warning'>Payment failure: Improper payment method, please provide chips.</span>")
return TRUE // we set this because they shouldn't even be able to get this far, and we want the UI to update.
if(paid)
if(item_given == TRUE)
vend(bi, usr)
speak("Thank you for your purchase, your [bi] has been logged.")
do_logging(currently_vending, usr, bi)
. = TRUE
else
to_chat(usr, "<span class='warning'>Payment failure: unable to process payment.</span>")
/obj/machinery/casino_prize_dispenser/proc/vend(datum/data/casino_prize/bi, mob/user)
SStgui.update_uis(src)
if(ispath(bi.equipment_path, /obj/item/stack))
new bi.equipment_path(loc, bi.equipment_amt)
playsound(src, 'sound/machines/vending/vending_drop.ogg', 100, 1)
return TRUE
for(var/i in 1 to bi.equipment_amt)
new bi.equipment_path(loc)
playsound(src, 'sound/machines/vending/vending_drop.ogg', 100, 1)
currently_vending = null
use_power(vend_power_usage) //actuators and stuff
flick("[icon_state]-vend",src)
/obj/machinery/casino_prize_dispenser/proc/do_logging(item, mob/user, datum/data/casino_prize/bi)
var/prize_log = "{ckey:[user.ckey]character_name:[user.name]item_path: [bi.equipment_path]}"
log[++log.len] = prize_log
//Currently doesnt have an ingame way to show. Can only be viewed through View-Variables, to ensure theres no chance of players ckeys exposed - Jack
/obj/machinery/casino_prize_dispenser/proc/speak(var/message)
if(stat & NOPOWER)
return
if(!message)
return
for(var/mob/O in hearers(src, null))
O.show_message("<span class='game say'><span class='name'>\The [src]</span> beeps, \"[message]\"</span>",2)
return
/obj/machinery/casino_prize_dispenser/process() //Might not need this, but just to be safe for now
if(stat & (BROKEN|NOPOWER))
>>>>>>> e5c108269d... Merge pull request #11454 from VOREStation/Arokha/stacks:code/modules/casino/casino_prize_vendor.dm
return

View File

@@ -86,8 +86,7 @@
to_chat(user, "<span class='notice'>You remove the cables.</span>")
state = 2
icon_state = "2"
var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc )
A.amount = 5
new /obj/item/stack/cable_coil(loc, 5)
if(istype(P, /obj/item/stack/material) && P.get_material_name() == "rglass")
var/obj/item/stack/RG = P

View File

@@ -189,7 +189,7 @@
to_chat(user, "<span class='notice'>\The [src] is already fully repaired.</span>")
return
var/obj/item/stack/P = C
if(P.amount < amt)
if(P.get_amount() < amt)
to_chat(user, "<span class='warning'>You don't have enough sheets to repair this! You need at least [amt] sheets.</span>")
return
to_chat(user, "<span class='notice'>You begin repairing [src]...</span>")

View File

@@ -277,8 +277,7 @@
if(repairing && I.is_crowbar())
var/datum/material/mat = get_material()
var/obj/item/stack/material/repairing_sheet = mat.place_sheet(loc)
repairing_sheet.amount += repairing-1
var/obj/item/stack/material/repairing_sheet = mat.place_sheet(loc, repairing)
repairing = 0
to_chat(user, "<span class='notice'>You remove \the [repairing_sheet].</span>")
playsound(src, I.usesound, 100, 1)

View File

@@ -90,8 +90,7 @@
return TRUE
if(reinforcing && I.is_crowbar())
var/obj/item/stack/material/plasteel/reinforcing_sheet = new /obj/item/stack/material/plasteel(src.loc)
reinforcing_sheet.amount = reinforcing
var/obj/item/stack/material/plasteel/reinforcing_sheet = new /obj/item/stack/material/plasteel(src.loc, reinforcing)
reinforcing = 0
to_chat(user, "<span class='notice'>You remove \the [reinforcing_sheet].</span>")
playsound(src, I.usesound, 100, 1)

View File

@@ -514,9 +514,8 @@
if(istype(P, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/CP = P
if(CP.get_amount() > 1)
var/camt = min(CP.amount, req_components[I]) // amount of cable to take, idealy amount required, but limited by amount provided
var/obj/item/stack/cable_coil/CC = new /obj/item/stack/cable_coil(src)
CC.amount = camt
var/camt = min(CP.get_amount(), req_components[I]) // amount of cable to take, idealy amount required, but limited by amount provided
var/obj/item/stack/cable_coil/CC = new /obj/item/stack/cable_coil(src, camt)
CC.update_icon()
CP.use(camt)
components += CC
@@ -587,9 +586,8 @@
if(istype(P, /obj/item/stack))
var/obj/item/stack/ST = P
if(ST.get_amount() > 1)
var/camt = min(ST.amount, req_components[I]) // amount of stack to take, idealy amount required, but limited by amount provided
var/obj/item/stack/NS = new ST.stacktype(src)
NS.amount = camt
var/camt = min(ST.get_amount(), req_components[I]) // amount of stack to take, idealy amount required, but limited by amount provided
var/obj/item/stack/NS = new ST.stacktype(src, camt)
NS.update_icon()
ST.use(camt)
components += NS

View File

@@ -71,8 +71,7 @@
to_chat(user, "<span class='notice'>You start to dismantle the IV drip.</span>")
if(do_after(user, 15))
to_chat(user, "<span class='notice'>You dismantle the IV drip.</span>")
var/obj/item/stack/rods/A = new /obj/item/stack/rods(src.loc)
A.amount = 6
new /obj/item/stack/rods(src.loc, 6)
if(beaker)
beaker.loc = get_turf(src)
beaker = null

View File

@@ -125,12 +125,12 @@
if(!(S.material.name in materials))
to_chat(user, "<span class='warning'>The [src] doesn't accept [S.material]!</span>")
return 1
if(S.amount < 1)
if(S.get_amount() < 1)
return 1 // Does this even happen? Sanity check I guess.
var/max_res_amount = storage_capacity[S.material.name]
if(materials[S.material.name] + S.perunit <= max_res_amount)
var/count = 0
while(materials[S.material.name] + S.perunit <= max_res_amount && S.amount >= 1)
while(materials[S.material.name] + S.perunit <= max_res_amount && S.get_amount() >= 1)
materials[S.material.name] += S.perunit
S.use(1)
count++
@@ -205,7 +205,7 @@
// 0 amount = 0 means ejecting a full stack; -1 means eject everything
/obj/machinery/partslathe/proc/eject_materials(var/material, var/amount)
var/recursive = amount == -1 ? 1 : 0
var/recursive = amount == -1 ? TRUE : FALSE
material = lowertext(material)
var/mattype
switch(material)
@@ -219,9 +219,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(materials[material] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(min(ejected, amount)))
return
materials[material] -= ejected * S.perunit
if(recursive && materials[material] >= S.perunit)

View File

@@ -146,10 +146,9 @@
var/amount_ejected = 0
while (metal >= 1)
var/datum/material/M = get_material_by_name(MAT_STEEL)
var/obj/item/stack/material/S = new M.stack_type(get_turf(src))
S.amount = min(metal, S.max_amount)
metal -= S.amount
amount_ejected += S.amount
var/obj/item/stack/material/S = new M.stack_type(get_turf(src), metal)
metal -= S.get_amount()
amount_ejected += S.get_amount()
return amount_ejected
/obj/machinery/pipelayer/proc/dismantleFloor(var/turf/new_turf)

View File

@@ -21,7 +21,7 @@
if(M)
if(!M.get_amount())
return
while(metal_amount < 150000 && M.amount)
while(metal_amount < 150000 && M.get_amount())
metal_amount += O.matter[MAT_STEEL] /*O:height * O:width * O:length * 100000.0*/
M.use(1)
count++

View File

@@ -67,11 +67,10 @@
//Tanning!
for(var/obj/item/stack/hairlesshide/HH in washing)
var/obj/item/stack/wetleather/WL = new(src)
WL.amount = HH.amount
var/obj/item/stack/wetleather/WL = new(src, HH.get_amount())
washing -= HH
HH.forceMove(get_turf(src))
HH.use(HH.amount)
HH.use(HH.get_amount())
washing += WL

View File

@@ -8,8 +8,7 @@
required_type = list(/obj/mecha/working)
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/New()
cable = new(src)
cable.amount = 0
cable = new(src, 0)
..()
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/MoveAction()
@@ -38,13 +37,12 @@
log_message("[equip_ready?"Dea":"A"]ctivated.")
return
if(href_list["cut"])
if(cable && cable.amount)
var/m = round(input(chassis.occupant,"Please specify the length of cable to cut","Cut cable",min(cable.amount,30)) as num, 1)
m = min(m, cable.amount)
if(cable && cable.get_amount())
var/m = round(input(chassis.occupant, "Please specify the length of cable to cut", "Cut cable", min(cable.get_amount(), 30)) as num, 1)
m = min(m, cable.get_amount())
if(m)
use_cable(m)
var/obj/item/stack/cable_coil/CC = new (get_turf(chassis))
CC.amount = m
new /obj/item/stack/cable_coil(get_turf(chassis), m)
else
occupant_message("There's no more cable on the reel.")
return
@@ -52,19 +50,19 @@
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/get_equip_info()
var/output = ..()
if(output)
return "[output] \[Cable: [cable ? cable.amount : 0] m\][(cable && cable.amount) ? "- <a href='?src=\ref[src];toggle=1'>[!equip_ready?"Dea":"A"]ctivate</a>|<a href='?src=\ref[src];cut=1'>Cut</a>" : null]"
return "[output] \[Cable: [cable ? cable.get_amount() : 0] m\][(cable && cable.get_amount()) ? "- <a href='?src=\ref[src];toggle=1'>[!equip_ready?"Dea":"A"]ctivate</a>|<a href='?src=\ref[src];cut=1'>Cut</a>" : null]"
return
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/load_cable(var/obj/item/stack/cable_coil/CC)
if(istype(CC) && CC.amount)
var/cur_amount = cable? cable.amount : 0
if(istype(CC) && CC.get_amount())
var/cur_amount = cable? cable.get_amount() : 0
var/to_load = max(max_cable - cur_amount,0)
if(to_load)
to_load = min(CC.amount, to_load)
to_load = min(CC.get_amount(), to_load)
if(!cable)
cable = new(src)
cable.amount = 0
cable.amount += to_load
cable = new(src, to_load)
else
cable.add(to_load)
CC.use(to_load)
return to_load
else
@@ -72,12 +70,12 @@
return
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/use_cable(amount)
if(!cable || cable.amount<1)
if(!cable || cable.get_amount() < 1)
set_ready_state(TRUE)
occupant_message("Cable depleted, [src] deactivated.")
log_message("Cable depleted, [src] deactivated.")
return
if(cable.amount < amount)
if(cable.get_amount() < amount)
occupant_message("No enough cable to finish the task.")
return
cable.use(amount)

View File

@@ -18,8 +18,7 @@
/obj/item/mecha_parts/mecha_equipment/generator/Initialize()
. = ..()
fuel = new fuel_type(src)
fuel.amount = 0
fuel = new fuel_type(src, 0)
/obj/item/mecha_parts/mecha_equipment/generator/Destroy()
qdel(fuel)
@@ -29,7 +28,7 @@
if(!chassis)
set_ready_state(TRUE)
return PROCESS_KILL
if(fuel.amount<=0)
if(fuel.get_amount() <= 0)
log_message("Deactivated - no fuel.")
set_ready_state(TRUE)
return PROCESS_KILL
@@ -43,7 +42,7 @@
if(cur_charge<chassis.cell.maxcharge)
use_fuel = fuel_per_cycle_active
chassis.give_power(power_per_cycle)
fuel.amount -= min(use_fuel/fuel.perunit,fuel.amount)
fuel.set_amount(min(use_fuel/fuel.perunit, fuel.get_amount()), TRUE) // allows fuel to get to 0
update_equip_info()
/obj/item/mecha_parts/mecha_equipment/generator/detach()
@@ -68,7 +67,7 @@
/obj/item/mecha_parts/mecha_equipment/generator/get_equip_info()
var/output = ..()
if(output)
return "[output] \[[fuel]: [round(fuel.amount*fuel.perunit,0.1)] cm<sup>3</sup>\] - <a href='?src=\ref[src];toggle=1'>[(datum_flags & DF_ISPROCESSING)?"Dea":"A"]ctivate</a>"
return "[output] \[[fuel]: [round(fuel.get_amount()*fuel.perunit,0.1)] cm<sup>3</sup>\] - <a href='?src=\ref[src];toggle=1'>[(datum_flags & DF_ISPROCESSING)?"Dea":"A"]ctivate</a>"
return
/obj/item/mecha_parts/mecha_equipment/generator/action(target)
@@ -86,12 +85,12 @@
return
/obj/item/mecha_parts/mecha_equipment/generator/proc/load_fuel(var/obj/item/stack/material/P)
if(P.type == fuel.type && P.amount)
var/to_load = max(max_fuel - fuel.amount*fuel.perunit,0)
if(P.type == fuel.type && P.get_amount())
var/to_load = max(max_fuel - fuel.get_amount()*fuel.perunit,0)
if(to_load)
var/units = min(max(round(to_load / P.perunit),1),P.amount)
var/units = min(max(round(to_load / P.perunit),1),P.get_amount())
if(units)
fuel.amount += units
fuel.add(units)
P.use(units)
return units
else

View File

@@ -665,7 +665,7 @@
visible_message("[bicon(src)] <b>[src]</b> beeps: \"No records in User DB\"")
/obj/machinery/mecha_part_fabricator/proc/eject_materials(var/material, var/amount) // 0 amount = 0 means ejecting a full stack; -1 means eject everything
var/recursive = amount == -1 ? 1 : 0
var/recursive = amount == -1 ? TRUE : FALSE
var/matstring = lowertext(material)
var/datum/material/M = get_material_by_name(matstring)
@@ -673,9 +673,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(materials[matstring] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(ejected, amount))
return
materials[matstring] -= ejected * S.perunit
if(recursive && materials[matstring] >= S.perunit)

View File

@@ -190,8 +190,7 @@
holder.icon_state = "ripley4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "ripley2"
if(10)
if(diff==FORWARD)
@@ -238,8 +237,7 @@
holder.icon_state = "ripley10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "ripley8"
if(4)
if(diff==FORWARD)
@@ -261,8 +259,7 @@
holder.icon_state = "ripley13"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "ripley11"
if(1)
if(diff==FORWARD)
@@ -425,8 +422,7 @@
holder.icon_state = "gygax4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "gygax2"
if(16)
if(diff==FORWARD)
@@ -521,8 +517,7 @@
holder.icon_state = "gygax16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "gygax14"
if(4)
if(diff==FORWARD)
@@ -709,8 +704,7 @@
holder.icon_state = "gygax4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "gygax2"
if(16)
if(diff==FORWARD)
@@ -805,8 +799,7 @@
holder.icon_state = "gygax16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You pry the internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "gygax14"
if(4)
if(diff==FORWARD)
@@ -829,8 +822,7 @@
holder.icon_state = "gygax19-s"
else
user.visible_message("[user] pries the external armor layer from [holder].", "You pry the external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder)) // Fixes serenity giving Gygax Armor Plates for the reverse action...
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5) // Fixes serenity giving Gygax Armor Plates for the reverse action...
holder.icon_state = "gygax17"
if(1)
if(diff==FORWARD)
@@ -976,8 +968,7 @@
holder.icon_state = "fireripley4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "fireripley2"
if(11)
if(diff==FORWARD)
@@ -1024,8 +1015,7 @@
holder.icon_state = "fireripley10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "fireripley8"
if(5)
if(diff==FORWARD)
@@ -1047,8 +1037,7 @@
holder.icon_state = "fireripley13"
else
user.visible_message("[user] removes the external armor from [holder].", "You remove the external armor from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "fireripley11"
if(2)
if(diff==FORWARD)
@@ -1056,8 +1045,7 @@
holder.icon_state = "fireripley14"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "fireripley12"
if(1)
if(diff==FORWARD)
@@ -1221,8 +1209,7 @@
holder.icon_state = "durand4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "durand2"
if(16)
if(diff==FORWARD)
@@ -1317,8 +1304,7 @@
holder.icon_state = "durand16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "durand14"
if(4)
if(diff==FORWARD)
@@ -1480,8 +1466,7 @@
holder.icon_state = "odysseus4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "odysseus2"
if(10)
if(diff==FORWARD)
@@ -1528,8 +1513,7 @@
holder.icon_state = "odysseus10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "odysseus8"
if(4)
if(diff==FORWARD)
@@ -1550,9 +1534,8 @@
user.visible_message("[user] secures external armor layer.", "You secure external reinforced armor layer.")
holder.icon_state = "odysseus13"
else
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
user.visible_message("[user] pries [MS] from [holder].", "You prie [MS] from [holder].")
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
user.visible_message("[user] pries the plasteel from [holder].", "You prie the plasteel from [holder].")
holder.icon_state = "odysseus11"
if(1)
if(diff==FORWARD)
@@ -1715,8 +1698,7 @@
holder.icon_state = "phazon4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "phazon2"
if(16)
if(diff==FORWARD)
@@ -1811,8 +1793,7 @@
holder.icon_state = "phazon20"
else
user.visible_message("[user] pries the internal armor layer from [holder].", "You pry the internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "phazon14"
if(4)
if(diff==FORWARD)
@@ -1834,8 +1815,7 @@
holder.icon_state = "phazon23"
else
user.visible_message("[user] pries the external armor layer from [holder].", "You pry external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "phazon21"
if(1)
if(diff==FORWARD)
@@ -2005,8 +1985,7 @@
holder.icon_state = "janus4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "janus2"
if(18)
if(diff==FORWARD)
@@ -2117,8 +2096,7 @@
holder.icon_state = "janus18"
else
user.visible_message("[user] pries the internal armor layer from [holder].", "You pry the internal armor layer from [holder].")
var/obj/item/stack/material/durasteel/MS = new /obj/item/stack/material/durasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/durasteel(get_turf(holder), 5)
holder.icon_state = "janus16"
if(4)
if(diff==FORWARD)
@@ -2140,8 +2118,7 @@
holder.icon_state = "janus21"
else
user.visible_message("[user] pries the external armor layer from [holder].", "You pry external armor layer from [holder].")
var/obj/item/stack/material/morphium/MS = new /obj/item/stack/material/morphium(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/morphium(get_turf(holder), 5)
holder.icon_state = "janus19"
if(1)
if(diff==FORWARD)

View File

@@ -145,8 +145,7 @@
holder.icon_state = "polecat4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "polecat2"
if(16)
if(diff==FORWARD)
@@ -241,8 +240,7 @@
holder.icon_state = "polecat16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/steel(get_turf(holder), 3)
holder.icon_state = "polecat14"
if(4)
if(diff==FORWARD)
@@ -402,8 +400,7 @@
holder.icon_state = "gopher4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "gopher2"
if(10)
if(diff==FORWARD)
@@ -450,8 +447,7 @@
holder.icon_state = "gopher10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/steel(get_turf(holder), 3)
holder.icon_state = "gopher8"
if(4)
if(diff==FORWARD)
@@ -473,8 +469,7 @@
holder.icon_state = "gopher13"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 2
new /obj/item/stack/material/plasteel(get_turf(holder), 2)
holder.icon_state = "gopher11"
if(1)
if(diff==FORWARD)
@@ -635,8 +630,7 @@
holder.icon_state = "weasel4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "weasel2"
if(16)
if(diff==FORWARD)
@@ -731,8 +725,7 @@
holder.icon_state = "weasel16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/steel(get_turf(holder), 3)
holder.icon_state = "weasel14"
if(4)
if(diff==FORWARD)
@@ -754,8 +747,7 @@
holder.icon_state = "weasel19"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/plasteel(get_turf(holder), 3)
holder.icon_state = "weasel17"
if(1)
if(diff==FORWARD)

View File

@@ -29,8 +29,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(loc)
C.amount = 10
new /obj/item/stack/cable_coil(loc, 10)
to_chat(user, "You cut the cables and disassemble the unused power terminal.")
qdel(T)
new /obj/machinery/power/apc(loc, ndir, 1)

View File

@@ -127,7 +127,7 @@ var/list/marker_beacon_colors = list(
if(istype(I, /obj/item/stack/marker_beacon))
var/obj/item/stack/marker_beacon/M = I
to_chat(user, "<span class='notice'>You start picking [src] up...</span>")
if(do_after(user, remove_speed, target = src) && M.amount + 1 <= M.max_amount)
if(do_after(user, remove_speed, target = src) && M.get_amount() + 1 <= M.max_amount)
M.add(1)
playsound(src, 'sound/items/deconstruct.ogg', 50, 1)
qdel(src)

View File

@@ -17,7 +17,7 @@
center_of_mass = null
var/list/datum/stack_recipe/recipes
var/singular_name
var/amount = 1
VAR_PROTECTED/amount = 1
var/max_amount //also see stack recipes initialisation, param "max_res_amount" must be equal to this max_amount
var/stacktype //determines whether different stack types can merge
var/build_type = null //used when directly applied to a turf
@@ -33,8 +33,10 @@
. = ..()
if(!stacktype)
stacktype = type
if(amount)
src.amount = amount
if(!isnull(amount)) // Could be 0
if(amount < 0)
amount = max_amount
set_amount(amount, TRUE)
update_icon()
/obj/item/stack/Destroy()
@@ -229,12 +231,15 @@
//Return 1 if an immediate subsequent call to use() would succeed.
//Ensures that code dealing with stacks uses the same logic
/obj/item/stack/proc/can_use(var/used)
if (get_amount() < used)
if(used < 0 || used % 1)
stack_trace("Tried to use a bad stack amount: [used]")
return 0
if(get_amount() < used)
return 0
return 1
/obj/item/stack/proc/use(var/used)
if (!can_use(used))
if(!can_use(used))
return 0
if(!uses_charge)
amount -= used
@@ -251,6 +256,9 @@
return 1
/obj/item/stack/proc/add(var/extra)
if(extra < 0 || extra % 1)
stack_trace("Tried to add a bad stack amount: [extra]")
return 0
if(!uses_charge)
if(amount + extra > get_max_amount())
return 0
@@ -265,6 +273,27 @@
var/datum/matter_synth/S = synths[i]
S.add_charge(charge_costs[i] * extra)
/obj/item/stack/proc/set_amount(var/new_amount, var/no_limits = FALSE)
if(new_amount < 0 || new_amount % 1)
stack_trace("Tried to set a bad stack amount: [new_amount]")
return 0
// Clean up the new amount
new_amount = max(round(new_amount), 0)
// Can exceed max if you really want
if(new_amount > max_amount && !no_limits)
new_amount = max_amount
amount = new_amount
// Can set it to 0 without qdel if you really want
if(amount == 0 && !no_limits)
qdel(src)
return FALSE
return TRUE
/*
The transfer and split procs work differently than use() and add().
Whereas those procs take no action if the desired amount cannot be added or removed these procs will try to transfer whatever they can.
@@ -283,6 +312,10 @@
if (isnull(tamount))
tamount = src.get_amount()
if(tamount < 0 || tamount % 1)
stack_trace("Tried to transfer a bad stack amount: [tamount]")
return 0
var/transfer = max(min(tamount, src.get_amount(), (S.get_max_amount() - S.get_amount())), 0)
var/orig_amount = src.get_amount()
@@ -302,7 +335,10 @@
if(uses_charge)
return null
tamount = round(tamount)
if(tamount < 0 || tamount % 1)
stack_trace("Tried to split a bad stack amount: [tamount]")
return null
var/transfer = max(min(tamount, src.amount, initial(max_amount)), 0)
var/orig_amount = src.amount

View File

@@ -130,10 +130,10 @@
/obj/item/weapon/card/emag/attackby(obj/item/O as obj, mob/user as mob)
if(istype(O, /obj/item/stack/telecrystal))
var/obj/item/stack/telecrystal/T = O
if(T.amount < 1)
if(T.get_amount() < 1)
to_chat(usr, "<span class='notice'>You are not adding enough telecrystals to fuel \the [src].</span>")
return
uses += T.amount/2 //Gives 5 uses per 10 TC
uses += T.get_amount()*0.5 //Gives 5 uses per 10 TC
uses = CEILING(uses, 1) //Ensures no decimal uses nonsense, rounds up to be nice
to_chat(usr, "<span class='notice'>You add \the [O] to \the [src]. Increasing the uses of \the [src] to [uses].</span>")
qdel(O)

View File

@@ -13,7 +13,7 @@
/obj/item/weapon/whetstone/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/stack/material))
var/obj/item/stack/material/M = I
if(M.amount >= 5)
if(M.get_amount() >= 5)
to_chat(user, "You begin to refine the [src] with [M]...")
if(do_after(user, 70))
M.use(5)

View File

@@ -262,7 +262,7 @@
return 0
var/current = 0
for(var/obj/item/stack/material/S in contents)
current += S.amount
current += S.get_amount()
if(capacity == current)//If it's full, you're done
if(!stop_messages)
to_chat(usr, "<span class='warning'>The snatcher is full.</span>")
@@ -279,29 +279,27 @@
var/inserted = 0
var/current = 0
for(var/obj/item/stack/material/S2 in contents)
current += S2.amount
if(capacity < current + S.amount)//If the stack will fill it up
current += S2.get_amount()
if(capacity < current + S.get_amount())//If the stack will fill it up
amount = capacity - current
else
amount = S.amount
amount = S.get_amount()
for(var/obj/item/stack/material/sheet in contents)
if(S.type == sheet.type) // we are violating the amount limitation because these are not sane objects
sheet.amount += amount // they should only be removed through procs in this file, which split them up.
S.amount -= amount
if(S.type == sheet.type)
// we are violating the amount limitation because these are not sane objects
sheet.set_amount(sheet.get_amount() + amount, TRUE)
S.use(amount) // will qdel() if we use it all
inserted = 1
break
if(!inserted || !S.amount)
if(!inserted)
usr.remove_from_mob(S)
usr.update_icons() //update our overlays
if (usr.client && usr.s_active != src)
usr.client.screen -= S
S.dropped(usr)
if(!S.amount)
qdel(S)
else
S.loc = src
S.loc = src
orient2hud(usr)
if(usr.s_active)
@@ -322,7 +320,7 @@
for(var/obj/item/stack/material/I in contents)
adjusted_contents++
var/datum/numbered_display/D = new/datum/numbered_display(I)
D.number = I.amount
D.number = I.get_amount()
numbered_contents.Add( D )
var/row_num = 0
@@ -336,14 +334,14 @@
/obj/item/weapon/storage/bag/sheetsnatcher/quick_empty()
var/location = get_turf(src)
for(var/obj/item/stack/material/S in contents)
while(S.amount)
var/obj/item/stack/material/N = new S.type(location)
var/stacksize = min(S.amount,N.max_amount)
N.amount = stacksize
S.amount -= stacksize
N.update_icon()
if(!S.amount)
qdel(S) // todo: there's probably something missing here
var/cur_amount = S.get_amount()
var/full_stacks = round(cur_amount / S.max_amount) // Floor of current/max is amount of full stacks we make
var/remainder = cur_amount % S.max_amount // Current mod max is remainder after full sheets removed
for(var/i = 1 to full_stacks)
new S.type(location, S.max_amount)
if(remainder)
new S.type(location, remainder)
S.set_amount(0)
orient2hud(usr)
if(usr.s_active)
usr.s_active.show_to(usr)
@@ -359,10 +357,10 @@
//Therefore, make a new stack internally that has the remainder.
// -Sayu
if(S.amount > S.max_amount)
var/obj/item/stack/material/temp = new S.type(src)
temp.amount = S.amount - S.max_amount
S.amount = S.max_amount
if(S.get_amount() > S.max_amount)
var/newstack_amt = S.get_amount() - S.max_amount
new S.type(src, newstack_amt) // The one we'll keep to replace the one we give
S.set_amount(S.max_amount) // The one we hand to the clicker
return ..(S,new_location)

View File

@@ -116,7 +116,6 @@
for(var/i = 0, i<2, i++)
for(var/res in resources)
var/obj/item/stack/R = new res(src)
R.amount = R.max_amount
new res(src, -1)
return ..()

View File

@@ -43,8 +43,7 @@
to_chat(user, "<span class='notice'>You start to cut the shower curtains.</span>")
if(do_after(user, 10))
to_chat(user, "<span class='notice'>You cut the shower curtains.</span>")
var/obj/item/stack/material/plastic/A = new /obj/item/stack/material/plastic( src.loc )
A.amount = 3
new /obj/item/stack/material/plastic(src.loc, 3)
qdel(src)
return
else

View File

@@ -109,8 +109,7 @@
if(finished)
to_chat(user, "<span class='notice'>You start breaking down \the [src].</span>")
if(do_after(user, 10 SECONDS, src, exclusive = TASK_ALL_EXCLUSIVE))
var/obj/item/stack/S = new /obj/item/stack/material/plasteel(loc)
S.amount = 10
new /obj/item/stack/material/plasteel(loc, 10)
playsound(user, O.usesound, 50, 1)
qdel(src)
else

View File

@@ -101,8 +101,7 @@
return
if(product && product_amount) // Make wooden logs.
var/obj/item/stack/material/M = new product(get_turf(src))
M.amount = product_amount
var/obj/item/stack/material/M = new product(get_turf(src), product_amount)
M.update_icon()
visible_message("<span class='danger'>\The [src] is felled!</span>")
stump()

View File

@@ -22,8 +22,7 @@
to_chat(user, "<span class='notice'>You start to cut the plastic flaps.</span>")
if(do_after(user, 10 * P.toolspeed))
to_chat(user, "<span class='notice'>You cut the plastic flaps.</span>")
var/obj/item/stack/material/plastic/A = new /obj/item/stack/material/plastic( src.loc )
A.amount = 4
new /obj/item/stack/material/plastic(src.loc, 4)
qdel(src)
return
else

View File

@@ -297,7 +297,7 @@
visible_message("<span class='notice'>[user] dismantles \the [src].</span>")
var/obj/item/stack/material/mats = new glasstype(loc)
if(is_fulltile())
mats.amount = 4
mats.set_amount(4)
qdel(src)
else if(istype(W, /obj/item/stack/cable_coil) && reinf && state == 0 && !istype(src, /obj/structure/window/reinforced/polarized))
var/obj/item/stack/cable_coil/C = W

View File

@@ -96,7 +96,7 @@
if(!use_flooring)
return
// Do we have enough?
if(use_flooring.build_cost && S.amount < use_flooring.build_cost)
if(use_flooring.build_cost && S.get_amount() < use_flooring.build_cost)
to_chat(user, "<span class='warning'>You require at least [use_flooring.build_cost] [S.name] to complete the [use_flooring.descriptor].</span>")
return
// Stay still and focus...

View File

@@ -31,8 +31,7 @@
to_chat(user, "<span class='notice'>You begin to remove \the [src] with your [W].</span>")
if(do_after(user, 4 SECONDS * W.toolspeed))
to_chat(user, "<span class='notice'>\The [src] has been dug up, and now lies in a pile nearby.</span>")
var/obj/item/stack/material/snow/S = new(src)
S.amount = 10
new /obj/item/stack/material/snow(src, 10)
demote()
else
to_chat(user, "<span class='notice'>You decide to not finish removing \the [src].</span>")

View File

@@ -0,0 +1,79 @@
/turf/simulated/floor/outdoors/newdirt/attack_hand(mob/user)
if(user.pulling)
return ..()
var/static/list/has_rocks = list("dirt5", "dirt6", "dirt7", "dirt8", "dirt9")
if(!Adjacent(user))
return ..()
if(icon_state in has_rocks)
user.visible_message("[user] loosens rocks from \the [src]...", "You loosen rocks from \the [src]...")
if(do_after(user, 5 SECONDS, exclusive = TASK_USER_EXCLUSIVE))
var/obj/item/stack/material/flint/R = new(get_turf(src), rand(1,4))
R.pixel_x = rand(-6,6)
R.pixel_y = rand(-6,6)
icon_state = "dirt0"
return
if(locate(/obj) in src)
to_chat(user, "<span class='notice'>The [name] isn't clear.</span>")
return
else
var/choice= tgui_alert(user, "Do you want to build a growplot out of the dirt?", "Build growplot?" , list("Yes", "No"))
if(!choice||choice=="No")
return
user.visible_message("[user] starts piling up \the [src]...", "You start piling up \the [src]...")
if(do_after(user, 5 SECONDS, exclusive = TASK_USER_EXCLUSIVE))
new /obj/machinery/portable_atmospherics/hydroponics/soil(src)
/turf/simulated/floor/outdoors
var/rock_chance = 0
/turf/simulated/floor/outdoors/proc/rock_gathering(var/mob/user as mob)
if(locate(/obj) in src)
to_chat(user, "<span class='notice'>The [name] isn't clear.</span>")
return
user.visible_message("[user] starts digging around in \the [src]...", "You start digging around in \the [src]...")
if(do_after(user, 5 SECONDS, exclusive = TASK_USER_EXCLUSIVE))
if(prob(rock_chance))
var/obj/item/stack/material/flint/R = new(get_turf(src), rand(1,4))
to_chat(user, "<span class='notice'>You found some [R]</span>")
R.pixel_x = rand(-6,6)
R.pixel_y = rand(-6,6)
else
to_chat(user, "<span class='notice'>You didn't find anything...</span>")
else
return
/turf/simulated/floor/outdoors/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(istype(O, /obj/item/weapon/shovel) && rock_chance)
rock_gathering(user)
else
return ..()
/turf/simulated/floor/outdoors/newdirt
rock_chance = 5
/turf/simulated/floor/outdoors/dirt
rock_chance = 10
/turf/simulated/floor/outdoors/rocks
rock_chance = 100
/turf/simulated/floor/outdoors/ironsand
rock_chance = 50
/turf/simulated/floor/outdoors/newdirt/examine(var/mob/user)
. = ..()
if(Adjacent(user))
var/static/list/has_rocks = list("dirt5", "dirt6", "dirt7", "dirt8", "dirt9")
if(icon_state in has_rocks)
. += "<span class='notice'>There are some rocks in the dirt.</span>"
/obj/structure/flora/tree
var/sticks = TRUE
/obj/structure/flora/tree/attack_hand(mob/user)
if(sticks)
user.visible_message("[user] searches \the [src] for loose sticks...", "You search \the [src] for loose sticks...")
if(do_after(user, 5 SECONDS, exclusive = TASK_USER_EXCLUSIVE))
var/obj/item/stack/material/stick/S = new(get_turf(user), rand(1,3))
S.pixel_x = rand(-6,6)
S.pixel_y = rand(-6,6)
sticks = FALSE
else
to_chat(user, "<span class='notice'>You don't see any loose sticks...</span>")

View File

@@ -57,8 +57,7 @@
var/bar_type = pick(possible_spawns)
for(var/i=0,i<amount,i++)
var/obj/item/stack/material/M = new bar_type(C)
M.amount = quantity
new bar_type(C, quantity)
else
//credits
var/amount = rand(2,6)

View File

@@ -95,7 +95,7 @@
return
var/obj/item/stack/cable_coil/cable = W
if(!cable.amount >= 5)
if(!cable.get_amount() >= 5)
to_chat(user, "You need five units of cable to repair \the [src].")
return

View File

@@ -76,8 +76,7 @@
..()
return
var/obj/item/stack/cable_coil/CC = new/obj/item/stack/cable_coil(user.loc)
CC.amount = 1
var/obj/item/stack/cable_coil/CC = new (user.loc)
CC.update_icon()
cut_overlays()
string_attached = null

View File

@@ -58,7 +58,7 @@
return
else if(istype(I, /obj/item/stack/cable_coil) && !strung)
var/obj/item/stack/cable_coil/C = I
if(C.amount < 5)
if(C.get_amount() < 5)
to_chat(user, "<span class='warning'>You do not have enough length in \the [C] to string this!</span>")
return
if(do_after(user, rand(10 SECONDS, 20 SECONDS)))

View File

@@ -60,7 +60,7 @@
for(var/obj/item/stack/wetleather/WL in I.instances)
if(!WL.wetness)
if(WL.amount)
if(WL.get_amount())
WL.forceMove(get_turf(src))
WL.dry()
I.instances -= WL

View File

@@ -20,7 +20,7 @@
while(count > 0)
var/obj/item/stack/S = I.get_product(get_turf(src), min(count, amount))
count -= S.amount
count -= S.get_amount()
SStgui.update_uis(src)
/obj/machinery/smartfridge/sheets/find_record(var/obj/item/O)

View File

@@ -201,12 +201,12 @@
var/obj/item/stack/material/wood/NG = new (user.loc)
if(flesh_colour) NG.color = flesh_colour
for (var/obj/item/stack/material/wood/G in user.loc)
if(G==NG)
if(G == NG)
continue
if(G.amount>=G.max_amount)
if(G.get_amount() >= G.max_amount)
continue
G.attackby(NG, user)
to_chat(user, "You add the newly-formed wood to the stack. It now contains [NG.amount] planks.")
to_chat(user, "You add the newly-formed wood to the stack. It now contains [NG.get_amount()] planks.")
qdel(src)
return
else if(!isnull(seed.chems["potato"]))
@@ -280,12 +280,12 @@
var/obj/item/stack/tile/grass/G = new (user.loc)
if(flesh_colour) G.color = flesh_colour
for (var/obj/item/stack/tile/grass/NG in user.loc)
if(G==NG)
if(G == NG)
continue
if(NG.amount>=NG.max_amount)
if(NG.get_amount() >= NG.max_amount)
continue
NG.attackby(G, user)
to_chat(user, "You add the newly-formed grass to the stack. It now contains [G.amount] tiles.")
to_chat(user, "You add the newly-formed grass to the stack. It now contains [G.get_amount()] tiles.")
qdel(src)
return

View File

@@ -40,7 +40,7 @@
if(debug)
to_chat(user, span("warning", "\The [src] does not need any material."))
return
var/num = min((max_metal - metal) / metal_per_sheet, stack.amount)
var/num = min((max_metal - metal) / metal_per_sheet, stack.get_amount())
if(num < 1)
to_chat(user, span("warning", "\The [src] is too full to add more metal."))
return

View File

@@ -10,8 +10,7 @@
..()
var/turf/T = get_turf(src)
var/obj/structure/closet/C = locate() in T
var/obj/item/stack/M = new type_to_spawn(C || T)
M.amount = M.max_amount //some stuff spawns with 60, we're still calling it fifty
var/obj/item/stack/M = new type_to_spawn(C || T, -1)
M.update_icon() // Some stacks have different sprites depending on how full they are.
return INITIALIZE_HINT_QDEL //Bye!

View File

@@ -312,9 +312,9 @@ var/list/name_to_material
place_sheet(target)
// Debris product. Used ALL THE TIME.
/datum/material/proc/place_sheet(var/turf/target)
/datum/material/proc/place_sheet(var/turf/target, amount)
if(stack_type)
return new stack_type(target)
return new stack_type(target, amount)
// As above.
/datum/material/proc/place_shard(var/turf/target)

View File

@@ -24,14 +24,14 @@
//Try locating an exisitng stack on the tile and add to there if possible
var/obj/item/stack/hairlesshide/H = null
for(var/obj/item/stack/hairlesshide/HS in user.loc) // Could be scraping something inside a locker, hence the .loc, not get_turf
if(HS.amount < HS.max_amount)
if(HS.get_amount() < HS.max_amount)
H = HS
break
// Either we found a valid stack, in which case increment amount,
// Or we need to make a new stack
if(istype(H))
H.amount++
H.add(1)
else
H = new /obj/item/stack/hairlesshide(user.loc)

View File

@@ -21,14 +21,14 @@
for(var/i in 1 to wateramount)
var/obj/item/stack/wetleather/H = null
for(var/obj/item/stack/wetleather/HS in get_turf(src)) // Doesn't have a user, can't just use their loc
if(HS.amount < HS.max_amount)
if(HS.get_amount() < HS.max_amount)
H = HS
break
// Either we found a valid stack, in which case increment amount,
// Or we need to make a new stack
if(istype(H))
H.amount++
H.add(1)
else
H = new /obj/item/stack/wetleather(get_turf(src))

View File

@@ -38,9 +38,8 @@
dry()
/obj/item/stack/wetleather/proc/dry()
var/obj/item/stack/material/leather/L = new(src.loc)
L.amount = amount
use(amount)
var/obj/item/stack/material/leather/L = new(src.loc, get_amount())
use(get_amount())
return L
/obj/item/stack/wetleather/transfer_to(obj/item/stack/S, var/tamount=null, var/type_verified)

View File

@@ -41,7 +41,7 @@
drying = A
else // Drying something, add if possible
var/obj/item/stack/wetleather/W = A
W.transfer_to(drying, W.amount, TRUE)
W.transfer_to(drying, W.get_amount(), TRUE)
update_icon()
return TRUE
return ..()
@@ -50,9 +50,8 @@
if(drying)
var/obj/item/stack/S = drying
if(!drying.wetness) // If it's dry, make a stack of dry leather and prepare to put that in their hands
var/obj/item/stack/material/leather/L = new(src)
L.amount = drying.amount
drying.use(drying.amount)
var/obj/item/stack/material/leather/L = new(src, drying.get_amount())
drying.set_amount(0)
S = L
if(ishuman(user))

View File

@@ -47,9 +47,8 @@
existing_wood = M
break
var/obj/item/stack/material/wood/new_wood = new plank_type(user.loc)
new_wood.amount = 2
var/obj/item/stack/material/wood/new_wood = new plank_type(user.loc, 2)
if(existing_wood && new_wood.transfer_to(existing_wood))
to_chat(user, "<span class='notice'>You add the newly-formed wood to the stack. It now contains [existing_wood.amount] planks.</span>")
to_chat(user, "<span class='notice'>You add the newly-formed wood to the stack. It now contains [existing_wood.get_amount()] planks.</span>")
else
return ..()

View File

@@ -62,10 +62,8 @@
var/stack = params["stack"]
if(machine.stack_storage[stack] > 0)
var/stacktype = machine.stack_paths[stack]
var/obj/item/stack/material/S = new stacktype(get_turf(machine.output))
S.amount = machine.stack_storage[stack]
new stacktype(get_turf(machine.output), machine.stack_storage[stack])
machine.stack_storage[stack] = 0
S.update_icon()
. = TRUE
add_fingerprint(usr)
@@ -125,7 +123,7 @@
var/obj/item/stack/material/S = O
var/matname = S.material.name
if(!isnull(stack_storage[matname]))
stack_storage[matname] += S.amount
stack_storage[matname] += S.get_amount()
qdel(S)
else
O.loc = output.loc
@@ -136,10 +134,8 @@
for(var/sheet in stack_storage)
if(stack_storage[sheet] >= stack_amt)
var/stacktype = stack_paths[sheet]
var/obj/item/stack/material/S = new stacktype (get_turf(output))
S.amount = stack_amt
new stacktype (get_turf(output), stack_amt)
stack_storage[sheet] -= stack_amt
S.update_icon()
if(console)
console.updateUsrDialog()

View File

@@ -298,8 +298,7 @@
new /obj/item/device/assembly/prox_sensor(Tsec)
if(prob(50))
new /obj/item/robot_parts/l_arm(Tsec)
var/obj/item/stack/tile/floor/T = new /obj/item/stack/tile/floor(Tsec)
T.amount = amount
new /obj/item/stack/tile/floor(Tsec, amount)
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()

View File

@@ -310,8 +310,8 @@
to_chat(src,"<span class='warning'>You can't process [substance]!</span>")
return //Only a few things matter, the rest are best not cluttering the lists.
var/howmuch = input(src,"How much do you want to store? (0-[matstack.amount])","Select amount") as null|num
if(!howmuch || matstack != get_active_hand() || howmuch > matstack.amount)
var/howmuch = input(src,"How much do you want to store? (0-[matstack.get_amount()])","Select amount") as null|num
if(!howmuch || matstack != get_active_hand() || howmuch > matstack.get_amount())
return //Quietly fail
var/actually_added = refactory.add_stored_material(substance,howmuch*matstack.perunit)

View File

@@ -139,10 +139,19 @@
H.synth_color = TRUE
/datum/species/protean/equip_survival_gear(var/mob/living/carbon/human/H)
<<<<<<< HEAD
var/boxtype = /obj/item/weapon/storage/box/survival //CHOMP Addition
var/obj/item/stack/material/steel/metal_stack = new()
metal_stack.amount = 5 //CHOMP Edit
||||||| parent of e5c108269d... Merge pull request #11454 from VOREStation/Arokha/stacks
var/obj/item/stack/material/steel/metal_stack = new()
metal_stack.amount = 3
=======
var/obj/item/stack/material/steel/metal_stack = new(null, 3)
>>>>>>> e5c108269d... Merge pull request #11454 from VOREStation/Arokha/stacks
var/obj/item/clothing/accessory/permit/nanotech/permit = new()
permit.set_name(H.real_name)

View File

@@ -62,11 +62,8 @@
// This could be done better.
var/obj/item/stack/medical/MED = O
if(health < getMaxHealth())
if(MED.amount >= 1)
if(MED.use(1))
adjustBruteLoss(-MED.heal_brute)
MED.amount -= 1
if(MED.amount <= 0)
qdel(MED)
visible_message("<b>\The [user]</b> applies the [MED] on [src].")
else
var/datum/gender/T = gender_datums[src.get_visible_gender()]

View File

@@ -757,8 +757,7 @@ GLOBAL_VAR_INIT(teppi_count, 0) // How mant teppi DO we have?
if(do_after(user, sheartime, exclusive = TASK_USER_EXCLUSIVE, target = src))
user.visible_message("<span class='notice'>\The [user] shears \the [src] with \the [tool].</span>","<span class='notice'>You shear \the [src] with \the [tool].</span>")
amount_grown = rand(0,250)
var/obj/item/stack/material/fur/F = new(get_turf(user))
F.amount = rand(10,15)
var/obj/item/stack/material/fur/F = new(get_turf(user), rand(10,15))
F.color = marking_color
teppi_wool = FALSE
update_icon()

View File

@@ -57,8 +57,7 @@
continue
while(count > 0)
inst = new real_path
inst.amount = min(count, max_amount)
inst = new real_path(null, min(count, max_amount))
count -= inst.get_amount()
. += inst

View File

@@ -559,7 +559,7 @@ GLOBAL_LIST_EMPTY(apcs)
"You start adding cables to the APC frame...")
playsound(src, 'sound/items/Deconstruct.ogg', 50, 1)
if(do_after(user, 20))
if(C.amount >= 10 && !terminal && opened && has_electronics != APC_HAS_ELECTRONICS_SECURED)
if(C.get_amount() >= 10 && !terminal && opened && has_electronics != APC_HAS_ELECTRONICS_SECURED)
var/obj/structure/cable/N = T.get_cable_node()
if(prob(50) && electrocute_mob(usr, N, N))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread

View File

@@ -163,10 +163,8 @@
//Removes one stack's worth of material from the generator.
/obj/machinery/power/port_gen/pacman/DropFuel()
if(sheets)
var/obj/item/stack/material/S = new sheet_path(loc)
var/amount = min(sheets, S.max_amount)
S.amount = amount
sheets -= amount
var/obj/item/stack/material/S = new sheet_path(loc, sheets)
sheets -= S.get_amount()
/obj/machinery/power/port_gen/pacman/UseFuel()
@@ -265,7 +263,7 @@
/obj/machinery/power/port_gen/pacman/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(istype(O, sheet_path))
var/obj/item/stack/addstack = O
var/amount = min((max_sheets - sheets), addstack.amount)
var/amount = min((max_sheets - sheets), addstack.get_amount())
if(amount < 1)
to_chat(user, "<span class='warning'>The [src.name] is full!</span>")
return

View File

@@ -216,7 +216,7 @@
to_chat(user, "<span class='notice'>\The [src] is already fully repaired.</span>")
return
var/obj/item/stack/P = W
if(P.amount < amt)
if(!P.can_use(amt))
to_chat(user, "<span class='warning'>You don't have enough sheets to repair this! You need at least [amt] sheets.</span>")
return
to_chat(user, "<span class='notice'>You begin repairing \the [src]...</span>")

View File

@@ -63,8 +63,7 @@ GLOBAL_LIST_EMPTY(solars_list)
if(do_after(user, 50))
var/obj/item/solar_assembly/S = new(loc)
S.anchored = TRUE
var/obj/item/stack/glass = new glass_type(loc)
glass.amount = 2
new glass_type(loc, 2)
playsound(src, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message("<span class='notice'>[user] takes the glass off the solar panel.</span>")
qdel(src)

View File

@@ -58,8 +58,7 @@
var/obj/item/solar_assembly/S = new(loc)
S.tracker = TRUE
S.anchored = TRUE
var/obj/item/stack/glass = new glass_type(loc)
glass.amount = 2
new glass_type(loc, 2)
playsound(src, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message("<span class='notice'>[user] takes the glass off the tracker.</span>")
qdel(src)

View File

@@ -232,7 +232,7 @@
var/obj/item/stack/stack = O
if(istype(stack))
var/list/sheet_components = sheet_reagents[stack.type]
var/amount_to_take = max(0,min(stack.amount,round(remaining_volume/REAGENTS_PER_SHEET)))
var/amount_to_take = max(0,min(stack.get_amount(),round(remaining_volume/REAGENTS_PER_SHEET)))
if(amount_to_take)
stack.use(amount_to_take)
if(QDELETED(stack))

View File

@@ -271,9 +271,7 @@
var/chosen = pick(material)
if(chosen in rare_types)
spawn_amount = rand(1,15)
var/obj/item/stack/material/C = new chosen
C.amount = spawn_amount
C.loc = get_turf(holder.my_atom)
new chosen(get_turf(holder.my_atom), spawn_amount)
/decl/chemical_reaction/instant/slimelight
name = "Slime Glow"
@@ -297,9 +295,7 @@
result_amount = 1
/decl/chemical_reaction/instant/slimephoron/on_reaction(var/datum/reagents/holder)
var/obj/item/stack/material/phoron/P = new /obj/item/stack/material/phoron
P.amount = 10
P.loc = get_turf(holder.my_atom)
new /obj/item/stack/material/phoron(get_turf(holder.my_atom), 10)
/decl/chemical_reaction/instant/slimefreeze
name = "Slime Freeze"

View File

@@ -349,11 +349,11 @@
if(istype(O, /obj/item/stack/medical/bruise_pack) && round(volume) >= 5)
var/obj/item/stack/medical/bruise_pack/C = O
var/packname = C.name
var/to_produce = min(C.amount, round(volume / 5))
var/to_produce = min(C.get_amount(), round(volume / 5))
var/obj/item/stack/medical/M = C.upgrade_stack(to_produce)
if(M && M.amount)
if(M && M.get_amount())
holder.my_atom.visible_message("<b>\The [packname]</b> bubbles.")
remove_self(to_produce * 5)
@@ -1284,11 +1284,11 @@
if(istype(O, /obj/item/stack/medical/crude_pack) && round(volume) >= 1)
var/obj/item/stack/medical/crude_pack/C = O
var/packname = C.name
var/to_produce = min(C.amount, round(volume))
var/to_produce = min(C.get_amount(), round(volume))
var/obj/item/stack/medical/M = C.upgrade_stack(to_produce)
if(M && M.amount)
if(M && M.get_amount())
holder.my_atom.visible_message("<b>\The [packname]</b> bubbles.")
remove_self(to_produce)

View File

@@ -188,8 +188,8 @@
var/stacktype = M.stack_type
var/turf/T = get_step(src, dir)
var/obj/item/stack/S = locate(stacktype) in T
if(S)
S.amount++
if(S && S.get_amount() < S.max_amount)
S.add(1)
else
new stacktype(T)

View File

@@ -100,8 +100,7 @@ using metal and glass, it uses glass and reagents (usually sulphuric acid).
if(materials[f] >= SHEET_MATERIAL_AMOUNT)
var/path = getMaterialType(f)
if(path)
var/obj/item/stack/S = new path(loc)
S.amount = round(materials[f] / SHEET_MATERIAL_AMOUNT)
new path(loc, round(materials[f] / SHEET_MATERIAL_AMOUNT))
..()
/obj/machinery/r_n_d/circuit_imprinter/attackby(var/obj/item/O as obj, var/mob/user as mob)

View File

@@ -233,7 +233,7 @@
new_item.matter[i] = new_item.matter[i] * mat_efficiency
/obj/machinery/r_n_d/protolathe/proc/eject_materials(var/material, var/amount) // 0 amount = 0 means ejecting a full stack; -1 means eject everything
var/recursive = amount == -1 ? 1 : 0
var/recursive = amount == -1 ? TRUE : FALSE
material = lowertext(material)
var/obj/item/stack/material/mattype
var/datum/material/MAT = get_material_by_name(material)
@@ -250,9 +250,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(materials[material] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(ejected, amount))
return
materials[material] -= ejected * S.perunit
if(recursive && materials[material] >= S.perunit)

View File

@@ -38,6 +38,5 @@
eject = amount == -1 ? eject : min(eject, amount)
if(eject < 1)
return
var/obj/item/stack/material/S = new sheetType(loc)
S.amount = eject
new sheetType(loc, eject)
materials[material] -= eject * perUnit

View File

@@ -394,9 +394,9 @@
var/amnt = S.perunit
if(stored_material[S.material.name] + amnt <= max_res_amount)
if(S && S.amount >= 1)
if(S && S.get_amount() >= 1)
var/count = 0
while(stored_material[S.material.name] + amnt <= max_res_amount && S.amount >= 1)
while(stored_material[S.material.name] + amnt <= max_res_amount && S.get_amount() >= 1)
stored_material[S.material.name] += amnt
S.use(1)
count++