Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit e235dbc

Browse files
fix cable layers and meteor spins (#21482)
1 parent c3f6abc commit e235dbc

5 files changed

Lines changed: 80 additions & 61 deletions

File tree

code/__DEFINES/dcs/signals/signals_atom/signals_atom_main.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
/// from cosmetic items to restyle certain mobs, objects or organs: (atom/source, mob/living/trimmer, atom/movable/original_target, body_zone, restyle_type, style_speed)
101101
#define COMSIG_ATOM_RESTYLE "atom_restyle"
102102

103+
/// Called on [/atom/SpinAnimation()] : (speed, loops, segments, angle)
104+
#define COMSIG_ATOM_SPIN_ANIMATION "atom_spin_animation"
105+
103106
///! from proc/get_rad_contents(): ()
104107
#define COMSIG_ATOM_RAD_PROBE "atom_rad_probe"
105108
#define COMPONENT_BLOCK_RADIATION 1

code/__HELPERS/animations.dm

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,53 @@
6565
animate(transform = transforms[2], time = 0.1)
6666
animate(transform = transforms[3], time = 0.2)
6767
animate(transform = transforms[4], time = 0.3)
68+
69+
70+
/**
71+
* Proc called when you want the atom to spin around the center of its icon (or where it would be if its transform var is translated)
72+
* By default, it makes the atom spin forever and ever at a speed of 60 rpm.
73+
*
74+
* Arguments:
75+
* * speed: how much it takes for the atom to complete one 360° rotation
76+
* * loops: how many times do we want the atom to rotate
77+
* * clockwise: whether the atom ought to spin clockwise or counter-clockwise
78+
* * segments: in how many animate calls the rotation is split. Probably unnecessary, but you shouldn't set it lower than 3 anyway.
79+
* * parallel: whether the animation calls have the ANIMATION_PARALLEL flag, necessary for it to run alongside concurrent animations.
80+
*/
81+
/atom/proc/SpinAnimation(speed = 1 SECONDS, loops = -1, clockwise = TRUE, segments = 3, parallel = TRUE)
82+
if(!segments)
83+
return
84+
var/segment = 360/segments
85+
if(!clockwise)
86+
segment = -segment
87+
SEND_SIGNAL(src, COMSIG_ATOM_SPIN_ANIMATION, speed, loops, segments, segment)
88+
do_spin_animation(speed, loops, segments, segment, parallel)
89+
90+
/atom/proc/DabAnimation(speed = 1, loops = 1, direction = 1 , hold_seconds = 0 , angle = 1 , stay = FALSE) // Hopek 2019
91+
// By making this in atom/proc everything in the game can potentially dab. You have been warned.
92+
if(hold_seconds > 9999) // if you need to hold a dab for more than 2 hours intentionally let me know.
93+
return
94+
if(hold_seconds > 0)
95+
hold_seconds = hold_seconds * 10 // Converts seconds to deciseconds
96+
if(angle == 1) //if angle is 1: random angle. Else take angle
97+
angle = rand(25,50)
98+
if(direction == 1) // direciton:: 1 for random pick, 2 for clockwise , 3 for anti-clockwise
99+
direction = pick(2,3)
100+
if(direction == 3) // if 3 then counter clockwise
101+
angle = angle * -1
102+
if(speed == 1) // if speed is 1 choose random speed from list
103+
speed = rand(3,5)
104+
105+
// dab matrix here
106+
var/matrix/DAB_COMMENCE = matrix(transform)
107+
var/matrix/DAB_RETURN = matrix(transform)
108+
DAB_COMMENCE.Turn(angle) // dab angle to matrix
109+
110+
// Dab animation
111+
animate(src, transform = DAB_COMMENCE, time = speed, loops ) // dab to hold angle
112+
if(hold_seconds > 0)
113+
sleep(hold_seconds) // time to hold the dab before going back
114+
if(!stay) // if stay param is true dab doesn't return
115+
animate(transform = DAB_RETURN, time = speed * 1.5, loops ) // reverse dab to starting position , slower
116+
//doesn't have an object argument because this is "Stacking" with the animate call above
117+
//3 billion% intentional

code/__HELPERS/matrices.dm

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,6 @@
22
. = new_angle - old_angle
33
Turn(.) //BYOND handles cases such as -270, 360, 540 etc. DOES NOT HANDLE 180 TURNS WELL, THEY TWEEN AND LOOK LIKE SHIT
44

5-
/atom/proc/SpinAnimation(speed = 1 SECONDS, loops = -1, clockwise = 1, segments = 3, parallel = TRUE)
6-
if(!segments)
7-
return
8-
var/segment = 360/segments
9-
if(!clockwise)
10-
segment = -segment
11-
var/list/matrices = list()
12-
for(var/i in 1 to segments-1)
13-
var/matrix/M = matrix(transform)
14-
M.Turn(segment*i)
15-
matrices += M
16-
var/matrix/last = matrix(transform)
17-
matrices += last
18-
19-
speed /= segments
20-
21-
if(parallel)
22-
animate(src, transform = matrices[1], time = speed, loops , flags = ANIMATION_PARALLEL)
23-
else
24-
animate(src, transform = matrices[1], time = speed, loops)
25-
for(var/i in 2 to segments) //2 because 1 is covered above
26-
animate(transform = matrices[i], time = speed)
27-
//doesn't have an object argument because this is "Stacking" with the animate call above
28-
//3 billion% intentional
29-
30-
/atom/proc/DabAnimation(speed = 1, loops = 1, direction = 1 , hold_seconds = 0 , angle = 1 , stay = FALSE) // Hopek 2019
31-
// By making this in atom/proc everything in the game can potentially dab. You have been warned.
32-
if(hold_seconds > 9999) // if you need to hold a dab for more than 2 hours intentionally let me know.
33-
return
34-
if(hold_seconds > 0)
35-
hold_seconds = hold_seconds * 10 // Converts seconds to deciseconds
36-
if(angle == 1) //if angle is 1: random angle. Else take angle
37-
angle = rand(25,50)
38-
if(direction == 1) // direciton:: 1 for random pick, 2 for clockwise , 3 for anti-clockwise
39-
direction = pick(2,3)
40-
if(direction == 3) // if 3 then counter clockwise
41-
angle = angle * -1
42-
if(speed == 1) // if speed is 1 choose random speed from list
43-
speed = rand(3,5)
44-
45-
// dab matrix here
46-
var/matrix/DAB_COMMENCE = matrix(transform)
47-
var/matrix/DAB_RETURN = matrix(transform)
48-
DAB_COMMENCE.Turn(angle) // dab angle to matrix
49-
50-
// Dab animation
51-
animate(src, transform = DAB_COMMENCE, time = speed, loops ) // dab to hold angle
52-
if(hold_seconds > 0)
53-
sleep(hold_seconds) // time to hold the dab before going back
54-
if(!stay) // if stay param is true dab doesn't return
55-
animate(transform = DAB_RETURN, time = speed * 1.5, loops ) // reverse dab to starting position , slower
56-
//doesn't have an object argument because this is "Stacking" with the animate call above
57-
//3 billion% intentional
58-
595
//Dumps the matrix data in format a-f
606
/matrix/proc/tolist()
617
. = list()

code/game/gamemodes/meteor/meteors.dm

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,33 @@ GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event
8888
icon_state = "small"
8989
density = TRUE
9090
anchored = TRUE
91-
var/hits = 4
92-
var/hitpwr = 2 //Level of ex_act to be called on hit.
93-
var/dest
9491
pass_flags = PASSTABLE
95-
var/heavy = 0
92+
93+
///The resilience of our meteor
94+
var/hits = 4
95+
///Level of ex_act to be called on hit.
96+
var/hitpwr = EXPLODE_HEAVY
97+
//Should we shake people's screens on impact
98+
var/heavy = FALSE
99+
///Sound to play when you hit something
96100
var/meteorsound = 'sound/effects/meteorimpact.ogg'
101+
///Our starting z level, prevents infinite meteors
97102
var/z_original
98-
var/threat = 0 // used for determining which meteors are most interesting
99-
var/lifetime = DEFAULT_METEOR_LIFETIME
100-
var/timerid = null
103+
///Used for determining which meteors are most interesting
104+
var/threat = 0
105+
106+
//Potential items to spawn when you die
101107
var/list/meteordrop = list(/obj/item/stack/ore/iron)
108+
///How much stuff to spawn when you die
102109
var/dropamt = 2
103110

111+
///The thing we're moving towards, usually a turf
112+
var/atom/dest
113+
///Lifetime in seconds
114+
var/lifetime = DEFAULT_METEOR_LIFETIME
115+
116+
var/timerid = null
117+
104118
/obj/effect/meteor/Move()
105119
if(z != z_original || loc == dest)
106120
qdel(src)
@@ -134,6 +148,7 @@ GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event
134148
SpinAnimation()
135149
timerid = QDEL_IN(src, lifetime)
136150
chase_target(target)
151+
update_appearance()
137152

138153
/obj/effect/meteor/Bump(atom/A)
139154
if(A)

code/modules/power/cable.dm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ By design, d1 is the smallest direction and d2 is the highest
2727
desc = "A flexible, superconducting insulated cable for heavy-duty power transfer."
2828
icon = 'icons/obj/power_cond/cables.dmi'
2929
icon_state = "0-1"
30+
plane = FLOOR_PLANE
3031
layer = WIRE_LAYER //Above hidden pipes, GAS_PIPE_HIDDEN_LAYER
3132
anchored = TRUE
3233
obj_flags = CAN_BE_HIT | ON_BLUEPRINTS
@@ -89,7 +90,11 @@ By design, d1 is the smallest direction and d2 is the highest
8990
cable_color = param_color || cable_color || pick(cable_colors)
9091
if(cable_colors[cable_color])
9192
cable_color = cable_colors[cable_color]
93+
return INITIALIZE_HINT_LATELOAD
94+
95+
/obj/structure/cable/LateInitialize()
9296
update_appearance(UPDATE_ICON)
97+
//is_fully_initialized = TRUE
9398

9499
/obj/structure/cable/Destroy() // called when a cable is deleted
95100
if(powernet)

0 commit comments

Comments
 (0)