Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/CLedge3.txt
1319 views
1
//---------------Sonic CD Crumble Ledge 3 Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.HitboxLeft
7
#alias Object.Value1 : Object.HitboxRight
8
#alias Object.Value2 : Object.Timer
9
#alias Object.Value3 : Object.Length
10
#alias Object.Value4 : Object.YVelocity
11
12
// States
13
#alias 0 : CLEDGE3_IDLE
14
#alias 1 : CLEDGE3_DELAY_FROM_RIGHT
15
#alias 2 : CLEDGE3_DELAY_FROM_LEFT
16
#alias 3 : CLEDGE3_COLLAPSE_RIGHT
17
#alias 4 : CLEDGE3_COLLAPSE_LEFT
18
#alias 5 : CLEDGE3_RESTORE // Unused
19
20
#alias 6 : CLEDGE3_DEBRIS
21
22
// Stage SFX
23
#alias 0 : SFX_S_CRUMBLE
24
25
// Priority
26
#alias 0 : PRIORITY_BOUNDS
27
#alias 1 : PRIORITY_ACTIVE
28
29
30
sub ObjectMain
31
switch Object.State
32
case CLEDGE3_DELAY_FROM_RIGHT
33
if Object.Timer > 0
34
Object.Timer--
35
else
36
PlayStageSfx(SFX_S_CRUMBLE, false)
37
Object.State = CLEDGE3_COLLAPSE_RIGHT
38
end if
39
break
40
41
case CLEDGE3_DELAY_FROM_LEFT
42
if Object.Timer > 0
43
Object.Timer--
44
else
45
PlayStageSfx(SFX_S_CRUMBLE, false)
46
Object.State = CLEDGE3_COLLAPSE_LEFT
47
end if
48
break
49
50
case CLEDGE3_COLLAPSE_RIGHT
51
Object.Timer++
52
if Object.Timer == 12
53
Object.Timer = 0
54
if Object.HitboxRight > Object.HitboxLeft
55
Object.Length--
56
Object.HitboxRight -= 16
57
TempValue0 = Object.HitboxRight
58
TempValue0 += 8
59
TempValue0 <<= 16
60
TempValue0 += Object.XPos
61
CreateTempObject(TypeName[Crumble Ledge 3], 0, TempValue0, Object.YPos)
62
Object[TempObjectPos].State = CLEDGE3_DEBRIS
63
else
64
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
65
end if
66
end if
67
break
68
69
case CLEDGE3_COLLAPSE_LEFT
70
Object.Timer++
71
if Object.Timer == 12
72
73
Object.Timer = 0
74
if Object.HitboxLeft < Object.HitboxRight
75
Object.Length--
76
77
Object.HitboxLeft += 16
78
TempValue0 = Object.HitboxLeft
79
TempValue0 -= 8
80
TempValue0 <<= 16
81
TempValue0 += Object.XPos
82
83
CreateTempObject(TypeName[Crumble Ledge 3], 0, TempValue0, Object.YPos)
84
Object[TempObjectPos].State = CLEDGE3_DEBRIS
85
else
86
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
87
end if
88
89
end if
90
break
91
92
case CLEDGE3_RESTORE
93
if Object.OutOfBounds == true
94
Object.State = CLEDGE3_IDLE
95
Object.Length = Object.PropertyValue
96
97
Object.HitboxLeft = Object.PropertyValue
98
Object.HitboxLeft <<= 3
99
100
Object.HitboxRight = Object.HitboxLeft
101
FlipSign(Object.HitboxLeft)
102
103
Object.Priority = PRIORITY_BOUNDS
104
Object.Timer = 0
105
end if
106
break
107
108
case CLEDGE3_DEBRIS
109
Object.YVelocity += 0x4000
110
if Object.YVelocity > 0
111
Object.YPos += Object.YVelocity
112
end if
113
114
if Object.OutOfBounds == true
115
Object.Type = TypeName[Blank Object]
116
end if
117
break
118
119
end switch
120
end sub
121
122
123
sub ObjectPlayerInteraction
124
if Object.State == CLEDGE3_IDLE
125
PlayerObjectCollision(C_PLATFORM, Object.HitboxLeft, -17, Object.HitboxRight, 16)
126
if CheckResult == true
127
Object.Timer = 1
128
Object.Priority = PRIORITY_ACTIVE
129
if Player.XPos > Object.XPos
130
Object.State = CLEDGE3_DELAY_FROM_RIGHT
131
else
132
Object.State = CLEDGE3_DELAY_FROM_LEFT
133
end if
134
end if
135
else
136
PlayerObjectCollision(C_PLATFORM, Object.HitboxLeft, -17, Object.HitboxRight, 16)
137
end if
138
end sub
139
140
141
sub ObjectDraw
142
switch Object.State
143
case CLEDGE3_IDLE
144
case CLEDGE3_DELAY_FROM_RIGHT
145
case CLEDGE3_DELAY_FROM_LEFT
146
case CLEDGE3_COLLAPSE_RIGHT
147
TempValue0 = 0
148
TempValue1 = Object.HitboxLeft
149
TempValue1 <<= 16
150
TempValue1 += 0x80000
151
TempValue1 += Object.XPos
152
while TempValue0 < Object.Length
153
DrawSpriteXY(0, TempValue1, Object.YPos)
154
TempValue0++
155
TempValue1 += 0x100000
156
loop
157
break
158
159
case CLEDGE3_COLLAPSE_LEFT
160
TempValue0 = 0
161
TempValue1 = Object.HitboxRight
162
TempValue1 <<= 16
163
TempValue1 -= 0x80000
164
TempValue1 += Object.XPos
165
while TempValue0 < Object.Length
166
DrawSpriteXY(0, TempValue1, Object.YPos)
167
TempValue0++
168
TempValue1 -= 0x100000
169
loop
170
break
171
172
case CLEDGE3_DEBRIS
173
DrawSprite(Object.Frame)
174
break
175
end switch
176
end sub
177
178
179
sub ObjectStartup
180
LoadSpriteSheet("R1/Objects2.gif")
181
182
SpriteFrame(-8, -32, 16, 48, 163, 1) // #0 - Ledge
183
184
// Used to be below LoadSpriteSheet, moved here for consistency
185
ArrayPos0 = 32
186
while ArrayPos0 < 1056
187
if Object[ArrayPos0].Type == TypeName[Crumble Ledge 3]
188
Object[ArrayPos0].Length = Object[ArrayPos0].PropertyValue
189
Object[ArrayPos0].HitboxLeft = Object[ArrayPos0].PropertyValue
190
Object[ArrayPos0].HitboxLeft <<= 3
191
Object[ArrayPos0].HitboxRight = Object[ArrayPos0].HitboxLeft
192
FlipSign(Object[ArrayPos0].HitboxLeft)
193
end if
194
ArrayPos0++
195
loop
196
end sub
197
198
199
// ========================
200
// Editor Subs
201
// ========================
202
203
sub RSDKDraw
204
Object.Length = Object.PropertyValue
205
Object.HitboxLeft = Object.PropertyValue
206
Object.HitboxLeft <<= 3
207
Object.HitboxRight = Object.HitboxLeft
208
FlipSign(Object.HitboxLeft)
209
210
TempValue0 = 0
211
TempValue1 = Object.HitboxLeft
212
TempValue1 <<= 16
213
TempValue1 += 0x80000
214
TempValue1 += Object.XPos
215
while TempValue0 < Object.Length
216
DrawSpriteXY(0, TempValue1, Object.YPos)
217
TempValue0++
218
TempValue1 += 0x100000
219
loop
220
end sub
221
222
223
sub RSDKLoad
224
LoadSpriteSheet("R1/Objects2.gif")
225
226
SpriteFrame(-8, -32, 16, 48, 163, 1) // #0 - Ledge
227
228
SetVariableAlias(ALIAS_VAR_PROPVAL, "length")
229
end sub
230
231