Merge pull request #12319 from Very-Soft/trader

Trader!
This commit is contained in:
Casey
2022-02-25 14:57:44 -05:00
committed by CHOMPStation2
parent 5595f511c6
commit a2646d37c5
11 changed files with 350 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/obj/item/capture_crystal
name = "curious crystal"
name = "capture crystal"
desc = "A silent, unassuming crystal in what appears to be some kind of steel housing."
icon = 'icons/obj/capture_crystal_vr.dmi'
icon_state = "inactive"
@@ -503,13 +503,18 @@
to_chat(thrower, "<span class='notice'>\The [src] clicks unpleasantly...</span>")
playsound(src, 'sound/effects/capture-crystal-negative.ogg', 75, 1, -1)
/obj/item/capture_crystal/basic
/obj/item/capture_crystal/great
name = "great capture crystal"
capture_chance_modifier = 1.5
/obj/item/capture_crystal/ultra
name = "ultra capture crystal"
capture_chance_modifier = 2
/obj/item/capture_crystal/master
name = "master capture crystal"
capture_chance_modifier = 100
/obj/item/capture_crystal/cass

View File

@@ -18,7 +18,7 @@
spawn_nothing_percentage = 50
/obj/random/awayloot/item_to_spawn()
return pick(prob(50);/obj/item/weapon/aliencoin,
return pick(prob(50);/obj/item/weapon/aliencoin/basic,
prob(40);/obj/item/weapon/aliencoin/silver,
prob(30);/obj/item/weapon/aliencoin/gold,
prob(20);/obj/item/weapon/aliencoin/phoron,

View File

@@ -18,23 +18,25 @@
/obj/item/weapon/aliencoin/New()
randpixel_xy()
/obj/item/weapon/aliencoin/basic
/obj/item/weapon/aliencoin/gold
name = "curious coin"
icon_state = "triangle-g"
desc = "A curious triangular coin made primarily of some kind of dark, smooth metal. This one's markings appear to reveal a golden material underneath."
value = 3
value = 10
/obj/item/weapon/aliencoin/silver
name = "curious coin"
icon_state = "triangle-s"
desc = "A curious triangular coin made primarily of some kind of dark, smooth metal. This one's markings appear to reveal a silver material underneath."
value = 2
value = 5
/obj/item/weapon/aliencoin/phoron
name = "curious coin"
icon_state = "triangle-p"
desc = "A curious triangular coin made primarily of some kind of dark, smooth metal. This one's markings appear to reveal a purple material underneath."
value = 4
value = 20
/obj/item/weapon/aliencoin/attack_self(mob/user as mob)

View File

@@ -0,0 +1,329 @@
/obj/trader
name = "trader"
desc = "Some kind of trade thing."
icon = 'icons/obj/vending.dmi'
icon_state = "generic"
anchored = TRUE
density = TRUE
unacidable = TRUE
var/accepts = "coin" // "coin" - "money" - "item" - determines the 'kind' of thing the machine will accept
var/accepted_itemtype //only for use with "item" mode - if set to a type path, it will count anything with that type path
var/accepted_item_worth = 1 //only for use with "item" mode - when counted, things of the appropriate type will add this much to the banked funds
var/list/bank = list() //Anything accepted by "money" or "item" mode will be marked down here
var/coinbalance = 0 //only for use with coin mode - when you put a curious coin in, it adds the coins value to this number
var/list/start_products = list() //Type paths entered here will spawn inside the trader and add themselves to the products list.
var/list/products = list() //Anything in this list will be listed for sale
var/list/prices = list() //Enter a type path with an associated number, and if the trader tries to sell something of that type, it will expect the number as the cost for that product
var/list/multiple = list() //Enter a type path with an associated number, and the trader will have however many of that type to sell as the number you entered
var/trading = FALSE //'Busy' - Only one person can trade at a time.
var/welcome_msg = "This machine accepts" //The first part of the welcome message
var/welcome_accepts_name = "curious coins" //The name of the kind of thing the trader expects, automatically set except on "item" mode, where if you enter a value it will not change it.
var/welcome_msg_finish = ". Would you like to browse the wares?" //The final part of the welcome message.
var/list/interact_sound = list() //The sounds that may play when you click it. It will pick one at random from this list. It only thinks about this if there's anything in the list.
var/sound_cooldown = 0 //The sound can only play this often in deciseconds. Use '10 SECONDS' format to make it easier to read
var/sound_lastplayed = 0 //Automatically set when the sound is played.
var/pick_inventory = FALSE //If true, when initialized the trader will randomly pick things from its start products list to set up
var/pick_inventory_quantity = 0 //This is how many things will be picked if pick_inventory is TRUE
/obj/trader/Initialize(mapload)
. = ..()
if(pick_inventory)
while(pick_inventory_quantity > 0)
var/t = pickweight(start_products)
var/i = new t(src)
start_products -= t
products += i
pick_inventory_quantity --
else
for(var/item in start_products)
var/obj/p = new item(src)
products += p
start_products -= item
/obj/trader/Destroy()
. = ..()
LAZYCLEARLIST(products)
LAZYCLEARLIST(bank)
LAZYCLEARLIST(start_products)
LAZYCLEARLIST(prices)
LAZYCLEARLIST(multiple)
for(var/item in contents)
qdel(item)
/obj/trader/attack_hand(mob/living/user)
. = ..()
if(trading)
to_chat(user, "<span class='notice'>\The [src] is busy with someone else at the moment...</span>")
return
var/coin_value = get_value(accepts)
if(products.len > 0)
trading = TRUE
switch(accepts)
if("coin")
welcome_accepts_name = "curious coins"
if("money")
welcome_accepts_name = "Thalers"
if("item")
if(welcome_accepts_name == "curious coins")
welcome_accepts_name = "a kind of item"
var/ask = tgui_alert(user, "[welcome_msg][welcome_accepts_name][welcome_msg_finish]", "[src]",list("Yes","No","Return banked funds"), timeout = 10 SECONDS)
if (ask == "Return banked funds")
if(!Adjacent(user))
to_chat(user, "<span class='notice'>You aren't close enough.</span>")
trading = FALSE
return
return_funds()
trading = FALSE
return
else if(ask != "Yes")
trading = FALSE
return
if(!Adjacent(user))
to_chat(user, "<span class='notice'>You decided not to get anything.</span>")
trading = FALSE
return
if(interact_sound.len > 0)
if((world.time- sound_lastplayed) > sound_cooldown)
var/sound = pick(interact_sound)
playsound(src, sound, 25, FALSE, ignore_walls = FALSE)
sound_lastplayed = world.time
var/obj/input = tgui_input_list(user, "What would you like? You have [coin_value] banked with this trader.", "Trader", products, timeout = 30 SECONDS)
if(!input || !Adjacent(user))
to_chat(user, "<span class='notice'>You decided not to get anything.</span>")
trading = FALSE
return
var/p = 0
var/t = input.type
if(t in prices)
p = prices[t]
if(p > 0)
if(tgui_alert(user, "Are you sure? This costs [p].", "Confirm",list("Yes","No")) != "Yes")
to_chat(user, "<span class='notice'>You decided not to.</span>")
trading = FALSE
return
else if (coin_value < p)
to_chat(user, "<span class='warning'>You haven't provided enough funds!</span>")
trading = FALSE
return
if(!Adjacent(user))
to_chat(user, "<span class='notice'>You decided not to get anything.</span>")
trading = FALSE
return
if(t in multiple)
multiple[t] -= 1
var/temp = input
input = new t(get_turf(user))
if(multiple[t] <= 0)
for(var/obj/d in products)
if(istype(d, temp))
d.forceMove(get_turf(loc))
qdel(d)
input.forceMove(get_turf(user))
user.put_in_hands(input)
products -= input
deduct_value(p)
if(tgui_alert(user, "Would you like your change back, or would you like it to remain banked for later use? (Anyone can use banked funds)", "[src]",list("Keep it banked","I want my change"), timeout = 10 SECONDS) == "I want my change")
if(!Adjacent(user))
to_chat(user, "<span class='notice'>You aren't close enough.</span>")
trading = FALSE
return
visible_message("<span class='notice'>\The [src] drops the banked [welcome_accepts_name].</span>")
return_funds()
else
to_chat(user, "<span class='notice'>You decided leave your change banked.</span>")
trading = FALSE
else
to_chat(user, "<span class='notice'>\The [src] hasn't got anything to sell.</span>")
return
/obj/trader/attackby(obj/item/O, mob/user)
. = ..()
switch(accepts)
if("coin")
if(istype(O, /obj/item/weapon/aliencoin))
var/obj/item/weapon/aliencoin/a = O
coinbalance += a.value
visible_message("<span class='notice'>\The [src] accepts \the [user]'s [O].</span>")
qdel(a)
if("money")
if(istype(O, /obj/item/weapon/spacecash))
var/obj/item/weapon/spacecash/w = O
for(var/obj/item/weapon/spacecash/c in bank)
var/loadsamoney = w.worth
qdel(w)
c.worth += loadsamoney
c.update_icon()
loadsamoney = null
visible_message("<span class='notice'>\The [src] accepts \the [user]'s [O].</span>")
return
user.drop_item()
w.forceMove(src.contents)
bank += w
visible_message("<span class='notice'>\The [src] accepts \the [user]'s [w].</span>")
if("item")
if(istype(O, /obj))
user.drop_item()
O.forceMove(src.contents)
bank += O
visible_message("<span class='notice'>\The [src] accepts \the [user]'s [O].</span>")
/obj/trader/proc/get_value(kind)
var/value = 0
switch(kind)
if("coin")
value = coinbalance
if("money")
for(var/obj/c in bank)
if(istype(c, /obj/item/weapon/spacecash))
var/obj/item/weapon/spacecash/a = c
value += a.worth
else
c.forceMove(get_turf(src))
visible_message("<span class='warning'>\The [src] drops the worthless [c]...</span>")
if("item")
for(var/obj/c in bank)
if(istype(c, accepted_itemtype))
value += accepted_item_worth
else
c.forceMove(get_turf(src))
visible_message("<span class='warning'>\The [src] drops the worthless [c]...</span>")
return value
/obj/trader/proc/deduct_value(amount)
switch(accepts)
if("coin")
coinbalance -= amount
if("money")
for(var/obj/c in bank)
if(istype(c, /obj/item/weapon/spacecash))
var/obj/item/weapon/spacecash/a = c
a.worth -= amount
a.update_icon()
if("item")
var/v = amount
while(v > 0)
for(var/obj/c in bank)
if(istype(c, accepted_itemtype))
c.forceMove(get_turf(loc))
qdel(c)
v -= accepted_item_worth
/obj/trader/proc/return_funds()
switch(accepts)
if("coin")
while(coinbalance > 0)
if(coinbalance >= 20)
new /obj/item/weapon/aliencoin/phoron(get_turf(loc))
coinbalance -= 20
else if(coinbalance >= 10)
new /obj/item/weapon/aliencoin/gold(get_turf(loc))
coinbalance -= 10
else if(coinbalance >= 5)
new /obj/item/weapon/aliencoin/silver(get_turf(loc))
coinbalance -= 5
else
new /obj/item/weapon/aliencoin/basic(get_turf(loc))
coinbalance --
if("money")
for(var/obj/c in bank)
c.forceMove(get_turf(loc))
bank -= c
if("item")
for(var/obj/c in bank)
c.forceMove(get_turf(loc))
bank -= c
/obj/trader/capture_crystal
name = "curious trader"
desc = "A tall metal cylander on a squarish base. It looks almost like a vending machine, but there's nowhere to swipe your card. It appears to accept some kind of triangle currency..."
icon = 'icons/obj/vending_vr.dmi'
icon_state = "cap_crys"
interact_sound = list('sound/music/capture_crystal_1.ogg', 'sound/music/capture_crystal_2.ogg')
sound_cooldown = 1 MINUTE
start_products = list(
/obj/item/capture_crystal/basic,
/obj/item/capture_crystal/great,
/obj/item/capture_crystal/ultra,
/obj/item/capture_crystal/master,
/obj/item/capture_crystal/random
)
prices = list(
/obj/item/capture_crystal/basic = 5,
/obj/item/capture_crystal/great = 10,
/obj/item/capture_crystal/ultra = 15,
/obj/item/capture_crystal/master = 100,
/obj/item/capture_crystal/random = 10
)
multiple = list(
/obj/item/capture_crystal/basic = 10,
/obj/item/capture_crystal/great = 5,
/obj/item/capture_crystal/ultra = 2)
/obj/trader/capture_crystal/cash
accepts = "money"
prices = list(
/obj/item/capture_crystal/basic = 500,
/obj/item/capture_crystal/great = 1000,
/obj/item/capture_crystal/ultra = 1500,
/obj/item/capture_crystal/master = 10000,
/obj/item/capture_crystal/random = 1000
)
/obj/trader/general
name = "trader"
desc = "A large canine woman. She might have a few things to sell."
icon = 'icons/obj/traderx64.dmi'
icon_state = "trader1"
pixel_x = -16
layer = ABOVE_MOB_LAYER
plane = ABOVE_MOB_PLANE
welcome_msg = "Hey there, welcome~ If you've got any"
welcome_msg_finish = " then I may have something for you. Would you like to browse what I've got?"
pick_inventory = TRUE
pick_inventory_quantity = 5
start_products = list(
/obj/item/capture_crystal/basic = 100,
/obj/item/capture_crystal/random = 50,
/obj/item/device/perfect_tele = 10,
/obj/item/device/chameleon = 25,
/obj/item/weapon/gun/energy/sizegun/old = 25,
/obj/item/weapon/implant/sizecontrol = 25,
/obj/item/clothing/under/hyperfiber/bluespace = 25,
/obj/item/device/nif/authentic = 1,
/obj/item/toy/bosunwhistle = 50,
/obj/item/weapon/cell/infinite = 10,
/obj/item/weapon/cell/void = 15,
/obj/item/weapon/cell/device/weapon/recharge/alien = 10,
/obj/item/weapon/reagent_containers/food/snacks/jellyfishcore = 50,
/obj/item/device/denecrotizer = 10,
/obj/item/clothing/shoes/boots/speed = 15,
/obj/item/weapon/bluespace_harpoon = 20,
/obj/item/weapon/telecube/randomized = 5
)
prices = list(
/obj/item/capture_crystal/basic = 6,
/obj/item/capture_crystal/random = 15,
/obj/item/device/perfect_tele = 20,
/obj/item/device/chameleon = 20,
/obj/item/weapon/gun/energy/sizegun/old = 10,
/obj/item/weapon/implant/sizecontrol = 10,
/obj/item/clothing/under/hyperfiber/bluespace = 10,
/obj/item/device/nif/authentic = 100,
/obj/item/toy/bosunwhistle = 1,
/obj/item/weapon/cell/infinite = 20,
/obj/item/weapon/cell/void = 20,
/obj/item/weapon/cell/device/weapon/recharge/alien = 20,
/obj/item/weapon/reagent_containers/food/snacks/jellyfishcore = 3,
/obj/item/device/denecrotizer = 20,
/obj/item/clothing/shoes/boots/speed = 20,
/obj/item/weapon/bluespace_harpoon = 20,
/obj/item/weapon/telecube/randomized = 50
)
multiple = list(
/obj/item/capture_crystal/basic = 10,
/obj/item/capture_crystal/random = 2,
/obj/item/weapon/gun/energy/sizegun/old = 2,
/obj/item/weapon/implant/sizecontrol = 2,
/obj/item/clothing/under/hyperfiber/bluespace = 2,
/obj/item/weapon/reagent_containers/food/snacks/jellyfishcore = 10
)

BIN
icons/obj/traderx64.dmi Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 147 KiB

View File

@@ -68,7 +68,7 @@
/turf/simulated/floor/tiled/eris/white/orangecorner,
/area/om_adventure/poi/medicalcenter)
"G" = (
/obj/structure/table/glass,
/obj/trader/capture_crystal,
/obj/machinery/light{
dir = 8
},

View File

@@ -136,6 +136,12 @@
},
/turf/simulated/floor/wood,
/area/om_adventure/poi/woodentemple)
"W" = (
/obj/trader/general{
dir = 8
},
/turf/simulated/floor/wood,
/area/om_adventure/poi/woodentemple)
"Z" = (
/turf/simulated/wall/hardwood,
/area/om_adventure/poi/woodentemple)
@@ -450,7 +456,7 @@ k
k
d
A
d
W
U
b
Q

Binary file not shown.

Binary file not shown.

View File

@@ -2277,6 +2277,7 @@
#include "code\modules\economy\price_list_yw.dm"
#include "code\modules\economy\retail_scanner.dm"
#include "code\modules\economy\TradeDestinations.dm"
#include "code\modules\economy\trader.dm"
#include "code\modules\economy\vending.dm"
#include "code\modules\economy\vending_machines.dm"
#include "code\modules\economy\vending_machines_vr.dm"