mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 00:55:20 +01:00
fb58e99934
## About The Pull Request Two main items: 1: Admins can now use the new "Create new Blackmarket Item" verb, which prompts them about the item, price, quantity, name and description of the item they'd like to list. If successful, the item will be listed to the black market, available to purchase by the crew. Prices can be set very, very high, though I've limited the available quantity to 100 per listing as a nice middle-ground value. The verb can be used any number of times, allowing for admins to use the black market to run events, as such. Of note, this verb will spawn a fresh typepath of the object listed, so it cannot be used to list var-edited objects as-is, but it's still quite useful for offering unique or rare items to the crew based on the needs of the round. 2: This PR does a few tweaks to the "launch" shipping option on the black market. The text displayed when having an object launched to the station has been adjusted to reduce some ambiguity on if the item is potentially deleted when launched. The launch behavior has not been modified in this way, as the object is still launched at the station using similar logic as before. **However**, the item is now launched to the station in a faux-energy bubble, which destroys itself and empties it's contents when it makes thrown impact or is opened by hand. In practice, this is only noticeable if you were outside when the order is launched at the station, or if the crate makes impact with you. This allows for black market objects that create spawners to arrive at the station harmlessly, which also potentially reducing some of the randomness of an object being thrown at the station, and then leaving the z-level immediately based on the extra collision involved. Additionally, I've lowered the **shipping cost to 0** of launched items. Misc: Did some code cleanup by adding defines for each of the categories of black market items, and a list-define for every category together. ## Why It's Good For The Game I've wanted to have the option for admins to be able to list things for the crew to buy for quite awhile now, without requiring them to barter by hand or through a reliable means that can't be bypassed by 3 assistants with baseball bats. This offers that option, while also having some flavor of being offered on the black market, if that's desirable. Otherwise, it's no impact on the average round as it's admin-only. Regarding the launch options, this started as a grammar tweak as I was talking with Arm on discord and the lack of clarity raised the whole shipping option to our attention. After confirming that launching things to the station was NOT, in fact a literal noob trap, just an awful choice, I started work on the shield-bubble idea in an attempt to see if I could try and reduce some of the randomness involved with that shipping option. It already sucks due to the risk of going out into space, there's no need to make it suck worse by potentially losing any of the cooler items available on the black market at the same time. So, price down and a mild consistency up. I also ran into #95183 while I was testing all of this, so this should fix #95183. Lastly, code cleanup. Made a few things look 3% nicer.
98 lines
3.7 KiB
Plaintext
98 lines
3.7 KiB
Plaintext
/datum/market
|
|
/// Name for the market.
|
|
var/name = "huh?"
|
|
|
|
/// Available shipping methods and prices, just leave the shipping method out that you don't want to have.
|
|
var/list/shipping
|
|
|
|
// Automatic vars, do not touch these.
|
|
/// Items available from this market, populated by SSmarket on initialization. Automatically assigned, so don't manually adjust.
|
|
var/list/available_items = list()
|
|
/// Item categories available from this market, only items which are in these categories can be gotten from this market. Automatically assigned, so don't manually adjust.
|
|
var/list/categories = list()
|
|
/// Are the items from this market legal or illegal? If illegal, apply a contrband trait to the bought object.
|
|
var/legal_status = TRUE
|
|
|
|
/// Adds item to the available items and add its category if it is not in categories yet.
|
|
/datum/market/proc/add_item(datum/market_item/item)
|
|
if(ispath(item, /datum/market_item))
|
|
item = new item()
|
|
|
|
if(!(item.category in categories))
|
|
categories += item.category
|
|
available_items[item.category] = list()
|
|
|
|
available_items[item.category][item.identifier] = item
|
|
RegisterSignal(item, COMSIG_QDELETING, PROC_REF(on_item_del))
|
|
return TRUE
|
|
|
|
/datum/market/proc/on_item_del(datum/market_item/item)
|
|
SIGNAL_HANDLER
|
|
available_items[item.category] -= item.identifier
|
|
if(!length(available_items[item.category]))
|
|
available_items -= item.category
|
|
|
|
/**
|
|
* Handles buying the item for a market.
|
|
*
|
|
* @param identifier The identifier of the item to buy.
|
|
* @param category The category of the item to buy.
|
|
* @param method The shipping method to use to get the item on the station.
|
|
* @param uplink The uplink object that is buying the item.
|
|
* @param user The mob that is buying the item.
|
|
*/
|
|
/datum/market/proc/purchase(identifier, category, method, obj/item/market_uplink/uplink, user)
|
|
var/datum/market_item/item = available_items[category][identifier]
|
|
if(isnull(item))
|
|
return FALSE
|
|
|
|
if(!istype(uplink) || !((method in shipping) || (method in item.shipping_override)))
|
|
return FALSE
|
|
|
|
var/shipment_fee = item.shipping_override?[method]
|
|
if(isnull(shipment_fee))
|
|
shipment_fee = shipping[method]
|
|
var/price = item.price + shipment_fee
|
|
|
|
if(!uplink.current_user)///There is no ID card on the user, or the ID card has no account
|
|
to_chat(user, span_warning("The uplink sparks, as it can't identify an ID card with a bank account on you."))
|
|
return FALSE
|
|
var/balance = uplink?.current_user.account_balance
|
|
|
|
// I can't get the price of the item and shipping in a clean way to the UI, so I have to do this.
|
|
if(balance < price)
|
|
to_chat(user, span_warning("You don't have enough [MONEY_NAME] in [uplink] for [item] with [method] shipping."))
|
|
return FALSE
|
|
|
|
if(item.buy(uplink, user, method, legal_status))
|
|
uplink.current_user.adjust_money(-price, "Other: Third Party Transaction")
|
|
if(ismob(user))
|
|
var/mob/m_user = user
|
|
m_user.playsound_local(get_turf(m_user), 'sound/machines/beep/twobeep_high.ogg', 50, TRUE)
|
|
return TRUE
|
|
|
|
return FALSE
|
|
|
|
/**
|
|
* A proc that restocks only the EXISTING items of this market.
|
|
* If you want to selectively restock markets, call SSmarket.restock(market_or_list_of_markets) instead.
|
|
*/
|
|
/datum/market/proc/restock(list/existing_items)
|
|
for(var/category in available_items)
|
|
var/category_list = available_items[category]
|
|
for(var/identifier in category_list)
|
|
var/datum/market_item/item = category_list[identifier]
|
|
existing_items |= item.type
|
|
if(!item.restockable || item.stock >= item.stock_max || !prob(item.availability_prob))
|
|
continue
|
|
item.stock += rand(1, item.stock_max - item.stock)
|
|
|
|
/datum/market/blackmarket
|
|
name = "Black Market"
|
|
shipping = list(
|
|
SHIPPING_METHOD_LTSRBT = 40,
|
|
SHIPPING_METHOD_LAUNCH = 0,
|
|
SHIPPING_METHOD_TELEPORT = 75,
|
|
)
|
|
legal_status = FALSE
|