Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/KumoKumo2.txt
1319 views
1
//----------------Sonic CD KumoKumo 2 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
#alias Object.Value0 : Object.Timer
8
#alias Object.Value1 : Object.YVelocity
9
10
#alias Object.PropertyValue : Object.Quality
11
12
// Kumo Kumo Web Aliases
13
#alias Object.Value1 : Object.XVelocity
14
15
// States
16
#alias 0 : KUMOKUMO2_AIRBORNE
17
18
// Different Ground States for the different conditions a Kumo Kumo can come in
19
#alias 1 : KUMOKUMO2_GOOD_GROUND
20
#alias 2 : KUMOKUMO2_BAD_GROUND
21
22
#alias 3 : KUMOKUMO2_SHOOT
23
24
// Badnik Quality / Property Values
25
#alias 0 : GOOD_QUALITY
26
#alias 1 : BAD_QUALITY
27
28
// SFX Aliases
29
#alias 2 : SFX_S_SHOT
30
31
// Collision Sides
32
#alias 0 : CSIDE_FLOOR
33
34
35
sub ObjectMain
36
37
switch Object.State
38
case KUMOKUMO2_AIRBORNE
39
// This Airborne State isn't only for after jumping, but it's also what a Kumo Kumo spawns with to align it to the ground
40
41
// Apply a Gravity of 0.25 pixels per frame
42
TempValue0 = 0x4000
43
TempValue0 *= 4
44
Object.YVelocity += TempValue0
45
46
TempValue0 = Object.YVelocity
47
TempValue0 *= 4
48
Object.YPos += TempValue0
49
50
// Only check for ground collisions when going downards
51
if Object.YVelocity > 0
52
ObjectTileCollision(CSIDE_FLOOR, 0, 24, 0)
53
54
if CheckResult == true
55
// The Kumo Kumo has touched the ground, make it land
56
57
// Move the Kumo Kumo 8 pixels down
58
Object.YPos += 0x80000
59
60
Object.Frame = 0
61
62
// Move the Kumo Kumo back to its normal Draw Order
63
// (In most cases this won't change anything, but for Good Kumo Kumos, this restores them after they launch a web)
64
Object.DrawOrder = 3
65
66
if Object.Quality == GOOD_QUALITY
67
Object.State = KUMOKUMO2_GOOD_GROUND
68
else
69
Object.State = KUMOKUMO2_BAD_GROUND
70
Object.Direction = FACING_LEFT
71
end if
72
end if
73
end if
74
break
75
76
case KUMOKUMO2_GOOD_GROUND
77
if Object.Timer < 45
78
// Pausing before the big jump...
79
80
Object.Timer++
81
Object.Frame++
82
Object.Frame &= 3
83
else
84
// Make the Kumo Kumo jump
85
86
// Move the Kumo Kumo 8 pixels up
87
Object.YPos -= 0x80000
88
89
Object.Timer = 0
90
91
// The Kumo Kumo's Velocity will be 8 pixels upwards as well
92
Object.YVelocity = -0x80000
93
94
Object.YPos += Object.YVelocity
95
Object.YVelocity += 0x4000
96
97
Object.State = KUMOKUMO2_AIRBORNE
98
end if
99
break
100
101
case KUMOKUMO2_BAD_GROUND
102
if Object.Timer < 45
103
// Getting ready for a jump...
104
// Unlike a good Kumo Kumo, Bad Kumo Kumos have a rather slow animation speed when getting ready
105
106
Object.Timer++
107
Object.Frame++
108
Object.Frame &= 7
109
else
110
// Make the Kumo Kumo jump
111
// However, Bad Kumo Kumos jump lower than Good Kumo Kumos
112
113
// Move the Kumo Kumo 8 pixels up
114
Object.YPos -= 0x80000
115
116
Object.Timer = 0
117
118
// Since this is a bad Kumo Kumo, it gets a velocity of 5 pixels per frame rather than the Good variant's 8
119
Object.YVelocity = -0x50000
120
Object.YPos += Object.YVelocity
121
122
Object.State = KUMOKUMO2_AIRBORNE
123
end if
124
break
125
126
case KUMOKUMO2_SHOOT
127
if Object.Timer < 16
128
Object.Timer++
129
else
130
// Launch the web!
131
132
// Create the Web Object, notably as a temp object meaning it'll be near the end of the Object List
133
CreateTempObject(TypeName[Kumo Kumo Web], 0, Object.XPos, Object.YPos)
134
135
// Give the Web a high draw order, as it should draw above the Player
136
Object[TempObjectPos].DrawOrder = 4
137
138
// Set its starting movement properties
139
if Object.Direction == FACING_RIGHT
140
Object[TempObjectPos].XPos += 0x80000
141
Object[TempObjectPos].XVelocity = 0x30000
142
else
143
Object[TempObjectPos].XPos -= 0x80000
144
Object[TempObjectPos].XVelocity = -0x30000
145
end if
146
147
// And then make the Kumo Kumo jump
148
149
// First, move it 8px up
150
Object.YPos -= 0x80000
151
152
Object.Timer = 0
153
154
// Its Velocity should be 8 pixels upwards per frame, as well
155
Object.YVelocity = -0x80000
156
Object.YPos += Object.YVelocity
157
158
// But apply a small starting Gravity of 0.25 pixels, too
159
Object.YVelocity += 0x4000
160
161
Object.State = KUMOKUMO2_AIRBORNE
162
163
// Give the Kumo Kumo a high draw order, to make it match with its shot Web
164
Object.DrawOrder = 4
165
166
PlayStageSfx(SFX_S_SHOT, false)
167
end if
168
break
169
170
end switch
171
172
// Check to see if the Kumo Kumo should become a Flower
173
CallFunction(StageSetup_CheckGoodFuture)
174
175
end sub
176
177
178
sub ObjectPlayerInteraction
179
// Check collision for the main Badnik
180
PlayerObjectCollision(C_ENEMY, -24, -16, 24, 16)
181
if CheckResult == true
182
CallFunction(Player_BadnikBreak)
183
end if
184
185
// Only Good Badniks are able to shoot, and they have to be on the ground too
186
if Object.State == KUMOKUMO2_GOOD_GROUND
187
188
// Based on the Kumo Kumo's direction, check to see if the Player's walked in front of it
189
if Object.Direction == FACING_RIGHT
190
PlayerObjectCollision(C_TOUCH, -64, -32, 0, 16)
191
192
if CheckResult == true
193
// The Player's stepped into range, turn around and shoot!
194
195
Object.Direction = FACING_LEFT
196
Object.State = KUMOKUMO2_SHOOT
197
Object.Frame = 0
198
Object.Timer = 0
199
end if
200
else
201
PlayerObjectCollision(C_TOUCH, 0, -32, 64, 16)
202
203
if CheckResult == true
204
// The Player is within range, start the shooting process
205
206
Object.Direction = FACING_RIGHT
207
Object.State = KUMOKUMO2_SHOOT
208
Object.Frame = 0
209
Object.Timer = 0
210
end if
211
end if
212
end if
213
end sub
214
215
216
sub ObjectDraw
217
218
switch Object.State
219
case KUMOKUMO2_AIRBORNE
220
if Object.Quality == GOOD_QUALITY
221
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
222
else
223
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
224
end if
225
break
226
227
case KUMOKUMO2_GOOD_GROUND
228
TempValue0 = Object.Frame
229
TempValue0 >>= 1
230
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
231
break
232
233
case KUMOKUMO2_BAD_GROUND
234
TempValue0 = Object.Frame
235
TempValue0 >>= 2
236
TempValue0 += 3
237
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
238
break
239
240
case KUMOKUMO2_SHOOT
241
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
242
break
243
244
end switch
245
246
end sub
247
248
249
sub ObjectStartup
250
251
LoadSpriteSheet("R5/Objects.gif")
252
253
SpriteFrame(-28, -20, 56, 36, 199, 1)
254
SpriteFrame(-28, -16, 56, 32, 199, 38)
255
SpriteFrame(-28, -28, 56, 52, 142, 1)
256
SpriteFrame(-28, -20, 56, 36, 199, 71)
257
SpriteFrame(-28, -16, 56, 32, 199, 108)
258
SpriteFrame(-28, -28, 56, 52, 142, 54)
259
260
end sub
261
262
263
// ========================
264
// Editor Subs
265
// ========================
266
267
sub RSDKEdit
268
if Editor.ReturnVariable == true
269
switch Editor.VariableID
270
case EDIT_VAR_PROPVAL // Property Value
271
CheckResult = Object.PropertyValue
272
break
273
case 0 // Condition
274
CheckResult = Object.PropertyValue
275
break
276
end switch
277
else
278
switch Editor.VariableID
279
case EDIT_VAR_PROPVAL // Property Value
280
Object.PropertyValue = Editor.VariableValue
281
break
282
case 0 // Condition
283
Object.PropertyValue = Editor.VariableValue
284
break
285
end switch
286
end if
287
end sub
288
289
290
sub RSDKDraw
291
DrawSprite(Object.PropertyValue)
292
end sub
293
294
295
sub RSDKLoad
296
LoadSpriteSheet("R5/Objects.gif")
297
298
// Kumo Kumo Frames
299
300
// Good Standing Frame
301
SpriteFrame(-28, -20, 56, 36, 199, 1)
302
303
// Bad Standing Frame
304
SpriteFrame(-28, -20, 56, 36, 199, 71)
305
306
AddEditorVariable("Condition")
307
SetActiveVariable("Condition")
308
AddEnumVariable("Good", GOOD_QUALITY)
309
AddEnumVariable("Bad", BAD_QUALITY)
310
end sub
311
312
313
314