Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/VerticalDoor.txt
1319 views
1
//---------------Sonic CD Vertical Door Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.DrawPosY
7
8
// HUD Alias
9
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
10
11
// States
12
#alias 0 : VERTICALDOOR_CLOSED
13
#alias 1 : VERTICALDOOR_START_OPENING
14
#alias 2 : VERTICALDOOR_END_CLOSING
15
#alias 3 : VERTICALDOOR_END_OPENED
16
#alias 4 : VERTICALDOOR_END_CLOSING_METAL
17
#alias 5 : VERTICALDOOR_START_OPENED
18
#alias 6 : VERTICALDOOR_END_CLOSED_SONIC
19
20
// Time Periods
21
#alias 2 : TIME_GOOD_FUTURE
22
23
// Stage SFX
24
#alias 3 : SFX_S_DOORCLOSE
25
26
27
sub ObjectMain
28
switch Object.State
29
case VERTICALDOOR_START_OPENING
30
if Object.DrawPosY < 0x400000
31
Object.DrawPosY += 0x20000
32
Object.YPos -= 0x20000
33
else
34
Object.State = VERTICALDOOR_START_OPENED
35
end if
36
break
37
38
case VERTICALDOOR_END_CLOSING
39
if Object.DrawPosY > 0x00000
40
Object.DrawPosY -= 0x20000
41
Object.YPos += 0x20000
42
else
43
Object.State = VERTICALDOOR_END_CLOSED_SONIC
44
end if
45
break
46
47
case VERTICALDOOR_END_OPENED
48
TempValue0 = Player.CollisionRight
49
TempValue0 += 16
50
TempValue0 <<= 16
51
TempValue0 += Object.XPos
52
if Player.XPos > TempValue0
53
// The Player is past the door, meaning Sonic's won
54
55
#platform: Use_Origins
56
// There can only be one, let the game know we've killed Metal Sonic
57
// -> This doesn't really seem to do much, the NOTIFY_BOSS_END is what triggers all the fancy screens and such
58
EngineCallback(NOTIFY_KILL_BOSS)
59
#endplatform
60
61
// From here, do the standard closing routine
62
Object.State = VERTICALDOOR_END_CLOSING
63
PlayStageSfx(SFX_S_DOORCLOSE, false)
64
else
65
if Object[+2].XPos > Object.XPos
66
// If Metal Sonic is past the door
67
Object.State = VERTICALDOOR_END_CLOSING_METAL
68
PlayStageSfx(SFX_S_DOORCLOSE, false)
69
end if
70
end if
71
break
72
73
case VERTICALDOOR_END_CLOSING_METAL
74
if Object.DrawPosY > 0x00000
75
Object.DrawPosY -= 0x20000
76
Object.YPos += 0x20000
77
end if
78
break
79
80
end switch
81
82
end sub
83
84
85
sub ObjectPlayerInteraction
86
87
switch Object.State
88
case VERTICALDOOR_CLOSED
89
// Act as a tall vertical wall
90
PlayerObjectCollision(C_BOX, -16, -32, 16, 64)
91
break
92
93
case VERTICALDOOR_START_OPENING
94
case VERTICALDOOR_START_OPENED
95
// Acting as a comparatively shorter wall (it's still pretty tall though!)
96
PlayerObjectCollision(C_BOX, -16, -32, 16, 32)
97
break
98
99
case VERTICALDOOR_END_CLOSING
100
case VERTICALDOOR_END_CLOSED_SONIC
101
// Acting as a *really* tall vertical wall
102
PlayerObjectCollision(C_BOX, -16, -32, 16, 128)
103
104
// Enforce right bounds, make sure the player doesn't leave where they should be
105
TempValue0 = Player.CollisionRight
106
TempValue0 <<= 16
107
TempValue0 += Player.XPos
108
TempValue1 = Stage.XBoundary2
109
TempValue1 <<= 16
110
if TempValue0 > TempValue1
111
Player.XVelocity = 0
112
Player.Speed = 0
113
Player.XPos = TempValue1
114
TempValue0 = Player.CollisionRight
115
TempValue0 <<= 16
116
Player.XPos -= TempValue0
117
end if
118
break
119
120
case VERTICALDOOR_END_OPENED
121
// Somewhat tall vertical wall
122
PlayerObjectCollision(C_BOX, -16, -32, 16, 32)
123
124
// And enforce right bounds here too
125
TempValue0 = Player.CollisionRight
126
TempValue0 <<= 16
127
TempValue0 += Player.XPos
128
TempValue1 = Stage.XBoundary2
129
TempValue1 <<= 16
130
if TempValue0 > TempValue1
131
Player.XVelocity = 0
132
Player.Speed = 0
133
Player.XPos = TempValue1
134
TempValue0 = Player.CollisionRight
135
TempValue0 <<= 16
136
Player.XPos -= TempValue0
137
end if
138
break
139
140
case VERTICALDOOR_END_CLOSING_METAL
141
// Only enforcing right bounds, no need for collision checks anymore
142
TempValue0 = Player.CollisionRight
143
TempValue0 <<= 16
144
TempValue0 += Player.XPos
145
TempValue1 = Object.XPos
146
TempValue1 -= 0x100000
147
if TempValue0 > TempValue1
148
Player.XVelocity = 0
149
Player.Speed = 0
150
Player.XPos = TempValue1
151
TempValue0 = Player.CollisionRight
152
TempValue0 <<= 16
153
Player.XPos -= TempValue0
154
end if
155
break
156
157
end switch
158
159
end sub
160
161
162
sub ObjectDraw
163
164
// Draw the extension sprite
165
TempValue0 = Object.DrawPosY
166
TempValue0 >>= 1
167
TempValue0 += Object.YPos
168
DrawSpriteXY(0, Object.XPos, TempValue0)
169
170
// Draw the base sprite
171
DrawSprite(1)
172
173
end sub
174
175
176
sub ObjectStartup
177
178
LoadSpriteSheet("R7/Objects.gif")
179
180
// Good future gets different sprites from other time periods
181
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
182
SpriteFrame(-16, -32, 32, 32, 117, 219)
183
SpriteFrame(-16, 0, 32, 32, 117, 219)
184
else
185
SpriteFrame(-16, -32, 32, 32, 1, 1)
186
SpriteFrame(-16, 0, 32, 32, 1, 1)
187
end if
188
189
end sub
190
191
192
// ========================
193
// Editor Subs
194
// ========================
195
196
sub RSDKDraw
197
DrawSprite(0)
198
DrawSprite(1)
199
end sub
200
201
202
sub RSDKLoad
203
LoadSpriteSheet("R7/Objects.gif")
204
SpriteFrame(-16, 0, 32, 32, 1, 1) // Sticking with the normal variant here...
205
SpriteFrame(-16, -32, 32, 32, 1, 1)
206
207
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
208
end sub
209
210