Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/EffectTrigger.txt
1319 views
1
//--------------Sonic CD Effect Trigger Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Property Values
6
7
// Level
8
#alias 0 : SET_BG_LAYER
9
#alias 1 : SWAP_BACKGROUND
10
#alias 2 : WATER_HEIGHT
11
#alias 13 : WATER_HEIGHT_2 // not sure if this is used
12
13
// Pipes
14
#alias 4 : PIPE_BOTTOM_ENTRY
15
#alias 5 : PIPE_TOP_ENTRY
16
#alias 6 : PIPE_TURN_LEFT
17
#alias 7 : PIPE_TURN_RIGHT
18
#alias 8 : PIPE_TURN_UP
19
#alias 9 : PIPE_TURN_DOWN
20
#alias 10 : UNUSED
21
#alias 11 : UNUSED_2
22
#alias 12 : PIPE_EXIT_PIPE
23
24
25
sub ObjectMain
26
switch Object.PropertyValue
27
case SET_BG_LAYER
28
if Player.XPos < 0x2800000 // X - 640 in map coords
29
Stage[0].ActiveLayer = 1 // why it does this instead of starting with this layer directly? no clue
30
31
Object.Type = TypeName[Blank Object]
32
Object[19].Type = TypeName[BGAnimation]
33
end if
34
break
35
36
case SWAP_BACKGROUND
37
if Player.YPos > Object.YPos
38
Stage[0].ActiveLayer = 2
39
40
Object[19].Type = TypeName[BGAnimation]
41
else
42
Stage[0].ActiveLayer = 1
43
44
Object[19].Type = TypeName[BGAnimation]
45
end if
46
break
47
48
case WATER_HEIGHT
49
if Player.XPos > Object.XPos
50
Stage.NewWaterLevel = 0x2640000 // Y - 612 in map coords
51
else
52
Stage.NewWaterLevel = 0x2840000 // Y - 644 in map coords
53
end if
54
break
55
56
case PIPE_BOTTOM_ENTRY
57
PlayerObjectCollision(C_TOUCH, -10, -16, 10, 16)
58
if CheckResult == true
59
if Player.State != Player_State_Death
60
if Player.State != Player_State_Drown
61
Warp.Timer = 0
62
63
Player.State = Player_State_WaterCurrent
64
Player.Animation = ANI_FANROTATE
65
66
Player.XVelocity = 0
67
Player.YVelocity = -0x40000
68
69
if Player.XPos < Object.XPos
70
Player.XPos += 0x10000
71
else
72
Player.XPos -= 0x10000
73
end if
74
end if
75
end if
76
else
77
if Player.State == Player_State_WaterCurrent
78
PlayerObjectCollision(C_TOUCH, -64, -16, -32, 16)
79
if CheckResult == true
80
81
#platform: Use_Origins
82
Player.State = Player_State_Air_NoDropDash
83
#endplatform
84
85
#platform: Use_Standalone
86
Player.State = Player_State_Air
87
#endplatform
88
89
Player.Animation = ANI_WALKING
90
end if
91
92
PlayerObjectCollision(C_TOUCH, 32, -16, 64, 16)
93
if CheckResult == true
94
95
#platform: Use_Origins
96
Player.State = Player_State_Air_NoDropDash
97
#endplatform
98
99
#platform: Use_Standalone
100
Player.State = Player_State_Air
101
#endplatform
102
103
Player.Animation = ANI_WALKING
104
end if
105
end if
106
end if
107
break
108
109
case PIPE_TOP_ENTRY
110
PlayerObjectCollision(C_TOUCH, -10, -16, 10, 16)
111
if CheckResult == true
112
if Player.State != Player_State_Death
113
if Player.State != Player_State_Drown
114
Warp.Timer = 0
115
Player.State = Player_State_WaterCurrent
116
Player.Animation = ANI_FANROTATE
117
118
Player.XVelocity = 0
119
Player.YVelocity = 0x40000
120
121
if Player.XPos < Object.XPos
122
Player.XPos += 0x10000
123
else
124
Player.XPos -= 0x10000
125
end if
126
end if
127
end if
128
else
129
if Player.State == Player_State_WaterCurrent
130
PlayerObjectCollision(C_TOUCH, -64, -16, -32, 16)
131
if CheckResult == true
132
Player.State = Player_State_Ground
133
Player.Animation = ANI_WALKING
134
end if
135
136
PlayerObjectCollision(C_TOUCH, 32, -16, 64, 16)
137
if CheckResult == true
138
Player.State = Player_State_Ground
139
Player.Animation = ANI_WALKING
140
end if
141
end if
142
end if
143
break
144
145
case PIPE_TURN_LEFT
146
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
147
if CheckResult == true
148
if Player.State != Player_State_Death
149
if Player.State != Player_State_Drown
150
Player.XVelocity = -0x40000
151
Player.Animation = ANI_FANROTATE
152
end if
153
end if
154
end if
155
break
156
157
case PIPE_TURN_RIGHT
158
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
159
if CheckResult == true
160
if Player.State != Player_State_Death
161
if Player.State != Player_State_Drown
162
Player.XVelocity = 0x40000
163
Player.Animation = ANI_FANROTATE
164
end if
165
end if
166
end if
167
break
168
169
case PIPE_TURN_UP
170
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
171
if CheckResult == true
172
if Player.State != Player_State_Death
173
if Player.State != Player_State_Drown
174
Player.YVelocity = -0x40000
175
Player.Animation = ANI_FANROTATE
176
end if
177
end if
178
end if
179
break
180
181
case PIPE_TURN_DOWN
182
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
183
if CheckResult == true
184
if Player.State != Player_State_Death
185
if Player.State != Player_State_Drown
186
Player.YVelocity = 0x40000
187
Player.Animation = ANI_FANROTATE
188
end if
189
end if
190
end if
191
break
192
193
case UNUSED
194
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
195
if CheckResult == true
196
if Player.State != Player_State_Death
197
if Player.State != Player_State_Drown
198
Player.XVelocity = 0
199
end if
200
end if
201
end if
202
break
203
204
case UNUSED_2
205
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
206
if CheckResult == true
207
if Player.State != Player_State_Death
208
if Player.State != Player_State_Drown
209
Player.YVelocity = 0
210
end if
211
end if
212
end if
213
break
214
215
case PIPE_EXIT_PIPE
216
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
217
if CheckResult == true
218
if Player.State != Player_State_Death
219
if Player.State != Player_State_Drown
220
Player.YVelocity = 0x40000
221
222
#platform: Use_Origins
223
Player.State = Player_State_Air_NoDropDash
224
#endplatform
225
226
#platform: Use_Standalone
227
Player.State = Player_State_Air
228
#endplatform
229
230
Player.Animation = ANI_WALKING
231
end if
232
end if
233
end if
234
break
235
236
case WATER_HEIGHT_2
237
if Player.XPos > Object.XPos
238
Stage.NewWaterLevel = 0x7800000 // Y - 1920 in map coords
239
else
240
Stage.NewWaterLevel = 0x5340000 // Y - 1332 in map coords
241
end if
242
break
243
244
end switch
245
end sub
246
247
248
// ========================
249
// Editor Subs
250
// ========================
251
252
sub RSDKEdit
253
if Editor.ReturnVariable == true
254
switch Editor.VariableID
255
case EDIT_VAR_PROPVAL // Property Value
256
CheckResult = Object.PropertyValue
257
break
258
case 0 // effect
259
CheckResult = Object.PropertyValue
260
CheckResult %= 14
261
break
262
end switch
263
else
264
switch Editor.VariableID
265
case EDIT_VAR_PROPVAL // Property Value
266
Object.PropertyValue = Editor.VariableValue
267
break
268
case 0 // effect
269
Object.PropertyValue = Editor.VariableValue
270
Object.PropertyValue %= 14
271
break
272
end switch
273
end if
274
end sub
275
276
277
sub RSDKDraw
278
LoadSpriteSheet("Global/Display.gif")
279
TempValue5 = Object.SpriteSheet
280
LoadSpriteSheet("Players/Sonic3.gif")
281
TempValue6 = Object.SpriteSheet
282
283
Object.InkEffect = 2
284
Object.Alpha = 198
285
286
TempValue0 = Object.XPos
287
TempValue0 -= 0x300000
288
TempValue1 = Object.XPos
289
TempValue1 += 0x300000
290
TempValue2 = Object.YPos
291
TempValue2 -= 0x300000
292
TempValue3 = Object.YPos
293
TempValue3 += 0x300000
294
295
switch Object.PropertyValue
296
case SET_BG_LAYER
297
case SWAP_BACKGROUND
298
case WATER_HEIGHT
299
case WATER_HEIGHT_2
300
Object.SpriteSheet = TempValue5
301
TempValue1 = Object.YPos
302
TempValue1 -= 0x80000
303
TempValue2 = Object.YPos
304
TempValue2 += 0x80000
305
TempValue0 = Object.XPos
306
TempValue0 -= 0x80000
307
DrawSpriteXY(1, TempValue0, TempValue1)
308
DrawSpriteXY(1, TempValue0, TempValue2)
309
TempValue0 = Object.XPos
310
TempValue0 += 0x80000
311
DrawSpriteXY(1, TempValue0, TempValue1)
312
DrawSpriteXY(1, TempValue0, TempValue2)
313
break
314
315
case PIPE_BOTTOM_ENTRY
316
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue3, 255, 0, 0)
317
318
Object.SpriteSheet = TempValue5
319
DrawSpriteXY(1, Object.XPos, Object.YPos)
320
TempValue4 = Object.XPos
321
TempValue4 -= 0x100000
322
DrawSpriteXY(1, TempValue4, Object.YPos)
323
TempValue4 = Object.XPos
324
TempValue4 += 0x100000
325
DrawSpriteXY(1, TempValue4, Object.YPos)
326
break
327
case PIPE_TOP_ENTRY
328
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue3, 255, 0, 0)
329
330
Object.SpriteSheet = TempValue5
331
DrawSpriteXY(1, Object.XPos, Object.YPos)
332
TempValue4 = Object.XPos
333
TempValue4 -= 0x100000
334
DrawSpriteXY(1, TempValue4, Object.YPos)
335
TempValue4 = Object.XPos
336
TempValue4 += 0x100000
337
DrawSpriteXY(1, TempValue4, Object.YPos)
338
break
339
case PIPE_TURN_LEFT
340
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, 0, 0)
341
342
Object.SpriteSheet = TempValue6
343
DrawSpriteFX(4, FX_INK, Object.XPos, Object.YPos)
344
break
345
case PIPE_TURN_RIGHT
346
DrawArrow(Object.XPos, Object.YPos, TempValue1, Object.YPos, 255, 0, 0)
347
348
Object.SpriteSheet = TempValue6
349
DrawSpriteFX(2, FX_INK, Object.XPos, Object.YPos)
350
break
351
case PIPE_TURN_UP
352
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue2, 255, 0, 0)
353
354
Object.SpriteSheet = TempValue6
355
DrawSpriteFX(3, FX_INK, Object.XPos, Object.YPos)
356
break
357
case PIPE_TURN_DOWN
358
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue3, 255, 0, 0)
359
360
Object.SpriteSheet = TempValue6
361
DrawSpriteFX(3, FX_INK, Object.XPos, Object.YPos)
362
break
363
case UNUSED
364
case UNUSED_2
365
DrawSpriteFX(4, FX_INK, Object.XPos, Object.YPos)
366
break
367
case PIPE_EXIT_PIPE
368
Object.SpriteSheet = TempValue6
369
DrawSpriteFX(3, FX_INK, Object.XPos, Object.YPos)
370
371
Object.SpriteSheet = TempValue5
372
TempValue2 = Object.YPos
373
TempValue2 -= 0x100000
374
DrawSpriteXY(1, Object.XPos, TempValue2)
375
TempValue4 = Object.XPos
376
TempValue4 -= 0x100000
377
DrawSpriteXY(1, TempValue4, TempValue2)
378
TempValue4 = Object.XPos
379
TempValue4 += 0x100000
380
DrawSpriteXY(1, TempValue4, TempValue2)
381
TempValue2 = Object.YPos
382
TempValue2 += 0x300000
383
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue2, 255, 0, 0)
384
break
385
end switch
386
end sub
387
388
389
sub RSDKLoad
390
LoadSpriteSheet("Global/Display.gif")
391
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
392
SpriteFrame(-8, -8, 16, 16, 173, 67) // #1 - "T" Icon
393
394
LoadSpriteSheet("Players/Sonic3.gif")
395
SpriteFrame(-28, -12, 56, 24, 199, 75) // #2 - Sonic Fan Rotate frame 0
396
SpriteFrame(-24, -12, 48, 24, 207, 125) // #3 - Sonic Fan Rotate frame 1
397
SpriteFrame(-28, -12, 56, 24, 199, 100) // #4 - Sonic Fan Rotate frame 2
398
399
AddEditorVariable("effect")
400
SetActiveVariable("effect")
401
AddEnumVariable("Set background layer", SET_BG_LAYER)
402
AddEnumVariable("Swap backgrounds", SWAP_BACKGROUND)
403
AddEnumVariable("Set water height", WATER_HEIGHT)
404
AddEnumVariable("Stream entry (Bottom)", PIPE_BOTTOM_ENTRY)
405
AddEnumVariable("Stream entry (Top)", PIPE_TOP_ENTRY)
406
AddEnumVariable("Stream turn (Left)", PIPE_TURN_LEFT)
407
AddEnumVariable("Stream turn (Right)", PIPE_TURN_RIGHT)
408
AddEnumVariable("Stream turn (Up)", PIPE_TURN_UP)
409
AddEnumVariable("Stream turn (Down)", PIPE_TURN_DOWN)
410
AddEnumVariable("Stop horizontal speed", UNUSED)
411
AddEnumVariable("Stop vertical speed", UNUSED_2)
412
AddEnumVariable("Exit stream", PIPE_EXIT_PIPE)
413
AddEnumVariable("Set water height (Bottom of level)", WATER_HEIGHT_2)
414
end sub
415
416