Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/Kamemusi.txt
1319 views
1
//-----------------Sonic CD Kamemusi 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.FireTimer
8
9
#alias Object.PropertyValue : Object.Quality
10
11
// Bullet Aliases
12
#alias Object.Value1 : Bullet.XVelocity
13
#alias Object.Value2 : Bullet.YVelocity
14
15
// States
16
#alias 0 : KAMEMUSI_MOVE_LEFT
17
#alias 1 : KAMEMUSI_MOVE_RIGHT
18
#alias 2 : KAMEMUSI_SHOOT
19
20
// Collision Sides
21
#alias 0 : CSIDE_FLOOR
22
23
// Stage SFX
24
#alias 1 : SFX_S_SHOT
25
26
// Badnik Quality / Property Values
27
#alias 0 : GOOD_QUALITY
28
#alias 1 : BAD_QUALITY
29
30
31
sub ObjectMain
32
if Object.Quality == GOOD_QUALITY
33
switch Object.State
34
case KAMEMUSI_MOVE_LEFT
35
Object.Frame++
36
Object.Frame %= 60
37
38
Object.XPos -= 0xAAAA
39
40
Object.Timer--
41
if Object.Timer == -192
42
Object.State = KAMEMUSI_MOVE_RIGHT
43
Object.Direction = FACING_LEFT
44
end if
45
46
ObjectTileGrip(CSIDE_FLOOR, 0, 14, 0) // Check if there's no more floor
47
if CheckResult == false
48
Object.State = KAMEMUSI_MOVE_RIGHT
49
Object.Timer = -192
50
Object.Direction = FACING_LEFT
51
end if
52
53
if Object.FireTimer > -1
54
PlayerObjectCollision(C_TOUCH, -64, -64, 64, 64)
55
if CheckResult == true
56
Object.State = KAMEMUSI_SHOOT
57
Object.DrawOrder = 4
58
end if
59
else
60
Object.FireTimer++
61
end if
62
break
63
64
case KAMEMUSI_MOVE_RIGHT
65
Object.Frame++
66
Object.Frame %= 60
67
68
Object.XPos += 0xAAAA
69
70
Object.Timer++
71
if Object.Timer == 192
72
Object.State = KAMEMUSI_MOVE_LEFT
73
Object.Direction = FACING_RIGHT
74
end if
75
76
ObjectTileGrip(CSIDE_FLOOR, 0, 14, 0) // Check if there's no more floor
77
if CheckResult == false
78
Object.State = KAMEMUSI_MOVE_LEFT
79
Object.Timer = 192
80
Object.Direction = FACING_RIGHT
81
end if
82
83
if Object.FireTimer > -1
84
PlayerObjectCollision(C_TOUCH, -64, -64, 64, 64)
85
if CheckResult == true
86
Object.State = KAMEMUSI_SHOOT
87
Object.DrawOrder = 4
88
end if
89
else
90
Object.FireTimer++
91
end if
92
break
93
94
case KAMEMUSI_SHOOT
95
if Object.FireTimer == 60
96
CreateTempObject(TypeName[Bullet], 0, Object.XPos, Object.YPos)
97
Bullet[TempObjectPos].XVelocity = -0x20000
98
Bullet[TempObjectPos].YVelocity = -0x50000
99
end if
100
101
if Object.FireTimer == 62
102
CreateTempObject(TypeName[Bullet], 0, Object.XPos, Object.YPos)
103
Bullet[TempObjectPos].XVelocity = 0x20000
104
Bullet[TempObjectPos].YVelocity = -0x50000
105
PlayStageSfx(SFX_S_SHOT, false)
106
end if
107
108
if Object.FireTimer == 64
109
Object.State = Object.Direction
110
Object.FireTimer = -120
111
Object.DrawOrder = 3
112
else
113
Object.FireTimer++
114
end if
115
116
break
117
end switch
118
else
119
switch Object.State
120
case KAMEMUSI_MOVE_LEFT
121
Object.Frame++
122
Object.Frame %= 12
123
124
Object.XPos -= 0x3800
125
126
Object.Timer--
127
if Object.Timer == -384
128
Object.State = KAMEMUSI_MOVE_RIGHT
129
Object.Direction = FACING_LEFT
130
end if
131
132
ObjectTileGrip(CSIDE_FLOOR, 0, 14, 0)
133
if CheckResult == false
134
Object.State = KAMEMUSI_MOVE_RIGHT
135
Object.Timer = -384
136
Object.Direction = FACING_LEFT
137
end if
138
139
if Object.FireTimer == 82
140
Object.State = KAMEMUSI_SHOOT
141
Object.FireTimer = 0
142
else
143
Object.FireTimer++
144
end if
145
146
break
147
148
case KAMEMUSI_MOVE_RIGHT
149
Object.Frame++
150
Object.Frame %= 12
151
152
Object.XPos += 0x3800
153
Object.Timer++
154
if Object.Timer == 384
155
Object.State = KAMEMUSI_MOVE_LEFT
156
Object.Direction = FACING_RIGHT
157
end if
158
159
ObjectTileGrip(CSIDE_FLOOR, 0, 14, 0)
160
if CheckResult == false
161
Object.State = KAMEMUSI_MOVE_LEFT
162
Object.Timer = 384
163
Object.Direction = FACING_RIGHT
164
end if
165
166
if Object.FireTimer == 82
167
Object.State = KAMEMUSI_SHOOT
168
Object.FireTimer = 0
169
else
170
Object.FireTimer++
171
end if
172
break
173
174
case KAMEMUSI_SHOOT // in his broken state, the shoot will fail
175
if Object.FireTimer == 14
176
Object.State = Object.Direction
177
Object.FireTimer = 0
178
else
179
Object.FireTimer++
180
end if
181
break
182
183
end switch
184
end if
185
CallFunction(StageSetup_CheckGoodFuture) // Check if it should be a flower
186
end sub
187
188
189
sub ObjectPlayerInteraction
190
#platform: Use_Standalone
191
PlayerObjectCollision(C_TOUCH, -16, -14, 16, 14)
192
#endplatform
193
#platform: Use_Origins
194
PlayerObjectCollision(C_ENEMY, -16, -14, 16, 14)
195
#endplatform
196
if CheckResult == true
197
CallFunction(Player_BadnikBreak)
198
end if
199
end sub
200
201
202
sub ObjectDraw
203
if Object.Quality == GOOD_QUALITY
204
if Object.State < KAMEMUSI_SHOOT
205
TempValue0 = Object.Frame
206
TempValue0 /= 30
207
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
208
else
209
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
210
end if
211
else
212
if Object.State < KAMEMUSI_SHOOT
213
TempValue0 = Object.Frame
214
TempValue0 /= 6
215
TempValue0 += 2
216
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
217
else
218
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
219
end if
220
end if
221
end sub
222
223
224
sub ObjectStartup
225
LoadSpriteSheet("R1/Objects.gif")
226
227
// Good Quality
228
SpriteFrame(-16, -15, 32, 29, 223, 34) // #0 - Kamemusi Movement Frame 0
229
SpriteFrame(-16, -14, 32, 28, 223, 93) // #1 - Kamemusi Movement Frame 1
230
// Bad Quality
231
SpriteFrame(-16, -15, 32, 29, 223, 34) // #2 - Old Kamemusi Movement Frame 0
232
SpriteFrame(-16, -14, 32, 28, 223, 64) // #3 - Old Kamemusi Movement Frame 1
233
234
SpriteFrame(-16, -17, 32, 31, 223, 122) // #4 - Kamemusi Shoot Position
235
end sub
236
237
238
// ========================
239
// Editor Subs
240
// ========================
241
242
sub RSDKEdit
243
if Editor.ReturnVariable == true
244
switch Editor.VariableID
245
case EDIT_VAR_PROPVAL // Property Value
246
CheckResult = Object.PropertyValue
247
CheckResult &= 1
248
break
249
case 0 // type
250
CheckResult = Object.PropertyValue
251
CheckResult &= 1
252
break
253
end switch
254
else
255
switch Editor.VariableID
256
case EDIT_VAR_PROPVAL // Property Value
257
Object.PropertyValue = Editor.VariableValue
258
Object.PropertyValue &= 1
259
break
260
case 0 // type
261
Object.PropertyValue = Editor.VariableValue
262
Object.PropertyValue &= 1
263
break
264
end switch
265
end if
266
end sub
267
268
269
sub RSDKDraw
270
DrawSprite(Object.PropertyValue)
271
end sub
272
273
274
sub RSDKLoad
275
LoadSpriteSheet("R1/Objects.gif")
276
277
SpriteFrame(-16, -15, 32, 29, 223, 34) // #0 - Kamemusi
278
SpriteFrame(-16, -15, 32, 29, 223, 34) // #1 - Old Kamemusi
279
280
AddEditorVariable("condition")
281
SetActiveVariable("condition")
282
AddEnumVariable("Good Quality", GOOD_QUALITY)
283
AddEnumVariable("Bad Quality", BAD_QUALITY)
284
end sub
285
286