Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/SignPost.txt
1319 views
1
//-----------------Sonic CD Sign Post 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
#alias Object.Value1 : Object.FrameTimer
8
9
// Player Aliases
10
#alias Player.Value4 : Player.InvincibleTimer
11
12
// ActFinish Aliases
13
#alias Object[30].DrawOrder : ActFinish.DrawOrder
14
#alias Object[30].Priority : ActFinish.Priority
15
16
// States
17
#alias 0 : SIGNPOST_IDLE
18
#alias 1 : SIGNPOST_FLIP
19
#alias 2 : SIGNPOST_MOVE_PLAYER
20
#alias 3 : SIGNPOST_STOP_PLAYER
21
#alias 4 : SIGNPOST_BLANK
22
23
// Control Mode
24
#alias -1 : CONTROLMODE_NONE
25
26
// Player
27
#alias 0 : PLAYER_SONIC_A
28
#alias 1 : PLAYER_TAILS_A
29
30
// Global SFX
31
#alias 15 : SFX_G_SIGNPOST
32
33
// Property Values
34
#alias 0 : UPDATE_TILELAYER_1
35
#alias 1 : UPDATE_TILELAYER_2
36
#alias 2 : COMMON_SIGN
37
#alias 3 : HANDLE_MULTIPLE_SIGNS
38
39
// Priority
40
#alias 1 : PRIORITY_ACTIVE
41
#alias 3 : PRIORITY_XBOUNDS
42
43
44
sub ObjectMain
45
switch Object.State
46
case SIGNPOST_IDLE
47
Object.Frame = 1
48
49
TempValue0 = Object.YPos
50
TempValue0 += 0x600000
51
if Player.YPos < TempValue0 // Makes sure the player triggers the signpost no matter the height
52
Stage.NewXBoundary1 = Object.XPos
53
Stage.NewXBoundary1 >>= 16
54
Stage.NewXBoundary1 -= Screen.CenterX
55
Stage.NewXBoundary1 -= Screen.CenterX
56
57
Stage.NewXBoundary2 = Object.XPos
58
Stage.NewXBoundary2 >>= 16
59
Stage.NewXBoundary2 += Screen.CenterX
60
61
if Player.XPos > Object.XPos // Check that the player crossed the sign post
62
Stage.NewXBoundary1 = Object.XPos
63
Stage.NewXBoundary1 >>= 16
64
Stage.NewXBoundary1 -= Screen.CenterX
65
#platform: Use_Origins
66
EngineCallback(NOTIFY_TOUCH_SIGNPOST)
67
#endplatform
68
Stage.TimeEnabled = false
69
70
Object.State = SIGNPOST_FLIP
71
Object.Timer = 8
72
73
PlaySfx(SFX_G_SIGNPOST, false)
74
75
#platform: Use_Haptics
76
HapticEffect(50, 0, 0, 0)
77
#endplatform
78
79
end if
80
end if
81
break
82
83
case SIGNPOST_FLIP
84
Music.Volume--
85
Object.FrameTimer++
86
if Object.FrameTimer == 2
87
88
Object.FrameTimer = 0
89
Object.Frame++
90
if Object.Frame == 5
91
// Spawn a ring sparkle at random location close to the sign post
92
Rand(TempValue0, 48)
93
TempValue0 <<= 16
94
TempValue0 += Object.XPos
95
TempValue0 -= 0x180000
96
97
Rand(TempValue1, 32)
98
TempValue1 <<= 16
99
TempValue1 += Object.YPos
100
TempValue1 -= 0x1C0000
101
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
102
103
Object.Timer--
104
if Object.Timer == 0
105
106
if Object[0].Type == TypeName[Blank Object] // Check if the player already leave by itself
107
Object.State = SIGNPOST_BLANK
108
if Object.PropertyValue < 3
109
PlayMusic(1)
110
else
111
if Object.OutOfBounds == false
112
PlayMusic(1)
113
end if
114
end if
115
116
Object[30].Type = TypeName[ActFinish]
117
ActFinish.DrawOrder = 6
118
ActFinish.Priority = PRIORITY_ACTIVE
119
else // Otherwise the signpost will do it itself.
120
Player.ControlMode = CONTROLMODE_NONE
121
Player.Up = false
122
Player.Down = false
123
Player.Left = false
124
Player.JumpPress = false
125
Player.JumpHold = false
126
Object.State = SIGNPOST_MOVE_PLAYER
127
end if
128
129
end if
130
131
end if
132
133
if Object.Frame == 9
134
// Spawn a ring sparkle at random location close to the sign post
135
Rand(TempValue0, 48)
136
TempValue0 <<= 16
137
TempValue0 += Object.XPos
138
TempValue0 -= 0x180000
139
140
Rand(TempValue1, 32)
141
TempValue1 <<= 16
142
TempValue1 += Object.YPos
143
TempValue1 -= 0x1C0000
144
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
145
// Resets the animation cycle
146
Object.Frame = 1
147
end if
148
149
end if
150
// Freezes the player after leaving the screen
151
TempValue0 = 40
152
TempValue0 += Screen.CenterX
153
TempValue0 <<= 16
154
TempValue0 += Object.XPos
155
if Player.XPos > TempValue0
156
Player.XPos = TempValue0
157
Player.Speed = 0
158
Player.XVelocity = 0
159
end if
160
break
161
162
case SIGNPOST_MOVE_PLAYER
163
if Object[0].Type == TypeName[Blank Object]
164
Object.State = SIGNPOST_BLANK
165
if Object.PropertyValue < 3
166
PlayMusic(1)
167
else
168
if Object.OutOfBounds == false
169
PlayMusic(1)
170
end if
171
end if
172
Object[30].Type = TypeName[ActFinish]
173
ActFinish.DrawOrder = 6
174
ActFinish.Priority = PRIORITY_ACTIVE
175
end if
176
177
if Player.ControlMode == CONTROLMODE_NONE
178
Player.Right = true
179
end if
180
181
TempValue0 = Screen.CenterX
182
TempValue0 <<= 16
183
TempValue0 += Object.XPos
184
185
if Player.XPos > TempValue0
186
if Object.PropertyValue < 3
187
PlayMusic(1)
188
else
189
if Object.OutOfBounds == false
190
PlayMusic(1)
191
end if
192
end if
193
Object.State = SIGNPOST_STOP_PLAYER
194
195
Object[30].Type = TypeName[ActFinish]
196
ActFinish.DrawOrder = 6
197
ActFinish.Priority = PRIORITY_ACTIVE
198
else
199
#platform: Use_Origins
200
// Some Mission Mode stuff
201
if Player.Animation == ANI_PUSHING
202
PlayMusic(1)
203
Object.State = SIGNPOST_BLANK
204
Object[30].Type = TypeName[ActFinish]
205
Object[30].DrawOrder = 6
206
Object[30].Priority = PRIORITY_ACTIVE
207
end if
208
#endplatform
209
end if
210
break
211
212
case SIGNPOST_STOP_PLAYER
213
if Player.ControlMode == CONTROLMODE_NONE
214
Player.Right = true
215
end if
216
TempValue0 = 40
217
TempValue0 += Screen.CenterX
218
TempValue0 <<= 16
219
TempValue0 += Object.XPos
220
if Player.XPos > TempValue0
221
Player.XPos = TempValue0
222
Player.Speed = 0
223
Player.XVelocity = 0
224
end if
225
break
226
227
case SIGNPOST_BLANK
228
break
229
end switch
230
231
#platform: Use_Origins
232
if game.playMode == BOOT_PLAYMODE_MISSION
233
if Object.State > SIGNPOST_IDLE
234
// Origins gives the player invincibility, in case the game stops you close to a hazard
235
Player.InvincibleTimer = 80
236
end if
237
end if
238
#endplatform
239
end sub
240
241
242
sub ObjectDraw
243
DrawSprite(0)
244
DrawSprite(Object.Frame)
245
end sub
246
247
248
sub ObjectStartup
249
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
250
LoadSpriteSheet("Global/Items2.gif")
251
end if
252
if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins
253
LoadSpriteSheet("Global/Items2_t.gif")
254
end if
255
#platform: Use_Origins
256
// the file name suffixes are lowercase in every other script, but for some reason they're uppercase here in this script only? sure ig..?
257
if Stage.PlayerListPos == PLAYER_KNUCKLES
258
LoadSpriteSheet("Global/Items2_K.gif")
259
end if
260
if Stage.PlayerListPos == PLAYER_AMY
261
LoadSpriteSheet("Global/Items2_A.gif")
262
end if
263
#endplatform
264
265
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
266
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
267
SpriteFrame(-16, -44, 32, 32, 1, 183) // #2 - Sign Post Head (Flip 1)
268
SpriteFrame(-4, -44, 8, 32, 25, 150) // #3 - Sign Post Head (Flip 2)
269
SpriteFrame(-16, -44, 32, 32, 1, 216) // #4 - Sign Post Head (Flip 3)
270
SpriteFrame(-24, -44, 48, 32, 34, 132) // #5 - Sign Post Head (Player)
271
SpriteFrame(-16, -44, 32, 32, 1, 183) // #6 - Sign Post Head (Flip 1)
272
SpriteFrame(-4, -44, 8, 32, 25, 150) // #7 - Sign Post Head (Flip 2)
273
SpriteFrame(-16, -44, 32, 32, 1, 216) // #8 - Sign Post Head (Flip 3)
274
275
ArrayPos0 = 32
276
while ArrayPos0 < 1056
277
if Object[ArrayPos0].Type == TypeName[Sign Post]
278
Object[ArrayPos0].Priority = PRIORITY_XBOUNDS
279
280
// If needed, let's extend the stage a bit by repeating the last column of chunks
281
if Object[ArrayPos0].PropertyValue < 2
282
TempValue0 = TileLayer[0].XSize
283
TempValue0 -= 2
284
285
TempValue1 = TileLayer[0].XSize
286
TempValue2 = Object[ArrayPos0].iYPos
287
TempValue2 += 64
288
TempValue2 >>= 7
289
290
GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)
291
SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)
292
293
TempValue0++
294
TempValue1++
295
GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)
296
SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)
297
298
if Object[ArrayPos0].PropertyValue == UPDATE_TILELAYER_2
299
TempValue0--
300
TempValue1--
301
TempValue2--
302
GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)
303
SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)
304
305
TempValue0++
306
TempValue1++
307
GetTileLayerEntry(TempValue3, 0, TempValue0, TempValue2)
308
SetTileLayerEntry(TempValue3, 0, TempValue1, TempValue2)
309
end if
310
end if
311
end if
312
ArrayPos0++
313
loop
314
end sub
315
316
317
// ========================
318
// Editor Subs
319
// ========================
320
321
sub RSDKEdit
322
if Editor.ReturnVariable == true
323
switch Editor.VariableID
324
case EDIT_VAR_PROPVAL // Property Value
325
CheckResult = Object.PropertyValue
326
break
327
case 0 // Type
328
CheckResult = Object.PropertyValue
329
break
330
end switch
331
else
332
switch Editor.VariableID
333
case EDIT_VAR_PROPVAL // Property Value
334
Object.PropertyValue = Editor.VariableValue
335
break
336
case 0 // Type
337
Object.PropertyValue = Editor.VariableValue
338
break
339
end switch
340
end if
341
end sub
342
343
344
sub RSDKDraw
345
DrawSprite(0)
346
DrawSprite(1)
347
end sub
348
349
350
sub RSDKLoad
351
LoadSpriteSheet("Global/Items2.gif")
352
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
353
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
354
355
356
AddEditorVariable("Type")
357
SetActiveVariable("Type")
358
AddEnumVariable("Updates TileLayer (1)", 0)
359
AddEnumVariable("Updates TileLayer (2)", 1)
360
AddEnumVariable("Normal", 2)
361
AddEnumVariable("Normal (Handles Multiple SignPosts)", 3)
362
end sub
363
364