Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/ConveyorPlatforms.txt
1319 views
1
//------------Sonic CD Conveyor Platforms Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Angle
7
#alias Object.Value1 : Object.AngleOriginPos
8
#alias Object.Value2 : Object.PlatformXPos
9
#alias Object.Value3 : Object.PlatformYPos
10
#alias Object.Value4 : Object.XCollisionOffset
11
#alias Object.Value5 : Object.YCollisionOffset
12
#alias Object.Value6 : Object.CanBeStepped
13
14
// Property Values
15
#alias 0 : GIMMICK_PARENT
16
#alias 1 : GIMMICK_CHILD
17
18
19
sub ObjectMain
20
if Object.PropertyValue == GIMMICK_PARENT
21
TempValue2 = 0
22
ArrayPos0 = Object.EntityNo
23
ArrayPos0++
24
while TempValue2 < 5
25
Object[ArrayPos0].Angle = Object[ArrayPos0].AngleOriginPos
26
Object[ArrayPos0].Angle += Object.Angle
27
Object[ArrayPos0].Angle %= 448
28
if Object[ArrayPos0].Angle < 160
29
Object[ArrayPos0].XCollisionOffset = Object.XPos
30
Object[ArrayPos0].XCollisionOffset -= 0x400000
31
32
TempValue0 = Object[ArrayPos0].Angle
33
TempValue0 <<= 16
34
Object[ArrayPos0].XCollisionOffset += TempValue0
35
Object[ArrayPos0].YCollisionOffset = Object.YPos
36
Object[ArrayPos0].YCollisionOffset -= 0x3A0000
37
38
TempValue0 = Object[ArrayPos0].Angle
39
TempValue0 <<= 15
40
Object[ArrayPos0].YCollisionOffset += TempValue0
41
else
42
if Object[ArrayPos0].Angle < 224
43
TempValue0 = Object[ArrayPos0].Angle
44
TempValue0 -= 144
45
TempValue0 <<= 2
46
if TempValue0 > 144
47
Object[ArrayPos0].Rotation++
48
Object[ArrayPos0].Rotation %= 24
49
Object[ArrayPos0].CanBeStepped = false
50
end if
51
Sin(Object[ArrayPos0].XCollisionOffset, TempValue0)
52
Object[ArrayPos0].XCollisionOffset *= 0xC00
53
Object[ArrayPos0].XCollisionOffset += Object.XPos
54
Object[ArrayPos0].XCollisionOffset += 0x500000
55
56
Cos(Object[ArrayPos0].YCollisionOffset, TempValue0)
57
Object[ArrayPos0].YCollisionOffset *= -0xC00
58
Object[ArrayPos0].YCollisionOffset += Object.YPos
59
Object[ArrayPos0].YCollisionOffset += 0x280000
60
else
61
if Object[ArrayPos0].Angle < 384
62
Object[ArrayPos0].Rotation++
63
Object[ArrayPos0].Rotation %= 24
64
Object[ArrayPos0].CanBeStepped = false
65
66
TempValue0 = Object[ArrayPos0].Angle
67
TempValue0 -= 224
68
69
Object[ArrayPos0].XCollisionOffset = Object.XPos
70
Object[ArrayPos0].XCollisionOffset += 0x3E0000
71
TempValue1 = TempValue0
72
TempValue1 <<= 16
73
Object[ArrayPos0].XCollisionOffset -= TempValue1
74
75
Object[ArrayPos0].YCollisionOffset = Object.YPos
76
Object[ArrayPos0].YCollisionOffset += 0x390000
77
TempValue1 = TempValue0
78
TempValue1 <<= 15
79
Object[ArrayPos0].YCollisionOffset -= TempValue1
80
else
81
TempValue0 = Object[ArrayPos0].Angle
82
TempValue0 -= 368
83
TempValue0 <<= 2
84
if TempValue0 > 144
85
Object[ArrayPos0].Rotation = 0
86
Object[ArrayPos0].CanBeStepped = true
87
else
88
Object[ArrayPos0].Rotation++
89
Object[ArrayPos0].Rotation %= 24
90
Object[ArrayPos0].CanBeStepped = false
91
end if
92
93
Sin(Object[ArrayPos0].XCollisionOffset, TempValue0)
94
Object[ArrayPos0].XCollisionOffset *= -0xC00
95
Object[ArrayPos0].XCollisionOffset += Object.XPos
96
Object[ArrayPos0].XCollisionOffset -= 0x500000
97
98
Cos(Object[ArrayPos0].YCollisionOffset, TempValue0)
99
Object[ArrayPos0].YCollisionOffset *= 0xC00
100
Object[ArrayPos0].YCollisionOffset += Object.YPos
101
Object[ArrayPos0].YCollisionOffset -= 0x280000
102
end if
103
end if
104
end if
105
Object[ArrayPos0].XCollisionOffset &= 0xFFFF0000 // Truncate the value
106
Object[ArrayPos0].PlatformXPos = Object[ArrayPos0].XCollisionOffset
107
Object[ArrayPos0].XCollisionOffset -= Object[ArrayPos0].XPos
108
109
Object[ArrayPos0].YCollisionOffset &= 0xFFFF0000 // Truncate the value
110
Object[ArrayPos0].PlatformYPos = Object[ArrayPos0].YCollisionOffset
111
Object[ArrayPos0].YCollisionOffset -= Object[ArrayPos0].YPos
112
113
TempValue2++
114
ArrayPos0++
115
loop
116
117
Object.Angle++
118
Object.Angle %= 448
119
end if
120
end sub
121
122
123
sub ObjectPlayerInteraction
124
if Object.PropertyValue == GIMMICK_CHILD
125
if Object.CanBeStepped == true
126
PlayerObjectCollision(C_PLATFORM, -16, -5, 16, 11)
127
if CheckResult == true
128
Player.XPos += Object.XCollisionOffset
129
Player.YPos += Object.YCollisionOffset
130
end if
131
end if
132
end if
133
end sub
134
135
136
sub ObjectDraw
137
if Object.PropertyValue == GIMMICK_CHILD
138
Object.XPos = Object.PlatformXPos
139
Object.YPos = Object.PlatformYPos
140
141
TempValue0 = Object.Rotation
142
TempValue0 >>= 1
143
switch TempValue0
144
case 0
145
case 6
146
DrawSprite(0)
147
break
148
case 1
149
case 7
150
DrawSprite(1)
151
break
152
case 2
153
case 8
154
DrawSprite(2)
155
break
156
case 3
157
case 9
158
DrawSprite(3)
159
break
160
case 4
161
case 10
162
Object.Direction = FACING_LEFT
163
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
164
break
165
case 5
166
case 11
167
Object.Direction = FACING_LEFT
168
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
169
break
170
end switch
171
end if
172
end sub
173
174
175
sub ObjectStartup
176
LoadSpriteSheet("R8/Objects.gif")
177
178
SpriteFrame(-16, -8, 32, 16, 107, 98) // #0 - Platform Horizontal
179
SpriteFrame(-16, -12, 32, 24, 107, 115) // #1 - Platform Tilted frame 0
180
SpriteFrame(-12, -16, 24, 32, 230, 34) // #2 - Platform Tilted frame 1
181
182
SpriteFrame(-8, -16, 16, 32, 239, 212) // #3 - Platform Vertical
183
SpriteFrame(-12, -16, 24, 32, 230, 34) // #4 - Platform Tilted frame 0
184
SpriteFrame(-16, -12, 32, 24, 107, 115) // #5 - Platform Tilted frame 1
185
186
ArrayPos0 = 32
187
while ArrayPos0 < 1056
188
if Object[ArrayPos0].Type == TypeName[CPlatforms]
189
if Object[ArrayPos0].PropertyValue == GIMMICK_PARENT
190
ArrayPos0++
191
Object[ArrayPos0].AngleOriginPos = 0
192
Object[ArrayPos0].CanBeStepped = true
193
Object[ArrayPos0].PlatformXPos = Object[ArrayPos0].XPos
194
Object[ArrayPos0].PlatformYPos = Object[ArrayPos0].YPos
195
ArrayPos0++
196
Object[ArrayPos0].AngleOriginPos = 90
197
Object[ArrayPos0].CanBeStepped = true
198
Object[ArrayPos0].PlatformXPos = Object[ArrayPos0].XPos
199
Object[ArrayPos0].PlatformYPos = Object[ArrayPos0].YPos
200
ArrayPos0++
201
Object[ArrayPos0].AngleOriginPos = 180
202
Object[ArrayPos0].CanBeStepped = true
203
Object[ArrayPos0].PlatformXPos = Object[ArrayPos0].XPos
204
Object[ArrayPos0].PlatformYPos = Object[ArrayPos0].YPos
205
ArrayPos0++
206
Object[ArrayPos0].AngleOriginPos = 268
207
Object[ArrayPos0].CanBeStepped = true
208
Object[ArrayPos0].PlatformXPos = Object[ArrayPos0].XPos
209
Object[ArrayPos0].PlatformYPos = Object[ArrayPos0].YPos
210
ArrayPos0++
211
Object[ArrayPos0].AngleOriginPos = 358
212
Object[ArrayPos0].CanBeStepped = true
213
Object[ArrayPos0].PlatformXPos = Object[ArrayPos0].XPos
214
Object[ArrayPos0].PlatformYPos = Object[ArrayPos0].YPos
215
end if
216
end if
217
ArrayPos0++
218
loop
219
end sub
220
221
222
// ========================
223
// Editor Subs
224
// ========================
225
226
sub RSDKDraw
227
DrawSprite(0)
228
229
if Object.PropertyValue == GIMMICK_CHILD
230
ArrayPos0 = Object.EntityNo
231
TempValue0 = 0
232
TempValue1 = 0
233
while TempValue1 == false
234
if TempValue0 == 5
235
TempValue1 = true
236
end if
237
ArrayPos0--
238
TempValue0++
239
CheckEqual(Object[ArrayPos0].Type, TypeName[CPlatforms])
240
TempValue1 = CheckResult
241
CheckNotEqual(Object[ArrayPos0].PropertyValue, GIMMICK_CHILD)
242
TempValue1 &= CheckResult
243
loop
244
DrawLine(Object.XPos, Object.YPos, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos, 255, 255, 0)
245
ArrayPos1 = Object.EntityNo
246
ArrayPos1 -= Object[ArrayPos0].EntityNo
247
switch ArrayPos1
248
case 1
249
TempValue7 = 0
250
break
251
case 2
252
TempValue7 = 90
253
break
254
case 3
255
TempValue7 = 180
256
break
257
case 4
258
TempValue7 = 268
259
break
260
case 5
261
TempValue7 = 358
262
break
263
end switch
264
265
if TempValue7 < 160
266
TempValue4 = Object.XPos
267
TempValue4 -= 0x400000
268
269
TempValue0 = TempValue7
270
TempValue0 <<= 16
271
TempValue4 += TempValue0
272
TempValue5 = Object.YPos
273
TempValue5 -= 0x3A0000
274
275
TempValue0 = TempValue7
276
TempValue0 <<= 15
277
TempValue5 += TempValue0
278
else
279
if TempValue7 < 224
280
TempValue0 = TempValue7
281
TempValue0 -= 144
282
TempValue0 <<= 2
283
Sin(TempValue4, TempValue0)
284
TempValue4 *= 0xC00
285
TempValue4 += Object.XPos
286
TempValue4 += 0x500000
287
288
Cos(TempValue5, TempValue0)
289
TempValue5 *= -0xC00
290
TempValue5 += Object.YPos
291
TempValue5 += 0x280000
292
else
293
if TempValue7 < 384
294
TempValue0 = TempValue7
295
TempValue0 -= 224
296
297
TempValue4 = Object.XPos
298
TempValue4 += 0x3E0000
299
TempValue1 = TempValue0
300
TempValue1 <<= 16
301
TempValue4 -= TempValue1
302
303
TempValue5 = Object.YPos
304
TempValue5 += 0x390000
305
TempValue1 = TempValue0
306
TempValue1 <<= 15
307
TempValue5 -= TempValue1
308
else
309
TempValue0 = TempValue7
310
TempValue0 -= 368
311
TempValue0 <<= 2
312
313
Sin(TempValue4, TempValue0)
314
TempValue4 *= -0xC00
315
TempValue4 += Object.XPos
316
TempValue4 -= 0x500000
317
318
Cos(TempValue5, TempValue0)
319
TempValue5 *= 0xC00
320
TempValue5 += Object.YPos
321
TempValue5 -= 0x280000
322
end if
323
end if
324
end if
325
TempValue4 &= 0xFFFF0000 // Truncate the value
326
TempValue2 = TempValue4
327
TempValue4 = Object.XPos
328
329
TempValue5 &= 0xFFFF0000 // Truncate the value
330
TempValue3 = TempValue5
331
TempValue5 = Object.YPos
332
if Editor.ShowGizmos == true
333
Editor.DrawingOverlay = true
334
Object.InkEffect = 1
335
DrawSpriteFX(0, FX_INK,TempValue2,TempValue3)
336
DrawLine(Object.XPos, Object.YPos, TempValue2, TempValue3, 255, 255, 0)
337
Editor.DrawingOverlay = false
338
end if
339
end if
340
end sub
341
342
343
sub RSDKLoad
344
LoadSpriteSheet("R8/Objects.gif")
345
346
SpriteFrame(-16, -8, 32, 16, 107, 98) // #0 - Platform Horizontal
347
SpriteFrame(-16, -12, 32, 24, 107, 115) // #1 - Platform Tilted frame 0
348
SpriteFrame(-12, -16, 24, 32, 230, 34) // #2 - Platform Tilted frame 1
349
350
SpriteFrame(-8, -16, 16, 32, 239, 212) // #3 - Platform Vertical
351
SpriteFrame(-12, -16, 24, 32, 230, 34) // #4 - Platform Tilted frame 0
352
SpriteFrame(-16, -12, 32, 24, 107, 115) // #5 - Platform Tilted frame 1
353
354
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
355
end sub
356
357