Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/SignPostM094.txt
1319 views
1
//---------------Sonic CD SignPost M094 Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//-----------Used on Mission "M094 - Tough Bluff"-------------//
5
6
// Aliases
7
#alias Object.Value0 : Object.Timer
8
#alias Object.Value1 : Object.FrameTimer
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 : SIGNPOSTM094_IDLE
19
#alias 1 : SIGNPOSTM094_FLIP
20
#alias 2 : SIGNPOSTM094_MOVE_PLAYER
21
#alias 3 : SIGNPOSTM094_STOP_PLAYER
22
#alias 4 : SIGNPOSTM094_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 SIGNPOSTM094_IDLE
38
Object.Frame = 1
39
40
TempValue0 = Object.YPos
41
TempValue0 += 0x600000
42
if Player.YPos < TempValue0 // Makes sure the player triggers the signpost no matter the height
43
if Player.XPos > Object.XPos
44
Stage.NewXBoundary1 = Object.XPos
45
Stage.NewXBoundary1 >>= 16
46
Stage.NewXBoundary1 -= Screen.CenterX
47
Stage.NewXBoundary2 = Object.XPos
48
Stage.NewXBoundary2 >>= 16
49
Stage.NewXBoundary2 += Screen.CenterX
50
51
EngineCallback(NOTIFY_TOUCH_SIGNPOST)
52
53
Stage.TimeEnabled = false
54
Object.State = SIGNPOSTM094_FLIP
55
Object.Timer = 8
56
57
PlaySfx(SFX_G_SIGNPOST, false)
58
end if
59
end if
60
break
61
62
case SIGNPOSTM094_FLIP
63
Music.Volume--
64
Object.FrameTimer++
65
if Object.FrameTimer == 2
66
67
Object.FrameTimer = 0
68
Object.Frame++
69
if Object.Frame == 5
70
// Spawn a ring sparkle at random location close to the sign post
71
Rand(TempValue0, 48)
72
TempValue0 <<= 16
73
TempValue0 += Object.XPos
74
TempValue0 -= 0x180000
75
76
Rand(TempValue1, 32)
77
TempValue1 <<= 16
78
TempValue1 += Object.YPos
79
TempValue1 -= 0x1C0000
80
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
81
82
Object.Timer--
83
if Object.Timer == 0
84
85
if Object[0].Type == TypeName[Blank Object] // Check if the player already leave by itself
86
87
Object.State = SIGNPOSTM094_BLANK
88
89
PlayMusic(1)
90
91
Object[30].Type = TypeName[ActFinish]
92
ActFinish.DrawOrder = 6
93
ActFinish.Priority = PRIORITY_ACTIVE
94
else // Otherwise the signpost will do it itself.
95
Player.ControlMode = CONTROLMODE_NONE
96
Player.Up = false
97
Player.Down = false
98
Player.Left = false
99
Player.JumpPress = false
100
Player.JumpHold = false
101
Object.State = SIGNPOSTM094_MOVE_PLAYER
102
end if
103
104
end if
105
106
end if
107
108
if Object.Frame == 9
109
// Spawn a ring sparkle at random location close to the sign post
110
Rand(TempValue0, 48)
111
TempValue0 <<= 16
112
TempValue0 += Object.XPos
113
TempValue0 -= 0x180000
114
115
Rand(TempValue1, 32)
116
TempValue1 <<= 16
117
TempValue1 += Object.YPos
118
TempValue1 -= 0x1C0000
119
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
120
// Resets the animation cycle
121
Object.Frame = 1
122
end if
123
124
end if
125
// Freezes the player after leaving the screen
126
TempValue0 = 40
127
TempValue0 += Screen.CenterX
128
TempValue0 <<= 16
129
TempValue0 += Object.XPos
130
if Player.XPos > TempValue0
131
Player.XPos = TempValue0
132
Player.Speed = 0
133
Player.XVelocity = 0
134
end if
135
break
136
137
case SIGNPOSTM094_MOVE_PLAYER
138
if Object[0].Type == TypeName[Blank Object]
139
Object.State = SIGNPOSTM094_BLANK
140
if Object.OutOfBounds == false
141
PlayMusic(1)
142
end if
143
Object[30].Type = TypeName[ActFinish]
144
ActFinish.DrawOrder = 6
145
ActFinish.Priority = PRIORITY_ACTIVE
146
end if
147
148
if Player.ControlMode == CONTROLMODE_NONE
149
Player.Right = true
150
end if
151
152
TempValue0 = Screen.CenterX
153
TempValue0 <<= 16
154
TempValue0 += Object.XPos
155
156
if Player.XPos > TempValue0
157
if Object.OutOfBounds == false
158
PlayMusic(1)
159
end if
160
Object.State = SIGNPOSTM094_STOP_PLAYER
161
Object[30].Type = TypeName[ActFinish]
162
ActFinish.DrawOrder = 6
163
ActFinish.Priority = PRIORITY_ACTIVE
164
end if
165
break
166
167
case SIGNPOSTM094_STOP_PLAYER
168
if Player.ControlMode == CONTROLMODE_NONE
169
Player.Right = true
170
end if
171
TempValue0 = 40
172
TempValue0 += Screen.CenterX
173
TempValue0 <<= 16
174
TempValue0 += Object.XPos
175
if Player.XPos > TempValue0
176
Player.XPos = TempValue0
177
Player.Speed = 0
178
Player.XVelocity = 0
179
end if
180
break
181
end switch
182
183
if Object.State > SIGNPOSTM094_IDLE
184
Player.InvincibleTimer = 80
185
end if
186
end sub
187
188
189
sub ObjectDraw
190
DrawSprite(0)
191
DrawSprite(Object.Frame)
192
end sub
193
194
195
sub ObjectStartup
196
if Stage.PlayerListPos == PLAYER_SONIC
197
LoadSpriteSheet("Global/Items2.gif")
198
end if
199
if Stage.PlayerListPos == PLAYER_TAILS
200
LoadSpriteSheet("Global/Items2_t.gif")
201
end if
202
if Stage.PlayerListPos == PLAYER_KNUCKLES
203
LoadSpriteSheet("Global/Items2_K.gif")
204
end if
205
if Stage.PlayerListPos == PLAYER_AMY
206
LoadSpriteSheet("Global/Items2_A.gif")
207
end if
208
209
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
210
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
211
SpriteFrame(-16, -44, 32, 32, 1, 183) // #2 - Sign Post Head (Flip 1)
212
SpriteFrame(-4, -44, 8, 32, 25, 150) // #3 - Sign Post Head (Flip 2)
213
SpriteFrame(-16, -44, 32, 32, 1, 216) // #4 - Sign Post Head (Flip 3)
214
SpriteFrame(-24, -44, 48, 32, 34, 132) // #5 - Sign Post Head (Player)
215
SpriteFrame(-16, -44, 32, 32, 1, 183) // #6 - Sign Post Head (Flip 1)
216
SpriteFrame(-4, -44, 8, 32, 25, 150) // #7 - Sign Post Head (Flip 2)
217
SpriteFrame(-16, -44, 32, 32, 1, 216) // #8 - Sign Post Head (Flip 3)
218
219
ArrayPos0 = 32
220
while ArrayPos0 < 1056
221
if Object[ArrayPos0].Type == TypeName[SignPostM094]
222
Object[ArrayPos0].Priority = PRIORITY_XBOUNDS
223
end if
224
ArrayPos0++
225
loop
226
end sub
227
228
229
// ========================
230
// Editor Subs
231
// ========================
232
233
234
sub RSDKDraw
235
DrawSprite(0)
236
DrawSprite(1)
237
end sub
238
239
240
sub RSDKLoad
241
LoadSpriteSheet("Global/Items2.gif")
242
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
243
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
244
245
// TODO: prob val is differnt every time it's used though, does that mean anything?
246
// (254 in extreme ssz, 255 in m094)
247
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
248
end sub
249
250
251
252
253
254