Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/KamaKama.txt
1319 views
1
//-----------------Sonic CD Kama Kama 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.FrameTimer
8
#alias Object.Value2 : Object.XVelocity
9
#alias Object.Value3 : Object.XOriginPos
10
#alias Object.Value4 : Object.YOriginPos
11
12
#alias Object.PropertyValue : Object.Quality
13
14
// Blade Aliases
15
#alias Object.Value2 : Object.KamaKamaEntityNo
16
17
// States
18
#alias 0 : KAMAKAMA_GUARD
19
#alias 1 : KAMAKAMA_LAUNCH_BLADE
20
#alias 2 : KAMAKAMA_PREPARE_CHARGE
21
#alias 3 : KAMAKAMA_CHARGE
22
#alias 4 : KAMAKAMA_SWITCH_DIRECTION
23
24
// Collision Sides
25
#alias 0 : CSIDE_FLOOR
26
27
// Badnik Quality / Property Values
28
#alias 0 : GOOD_QUALITY
29
#alias 1 : BAD_QUALITY
30
31
// Priority
32
#alias 0 : PRIORITY_BOUNDS
33
#alias 1 : PRIORITY_ACTIVE
34
35
36
sub ObjectMain
37
Object.FrameTimer++
38
Object.FrameTimer &= 15
39
switch Object.State
40
case KAMAKAMA_GUARD
41
ObjectTileGrip(CSIDE_FLOOR, 0, 19, 0)
42
if Object.XPos > Player.XPos
43
Object.Direction = FACING_RIGHT
44
else
45
Object.Direction = FACING_LEFT
46
end if
47
48
PlayerObjectCollision(C_TOUCH, -96, -48, 96, 48)
49
if CheckResult == true
50
Object.State = KAMAKAMA_LAUNCH_BLADE
51
Object.Priority = PRIORITY_ACTIVE
52
if Object.Quality == GOOD_QUALITY // Only badniks in a good state still have blades to throw
53
CreateTempObject(TypeName[Kama Kama Blade], 24, Object.XPos, Object.YPos)
54
Object[TempObjectPos].Direction = Object.Direction
55
Object[TempObjectPos].iYPos -= 6
56
Object[TempObjectPos].KamaKamaEntityNo = Object.EntityNo
57
58
if Object.Direction == FACING_RIGHT
59
Object[TempObjectPos].iXPos -= 8
60
else
61
Object[TempObjectPos].iXPos += 8
62
end if
63
CreateTempObject(TypeName[Kama Kama Blade], 56, Object.XPos, Object.YPos)
64
Object[TempObjectPos].Direction = Object.Direction
65
Object[TempObjectPos].iYPos -= 4
66
Object[TempObjectPos].KamaKamaEntityNo = Object.EntityNo
67
68
if Object.Direction == FACING_RIGHT
69
Object[TempObjectPos].iXPos -= 16
70
else
71
Object[TempObjectPos].iXPos += 16
72
end if
73
74
end if
75
76
end if
77
break
78
79
case KAMAKAMA_LAUNCH_BLADE
80
if Object.Timer < 110
81
Object.Timer++
82
else
83
Object.State = KAMAKAMA_PREPARE_CHARGE
84
Object.Timer = 0
85
end if
86
break
87
88
case KAMAKAMA_PREPARE_CHARGE
89
if Object.Timer < 48
90
Object.Timer++
91
else
92
Object.State = KAMAKAMA_CHARGE
93
Object.Timer = 0
94
Object.Frame = 0
95
if Object.Direction == FACING_RIGHT
96
Object.XVelocity = -0x10000
97
else
98
Object.XVelocity = 0x10000
99
end if
100
if Object.Quality > 0
101
Object.XVelocity >>= 1
102
end if
103
end if
104
break
105
106
case KAMAKAMA_CHARGE
107
Object.Frame++
108
Object.Frame &= 31
109
110
Object.XPos += Object.XVelocity
111
ObjectTileGrip(CSIDE_FLOOR, 0, 19, 0) // Check if it's reaching a ledge
112
if CheckResult == false
113
Object.State = KAMAKAMA_SWITCH_DIRECTION
114
Object.Timer = 60
115
end if
116
break
117
118
case KAMAKAMA_SWITCH_DIRECTION
119
Object.Frame++
120
Object.Frame &= 31
121
if Object.Timer > 0
122
Object.Timer--
123
else
124
Object.State = KAMAKAMA_CHARGE
125
FlipSign(Object.XVelocity)
126
if Object.Direction == FACING_RIGHT
127
Object.Direction = FACING_LEFT
128
else
129
Object.Direction = FACING_RIGHT
130
end if
131
132
end if
133
break
134
135
end switch
136
137
// Reset object when out of bounds
138
if Object.OutOfBounds == true
139
Object.Priority = PRIORITY_BOUNDS
140
141
Object.State = KAMAKAMA_GUARD
142
143
Object.Timer = 0
144
Object.FrameTimer = 0
145
Object.Frame = 0
146
147
Object.XPos = Object.XOriginPos
148
Object.YPos = Object.YOriginPos
149
end if
150
151
CallFunction(StageSetup_CheckGoodFuture) // Check if it should be a flower
152
end sub
153
154
155
sub ObjectPlayerInteraction
156
#platform: Use_Standalone
157
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 20)
158
#endplatform
159
#platform: Use_Origins
160
PlayerObjectCollision(C_ENEMY, -16, -16, 16, 20)
161
#endplatform
162
if CheckResult == true
163
CallFunction(Player_BadnikBreak)
164
end if
165
end sub
166
167
168
sub ObjectDraw
169
switch Object.State
170
case KAMAKAMA_GUARD
171
TempValue0 = Object.FrameTimer
172
TempValue0 >>= 3
173
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
174
175
if Object.Quality == GOOD_QUALITY
176
TempValue1 = TempValue0
177
TempValue1 += 4
178
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
179
180
TempValue1 += 12
181
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
182
183
TempValue1 -= 10
184
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
185
else
186
TempValue1 = TempValue0
187
TempValue1 += 10
188
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
189
190
TempValue1 += 2
191
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
192
end if
193
break
194
195
case KAMAKAMA_LAUNCH_BLADE
196
TempValue0 = Object.FrameTimer
197
TempValue0 >>= 3
198
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
199
200
if Object.Quality == GOOD_QUALITY
201
TempValue1 = TempValue0
202
TempValue1 += 4
203
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
204
205
TempValue1 += 2
206
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
207
else
208
TempValue1 = TempValue0
209
TempValue1 += 10
210
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
211
212
TempValue1 += 2
213
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
214
end if
215
break
216
217
case KAMAKAMA_PREPARE_CHARGE
218
TempValue0 = Object.FrameTimer
219
TempValue0 >>= 3
220
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
221
222
if Object.Quality == GOOD_QUALITY
223
TempValue1 = TempValue0
224
TempValue1 += 4
225
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
226
227
TempValue1 += 4
228
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
229
else
230
TempValue1 = TempValue0
231
TempValue1 += 10
232
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
233
234
TempValue1 += 4
235
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
236
end if
237
break
238
239
case KAMAKAMA_CHARGE
240
case KAMAKAMA_SWITCH_DIRECTION
241
TempValue0 = Object.Frame
242
TempValue0 >>= 3
243
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
244
245
TempValue0 = Object.FrameTimer
246
TempValue0 >>= 3
247
248
if Object.Quality == GOOD_QUALITY
249
TempValue1 = TempValue0
250
TempValue1 += 4
251
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
252
253
TempValue1 += 2
254
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
255
else
256
TempValue1 = TempValue0
257
TempValue1 += 10
258
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
259
260
TempValue1 += 2
261
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
262
end if
263
break
264
265
end switch
266
end sub
267
268
269
sub ObjectStartup
270
LoadSpriteSheet("R3/Objects.gif")
271
272
SpriteFrame(0, 4, 16, 16, 198, 119) // #0 - Wheel Frame 0
273
SpriteFrame(0, 4, 16, 16, 215, 119) // #1 - Wheel Frame 1
274
SpriteFrame(0, 4, 16, 16, 232, 119) // #2 - Wheel Frame 2
275
SpriteFrame(0, 4, 16, 16, 215, 119) // #3 - Wheel Frame 3
276
277
// Good Kama Kama
278
SpriteFrame(-10, -4, 24, 16, 215, 102) // #4 - Body Frame 0
279
SpriteFrame(-10, -3, 24, 16, 215, 102) // #5 - Body Frame 1
280
281
SpriteFrame(-16, -20, 16, 16, 198, 102) // #6 - Head Frame 0
282
SpriteFrame(-16, -19, 16, 16, 198, 102) // #7 - Head Frame 1
283
SpriteFrame(-16, -20, 16, 16, 198, 136) // #8 - Head Frame 2
284
SpriteFrame(-16, -19, 16, 16, 198, 102) // #9 - Head Frame 3
285
286
// Bad Kama Kama
287
SpriteFrame(-10, -4, 24, 16, 232, 136) // #10 - Body Frame 0
288
SpriteFrame(-10, -3, 24, 16, 198, 153) // #11 - Body Frame 1
289
290
SpriteFrame(-16, -20, 16, 16, 215, 136) // #12 - Head Frame 0
291
SpriteFrame(-16, -19, 16, 16, 240, 102) // #13 - Head Frame 0
292
SpriteFrame(-16, -20, 16, 16, 198, 136) // #14 - Head Frame 0
293
SpriteFrame(-16, -19, 16, 16, 240, 102) // #15 - Head Frame 0
294
295
SpriteFrame(-22, -14, 24, 20, 173, 101) // #16 - Claws Frame 0
296
SpriteFrame(-22, -14, 24, 20, 173, 122) // #17 - Claws Frame 1
297
298
// Used to be below LoadSpriteSheet, moved here for consistency
299
ArrayPos0 = 32
300
while ArrayPos0 < 1056
301
if Object[ArrayPos0].Type == TypeName[Kama Kama]
302
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
303
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
304
end if
305
ArrayPos0++
306
loop
307
end sub
308
309
310
// ========================
311
// Editor Subs
312
// ========================
313
314
315
sub RSDKEdit
316
if Editor.ReturnVariable == true
317
switch Editor.VariableID
318
case EDIT_VAR_PROPVAL // Property Value
319
CheckResult = Object.PropertyValue
320
CheckResult &= 1
321
break
322
case 0 // condition
323
CheckResult = Object.PropertyValue
324
CheckResult &= 1
325
break
326
end switch
327
else
328
switch Editor.VariableID
329
case EDIT_VAR_PROPVAL // Property Value
330
Object.PropertyValue = Editor.VariableValue
331
Object.PropertyValue &= 1
332
break
333
case 0 // condition
334
Object.PropertyValue = Editor.VariableValue
335
Object.PropertyValue &= 1
336
break
337
end switch
338
end if
339
end sub
340
341
342
sub RSDKDraw
343
DrawSprite(0)
344
345
switch Object.Quality
346
case GOOD_QUALITY
347
DrawSprite(1)
348
DrawSprite(2)
349
DrawSprite(3)
350
break
351
case BAD_QUALITY
352
DrawSprite(4)
353
DrawSprite(5)
354
break
355
end switch
356
end sub
357
358
359
sub RSDKLoad
360
LoadSpriteSheet("R3/Objects.gif")
361
362
SpriteFrame(0, 4, 16, 16, 198, 119) // #0 - Wheel
363
364
// Good Kama Kama
365
SpriteFrame(-10, -4, 24, 16, 215, 102) // #1 - Body
366
SpriteFrame(-16, -20, 16, 16, 198, 102) // #2 - Head
367
SpriteFrame(-22, -14, 24, 20, 173, 101) // #3 - Claws
368
369
// Bad Kama Kama
370
SpriteFrame(-10, -4, 24, 16, 232, 136) // #4 - Body
371
SpriteFrame(-16, -20, 16, 16, 215, 136) // #5 - Head
372
373
AddEditorVariable("condition")
374
SetActiveVariable("condition")
375
AddEnumVariable("Good Quality", GOOD_QUALITY)
376
AddEnumVariable("Bad Quality", BAD_QUALITY)
377
end sub
378
379