-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathdiscoball.dm
193 lines (175 loc) · 6.79 KB
/
discoball.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/obj/item/discoballdeployer
name = "Portable Disco Ball"
desc = "Press the button to launch a small party!!"
icon = 'icons/obj/device.dmi'
icon_state = "ethdisco"
/obj/item/discoballdeployer/attack_self(mob/living/carbon/user)
.=..()
to_chat(user, span_notice("You deploy the Disco Ball."))
playsound(src, 'sound/items/deconstruct.ogg', 50, 1)
new /obj/structure/discoball(user.loc)
qdel(src)
/obj/structure/discoball
name = "Disco Ball"
desc = "This is an improved portable disco ball model. Use wrench to undeploy."
icon = 'icons/obj/device.dmi'
icon_state = "disco_0"
anchored = TRUE
density = TRUE
var/TurnedOn = FALSE
var/current_color
var/TimerID
var/range = 7
var/power = 3
var/list/spotlights = list()
var/list/sparkles = list()
/obj/structure/discoball/Initialize(mapload)
. = ..()
update_appearance(UPDATE_ICON)
/obj/structure/discoball/attack_hand(mob/living/carbon/human/user)
. = ..()
if(TurnedOn)
TurnOff()
else
TurnOn()
/obj/structure/discoball/proc/TurnOn()
var/mob/living/user = usr
to_chat(user, span_notice("You turn on the disco ball."))
TurnedOn = TRUE //Same
DiscoFever()
dance_setup()
lights_spin()
/obj/structure/discoball/proc/TurnOff()
var/mob/living/user = usr
to_chat(user, span_notice("You turn off the disco ball."))
TurnedOn = FALSE
set_light(0)
remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
update_appearance(UPDATE_ICON)
if(TimerID)
deltimer(TimerID)
over()
/obj/structure/discoball/Destroy() //delete lights if destroyed
over()
return ..()
/obj/structure/discoball/proc/over()
QDEL_LIST(spotlights)
QDEL_LIST(sparkles)
/obj/structure/discoball/proc/DiscoFever()
remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
current_color = random_color()
set_light_color(current_color)
add_atom_colour("#[current_color]", FIXED_COLOUR_PRIORITY)
update_appearance(UPDATE_ICON)
TimerID = addtimer(CALLBACK(src, PROC_REF(DiscoFever)), 5, TIMER_STOPPABLE) //Call ourselves every 0.5 seconds to change colors
/obj/structure/discoball/update_overlays()
. = ..()
icon_state = "disco_[TurnedOn]"
var/mutable_appearance/base_overlay = mutable_appearance(icon, "ethdisco_base")
base_overlay.appearance_flags = RESET_COLOR
. += base_overlay
/obj/structure/discoball/wrench_act(mob/living/user, obj/item/I)
. = ..()
if(!TurnedOn)
to_chat(user, span_notice("You undeploy the Disco Ball."))
playsound(src, 'sound/items/deconstruct.ogg', 50, 1)
new /obj/item/discoballdeployer(user.loc)
qdel(src)
return TRUE
else
to_chat(user, span_notice("Cannot undeploy if active."))
return TRUE
/**
* im literally copying shit from radiant mk IV
* :(
*/
/obj/structure/discoball/proc/dance_setup()
var/turf/cen = get_turf(src)
var/turf/t
FOR_DVIEW(t, 3, get_turf(src),INVISIBILITY_LIGHTING)
if(t.x == cen.x && t.y > cen.y)
spotlights += new /obj/item/flashlight/spotlight(t, 1 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_RED)
continue
if(t.x == cen.x && t.y < cen.y)
spotlights += new /obj/item/flashlight/spotlight(t, 1 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_PURPLE)
continue
if(t.x > cen.x && t.y == cen.y)
spotlights += new /obj/item/flashlight/spotlight(t, 1 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_YELLOW)
continue
if(t.x < cen.x && t.y == cen.y)
spotlights += new /obj/item/flashlight/spotlight(t, 1 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_GREEN)
continue
if((t.x+1 == cen.x && t.y+1 == cen.y) || (t.x+2==cen.x && t.y+2 == cen.y))
spotlights += new /obj/item/flashlight/spotlight(t, 1.4 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_ORANGE)
continue
if((t.x-1 == cen.x && t.y-1 == cen.y) || (t.x-2==cen.x && t.y-2 == cen.y))
spotlights += new /obj/item/flashlight/spotlight(t, 1.4 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_CYAN)
continue
if((t.x-1 == cen.x && t.y+1 == cen.y) || (t.x-2==cen.x && t.y+2 == cen.y))
spotlights += new /obj/item/flashlight/spotlight(t, 1.4 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_BLUEGREEN)
continue
if((t.x+1 == cen.x && t.y-1 == cen.y) || (t.x+2==cen.x && t.y-2 == cen.y))
spotlights += new /obj/item/flashlight/spotlight(t, 1.4 + get_dist(src, t), 30 - (get_dist(src, t) * 8), LIGHT_COLOR_BLUE)
continue
continue
FOR_DVIEW_END
/obj/structure/discoball/proc/hierofunk()
for(var/i in 1 to 10)
spawn_atom_to_turf(/obj/effect/temp_visual/hierophant/telegraph/edge, src, 1, FALSE)
sleep(0.5 SECONDS)
#define DISCO_INFENO_RANGE (rand(85, 115)*0.01)
/obj/structure/discoball/proc/lights_spin()
for(var/i in 1 to 25)
if(QDELETED(src) || !TurnedOn)
return
var/obj/effect/overlay/sparkles/S = new /obj/effect/overlay/sparkles(src)
S.alpha = 0
sparkles += S
switch(i)
if(1 to 8)
S.orbit(src, 30, TRUE, 60, 36, TRUE)
if(9 to 16)
S.orbit(src, 62, TRUE, 60, 36, TRUE)
if(17 to 24)
S.orbit(src, 95, TRUE, 60, 36, TRUE)
if(25)
S.pixel_y = 7
S.forceMove(get_turf(src))
sleep(0.7 SECONDS)
for(var/s in sparkles)
var/obj/effect/overlay/sparkles/reveal = s
reveal.alpha = 255
while(TurnedOn)
for(var/g in spotlights) // The multiples reflects custom adjustments to each colors after dozens of tests
var/obj/item/flashlight/spotlight/glow = g
if(QDELETED(glow))
stack_trace("[glow?.gc_destroyed ? "Qdeleting glow" : "null entry"] found in [src].[gc_destroyed ? " Source qdeleting at the time." : ""]")
return
if(glow.light_color == LIGHT_COLOR_RED)
glow.set_light_range_power_color(0, glow.light_power * 1.48, LIGHT_COLOR_BLUE)
continue
if(glow.light_color == LIGHT_COLOR_BLUE)
glow.set_light_range_power_color(glow.light_range * DISCO_INFENO_RANGE, glow.light_power * 2, LIGHT_COLOR_GREEN)
continue
if(glow.light_color == LIGHT_COLOR_GREEN)
glow.set_light_range_power_color(0, glow.light_power * 0.5, LIGHT_COLOR_ORANGE)
continue
if(glow.light_color == LIGHT_COLOR_ORANGE)
glow.set_light_range_power_color(glow.light_range * DISCO_INFENO_RANGE, glow.light_power * 2.27, LIGHT_COLOR_PURPLE)
continue
if(glow.light_color == LIGHT_COLOR_PURPLE)
glow.set_light_range_power_color(0, glow.light_power * 0.44, LIGHT_COLOR_BLUEGREEN)
continue
if(glow.light_color == LIGHT_COLOR_BLUEGREEN)
glow.set_light_range_power_color(glow.light_range * DISCO_INFENO_RANGE, glow.light_power, LIGHT_COLOR_YELLOW)
continue
if(glow.light_color == LIGHT_COLOR_YELLOW)
glow.set_light_range_power_color(0, glow.light_power, LIGHT_COLOR_CYAN)
continue
if(glow.light_color == LIGHT_COLOR_CYAN)
glow.set_light_range_power_color(glow.light_range * DISCO_INFENO_RANGE, glow.light_power * 0.68, LIGHT_COLOR_RED)
continue
if(prob(2)) // Unique effects for the dance floor that show up randomly to mix things up
INVOKE_ASYNC(src, PROC_REF(hierofunk))
sleep(0.5 SECONDS)
#undef DISCO_INFENO_RANGE