Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/CollisionM093.txt
1319 views
1
//---------------Sonic CD Collision M093 Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//--------------Used on Mission "M093 - Fast Foes"------------//
5
6
// Aliases
7
// Used in general by all badniks
8
#alias Object.Value0 : Badnik.Timer
9
#alias Object.Direction : Badnik.Direction
10
#alias Object.State : Badnik.State
11
12
// Used by NoroNoro and Sasuri
13
#alias Object.Value2 : Badnik.SavedTimer
14
15
// Used by KumoKumo and KumoKumo2
16
#alias Object.YPos : Badnik.YPos
17
#alias Object.Value1 : Badnik.YVelocity
18
#alias Object.DrawOrder : Badnik.DrawOrder
19
#alias Object.PropertyValue : Badnik.Quality
20
#alias Object.Frame : Badnik.Frame
21
22
// Mission Block Alias
23
#alias Object.PropertyValue : Object.BlocksNo
24
25
// Badniks
26
#alias 53 : TYPE_NORONORO
27
#alias 54 : TYPE_SASURI
28
#alias 57 : TYPE_KUMOKUMO
29
#alias 76 : TYPE_KUMOKUMO2
30
31
// NoroNoro and Sasuri States
32
#alias 0 : BADNIK_FINDGROUND // Good thing both NoroNoro and Sasuri uses this
33
#alias 1 : BADNIK_MOVELEFT // CrawlLeft for Sasuri, RollLeft for NoroNoro
34
#alias 2 : BADNIK_MOVERIGHT // CrawlRight for Sasuri, RollRight for NoroNoro
35
36
// KumoKumo States
37
#alias 0 : KUMOKUMO_AIRBORNE
38
#alias 1 : KUMOKUMO_GOOD_GROUND
39
#alias 2 : KUMOKUMO_BAD_GROUND
40
41
// Badnik Quality / Property Values
42
#alias 0 : GOOD_QUALITY
43
#alias 1 : BAD_QUALITY
44
45
// Priority
46
#alias 1 : PRIORITY_ACTIVE
47
48
49
sub ObjectMain
50
51
// This object fakes collision between Mission Blocks and Quartz Quadrant Badniks
52
// specifically for Mission 093, 'Fast Foes'.
53
// However, none of the badniks present in the level touches a mission block at any point
54
// that, along with the fact that Sasuri is present here despite never appearing in the level
55
// makes me think that the layout of the level was totally different when this object was made
56
// maybe starting from the middle of the level instead of the beginning?
57
58
ArrayPos0 = 32
59
while ArrayPos0 < 1056
60
CheckResult = false
61
switch Object[ArrayPos0].Type
62
case TYPE_NORONORO
63
case TYPE_SASURI
64
case TYPE_KUMOKUMO
65
case TYPE_KUMOKUMO2
66
CheckResult = true
67
break
68
69
end switch
70
71
if CheckResult == true
72
ArrayPos1 = 32
73
Object.XPos = Object[ArrayPos0].XPos
74
Object.XPos >>= 16
75
Object.YPos = Object[ArrayPos0].YPos
76
Object.YPos >>= 16
77
else
78
ArrayPos1 = 2000
79
end if
80
81
while ArrayPos1 < 1056
82
if Object[ArrayPos1].Type == TypeName[MissionBlock]
83
if Object[ArrayPos1].BlocksNo <= 1
84
TempValue3 = -16
85
else
86
TempValue3 = -32
87
TempValue3 *= Object[ArrayPos1].PropertyValue
88
TempValue3 += 16
89
end if
90
91
TempValue4 = 16
92
93
TempValue0 = Object[ArrayPos1].XPos
94
TempValue0 >>= 16
95
TempValue0 -= Object.XPos
96
CheckGreater(TempValue0, TempValue3)
97
TempValue1 = CheckResult
98
CheckLower(TempValue0, TempValue4)
99
TempValue1 &= CheckResult
100
if TempValue1 == true
101
TempValue2 = Object[ArrayPos1].YPos
102
TempValue2 >>= 16
103
104
TempValue1 = Object.YPos
105
TempValue1 += 16
106
107
TempValue2 -= TempValue1
108
CheckGreater(TempValue2, -16)
109
TempValue1 = CheckResult
110
CheckLower(TempValue2 ,15)
111
TempValue1 &= CheckResult
112
if TempValue1 == true
113
Object.YPos = Object[ArrayPos1].YPos
114
Object.YPos >>= 16
115
Object.YPos -= 32
116
117
Object[ArrayPos0].YPos = Object.YPos
118
Object[ArrayPos0].YPos <<= 16
119
120
TempValue2 = 16
121
end if
122
123
if TempValue2 == 16
124
switch Object[ArrayPos0].Type
125
case TYPE_NORONORO
126
case TYPE_SASURI
127
Badnik[ArrayPos0].Timer = Badnik[ArrayPos0].SavedTimer
128
switch Badnik[ArrayPos0].State
129
case BADNIK_FINDGROUND
130
Badnik[ArrayPos0].State = BADNIK_MOVELEFT
131
break
132
133
case BADNIK_MOVELEFT
134
TempValue5 = TempValue3
135
TempValue5 += 4
136
if TempValue0 > TempValue5
137
Badnik[ArrayPos0].Timer++
138
if Badnik[ArrayPos0].Timer != 320
139
Badnik[ArrayPos0].State = BADNIK_MOVERIGHT
140
Badnik[ArrayPos0].Direction = FACING_LEFT
141
end if
142
end if
143
break
144
145
case BADNIK_MOVERIGHT
146
TempValue5 = TempValue4
147
TempValue5 -= 4
148
if TempValue0 < TempValue5
149
Badnik[ArrayPos0].Timer--
150
if Badnik[ArrayPos0].Timer != -320
151
Object[ArrayPos0].State = BADNIK_MOVELEFT
152
Object[ArrayPos0].Direction = FACING_RIGHT
153
end if
154
end if
155
break
156
end switch
157
158
Badnik[ArrayPos0].SavedTimer = Badnik[ArrayPos0].Timer
159
break
160
161
case TYPE_KUMOKUMO
162
case TYPE_KUMOKUMO2
163
if Badnik[ArrayPos0].State == KUMOKUMO_AIRBORNE
164
if Badnik[ArrayPos0].YVelocity > 0
165
Badnik[ArrayPos0].YPos += 0x80000
166
Badnik[ArrayPos0].Frame = 0
167
Badnik[ArrayPos0].DrawOrder = 3
168
if Badnik[ArrayPos0].Quality == GOOD_QUALITY
169
Badnik[ArrayPos0].State = KUMOKUMO_GOOD_GROUND
170
else
171
Badnik[ArrayPos0].State = KUMOKUMO_BAD_GROUND
172
Badnik[ArrayPos0].Direction = FACING_LEFT
173
end if
174
end if
175
end if
176
break
177
end switch
178
end if
179
end if
180
end if
181
ArrayPos1++
182
loop
183
ArrayPos0++
184
loop
185
end sub
186
187
188
sub ObjectStartup
189
ArrayPos0 = 32
190
while ArrayPos0 < 1056
191
if Object[ArrayPos0].Type == TypeName[CollisionM093]
192
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
193
end if
194
ArrayPos0++
195
loop
196
end sub
197
198
199
// ========================
200
// Editor Subs
201
// ========================
202
203
sub RSDKDraw
204
DrawSprite(0)
205
end sub
206
207
208
sub RSDKLoad
209
LoadSpriteSheet("Global/Display.gif")
210
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
211
212
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
213
end sub
214
215
216
217