Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/MovingBlocks2.txt
1319 views
1
//--------------Sonic CD Moving Blocks 2 Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.BlockXPos_1
7
#alias Object.Value1 : Object.BlockYPos_1
8
#alias Object.Value2 : Object.BlockXPos_2
9
#alias Object.Value3 : Object.BlockYPos_2
10
#alias Object.Value4 : Object.BlockXPos_3
11
#alias Object.Value5 : Object.BlockYPos_3
12
#alias Object.Value6 : Object.CurrentBlock
13
14
// Collision
15
#alias 1 : PLAYER_COL_FLOOR
16
#alias 4 : PLAYER_COL_ROOF
17
18
// Global SFX
19
#alias 5 : SFX_G_HURT
20
21
// Gravity
22
#alias 0 : GRAVITY_GROUND
23
24
25
// Function declarations
26
#function MovingBlocks_HandleMovement
27
28
function MovingBlocks_HandleMovement
29
switch Object.CurrentBlock
30
case 0
31
Object.BlockYPos_1 -= 0x8000
32
if Object.AnimationTimer == 64
33
Object.BlockYPos_2 = Object.BlockYPos_1
34
end if
35
break
36
37
case 1
38
Object.BlockYPos_1 -= 0x8000
39
break
40
41
case 2
42
Object.BlockYPos_1 += 0x8000
43
Object.BlockYPos_3 += 0x8000
44
if Object.AnimationTimer == 64
45
Object.BlockYPos_1 = Object.BlockYPos_3
46
end if
47
break
48
49
case 3
50
Object.BlockYPos_1 += 0x8000
51
Object.BlockYPos_2 += 0x8000
52
break
53
54
case 4
55
Object.BlockYPos_1 -= 0x8000
56
Object.BlockYPos_2 -= 0x8000
57
if Object.AnimationTimer == 64
58
Object.BlockYPos_1 = Object.BlockYPos_2
59
end if
60
break
61
62
case 5
63
Object.BlockYPos_1 -= 0x8000
64
Object.BlockYPos_3 -= 0x8000
65
break
66
end switch
67
end function
68
69
70
sub ObjectMain
71
Object.Rotation -= 2
72
if Object.Rotation < 0
73
Object.Rotation += 512
74
end if
75
Object.AnimationTimer++
76
CallFunction(MovingBlocks_HandleMovement)
77
if Object.AnimationTimer == 64
78
Object.AnimationTimer = 0
79
Object.CurrentBlock++
80
if Object.CurrentBlock > 5
81
Object.CurrentBlock = 2
82
end if
83
end if
84
end sub
85
86
87
sub ObjectPlayerInteraction
88
TempValue0 = Object.XPos
89
TempValue1 = Object.YPos
90
switch Object.CurrentBlock
91
case 0
92
case 1
93
Object.XPos = Object.BlockXPos_2
94
Object.YPos = Object.BlockYPos_2
95
PlayerObjectCollision(C_BOX, -16, -17, 16, 16)
96
if CheckResult == PLAYER_COL_FLOOR
97
Player.YPos += 0x10000
98
end if
99
break
100
// This exist in mobile and origins versions of the game, for some reason
101
// Object.XPos = Object.Value0
102
// Object.YPos = Object.Value1
103
// PlayerObjectCollision(C_BOX, -16, -17, 16, 16)
104
// if CheckResult == 1
105
// Player.YPos += 0x10000
106
// end if
107
// break
108
109
case 2
110
Object.XPos = Object.BlockXPos_2
111
Object.YPos = Object.BlockYPos_2
112
113
PlayerObjectCollision(C_BOX, -16, -17, 16, 16)
114
if CheckResult == PLAYER_COL_FLOOR
115
Player.YPos += 0x10000
116
end if
117
118
Object.XPos = Object.BlockXPos_3
119
Object.YPos = Object.BlockYPos_3
120
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
121
if CheckResult == PLAYER_COL_ROOF
122
if Player.Gravity == GRAVITY_GROUND
123
PlaySfx(SFX_G_HURT, false)
124
Player.DrawOrder = 5
125
Player.Speed = 0
126
Player.XVelocity = 0
127
Player.YVelocity = -0x68000
128
129
Player.State = Player_State_Death
130
Player.Animation = ANI_DYING
131
132
Player.TileCollisions = false
133
Player.ObjectInteraction = false
134
Screen.CameraEnabled = false
135
end if
136
end if
137
break
138
139
case 3
140
case 4
141
Object.XPos = Object.BlockXPos_2
142
Object.YPos = Object.BlockYPos_2
143
144
PlayerObjectCollision(C_BOX, -16, -17, 16, 16)
145
if CheckResult == PLAYER_COL_FLOOR
146
Player.YPos += 0x10000
147
end if
148
149
Object.XPos = Object.BlockXPos_3
150
Object.YPos = Object.BlockYPos_3
151
PlayerObjectCollision(C_TOUCH, -12, -16, 12, 32)
152
if CheckResult == true
153
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
154
155
Object.XPos = Object.BlockXPos_1
156
Object.YPos = Object.BlockYPos_1
157
158
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
159
if CheckResult == PLAYER_COL_ROOF
160
if Player.Gravity == GRAVITY_GROUND
161
PlaySfx(SFX_G_HURT, false)
162
Player.DrawOrder = 5
163
164
Player.Speed = 0
165
Player.XVelocity = 0
166
Player.YVelocity = -0x68000
167
168
Player.State = Player_State_Death
169
Player.Animation = ANI_DYING
170
171
Player.TileCollisions = false
172
Player.ObjectInteraction = false
173
Screen.CameraEnabled = false
174
end if
175
end if
176
else
177
PlayerObjectCollision(C_BOX, -16, -16, 16, 32)
178
end if
179
break
180
case 5
181
Object.XPos = Object.BlockXPos_2
182
Object.YPos = Object.BlockYPos_2
183
PlayerObjectCollision(C_BOX, -16, -17, 16, 16)
184
if CheckResult == PLAYER_COL_FLOOR
185
Player.YPos += 0x10000
186
end if
187
Object.XPos = Object.BlockXPos_1
188
Object.YPos = Object.BlockYPos_1
189
PlayerObjectCollision(C_BOX, -16, -17, 16, 16)
190
if CheckResult == PLAYER_COL_FLOOR
191
Player.YPos += 0x10000
192
end if
193
break
194
end switch
195
Object.XPos = TempValue0
196
Object.YPos = TempValue1
197
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
198
end sub
199
200
201
sub ObjectDraw
202
DrawSpriteXY(0, Object.BlockXPos_1, Object.BlockYPos_1)
203
DrawSpriteXY(0, Object.BlockXPos_2, Object.BlockYPos_2)
204
DrawSpriteXY(0, Object.BlockXPos_3, Object.BlockYPos_3)
205
DrawSprite(0)
206
end sub
207
208
209
sub ObjectStartup
210
LoadSpriteSheet("R6/Objects.gif")
211
212
SpriteFrame(-16, -16, 32, 32, 173, 1) // #0 - Block
213
214
ArrayPos0 = 32
215
while ArrayPos0 < 1056
216
if Object[ArrayPos0].Type == TypeName[Moving Blocks]
217
Object[ArrayPos0].BlockXPos_1 = Object[ArrayPos0].XPos
218
Object[ArrayPos0].BlockYPos_1 = Object[ArrayPos0].YPos
219
Object[ArrayPos0].BlockXPos_2 = Object[ArrayPos0].XPos
220
Object[ArrayPos0].BlockYPos_2 = Object[ArrayPos0].YPos
221
Object[ArrayPos0].BlockXPos_3 = Object[ArrayPos0].XPos
222
Object[ArrayPos0].BlockYPos_3 = Object[ArrayPos0].YPos
223
Object[ArrayPos0].Rotation = 480
224
end if
225
ArrayPos0++
226
loop
227
end sub
228
229
230
// ========================
231
// Editor Subs
232
// ========================
233
234
sub RSDKDraw
235
DrawSprite(0)
236
TempValue0 = Object.YPos
237
TempValue0 -= 0x100000
238
TempValue1 = Object.XPos
239
TempValue1 -= 0x100000
240
if Editor.ShowGizmos == true
241
Editor.DrawingOverlay = true
242
TempValue0 -= 0x200000
243
DrawRectOutline(TempValue1,TempValue0, 0x20, 0x20, 255, 255, 0, 255)
244
DrawArrow(Object.XPos,Object.YPos,Object.XPos,TempValue0, 255, 0, 0)
245
TempValue0 -= 0x200000
246
DrawRectOutline(TempValue1,TempValue0, 0x20, 0x20, 255, 255, 0, 255)
247
Editor.DrawingOverlay = false
248
end if
249
end sub
250
251
252
sub RSDKLoad
253
LoadSpriteSheet("R6/Objects.gif")
254
255
SpriteFrame(-16, -16, 32, 32, 173, 1) // #0 - Block
256
257
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
258
end sub
259
260