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