Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/Transporter.txt
1319 views
1
//----------------Sonic CD Transporter Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.FrameTimer
7
#alias Object.Value1 : Object.YOriginPos
8
#alias Object.Value2 : Object.Timer
9
#alias Object.Value3 : Object.Oscillation
10
11
// States
12
#alias 0 : TRANSPORTER_HOVER_DOWN
13
#alias 1 : TRANSPORTER_HOVER_UP
14
#alias 2 : TRANSPORTER_EXPLODE
15
16
// Player
17
#alias 0 : PLAYER_SONIC_A
18
19
// Property Values
20
#alias 0 : OPERATIVE
21
#alias 1 : OLD
22
#alias 2 : DESTROYED
23
#alias 3 : OLD_DESTROYED
24
25
// Global SFX
26
#alias 21 : SFX_G_ACHIEVEMENT
27
#alias 22 : SFX_G_EXPLOSION
28
29
// Priority
30
#alias 0 : PRIORITY_BOUNDS
31
#alias 1 : PRIORITY_ACTIVE
32
33
// Directions
34
#alias 2 : FLIP_Y
35
36
37
sub ObjectMain
38
if Object.PropertyValue == OPERATIVE
39
switch Object.State
40
case TRANSPORTER_HOVER_DOWN
41
Object.Timer++
42
if Object.Timer == 32
43
Object.Oscillation = 0x2000
44
Object.Timer = 0
45
Object.State = TRANSPORTER_HOVER_UP
46
end if
47
break
48
49
case TRANSPORTER_HOVER_UP
50
Object.Timer++
51
if Object.Timer == 32
52
Object.Oscillation = -0x2000
53
Object.Timer = 0
54
Object.State = TRANSPORTER_HOVER_DOWN
55
end if
56
break
57
58
case TRANSPORTER_EXPLODE
59
// Explosion code
60
Rand(TempValue0, 80)
61
TempValue0 -= 40
62
TempValue0 <<= 16
63
TempValue0 += Object.XPos
64
65
Rand(TempValue1, 64)
66
TempValue1 -= 32
67
TempValue1 <<= 16
68
TempValue1 += Object.YPos
69
70
CreateTempObject(TypeName[Explosion], 0, TempValue0, TempValue1)
71
72
TempValue0 = Object.Timer
73
TempValue0 &= 3
74
if TempValue0 == 0
75
PlaySfx(SFX_G_EXPLOSION, false)
76
end if
77
78
Object.Timer++
79
if Object.Timer == 60
80
Object.Priority = PRIORITY_BOUNDS
81
Object.Timer = 0
82
Object.State = TRANSPORTER_HOVER_DOWN
83
Object.PropertyValue = DESTROYED
84
85
Object.iYPos += 16
86
PlaySfx(SFX_G_ACHIEVEMENT, false)
87
end if
88
break
89
end switch
90
end if
91
end sub
92
93
94
sub ObjectPlayerInteraction
95
if Object.PropertyValue == OPERATIVE
96
if Object.State < TRANSPORTER_EXPLODE
97
// if Player.Animation == ANI_JUMPING // Original check
98
99
CheckEqual(Player.Animation, ANI_JUMPING)
100
TempValue0 = CheckResult
101
#platform: Use_Origins
102
CheckEqual(Player.Animation, ANI_GLIDING)
103
TempValue0 |= CheckResult
104
if Stage.PlayerListPos == PLAYER_AMY
105
if Player.Animation == ANI_HAMMER_JUMP
106
TempValue0 = true
107
end if
108
if Player.Animation == ANI_HAMMER_DASH
109
TempValue0 = true
110
end if
111
end if
112
#endplatform
113
if TempValue0 == true
114
PlayerObjectCollision(C_TOUCH, -38, -32, 38, 32)
115
if CheckResult == true
116
Object.State = TRANSPORTER_EXPLODE
117
118
Object.YPos = Object.YOriginPos
119
120
Transporter_Destroyed = true
121
Good_Future = true
122
123
Object.Priority = PRIORITY_ACTIVE
124
125
Player.Score += 1500
126
if Stage.ActNo < 3
127
TempValue0 = Stage.ListPos
128
TempValue0 /= 10
129
TempValue0 <<= 1
130
TempValue0 += Stage.ActNo
131
TempValue0--
132
SetBit(Good_Future_List, TempValue0, 1)
133
end if
134
135
// Saviour of the Planet unlock criteria
136
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
137
if Stage.DebugMode == false
138
if Good_Future_List > 16382 // 0b11111111111110
139
if MetalSonic_List > 11
140
SetAchievement(11, 100)
141
end if
142
end if
143
end if
144
end if
145
146
#platform: Use_Haptics
147
HapticEffect(90, 0, 0, 0)
148
#endplatform
149
150
end if
151
else
152
PlayerObjectCollision(C_BOX, -38, -32, 38, 36)
153
if CheckResult == true
154
Player.YPos += Object.Oscillation
155
end if
156
157
end if
158
159
end if
160
161
end if
162
end sub
163
164
165
sub ObjectDraw
166
switch Object.PropertyValue
167
case OPERATIVE
168
if Object.State < TRANSPORTER_EXPLODE
169
Object.YPos += Object.Oscillation
170
DrawSprite(Object.Frame)
171
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
172
173
// Electricity
174
TempValue0 = Object.Frame
175
TempValue0 += 4
176
DrawSprite(TempValue0)
177
TempValue0 += 4
178
DrawSprite(TempValue0)
179
TempValue0 += 4
180
DrawSprite(TempValue0)
181
182
Object.FrameTimer++
183
if Object.FrameTimer > 3
184
Object.FrameTimer = 0
185
Object.Frame++
186
if Object.Frame > 3
187
Object.Frame = 0
188
end if
189
end if
190
191
end if
192
break
193
194
case OLD
195
DrawSprite(17)
196
DrawSpriteFX(17, FX_FLIP, Object.XPos, Object.YPos)
197
break
198
199
case DESTROYED
200
DrawSprite(16)
201
break
202
203
case OLD_DESTROYED
204
DrawSprite(18)
205
break
206
end switch
207
end sub
208
209
210
sub ObjectStartup
211
LoadSpriteSheet("Global/Items3.gif")
212
SpriteFrame(-40, -32, 80, 24, 175, 61) // #0 - Transporter Frame 0
213
SpriteFrame(-40, -32, 80, 24, 175, 86) // #1 - Transporter Frame 1
214
SpriteFrame(-40, -32, 80, 24, 175, 111) // #2 - Transporter Frame 2
215
SpriteFrame(-40, -32, 80, 24, 175, 86) // #3 - Transporter Frame 3
216
SpriteFrame(-6, -8, 12, 16, 149, 1) // #4 - Electricity Frame 0
217
SpriteFrame(-6, -8, 12, 16, 162, 1) // #5 - Electricity Frame 1
218
SpriteFrame(-6, -8, 12, 16, 149, 18) // #6 - Electricity Frame 2
219
SpriteFrame(-6, -8, 12, 16, 162, 18) // #7 - Electricity Frame 3
220
SpriteFrame(-22, -8, 12, 16, 149, 1) // #8 - Electricity Frame 4
221
SpriteFrame(-22, -8, 12, 16, 162, 1) // #9 - Electricity Frame 5
222
SpriteFrame(-22, -8, 12, 16, 149, 18) // #10 - Electricity Frame 6
223
SpriteFrame(-22, -8, 12, 16, 162, 18) // #11 - Electricity Frame 7
224
SpriteFrame(10, -8, 12, 16, 149, 1) // #12 - Electricity Frame 8
225
SpriteFrame(10, -8, 12, 16, 162, 1) // #13 - Electricity Frame 9
226
SpriteFrame(10, -8, 12, 16, 149, 18) // #14 - Electricity Frame 10
227
SpriteFrame(10, -8, 12, 16, 162, 18) // #15 - Electricity Frame 11
228
SpriteFrame(-40, 16, 80, 16, 175, 44) // #16 - Transporter Destroyed
229
SpriteFrame(-40, -32, 80, 25, 175, 18) // #17 - Transporter Old
230
SpriteFrame(-40, 16, 80, 16, 175, 1) // #18 - Transporter Old Destroyed
231
232
ArrayPos0 = 32
233
while ArrayPos0 < 1056
234
if Object[ArrayPos0].Type == TypeName[Transporter]
235
Object[ArrayPos0].Direction = FLIP_Y
236
237
if Transporter_Destroyed == true
238
switch Object[ArrayPos0].PropertyValue
239
case OPERATIVE
240
Object[ArrayPos0].PropertyValue = DESTROYED
241
break
242
case OLD
243
Object[ArrayPos0].PropertyValue = OLD_DESTROYED
244
break
245
end switch
246
else
247
if Object[ArrayPos0].PropertyValue == OPERATIVE
248
Object[ArrayPos0].iYPos -= 16
249
end if
250
251
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
252
Object[ArrayPos0].Oscillation = -0x2000
253
end if
254
end if
255
ArrayPos0++
256
loop
257
end sub
258
259
260
// ========================
261
// Editor Subs
262
// ========================
263
264
sub RSDKEdit
265
if Editor.ReturnVariable == true
266
switch Editor.VariableID
267
case EDIT_VAR_PROPVAL // Property Value
268
case 0 // inactive
269
CheckResult = Object.PropertyValue
270
break
271
end switch
272
else
273
switch Editor.VariableID
274
case EDIT_VAR_PROPVAL // Property Value
275
case 0 // inactive
276
Object.PropertyValue = Editor.VariableValue
277
break
278
end switch
279
end if
280
end sub
281
282
283
sub RSDKDraw
284
Object.Direction = FLIP_Y
285
286
if Object.PropertyValue == OPERATIVE
287
// Machine
288
DrawSprite(0)
289
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
290
291
// Electricity
292
DrawSprite(4)
293
DrawSprite(8)
294
DrawSprite(12)
295
else
296
DrawSprite(17)
297
DrawSpriteFX(17, FX_FLIP, Object.XPos, Object.YPos)
298
end if
299
end sub
300
301
302
sub RSDKLoad
303
LoadSpriteSheet("Global/Items3.gif")
304
SpriteFrame(-40, -32, 80, 24, 175, 61) // #0 - Transporter Frame 0
305
SpriteFrame(-40, -32, 80, 24, 175, 86) // #1 - Transporter Frame 1
306
SpriteFrame(-40, -32, 80, 24, 175, 111) // #2 - Transporter Frame 2
307
SpriteFrame(-40, -32, 80, 24, 175, 86) // #3 - Transporter Frame 3
308
SpriteFrame(-6, -8, 12, 16, 149, 1) // #4 - Electricity Frame 0
309
SpriteFrame(-6, -8, 12, 16, 162, 1) // #5 - Electricity Frame 1
310
SpriteFrame(-6, -8, 12, 16, 149, 18) // #6 - Electricity Frame 2
311
SpriteFrame(-6, -8, 12, 16, 162, 18) // #7 - Electricity Frame 3
312
SpriteFrame(-22, -8, 12, 16, 149, 1) // #8 - Electricity Frame 4
313
SpriteFrame(-22, -8, 12, 16, 162, 1) // #9 - Electricity Frame 5
314
SpriteFrame(-22, -8, 12, 16, 149, 18) // #10 - Electricity Frame 6
315
SpriteFrame(-22, -8, 12, 16, 162, 18) // #11 - Electricity Frame 7
316
SpriteFrame(10, -8, 12, 16, 149, 1) // #12 - Electricity Frame 8
317
SpriteFrame(10, -8, 12, 16, 162, 1) // #13 - Electricity Frame 9
318
SpriteFrame(10, -8, 12, 16, 149, 18) // #14 - Electricity Frame 10
319
SpriteFrame(10, -8, 12, 16, 162, 18) // #15 - Electricity Frame 11
320
SpriteFrame(-40, 16, 80, 16, 175, 44) // #16 - Transporter Destroyed
321
SpriteFrame(-40, -32, 80, 25, 175, 18) // #17 - Transporter Old
322
SpriteFrame(-40, 16, 80, 16, 175, 1) // #18 - Transporter Old Destroyed
323
324
AddEditorVariable("inactive")
325
SetActiveVariable("inactive")
326
AddEnumVariable("False", false)
327
AddEnumVariable("True", true)
328
end sub
329
330