Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/SignPost2.txt
1319 views
1
//----------------Sonic CD SignPost 2 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
#alias Object.Value2 : Object.SignPostBound
9
10
// Player Aliases
11
#alias Player.Value4 : Player.InvincibleTimer
12
13
// ActFinish Aliases
14
#alias Object[30].DrawOrder : ActFinish.DrawOrder
15
#alias Object[30].Priority : ActFinish.Priority
16
17
// States
18
#alias 0 : SIGNPOST2_CHECK_BOUNDS
19
#alias 1 : SIGNPOST2_FLIP
20
#alias 2 : SIGNPOST2_MOVE_PLAYER
21
#alias 3 : SIGNPOST2_STOP_PLAYER
22
#alias 4 : SIGNPOST2_BLANK
23
24
// Control Mode
25
#alias -1 : CONTROLMODE_NONE
26
27
// Global SFX
28
#alias 15 : SFX_G_SIGNPOST
29
30
// Priority
31
#alias 1 : PRIORITY_ACTIVE
32
#alias 3 : PRIORITY_XBOUNDS
33
34
35
sub ObjectMain
36
switch Object.State
37
case SIGNPOST2_CHECK_BOUNDS
38
Object.Frame = 1
39
40
TempValue0 = Object.YPos
41
TempValue0 += 0x600000
42
43
if Player.YPos < TempValue0
44
if Object.SignPostBound > 0
45
TempValue0 = Object.XPos
46
TempValue0 -= Player.XPos
47
TempValue0 >>= 16
48
CheckGreater(TempValue0, 0)
49
TempValue1 = CheckResult
50
CheckLower(TempValue0, Object.SignPostBound)
51
CheckResult &= TempValue1
52
if CheckResult == true
53
Stage.NewXBoundary1 = Object.iXPos
54
Stage.NewXBoundary1 -= Object.SignPostBound
55
Stage.NewXBoundary2 = Object.XPos
56
Stage.NewXBoundary2 >>= 16
57
Stage.NewXBoundary2 += Screen.CenterX
58
end if
59
else
60
Stage.NewXBoundary1 = Object.XPos
61
Stage.NewXBoundary1 >>= 16
62
Stage.NewXBoundary1 -= Screen.CenterX
63
Stage.NewXBoundary1 -= Screen.CenterX
64
65
Stage.NewXBoundary2 = Object.XPos
66
Stage.NewXBoundary2 >>= 16
67
Stage.NewXBoundary2 += Screen.CenterX
68
end if
69
70
if Player.XPos > Object.XPos
71
Stage.NewXBoundary1 = Object.XPos
72
Stage.NewXBoundary1 >>= 16
73
Stage.NewXBoundary1 -= Screen.CenterX
74
75
EngineCallback(NOTIFY_TOUCH_SIGNPOST)
76
77
Stage.TimeEnabled = false
78
Object.State = SIGNPOST2_FLIP
79
Object.Timer = 8
80
81
PlaySfx(SFX_G_SIGNPOST, false)
82
83
end if
84
end if
85
break
86
87
case SIGNPOST2_FLIP
88
Music.Volume--
89
Object.FrameTimer++
90
if Object.FrameTimer == 2
91
92
Object.FrameTimer = 0
93
Object.Frame++
94
if Object.Frame == 5
95
// Spawn a ring sparkle at random location close to the sign post
96
Rand(TempValue0, 48)
97
TempValue0 <<= 16
98
TempValue0 += Object.XPos
99
TempValue0 -= 0x180000
100
101
Rand(TempValue1, 32)
102
TempValue1 <<= 16
103
TempValue1 += Object.YPos
104
TempValue1 -= 0x1C0000
105
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
106
107
Object.Timer--
108
if Object.Timer == 0
109
if Object[0].Type == TypeName[Blank Object] // Check if the player already leave by itself
110
Object.State = SIGNPOST2_BLANK
111
112
if Object.OutOfBounds == false
113
PlayMusic(1)
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 = SIGNPOST2_MOVE_PLAYER
127
end if
128
end if
129
end if
130
131
if Object.Frame == 9
132
// Spawn a ring sparkle at random location close to the sign post
133
Rand(TempValue0, 48)
134
TempValue0 <<= 16
135
TempValue0 += Object.XPos
136
TempValue0 -= 0x180000
137
138
Rand(TempValue1, 32)
139
TempValue1 <<= 16
140
TempValue1 += Object.YPos
141
TempValue1 -= 0x1C0000
142
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
143
// Resets the animation cycle
144
Object.Frame = 1
145
end if
146
147
end if
148
// Freezes the player after leaving the screen
149
TempValue0 = 40
150
TempValue0 += Screen.CenterX
151
TempValue0 <<= 16
152
TempValue0 += Object.XPos
153
if Player.XPos > TempValue0
154
Player.XPos = TempValue0
155
Player.Speed = 0
156
Player.XVelocity = 0
157
end if
158
break
159
160
case SIGNPOST2_MOVE_PLAYER
161
if Object[0].Type == TypeName[Blank Object]
162
Object.State = SIGNPOST2_BLANK
163
164
if Object.OutOfBounds == false
165
PlayMusic(1)
166
end if
167
168
Object[30].Type = TypeName[ActFinish]
169
ActFinish.DrawOrder = 6
170
ActFinish.Priority = PRIORITY_ACTIVE
171
end if
172
173
if Object.PropertyValue > 127
174
if Player.ControlMode == CONTROLMODE_NONE
175
Player.Right = true
176
end if
177
end if
178
179
TempValue0 = Screen.CenterX
180
TempValue0 <<= 16
181
TempValue0 += Object.XPos
182
CheckGreater(Player.XPos, TempValue0)
183
TempValue1 = CheckResult
184
CheckLower(Object.PropertyValue, 128)
185
CheckResult |= TempValue1
186
if CheckResult == true
187
if Object.OutOfBounds == false
188
PlayMusic(1)
189
end if
190
191
Object.State = SIGNPOST2_STOP_PLAYER
192
Object[30].Type = TypeName[ActFinish]
193
ActFinish.DrawOrder = 6
194
ActFinish.Priority = PRIORITY_ACTIVE
195
else
196
if Player.Animation == ANI_PUSHING
197
PlayMusic(1)
198
Object.State = SIGNPOST2_BLANK
199
Object[30].Type = TypeName[ActFinish]
200
ActFinish.DrawOrder = 6
201
ActFinish.Priority = PRIORITY_ACTIVE
202
end if
203
end if
204
break
205
206
case SIGNPOST2_STOP_PLAYER
207
if Object.PropertyValue > 127
208
if Player.ControlMode == CONTROLMODE_NONE
209
Player.Right = true
210
end if
211
end if
212
213
TempValue0 = 40
214
TempValue0 += Screen.CenterX
215
TempValue0 <<= 16
216
TempValue0 += Object.XPos
217
218
if Player.XPos > TempValue0
219
Player.XPos = TempValue0
220
Player.Speed = 0
221
Player.XVelocity = 0
222
end if
223
break
224
end switch
225
226
if Object.State > SIGNPOST2_FLIP
227
if Object.PropertyValue < 128
228
CheckEqual(Player.State, Player_State_Ground)
229
TempValue0 = CheckResult
230
CheckEqual(Player.OutOfBounds, true)
231
TempValue0 |= CheckResult
232
233
TempValue1 = Screen.XOffset
234
TempValue1 += Screen.XSize
235
TempValue1 += 32
236
CheckGreater(Player.iXPos, TempValue1)
237
TempValue0 |= CheckResult
238
if TempValue0 == true
239
Player.ControlMode = CONTROLMODE_NONE
240
Player.JumpHold = false
241
Player.Right = false
242
Player.Left = false
243
Player.Up = false
244
Player.Down = false
245
246
if Player.State == Player_State_Ground
247
Player.XVelocity = 0
248
Player.YVelocity = 0
249
end if
250
251
Player.Speed = 0
252
Screen.CameraEnabled = false
253
end if
254
end if
255
end if
256
257
if Object.State > SIGNPOST2_CHECK_BOUNDS
258
Player.InvincibleTimer = 80
259
end if
260
end sub
261
262
263
sub ObjectDraw
264
DrawSprite(0)
265
DrawSprite(Object.Frame)
266
end sub
267
268
269
sub ObjectStartup
270
if Stage.PlayerListPos == PLAYER_SONIC
271
LoadSpriteSheet("Global/Items2.gif")
272
end if
273
if Stage.PlayerListPos == PLAYER_TAILS
274
LoadSpriteSheet("Global/Items2_t.gif")
275
end if
276
if Stage.PlayerListPos == PLAYER_KNUCKLES
277
LoadSpriteSheet("Global/Items2_K.gif")
278
end if
279
if Stage.PlayerListPos == PLAYER_AMY
280
LoadSpriteSheet("Global/Items2_A.gif")
281
end if
282
283
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
284
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
285
SpriteFrame(-16, -44, 32, 32, 1, 183) // #2 - Sign Post Head (Flip 1)
286
SpriteFrame(-4, -44, 8, 32, 25, 150) // #3 - Sign Post Head (Flip 2)
287
SpriteFrame(-16, -44, 32, 32, 1, 216) // #4 - Sign Post Head (Flip 3)
288
SpriteFrame(-24, -44, 48, 32, 34, 132) // #5 - Sign Post Head (Player)
289
SpriteFrame(-16, -44, 32, 32, 1, 183) // #6 - Sign Post Head (Flip 1)
290
SpriteFrame(-4, -44, 8, 32, 25, 150) // #7 - Sign Post Head (Flip 2)
291
SpriteFrame(-16, -44, 32, 32, 1, 216) // #8 - Sign Post Head (Flip 3)
292
293
ArrayPos0 = 32
294
while ArrayPos0 < 1056
295
if Object[ArrayPos0].Type == TypeName[SignPost2]
296
Object[ArrayPos0].Priority = PRIORITY_XBOUNDS
297
if Object[ArrayPos0].PropertyValue < 128
298
Object[ArrayPos0].SignPostBound = Object[ArrayPos0].PropertyValue
299
else
300
Object[ArrayPos0].SignPostBound = 256
301
Object[ArrayPos0].SignPostBound -= Object[ArrayPos0].PropertyValue
302
end if
303
Object[ArrayPos0].SignPostBound <<= 4
304
end if
305
ArrayPos0++
306
loop
307
end sub
308
309
310
// ========================
311
// Editor Subs
312
// ========================
313
314
sub RSDKDraw
315
DrawSprite(0)
316
DrawSprite(1)
317
end sub
318
319
320
sub RSDKLoad
321
LoadSpriteSheet("Global/Items2.gif")
322
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
323
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
324
325
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
326
end sub
327
328
329
330