mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Adds fireworks and their launchers
This commit is contained in:
124
code/modules/fireworks/firework_launcher.dm
Normal file
124
code/modules/fireworks/firework_launcher.dm
Normal file
@@ -0,0 +1,124 @@
|
||||
/obj/machinery/firework_launcher
|
||||
name = "firework launcher"
|
||||
desc = "A machine for launching fireworks of varying practicality."
|
||||
icon = 'icons/obj/machines/firework_launcher.dmi'
|
||||
icon_state = "launcher01"
|
||||
density = TRUE
|
||||
anchored = TRUE
|
||||
|
||||
circuit = /obj/item/weapon/circuitboard/firework_launcher
|
||||
var/obj/item/weapon/firework_star/loaded_star
|
||||
var/last_launch
|
||||
var/launch_cooldown = 5 MINUTES
|
||||
|
||||
/obj/machinery/firework_launcher/Initialize()
|
||||
. = ..()
|
||||
|
||||
default_apply_parts()
|
||||
last_launch = world.time // Prevents cheesing cooldown by deconstructing and reconstructing
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/firework_launcher/RefreshParts()
|
||||
launch_cooldown = 5 MINUTES
|
||||
var/rating = 0
|
||||
for(var/obj/item/weapon/stock_parts/micro_laser/laser in component_parts)
|
||||
rating += laser.rating - 1
|
||||
launch_cooldown = max(0, (launch_cooldown - ((rating*30) SECONDS))) // For every part tier above 1 on the two lasers, reduce cooldown by 30 seconds. 1 minute cooldown on the tier 5 parts, 3 minutes on tier 3.
|
||||
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/firework_launcher/update_icon()
|
||||
icon_state = "launcher[loaded_star ? "1" : "0"][anchored ? "1" : "0"][panel_open ? "_open" : ""]"
|
||||
|
||||
/obj/machinery/firework_launcher/attackby(var/obj/item/O, var/mob/user)
|
||||
if(default_deconstruction_screwdriver(user, O))
|
||||
update_icon()
|
||||
return
|
||||
|
||||
if(default_deconstruction_crowbar(user, O))
|
||||
return
|
||||
|
||||
if(default_part_replacement(user, O))
|
||||
return
|
||||
|
||||
if(default_unfasten_wrench(user, O, 20))
|
||||
update_icon()
|
||||
return
|
||||
|
||||
if(istype(O, /obj/item/weapon/firework_star))
|
||||
loaded_star = O
|
||||
user.drop_item()
|
||||
O.forceMove(src)
|
||||
to_chat(user, "<span class='notice'>You insert the firework star into the launcher.</span>")
|
||||
add_fingerprint(user)
|
||||
update_icon()
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/firework_launcher/verb/eject()
|
||||
set category = "Object"
|
||||
set name = "Eject Firework Star"
|
||||
set src in oview(1)
|
||||
|
||||
var/mob/living/user = usr
|
||||
if(!user || user.stat != 0)
|
||||
return
|
||||
if(!loaded_star)
|
||||
to_chat(user, "<span class='notice'>There is no firework star loaded in the launcher.</span>")
|
||||
return
|
||||
else
|
||||
loaded_star.forceMove(get_turf(src))
|
||||
loaded_star = null
|
||||
add_fingerprint(user)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/firework_launcher/attack_hand(mob/user) // Maybe this proc could be better as entirely its own proc, called from attack_hand, but also I don't really see the point
|
||||
if(panel_open)
|
||||
to_chat(user, "<span class='warning'>Close the panel first!</span>")
|
||||
return
|
||||
|
||||
if(!loaded_star)
|
||||
to_chat(user, "<span class='notice'>There is no firework star loaded in the launcher.</span>")
|
||||
return
|
||||
|
||||
if((world.time - last_launch) <= launch_cooldown)
|
||||
to_chat(user, "<span class='notice'>The launcher is still re-priming for launch.</span>")
|
||||
return
|
||||
|
||||
if(!anchored)
|
||||
to_chat(user, "<span class='warning'>Launcher must be firmly secured to the ground before firework can be launched!</span>")
|
||||
return
|
||||
|
||||
var/datum/planet/P = get_planet()
|
||||
if(!P || !(P.weather_holder)) // There are potential cases of being outside but not on planet. And checking whether planet has weather at all is more sanity thing than anything.
|
||||
to_chat(user, "<span class='warning'>Launcher beeps as its safeties seem to prevent launch in the current location.</span>")
|
||||
return
|
||||
|
||||
var/datum/weather_holder/WH = P.weather_holder
|
||||
if(WH.firework_override && istype(loaded_star, /obj/item/weapon/firework_star/weather)) // Enable weather-based events to not be ruined
|
||||
to_chat(user, "<span class='warning'>Launcher beeps as it seems some interference is preventing launch of this type of firework.</span>")
|
||||
return
|
||||
|
||||
to_chat(user, "<span class='notice'>You launch the firework!</span>")
|
||||
playsound(get_turf(src), 'sound/weapons/rpg.ogg', 75, 1)
|
||||
loaded_star.trigger_firework(WH)
|
||||
qdel(loaded_star)
|
||||
loaded_star = null
|
||||
last_launch = world.time
|
||||
add_fingerprint(user)
|
||||
update_icon()
|
||||
flick("launcher_launch", src)
|
||||
|
||||
/obj/machinery/firework_launcher/proc/get_planet()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!T)
|
||||
return
|
||||
|
||||
if(!T.is_outdoors())
|
||||
return
|
||||
|
||||
var/datum/planet/P = SSplanets.z_to_planet[T.z]
|
||||
if(!P)
|
||||
return
|
||||
return P
|
||||
142
code/modules/fireworks/firework_stars.dm
Normal file
142
code/modules/fireworks/firework_stars.dm
Normal file
@@ -0,0 +1,142 @@
|
||||
#define T_FIREWORK_WEATHER_STAR(name) "weather firework star (" + (name) + ")"
|
||||
|
||||
/obj/item/weapon/firework_star
|
||||
icon = 'icons/obj/firework_stars.dmi'
|
||||
name = "firework star"
|
||||
desc = "A very tightly compacted ball of chemicals for use with firework launcher."
|
||||
icon_state = "star"
|
||||
w_class = ITEMSIZE_SMALL
|
||||
origin_tech = list(TECH_MATERIAL = 2, TECH_ENGINEERING = 1)
|
||||
|
||||
/obj/item/weapon/firework_star/proc/trigger_firework(var/datum/weather_holder/w_holder)
|
||||
return
|
||||
|
||||
|
||||
/obj/item/weapon/firework_star/weather
|
||||
name = "weather firework star"
|
||||
desc = "A firework star designed to alter a weather, rather than put on a show."
|
||||
var/weather_type
|
||||
origin_tech = list(TECH_MATERIAL = 5, TECH_ENGINEERING = 2)
|
||||
|
||||
/obj/item/weapon/firework_star/weather/trigger_firework(var/datum/weather_holder/w_holder)
|
||||
if(!w_holder) // Sanity
|
||||
return
|
||||
if(w_holder.firework_override) // Make sure weather-based events can't be interfered with
|
||||
return
|
||||
if(weather_type && (weather_type in w_holder.allowed_weather_types))
|
||||
w_holder.message_all_outdoor_players("Something seems to flash in the sky, as weather suddenly shifts!")
|
||||
w_holder.change_weather(weather_type)
|
||||
w_holder.rebuild_forecast()
|
||||
|
||||
/obj/item/weapon/firework_star/weather/clear
|
||||
name = T_FIREWORK_WEATHER_STAR("CLEAR SKY")
|
||||
weather_type = WEATHER_CLEAR
|
||||
icon_state = "clear"
|
||||
|
||||
/obj/item/weapon/firework_star/weather/overcast
|
||||
name = T_FIREWORK_WEATHER_STAR("CLOUDY")
|
||||
weather_type = WEATHER_OVERCAST
|
||||
icon_state = "cloudy"
|
||||
|
||||
/obj/item/weapon/firework_star/weather/rain
|
||||
name = T_FIREWORK_WEATHER_STAR("RAIN")
|
||||
weather_type = WEATHER_RAIN
|
||||
icon_state = "rain"
|
||||
|
||||
/obj/item/weapon/firework_star/weather/storm
|
||||
name = T_FIREWORK_WEATHER_STAR("STORM")
|
||||
weather_type = WEATHER_STORM
|
||||
icon_state = "rain"
|
||||
|
||||
/obj/item/weapon/firework_star/weather/light_snow
|
||||
name = T_FIREWORK_WEATHER_STAR("SNOW - LIGHT")
|
||||
weather_type = WEATHER_LIGHT_SNOW
|
||||
icon_state = "snow"
|
||||
|
||||
/obj/item/weapon/firework_star/weather/snow
|
||||
name = T_FIREWORK_WEATHER_STAR("SNOW - MEDIUM")
|
||||
weather_type = WEATHER_SNOW
|
||||
icon_state = "snow"
|
||||
|
||||
/obj/item/weapon/firework_star/weather/blizzard
|
||||
name = T_FIREWORK_WEATHER_STAR("SNOW - HEAVY")
|
||||
weather_type = WEATHER_BLIZZARD
|
||||
icon_state = "snow"
|
||||
|
||||
/obj/item/weapon/firework_star/weather/hail
|
||||
name = T_FIREWORK_WEATHER_STAR("HAIL")
|
||||
weather_type = WEATHER_HAIL
|
||||
icon_state = "snow"
|
||||
origin_tech = list(TECH_MATERIAL = 5, TECH_ENGINEERING = 2, TECH_ILLEGAL = 1)
|
||||
|
||||
/obj/item/weapon/firework_star/weather/fallout
|
||||
name = T_FIREWORK_WEATHER_STAR("NUCLEAR")
|
||||
desc = "This is the worst idea ever."
|
||||
weather_type = WEATHER_FALLOUT_TEMP
|
||||
icon_state = "nuclear"
|
||||
origin_tech = list(TECH_MATERIAL = 7, TECH_ENGINEERING = 3, TECH_ILLEGAL = 5)
|
||||
|
||||
/obj/item/weapon/firework_star/weather/confetti
|
||||
name = T_FIREWORK_WEATHER_STAR("CONFETTI")
|
||||
desc = "A firework star designed to alter a weather, rather than put on a show. This one makes colorful confetti rain from the sky."
|
||||
weather_type = WEATHER_CONFETTI
|
||||
icon_state = "confetti"
|
||||
|
||||
|
||||
/obj/item/weapon/firework_star/aesthetic
|
||||
name = "aesthetic firework star"
|
||||
desc = "A firework star designed to paint the sky with pretty lights."
|
||||
var/list/firework_adjectives = list("beautiful", "pretty", "fancy", "colorful", "bright", "shimmering")
|
||||
var/list/firework_colors = list("red", "orange", "yellow", "green", "cyan", "blue", "purple", "pink", "beige", "white")
|
||||
|
||||
/obj/item/weapon/firework_star/aesthetic/trigger_firework(var/datum/weather_holder/w_holder)
|
||||
if(!w_holder)
|
||||
return
|
||||
w_holder.message_all_outdoor_players(get_firework_message())
|
||||
|
||||
/obj/item/weapon/firework_star/aesthetic/proc/get_firework_message()
|
||||
return "You see a [pick(firework_adjectives)] explosion of [pick(firework_colors)] sparks in the sky!"
|
||||
|
||||
/obj/item/weapon/firework_star/aesthetic/configurable
|
||||
name = "configurable aesthetic firework star"
|
||||
desc = "A firework star designed to paint the sky with pretty lights. This one's advanced and can be configured to specific shapes or colors."
|
||||
icon_state = "config"
|
||||
var/current_color = "white"
|
||||
var/current_shape = "Random"
|
||||
var/list/firework_shapes = list("none", "Random",
|
||||
"a circle", "an oval", "a triangle", "a square", "a pentagon", "a hexagon", "an octagon", "a plus sign", "an x", "a star", "a spiral", "a heart", "a teardrop",
|
||||
"a smiling face", "a winking face", "a mouse", "a cat", "a dog", "a fox", "a bird", "a fish", "a lizard", "a bug", "a butterfly", "a robot", "a dragon", "a teppi", "a catslug",
|
||||
"a tree", "a leaf", "a flower", "a lightning bolt", "a cloud", "a sun", "a gemstone", "a flame", "a wrench", "a beaker", "a syringe", "a pickaxe", "a pair of handcuffs", "a crown",
|
||||
"a bottle", "a boat", "a spaceship",
|
||||
"Nanotrasen logo", "a geometric-looking letter S", "a dodecahedron")
|
||||
|
||||
/obj/item/weapon/firework_star/aesthetic/configurable/attack_self(var/mob/user)
|
||||
var/choice = tgui_alert(usr, "What setting do you want to adjust?", "Firework Star", list("Color", "Shape", "Nothing"))
|
||||
if(src.loc != user)
|
||||
return
|
||||
|
||||
if(choice == "Color")
|
||||
var/color_choice = tgui_input_list(user, "What color would you like firework to be?", "Firework Star", firework_colors)
|
||||
if(src.loc != user)
|
||||
return
|
||||
if(color_choice)
|
||||
current_color = color_choice
|
||||
|
||||
if(choice == "Shape")
|
||||
var/shape_choice = tgui_input_list(user, "What shape would you like firework to be?", "Firework Star", firework_shapes)
|
||||
if(src.loc != user)
|
||||
return
|
||||
if(shape_choice)
|
||||
current_shape = shape_choice
|
||||
|
||||
/obj/item/weapon/firework_star/aesthetic/configurable/get_firework_message()
|
||||
var/temp_shape = current_shape
|
||||
if(temp_shape == "Random")
|
||||
var/list/shapes_copy = firework_shapes.Copy()
|
||||
shapes_copy -= "Random"
|
||||
temp_shape = pick(shapes_copy)
|
||||
|
||||
if(temp_shape == "none" || !temp_shape)
|
||||
return "You see a [pick(firework_adjectives)] explosion of [current_color] sparks in the sky!"
|
||||
else
|
||||
return "You see a [pick(firework_adjectives)] explosion of [current_color] sparks in the sky, forming into shape of [current_shape]!"
|
||||
8
code/modules/fireworks/launcher_construction.dm
Normal file
8
code/modules/fireworks/launcher_construction.dm
Normal file
@@ -0,0 +1,8 @@
|
||||
/obj/item/weapon/circuitboard/firework_launcher
|
||||
name = T_BOARD("firework launcher")
|
||||
board_type = new /datum/frame/frame_types/machine
|
||||
build_path = /obj/machinery/firework_launcher
|
||||
origin_tech = list(TECH_MATERIAL = 4, TECH_ENGINEERING = 2)
|
||||
req_components = list (
|
||||
/obj/item/weapon/stock_parts/micro_laser = 2
|
||||
)
|
||||
Reference in New Issue
Block a user