Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/Amy.txt
1319 views
1
//-----------------Sonic CD Amy Rose Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// ========================
6
// Aliases
7
// ========================
8
9
#alias Object.Value0 : Object.XVelocity
10
#alias Object.Value1 : Object.YVelocity
11
#alias Object.Value2 : Object.LeftLimit
12
#alias Object.Value3 : Object.RightLimit
13
#alias Object.Value4 : Object.SonicHugged
14
#alias Object.Value5 : Object.Gravity
15
#alias Object.Value6 : Object.FrameTimer
16
#alias Object.Value7 : Object.HeartTimer
17
18
// States
19
#alias 0 : AMY_IDLE
20
#alias 1 : AMY_CHASE
21
#alias 2 : AMY_AWAIT_RIGHT
22
#alias 3 : AMY_CHEER_LEFT
23
#alias 4 : AMY_CHEER_RIGHT
24
#alias 5 : AMY_AWAIT_LEFT
25
#alias 6 : AMY_HEART_STARE
26
#alias 7 : AMY_HUG
27
#alias 8 : AMY_REJECTED
28
29
// Priority Aliases
30
#alias 0 : PRIORITY_BOUNDS
31
#alias 1 : PRIORITY_ACTIVE
32
33
// Gravity Aliases
34
#alias 0 : GRAVITY_GROUND
35
#alias 1 : GRAVITY_AIR
36
37
// Player Aliases
38
#alias 0 : PLAYER_SONIC_A
39
40
// Collision Side Aliases
41
#alias 0 : CSIDE_FLOOR
42
43
// Ink Effect Aliases
44
#alias 2 : INK_ALPHA
45
46
// Stage SFX Aliases
47
#alias 3 : SFX_S_GIGGLE
48
49
// Game Mode Aliases
50
#alias 2 : MODE_TIMEATTACK
51
52
53
// ========================
54
// Events
55
// ========================
56
57
sub ObjectMain
58
Object.Priority = PRIORITY_ACTIVE
59
if Player.XPos < Object.XPos
60
Object.Direction = FACING_LEFT
61
else
62
Object.Direction = FACING_RIGHT
63
end if
64
65
switch Object.State
66
case AMY_IDLE
67
TempValue0 = Object.FrameTimer
68
TempValue0 /= 10
69
TempValue0 += 11
70
Object.Frame = TempValue0
71
Object.FrameTimer++
72
if Object.FrameTimer > 139
73
Object.FrameTimer = 0
74
end if
75
76
// Check to see if Sonic's anywhere near, and if so, start giving chase!
77
PlayerObjectCollision(C_TOUCH, -96, -360, 96, 360)
78
if CheckResult == true
79
Object.XVelocity = 0
80
Object.State = AMY_CHASE
81
Object.Frame = 4
82
Object.FrameTimer = 0
83
end if
84
break
85
86
case AMY_CHASE
87
Object.FrameTimer++
88
switch Object.Frame
89
case 4
90
case 6
91
if Object.FrameTimer == 4
92
Object.FrameTimer = 0
93
Object.Frame++
94
end if
95
break
96
97
case 5
98
case 7
99
if Object.FrameTimer == 3
100
Object.FrameTimer = 0
101
Object.Frame++
102
end if
103
break
104
105
end switch
106
107
if Object.Frame > 7
108
Object.Frame = 4
109
end if
110
111
if Object.Direction == FACING_RIGHT
112
if Object.XVelocity < 0x20000
113
Object.XVelocity += 0x1000
114
end if
115
116
PlayerObjectCollision(C_TOUCH, -32, -360, 4, 360)
117
if CheckResult == true
118
if Player.Gravity == GRAVITY_GROUND
119
if Player.Direction == Object.Direction
120
PlayerObjectCollision(C_TOUCH, -32, -20, 4, 20)
121
if CheckResult == true
122
CheckEqual(Player.Animation, ANI_SPINDASH)
123
TempValue0 = CheckResult
124
125
// Before commencing the hugging, make sure Sonic's not already being hugged by someone else first
126
// -> This check was only added in via an update, so it's not present in the Steam version of the game
127
CheckEqual(Object[2].Type, TypeName[Blue Shield])
128
TempValue0 |= CheckResult
129
130
if TempValue0 == true
131
Object.State = AMY_REJECTED
132
Object.Frame = 9
133
Object.YVelocity = -0x40000
134
Object.Gravity = GRAVITY_AIR
135
Object.XVelocity = -0x10000
136
else
137
Object.SonicHugged = true
138
Object.State = AMY_HUG
139
Object.Frame = 8
140
Object.FrameTimer = 0
141
Player.State = Player_State_Hugged
142
PlayStageSfx(SFX_S_GIGGLE, false)
143
144
#platform: Use_Haptics
145
HapticEffect(52, 0, 0, 0)
146
#endplatform
147
148
// Just one hug is enough unlock criteria
149
if Stage.DebugMode == false
150
SetAchievement(1, 100)
151
end if
152
end if
153
else
154
Object.State = AMY_HEART_STARE
155
Object.Frame = 0
156
Object.FrameTimer = 0
157
Object.XVelocity = 0
158
end if
159
160
else
161
Object.State = AMY_HEART_STARE
162
Object.Frame = 0
163
Object.FrameTimer = 0
164
Object.XVelocity = 0
165
end if // Player.Direction == Object.Direction
166
end if // Player.Gravity == GRAVITY_GROUND
167
end if // CheckResult == true (from the box of -32, -360, 4, 360)
168
169
if Object.XPos < Object.RightLimit
170
Object.XPos += Object.XVelocity
171
else
172
Object.XVelocity = 0
173
Object.XPos = Object.RightLimit
174
175
if Object.SonicHugged == true
176
Object.State = AMY_CHEER_RIGHT
177
else
178
Object.State = AMY_AWAIT_RIGHT
179
Object.Frame = 0
180
Object.FrameTimer = 0
181
end if
182
183
end if
184
else // Object.Direction == FACING_LEFT
185
if Object.XVelocity > -0x20000
186
Object.XVelocity -= 0x1000
187
end if
188
189
PlayerObjectCollision(C_TOUCH, -4, -360, 32, 360)
190
if CheckResult == true
191
if Player.Gravity == GRAVITY_GROUND
192
if Player.Direction == Object.Direction
193
PlayerObjectCollision(C_TOUCH, -32, -20, 4, 20)
194
if CheckResult == true
195
CheckEqual(Player.Animation, ANI_SPINDASH)
196
TempValue0 = CheckResult
197
198
// Make sure Sonic isn't wearing a shield before having Amy grab on
199
// -> This change was only introduced in an update, the Steam version doesn't have this check
200
CheckEqual(Object[2].Type, TypeName[Blue Shield])
201
TempValue0 |= CheckResult
202
203
if TempValue0 == true
204
Object.State = AMY_REJECTED
205
Object.Frame = 9
206
Object.YVelocity = -0x40000
207
Object.Gravity = GRAVITY_AIR
208
Object.XVelocity = 0x10000
209
else
210
Object.SonicHugged = true
211
Object.State = AMY_HUG
212
Object.Frame = 8
213
Object.FrameTimer = 0
214
Player.State = Player_State_Hugged
215
PlayStageSfx(SFX_S_GIGGLE, false)
216
217
#platform: Use_Haptics
218
HapticEffect(52, 0, 0, 0)
219
#endplatform
220
221
// Just one hug is enough unlock criteria
222
if Stage.DebugMode == false
223
SetAchievement(1, 100)
224
end if
225
226
end if
227
else
228
Object.State = AMY_HEART_STARE
229
Object.Frame = 0
230
Object.FrameTimer = 0
231
Object.XVelocity = 0
232
end if
233
else
234
Object.State = AMY_HEART_STARE
235
Object.Frame = 0
236
Object.FrameTimer = 0
237
Object.XVelocity = 0
238
end if // Player.Direction == Object.Direction
239
end if // Player.Gravity == GRAVITY_GROUND
240
end if // CheckResult == true (from the box of -4, -360, 32, 360)
241
242
if Object.XPos > Object.LeftLimit
243
Object.XPos += Object.XVelocity
244
else
245
Object.XVelocity = 0
246
Object.XPos = Object.LeftLimit
247
248
if Object.SonicHugged == true
249
Object.State = AMY_AWAIT_LEFT
250
else
251
Object.State = AMY_CHEER_LEFT
252
Object.Frame = 0
253
Object.FrameTimer = 0
254
end if
255
end if
256
end if
257
break
258
259
case AMY_AWAIT_RIGHT
260
Object.FrameTimer++
261
if Object.FrameTimer == 12
262
Object.FrameTimer = 0
263
Object.Frame++
264
end if
265
266
if Object.Frame > 3
267
Object.Frame = 0
268
end if
269
270
if Object.Direction == FACING_LEFT
271
Object.State = AMY_CHASE
272
Object.Frame = 4
273
Object.FrameTimer = 0
274
end if
275
break
276
277
case AMY_CHEER_LEFT
278
Object.FrameTimer++
279
if Object.FrameTimer == 12
280
Object.FrameTimer = 0
281
Object.Frame++
282
end if
283
284
if Object.Frame > 3
285
Object.Frame = 0
286
end if
287
288
if Object.Direction == FACING_RIGHT
289
Object.State = AMY_CHASE
290
Object.Frame = 4
291
Object.FrameTimer = 0
292
end if
293
break
294
295
case AMY_CHEER_RIGHT
296
if Object.FrameTimer < 8
297
Object.Frame = 0
298
else
299
if Object.FrameTimer > 47
300
if Object.Gravity == GRAVITY_GROUND
301
if Object.FrameTimer < 120
302
Object.YVelocity = -0x40000
303
Object.Gravity = GRAVITY_AIR
304
Object.Frame = 9
305
else
306
Object.FrameTimer = 0
307
end if
308
else
309
if Object.YVelocity > 0
310
Object.Frame = 0
311
end if
312
end if
313
else
314
TempValue0 = Object.FrameTimer
315
TempValue0 -= 8
316
TempValue0 %= 20
317
TempValue0 /= 10
318
319
Object.Frame = TempValue0
320
Object.Frame += 9
321
end if
322
end if
323
324
if Object.Gravity == GRAVITY_GROUND
325
if Object.Direction == FACING_LEFT
326
Object.State = AMY_CHASE
327
Object.Frame = 4
328
Object.FrameTimer = 0
329
end if
330
end if
331
332
Object.FrameTimer++
333
break
334
335
case AMY_AWAIT_LEFT
336
if Object.FrameTimer < 8
337
Object.Frame = 0
338
else
339
if Object.FrameTimer > 47
340
if Object.Gravity == GRAVITY_GROUND
341
if Object.FrameTimer < 120
342
Object.YVelocity = -0x40000
343
Object.Gravity = GRAVITY_AIR
344
Object.Frame = 9
345
else
346
Object.FrameTimer = 0
347
end if
348
else
349
if Object.YVelocity > 0
350
Object.Frame = 0
351
end if
352
end if
353
else
354
TempValue0 = Object.FrameTimer
355
TempValue0 -= 8
356
TempValue0 %= 20
357
TempValue0 /= 10
358
359
Object.Frame = TempValue0
360
Object.Frame += 9
361
end if
362
end if
363
364
if Object.Gravity == GRAVITY_GROUND
365
if Object.Direction == FACING_RIGHT
366
Object.State = AMY_CHASE
367
Object.Frame = 4
368
Object.FrameTimer = 0
369
end if
370
end if
371
372
Object.FrameTimer++
373
break
374
375
case AMY_HEART_STARE
376
Object.FrameTimer++
377
if Object.FrameTimer == 12
378
Object.FrameTimer = 0
379
Object.Frame++
380
end if
381
382
if Object.Frame > 3
383
Object.Frame = 0
384
end if
385
386
PlayerObjectCollision(C_TOUCH, -4, -360, 4, 360)
387
if CheckResult == false
388
if Player.Gravity == GRAVITY_GROUND
389
// If you're not exactly above her, she'll start chasing you again
390
391
Object.State = AMY_CHASE
392
Object.Frame = 4
393
Object.FrameTimer = 0
394
end if
395
else
396
if Player.Gravity == GRAVITY_AIR
397
// If you jump while she waits for you, she'll start chasing you again
398
399
Object.State = AMY_CHASE
400
Object.Frame = 4
401
Object.FrameTimer = 0
402
end if
403
end if
404
break
405
406
case AMY_HUG
407
Player.Speed = 0
408
Player.XVelocity = 0
409
Player.Direction = Object.Direction
410
if Player.Animation == ANI_JUMPING
411
412
Object.State = AMY_REJECTED
413
Object.Frame = 9
414
Object.YVelocity = -0x40000
415
Object.Gravity = GRAVITY_AIR
416
if Object.Direction == FACING_RIGHT
417
Object.XVelocity = -0x10000
418
else
419
Object.XVelocity = 0x10000
420
end if
421
422
end if
423
break
424
425
case AMY_REJECTED
426
if Object.YVelocity > 0
427
Object.Frame = 10
428
end if
429
430
if Object.XVelocity > 0
431
Object.XVelocity -= 0x800
432
end if
433
434
if Object.XVelocity < 0
435
Object.XVelocity += 0x800
436
end if
437
438
Object.XPos += Object.XVelocity
439
if Object.Gravity == GRAVITY_GROUND
440
441
if Object.FrameTimer == 16
442
Object.State = AMY_CHASE
443
Object.Frame = 4
444
Object.FrameTimer = 0
445
else
446
Object.FrameTimer++
447
end if
448
449
end if
450
451
if Object.XPos > Object.RightLimit
452
Object.XPos = Object.RightLimit
453
end if
454
break
455
456
end switch
457
458
Object.HeartTimer++
459
if Object.State == AMY_HUG
460
if Object.HeartTimer > 15
461
CreateTempObject(TypeName[Love Heart], 0, Object.XPos, Object.YPos)
462
Object[TempObjectPos].iYPos -= 6
463
Object[TempObjectPos].InkEffect = INK_ALPHA
464
Object[TempObjectPos].Alpha = 255
465
Object.HeartTimer = 0
466
end if
467
else
468
if Object.HeartTimer > 41
469
CreateTempObject(TypeName[Love Heart], 0, Object.XPos, Object.YPos)
470
Object[TempObjectPos].iYPos -= 6
471
Object[TempObjectPos].InkEffect = INK_ALPHA
472
Object[TempObjectPos].Alpha = 255
473
Object.HeartTimer = 0
474
end if
475
end if
476
477
if Object.Gravity == GRAVITY_GROUND
478
ObjectTileGrip(CSIDE_FLOOR, 0, 19, 0)
479
else
480
Object.YVelocity += 0x4000
481
Object.YPos += Object.YVelocity
482
ObjectTileCollision(CSIDE_FLOOR, 0, 19, 0)
483
if CheckResult == true
484
Object.YVelocity = 0
485
Object.Gravity = GRAVITY_GROUND
486
end if
487
end if
488
489
if Object.OutOfBounds == true
490
Object.Priority = PRIORITY_BOUNDS
491
Object.State = AMY_IDLE
492
Object.SonicHugged = false
493
end if
494
end sub
495
496
497
sub ObjectDraw
498
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
499
end sub
500
501
502
sub ObjectStartup
503
LoadSpriteSheet("R1/Objects.gif")
504
505
// Idle
506
SpriteFrame(-11, -20, 22, 40, 34, 208) // #0 - Amy Idle Frame 0
507
SpriteFrame(-11, -20, 22, 40, 57, 208) // #1 - Amy Idle Frame 1
508
SpriteFrame(-11, -20, 22, 40, 34, 208) // #2 - Amy Idle Frame 2
509
SpriteFrame(-11, -20, 22, 40, 126, 167) // #3 - Amy Idle Frame 3
510
511
// Walking
512
SpriteFrame(-15, -20, 30, 40, 68, 167) // #4 - Amy Walking Frame 0
513
SpriteFrame(-10, -20, 21, 40, 166, 101) // #5 - Amy Walking Frame 1
514
SpriteFrame(-13, -20, 26, 40, 99, 167) // #6 - Amy Walking Frame 2
515
SpriteFrame(-10, -20, 21, 40, 166, 101) // #7 - Amy Walking Frame 3
516
517
// Hug
518
SpriteFrame(-12, -20, 24, 40, 181, 208) // #8 - Amy Hug
519
520
// Jumping
521
SpriteFrame(-13, -20, 26, 40, 80, 208) // #9 - Amy Jumping Frame 0
522
SpriteFrame(-12, -20, 24, 40, 107, 208) // #10 - Amy Jumping Frame 1
523
524
// Looking for Sonic, frames are repeated in place of making the sprite last longer animation-wise
525
// Amy Looking Frame "0"
526
SpriteFrame(-12, -20, 22, 40, 158, 208) // #11
527
SpriteFrame(-12, -20, 22, 40, 158, 208) // #12
528
SpriteFrame(-12, -20, 22, 40, 158, 208) // #13
529
SpriteFrame(-12, -20, 22, 40, 158, 208) // #14
530
SpriteFrame(-12, -20, 22, 40, 158, 208) // #15
531
532
// Amy Looking Frame "1"
533
SpriteFrame(-14, -20, 25, 40, 132, 208) // #16
534
SpriteFrame(-14, -20, 25, 40, 132, 208) // #17
535
SpriteFrame(-14, -20, 25, 40, 132, 208) // #18
536
537
// Amy Looking Frame "2"
538
SpriteFrame(-12, -20, 22, 40, 158, 208) // #19
539
SpriteFrame(-12, -20, 22, 40, 158, 208) // #20
540
SpriteFrame(-12, -20, 22, 40, 158, 208) // #21
541
542
// Amy Looking Frame "3"
543
SpriteFrame(-14, -20, 25, 40, 132, 208) // #22
544
SpriteFrame(-14, -20, 25, 40, 132, 208) // #23
545
SpriteFrame(-14, -20, 25, 40, 132, 208) // #24
546
547
// This used to be below LoadSpriteSheet, moved here for consistency with the rest
548
ArrayPos0 = 32
549
while ArrayPos0 < 1056
550
if Object[ArrayPos0].Type == TypeName[Amy Rose]
551
//if Stage.PlayerListPos == PLAYER_TAILS_A // Standalones/Preplus check
552
if Stage.PlayerListPos != PLAYER_SONIC_A // PLAYER_SONIC in origins
553
Object[ArrayPos0].Type = TypeName[Blank Object]
554
else
555
if Options.GameMode == MODE_TIMEATTACK
556
Object[ArrayPos0].Type = TypeName[Blank Object]
557
else
558
Object[ArrayPos0].LeftLimit = Object[ArrayPos0].XPos
559
Object[ArrayPos0].LeftLimit -= 0x1400000
560
561
Object[ArrayPos0].RightLimit = Object[ArrayPos0].XPos
562
Object[ArrayPos0].RightLimit += 0x400000
563
564
Object[ArrayPos0].DrawOrder = 4
565
end if
566
end if
567
end if
568
569
ArrayPos0++
570
loop
571
end sub
572
573
574
// ========================
575
// Editor Subs
576
// ========================
577
578
sub RSDKDraw
579
DrawSprite(0)
580
end sub
581
582
583
sub RSDKLoad
584
LoadSpriteSheet("R1/Objects.gif")
585
SpriteFrame(-11, -20, 22, 40, 34, 208) // #0 - Amy Idle
586
587
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
588
end sub
589
590