Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/FallSignPost.txt
1319 views
1
//---------------Sonic CD Fall 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
#alias Object.Value2 : Object.IdleTimer
9
#alias Object.Value4 : Object.YVelocity
10
#alias Object.Value5 : Object.OnFloor
11
12
// States
13
#alias 0 : FALLSIGNPOST_SETUP
14
#alias 1 : FALLSIGNPOST_AIR_FLIP
15
#alias 2 : FALLSIGNPOST_FLIP
16
#alias 3 : FALLSIGNPOST_STOP_PLAYER
17
18
// Camera
19
#alias 4 : CAMERASTYLE_HLOCKED
20
21
// Control Mode
22
#alias -1 : CONTROLMODE_NONE
23
24
// Collision Sides
25
#alias 0 : CSIDE_FLOOR
26
27
// Global SFX
28
#alias 15 : SFX_G_SIGNPOST
29
30
// Priority
31
#alias 1 : PRIORITY_ACTIVE
32
33
34
sub ObjectMain
35
switch Object.State
36
case FALLSIGNPOST_SETUP
37
CheckEqual(game.missionCondition, MISSION_CONDITION_CLEAR)
38
TempValue0 = CheckResult
39
CheckNotEqual(Screen.YOffset, 0)
40
TempValue0 &= CheckResult
41
if TempValue0 == true
42
game.missionCondition = false
43
Object.XPos = Player.XPos
44
Object.XPos -= 0x80000
45
46
Object.YPos = Screen.YOffset
47
Object.YPos += 24
48
Object.YPos <<= 16
49
50
Screen.CameraStyle = CAMERASTYLE_HLOCKED
51
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
52
if CheckResult == true
53
Object.OnFloor = true
54
end if
55
Object.State = FALLSIGNPOST_AIR_FLIP
56
PlaySfx(SFX_G_SIGNPOST, false)
57
end if
58
break
59
60
case FALLSIGNPOST_AIR_FLIP
61
Object.IdleTimer++
62
63
Object.YPos += Object.YVelocity
64
Object.YVelocity += 0xC00
65
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
66
if CheckResult == true
67
if Object.OnFloor == false
68
Object.Timer = 4
69
Object.State = FALLSIGNPOST_FLIP
70
end if
71
else
72
Object.OnFloor = false
73
end if
74
75
TempValue0 = Screen.YOffset
76
TempValue0 += Screen.YSize
77
TempValue0 += 44
78
if Object.iYPos >= TempValue0
79
Object.Timer = 4
80
Object.State = FALLSIGNPOST_FLIP
81
end if
82
83
Object.FrameTimer++
84
if Object.FrameTimer == 2
85
Object.FrameTimer = 0
86
Object.Frame++
87
if Object.Frame == 5
88
Rand(TempValue0,48)
89
TempValue0 <<= 16
90
TempValue0 += Object.XPos
91
TempValue0 -= 0x180000
92
93
Rand(TempValue1,32)
94
TempValue1 <<= 16
95
TempValue1 += Object.YPos
96
TempValue1 -= 0x140000
97
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
98
end if
99
100
if Object.Frame == 9
101
Object.Frame = 1
102
Rand(TempValue0, 48)
103
TempValue0 <<= 16
104
TempValue0 += Object.XPos
105
TempValue0 -= 0x180000
106
107
Rand(TempValue1, 32)
108
TempValue1 <<= 16
109
TempValue1 += Object.YPos
110
TempValue1 -= 0x140000
111
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
112
end if
113
end if
114
break
115
116
case FALLSIGNPOST_FLIP
117
Object.IdleTimer++
118
if Stage.TimeEnabled == true
119
Music.Volume -= 2
120
end if
121
122
Object.FrameTimer++
123
if Object.FrameTimer == 2
124
Object.FrameTimer = 0
125
Object.Frame++
126
if Object.Frame == 5
127
Rand(TempValue0, 48)
128
TempValue0 <<= 16
129
TempValue0 += Object.XPos
130
TempValue0 -= 0x180000
131
132
Rand(TempValue1, 32)
133
TempValue1 <<= 16
134
TempValue1 += Object.YPos
135
TempValue1 -= 0x140000
136
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
137
end if
138
139
if Object.Frame == 9
140
Rand(TempValue0, 48)
141
TempValue0 <<= 16
142
TempValue0 += Object.XPos
143
TempValue0 -= 0x180000
144
145
Rand(TempValue1, 32)
146
TempValue1 <<= 16
147
TempValue1 += Object.YPos
148
TempValue1 -= 0x140000
149
CreateTempObject(TypeName[Ring Sparkle], 0, TempValue0, TempValue1)
150
Object.Timer--
151
if Object.Timer == 0
152
Object.Frame = 5
153
Object.State = FALLSIGNPOST_STOP_PLAYER
154
else
155
Object.Frame = 1
156
end if
157
end if
158
end if
159
break
160
161
case FALLSIGNPOST_STOP_PLAYER
162
CheckEqual(Player.State, Player_State_Ground)
163
TempValue0 = CheckResult
164
CheckEqual(Player.OutOfBounds, true)
165
TempValue0 |= CheckResult
166
167
TempValue1 = Screen.XOffset
168
TempValue1 += Screen.XSize
169
TempValue1 += 32
170
CheckGreater(Player.iXPos, TempValue1)
171
TempValue0 |= CheckResult
172
if TempValue0 == true
173
Player.ControlMode = CONTROLMODE_NONE
174
Player.JumpHold = false
175
Player.Right = false
176
Player.Left = false
177
Player.Up = false
178
Player.Down = false
179
180
if Player.State == Player_State_Ground
181
Player.XVelocity = 0
182
Player.YVelocity = 0
183
end if
184
Player.Speed = 0
185
186
Screen.CameraEnabled = false
187
end if
188
break
189
end switch
190
191
CheckGreater(Object.IdleTimer, 60)
192
TempValue0 = CheckResult
193
CheckEqual(Object[30].Type, TypeName[Blank Object])
194
TempValue0 &= CheckResult
195
if TempValue0 == true
196
EngineCallback(NOTIFY_TOUCH_SIGNPOST)
197
Stage.TimeEnabled = false
198
PlayMusic(1)
199
200
Object[30].Type = TypeName[ActFinish]
201
Object[30].DrawOrder = 6
202
Object[30].Priority = PRIORITY_ACTIVE
203
end if
204
205
if Stage.TimeEnabled == false
206
Player.AirTimer = 0
207
end if
208
end sub
209
210
211
sub ObjectDraw
212
if Object.State > FALLSIGNPOST_SETUP
213
DrawSprite(0)
214
DrawSprite(Object.Frame)
215
end if
216
end sub
217
218
219
sub ObjectStartup
220
LoadSpriteSheet("Global/Items2.gif")
221
222
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
223
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
224
SpriteFrame(-16, -44, 32, 32, 1, 183) // #2 - Sign Post Head (Flip 1)
225
SpriteFrame(-4, -44, 8, 32, 25, 150) // #3 - Sign Post Head (Flip 2)
226
SpriteFrame(-16, -44, 32, 32, 1, 216) // #4 - Sign Post Head (Flip 3)
227
SpriteFrame(-24, -44, 48, 32, 34, 132) // #5 - Sign Post Head (Player)
228
SpriteFrame(-16, -44, 32, 32, 1, 183) // #6 - Sign Post Head (Flip 1)
229
SpriteFrame(-4, -44, 8, 32, 25, 150) // #7 - Sign Post Head (Flip 2)
230
SpriteFrame(-16, -44, 32, 32, 1, 216) // #8 - Sign Post Head (Flip 3)
231
232
ArrayPos0 = 32
233
while ArrayPos0 < 1056
234
if Object[ArrayPos0].Type == TypeName[FallSignPost]
235
Object[ArrayPos0].Frame = 1
236
Object[ArrayPos0].Timer = 16
237
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
238
end if
239
ArrayPos0++
240
loop
241
end sub
242
243
244
// ========================
245
// Editor Subs
246
// ========================
247
248
sub RSDKDraw
249
DrawSprite(0)
250
DrawSprite(1)
251
end sub
252
253
254
sub RSDKLoad
255
LoadSpriteSheet("Global/Items2.gif")
256
257
SpriteFrame(-12, -12, 24, 24, 0, 150) // #0 - Sign Post
258
SpriteFrame(-24, -44, 48, 32, 34, 99) // #1 - Sign Post Head (Eggman)
259
260
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
261
end sub
262
263
264
265