Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/FallingBlocks.txt
1319 views
1
//----------------Sonic CD Falling 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.YVelocity
8
#alias Object.Value2 : Object.YOriginPos
9
#alias Object.Value3 : Object.TargetHeight
10
#alias Object.Value4 : Object.R4BlockSheet
11
#alias Object.Value5 : Object.SpikeSheet
12
13
// HUD alias
14
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
15
16
// States
17
#alias 0 : FALLINGBLOCKS_SETUP
18
#alias 1 : FALLINGBLOCKS_CRUMBLE
19
#alias 2 : FALLINGBLOCKS_DELAY
20
#alias 3 : FALLINGBLOCKS_FALL
21
22
// Time Periods
23
#alias 0 : TIME_PRESENT
24
#alias 1 : TIME_PAST
25
#alias 2 : TIME_GOOD_FUTURE
26
#alias 3 : TIME_BAD_FUTURE
27
28
// Priority
29
#alias 0 : PRIORITY_BOUNDS
30
#alias 1 : PRIORITY_ACTIVE
31
32
// Collision Sides
33
#alias 0 : CSIDE_FLOOR
34
35
// Collision
36
#alias 4 : PLAYER_COL_ROOF
37
38
// Gravity
39
#alias 1 : GRAVITY_AIR
40
41
42
sub ObjectMain
43
switch Object.State
44
case FALLINGBLOCKS_SETUP
45
PlayerObjectCollision(C_TOUCH, -16, -64, 16, 192)
46
if CheckResult == true
47
Object.Priority = PRIORITY_ACTIVE
48
49
Object.YVelocity = 0
50
51
Object.TargetHeight = Object.YPos
52
Object.TargetHeight += 0x200000
53
54
Object.State++
55
end if
56
break
57
58
case FALLINGBLOCKS_CRUMBLE
59
Object.YVelocity += 0x2000
60
Object.YPos += Object.YVelocity
61
if Object.YPos >= Object.TargetHeight
62
Object.YPos = Object.TargetHeight
63
Object.YVelocity = 0
64
65
Object.State++
66
end if
67
break
68
69
case FALLINGBLOCKS_DELAY
70
if Object.Timer < 30
71
Object.Timer++
72
else
73
Object.Timer = 0
74
Object.State++
75
end if
76
break
77
78
case FALLINGBLOCKS_FALL
79
Object.YVelocity += 0x2000
80
Object.YPos += Object.YVelocity
81
82
ObjectTileCollision(CSIDE_FLOOR, 0, 32, 0)
83
if CheckResult == true
84
Object.State++
85
end if
86
break
87
88
end switch
89
90
if Object.OutOfBounds == true
91
Object.YPos = Object.YOriginPos
92
Object.Priority = PRIORITY_BOUNDS
93
94
Object.State = FALLINGBLOCKS_SETUP
95
end if
96
end sub
97
98
99
sub ObjectPlayerInteraction
100
PlayerObjectCollision(C_BOX, -16, -64, 16, 62)
101
if CheckResult == PLAYER_COL_ROOF
102
if Player.Gravity == GRAVITY_AIR
103
CallFunction(Player_Hit)
104
else
105
CallFunction(Player_Kill)
106
end if
107
end if
108
end sub
109
110
111
sub ObjectDraw
112
Object.SpriteSheet = Object.R4BlockSheet
113
DrawSpriteXY(0, Object.XPos, Object.YPos)
114
DrawSpriteXY(1, Object.XPos, Object.YPos)
115
DrawSpriteXY(2, Object.XPos, Object.YPos)
116
117
Object.SpriteSheet = Object.SpikeSheet
118
DrawSpriteXY(3, Object.XPos, Object.YPos)
119
end sub
120
121
122
sub ObjectStartup
123
switch HUD.CurrentTimePeriod
124
case TIME_PRESENT
125
LoadSpriteSheet("R4/Objects.gif")
126
TempValue0 = 163
127
TempValue1 = 1
128
TempValue2 = 196
129
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
130
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
131
SpriteFrame(-16, 0, 32, 32, TempValue0, TempValue1) // #2 - R4 Block 3
132
break
133
134
case TIME_PAST
135
LoadSpriteSheet("R4/Objects2.gif")
136
TempValue0 = 1
137
TempValue1 = 157
138
TempValue2 = 34
139
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
140
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
141
SpriteFrame(-16, 0, 32, 32, TempValue2, TempValue1) // #2 - R4 Block 3
142
break
143
144
case TIME_GOOD_FUTURE
145
LoadSpriteSheet("R4/Objects2.gif")
146
TempValue0 = 1
147
TempValue1 = 190
148
TempValue2 = 34
149
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
150
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
151
SpriteFrame(-16, 0, 32, 32, TempValue0, TempValue1) // #2 - R4 Block 3
152
break
153
154
case TIME_BAD_FUTURE
155
LoadSpriteSheet("R4/Objects2.gif")
156
TempValue0 = 1
157
TempValue1 = 223
158
TempValue2 = 34
159
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
160
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
161
SpriteFrame(-16, 0, 32, 32, TempValue0, TempValue1) // #2 - R4 Block 3
162
break
163
164
end switch
165
TempValue0 = Object.SpriteSheet
166
167
LoadSpriteSheet("Global/Items3.gif")
168
TempValue1 = Object.SpriteSheet
169
SpriteFrame(-16, 32, 32, 32, 50, 100) // #3 - Spikes
170
171
ArrayPos0 = 32
172
while ArrayPos0 < 1056
173
if Object[ArrayPos0].Type == TypeName[Falling Blocks]
174
Object[ArrayPos0].R4BlockSheet = TempValue0
175
Object[ArrayPos0].SpikeSheet = TempValue1
176
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
177
end if
178
ArrayPos0++
179
loop
180
end sub
181
182
183
// ========================
184
// Editor Subs
185
// ========================
186
187
sub RSDKDraw
188
LoadSpriteSheet("R4/Objects.gif")
189
TempValue0 = Object.SpriteSheet
190
LoadSpriteSheet("Global/Items3.gif")
191
TempValue1 = Object.SpriteSheet
192
193
Object.SpriteSheet = TempValue0
194
DrawSpriteXY(0, Object.XPos, Object.YPos)
195
DrawSpriteXY(1, Object.XPos, Object.YPos)
196
DrawSpriteXY(2, Object.XPos, Object.YPos)
197
198
Object.SpriteSheet = TempValue1
199
DrawSpriteXY(3, Object.XPos, Object.YPos)
200
end sub
201
202
203
sub RSDKLoad
204
CallFunction(EditorHelpers_FindTimePeriod)
205
switch CheckResult
206
case TIME_PRESENT
207
LoadSpriteSheet("R4/Objects.gif")
208
TempValue0 = 163
209
TempValue1 = 1
210
TempValue2 = 196
211
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
212
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
213
SpriteFrame(-16, 0, 32, 32, TempValue0, TempValue1) // #2 - R4 Block 3
214
break
215
216
case TIME_PAST
217
LoadSpriteSheet("R4/Objects2.gif")
218
TempValue0 = 1
219
TempValue1 = 157
220
TempValue2 = 34
221
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
222
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
223
SpriteFrame(-16, 0, 32, 32, TempValue2, TempValue1) // #2 - R4 Block 3
224
break
225
226
case TIME_GOOD_FUTURE
227
LoadSpriteSheet("R4/Objects2.gif")
228
TempValue0 = 1
229
TempValue1 = 190
230
TempValue2 = 34
231
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
232
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
233
SpriteFrame(-16, 0, 32, 32, TempValue0, TempValue1) // #2 - R4 Block 3
234
break
235
236
case TIME_BAD_FUTURE
237
LoadSpriteSheet("R4/Objects2.gif")
238
TempValue0 = 1
239
TempValue1 = 223
240
TempValue2 = 34
241
SpriteFrame(-16, -64, 32, 32, TempValue0, TempValue1) // #0 - R4 Block 1
242
SpriteFrame(-16, -32, 32, 32, TempValue0, TempValue1) // #1 - R4 Block 2
243
SpriteFrame(-16, 0, 32, 32, TempValue0, TempValue1) // #2 - R4 Block 3
244
break
245
246
end switch
247
TempValue0 = Object.SpriteSheet
248
249
LoadSpriteSheet("Global/Items3.gif")
250
TempValue1 = Object.SpriteSheet
251
SpriteFrame(-16, 32, 32, 32, 50, 100) // #3 - Spikes
252
253
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
254
end sub
255
256