Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/CLedge2.txt
1319 views
1
//---------------Sonic CD Crumble Ledge 2 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.YVelocity
8
9
// States
10
#alias 0 : CLEDGE2_IDLE
11
#alias 1 : CLEDGE2_DEBRIS
12
#alias 2 : CLEDGE2_RESTORE // Unused
13
14
// Stage SFX
15
#alias 0 : SFX_S_CRUMBLE
16
17
// Priority
18
#alias 0 : PRIORITY_BOUNDS
19
20
21
sub ObjectMain
22
switch Object.State
23
case CLEDGE2_DEBRIS
24
if Object.Timer > 0
25
Object.Timer--
26
else
27
Object.YVelocity += 0x5000
28
Object.YPos += Object.YVelocity
29
end if
30
if Object.OutOfBounds == true
31
Object.Type = TypeName[Blank Object]
32
end if
33
break
34
35
case CLEDGE2_RESTORE
36
37
if Object.OutOfBounds == true
38
Object.State = CLEDGE2_IDLE
39
Object.Priority = PRIORITY_BOUNDS
40
end if
41
42
break
43
end switch
44
end sub
45
46
47
sub ObjectPlayerInteraction
48
switch Object.PropertyValue
49
case 0
50
if Object.State == CLEDGE2_IDLE
51
PlayerObjectCollision(C_PLATFORM, -40, -24, 40, -8)
52
if CheckResult == true
53
Object.Priority = PRIORITY_BOUNDS
54
Object.Type = TypeName[Blank Object]
55
// TempValue0 : Debris chunk value
56
// TempValue1 : Ledge section value
57
// TempValue2 : Debris for ledge section
58
// TempValue3 : Fall Timer
59
// TempValue4 : XPos
60
// TempValue5 : YPos
61
TempValue0 = 1
62
TempValue1 = 0
63
TempValue4 = Object.XPos
64
TempValue4 -= 0x200000
65
while TempValue1 < 5
66
TempValue2 = 0
67
TempValue5 = Object.YPos
68
TempValue5 += 0x200000
69
switch TempValue1
70
case 0
71
TempValue3 = 58
72
break
73
case 1
74
TempValue3 = 46
75
break
76
case 2
77
TempValue3 = 34
78
break
79
case 3
80
TempValue3 = 27
81
break
82
case 4
83
TempValue3 = 10
84
break
85
end switch
86
87
while TempValue2 < 5
88
CreateTempObject(TypeName[Crumble Ledge 2], TempValue0, TempValue4, TempValue5)
89
Object[TempObjectPos].Timer = TempValue3
90
Object[TempObjectPos].State = CLEDGE2_DEBRIS
91
TempValue3 += 5
92
TempValue0++
93
TempValue2++
94
TempValue5 -= 0x100000
95
loop
96
97
TempValue3 -= 8
98
TempValue1++
99
TempValue4 += 0x100000
100
loop
101
PlayStageSfx(SFX_S_CRUMBLE, false)
102
end if
103
end if
104
break
105
// The five debris chunks at the very top retains collision
106
case 4
107
case 9
108
case 14
109
case 19
110
case 24
111
if Object.Timer > 0
112
PlayerObjectCollision(C_PLATFORM, -8, -8, 8, 8)
113
end if
114
break
115
116
end switch
117
end sub
118
119
120
sub ObjectDraw
121
if Object.State < CLEDGE2_RESTORE
122
DrawSprite(Object.PropertyValue)
123
end if
124
end sub
125
126
127
sub ObjectStartup
128
LoadSpriteSheet("R1/Objects2.gif")
129
130
SpriteFrame(-40, -40, 80, 80, 82, 1) // #0 - Ledge
131
132
// Debris chunks
133
TempValue1 = 82
134
while TempValue1 < 162
135
TempValue0 = 65
136
while TempValue0 > 0
137
SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue0)
138
TempValue0 -= 16
139
loop
140
TempValue1 += 16
141
loop
142
end sub
143
144
145
// ========================
146
// Editor Subs
147
// ========================
148
149
sub RSDKDraw
150
DrawSprite(0)
151
end sub
152
153
154
sub RSDKLoad
155
LoadSpriteSheet("R1/Objects2.gif")
156
157
SpriteFrame(-40, -40, 80, 80, 82, 1) // #0 - Ledge
158
159
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
160
end sub
161
162