Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/BossCurtain.txt
1319 views
1
//---------------Sonic CD Boss Curtain 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.LeftCurtainTile
8
#alias Object.Value2 : Object.RightCurtainTile
9
10
// Boss Wing Alias
11
#alias Object.Value7 : BossWing.EggMobileEntity
12
13
// Egg Mobile Alias
14
#alias Object[-3].Value4 : EggMobile.WingOffset
15
16
// Helper 1 Aliases
17
#alias Object[-2].Value0 : Helper1.BossHealth
18
#alias Object[-2].Value1 : Helper1.Controller
19
#alias Object[-2].Value4 : Helper1.LeftBound
20
#alias Object[-2].Value5 : Helper1.RightBound
21
#alias Object[-2].Value6 : Helper1.CenterBound
22
23
// Helper 2 Alias
24
#alias Object[-1].Value6 : Helper2.CutsceneRightBound
25
26
// R8 Setup Alias
27
#alias Object[19].Value1 : R8Setup.CurrentPalette
28
29
// HUD Alias
30
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
31
32
// States
33
#alias 0 : BOSSCURTAIN_WAIT_PLAYER
34
#alias 1 : BOSSCURTAIN_SPAWN_BOSS
35
#alias 2 : BOSSCURTAIN_SET_BOUNDS
36
37
// Time Periods
38
#alias 1 : TIME_PAST
39
40
// Soundtrack
41
#alias 0 : OST_JP
42
43
// Tile Info
44
#alias 0 : TILEINFO_INDEX
45
46
// Fade Music Property Values
47
#alias 0 : FADEMUSIC_TO_BOSS
48
49
50
sub ObjectMain
51
switch Object.State
52
case BOSSCURTAIN_WAIT_PLAYER
53
if Player.XPos > Object.XPos
54
// This check doesn't make sense
55
// is a boss stage, you're already forced to be in the future
56
if HUD.CurrentTimePeriod > 1
57
if Options.Soundtrack == OST_JP
58
SetMusicTrack("JP/FinalBoss.ogg", 4, true)
59
else
60
SetMusicTrack("US/FinalBoss.ogg", 4, true)
61
end if
62
end if
63
64
Object.State++
65
end if
66
break
67
68
case BOSSCURTAIN_SPAWN_BOSS
69
if Object.Timer < 240
70
Object.Timer++
71
72
if Object.Timer == 140
73
CreateTempObject(TypeName[Fade Music], FADEMUSIC_TO_BOSS, Object.XPos, Object.YPos)
74
end if
75
else
76
Object.Timer = 0
77
R8Setup.CurrentPalette = 0
78
ArrayPos0 = Object.EntityNo
79
ArrayPos0 -= 3
80
Object[-3].Type = TypeName[Egg Mobile]
81
82
Object[-7].Type = TypeName[Boss Wing]
83
BossWing[-7].EggMobileEntity = ArrayPos0
84
85
Object[-6].Type = TypeName[Boss Wing]
86
BossWing[-6].EggMobileEntity = ArrayPos0
87
88
Object[-5].Type = TypeName[Boss Wing]
89
BossWing[-5].EggMobileEntity = ArrayPos0
90
91
Object[-4].Type = TypeName[Boss Wing]
92
BossWing[-4].EggMobileEntity = ArrayPos0
93
94
Helper1.BossHealth = 4
95
Helper1.CenterBound = Object.XPos
96
97
Helper1.LeftBound = Object.XPos
98
Helper1.LeftBound -= 0x7C0000
99
100
Helper1.RightBound = Object.XPos
101
Helper1.RightBound += 0x7C0000
102
103
EggMobile.WingOffset = 0x1000
104
105
Helper1.Controller = Helper1Controller_FourWings
106
107
Helper2.CutsceneRightBound = Stage.XBoundary2
108
Object.State++
109
end if
110
break
111
112
case BOSSCURTAIN_SET_BOUNDS
113
if Object.Alpha > 0
114
Object.Alpha -= 4
115
end if
116
117
Object.LeftCurtainTile -= 0x20000
118
Object.RightCurtainTile += 0x20000
119
120
TempValue1 = Object.LeftCurtainTile
121
TempValue1 >>= 16
122
TempValue1 += 7
123
124
TempValue3 = Object.RightCurtainTile
125
TempValue3 >>= 16
126
TempValue3 -= 7
127
128
TempValue2 = Object.iYPos
129
TempValue2 -= 92
130
131
TempValue0 = 0
132
while TempValue0 < 12
133
// Swap tiles to fake motion on the curtain background
134
Set16x16TileInfo(0, TempValue1, TempValue2, TILEINFO_INDEX)
135
TempValue1 -= 16
136
Set16x16TileInfo(395, TempValue1, TempValue2, TILEINFO_INDEX)
137
TempValue1 += 16
138
Set16x16TileInfo(0, TempValue3, TempValue2, TILEINFO_INDEX)
139
TempValue3 += 16
140
Set16x16TileInfo(395, TempValue3, TempValue2, TILEINFO_INDEX)
141
TempValue3 -= 16
142
TempValue2 += 16
143
TempValue0++
144
loop
145
146
if Object.Timer < 120
147
Object.Timer++
148
else
149
Object.Timer = 0
150
Object.State++
151
// Wide resolutions get forced to fight in a 320px wide area
152
if Screen.XSize > 320
153
ResetObjectEntity(Object.EntityNo, TypeName[Forcefield], 240, Object.XPos, Object.YPos)
154
else
155
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, Object.XPos, Object.YPos)
156
end if
157
end if
158
break
159
end switch
160
end sub
161
162
163
sub ObjectPlayerInteraction
164
// Player Right Bound
165
TempValue0 = Player.CollisionRight
166
TempValue0 <<= 16
167
TempValue0 += Player.XPos
168
169
// Stage Bound
170
TempValue1 = Stage.XBoundary2
171
TempValue1 <<= 16
172
173
// Stop the player from advancing if the player right bound pos is after the stage bound pos
174
if TempValue0 > TempValue1
175
Player.XVelocity = 0
176
Player.Speed = 0
177
Player.XPos = TempValue1
178
179
TempValue0 = Player.CollisionRight
180
TempValue0 <<= 16
181
Player.XPos -= TempValue0
182
end if
183
end sub
184
185
186
sub ObjectDraw
187
if Object.DrawOrder == 2
188
DrawRect(0, 0, Screen.XSize, Screen.YSize, 0, 0, 0, Object.Alpha)
189
SetDrawListEntityRef(Object.EntityNo, 3, Screen[3].DrawListSize)
190
Screen[3].DrawListSize++
191
Object.DrawOrder = 3
192
else
193
TempValue0 = 0
194
while TempValue0 < 6
195
DrawSpriteXY(TempValue0, Object.LeftCurtainTile, Object.YPos)
196
DrawSpriteFX(TempValue0, FX_FLIP, Object.RightCurtainTile, Object.YPos)
197
TempValue0++
198
loop
199
Object.DrawOrder = 2
200
end if
201
end sub
202
203
204
sub ObjectStartup
205
LoadSpriteSheet("R8/Objects2.gif")
206
207
SpriteFrame(-8, -96, 16, 32, 134, 187) // #0 - Curtain Center Section 1
208
SpriteFrame(-8, -64, 16, 32, 134, 187) // #1 - Curtain Center Section 2
209
SpriteFrame(-8, -32, 16, 32, 134, 187) // #2 - Curtain Center Section 3
210
SpriteFrame(-8, 0, 16, 32, 134, 187) // #3 - Curtain Center Section 4
211
SpriteFrame(-8, 32, 16, 32, 134, 187) // #4 - Curtain Center Section 5
212
SpriteFrame(-8, 64, 16, 32, 134, 187) // #5 - Curtain Center Section 6
213
214
ArrayPos0 = 32
215
while ArrayPos0 < 1056
216
if Object[ArrayPos0].Type == TypeName[Boss Curtain]
217
Object[ArrayPos0].Direction = FACING_LEFT
218
Object[ArrayPos0].DrawOrder = 2
219
Object[ArrayPos0].Alpha = 224
220
221
Object[ArrayPos0].LeftCurtainTile = Object[ArrayPos0].XPos
222
Object[ArrayPos0].LeftCurtainTile -= 0x80000
223
224
Object[ArrayPos0].RightCurtainTile = Object[ArrayPos0].XPos
225
Object[ArrayPos0].RightCurtainTile += 0x80000
226
end if
227
ArrayPos0++
228
loop
229
end sub
230
231
232
// ========================
233
// Editor Subs
234
// ========================
235
236
sub RSDKDraw
237
Object.Direction = FACING_LEFT
238
239
TempValue1 = Object.XPos
240
TempValue1 -= 0x80000
241
TempValue2 = Object.XPos
242
TempValue2 += 0x80000
243
244
TempValue0 = 0
245
while TempValue0 < 6
246
DrawSpriteXY(TempValue0, TempValue1, Object.YPos)
247
DrawSpriteFX(TempValue0, FX_FLIP, TempValue2, Object.YPos)
248
TempValue0++
249
loop
250
Object.DrawOrder = 2
251
end sub
252
253
254
sub RSDKLoad
255
LoadSpriteSheet("R8/Objects2.gif")
256
257
SpriteFrame(-8, -96, 16, 32, 134, 187) // #0 - Curtain Center Section 1
258
SpriteFrame(-8, -64, 16, 32, 134, 187) // #1 - Curtain Center Section 2
259
SpriteFrame(-8, -32, 16, 32, 134, 187) // #2 - Curtain Center Section 3
260
SpriteFrame(-8, 0, 16, 32, 134, 187) // #3 - Curtain Center Section 4
261
SpriteFrame(-8, 32, 16, 32, 134, 187) // #4 - Curtain Center Section 5
262
SpriteFrame(-8, 64, 16, 32, 134, 187) // #5 - Curtain Center Section 6
263
264
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
265
end sub
266
267