Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/SolidBlock.txt
1319 views
1
//----------------Sonic CD Solid Block Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
7
// Time Period Aliases
8
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
9
10
#alias 0 : TIME_PRESENT
11
#alias 1 : TIME_PAST
12
#alias 2 : TIME_GOOD_FUTURE
13
#alias 3 : TIME_BAD_FUTURE
14
15
// Gravity
16
#alias 0 : GRAVITY_GROUND
17
18
// Ink Effect
19
#alias 1 : INK_BLEND
20
21
// Player Collision
22
#alias 4 : C_BOX3
23
#alias 2 : PLAYER_COL_LWALL
24
#alias 3 : PLAYER_COL_RWALL
25
#alias 4 : PLAYER_COL_ROOF
26
27
// Property Values
28
#alias 0 : BLOCK_SINGLE
29
#alias 1 : BLOCK_TWO_H
30
#alias 2 : BLOCK_THREE_H
31
#alias 3 : BLOCK_FOUR_H
32
#alias 4 : BLOCK_TWO_V
33
#alias 5 : BLOCK_THREE_V
34
#alias 6 : BLOCK_FOUR_V
35
#alias 7 : BLOCK_INVISIBLE
36
37
38
sub ObjectPlayerInteraction
39
TempValue0 = Player.YPos
40
#platform: Use_Origins
41
if Player.State != Player_State_LedgePullUp
42
if Player.Animation == ANI_CLIMBING
43
switch Object.PropertyValue
44
case BLOCK_SINGLE
45
case BLOCK_INVISIBLE
46
PlayerObjectCollision(C_BOX3, -16, -16, 16, 16)
47
break
48
49
case BLOCK_TWO_H
50
PlayerObjectCollision(C_BOX3, -32, -16, 32, 16)
51
break
52
53
case BLOCK_THREE_H
54
PlayerObjectCollision(C_BOX3, -48, -16, 48, 16)
55
break
56
57
case BLOCK_FOUR_H
58
PlayerObjectCollision(C_BOX3, -64, -16, 64, 16)
59
break
60
61
case BLOCK_TWO_V
62
PlayerObjectCollision(C_BOX3, -16, -32, 16, 32)
63
break
64
65
case BLOCK_THREE_V
66
PlayerObjectCollision(C_BOX3, -16, -48, 16, 48)
67
break
68
69
case BLOCK_FOUR_V
70
PlayerObjectCollision(C_BOX3, -16, -64, 16, 64)
71
break
72
end switch
73
else
74
if Player.Animation == ANI_GLIDING
75
switch Object.PropertyValue
76
case BLOCK_SINGLE
77
case BLOCK_INVISIBLE
78
PlayerObjectCollision(C_BOX3, -16, -16, 16, 16)
79
break
80
81
case BLOCK_TWO_H
82
PlayerObjectCollision(C_BOX3, -32, -16, 32, 16)
83
break
84
85
case BLOCK_THREE_H
86
PlayerObjectCollision(C_BOX3, -48, -16, 48, 16)
87
break
88
89
case BLOCK_FOUR_H
90
PlayerObjectCollision(C_BOX3, -64, -16, 64, 16)
91
break
92
93
case BLOCK_TWO_V
94
PlayerObjectCollision(C_BOX3, -16, -32, 16, 32)
95
break
96
97
case BLOCK_THREE_V
98
PlayerObjectCollision(C_BOX3, -16, -48, 16, 48)
99
break
100
101
case BLOCK_FOUR_V
102
PlayerObjectCollision(C_BOX3, -16, -64, 16, 64)
103
break
104
end switch
105
106
if Player.Animation == ANI_GLIDING
107
switch CheckResult
108
case PLAYER_COL_LWALL
109
case PLAYER_COL_RWALL
110
CallFunction(Player_ClimbBlock)
111
break
112
end switch
113
end if
114
else
115
#endplatform
116
switch Object.PropertyValue
117
case BLOCK_SINGLE
118
case BLOCK_INVISIBLE
119
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
120
break
121
122
case BLOCK_TWO_H
123
PlayerObjectCollision(C_BOX, -32, -16, 32, 16)
124
break
125
126
case BLOCK_THREE_H
127
PlayerObjectCollision(C_BOX, -48, -16, 48, 16)
128
break
129
130
case BLOCK_FOUR_H
131
PlayerObjectCollision(C_BOX, -64, -16, 64, 16)
132
break
133
134
case BLOCK_TWO_V
135
PlayerObjectCollision(C_BOX, -16, -32, 16, 32)
136
break
137
138
case BLOCK_THREE_V
139
PlayerObjectCollision(C_BOX, -16, -48, 16, 48)
140
break
141
142
case BLOCK_FOUR_V
143
PlayerObjectCollision(C_BOX, -16, -64, 16, 64)
144
break
145
end switch
146
#platform: Use_Origins
147
end if
148
end if
149
end if
150
#endplatform
151
152
if CheckResult == PLAYER_COL_LWALL
153
Player.RCollisionFlag = true // Used in the Metal Sonic race sequence, but set by the Block regardless of current level
154
end if
155
156
if Player.Gravity == GRAVITY_GROUND
157
if CheckResult == PLAYER_COL_ROOF
158
Player.YPos = TempValue0 // Move the player back ontop of the block
159
end if
160
end if
161
end sub
162
163
164
sub ObjectDraw
165
switch Object.PropertyValue
166
case BLOCK_SINGLE
167
DrawSprite(0)
168
break
169
170
case BLOCK_TWO_H
171
TempValue0 = Object.XPos
172
TempValue0 -= 0x100000
173
DrawSpriteXY(0, TempValue0, Object.YPos)
174
TempValue0 += 0x200000
175
DrawSpriteXY(0, TempValue0, Object.YPos)
176
break
177
178
case BLOCK_THREE_H
179
TempValue0 = Object.XPos
180
TempValue0 -= 0x200000
181
DrawSpriteXY(0, TempValue0, Object.YPos)
182
TempValue0 += 0x200000
183
DrawSpriteXY(0, TempValue0, Object.YPos)
184
TempValue0 += 0x200000
185
DrawSpriteXY(0, TempValue0, Object.YPos)
186
break
187
188
case BLOCK_FOUR_H
189
TempValue0 = Object.XPos
190
TempValue0 -= 0x300000
191
DrawSpriteXY(0, TempValue0, Object.YPos)
192
TempValue0 += 0x200000
193
DrawSpriteXY(0, TempValue0, Object.YPos)
194
TempValue0 += 0x200000
195
DrawSpriteXY(0, TempValue0, Object.YPos)
196
TempValue0 += 0x200000
197
DrawSpriteXY(0, TempValue0, Object.YPos)
198
break
199
200
case BLOCK_TWO_V
201
TempValue0 = Object.YPos
202
TempValue0 -= 0x100000
203
DrawSpriteXY(0, Object.XPos, TempValue0)
204
TempValue0 += 0x200000
205
DrawSpriteXY(0, Object.XPos, TempValue0)
206
break
207
208
case BLOCK_THREE_V
209
TempValue0 = Object.YPos
210
TempValue0 -= 0x200000
211
DrawSpriteXY(0, Object.XPos, TempValue0)
212
TempValue0 += 0x200000
213
DrawSpriteXY(0, Object.XPos, TempValue0)
214
TempValue0 += 0x200000
215
DrawSpriteXY(0, Object.XPos, TempValue0)
216
break
217
218
case BLOCK_FOUR_V
219
TempValue0 = Object.YPos
220
TempValue0 -= 0x300000
221
DrawSpriteXY(0, Object.XPos, TempValue0)
222
TempValue0 += 0x200000
223
DrawSpriteXY(0, Object.XPos, TempValue0)
224
TempValue0 += 0x200000
225
DrawSpriteXY(0, Object.XPos, TempValue0)
226
TempValue0 += 0x200000
227
DrawSpriteXY(0, Object.XPos, TempValue0)
228
break
229
230
// case 7, the invisible block, doesn't draw anything of course
231
end switch
232
end sub
233
234
235
sub ObjectStartup
236
LoadSpriteSheet("R7/Objects.gif")
237
238
// Load the appropriate version of the sprite based on the current time period
239
switch HUD.CurrentTimePeriod
240
case TIME_PRESENT
241
case TIME_PAST
242
case TIME_BAD_FUTURE
243
// Normal version of the sprite
244
SpriteFrame(-16, -16, 32, 32, 1, 1)
245
break
246
247
case TIME_GOOD_FUTURE
248
// Good future version of the sprite
249
SpriteFrame(-16, -16, 32, 32, 117, 219)
250
break
251
end switch
252
end sub
253
254
255
// ========================
256
// Editor Subs
257
// ========================
258
259
sub RSDKEdit
260
if Editor.ReturnVariable == true
261
switch Editor.VariableID
262
case EDIT_VAR_PROPVAL // Property Value
263
CheckResult = Object.PropertyValue
264
break
265
case 0 // Type
266
CheckResult = Object.PropertyValue
267
CheckResult &= 7
268
break
269
end switch
270
else
271
switch Editor.VariableID
272
case EDIT_VAR_PROPVAL // Property Value
273
Object.PropertyValue = Editor.VariableValue
274
break
275
case 0 // Type
276
Object.PropertyValue = Editor.VariableValue
277
Object.PropertyValue &= 7
278
break
279
end switch
280
end if
281
end sub
282
283
284
sub RSDKDraw
285
switch Object.PropertyValue
286
case BLOCK_SINGLE
287
DrawSprite(0)
288
break
289
290
case BLOCK_TWO_H
291
TempValue0 = Object.XPos
292
TempValue0 -= 0x100000
293
DrawSpriteXY(0, TempValue0, Object.YPos)
294
TempValue0 += 0x200000
295
DrawSpriteXY(0, TempValue0, Object.YPos)
296
break
297
298
case BLOCK_THREE_H
299
TempValue0 = Object.XPos
300
TempValue0 -= 0x200000
301
DrawSpriteXY(0, TempValue0, Object.YPos)
302
TempValue0 += 0x200000
303
DrawSpriteXY(0, TempValue0, Object.YPos)
304
TempValue0 += 0x200000
305
DrawSpriteXY(0, TempValue0, Object.YPos)
306
break
307
308
case BLOCK_FOUR_H
309
TempValue0 = Object.XPos
310
TempValue0 -= 0x300000
311
DrawSpriteXY(0, TempValue0, Object.YPos)
312
TempValue0 += 0x200000
313
DrawSpriteXY(0, TempValue0, Object.YPos)
314
TempValue0 += 0x200000
315
DrawSpriteXY(0, TempValue0, Object.YPos)
316
TempValue0 += 0x200000
317
DrawSpriteXY(0, TempValue0, Object.YPos)
318
break
319
320
case BLOCK_TWO_V
321
TempValue0 = Object.YPos
322
TempValue0 -= 0x100000
323
DrawSpriteXY(0, Object.XPos, TempValue0)
324
TempValue0 += 0x200000
325
DrawSpriteXY(0, Object.XPos, TempValue0)
326
break
327
328
case BLOCK_THREE_V
329
TempValue0 = Object.YPos
330
TempValue0 -= 0x200000
331
DrawSpriteXY(0, Object.XPos, TempValue0)
332
TempValue0 += 0x200000
333
DrawSpriteXY(0, Object.XPos, TempValue0)
334
TempValue0 += 0x200000
335
DrawSpriteXY(0, Object.XPos, TempValue0)
336
break
337
338
case BLOCK_FOUR_V
339
TempValue0 = Object.YPos
340
TempValue0 -= 0x300000
341
DrawSpriteXY(0, Object.XPos, TempValue0)
342
TempValue0 += 0x200000
343
DrawSpriteXY(0, Object.XPos, TempValue0)
344
TempValue0 += 0x200000
345
DrawSpriteXY(0, Object.XPos, TempValue0)
346
TempValue0 += 0x200000
347
DrawSpriteXY(0, Object.XPos, TempValue0)
348
break
349
350
case BLOCK_INVISIBLE
351
// This subtype acts as an invis block so normally it's invisible - but it has to show in the editor somehow!
352
353
Object.InkEffect = INK_BLEND
354
DrawSpriteFX(0, FX_INK, Object.XPos, Object.YPos)
355
356
// The sprite is faint so draw the hitbox of the box
357
358
TempValue0 = Object.XPos
359
TempValue0 -= 0x100000
360
TempValue1 = Object.YPos
361
TempValue1 -= 0x100000
362
DrawRectOutline(TempValue0, TempValue1, 32, 32, 255, 255, 255, 255)
363
break
364
end switch
365
end sub
366
367
368
sub RSDKLoad
369
LoadSpriteSheet("R7/Objects.gif")
370
SpriteFrame(-16, -16, 32, 32, 1, 1)
371
372
AddEditorVariable("Type")
373
SetActiveVariable("Type")
374
AddEnumVariable("Single Block", BLOCK_SINGLE)
375
AddEnumVariable("Two Blocks (Horizontal)", BLOCK_TWO_H)
376
AddEnumVariable("Three Blocks (Horizontal)", BLOCK_THREE_H)
377
AddEnumVariable("Four Blocks (Horizontal)", BLOCK_FOUR_H)
378
AddEnumVariable("Two Blocks (Vertical)", BLOCK_TWO_V)
379
AddEnumVariable("Three Blocks (Vertical)", BLOCK_THREE_V)
380
AddEnumVariable("Four Blocks (Vertical)", BLOCK_FOUR_V)
381
AddEnumVariable("Invisible Block", BLOCK_INVISIBLE)
382
end sub
383
384