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