mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-27 10:32:40 +00:00
Ports GinjaNinja32's drinks rewrite from Bay
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
#define DRINK_ICON_FILE 'icons/pdrink.dmi'
|
||||
|
||||
/var/const/DRINK_FIZZ = "fizz"
|
||||
/var/const/DRINK_ICE = "ice"
|
||||
/var/const/DRINK_ICON_DEFAULT = ""
|
||||
/var/const/DRINK_ICON_NOISY = "_noise"
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2
|
||||
name = "glass" // Name when empty
|
||||
var/base_name = "glass" // Name to put in front of drinks, i.e. "[base_name] of [contents]"
|
||||
desc = "A generic drinking glass." // Description when empty
|
||||
icon = DRINK_ICON_FILE
|
||||
var/base_icon = "square" // Base icon name
|
||||
volume = 30
|
||||
|
||||
var/list/filling_states // List of percentages full that have icons
|
||||
|
||||
var/list/extras = list() // List of extras. Two extras maximum
|
||||
|
||||
var/rim_pos
|
||||
|
||||
center_of_mass = list("x"=16, "y"=10)
|
||||
|
||||
amount_per_transfer_from_this = 5
|
||||
possible_transfer_amounts = list(5,10,15,30)
|
||||
flags = OPENCONTAINER
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/examine(mob/M as mob)
|
||||
..()
|
||||
|
||||
for(var/I in extras)
|
||||
if(istype(I, /obj/item/weapon/glass_extra))
|
||||
M << "There is \a [I] in \the [src]."
|
||||
else if(istype(I, /obj/item/weapon/reagent_containers/food/snacks/fruit_slice))
|
||||
M << "There is \a [I] on the rim."
|
||||
else
|
||||
M << "There is \a [I] somewhere on the glass. Somehow."
|
||||
|
||||
if(has_ice())
|
||||
M << "There is some ice floating in the drink."
|
||||
|
||||
if(has_fizz())
|
||||
M << "It is fizzing slightly."
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/proc/has_ice()
|
||||
if(reagents.reagent_list.len > 0)
|
||||
var/datum/reagent/R = reagents.get_master_reagent()
|
||||
if(!((R.id == "ice") || ("ice" in R.glass_special))) // if it's not a cup of ice, and it's not already supposed to have ice in, see if the bartender's put ice in it
|
||||
if(reagents.has_reagent("ice", reagents.total_volume / 10)) // 10% ice by volume
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/proc/has_fizz()
|
||||
if(reagents.reagent_list.len > 0)
|
||||
var/datum/reagent/R = reagents.get_master_reagent()
|
||||
if(!("fizz" in R.glass_special))
|
||||
var/totalfizzy = 0
|
||||
for(var/datum/reagent/re in reagents.reagent_list)
|
||||
if("fizz" in re.glass_special)
|
||||
totalfizzy += re.volume
|
||||
if(totalfizzy >= reagents.total_volume / 5) // 20% fizzy by volume
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/New()
|
||||
..()
|
||||
icon_state = base_icon
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/on_reagent_change()
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/proc/can_add_extra(obj/item/weapon/glass_extra/GE)
|
||||
if(!("[base_icon]_[GE.glass_addition]left" in icon_states(DRINK_ICON_FILE)))
|
||||
return 0
|
||||
if(!("[base_icon]_[GE.glass_addition]right" in icon_states(DRINK_ICON_FILE)))
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/update_icon()
|
||||
underlays.Cut()
|
||||
|
||||
if (reagents.reagent_list.len > 0)
|
||||
var/datum/reagent/R = reagents.get_master_reagent()
|
||||
name = "[base_name] of [R.glass_name ? R.glass_name : "something"]"
|
||||
desc = R.glass_desc ? R.glass_desc : initial(desc)
|
||||
|
||||
var/list/under_liquid = list()
|
||||
var/list/over_liquid = list()
|
||||
|
||||
var/amnt = 100
|
||||
var/percent = round((reagents.total_volume / volume) * 100)
|
||||
for(var/k in filling_states)
|
||||
if(percent <= k)
|
||||
amnt = k
|
||||
break
|
||||
|
||||
if(has_ice())
|
||||
over_liquid |= "[base_icon][amnt]_ice"
|
||||
|
||||
if(has_fizz())
|
||||
over_liquid |= "[base_icon][amnt]_fizz"
|
||||
|
||||
for(var/S in R.glass_special)
|
||||
if("[base_icon]_[S]" in icon_states(DRINK_ICON_FILE))
|
||||
under_liquid |= "[base_icon]_[S]"
|
||||
else if("[base_icon][amnt]_[S]" in icon_states(DRINK_ICON_FILE))
|
||||
over_liquid |= "[base_icon][amnt]_[S]"
|
||||
|
||||
for(var/k in under_liquid)
|
||||
underlays += image(DRINK_ICON_FILE, src, k, -3)
|
||||
|
||||
var/image/filling = image(DRINK_ICON_FILE, src, "[base_icon][amnt][R.glass_icon]", -2)
|
||||
filling.color = reagents.get_color()
|
||||
underlays += filling
|
||||
|
||||
for(var/k in over_liquid)
|
||||
underlays += image(DRINK_ICON_FILE, src, k, -1)
|
||||
else
|
||||
name = initial(name)
|
||||
desc = initial(desc)
|
||||
|
||||
var/side = "left"
|
||||
for(var/item in extras)
|
||||
if(istype(item, /obj/item/weapon/glass_extra))
|
||||
var/obj/item/weapon/glass_extra/GE = item
|
||||
var/image/I = image(DRINK_ICON_FILE, src, "[base_icon]_[GE.glass_addition][side]")
|
||||
if(GE.glass_color)
|
||||
I.color = GE.glass_color
|
||||
underlays += I
|
||||
else if(istype(item, /obj/item/weapon/reagent_containers/food/snacks/fruit_slice))
|
||||
var/obj/FS = item
|
||||
var/image/I = image(FS)
|
||||
|
||||
var/fsy = rim_pos[1] - 20
|
||||
var/fsx = rim_pos[side == "left" ? 2 : 3] - 16
|
||||
|
||||
var/matrix/M = matrix()
|
||||
M.Scale(0.5)
|
||||
M.Translate(fsx, fsy)
|
||||
I.transform = M
|
||||
underlays += I
|
||||
else continue
|
||||
side = "right"
|
||||
@@ -0,0 +1,69 @@
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/attackby(obj/item/I as obj, mob/user as mob)
|
||||
if(extras.len >= 2) return ..() // max 2 extras, one on each side of the drink
|
||||
|
||||
if(istype(I, /obj/item/weapon/glass_extra))
|
||||
var/obj/item/weapon/glass_extra/GE = I
|
||||
if(can_add_extra(GE))
|
||||
extras += GE
|
||||
user.remove_from_mob(GE)
|
||||
GE.loc = src
|
||||
user << "<span class=notice>You add \the [GE] to \the [src].</span>"
|
||||
update_icon()
|
||||
else
|
||||
user << "<span class=warning>There's no space to put \the [GE] on \the [src]!</span>"
|
||||
else if(istype(I, /obj/item/weapon/reagent_containers/food/snacks/fruit_slice))
|
||||
var/obj/item/weapon/reagent_containers/food/snacks/fruit_slice/FS = I
|
||||
extras += FS
|
||||
user.remove_from_mob(FS)
|
||||
FS.pixel_x = 0 // Reset its pixel offsets so the icons work!
|
||||
FS.pixel_y = 0
|
||||
FS.loc = src
|
||||
user << "<span class=notice>You add \the [FS] to \the [src].</span>"
|
||||
update_icon()
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/attack_hand(mob/user as mob)
|
||||
if(src != user.get_inactive_hand())
|
||||
return ..()
|
||||
|
||||
if(!extras.len)
|
||||
user << "<span class=warning>There's nothing on the glass to remove!</span>"
|
||||
return
|
||||
|
||||
var/choice = input(user, "What would you like to remove from the glass?") as null|anything in extras
|
||||
if(!choice || !(choice in extras))
|
||||
return
|
||||
|
||||
if(user.put_in_active_hand(choice))
|
||||
user << "<span class=notice>You remove \the [choice] from \the [src].</span>"
|
||||
extras -= choice
|
||||
else
|
||||
user << "<span class=warning>Something went wrong, please try again.</span>"
|
||||
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/glass_extra
|
||||
name = "generic glass addition"
|
||||
desc = "This goes on a glass."
|
||||
var/glass_addition
|
||||
var/glass_desc
|
||||
var/glass_color
|
||||
w_class = 1
|
||||
icon = DRINK_ICON_FILE
|
||||
|
||||
/obj/item/weapon/glass_extra/stick
|
||||
name = "stick"
|
||||
desc = "This goes in a glass."
|
||||
glass_addition = "stick"
|
||||
glass_desc = "There is a stick in the glass."
|
||||
icon_state = "stick"
|
||||
|
||||
/obj/item/weapon/glass_extra/straw
|
||||
name = "straw"
|
||||
desc = "This goes in a glass."
|
||||
glass_addition = "straw"
|
||||
glass_desc = "There is a straw in the glass."
|
||||
icon_state = "straw"
|
||||
|
||||
#undef DRINK_ICON_FILE
|
||||
@@ -0,0 +1,75 @@
|
||||
/obj/item/weapon/storage/box/mixedglasses
|
||||
name = "glassware box"
|
||||
desc = "A box of assorted glassware"
|
||||
can_hold = list(/obj/item/weapon/reagent_containers/food/drinks/glass2)
|
||||
New()
|
||||
..()
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/square(src)
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/rocks(src)
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/shake(src)
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/cocktail(src)
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/shot(src)
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/pint(src)
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/mug(src)
|
||||
new /obj/item/weapon/reagent_containers/food/drinks/glass2/wine(src)
|
||||
|
||||
/obj/item/weapon/storage/box/glasses
|
||||
name = "box of glasses"
|
||||
var/glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2
|
||||
can_hold = list(/obj/item/weapon/reagent_containers/food/drinks/glass2)
|
||||
New()
|
||||
..()
|
||||
|
||||
for(var/i = 1 to 7)
|
||||
new glass_type(src)
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/square
|
||||
name = "box of half-pint glasses"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/square
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/rocks
|
||||
name = "box of rocks glasses"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/rocks
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/shake
|
||||
name = "box of milkshake glasses"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/shake
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/cocktail
|
||||
name = "box of cocktail glasses"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/cocktail
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/shot
|
||||
name = "box of shot glasses"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/shot
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/pint
|
||||
name = "box of pint glasses"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/pint
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/mug
|
||||
name = "box of glass mugs"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/mug
|
||||
|
||||
/obj/item/weapon/storage/box/glasses/wine
|
||||
name = "box of wine glasses"
|
||||
glass_type = /obj/item/weapon/reagent_containers/food/drinks/glass2/wine
|
||||
|
||||
/obj/item/weapon/storage/box/glass_extras
|
||||
name = "box of cocktail garnishings"
|
||||
var/extra_type = /obj/item/weapon/glass_extra
|
||||
can_hold = list(/obj/item/weapon/glass_extra)
|
||||
storage_slots = 14
|
||||
New()
|
||||
..()
|
||||
|
||||
for(var/i = 1 to 14)
|
||||
new extra_type(src)
|
||||
|
||||
/obj/item/weapon/storage/box/glass_extras/straws
|
||||
name = "box of straws"
|
||||
extra_type = /obj/item/weapon/glass_extra/straw
|
||||
|
||||
/obj/item/weapon/storage/box/glass_extras/sticks
|
||||
name = "box of drink sticks"
|
||||
extra_type = /obj/item/weapon/glass_extra/stick
|
||||
@@ -0,0 +1,72 @@
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/square
|
||||
name = "half-pint glass"
|
||||
base_name = "glass"
|
||||
base_icon = "square"
|
||||
desc = "Your standard drinking glass."
|
||||
filling_states = list(20, 40, 60, 80, 100)
|
||||
volume = 30
|
||||
possible_transfer_amounts = list(5,10,15,30)
|
||||
rim_pos = list(23,13,20) // y, x0, x1
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/rocks
|
||||
name = "rocks glass"
|
||||
base_name = "glass"
|
||||
base_icon = "rocks"
|
||||
filling_states = list(25, 50, 75, 100)
|
||||
volume = 20
|
||||
possible_transfer_amounts = list(5,10,20)
|
||||
rim_pos = list(21, 10, 23)
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/shake
|
||||
name = "milkshake glass"
|
||||
base_name = "glass"
|
||||
base_icon = "shake"
|
||||
filling_states = list(25, 50, 75, 100)
|
||||
volume = 30
|
||||
possible_transfer_amounts = list(5,10,15,30)
|
||||
rim_pos = list(25, 13, 21)
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/cocktail
|
||||
name = "cocktail glass"
|
||||
base_name = "glass"
|
||||
base_icon = "cocktail"
|
||||
filling_states = list(33, 66, 100)
|
||||
volume = 15
|
||||
possible_transfer_amounts = list(5,10,15)
|
||||
rim_pos = list(22, 13, 21)
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/shot
|
||||
name = "shot glass"
|
||||
base_name = "shot"
|
||||
base_icon = "shot"
|
||||
filling_states = list(33, 66, 100)
|
||||
volume = 5
|
||||
possible_transfer_amounts = list(1,2,5)
|
||||
rim_pos = list(17, 13, 21)
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/pint
|
||||
name = "pint glass"
|
||||
base_name = "pint"
|
||||
base_icon = "pint"
|
||||
filling_states = list(16, 33, 50, 66, 83, 100)
|
||||
volume = 60
|
||||
possible_transfer_amounts = list(5,10,15,30,60)
|
||||
rim_pos = list(25, 12, 21)
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/mug
|
||||
name = "glass mug"
|
||||
base_name = "mug"
|
||||
base_icon = "mug"
|
||||
filling_states = list(25, 50, 75, 100)
|
||||
volume = 40
|
||||
possible_transfer_amounts = list(5,10,20,40)
|
||||
rim_pos = list(22, 12, 20)
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/glass2/wine
|
||||
name = "wine glass"
|
||||
base_name = "glass"
|
||||
base_icon = "wine"
|
||||
filling_states = list(20, 40, 60, 80, 100)
|
||||
volume = 25
|
||||
possible_transfer_amounts = list(5, 10, 15, 25)
|
||||
rim_pos = list(25, 12, 21)
|
||||
43
code/modules/reagents/reagent_containers/food/drinks/cup.dm
Normal file
43
code/modules/reagents/reagent_containers/food/drinks/cup.dm
Normal file
@@ -0,0 +1,43 @@
|
||||
/obj/item/weapon/reagent_containers/food/drinks/cup
|
||||
name = "coffee cup"
|
||||
desc = "The container of oriental luxuries."
|
||||
icon_state = "cup_empty"
|
||||
amount_per_transfer_from_this = 5
|
||||
volume = 30
|
||||
center_of_mass = list("x"=16, "y"=16)
|
||||
|
||||
on_reagent_change()
|
||||
if (reagents.reagent_list.len > 0)
|
||||
var/datum/reagent/R = reagents.get_master_reagent()
|
||||
|
||||
if(R.cup_icon_state)
|
||||
icon_state = R.cup_icon_state
|
||||
else
|
||||
icon_state = "cup_brown"
|
||||
|
||||
if(R.cup_name)
|
||||
name = R.cup_name
|
||||
else
|
||||
name = "Cup of.. what?"
|
||||
|
||||
if(R.cup_desc)
|
||||
desc = R.cup_desc
|
||||
else
|
||||
desc = "You can't really tell what this is."
|
||||
|
||||
if(R.cup_center_of_mass)
|
||||
center_of_mass = R.cup_center_of_mass
|
||||
else
|
||||
center_of_mass = list("x"=16, "y"=16)
|
||||
|
||||
if(R.price_tag)
|
||||
price_tag = R.price_tag
|
||||
else
|
||||
price_tag = null
|
||||
|
||||
else
|
||||
icon_state = "cup_empty"
|
||||
name = "coffee cup"
|
||||
desc = "The container of oriental luxuries."
|
||||
center_of_mass = list("x"=16, "y"=16)
|
||||
return
|
||||
Reference in New Issue
Block a user