Cleaning up and finishing up

This commit is contained in:
Artur
2020-04-08 18:16:10 +03:00
parent c402c6dc30
commit 5fbe05f3c9
4 changed files with 85 additions and 64 deletions

View File

@@ -707,10 +707,10 @@ CIGARETTE PACKETS ARE IN FANCY.DM
desc = "A classy and highly sophisticated electronic cigarette, for classy and dignified gentlemen. A warning label reads \"Warning: Do not fill with flammable materials.\""//<<< i'd vape to that. desc = "A classy and highly sophisticated electronic cigarette, for classy and dignified gentlemen. A warning label reads \"Warning: Do not fill with flammable materials.\""//<<< i'd vape to that.
icon = 'icons/obj/clothing/masks.dmi' icon = 'icons/obj/clothing/masks.dmi'
icon_state = "black_vape" icon_state = "black_vape"
item_state = null item_state = "black_vape"
w_class = WEIGHT_CLASS_TINY w_class = WEIGHT_CLASS_TINY
var/chem_volume = 100 var/chem_volume = 100
var/vapetime = FALSE //this so it won't puff out clouds every tick var/vapetime = FALSE //this so it won't puff out clouds every tick
var/screw = FALSE // kinky var/screw = FALSE // kinky
var/super = FALSE //for the fattest vapes dude. var/super = FALSE //for the fattest vapes dude.
@@ -723,11 +723,10 @@ CIGARETTE PACKETS ARE IN FANCY.DM
. = ..() . = ..()
create_reagents(chem_volume, NO_REACT, NO_REAGENTS_VALUE) // so it doesn't react until you light it create_reagents(chem_volume, NO_REACT, NO_REAGENTS_VALUE) // so it doesn't react until you light it
reagents.add_reagent(/datum/reagent/drug/nicotine, 50) reagents.add_reagent(/datum/reagent/drug/nicotine, 50)
if(!icon_state) if(!param_color)
if(!param_color) param_color = pick("red","blue","black","white","green","purple","yellow","orange")
param_color = pick("red","blue","black","white","green","purple","yellow","orange") icon_state = "[param_color]_vape"
icon_state = "[param_color]_vape" item_state = "[param_color]_vape"
item_state = "[param_color]_vape"
/obj/item/clothing/mask/vape/attackby(obj/item/O, mob/user, params) /obj/item/clothing/mask/vape/attackby(obj/item/O, mob/user, params)
if(O.tool_behaviour == TOOL_SCREWDRIVER) if(O.tool_behaviour == TOOL_SCREWDRIVER)

View File

@@ -120,8 +120,6 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
var/scan_id = TRUE var/scan_id = TRUE
///Coins that we accept? ///Coins that we accept?
var/obj/item/coin/coin var/obj/item/coin/coin
///Bills we accept?
var/obj/item/stack/spacecash/bill
///Default price of items if not overridden ///Default price of items if not overridden
/** /**
* Is this item on station or not * Is this item on station or not
@@ -184,7 +182,6 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
/obj/machinery/vending/Destroy() /obj/machinery/vending/Destroy()
QDEL_NULL(wires) QDEL_NULL(wires)
QDEL_NULL(coin) QDEL_NULL(coin)
QDEL_NULL(bill)
return ..() return ..()
/obj/machinery/vending/can_speak() /obj/machinery/vending/can_speak()
@@ -356,7 +353,6 @@ GLOBAL_LIST_EMPTY(vending_products)
..() ..()
if(panel_open) if(panel_open)
default_unfasten_wrench(user, I, time = 60) default_unfasten_wrench(user, I, time = 60)
unbuckle_all_mobs(TRUE)
return TRUE return TRUE
/obj/machinery/vending/screwdriver_act(mob/living/user, obj/item/I) /obj/machinery/vending/screwdriver_act(mob/living/user, obj/item/I)
@@ -380,9 +376,6 @@ GLOBAL_LIST_EMPTY(vending_products)
if(coin) if(coin)
to_chat(user, "<span class='warning'>[src] already has [coin] inserted</span>") to_chat(user, "<span class='warning'>[src] already has [coin] inserted</span>")
return return
if(bill)
to_chat(user, "<span class='warning'>[src] already has [bill] inserted</span>")
return
if(!premium.len) if(!premium.len)
to_chat(user, "<span class='warning'>[src] doesn't have a coin slot.</span>") to_chat(user, "<span class='warning'>[src] doesn't have a coin slot.</span>")
return return
@@ -391,21 +384,6 @@ GLOBAL_LIST_EMPTY(vending_products)
coin = I coin = I
to_chat(user, "<span class='notice'>You insert [I] into [src].</span>") to_chat(user, "<span class='notice'>You insert [I] into [src].</span>")
return return
else if(istype(I, /obj/item/stack/spacecash))
if(coin)
to_chat(user, "<span class='warning'>[src] already has [coin] inserted</span>")
return
if(bill)
to_chat(user, "<span class='warning'>[src] already has [bill] inserted</span>")
return
var/obj/item/stack/S = I
if(!premium.len)
to_chat(user, "<span class='warning'>[src] doesn't have a bill slot.</span>")
return
S.use(1)
bill = new S.type(src, 1)
to_chat(user, "<span class='notice'>You insert [I] into [src].</span>")
return
else if(refill_canister && istype(I, refill_canister)) else if(refill_canister && istype(I, refill_canister))
if (!panel_open) if (!panel_open)
to_chat(user, "<span class='warning'>You should probably unscrew the service panel first!</span>") to_chat(user, "<span class='warning'>You should probably unscrew the service panel first!</span>")
@@ -424,6 +402,7 @@ GLOBAL_LIST_EMPTY(vending_products)
else else
to_chat(user, "<span class='warning'>There's nothing to restock!</span>") to_chat(user, "<span class='warning'>There's nothing to restock!</span>")
return return
if(compartmentLoadAccessCheck(user) && user.a_intent != INTENT_HARM) if(compartmentLoadAccessCheck(user) && user.a_intent != INTENT_HARM)
if(canLoadItem(I)) if(canLoadItem(I))
loadingAttempt(I,user) loadingAttempt(I,user)
@@ -514,10 +493,12 @@ GLOBAL_LIST_EMPTY(vending_products)
. = ..() . = ..()
/obj/machinery/vending/emag_act(mob/user) /obj/machinery/vending/emag_act(mob/user)
. = ..()
if(obj_flags & EMAGGED) if(obj_flags & EMAGGED)
return return
obj_flags |= EMAGGED obj_flags |= EMAGGED
to_chat(user, "<span class='notice'>You short out the product lock on [src].</span>") to_chat(user, "<span class='notice'>You short out the product lock on [src].</span>")
return TRUE
/obj/machinery/vending/_try_interact(mob/user) /obj/machinery/vending/_try_interact(mob/user)
if(seconds_electrified && !(stat & NOPOWER)) if(seconds_electrified && !(stat & NOPOWER))
@@ -534,7 +515,7 @@ GLOBAL_LIST_EMPTY(vending_products)
if(!ui) if(!ui)
var/datum/asset/assets = get_asset_datum(/datum/asset/spritesheet/vending) var/datum/asset/assets = get_asset_datum(/datum/asset/spritesheet/vending)
assets.send(user) assets.send(user)
ui = new(user, src, ui_key, "vending", ui_key, 450, 600, master_ui, state) ui = new(user, src, ui_key, "vending", name, 450, 600, master_ui, state)
ui.open() ui.open()
/obj/machinery/vending/ui_static_data(mob/user) /obj/machinery/vending/ui_static_data(mob/user)
@@ -575,6 +556,7 @@ GLOBAL_LIST_EMPTY(vending_products)
for(var/datum/data/vending_product/R in product_records + coin_records + hidden_records) for(var/datum/data/vending_product/R in product_records + coin_records + hidden_records)
.["stock"][R.name] = R.amount .["stock"][R.name] = R.amount
.["extended_inventory"] = extended_inventory .["extended_inventory"] = extended_inventory
.["coin"] = coin
/obj/machinery/vending/ui_act(action, params) /obj/machinery/vending/ui_act(action, params)
. = ..() . = ..()
@@ -588,11 +570,12 @@ GLOBAL_LIST_EMPTY(vending_products)
if(panel_open) if(panel_open)
to_chat(usr, "<span class='warning'>The vending machine cannot dispense products while its service panel is open!</span>") to_chat(usr, "<span class='warning'>The vending machine cannot dispense products while its service panel is open!</span>")
return return
if((!allowed(usr)) && !(obj_flags & EMAGGED) && scan_id) //For SECURE VENDING MACHINES YEAH
to_chat(usr, "<span class='warning'>Access denied.</span>" )
flick(icon_deny,src)
return
vend_ready = FALSE //One thing at a time!! vend_ready = FALSE //One thing at a time!!
var/datum/data/vending_product/R = locate(params["ref"]) var/datum/data/vending_product/R = locate(params["ref"])
var/list/record_to_check = product_records + coin_records
if(extended_inventory)
record_to_check = product_records + coin_records + hidden_records
if(!R || !istype(R) || !R.product_path) if(!R || !istype(R) || !R.product_path)
vend_ready = TRUE vend_ready = TRUE
return return
@@ -600,28 +583,60 @@ GLOBAL_LIST_EMPTY(vending_products)
if(!extended_inventory) if(!extended_inventory)
vend_ready = TRUE vend_ready = TRUE
return return
else if(!(R in record_to_check)) else if(R in coin_records)
if(!(coin))
to_chat(usr, "<span class='warning'>You need to a coin to get this item!</span>")
vend_ready = TRUE
return
if(coin && coin.string_attached)
if(!prob(50))
to_chat(usr, "<span class='warning'>You weren't able to pull [coin] out fast enough, the machine ate it, string and all!</span>")
QDEL_NULL(coin)
return
if(!usr.CanReach(src))
to_chat(usr, "<span class='notice'>You successfully pull [coin] out of [src] to the floor.</span>")
coin = null
if(!usr.put_in_hands(coin))
to_chat(usr, "<span class='warning'>You couldn't pull [coin] out because your hands are full!</span>")
QDEL_NULL(coin)
to_chat(usr, "<span class='notice'>You successfully pull [coin] out before [src] could swallow it.</span>")
coin = null
QDEL_NULL(coin)
else if(!(R in product_records))
vend_ready = TRUE vend_ready = TRUE
message_admins("Vending machine exploit attempted by [ADMIN_LOOKUPFLW(usr)]!") message_admins("Vending machine exploit attempted by [ADMIN_LOOKUPFLW(usr)]!")
return return
if (R.amount <= 0) if(R.amount <= 0)
say("Sold out of [R.name].") to_chat(usr, "<span class='warning'>Sold out.</span>")
flick(icon_deny,src)
vend_ready = TRUE vend_ready = TRUE
return return
if(last_shopper != usr || purchase_message_cooldown < world.time) else
say("Thank you for shopping with [src]!") R.amount--
purchase_message_cooldown = world.time + 5 SECONDS if(((last_reply + 200) <= world.time) && vend_reply)
last_shopper = usr speak(vend_reply)
last_reply = world.time
use_power(5) use_power(5)
if(icon_vend) //Show the vending animation if needed if(icon_vend) //Show the vending animation if needed
flick(icon_vend,src) flick(icon_vend,src)
playsound(src, 'sound/machines/machine_vend.ogg', 50, TRUE, extrarange = -3) var/vended = new R.product_path(get_turf(src))
new R.product_path(get_turf(src)) if(usr.CanReach(src) && usr.put_in_hands(vended))
R.amount-- to_chat(usr, "<span class='notice'>You take [R.name] out of the slot.</span>")
else
to_chat(usr, "<span class='warning'>[capitalize(R.name)] falls onto the floor!</span>")
SSblackbox.record_feedback("nested tally", "vending_machine_usage", 1, list("[type]", "[R.product_path]")) SSblackbox.record_feedback("nested tally", "vending_machine_usage", 1, list("[type]", "[R.product_path]"))
vend_ready = TRUE vend_ready = TRUE
return
if("takeoutcoin")
usr.put_in_hands(coin)
to_chat(usr, "<span class='notice'>You remove [coin] from [src].</span>")
coin = null
return
else if("togglevoice" && panel_open)
shut_up = !shut_up
/obj/machinery/vending/process() /obj/machinery/vending/process()
if(stat & (BROKEN|NOPOWER)) if(stat & (BROKEN|NOPOWER))
return PROCESS_KILL return PROCESS_KILL
@@ -669,28 +684,26 @@ GLOBAL_LIST_EMPTY(vending_products)
*/ */
/obj/machinery/vending/proc/throw_item() /obj/machinery/vending/proc/throw_item()
var/obj/throw_item = null var/obj/throw_item = null
var/mob/living/target = locate() in view(7,src) var/mob/living/target = locate() in view(7, src)
if(!target) if(!target)
return 0 return FALSE
for(var/datum/data/vending_product/R in shuffle(product_records)) for(var/datum/data/vending_product/R in shuffle(product_records))
if(R.amount <= 0) //Try to use a record that actually has something to dump. if(R.amount <= 0) //Try to use a record that actually has something to dump.
continue continue
var/dump_path = R.product_path var/dump_path = R.product_path
if(!dump_path) if(!dump_path)
continue continue
R.amount-- R.amount--
throw_item = new dump_path(loc) throw_item = new dump_path(loc)
break break
if(!throw_item) if(!throw_item)
return 0 return FALSE
pre_throw(throw_item) pre_throw(throw_item)
throw_item.throw_at(target, 16, 3) throw_item.throw_at(target, 16, 3)
visible_message("<span class='danger'>[src] launches [throw_item] at [target]!</span>") visible_message("<span class='danger'>[src] launches [throw_item] at [target]!</span>")
return 1 return TRUE
/** /**
* A callback called before an item is tossed out * A callback called before an item is tossed out
* *

View File

@@ -2,7 +2,6 @@ import { Fragment } from 'inferno';
import { act } from '../byond'; import { act } from '../byond';
import { Section, Box, Button, Table } from '../components'; import { Section, Box, Button, Table } from '../components';
import { classes } from 'common/react'; import { classes } from 'common/react';
import { useBackend } from '../backend';
export const Vending = props => { export const Vending = props => {
const { state } = props; const { state } = props;
@@ -10,24 +9,37 @@ export const Vending = props => {
const { ref } = config; const { ref } = config;
let inventory; let inventory;
let custom = false; let custom = false;
if (data.vending_machine_input) { const onstation = true;
inventory = data.vending_machine_input; if (data.extended_inventory && data.coin) {
custom = true; inventory = [
...data.product_records,
...data.hidden_records,
...data.coin_records,
];
} else if (data.extended_inventory) { } else if (data.extended_inventory) {
inventory = [ inventory = [
...data.product_records, ...data.product_records,
...data.coin_records,
...data.hidden_records, ...data.hidden_records,
]; ];
} else if (data.coin) {
inventory = [
...data.product_records,
...data.coin_records,
];
} else { } else {
inventory = [ inventory = [
...data.product_records, ...data.product_records,
...data.coin_records,
]; ];
} }
return ( return (
<Fragment> <Fragment>
) {data.coin && (
<Section title="Coins">
<Button
content={"Take out the coin"}
onClick={() => act(ref, 'takeoutcoin')} />
</Section>
)}
<Section title="Products" > <Section title="Products" >
<Table> <Table>
{inventory.map((product => { {inventory.map((product => {
@@ -65,16 +77,13 @@ export const Vending = props => {
<Table.Cell> <Table.Cell>
{custom && ( {custom && (
<Button <Button
content={"Vend"} content={'Vend'}
onClick={() => act(ref, 'dispense', { onClick={() => act(ref, 'dispense', {
'item': product.name, 'item': product.name,
})} /> })} />
) || ( ) || (
<Button <Button
disabled={( content={'Vend'}
data.stock[product.namename] === 0
)}
content={"Vend"}
onClick={() => act(ref, 'vend', { onClick={() => act(ref, 'vend', {
'ref': product.ref, 'ref': product.ref,
})} /> })} />

File diff suppressed because one or more lines are too long