mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-07-18 03:32:56 +01:00
1ccb2df2de
NB. In some cases we go from a more complex image() to a single icon_state string and I assume this works for every case but do not care to check because of the sheer scale of extra fiddly effort. Buyer beware, not my code.
101 lines
3.0 KiB
Plaintext
101 lines
3.0 KiB
Plaintext
var/global/list/ashtray_cache = list()
|
|
|
|
/obj/item/material/ashtray
|
|
name = "ashtray"
|
|
icon = 'icons/obj/objects.dmi'
|
|
icon_state = "blank"
|
|
randpixel = 5
|
|
force_divisor = 0.1
|
|
thrown_force_divisor = 0.1
|
|
var/image/base_image
|
|
var/max_butts = 10
|
|
|
|
/obj/item/material/ashtray/Initialize(var/ml, var/material_name)
|
|
. = ..(ml, material_name)
|
|
if(!material)
|
|
return INITIALIZE_HINT_QDEL
|
|
max_butts = round(material.hardness/5) //This is arbitrary but whatever.
|
|
randpixel_xy()
|
|
update_icon()
|
|
|
|
/obj/item/material/ashtray/update_icon()
|
|
color = null
|
|
cut_overlays()
|
|
var/cache_key = "base-[material.name]"
|
|
if(!ashtray_cache[cache_key])
|
|
var/image/I = image('icons/obj/objects.dmi',"ashtray")
|
|
I.color = material.icon_colour
|
|
ashtray_cache[cache_key] = I
|
|
add_overlay(ashtray_cache[cache_key])
|
|
|
|
if (contents.len == max_butts)
|
|
if(!ashtray_cache["full"])
|
|
ashtray_cache["full"] = image('icons/obj/objects.dmi',"ashtray_full")
|
|
add_overlay(ashtray_cache["full"])
|
|
desc = "It's stuffed full."
|
|
else if (contents.len > max_butts/2)
|
|
if(!ashtray_cache["half"])
|
|
ashtray_cache["half"] = image('icons/obj/objects.dmi',"ashtray_half")
|
|
add_overlay(ashtray_cache["half"])
|
|
desc = "It's half-filled."
|
|
else
|
|
desc = "An ashtray made of [material.display_name]."
|
|
|
|
/obj/item/material/ashtray/attackby(obj/item/W as obj, mob/user as mob)
|
|
if (health <= 0)
|
|
return
|
|
if (istype(W,/obj/item/trash/cigbutt) || istype(W,/obj/item/clothing/mask/smokable/cigarette) || istype(W, /obj/item/flame/match))
|
|
if (contents.len >= max_butts)
|
|
to_chat(user, "\The [src] is full.")
|
|
return
|
|
user.remove_from_mob(W)
|
|
W.loc = src
|
|
|
|
if (istype(W,/obj/item/clothing/mask/smokable/cigarette))
|
|
var/obj/item/clothing/mask/smokable/cigarette/cig = W
|
|
if (cig.lit == 1)
|
|
src.visible_message("[user] crushes [cig] in \the [src], putting it out.")
|
|
STOP_PROCESSING(SSobj, cig)
|
|
var/obj/item/butt = new cig.type_butt(src)
|
|
cig.transfer_fingerprints_to(butt)
|
|
qdel(cig)
|
|
W = butt
|
|
//spawn(1)
|
|
// TemperatureAct(150)
|
|
else if (cig.lit == 0)
|
|
to_chat(user, "You place [cig] in [src] without even smoking it. Why would you do that?")
|
|
|
|
src.visible_message("[user] places [W] in [src].")
|
|
user.update_inv_l_hand()
|
|
user.update_inv_r_hand()
|
|
add_fingerprint(user)
|
|
update_icon()
|
|
else
|
|
health = max(0,health - W.force)
|
|
to_chat(user, "You hit [src] with [W].")
|
|
if (health < 1)
|
|
shatter()
|
|
return
|
|
|
|
/obj/item/material/ashtray/throw_impact(atom/hit_atom)
|
|
if (health > 0)
|
|
health = max(0,health - 3)
|
|
if (contents.len)
|
|
src.visible_message("<span class='danger'>\The [src] slams into [hit_atom], spilling its contents!</span>")
|
|
for (var/obj/item/clothing/mask/smokable/cigarette/O in contents)
|
|
O.loc = src.loc
|
|
if (health < 1)
|
|
shatter()
|
|
return
|
|
update_icon()
|
|
return ..()
|
|
|
|
/obj/item/material/ashtray/plastic/Initialize(var/ml)
|
|
. = ..(ml, MAT_PLASTIC)
|
|
|
|
/obj/item/material/ashtray/bronze/Initialize(var/ml)
|
|
. = ..(ml, MAT_BRONZE)
|
|
|
|
/obj/item/material/ashtray/glass/Initialize(var/ml)
|
|
. = ..(ml, MAT_GLASS)
|