Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/Hotaru2.txt
1319 views
1
//------------------Sonic CD Hotaru 2 Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//-------Used on Mission "M110 - Extreme! Gotta Go Fast"------//
5
6
// Aliases
7
#alias Object.Value0 : Object.Timer
8
#alias Object.Value1 : Object.XVelocity
9
#alias Object.Value2 : Object.YVelocity
10
#alias Object.Value3 : Object.XOriginPos
11
#alias Object.Value4 : Object.YOriginPos
12
#alias Object.Value5 : Object.LeftBound
13
#alias Object.Value6 : Object.RightBound
14
#alias Object.Value7 : Object.CheckBounds
15
16
// Hotaru Laser alias
17
#alias Object.Value2 : Object.HotaruEntity
18
19
// HUD Alias
20
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
21
22
// One Way Door Alias
23
#alias Object[+5].State : OneWayDoor.State
24
25
// Hotaru Spawner States
26
#alias 0 : HOTARU2_SPAWNER_CHECK_BOUNDS
27
#alias 1 : HOTARU2_SPAWNER_SPAWN_CHILD_1
28
#alias 2 : HOTARU2_SPAWNER_CHECK_CHILD_1
29
#alias 3 : HOTARU2_SPAWNER_SPAWN_CHILD_2
30
#alias 4 : HOTARU2_SPAWNER_CHECK_CHILD_2
31
#alias 5 : HOTARU2_SPAWNER_OPEN_DOORS
32
33
// Hotaru States
34
#alias 0 : HOTARU2_FADE_IN
35
#alias 1 : HOTARU2_MOVE
36
#alias 2 : HOTARU2_CHARGE_LASER
37
#alias 3 : HOTARU2_SHOT_LASER
38
#alias 4 : HOTARU2_SET_NEW_DESTINATION
39
40
// One Way Door States
41
#alias 1 : ONEWAYDOOR_OPEN
42
43
// Property Values
44
#alias 0 : PARENT_OBJECT
45
#alias 1 : CHILD_OBJECT
46
47
// Time Periods
48
#alias 0 : TIME_PRESENT
49
#alias 1 : TIME_PAST
50
#alias 2 : TIME_GOOD_FUTURE
51
#alias 3 : TIME_BAD_FUTURE
52
53
// Ink Effects
54
#alias 2 : INK_ALPHA
55
56
// Priority
57
#alias 1 : PRIORITY_ACTIVE
58
59
// Stage SFX
60
#alias 4 : SFX_S_HLASER
61
62
// Function declarations
63
#function Hotaru2_Set_Destination
64
65
function Hotaru2_Set_Destination
66
if Object.CheckBounds == false
67
TempValue0 = true
68
else
69
TempValue1 = Player.XPos
70
TempValue1 >>= 16
71
TempValue1 &= 0x7FF8
72
73
CheckLower(TempValue1, Object.LeftBound)
74
TempValue0 = CheckResult
75
76
CheckGreater(TempValue1, Object.RightBound)
77
TempValue0 |= CheckResult
78
end if
79
80
if TempValue0 == true
81
TempValue2 = Oscillation
82
TempValue2 &= 127
83
TempValue2 += Object.XOriginPos
84
TempValue2 -= 64
85
86
TempValue3 = Player.XPos
87
TempValue3 >>= 16
88
TempValue3 *= 5
89
TempValue3 &= 31
90
TempValue3 += Object.YOriginPos
91
else
92
TempValue2 = TempValue1
93
94
TempValue3 = Object.YOriginPos
95
TempValue3 -= 8
96
end if
97
Object.XVelocity = TempValue2
98
Object.XVelocity -= Object.iXPos
99
Object.XVelocity <<= 12
100
101
Object.YVelocity = TempValue3
102
Object.YVelocity -= Object.iYPos
103
Object.YVelocity <<= 12
104
105
Object.CheckBounds++
106
Object.CheckBounds &= 1
107
end function
108
109
110
sub ObjectMain
111
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
112
Object.Type = TypeName[Blank Object]
113
else
114
if Object.PropertyValue == PARENT_OBJECT
115
switch Object.State
116
case HOTARU2_SPAWNER_CHECK_BOUNDS
117
TempValue0 = Object.XPos
118
TempValue0 -= 0x300000
119
120
if Player.XPos > TempValue0
121
Object.State++
122
end if
123
break
124
125
case HOTARU2_SPAWNER_SPAWN_CHILD_1
126
if Object.Timer < 60
127
Object.Timer++
128
else
129
Object.Timer = 0
130
131
Object[+1].Type = TypeName[Hotaru2]
132
Object[+1].XPos = Object.XPos
133
Object[+1].XPos -= 0x500000
134
Object[+1].YPos = Object.YPos
135
Object[+1].YPos += 0x300000
136
Object.State++
137
end if
138
break
139
140
case HOTARU2_SPAWNER_CHECK_CHILD_1
141
// Check if the first Hotaru got destroyed
142
if Object[+1].Type != TypeName[Hotaru2]
143
Object.State++
144
else
145
if Object[+1].State < HOTARU2_CHARGE_LASER
146
TempValue0 = 176
147
else
148
TempValue0 = 0
149
end if
150
TempValue0 -= Object.Alpha
151
TempValue0 >>= 3
152
Object.Alpha += TempValue0
153
end if
154
break
155
156
case HOTARU2_SPAWNER_SPAWN_CHILD_2
157
if Object.Timer < 60
158
Object.Timer++
159
else
160
Object.Timer = 0
161
Object[+2].Type = TypeName[Hotaru2]
162
Object[+2].CheckBounds = true
163
164
Object[+2].XPos = Object.XPos
165
Object[+2].XPos -= 0x500000
166
167
Object[+2].YPos = Object.YPos
168
Object[+2].YPos += 0x280000
169
170
Object[+3].Type = TypeName[Hotaru2]
171
Object[+3].CheckBounds = false
172
173
Object[+3].XPos = Object.XPos
174
Object[+3].XPos += 0x500000
175
176
Object[+3].YPos = Object.YPos
177
Object[+3].YPos += 0x280000
178
Object.State++
179
end if
180
break
181
182
case HOTARU2_SPAWNER_CHECK_CHILD_2
183
if Object[+2].Type != TypeName[Hotaru]
184
if Object[+3].Type != TypeName[Hotaru]
185
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
186
else
187
if Object[+3].State < HOTARU2_CHARGE_LASER
188
TempValue0 = 176
189
else
190
TempValue0 = 0
191
end if
192
TempValue0 -= Object.Alpha
193
TempValue0 >>= 3
194
Object.Alpha += TempValue0
195
end if
196
else
197
if Object[+2].State < HOTARU2_CHARGE_LASER
198
TempValue0 = 176
199
else
200
TempValue0 = 0
201
end if
202
TempValue0 -= Object.Alpha
203
TempValue0 >>= 3
204
Object.Alpha += TempValue0
205
end if
206
break
207
208
case HOTARU2_SPAWNER_OPEN_DOORS
209
if Object[+2].State > HOTARU2_MOVE
210
if Object[+3].State > HOTARU2_MOVE
211
OneWayDoor.State = ONEWAYDOOR_OPEN
212
end if
213
end if
214
215
if HUD.CurrentTimePeriod == TIME_BAD_FUTURE
216
if Object.Alpha < 176
217
Object.Alpha++
218
end if
219
else
220
if Object.Alpha > 0
221
Object.Alpha--
222
end if
223
end if
224
225
PlayerObjectCollision(C_TOUCH, -192, -256, 420, 256)
226
if CheckResult == false
227
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
228
end if
229
break
230
end switch
231
else
232
switch Object.State
233
case HOTARU2_FADE_IN
234
if Object.Timer < 30
235
Object.Timer++
236
else
237
Object.Timer = 16
238
CallFunction(Hotaru2_Set_Destination)
239
Object.State++
240
end if
241
Object.Alpha = Object.Timer
242
Object.Alpha <<= 2
243
break
244
245
case HOTARU2_MOVE
246
Object.XPos += Object.XVelocity
247
Object.YPos += Object.YVelocity
248
249
TempValue0 = Object.Timer
250
TempValue0 &= 1
251
if TempValue0 == 0
252
CreateTempObject(TypeName[Hotaru Trail], 0, Object.XPos, Object.YPos)
253
Object[TempObjectPos].InkEffect = INK_ALPHA
254
Object[TempObjectPos].Alpha = 248
255
end if
256
257
Object.Timer--
258
if Object.Timer == 0
259
Object.State++
260
end if
261
break
262
263
case HOTARU2_CHARGE_LASER
264
Object.Timer++
265
if Object.Timer == 16
266
Object.Timer = 0
267
Object.State++
268
PlayStageSfx(SFX_S_HLASER, false)
269
end if
270
break
271
272
case HOTARU2_SHOT_LASER
273
TempValue0 = Object.Timer
274
TempValue0 &= 1
275
if TempValue0 == 0
276
CreateTempObject(TypeName[Blank Object], 0, Object.XPos, Object.YPos)
277
Object[TempObjectPos].HotaruEntity = Object.EntityNo
278
end if
279
Object.Timer++
280
if Object.Timer == 10
281
Object.Timer = 0
282
Object.State++
283
end if
284
break
285
286
case HOTARU2_SET_NEW_DESTINATION
287
Object.Timer++
288
if Object.Timer == 8
289
Object.Timer = 16
290
CallFunction(Hotaru2_Set_Destination)
291
Object.State = HOTARU2_MOVE
292
end if
293
break
294
end switch
295
end if
296
end if
297
end sub
298
299
300
sub ObjectPlayerInteraction
301
if Object.PropertyValue == CHILD_OBJECT
302
if Object.State == HOTARU2_SHOT_LASER
303
if Object.Timer > 1
304
PlayerObjectCollision(C_ENEMY, -5, -5, 5, 5)
305
if CheckResult == true
306
CallFunction(Player_BadnikBreak)
307
end if
308
end if
309
end if
310
end if
311
end sub
312
313
314
sub ObjectDraw
315
316
if Object.PropertyValue == CHILD_OBJECT
317
switch Object.State
318
case HOTARU2_FADE_IN
319
DrawSpriteFX(2, FX_INK, Object.XPos, Object.YPos)
320
break
321
322
case HOTARU2_MOVE
323
DrawSprite(2)
324
break
325
326
case HOTARU2_CHARGE_LASER
327
TempValue0 = Object.Timer
328
TempValue0 &= 3
329
TempValue0 >>= 1
330
if TempValue0 == 0
331
DrawSprite(3)
332
else
333
DrawSprite(0)
334
end if
335
break
336
337
case HOTARU2_SHOT_LASER
338
TempValue0 = Object.Timer
339
TempValue0 &= 7
340
TempValue0 >>= 2
341
DrawSprite(TempValue0)
342
DrawSprite(3)
343
break
344
345
case HOTARU2_SET_NEW_DESTINATION
346
TempValue0 = Object.Timer
347
TempValue0 &= 3
348
TempValue0 >>= 1
349
if TempValue0 == 0
350
DrawSprite(3)
351
else
352
DrawSprite(0)
353
end if
354
break
355
end switch
356
end if
357
end sub
358
359
360
sub ObjectStartup
361
LoadSpriteSheet("R8/Objects3.gif")
362
363
SpriteFrame(-12, -24, 24, 40, 96, 133) // #0 - Hotaru Idle frame 0
364
SpriteFrame(-12, -24, 24, 40, 121, 133) // #1 - Hotaru Idle frame 1
365
366
SpriteFrame(-12, -10, 24, 24, 146, 133) // #2 - Hotaru Bulb frame 0
367
SpriteFrame(-12, -10, 24, 24, 171, 133) // #3 - Hotaru Bulb frame 1
368
369
ArrayPos0 = 32
370
while ArrayPos0 < 1056
371
if Object[ArrayPos0].Type == TypeName[Hotaru]
372
Object[ArrayPos0].Type = TypeName[Hotaru2]
373
end if
374
375
if Object[ArrayPos0].Type == TypeName[Hotaru2]
376
Object[ArrayPos0].Alpha = 0
377
Object[ArrayPos0].InkEffect = INK_ALPHA
378
379
if HUD.CurrentTimePeriod == TIME_BAD_FUTURE
380
Object[ArrayPos0].DrawOrder = 2
381
end if
382
383
ArrayPos1 = ArrayPos0
384
ArrayPos1++
385
TempValue0 = 0
386
while TempValue0 < 3
387
// Setups the next 3 blank objects
388
Object[ArrayPos1].PropertyValue = CHILD_OBJECT
389
Object[ArrayPos1].DrawOrder = 4
390
Object[ArrayPos1].InkEffect = INK_ALPHA
391
392
Object[ArrayPos1].XOriginPos = Object[ArrayPos0].iXPos
393
Object[ArrayPos1].YOriginPos = Object[ArrayPos0].iYPos
394
395
Object[ArrayPos1].LeftBound = Object[ArrayPos0].iXPos
396
Object[ArrayPos1].LeftBound -= 112
397
398
Object[ArrayPos1].RightBound = Object[ArrayPos0].iXPos
399
Object[ArrayPos1].RightBound += 112
400
TempValue0++
401
ArrayPos1++
402
loop
403
ArrayPos0 += 3
404
end if
405
ArrayPos0++
406
loop
407
end sub
408
409
410
// ========================
411
// Editor Subs
412
// ========================
413
414
sub RSDKDraw
415
DrawSprite(0)
416
end sub
417
418
419
sub RSDKLoad
420
LoadSpriteSheet("R8/Objects3.gif")
421
422
SpriteFrame(-12, -24, 24, 40, 96, 133) // #0 - Hotaru Idle frame 0
423
424
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
425
end sub
426
427
428
429