Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/LBlocks.txt
1319 views
1
//------------------Sonic CD L Blocks Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.Rotation
8
9
// States
10
#alias 0 : LBLOCKS_INACTIVE
11
#alias 1 : LBLOCKS_STEP_LEFT
12
#alias 2 : LBLOCKS_STEP_RIGHT
13
#alias 3 : LBLOCKS_ROTATE_LEFT
14
#alias 4 : LBLOCKS_ROTATE_RIGHT
15
16
// Player Collision
17
#alias 1 : PLAYER_COL_FLOOR
18
19
// Stage SFX
20
#alias 8 : SFX_S_SWITCH
21
22
23
sub ObjectMain
24
switch Object.State
25
case LBLOCKS_STEP_LEFT
26
if Object.Timer < 14
27
Object.Timer++
28
else
29
Object.Timer = 0
30
Object.State = LBLOCKS_ROTATE_LEFT
31
PlayStageSfx(SFX_S_SWITCH, false)
32
end if
33
break
34
35
case LBLOCKS_STEP_RIGHT
36
if Object.Timer < 14
37
Object.Timer++
38
else
39
Object.Timer = 0
40
Object.State = LBLOCKS_ROTATE_RIGHT
41
PlayStageSfx(SFX_S_SWITCH, false)
42
end if
43
break
44
45
case LBLOCKS_ROTATE_LEFT
46
if Object.Timer < 8
47
Object.Timer++
48
Object.Rotation++
49
else
50
Object.Timer = 0
51
Object.State = LBLOCKS_INACTIVE
52
PlayStageSfx(SFX_S_SWITCH, false)
53
end if
54
break
55
56
case LBLOCKS_ROTATE_RIGHT
57
if Object.Timer < 8
58
Object.Timer++
59
Object.Rotation--
60
else
61
Object.Timer = 0
62
Object.State = LBLOCKS_INACTIVE
63
PlayStageSfx(SFX_S_SWITCH, false)
64
end if
65
break
66
end switch
67
end sub
68
69
70
sub ObjectPlayerInteraction
71
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
72
73
if Object.State == LBLOCKS_INACTIVE
74
TempValue1 = CheckResult
75
else
76
TempValue1 = 1
77
end if
78
79
if Object.State < LBLOCKS_ROTATE_LEFT
80
TempValue0 = Object.Rotation
81
TempValue0 >>= 3
82
switch TempValue0
83
case 0
84
PlayerObjectCollision(C_BOX, -16, -48, 16, -16)
85
PlayerObjectCollision(C_BOX, -48, -16, -16, 16)
86
if CheckResult == PLAYER_COL_FLOOR
87
if TempValue1 == 0
88
Object.State = LBLOCKS_STEP_LEFT
89
end if
90
end if
91
break
92
93
case 1
94
PlayerObjectCollision(C_BOX, -16, 16, 16, 48)
95
PlayerObjectCollision(C_BOX, -48, -16, -16, 16)
96
if CheckResult == PLAYER_COL_FLOOR
97
if TempValue1 == 0
98
Object.State = LBLOCKS_STEP_LEFT
99
end if
100
end if
101
break
102
103
case 2
104
PlayerObjectCollision(C_BOX, -16, 16, 16, 48)
105
PlayerObjectCollision(C_BOX, 16, -16, 48, 16)
106
if CheckResult == PLAYER_COL_FLOOR
107
if TempValue1 == 0
108
Object.State = LBLOCKS_STEP_RIGHT
109
end if
110
end if
111
break
112
113
case 3
114
PlayerObjectCollision(C_BOX, -16, -48, 16, -16)
115
PlayerObjectCollision(C_BOX, 16, -16, 48, 16)
116
if CheckResult == PLAYER_COL_FLOOR
117
if TempValue1 == 0
118
Object.State = LBLOCKS_STEP_RIGHT
119
end if
120
end if
121
break
122
123
end switch
124
end if
125
end sub
126
127
128
sub ObjectDraw
129
TempValue0 = Object.Rotation
130
if Object.State == LBLOCKS_ROTATE_RIGHT
131
TempValue0 += 3
132
end if
133
134
TempValue0 >>= 2
135
TempValue0 *= 3
136
137
TempValue0++
138
DrawSprite(TempValue0)
139
140
TempValue0++
141
DrawSprite(TempValue0)
142
143
TempValue0++
144
DrawSprite(TempValue0)
145
146
DrawSprite(0)
147
end sub
148
149
150
sub ObjectStartup
151
LoadSpriteSheet("R4/Objects3.gif")
152
153
SpriteFrame(-8, -8, 16, 16, 67, 46) // #0 - LBlock Center
154
// Rotation Set 1
155
SpriteFrame(-16, -16, 32, 32, 34, 34) // #1 - LBlock 1
156
SpriteFrame(-48, -16, 32, 32, 1, 34) // #2 - LBlock 2
157
SpriteFrame(-16, -48, 32, 32, 34, 1) // #3 - LBlock 3
158
SpriteFrame(-22, -22, 44, 44, 157, 1) // #4 - LBlock Diagonal 1
159
SpriteFrame(-44, -44, 44, 44, 112, 1) // #5 - LBlock Diagonal 2
160
SpriteFrame(-44, 0, 44, 44, 202, 1) // #6 - LBlock Diagonal 3
161
// Rotation Set 2
162
SpriteFrame(-16, -16, 32, 32, 34, 1) // #7 - LBlock 1
163
SpriteFrame(-48, -16, 32, 32, 1, 1) // #8 - LBlock 2
164
SpriteFrame(-16, 16, 32, 32, 34, 34) // #9 - LBlock 3
165
SpriteFrame(-22, -22, 44, 44, 112, 1) // #10 - LBlock Diagonal 1
166
SpriteFrame(-44, 0, 44, 44, 67, 1) // #11 - LBlock Diagonal 2
167
SpriteFrame(0, 0, 44, 44, 157, 1) // #12 - LBlock Diagonal 3
168
// Rotation Set 3
169
SpriteFrame(-16, -16, 32, 32, 1, 1) // #13 - LBlock 1
170
SpriteFrame(-16, 16, 32, 32, 1, 34) // #14 - LBlock 2
171
SpriteFrame(16, -16, 32, 32, 34, 1) // #15 - LBlock 3
172
SpriteFrame(-22, -22, 44, 44, 67, 1) // #16 - LBlock Diagonal 1
173
SpriteFrame(0, -44, 44, 44, 112, 1) // #17 - LBlock Diagonal 2
174
SpriteFrame(0, 0, 44, 44, 202, 1) // #18 - LBlock Diagonal 3
175
// Rotation Set 4
176
SpriteFrame(-16, -16, 32, 32, 1, 34) // #19 - LBlock 1
177
SpriteFrame(-16, -48, 32, 32, 1, 1) // #20 - LBlock 2
178
SpriteFrame(16, -16, 32, 32, 34, 34) // #21 - LBlock 3
179
SpriteFrame(-22, -22, 44, 44, 202, 1) // #22 - LBlock Diagonal 1
180
SpriteFrame(-44, -44, 44, 44, 67, 1) // #23 - LBlock Diagonal 2
181
SpriteFrame(0, -44, 44, 44, 157, 1) // #24 - LBlock Diagonal 3
182
183
ArrayPos0 = 32
184
while ArrayPos0 < 1056
185
if Object[ArrayPos0].Type == TypeName[L Blocks]
186
Object[ArrayPos0].Rotation = Object[ArrayPos0].PropertyValue
187
Object[ArrayPos0].Rotation <<= 3
188
end if
189
ArrayPos0++
190
loop
191
end sub
192
193
194
// ========================
195
// Editor Subs
196
// ========================
197
198
sub RSDKDraw
199
TempValue0 = Object.PropertyValue
200
TempValue0 <<= 3
201
202
TempValue0 >>= 2
203
TempValue0 *= 3
204
205
TempValue0++
206
DrawSprite(TempValue0)
207
208
TempValue0++
209
DrawSprite(TempValue0)
210
211
TempValue0++
212
DrawSprite(TempValue0)
213
214
DrawSprite(0)
215
end sub
216
217
218
sub RSDKLoad
219
LoadSpriteSheet("R4/Objects3.gif")
220
221
SpriteFrame(-8, -8, 16, 16, 67, 46) // #0 - LBlock Center
222
// Rotation Set 1
223
SpriteFrame(-16, -16, 32, 32, 34, 34) // #1 - LBlock 1
224
SpriteFrame(-48, -16, 32, 32, 1, 34) // #2 - LBlock 2
225
SpriteFrame(-16, -48, 32, 32, 34, 1) // #3 - LBlock 3
226
SpriteFrame(-22, -22, 44, 44, 157, 1) // #4 - LBlock Diagonal 1
227
SpriteFrame(-44, -44, 44, 44, 112, 1) // #5 - LBlock Diagonal 2
228
SpriteFrame(-44, 0, 44, 44, 202, 1) // #6 - LBlock Diagonal 3
229
// Rotation Set 2
230
SpriteFrame(-16, -16, 32, 32, 34, 1) // #7 - LBlock 1
231
SpriteFrame(-48, -16, 32, 32, 1, 1) // #8 - LBlock 2
232
SpriteFrame(-16, 16, 32, 32, 34, 34) // #9 - LBlock 3
233
SpriteFrame(-22, -22, 44, 44, 112, 1) // #10 - LBlock Diagonal 1
234
SpriteFrame(-44, 0, 44, 44, 67, 1) // #11 - LBlock Diagonal 2
235
SpriteFrame(0, 0, 44, 44, 157, 1) // #12 - LBlock Diagonal 3
236
// Rotation Set 3
237
SpriteFrame(-16, -16, 32, 32, 1, 1) // #13 - LBlock 1
238
SpriteFrame(-16, 16, 32, 32, 1, 34) // #14 - LBlock 2
239
SpriteFrame(16, -16, 32, 32, 34, 1) // #15 - LBlock 3
240
SpriteFrame(-22, -22, 44, 44, 67, 1) // #16 - LBlock Diagonal 1
241
SpriteFrame(0, -44, 44, 44, 112, 1) // #17 - LBlock Diagonal 2
242
SpriteFrame(0, 0, 44, 44, 202, 1) // #18 - LBlock Diagonal 3
243
// Rotation Set 4
244
SpriteFrame(-16, -16, 32, 32, 1, 34) // #19 - LBlock 1
245
SpriteFrame(-16, -48, 32, 32, 1, 1) // #20 - LBlock 2
246
SpriteFrame(16, -16, 32, 32, 34, 34) // #21 - LBlock 3
247
SpriteFrame(-22, -22, 44, 44, 202, 1) // #22 - LBlock Diagonal 1
248
SpriteFrame(-44, -44, 44, 44, 67, 1) // #23 - LBlock Diagonal 2
249
SpriteFrame(0, -44, 44, 44, 157, 1) // #24 - LBlock Diagonal 3
250
251
AddEditorVariable("block set")
252
SetActiveVariable("block set")
253
AddEnumVariable("Set 1", 0)
254
AddEnumVariable("Set 2", 1)
255
AddEnumVariable("Set 3", 2)
256
AddEnumVariable("Set 4", 3)
257
end sub
258
259