Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/Amy2.txt
1319 views
1
//-------------------Sonic CD Amy 2 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.Bounds.Left
10
#alias Object.Value4 : Object.Bounds.Right
11
#alias Object.Value5 : Object.InAir
12
#alias Object.Value6 : Object.HeartsTimer
13
#alias Object.Value7 : Object.FallBackTimer
14
15
// States
16
#alias 0 : AMY2_CHASEPLAYER
17
#alias 1 : AMY2_TRACKPLAYER
18
#alias 2 : AMY2_HUGGING
19
#alias 3 : AMY2_RECOIL
20
#alias 4 : AMY2_WAITNG_R
21
#alias 5 : AMY2_WAITNG_L
22
#alias 7 : AMY2_UNUSED
23
24
// Collision Sides
25
#alias 0 : CSIDE_FLOOR
26
27
// Gravity
28
#alias 0 : GRAVITY_GROUND
29
#alias 1 : GRAVITY_AIR
30
31
// Control Mode
32
#alias -1 : CONTROLMODE_NONE
33
34
// Fade Music States
35
#alias 3 : FADEMUSIC_SSZAMY
36
37
// Ink Effect
38
#alias 2 : INK_ALPHA
39
40
// Stage SFX
41
#alias 8 : SFX_S_GIGGLE
42
43
44
sub ObjectMain
45
// Always face Sonic
46
if Player.XPos < Object.XPos
47
Object.Direction = FACING_LEFT
48
else
49
Object.Direction = FACING_RIGHT
50
end if
51
52
if Object.FallBackTimer < 600
53
Object.FallBackTimer++
54
else
55
if Object.FallBackTimer == 600
56
// Can't run away forever!
57
58
// It's been 10 seconds of chasing Sonic already so end the level regardless if he wants it or not
59
Object.FallBackTimer = 601
60
61
// Lock Sonic's controls
62
Player.Left = false
63
Player.Right = false
64
Player.Up = false
65
Player.Down = false
66
Player.ControlMode = CONTROLMODE_NONE
67
68
CreateTempObject(TypeName[Fade Music], FADEMUSIC_SSZAMY, Object.XPos, Object.YPos)
69
end if
70
end if
71
72
switch Object.State
73
case AMY2_CHASEPLAYER
74
Object.Timer++
75
switch Object.Frame
76
case 4
77
case 6
78
if Object.Timer == 4
79
Object.Timer = 0
80
Object.Frame++
81
end if
82
break
83
84
case 5
85
case 7
86
if Object.Timer == 3
87
Object.Timer = 0
88
Object.Frame++
89
end if
90
break
91
92
end switch
93
94
if Object.Frame > 7
95
Object.Frame = 4
96
end if
97
98
if Object.Direction == FACING_RIGHT
99
// We're chasing Sonic, going right of course
100
101
if Object.XVelocity < 0x20000
102
Object.XVelocity += 0x2000
103
end if
104
105
PlayerObjectCollision(C_TOUCH, -32, -360, 4, 360)
106
if CheckResult == true
107
if Player.Gravity == GRAVITY_GROUND
108
if Player.Direction == Object.Direction
109
PlayerObjectCollision(C_TOUCH, -32, -20, 4, 20)
110
if CheckResult == true
111
if Player.Animation == ANI_SPINDASH
112
// Sonic's doing a spindash, throw Amy back (!)
113
114
Object.State = AMY2_RECOIL
115
Object.Frame = 9
116
Object.YVelocity = -0x40000
117
Object.InAir = true
118
Object.XVelocity = -0x10000
119
else
120
if Object.FallBackTimer < 600
121
Object.FallBackTimer = 601
122
Player.Left = false
123
Player.Right = false
124
Player.Up = false
125
Player.Down = false
126
Player.ControlMode = CONTROLMODE_NONE
127
128
CreateTempObject(TypeName[Fade Music], FADEMUSIC_SSZAMY, Object.XPos, Object.YPos)
129
end if
130
131
#platform: Use_Haptics
132
// Soft little nudge
133
HapticEffect(52, 0, 0, 0)
134
#endplatform
135
136
Object.State = AMY2_HUGGING
137
Object.Frame = 8
138
Object.Timer = 0
139
Player.State = Player_State_Hugged
140
PlayStageSfx(SFX_S_GIGGLE, false)
141
142
// Grant the "One Hug Is Enough" achievement
143
// -> It's possible that the player may have skipped Amy in PPZ, where the achievement is normally unlocked,
144
// so there's another opportunity here
145
SetAchievement(1, 100)
146
end if
147
else
148
Object.State = AMY2_TRACKPLAYER
149
Object.Frame = 0
150
Object.Timer = 0
151
Object.XVelocity = 0
152
end if
153
else
154
// Presumably some code should be here, given that the condition exists and all, and yet there isn't...
155
end if
156
end if
157
end if
158
159
if Object.XPos < Object.Bounds.Right
160
Object.XPos += Object.XVelocity
161
else
162
// Sonic has somehow escaped out of bounds to the left, stand still and patiently await his return
163
Object.XVelocity = 0
164
Object.XPos = Object.Bounds.Right
165
Object.State = AMY2_WAITNG_R
166
Object.Frame = 0
167
Object.Timer = 0
168
end if
169
170
else
171
172
if Object.XVelocity > -0x20000
173
Object.XVelocity -= 0x2000
174
end if
175
176
PlayerObjectCollision(C_TOUCH, -4, -360, 32, 360)
177
if CheckResult == true
178
if Player.Gravity == GRAVITY_GROUND
179
if Player.Direction == Object.Direction
180
PlayerObjectCollision(C_TOUCH, -32, -20, 4, 20)
181
if CheckResult == true
182
if Player.Animation == ANI_SPINDASH
183
// Sonic's doing a spindash, hit Amy back (!)
184
185
Object.State = AMY2_RECOIL
186
Object.Frame = 9
187
Object.YVelocity = -0x40000
188
Object.InAir = true
189
Object.XVelocity = 0x10000
190
else
191
if Object.FallBackTimer < 600
192
Object.FallBackTimer = 601
193
194
Player.Left = false
195
Player.Right = false
196
Player.Up = false
197
Player.Down = false
198
Player.ControlMode = CONTROLMODE_NONE
199
200
CreateTempObject(TypeName[Fade Music], FADEMUSIC_SSZAMY, Object.XPos, Object.YPos)
201
end if
202
203
Object.State = AMY2_HUGGING
204
Object.Frame = 8
205
Object.Timer = 0
206
Player.State = Player_State_Hugged
207
PlayStageSfx(SFX_S_GIGGLE, false)
208
209
// Unlock the "One Hug Is Enough" achievement
210
// There's a small chance you missed it in PPZ, so now you have a second chance at it here!
211
SetAchievement(1, 100)
212
213
#platform: Use_Haptics
214
HapticEffect(52, 0, 0, 0)
215
#endplatform
216
217
end if
218
else
219
Object.State = AMY2_TRACKPLAYER
220
Object.Frame = 0
221
Object.Timer = 0
222
Object.XVelocity = 0
223
end if
224
else
225
// This condition exists and yet there's no code inside of it...
226
end if
227
end if
228
end if
229
230
if Object.XPos > Object.Bounds.Left
231
Object.XPos += Object.XVelocity
232
else
233
// Sonic somehow escaped out of bounds to the right, look at him and wait
234
Object.XVelocity = 0
235
Object.XPos = Object.Bounds.Left
236
Object.State = AMY2_WAITNG_L
237
Object.Frame = 0
238
Object.Timer = 0
239
end if
240
241
end if
242
break
243
244
case AMY2_TRACKPLAYER
245
Object.Timer++
246
if Object.Timer == 12
247
Object.Timer = 0
248
Object.Frame++
249
end if
250
251
if Object.Frame > 3
252
Object.Frame = 0
253
end if
254
255
PlayerObjectCollision(C_TOUCH, -4, -360, 4, 360)
256
if CheckResult == false
257
if Player.Gravity == GRAVITY_GROUND
258
Object.State = AMY2_CHASEPLAYER
259
Object.Frame = 4
260
Object.Timer = 0
261
end if
262
else
263
if Player.Gravity == GRAVITY_AIR
264
Object.State = AMY2_CHASEPLAYER
265
Object.Frame = 4
266
Object.Timer = 0
267
end if
268
end if
269
break
270
271
case AMY2_HUGGING
272
Player.Speed = 0
273
Player.XVelocity = 0
274
Player.Direction = Object.Direction
275
break
276
277
case AMY2_RECOIL
278
if Object.YVelocity > 0
279
Object.Frame = 10
280
end if
281
282
if Object.XVelocity > 0
283
Object.XVelocity -= 0x800
284
end if
285
286
if Object.XVelocity < 0
287
Object.XVelocity += 0x800
288
end if
289
290
Object.XPos += Object.XVelocity
291
if Object.InAir == false
292
if Object.Timer == 16
293
Object.State = AMY2_CHASEPLAYER
294
Object.Frame = 4
295
Object.Timer = 0
296
else
297
Object.Timer++
298
end if
299
end if
300
break
301
302
case AMY2_WAITNG_R
303
// Staring at Sonic to the right
304
Object.Timer++
305
if Object.Timer == 12
306
Object.Timer = 0
307
Object.Frame++
308
end if
309
310
if Object.Frame > 3
311
Object.Frame = 0
312
end if
313
314
if Object.Direction == FACING_LEFT
315
Object.State = AMY2_CHASEPLAYER
316
Object.Frame = 4
317
Object.Timer = 0
318
end if
319
break
320
321
case AMY2_WAITNG_L
322
// Staring at Sonic to the Left
323
Object.Timer++
324
if Object.Timer == 12
325
Object.Timer = 0
326
Object.Frame++
327
end if
328
329
if Object.Frame > 3
330
Object.Frame = 0
331
end if
332
333
if Object.Direction == FACING_RIGHT
334
Object.State = AMY2_CHASEPLAYER
335
Object.Frame = 4
336
Object.Timer = 0
337
end if
338
break
339
340
end switch
341
342
Object.HeartsTimer++
343
344
// Wait what? State 7? Where'd that come from? This object's states end at 5!
345
// But I digress, spawn hearts at a faster rate while in state 7
346
// (Perhaps it was the hugging state? It is for PPZ's Amy, which is what this object seems to be based on)
347
if Object.State == AMY2_UNUSED
348
if Object.HeartsTimer > 15
349
CreateTempObject(TypeName[Love Heart], 0, Object.XPos, Object.YPos)
350
Object[TempObjectPos].iYPos -= 6
351
352
Object[TempObjectPos].InkEffect = INK_ALPHA
353
Object[TempObjectPos].Alpha = 255
354
355
Object.HeartsTimer = 0
356
end if
357
else
358
if Object.HeartsTimer > 41
359
CreateTempObject(TypeName[Love Heart], 0, Object.XPos, Object.YPos)
360
Object[TempObjectPos].iYPos -= 6
361
362
Object[TempObjectPos].InkEffect = INK_ALPHA
363
Object[TempObjectPos].Alpha = 255
364
365
Object.HeartsTimer = 0
366
end if
367
end if
368
369
if Object.InAir == false
370
// Track the ground
371
ObjectTileGrip(CSIDE_FLOOR, 0, 19, 0)
372
else
373
// Got launched into the air by Sonic...
374
375
// Apply air movements & gravity
376
Object.YVelocity += 0x4000
377
Object.YPos += Object.YVelocity
378
379
// See if Amy's landed yet
380
ObjectTileCollision(CSIDE_FLOOR, 0, 19, 0)
381
if CheckResult == true
382
Object.YVelocity = 0
383
Object.InAir = false
384
end if
385
end if
386
387
end sub
388
389
390
sub ObjectDraw
391
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
392
end sub
393
394
395
sub ObjectStartup
396
397
LoadSpriteSheet("R7/Objects2.gif")
398
399
// Amy Frames
400
401
// Idle Animation
402
SpriteFrame(-11, -20, 22, 40, 34, 208)
403
SpriteFrame(-11, -20, 22, 40, 57, 208)
404
SpriteFrame(-11, -20, 22, 40, 34, 208)
405
SpriteFrame(-11, -20, 22, 40, 126, 167)
406
407
// Walking Animation
408
SpriteFrame(-15, -20, 30, 40, 68, 167)
409
SpriteFrame(-10, -20, 21, 40, 149, 109)
410
SpriteFrame(-13, -20, 26, 40, 99, 167)
411
SpriteFrame(-10, -20, 21, 40, 149, 109)
412
413
// Hugging Frame, hearted eyes
414
SpriteFrame(-12, -20, 24, 40, 181, 208)
415
416
// Flown into Air Frame
417
SpriteFrame(-13, -20, 26, 40, 80, 208)
418
419
// Falling Frame
420
SpriteFrame(-12, -20, 24, 40, 107, 208)
421
422
end sub
423
424
425
// ========================
426
// Editor Subs
427
// ========================
428
429
sub RSDKDraw
430
DrawSprite(0)
431
end sub
432
433
434
sub RSDKLoad
435
// Amy 2 should never appear in a stage layout, only Amy 1 should, but may as well add a render for completeness's sake
436
437
LoadSpriteSheet("R7/Objects2.gif")
438
SpriteFrame(-11, -20, 22, 40, 34, 208)
439
440
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
441
end sub
442
443