Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/RPlaneShifter.txt
1319 views
1
//---------------Sonic CD R Plane Shifter Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.AnimFrameTimer
7
#alias Object.Value2 : Object.OnObject
8
9
// States
10
#alias 0 : RPLANESHIFTER_IDLE
11
// Facing Right
12
#alias 1 : RPLANESHIFTER_PLANE_A_TO_B_R
13
#alias 2 : RPLANESHIFTER_PLANE_B_TO_A_R
14
// Facing Left
15
#alias 3 : RPLANESHIFTER_PLANE_A_TO_B_L
16
#alias 4 : RPLANESHIFTER_PLANE_B_TO_A_L
17
18
// Property Values
19
#alias 0 : GIMMICK_PARENT
20
#alias 1 : GIMMICK_CHILD
21
22
// Collision Planes
23
#alias 0 : COLLISION_PLANE_A
24
#alias 1 : COLLISION_PLANE_B
25
26
27
sub ObjectMain
28
if Player.ObjectInteraction == true
29
if Object.PropertyValue == GIMMICK_PARENT
30
switch Object.State
31
case RPLANESHIFTER_PLANE_A_TO_B_R
32
if Object.AnimFrameTimer < 256
33
Object.AnimFrameTimer += 8
34
else
35
Object.State = RPLANESHIFTER_IDLE
36
Player.State = Player_State_Ground
37
Player.Frame = 0
38
Player.DrawOrder = 2
39
Player.CollisionPlane = COLLISION_PLANE_B
40
end if
41
42
TempValue0 = Object.AnimFrameTimer
43
TempValue0 >>= 6
44
switch TempValue0
45
case 0
46
Player.Frame = 1
47
break
48
case 1
49
Player.Frame = 2
50
break
51
case 2
52
Player.Frame = 3
53
break
54
case 3
55
Player.Frame = 0
56
Player.Direction = FACING_LEFT
57
break
58
end switch
59
60
Object.AnimationTimer++
61
Object.AnimationTimer %= 6
62
break
63
64
case RPLANESHIFTER_PLANE_B_TO_A_R
65
if Object.AnimFrameTimer > 0
66
Object.AnimFrameTimer -= 8
67
else
68
Object.State = RPLANESHIFTER_IDLE
69
Player.State = Player_State_Ground
70
Player.Frame = 0
71
Player.DrawOrder = 4
72
Player.CollisionPlane = COLLISION_PLANE_A
73
end if
74
75
TempValue0 = Object.AnimFrameTimer
76
TempValue0 >>= 6
77
switch TempValue0
78
case 0
79
Player.Frame = 0
80
Player.Direction = FACING_LEFT
81
break
82
case 1
83
Player.Frame = 4
84
break
85
case 2
86
Player.Frame = 0
87
break
88
case 3
89
Player.Frame = 1
90
break
91
end switch
92
93
Object.AnimationTimer++
94
Object.AnimationTimer %= 6
95
break
96
97
case RPLANESHIFTER_PLANE_A_TO_B_L
98
if Object.AnimFrameTimer > 256
99
Object.AnimFrameTimer -= 8
100
else
101
Object.State = RPLANESHIFTER_IDLE
102
Player.State = Player_State_Ground
103
Player.Frame = 0
104
Player.DrawOrder = 2
105
Player.CollisionPlane = COLLISION_PLANE_B
106
end if
107
108
TempValue0 = 512
109
TempValue0 -= Object.AnimFrameTimer
110
TempValue0 >>= 6
111
switch TempValue0
112
case 0
113
Player.Frame = 1
114
break
115
case 1
116
Player.Frame = 2
117
break
118
case 2
119
Player.Frame = 3
120
break
121
case 3
122
Player.Frame = 0
123
Player.Direction = FACING_RIGHT
124
break
125
end switch
126
127
Object.AnimationTimer++
128
Object.AnimationTimer %= 6
129
break
130
131
case RPLANESHIFTER_PLANE_B_TO_A_L
132
if Object.AnimFrameTimer < 512
133
Object.AnimFrameTimer += 8
134
else
135
Object.AnimFrameTimer = 0
136
Object.State = RPLANESHIFTER_IDLE
137
Player.State = Player_State_Ground
138
Player.Frame = 0
139
Player.DrawOrder = 4
140
Player.CollisionPlane = COLLISION_PLANE_A
141
end if
142
143
TempValue0 = 512
144
TempValue0 -= Object.AnimFrameTimer
145
TempValue0 >>= 6
146
switch TempValue0
147
case 0
148
Player.Frame = 0
149
Player.Direction = FACING_RIGHT
150
break
151
case 1
152
Player.Frame = 4
153
break
154
case 2
155
Player.Frame = 0
156
break
157
case 3
158
Player.Frame = 1
159
break
160
end switch
161
162
Object.AnimationTimer++
163
Object.AnimationTimer %= 6
164
break
165
end switch
166
167
// First Bar
168
Sin(Object[+1].XPos, Object.AnimFrameTimer)
169
Object[+1].XPos *= 0xC00
170
Object[+1].XPos += Object.XPos
171
Object[+1].YPos = Object.YPos
172
if Object.AnimFrameTimer > 128
173
if Object.AnimFrameTimer < 384
174
Object[+1].DrawOrder = 1
175
else
176
Object[+1].DrawOrder = 4
177
end if
178
else
179
Object[+1].DrawOrder = 4
180
end if
181
182
// Second Bar
183
TempValue0 = Object.AnimFrameTimer
184
TempValue0 += 170
185
TempValue0 &= 511
186
Sin(Object[+2].XPos, TempValue0)
187
Object[+2].XPos *= 0xC00
188
Object[+2].XPos += Object.XPos
189
Object[+2].YPos = Object.YPos
190
if TempValue0 > 128
191
if TempValue0 < 384
192
Object[+2].DrawOrder = 1
193
else
194
Object[+2].DrawOrder = 4
195
end if
196
else
197
Object[+2].DrawOrder = 4
198
end if
199
200
// Third Bar
201
TempValue0 = Object.AnimFrameTimer
202
TempValue0 += 341
203
TempValue0 &= 511
204
Sin(Object[+3].XPos, TempValue0)
205
Object[+3].XPos *= 0xC00
206
Object[+3].XPos += Object.XPos
207
Object[+3].YPos = Object.YPos
208
if TempValue0 > 128
209
if TempValue0 < 384
210
Object[+3].DrawOrder = 1
211
else
212
Object[+3].DrawOrder = 4
213
end if
214
else
215
Object[+3].DrawOrder = 4
216
end if
217
end if
218
end if
219
end sub
220
221
222
sub ObjectPlayerInteraction
223
if Object.PropertyValue == GIMMICK_PARENT
224
PlayerObjectCollision(C_PLATFORM, -40, -8, 40, 24)
225
TempValue1 = CheckResult
226
PlayerObjectCollision(C_BOX, -40, -184, 40, -168)
227
PlayerObjectCollision(C_TOUCH, -4, -48, 4, 8)
228
if CheckResult == true
229
if Object.OnObject == false
230
if TempValue1 == true
231
Object.OnObject = true
232
Player.State = Player_State_Static
233
Player.Animation = ANI_STOPPED
234
Player.XPos = Object.XPos
235
Player.Speed = 0
236
Player.XVelocity = 0
237
Player.YVelocity = 0
238
Player.TrackScroll = false
239
if Player.Direction == FACING_RIGHT
240
if Player.CollisionPlane == COLLISION_PLANE_A
241
Object.State = RPLANESHIFTER_PLANE_A_TO_B_R
242
Object.AnimFrameTimer = 0
243
else
244
Object.State = RPLANESHIFTER_PLANE_B_TO_A_R
245
Object.AnimFrameTimer = 256
246
end if
247
else
248
if Player.CollisionPlane == COLLISION_PLANE_A
249
Object.State = RPLANESHIFTER_PLANE_A_TO_B_L
250
Object.AnimFrameTimer = 512
251
else
252
Object.State = RPLANESHIFTER_PLANE_B_TO_A_L
253
Object.AnimFrameTimer = 256
254
end if
255
end if
256
end if
257
end if
258
else
259
Object.OnObject = false
260
end if
261
end if
262
end sub
263
264
265
sub ObjectDraw
266
if Object.PropertyValue == GIMMICK_PARENT
267
TempValue0 = Object.AnimationTimer
268
TempValue0 /= 3
269
DrawSprite(TempValue0)
270
TempValue0 += 2
271
DrawSprite(TempValue0)
272
else
273
DrawSprite(4)
274
DrawSprite(5)
275
DrawSprite(6)
276
DrawSprite(7)
277
DrawSprite(8)
278
end if
279
end sub
280
281
282
sub ObjectStartup
283
LoadSpriteSheet("R8/Objects2.gif")
284
285
SpriteFrame(-40, -8, 80, 16, 1, 200) // #0 - R Plane Shifter Base frame 0
286
SpriteFrame(-40, -8, 80, 16, 1, 217) // #1 - R Plane Shifter Base frame 1
287
288
SpriteFrame(-40, -184, 80, 16, 1, 200) // #2 - R Plane Shifter Roof frame 0
289
SpriteFrame(-40, -184, 80, 16, 1, 217) // #3 - R Plane Shifter Roof frame 1
290
291
SpriteFrame(-4, -40, 8, 32, 100, 35) // #4 - R Plane Shifter Bars 0
292
SpriteFrame(-4, -72, 8, 32, 100, 35) // #5 - R Plane Shifter Bars 1
293
SpriteFrame(-4, -104, 8, 32, 100, 35) // #6 - R Plane Shifter Bars 2
294
SpriteFrame(-4, -136, 8, 32, 100, 35) // #7 - R Plane Shifter Bars 3
295
SpriteFrame(-4, -168, 8, 32, 100, 35) // #8 - R Plane Shifter Bars 4
296
end sub
297
298
299
// ========================
300
// Editor Subs
301
// ========================
302
303
sub RSDKEdit
304
if Editor.ReturnVariable == true
305
switch Editor.VariableID
306
case EDIT_VAR_PROPVAL // Property Value
307
CheckResult = Object.PropertyValue
308
CheckResult &= 1
309
break
310
case 0 // type
311
CheckResult = Object.PropertyValue
312
CheckResult &= 1
313
break
314
end switch
315
else
316
switch Editor.VariableID
317
case EDIT_VAR_PROPVAL // Property Value
318
Object.PropertyValue = Editor.VariableValue
319
Object.PropertyValue &= 1
320
break
321
case 0 // type
322
Object.PropertyValue = Editor.VariableValue
323
Object.PropertyValue &= 1
324
break
325
end switch
326
end if
327
end sub
328
329
sub RSDKDraw
330
if Object.PropertyValue == GIMMICK_PARENT
331
TempValue0 = Object.AnimationTimer
332
TempValue0 /= 3
333
DrawSprite(TempValue0)
334
TempValue0 += 2
335
DrawSprite(TempValue0)
336
else
337
ArrayPos0 = Object.EntityNo
338
TempValue0 = 0
339
TempValue1 = 0
340
while TempValue1 == false
341
if TempValue0 == 3
342
TempValue1 = true
343
end if
344
ArrayPos0--
345
TempValue0++
346
CheckEqual(Object[ArrayPos0].Type, TypeName[R Plane Shifter])
347
TempValue1 = CheckResult
348
CheckNotEqual(Object[ArrayPos0].PropertyValue, GIMMICK_CHILD)
349
TempValue1 &= CheckResult
350
loop
351
ArrayPos1 = Object.EntityNo
352
ArrayPos1 -= Object[ArrayPos0].EntityNo
353
switch ArrayPos1
354
case 0
355
TempValue0 = 0
356
break
357
case 1
358
TempValue0 = 0
359
TempValue0 += 170
360
TempValue0 &= 511
361
break
362
case 2
363
TempValue0 = 0
364
TempValue0 += 341
365
TempValue0 &= 511
366
break
367
end switch
368
Sin(TempValue2, TempValue0)
369
TempValue2 *= 0xC00
370
TempValue2 += Object[ArrayPos0].XPos
371
DrawSpriteXY(4, TempValue2, Object.YPos)
372
DrawSpriteXY(5, TempValue2, Object.YPos)
373
DrawSpriteXY(6, TempValue2, Object.YPos)
374
DrawSpriteXY(7, TempValue2, Object.YPos)
375
DrawSpriteXY(8, TempValue2, Object.YPos)
376
end if
377
end sub
378
379
380
sub RSDKLoad
381
LoadSpriteSheet("R8/Objects2.gif")
382
383
SpriteFrame(-40, -8, 80, 16, 1, 200) // #0 - R Plane Shifter Base frame 0
384
SpriteFrame(-40, -8, 80, 16, 1, 217) // #1 - R Plane Shifter Base frame 1
385
386
SpriteFrame(-40, -184, 80, 16, 1, 200) // #2 - R Plane Shifter Roof frame 0
387
SpriteFrame(-40, -184, 80, 16, 1, 217) // #3 - R Plane Shifter Roof frame 1
388
389
SpriteFrame(-4, -40, 8, 32, 100, 35) // #4 - R Plane Shifter Bars 0
390
SpriteFrame(-4, -72, 8, 32, 100, 35) // #5 - R Plane Shifter Bars 1
391
SpriteFrame(-4, -104, 8, 32, 100, 35) // #6 - R Plane Shifter Bars 2
392
SpriteFrame(-4, -136, 8, 32, 100, 35) // #7 - R Plane Shifter Bars 3
393
SpriteFrame(-4, -168, 8, 32, 100, 35) // #8 - R Plane Shifter Bars 4
394
395
AddEditorVariable("type")
396
SetActiveVariable("type")
397
AddEnumVariable("Parent Object", GIMMICK_PARENT)
398
AddEnumVariable("Child Object", GIMMICK_CHILD)
399
end sub
400
401