Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/Flipper.txt
1319 views
1
//------------------Sonic CD Flipper 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
8
// States
9
#alias 0 : FLIPPER_IDLE
10
#alias 1 : FLIPPER_ACTIVE
11
#alias 2 : FLIPPER_RETURN_POSITION
12
13
// Collision
14
#alias 1 : PLAYER_COL_FLOOR
15
16
// Collision Mode
17
#alias 0 : CMODE_FLOOR
18
19
#alias 0 : GRAVITY_GROUND
20
21
// Global SFX
22
#alias 0 : SFX_G_JUMP
23
24
// Stage SFX
25
#alias 7 : SFX_S_FLIPPER
26
27
28
sub ObjectMain
29
switch Object.State
30
case FLIPPER_ACTIVE
31
Object.Frame = Object.Timer
32
Object.Frame >>= 1
33
34
Object.Timer++
35
if Object.Timer > 3
36
Object.Timer = 6
37
Object.State = FLIPPER_RETURN_POSITION
38
end if
39
break
40
41
case FLIPPER_RETURN_POSITION
42
Object.Frame = Object.Timer
43
Object.Frame /= 3
44
45
Object.Timer++
46
if Object.Timer > 12
47
Object.Timer = 0
48
Object.Frame = 0
49
Object.State = FLIPPER_IDLE
50
end if
51
break
52
53
end switch
54
end sub
55
56
57
sub ObjectPlayerInteraction
58
TempValue0 = 0
59
if Object.Direction == FACING_RIGHT
60
if Player.YPos > Object.YPos
61
if Player.YVelocity < 0
62
PlayerObjectCollision(C_BOX, -32, -12, 28, 12)
63
end if
64
end if
65
#platform: Use_Origins
66
PlayerObjectCollision(C_PLATFORM, 15, -16, 32, 16)
67
#endplatform
68
69
#platform:Use_Standalone
70
PlayerObjectCollision(C_PLATFORM, 20, -16, 32, 16)
71
#endplatform
72
TempValue0 = CheckResult
73
74
TempValue1 = Player.XPos
75
TempValue1 -= Object.XPos
76
TempValue1 >>= 16
77
TempValue1 += 32
78
TempValue1 += Player.CollisionRight
79
80
if TempValue1 >= 0
81
if TempValue1 < 54
82
TempValue2 = TempValue1
83
TempValue2 /= -2
84
TempValue2 += 10
85
PlayerObjectCollision(C_PLATFORM, -32, TempValue2, 32, 16)
86
TempValue0 |= CheckResult
87
end if
88
end if
89
90
if TempValue0 == PLAYER_COL_FLOOR
91
Player.CollisionMode = CMODE_FLOOR
92
93
Player.YPos += 0x40000
94
Player.XPos -= 0x10000
95
96
if Player.Speed < 0x4000
97
if Player.Speed > -0x4000
98
Player.Speed = -0x4000
99
end if
100
end if
101
#platform: Use_Origins
102
if Stage.PlayerListPos == PLAYER_KNUCKLES
103
if Player.Animation == ANI_GLIDING_STOP
104
Player.State = Player_State_Roll
105
Player.Animation = ANI_JUMPING
106
107
Player.Gravity = GRAVITY_GROUND
108
Player.Speed = 0x4000
109
end if
110
end if
111
#endplatform
112
else
113
PlayerObjectCollision(C_TOUCH, -32, -24, 32, 16)
114
if CheckResult == true
115
if Player.YVelocity < -0x40000
116
if Player.JumpPress == true
117
Player.Speed = Player.XPos
118
Player.Speed -= Object.XPos
119
Player.Speed >>= 2
120
121
Player.YVelocity = -0xE0000
122
TempValue2 = Player.Speed
123
TempValue2 >>= 2
124
if TempValue2 < 0
125
Player.YVelocity += TempValue2
126
else
127
Player.YVelocity -= TempValue2
128
end if
129
Object.State = FLIPPER_ACTIVE
130
StopSfx(SFX_G_JUMP)
131
PlayStageSfx(SFX_S_FLIPPER, false)
132
133
#platform: Use_Haptics
134
HapticEffect(88, 0, 0, 0)
135
#endplatform
136
end if
137
end if
138
end if
139
end if
140
141
else
142
if Player.YPos > Object.YPos
143
if Player.YVelocity < 0
144
PlayerObjectCollision(C_BOX, -28, -12, 32, 12)
145
end if
146
end if
147
148
#platform: Use_Origins
149
PlayerObjectCollision(C_PLATFORM, -32, -16, -15, 16)
150
#endplatform
151
152
#platform:Use_Standalone
153
PlayerObjectCollision(C_PLATFORM, -32, -16, -20, 16)
154
#endplatform
155
TempValue0 = CheckResult
156
157
TempValue1 = Player.XPos
158
TempValue1 -= Object.XPos
159
TempValue1 >>= 16
160
TempValue1 += 32
161
TempValue1 += Player.CollisionLeft
162
if TempValue1 >= 12
163
if TempValue1 < 64
164
TempValue2 = TempValue1
165
TempValue2 /= 2
166
TempValue2 -= 21
167
PlayerObjectCollision(C_PLATFORM, -32, TempValue2, 32, 16)
168
TempValue0 |= CheckResult
169
end if
170
end if
171
172
if TempValue0 == PLAYER_COL_FLOOR
173
Player.CollisionMode = CMODE_FLOOR
174
Player.YPos += 0x40000
175
Player.XPos += 0x10000
176
if Player.Speed > -0x4000
177
if Player.Speed < 0x4000
178
Player.Speed = 0x4000
179
end if
180
end if
181
182
#platform: Use_Origins
183
if Stage.PlayerListPos == PLAYER_KNUCKLES
184
if Player.Animation == ANI_GLIDING_STOP
185
Player.State = Player_State_Roll
186
Player.Animation = ANI_JUMPING
187
188
Player.Gravity = GRAVITY_GROUND
189
Player.Speed = 0x4000
190
end if
191
end if
192
#endplatform
193
else
194
PlayerObjectCollision(C_TOUCH, -32, -24, 32, 16)
195
if CheckResult == true
196
if Player.YVelocity < -0x40000
197
if Player.JumpPress == true
198
Player.Speed = Player.XPos
199
Player.Speed -= Object.XPos
200
Player.Speed >>= 2
201
202
Player.YVelocity = -0xE0000
203
204
TempValue2 = Player.Speed
205
TempValue2 >>= 2
206
if TempValue2 < 0
207
Player.YVelocity += TempValue2
208
else
209
Player.YVelocity -= TempValue2
210
end if
211
212
Object.State = FLIPPER_ACTIVE
213
214
StopSfx(SFX_G_JUMP)
215
PlayStageSfx(SFX_S_FLIPPER, false)
216
end if
217
end if
218
end if
219
end if
220
end if
221
end sub
222
223
224
sub ObjectDraw
225
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
226
end sub
227
228
229
sub ObjectStartup
230
LoadSpriteSheet("R3/Objects.gif")
231
232
SpriteFrame(-32, -12, 64, 32, 100, 167) // #0 - Flipper idle
233
SpriteFrame(-32, -12, 64, 24, 67, 200) // #1 - Flipper active frame 0
234
SpriteFrame(-32, -20, 64, 32, 132, 200) // #2 - Flipper active frame 1
235
SpriteFrame(-32, -12, 64, 24, 67, 200) // #3 - Flipper active frame 2
236
237
// Used to be below LoadSpriteSheet, moved here for consistency
238
ArrayPos0 = 32
239
while ArrayPos0 < 1056
240
if Object[ArrayPos0].Type == TypeName[Flipper]
241
Object[ArrayPos0].Direction = Object[ArrayPos0].PropertyValue
242
Object[ArrayPos0].DrawOrder = 4
243
end if
244
ArrayPos0++
245
loop
246
end sub
247
248
249
// ========================
250
// Editor Subs
251
// ========================
252
253
sub RSDKEdit
254
if Editor.ReturnVariable == true
255
switch Editor.VariableID
256
case EDIT_VAR_PROPVAL // Property Value
257
CheckResult = Object.PropertyValue
258
CheckResult &= 1
259
break
260
case 0 // condition
261
CheckResult = Object.PropertyValue
262
CheckResult &= 1
263
break
264
end switch
265
else
266
switch Editor.VariableID
267
case EDIT_VAR_PROPVAL // Property Value
268
Object.PropertyValue = Editor.VariableValue
269
Object.PropertyValue &= 1
270
break
271
case 0 // condition
272
Object.PropertyValue = Editor.VariableValue
273
Object.PropertyValue &= 1
274
break
275
end switch
276
end if
277
end sub
278
279
280
sub RSDKDraw
281
Object.Direction = Object.PropertyValue
282
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
283
end sub
284
285
286
sub RSDKLoad
287
LoadSpriteSheet("R3/Objects.gif")
288
289
SpriteFrame(-32, -12, 64, 32, 100, 167) // #0 - Flipper idle
290
291
AddEditorVariable("direction")
292
SetActiveVariable("direction")
293
AddEnumVariable("Facing Left", 0)
294
AddEnumVariable("Facing Right", 1)
295
end sub
296
297