mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-11 08:06:33 +01:00
0b0c5ea91e
## About The Pull Request Extends the part of the crafting unit test that ensures consistency between the total mats of the components of a recipe (or rather, the result of said recipe) and a generic instance of the same type as its result, previously only implemented on food recipes. ## Why It's Good For The Game This ensures a degree of consistency with the material composition of various objects in the game. I couldn't do it in the original PR as that one was too big already and it took months to get it merged, and have the relative bugs fixed. Currently a WIP as I slowly deal with the unit test reports. ## Changelog 🆑 refactor: Follow-up to the crafting/material refactor from months ago. All objects crafted with stacks now inherit their mat composition (not necessarily the effects and color) by default, while previously only a few things like chair, sinks and toilets did. Report any object looking or behaving weirdly as a result. fix: The material composition of ammo boxes is no longer a 1/10 of what it's supposed to be. It was a shitty hack to make it harder to recycle empty ammo boxes. Instead, they lose materials as they're emptied now. /🆑
118 lines
3.0 KiB
Plaintext
118 lines
3.0 KiB
Plaintext
#define INFLATED "inflated"
|
|
#define POPPED "popped"
|
|
#define DEFLATED "deflated"
|
|
|
|
/obj/item/latexballoon
|
|
name = "latex glove"
|
|
desc = "Sterile and airtight."
|
|
icon_state = "latexballoon"
|
|
icon = 'icons/obj/weapons/hand.dmi'
|
|
inhand_icon_state = "greyscale_gloves"
|
|
lefthand_file = 'icons/mob/inhands/clothing/gloves_righthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/clothing/gloves_lefthand.dmi'
|
|
force = 0
|
|
throwforce = 0
|
|
w_class = WEIGHT_CLASS_TINY
|
|
throw_speed = 1
|
|
throw_range = 7
|
|
custom_materials = list(/datum/material/iron = SMALL_MATERIAL_AMOUNT * 0.2, /datum/material/glass = SMALL_MATERIAL_AMOUNT * 0.2)
|
|
var/state = DEFLATED
|
|
var/datum/gas_mixture/air_contents = null
|
|
|
|
/obj/item/latexballoon/Initialize(mapload)
|
|
. = ..()
|
|
AddElement(/datum/element/atmos_sensitive, mapload)
|
|
AddElement(/datum/element/update_icon_updates_onmob)
|
|
|
|
/obj/item/latexballoon/proc/set_state(state_to_set)
|
|
state = state_to_set
|
|
update_appearance(UPDATE_ICON | UPDATE_DESC)
|
|
|
|
/obj/item/latexballoon/update_icon_state()
|
|
. = ..()
|
|
|
|
switch(state)
|
|
if(INFLATED)
|
|
icon_state = "latexballoon_blow"
|
|
lefthand_file = 'icons/mob/inhands/items_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/items_righthand.dmi'
|
|
inhand_icon_state = "latexballoon"
|
|
if(POPPED)
|
|
icon_state = "latexballoon_bursted"
|
|
inhand_icon_state = initial(inhand_icon_state)
|
|
lefthand_file = initial(lefthand_file)
|
|
righthand_file = initial(righthand_file)
|
|
|
|
/obj/item/latexballoon/update_desc()
|
|
. = ..()
|
|
switch(state)
|
|
if(INFLATED)
|
|
desc = "It's a blown up latex glove on a string."
|
|
if(POPPED)
|
|
desc = "The remains of a latex glove."
|
|
|
|
/obj/item/latexballoon/proc/blow(obj/item/tank/tank, mob/user)
|
|
if(state == POPPED)
|
|
return
|
|
|
|
air_contents = tank.remove_air_volume(3)
|
|
|
|
if(isnull(air_contents))
|
|
balloon_alert(user, "tank is empty!")
|
|
return
|
|
|
|
if(state == INFLATED)
|
|
burst() // too much air, pop it!
|
|
return
|
|
|
|
playsound(src, 'sound/items/modsuit/inflate_bloon.ogg', 50, TRUE)
|
|
|
|
balloon_alert(user, "you blow up the balloon!") // because it's a balloon obviously
|
|
|
|
set_state(INFLATED)
|
|
|
|
/obj/item/latexballoon/should_atmos_process(datum/gas_mixture/air, exposed_temperature)
|
|
return (exposed_temperature > T0C+100)
|
|
|
|
/obj/item/latexballoon/atmos_expose(datum/gas_mixture/air, exposed_temperature)
|
|
burst()
|
|
|
|
/obj/item/latexballoon/proc/burst()
|
|
if (!air_contents || state != INFLATED)
|
|
return
|
|
|
|
set_state(POPPED)
|
|
playsound(src, 'sound/items/balloon_pop.ogg', 75, TRUE)
|
|
loc.assume_air(air_contents)
|
|
|
|
/obj/item/latexballoon/ex_act(severity, target)
|
|
burst()
|
|
switch(severity)
|
|
if (EXPLODE_DEVASTATE)
|
|
qdel(src)
|
|
if (EXPLODE_HEAVY)
|
|
if (prob(50))
|
|
qdel(src)
|
|
|
|
return TRUE
|
|
|
|
/obj/item/latexballoon/bullet_act(obj/projectile/projectile)
|
|
if(projectile.damage > 0)
|
|
burst()
|
|
return ..()
|
|
|
|
/obj/item/latexballoon/attackby(obj/item/item, mob/user, list/modifiers, list/attack_modifiers)
|
|
if(istype(item, /obj/item/tank))
|
|
var/obj/item/tank/air_tank = item
|
|
blow(air_tank, user)
|
|
return
|
|
if(item.get_sharpness() || item.get_temperature())
|
|
burst()
|
|
return
|
|
|
|
return ..()
|
|
|
|
#undef INFLATED
|
|
#undef POPPED
|
|
#undef DEFLATED
|