Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Players/PlayerObject.txt
1319 views
1
//----------------Sonic CD Player Object Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Player.Value0 : Player.Rings
7
#alias Player.Value1 : Player.AbilityTimer
8
#alias Player.Value2 : Player.RollAnimationSpeed
9
#alias Player.Value3 : Player.SpeedShoesTimer
10
#alias Player.Value4 : Player.InvincibleTimer
11
#alias Player.Value5 : Player.BlinkTimer
12
#alias Player.Value6 : Player.MinRollSpeed
13
#alias Player.Value7 : Player.AnimationReserve
14
#alias Player.Value8 : Player.ScrollDelay
15
#alias Player.Value9 : Player.JumpOffset
16
#alias Player.Value10 : Player.JumpAbility
17
#alias Player.Value11 : Player.ActionPeelout
18
#alias Player.Value12 : Player.ActionSpindash
19
20
// Originally unused in the 2011 release, but Origins gave them a purpose
21
#alias Player.Value13 : Player.ForceGrounded
22
#alias Player.Value14 : Player.DropDashCharge
23
24
#alias Player.Value15 : Player.FlightVelocity
25
26
// Flailing states, v4 names explains this much better
27
#alias Player.Flailing[0] : Player.FloorSensorL
28
#alias Player.Flailing[1] : Player.FloorSensorC
29
#alias Player.Flailing[2] : Player.FloorSensorR
30
31
// LoseRing Aliases
32
#alias Object.Value0 : Object.XVelocity
33
#alias Object.Value1 : Object.YVelocity
34
35
// Warp Star Aliases
36
#alias Object[3].Value0 : WarpStar.Timer
37
#alias Object[3].DrawOrder : WarpStar.DrawOrder
38
39
// Object Score Alias
40
#alias Object[26].Value0 : ObjectScore.BadnikBonus
41
42
// Pause Menu Aliases
43
#alias Object[9].DrawOrder : PauseMenu.DrawOrder
44
#alias Object[9].Priority : PauseMenu.Priority
45
46
// Debug Mode Alias
47
#alias Object[25].Value7 : DebugMode.ButtonA
48
49
// Death Event Aliases
50
#alias Object.Value1 : DeathEvent.Text1XPos // Game or Time
51
#alias Object.Value2 : DeathEvent.Text2XPos // Over
52
#alias Object.Value3 : DeathEvent.Timer // Also used for fading
53
#alias Object.DrawOrder : DeathEvent.DrawOrder
54
#alias Object.State : DeathEvent.State
55
56
// Death Event States
57
#alias 0 : DEATHEVENT_GAMEOVER
58
#alias 1 : DEATHEVENT_TIMEOVER
59
#alias 2 : DEATHEVENT_FADEOUT
60
#alias 3 : DEATHEVENT_TIMEATTACK
61
62
// Priority
63
#alias 1 : PRIORITY_ACTIVE
64
#alias 2 : PRIORITY_ALWAYS
65
66
// Gravity
67
#alias 0 : GRAVITY_GROUND
68
#alias 1 : GRAVITY_AIR
69
70
// Player List Pos Aliases
71
#alias 0 : PLAYER_SONIC_A
72
#alias 1 : PLAYER_TAILS_A
73
#alias 2 : PLAYER_KNUCKLES_A
74
#alias 5 : PLAYER_AMY_A
75
76
// Ink
77
#alias 2 : INK_ALPHA
78
79
// Callbacks & Messages
80
#alias 2 : MESSAGE_LOSTFOCUS
81
82
// Cameras
83
#alias 0 : CAMERASTYLE_FOLLOW
84
#alias 1 : CAMERASTYLE_EXTENDED
85
#alias 2 : CAMERASTYLE_EXTENDED_OFFSET_L
86
#alias 3 : CAMERASTYLE_EXTENDED_OFFSET_R
87
#alias 4 : CAMERASTYLE_HLOCKED
88
89
// Damage Type
90
#alias 1 : DAMAGE_SHIELDED
91
#alias 2 : DAMAGE_HURT
92
#alias 3 : DAMAGE_DEATH
93
94
// Collision Modes
95
#alias 0 : CMODE_FLOOR
96
#alias 1 : CMODE_LWALL
97
#alias 2 : CMODE_ROOF
98
#alias 3 : CMODE_RWALL
99
100
// Collision Planes
101
#alias 0 : COLLISION_PLANE_A
102
103
// Collision Sides
104
#alias 0 : CSIDE_FLOOR
105
#alias 1 : CSIDE_LWALL
106
#alias 2 : CSIDE_RWALL
107
#alias 3 : CSIDE_ROOF
108
#alias 4 : CSIDE_ENTITY
109
110
// Entity Collision Effects
111
#alias 0 : ECEFFECT_NONE
112
#alias 1 : ECEFFECT_RESETSTORAGE
113
#alias 2 : ECEFFECT_BOXCOL3
114
115
// Control Modes
116
#alias -1 : CONTROLMODE_NONE
117
#alias 0 : CONTROLMODE_NORMAL
118
119
// Shield status
120
#alias 0 : NO_SHIELD
121
#alias 1 : ACTIVE_SHIELD
122
123
// Global SFX
124
#alias 0 : SFX_G_JUMP
125
#alias 3 : SFX_G_SKIDDING
126
#alias 4 : SFX_G_LOSERINGS
127
#alias 5 : SFX_G_HURT
128
#alias 6 : SFX_G_CHARGE
129
#alias 7 : SFX_G_RELEASE
130
#alias 8 : SFX_G_DESTROY
131
#alias 24 : SFX_G_FLYING
132
#alias 25 : SFX_G_TIRED
133
#alias 26 : SFX_G_OUTTAHERE
134
#alias 27 : SFX_G_SELECT
135
#alias 28 : SFX_G_DROPDASH // Origins-exclusive SFX start here
136
#alias 29 : SFX_G_HAMMERJUMP
137
#alias 30 : SFX_G_HAMMERDASH
138
#alias 31 : SFX_G_HAMMERHIT
139
#alias 32 : SFX_G_SLIDE
140
#alias 33 : SFX_G_GLIDEDROPLAND
141
#alias 34 : SFX_G_GRAB
142
143
// Game Mode Aliases
144
#alias 2 : MODE_TIMEATTACK
145
146
// Warp Destination
147
#alias 0 : WARPDEST_NONE
148
149
// Mission Functions
150
#alias 8 : RULE_MERCY_BADNIKS
151
152
// Engine Callbacks
153
#alias 13 : CALLBACK_PAUSE_REQUESTED
154
155
// Tile Info
156
#alias 8 : TILEINFO_ANGLEB
157
158
159
// Function declarations
160
161
// Main functions
162
#function Player_BadnikBreak
163
#function Player_Hit
164
#function Player_Kill
165
#function Player_ProcessUpdate
166
#function Player_State_Static
167
168
// "Physics" functions
169
#function Player_HandleRollAnimSpeed
170
#function Player_HandleWalkAnimSpeed
171
#function Player_HandleRunAnimSpeed
172
#function Player_HandleGroundMovement
173
#function Player_HandleAirFriction
174
#function Player_HandleRollDeceleration
175
#function Player_HandleAirMovement
176
#function Player_HandleOnGround
177
178
// Move Starters functions
179
#function Player_Action_Jump
180
#function Player_Action_Spindash_S2
181
#function Player_Action_Spindash_CD
182
#function Player_Action_Peelout_S2
183
#function Player_Action_Peelout_CD
184
#function Player_Action_DblJumpTails
185
186
// Player Movements
187
#function Player_State_Ground
188
#function Player_State_Air_NoDropDash // Origins function
189
#function Player_State_Air
190
#function Player_State_Roll
191
#function Player_State_RollJump // Unused - Leftover from Sonic Nexus
192
#function Player_State_LookUp
193
#function Player_State_Crouch
194
#function Player_State_Spindash_S2
195
#function Player_State_Spindash_CD
196
#function Player_State_Peelout_S2
197
#function Player_State_Peelout_CD
198
#function Player_State_Fly
199
200
// Damage and death
201
#function Player_State_GotHit
202
#function Player_State_Hurt
203
#function Player_State_OuttaHere
204
#function Player_State_Death
205
#function Player_State_Drown
206
207
// Level Gimmicks
208
#function Player_State_HangBar
209
#function Player_State_CorkscrewRun // Unused - Leftover from Sonic Nexus
210
#function Player_State_CorkscrewRoll // Unused - Leftover from Sonic Nexus
211
#function Player_State_TubeRoll
212
#function Player_State_TubeAirRoll
213
#function Player_State_SpinningTop
214
#function Player_State_Hugged
215
#function Player_State_Ramp3D
216
#function Player_State_WaterCurrent
217
#function Player_SetJumpOffset
218
#function Player_State_SizeChange
219
220
// Origins Functions
221
#function Player_HandleDropDash
222
#function Player_Action_DblJumpKnux
223
#function Player_State_GlideLeft
224
#function Player_State_GlideRight
225
#function Player_State_GlideDrop
226
#function Player_State_GlideSlide
227
#function Player_State_Climb
228
#function Player_State_LedgePullUp
229
#function Player_State_GlideLeftNoGrip
230
#function Player_State_GlideRightNoGrip
231
#function Player_CheckRoofGlide
232
#function Player_Action_GlideDrop
233
#function Player_Action_DblJumpAmy
234
#function Player_Action_HammerDash
235
#function Player_State_HammerDash
236
#function Player_SetHammerDashSpeed
237
#function Player_Setup_Startup
238
239
#function Player_ClimbBlock
240
#function Player_Unstick
241
#function Player_CancelClimb
242
#function Player_ForceNoGrip
243
#function Player_ForceGrip
244
245
// Used by badniks, if the conditions are met, they get destroyed, otherwise you get hurt
246
function Player_BadnikBreak
247
CheckEqual(Player.Animation, ANI_JUMPING)
248
TempValue0 = CheckResult
249
#platform: Use_Origins
250
CheckEqual(Player.Animation, ANI_HAMMER_JUMP)
251
TempValue0 |= CheckResult
252
CheckEqual(Player.Animation, ANI_HAMMER_DASH)
253
TempValue0 |= CheckResult
254
#endplatform
255
CheckEqual(Player.Animation, ANI_SPINDASH)
256
TempValue0 |= CheckResult
257
#platform: Use_Origins
258
CheckEqual(Player.Animation, ANI_GLIDING)
259
TempValue0 |= CheckResult
260
CheckEqual(Player.Animation, ANI_GLIDING_STOP)
261
TempValue0 |= CheckResult
262
#endplatform
263
264
ArrayPos0 = Player.EntityNo
265
ArrayPos0 += 2
266
CheckEqual(Object[ArrayPos0].Type, TypeName[Invincibility])
267
TempValue0 |= CheckResult
268
269
// you're invincible to badniks during the warping run
270
if Warp.Timer > 0
271
TempValue0 |= true
272
end if
273
274
if Player.Animation == ANI_FLYING
275
CheckGreater(Player.YPos, Object.YPos)
276
TempValue0 |= CheckResult
277
end if
278
279
#platform: Use_Origins
280
if game.playMode == BOOT_PLAYMODE_MISSION
281
if Stage.TimeEnabled == false
282
TempValue0 = false
283
end if
284
end if
285
#endplatform
286
287
if TempValue0 == true
288
ResetObjectEntity(Object.EntityNo, Flower_TypeNo, 0, Object.XPos, Object.YPos)
289
Object.DrawOrder = 4
290
291
CreateTempObject(TypeName[Smoke Puff], 0, Object.XPos, Object.YPos)
292
Object[TempObjectPos].DrawOrder = 4
293
294
CreateTempObject(TypeName[Object Score], ObjectScore.BadnikBonus, Object.XPos, Object.YPos)
295
Object[TempObjectPos].DrawOrder = 4
296
297
#platform: Use_Origins
298
TempValue0 = false
299
300
if Player.Animation == ANI_HAMMER_JUMP
301
TempValue0 = true
302
end if
303
304
if Player.Animation == ANI_HAMMER_DASH
305
TempValue0 = true
306
end if
307
308
if TempValue0 == true
309
PlaySfx(SFX_G_HAMMERHIT, false)
310
else
311
PlaySfx(SFX_G_DESTROY, false)
312
end if
313
#endplatform
314
315
#platform: Use_Standalone
316
PlaySfx(SFX_G_DESTROY, false)
317
#endplatform
318
319
if Player.YVelocity > 0
320
FlipSign(Player.YVelocity)
321
else
322
Player.YVelocity += 0xC000
323
end if
324
325
switch ObjectScore.BadnikBonus
326
case 0
327
Player.Score += 100
328
break
329
case 1
330
Player.Score += 200
331
break
332
case 2
333
Player.Score += 500
334
break
335
case 3
336
Player.Score += 1000
337
break
338
end switch
339
340
// (Normally the Badnik Bonus would be updated here, but 2011 does that in the Object Score script instead? That makes things kinda weird though, check out that script for more info)
341
342
#platform: Use_Haptics
343
HapticEffect(10, 0, 0, 0)
344
#endplatform
345
346
#platform: Use_Origins
347
TempValue0 = 0
348
game.callbackParam0 = 0
349
CheckEqual(Player.State, Player_State_Roll)
350
TempValue0 = CheckResult
351
CheckEqual(Player.State, Player_State_RollJump)
352
TempValue0 |= CheckResult
353
if TempValue0 == true
354
if Stage.PlayerListPos == PLAYER_SONIC
355
game.callbackParam0 = KILL_ENEMY_ATTR_SPINDASH
356
StageStatsUsabilityParam2 += 1
357
end if
358
end if
359
360
StageStatsUsabilityParam1 += 1
361
EngineCallback(NOTIFY_KILL_ENEMY)
362
if game.playMode == BOOT_PLAYMODE_MISSION
363
// Set during "M097 - Mercy"
364
if game.missionFunctionNo == RULE_MERCY_BADNIKS
365
game.forceKillPlayer = true
366
end if
367
end if
368
#endplatform
369
else
370
if Player.InvincibleTimer == 0
371
Player.State = Player_State_GotHit
372
373
#platform: Use_Origins
374
if game.playMode == BOOT_PLAYMODE_MISSION
375
if game.missionFunctionNo == RULE_MERCY_BADNIKS
376
game.missionValue = 1
377
end if
378
end if
379
#endplatform
380
381
if Player.XPos > Object.XPos
382
Player.Speed = 0x20000
383
else
384
Player.Speed = -0x20000
385
end if
386
end if
387
end if
388
end function
389
390
// Do you really need an explanation?
391
function Player_Hit
392
ArrayPos0 = Player.EntityNo
393
ArrayPos0 += 2
394
if Object[ArrayPos0].Type != TypeName[Invincibility]
395
if Player.InvincibleTimer == 0
396
Player.State = Player_State_GotHit
397
if Player.XPos > Object.XPos
398
Player.Speed = 0x20000
399
else
400
Player.Speed = -0x20000
401
end if
402
end if
403
end if
404
end function
405
406
// Called by block objects to see if Knuckles should climb them
407
// (Note that the block object needs to have called C_BOX3 before calling this function)
408
function Player_ClimbBlock
409
#platform: Use_Origins
410
if Player.State != Player_State_Climb
411
TempValue0 = false
412
ArrayPos0 = 32
413
if Player.State == Player_State_GlideRightNoGrip // Nothing for a left glide?
414
TempValue0 = true
415
else
416
while ArrayPos0 < 1056
417
if Object[ArrayPos0].Type == TypeName[Blank Object] // huh? maybe this is supposed to be [NoGripArea], but you can't use stage object TypeNames in global objects...
418
if Object[ArrayPos0].Value0 == true
419
TempValue0 = true
420
end if
421
end if
422
ArrayPos0++
423
loop
424
end if
425
426
if TempValue0 == false
427
if Player.Direction == FACING_LEFT
428
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_BOXCOL3)
429
else
430
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_BOXCOL3)
431
end if
432
PlaySfx(SFX_G_GRAB, false)
433
Player.State = Player_State_Climb
434
Player.Speed = 0
435
Player.XVelocity = 0
436
Player.YVelocity = 0
437
Player.Timer = 0
438
Player.Gravity = GRAVITY_AIR
439
game.callbackParam0 = 2
440
game.callbackParam1 = 0
441
game.callbackParam2 = 0
442
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
443
if Warp.Destination > 0
444
if Warp.Timer > 99
445
if Warp.Timer < 204
446
Warp.Destination = 0
447
end if
448
end if
449
Warp.Timer = 0
450
end if
451
end if
452
end if
453
#endplatform
454
end function
455
456
// These two functions are pretty similar, the former makes Knuckles cancel a climb into a glide drop, while the latter cancels a climb into normal air movement, instead
457
458
// See above, this one's p much only called by NoGripArea's
459
function Player_Unstick
460
#platform: Use_Origins
461
CallFunction(Player_Action_GlideDrop)
462
Player.PrevAnimation = ANI_GLIDING_DROP
463
Player.Frame = 2
464
#endplatform
465
end function
466
467
// See above, this one's p much only called by Bumpers
468
function Player_CancelClimb
469
#platform: Use_Origins
470
Player.Animation = ANI_WALKING
471
Player.Timer = 0
472
Player.State = Player_State_Air_NoDropDash
473
#endplatform
474
end function
475
476
// Called by No Grip Area objects to, well, force No Grip gliding
477
function Player_ForceNoGrip
478
#platform: Use_Origins
479
if Player.State == Player_State_GlideLeft
480
Player.State = Player_State_GlideLeftNoGrip
481
end if
482
483
if Player.State == Player_State_GlideRight
484
Player.State = Player_State_GlideRightNoGrip
485
end if
486
#endplatform
487
end function
488
489
// Called by No Grip Area objects to restore normal gliding
490
function Player_ForceGrip
491
#platform: Use_Origins
492
if Player.State == Player_State_GlideLeftNoGrip
493
Player.State = Player_State_GlideLeft
494
end if
495
496
if Player.State == Player_State_GlideRightNoGrip
497
Player.State = Player_State_GlideRight
498
end if
499
#endplatform
500
end function
501
502
503
// YOU DIED
504
function Player_Kill
505
PlaySfx(SFX_G_HURT, false)
506
507
Player.DrawOrder = 5
508
509
Player.Speed = 0
510
Player.XVelocity = 0
511
Player.YVelocity = -0x68000
512
513
Player.State = Player_State_Death
514
Player.Animation = ANI_DYING
515
516
Player.TileCollisions = false
517
Player.ObjectInteraction = false
518
Screen.CameraEnabled = false
519
520
#platform: Use_Haptics
521
HapticEffect(28, 0, 0, 0)
522
#endplatform
523
end function
524
525
function Player_ProcessUpdate
526
#platform: Standard
527
if Options.AttractMode == false
528
if Player.ControlMode == CONTROLMODE_NORMAL
529
if Object[9].Type == TypeName[Blank Object]
530
if KeyPress[1].Start == true
531
KeyPress[1].Start = false
532
if Options.DevMenuFlag == true
533
Stage.State = STAGE_PAUSED
534
PauseMusic()
535
PlaySfx(SFX_G_SELECT, false)
536
StopSFX(SFX_G_FLYING)
537
StopSFX(SFX_G_TIRED)
538
Object[9].Type = TypeName[Pause Menu]
539
PauseMenu.DrawOrder = 7
540
PauseMenu.Priority = PRIORITY_ALWAYS
541
else
542
EngineCallback(CALLBACK_PAUSE_REQUESTED) // ask the engine to open the "native" pause menu
543
end if
544
end if
545
end if
546
end if
547
548
ProcessPlayerControl()
549
end if
550
#endplatform
551
552
#platform: Use_Decomp
553
if Options.AttractMode == false
554
if Player.ControlMode == CONTROLMODE_NORMAL
555
if Object[9].Type == TypeName[Blank Object]
556
if Engine.Message == MESSAGE_LOSTFOCUS
557
Stage.State = STAGE_PAUSED
558
PauseMusic()
559
PlaySfx(SFX_G_SELECT, false)
560
StopSFX(SFX_G_FLYING)
561
StopSFX(SFX_G_TIRED)
562
Object[9].Type = TypeName[Pause Menu]
563
PauseMenu.DrawOrder = 7
564
PauseMenu.Priority = PRIORITY_ALWAYS
565
if Engine.FrameSkipTimer > -1
566
Engine.FrameSkipTimer = -1
567
end if
568
end if
569
end if
570
end if
571
end if
572
#endplatform
573
574
#platform: Mobile
575
if Options.AttractMode == false
576
if Options.TouchControls == true
577
if Player.ControlMode == CONTROLMODE_NORMAL
578
CheckTouchRect(0, 96, Screen.CenterX, Screen.YSize)
579
if CheckResult > -1
580
ArrayPos0 = CheckResult
581
// D-Pad XPos
582
TempValue0 = TouchScreen[ArrayPos0].XPos
583
TempValue0 -= Options.DPadX
584
// D-Pad YPos
585
TempValue1 = TouchScreen[ArrayPos0].YPos
586
TempValue1 -= 192
587
588
// tldr; check what did you touch in the d-pad
589
ATan2(TempValue2, TempValue0, TempValue1)
590
TempValue2 += 32
591
TempValue2 &= 255
592
TempValue2 >>= 6
593
switch TempValue2
594
case 0
595
KeyDown[1].Right = true
596
break
597
case 1
598
KeyDown[1].Down = true
599
break
600
case 2
601
KeyDown[1].Left = true
602
break
603
case 3
604
KeyDown[1].Up = true
605
break
606
end switch
607
end if
608
609
CheckTouchRect(Screen.CenterX, 96, Screen.XSize, 240)
610
if CheckResult > -1
611
KeyDown[1].ButtonA = true
612
end if
613
614
if DebugMode.ButtonA == false
615
KeyPress[1].ButtonA |= KeyDown[1].ButtonA
616
end if
617
618
DebugMode.ButtonA = KeyDown[1].ButtonA
619
if Object[9].Type == TypeName[Blank Object]
620
621
CheckTouchRect(240, 0, Screen.XSize, 40)
622
if CheckResult > -1
623
Stage.State = STAGE_PAUSED
624
PauseMusic()
625
PlaySfx(SFX_G_SELECT, false)
626
StopSFX(SFX_G_FLYING)
627
StopSFX(SFX_G_TIRED)
628
Object[9].Type = TypeName[Pause Menu]
629
PauseMenu.DrawOrder = 7
630
PauseMenu.Priority = PRIORITY_ALWAYS
631
if Engine.FrameSkipTimer > -1
632
Engine.FrameSkipTimer = -1
633
end if
634
635
end if
636
637
if Engine.Message == MESSAGE_LOSTFOCUS
638
Stage.State = STAGE_PAUSED
639
PauseMusic()
640
PlaySfx(SFX_G_SELECT, false)
641
StopSFX(SFX_G_FLYING)
642
StopSFX(SFX_G_TIRED)
643
Object[9].Type = TypeName[Pause Menu]
644
PauseMenu.DrawOrder = 7
645
PauseMenu.Priority = PRIORITY_ALWAYS
646
if Engine.FrameSkipTimer > -1
647
Engine.FrameSkipTimer = -1
648
end if
649
end if
650
end if
651
end if
652
else
653
if Player.ControlMode == CONTROLMODE_NORMAL
654
if Object[9].Type == TypeName[Blank Object]
655
if KeyPress[1].Start == true
656
657
KeyPress[1].Start = false
658
Stage.State = STAGE_PAUSED
659
PauseMusic()
660
PlaySfx(SFX_G_SELECT, false)
661
StopSFX(SFX_G_FLYING)
662
StopSFX(SFX_G_TIRED)
663
Object[9].Type = TypeName[Pause Menu]
664
PauseMenu.DrawOrder = 7
665
PauseMenu.Priority = PRIORITY_ALWAYS
666
if Engine.FrameSkipTimer > -1
667
Engine.FrameSkipTimer = -1
668
end if
669
end if
670
671
if Engine.Message == MESSAGE_LOSTFOCUS
672
Stage.State = STAGE_PAUSED
673
PauseMusic()
674
PlaySfx(SFX_G_SELECT, false)
675
StopSFX(SFX_G_FLYING)
676
StopSFX(SFX_G_TIRED)
677
Object[9].Type = TypeName[Pause Menu]
678
PauseMenu.DrawOrder = 7
679
PauseMenu.Priority = PRIORITY_ALWAYS
680
if Engine.FrameSkipTimer > -1
681
Engine.FrameSkipTimer = -1
682
end if
683
end if
684
end if
685
end if
686
end if
687
688
ProcessPlayerControl()
689
end if
690
#endplatform
691
692
// Speed Shoes control
693
if Player.SpeedShoesTimer > 0
694
Player.SpeedShoesTimer--
695
if Player.SpeedShoesTimer == 0
696
Player.Acceleration = 0xC00
697
Player.AirAcceleration = 0x1800
698
Player.TopSpeed = 0x60000
699
if Music.CurrentTrack == 3 // Speed Shoes
700
PlayMusic(0)
701
end if
702
end if
703
end if
704
705
// Invincibility Control
706
if Player.InvincibleTimer > 0
707
if Player.State != Player_State_Hurt
708
if Player.InvincibleTimer > 2000
709
Player.InvincibleTimer = 120
710
Player.BlinkTimer = 3
711
end if
712
end if
713
714
if Player.BlinkTimer > 0
715
Player.BlinkTimer++
716
if Player.BlinkTimer > 8
717
Player.BlinkTimer = 1
718
end if
719
if Player.BlinkTimer > 4
720
Player.Visible = false
721
else
722
Player.Visible = true
723
end if
724
end if
725
726
Player.InvincibleTimer--
727
if Player.InvincibleTimer == 0
728
Player.BlinkTimer = 0
729
Player.Visible = true
730
if Music.CurrentTrack == 2 // Invincibility
731
PlayMusic(0)
732
end if
733
if Object[+2].Type == TypeName[Invincibility]
734
switch Object[+2].PropertyValue
735
case NO_SHIELD
736
TempValue0 = Player.EntityNo
737
TempValue0 += 2
738
ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)
739
break
740
741
case ACTIVE_SHIELD
742
TempValue0 = Player.EntityNo
743
TempValue0 += 2
744
ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)
745
Object[+2].Type = TypeName[Blue Shield]
746
Object[+2].PropertyValue = ACTIVE_SHIELD
747
Object[+2].Priority = PRIORITY_ACTIVE
748
Object[+2].DrawOrder = 4
749
Object[+2].InkEffect = INK_ALPHA
750
Object[+2].Alpha = 160
751
Object[+2].XPos = Player.XPos
752
Object[+2].YPos = Player.YPos
753
break
754
755
end switch
756
end if
757
end if
758
end if
759
760
// Restore camera position after looking up / crounching
761
if Player.State != Player_State_LookUp
762
if Player.State != Player_State_Crouch
763
if Player.LookPos > 0
764
Player.LookPos -= 2
765
end if
766
767
if Player.LookPos < 0
768
Player.LookPos += 2
769
end if
770
end if
771
end if
772
773
if Warp.Timer > 0
774
Warp.Timer++
775
776
if Warp.Timer == 204
777
Screen.CameraEnabled = false
778
CreateTempObject(TypeName[Time Warp], 0, 0, 0)
779
#platform: Use_Standalone
780
Object[TempObjectPos].DrawOrder = 6
781
#endplatform
782
#platform: Use_Origins
783
Object[TempObjectPos].DrawOrder = 7
784
#endplatform
785
end if
786
end if
787
788
// Keeps the camera in place for a bit after releasing S2 Spin Dash
789
if Player.ScrollDelay > 0
790
Player.ScrollDelay--
791
if Player.ScrollDelay == 0
792
Screen.CameraStyle = CAMERASTYLE_FOLLOW
793
end if
794
end if
795
796
// Resets FlightVelocity
797
if Player.State != Player_State_Fly
798
if Player.FlightVelocity != 0
799
StopSFX(SFX_G_FLYING)
800
StopSFX(SFX_G_TIRED)
801
Player.FlightVelocity = 0
802
end if
803
end if
804
805
end function
806
807
// Do nothing!!
808
function Player_State_Static
809
CheckResult = false
810
end function
811
812
813
// Updates animation speed while rolling
814
function Player_HandleRollAnimSpeed
815
if Stage.PlayerListPos == PLAYER_TAILS_A
816
Player.RollAnimationSpeed = 120
817
else
818
Player.RollAnimationSpeed = Player.Speed
819
if Player.RollAnimationSpeed < 0
820
FlipSign(Player.RollAnimationSpeed)
821
end if
822
Player.RollAnimationSpeed *= 240
823
Player.RollAnimationSpeed /= 0x60000
824
Player.RollAnimationSpeed += 48
825
end if
826
end function
827
828
829
// Animation speed while walking
830
function Player_HandleWalkAnimSpeed
831
Player.AnimationSpeed = Player.Speed
832
if Player.AnimationSpeed < 0
833
FlipSign(Player.AnimationSpeed)
834
end if
835
Player.AnimationSpeed *= 60
836
Player.AnimationSpeed /= 0x60000
837
Player.AnimationSpeed += 20
838
end function
839
840
// Animation speed while running
841
function Player_HandleRunAnimSpeed
842
Player.AnimationSpeed = Player.Speed
843
if Player.AnimationSpeed < 0
844
FlipSign(Player.AnimationSpeed)
845
end if
846
Player.AnimationSpeed *= 80
847
Player.AnimationSpeed /= 0x60000
848
end function
849
850
// This makes you move
851
function Player_HandleGroundMovement
852
if Player.ControlLock > 0
853
Player.ControlLock--
854
Sin256(TempValue0, Player.Angle)
855
TempValue0 *= 0x2000
856
TempValue0 >>= 8
857
Player.Speed += TempValue0
858
else
859
if Player.Left == true
860
TempValue0 = Player.TopSpeed
861
FlipSign(TempValue0)
862
if Player.Speed > TempValue0
863
if Player.Speed > 0
864
if Player.CollisionMode == CMODE_FLOOR
865
// Skid
866
if Player.Speed > 0x40000
867
Player.Skidding = 16
868
end if
869
end if
870
871
if Player.Speed < 0x8000
872
Player.Speed = -0x8000
873
Player.Skidding = 0
874
else
875
Player.Speed -= 0x8000
876
end if
877
else
878
Player.Speed -= Player.Acceleration
879
Player.Skidding = 0
880
end if
881
end if
882
883
if Player.Speed <= 0
884
Player.Direction = FACING_LEFT
885
end if
886
end if
887
888
if Player.Right == true
889
if Player.Speed < Player.TopSpeed
890
if Player.Speed < 0
891
if Player.CollisionMode == CMODE_FLOOR
892
// Skid
893
if Player.Speed < -0x40000
894
Player.Skidding = 16
895
end if
896
end if
897
898
if Player.Speed > -0x8000
899
Player.Speed = 0x8000
900
Player.Skidding = 0
901
else
902
Player.Speed += 0x8000
903
end if
904
else
905
Player.Speed += Player.Acceleration
906
Player.Skidding = 0
907
end if
908
end if
909
910
if Player.Speed >= 0
911
Player.Direction = FACING_RIGHT
912
end if
913
end if
914
915
TempValue0 = Player.Left
916
TempValue0 |= Player.Right
917
if TempValue0 == false
918
//tldr, reduce speed with desaceleration, or based on angle
919
if Player.Speed > 0
920
Player.Speed -= Player.Deceleration
921
if Player.Speed < 0
922
Player.Speed = 0
923
end if
924
else
925
Player.Speed += Player.Deceleration
926
if Player.Speed > 0
927
Player.Speed = 0
928
end if
929
end if
930
931
if Player.Speed > 0x2000
932
Sin256(TempValue0, Player.Angle)
933
TempValue0 *= 0x2000
934
TempValue0 >>= 8
935
Player.Speed += TempValue0
936
end if
937
938
if Player.Speed < -0x2000
939
Sin256(TempValue0, Player.Angle)
940
TempValue0 *= 0x2000
941
TempValue0 >>= 8
942
Player.Speed += TempValue0
943
end if
944
945
if Player.Angle > 192
946
if Player.Angle < 228
947
if Player.Speed > -0x10000
948
if Player.Speed < 0x10000
949
Player.ControlLock = 30 // Lock the player to move out of the angle
950
end if
951
end if
952
end if
953
end if
954
955
if Player.Angle > 28
956
if Player.Angle < 64
957
if Player.Speed > -0x10000
958
if Player.Speed < 0x10000
959
Player.ControlLock = 30 // Lock the player to move out of the angle
960
end if
961
end if
962
end if
963
end if
964
else
965
Sin256(TempValue0, Player.Angle)
966
TempValue0 *= 0x2000
967
TempValue0 >>= 8
968
Player.Speed += TempValue0
969
970
if Player.Right == true
971
if Player.Left == false
972
if Player.Angle > 192
973
if Player.Angle < 228
974
if Player.Speed < 0x28000
975
if Player.Speed > -0x20000
976
Player.ControlLock = 30 // Lock the player to move out of the angle
977
end if
978
end if
979
end if
980
end if
981
end if
982
else
983
if Player.Left == true
984
if Player.Angle > 28
985
if Player.Angle < 64
986
if Player.Speed > -0x28000
987
if Player.Speed < 0x20000
988
Player.ControlLock = 30 // Lock the player to move out of the angle
989
end if
990
end if
991
end if
992
end if
993
end if
994
end if
995
end if
996
end if
997
end function
998
999
// Handle movement in the air
1000
function Player_HandleAirFriction
1001
if Player.YVelocity > -0x40000
1002
if Player.YVelocity < 0
1003
TempValue0 = Player.Speed
1004
TempValue0 >>= 5
1005
Player.Speed -= TempValue0
1006
end if
1007
end if
1008
TempValue0 = Player.TopSpeed
1009
FlipSign(TempValue0)
1010
1011
if Player.Speed > TempValue0
1012
if Player.Left == true
1013
Player.Speed -= Player.AirAcceleration
1014
Player.Direction = FACING_LEFT
1015
end if
1016
else
1017
if Player.Left == true
1018
Player.Direction = FACING_LEFT
1019
end if
1020
end if
1021
1022
if Player.Speed < Player.TopSpeed
1023
if Player.Right == true
1024
Player.Speed += Player.AirAcceleration
1025
Player.Direction = FACING_RIGHT
1026
end if
1027
else
1028
if Player.Right == true
1029
Player.Direction = FACING_RIGHT
1030
end if
1031
end if
1032
1033
if Options.OriginalControls == true
1034
if Player.Left == true
1035
TempValue0 = Player.TopSpeed
1036
FlipSign(TempValue0)
1037
if Player.Speed < TempValue0
1038
Player.Speed = TempValue0
1039
end if
1040
end if
1041
1042
if Player.Right == true
1043
if Player.Speed > Player.TopSpeed
1044
Player.Speed = Player.TopSpeed
1045
end if
1046
end if
1047
end if
1048
end function
1049
1050
// Handles desaceleration while rolling
1051
function Player_HandleRollDeceleration
1052
1053
if Player.Right == true
1054
if Player.Speed < 0
1055
Player.Speed += Player.RollingDeceleration
1056
end if
1057
end if
1058
1059
if Player.Left == true
1060
if Player.Speed > 0
1061
Player.Speed -= Player.RollingDeceleration
1062
end if
1063
end if
1064
1065
if Player.Speed > 0
1066
Player.Speed -= Player.AirDeceleration
1067
if Player.Speed < 0
1068
Player.Speed = 0
1069
end if
1070
1071
if Player.Speed == 0
1072
if Player.Angle > 224
1073
Player.State = Player_State_Ground
1074
end if
1075
if Player.Angle < 32
1076
Player.State = Player_State_Ground
1077
end if
1078
end if
1079
1080
Sin256(TempValue0, Player.Angle)
1081
if TempValue0 > 0
1082
Sin256(TempValue0, Player.Angle)
1083
TempValue0 *= 0x5000
1084
else
1085
Sin256(TempValue0, Player.Angle)
1086
TempValue0 *= 0x1E00
1087
end if
1088
1089
TempValue0 >>= 8
1090
Player.Speed += TempValue0
1091
else
1092
Player.Speed += Player.AirDeceleration
1093
if Player.Speed > 0
1094
Player.Speed = 0
1095
end if
1096
1097
if Player.Speed == 0
1098
if Player.Angle > 224
1099
Player.State = Player_State_Ground
1100
end if
1101
if Player.Angle < 32
1102
Player.State = Player_State_Ground
1103
end if
1104
end if
1105
1106
Sin256(TempValue0, Player.Angle)
1107
if TempValue0 < 0
1108
Sin256(TempValue0, Player.Angle)
1109
TempValue0 *= 0x5000
1110
else
1111
Sin256(TempValue0, Player.Angle)
1112
TempValue0 *= 0x1E00
1113
end if
1114
1115
TempValue0 >>= 8
1116
Player.Speed += TempValue0
1117
end if
1118
1119
if Player.Speed > 0x180000
1120
Player.Speed = 0x180000
1121
end if
1122
1123
if Player.Speed < -0x180000
1124
Player.Speed = -0x180000
1125
end if
1126
end function
1127
1128
// Movement when you fall from a cliff
1129
function Player_HandleAirMovement
1130
Player.TrackScroll = true
1131
1132
Player.YVelocity += Player.GravityStrength
1133
if Player.YVelocity < Player.JumpCap
1134
if Player.JumpHold == false
1135
if Player.Timer > 0
1136
Player.YVelocity = Player.JumpCap
1137
TempValue0 = Player.Speed
1138
TempValue0 >>= 5
1139
Player.Speed -= TempValue0
1140
end if
1141
end if
1142
end if
1143
Player.XVelocity = Player.Speed
1144
1145
if Player.Rotation < 256
1146
if Player.Rotation > 0
1147
Player.Rotation -= 4
1148
else
1149
Player.Rotation = 0
1150
end if
1151
else
1152
if Player.Rotation < 512
1153
Player.Rotation += 4
1154
else
1155
Player.Rotation = 0
1156
end if
1157
end if
1158
1159
Player.CollisionMode = CMODE_FLOOR
1160
if Player.Animation == ANI_JUMPING
1161
Player.AnimationSpeed = Player.RollAnimationSpeed
1162
end if
1163
end function
1164
1165
// Gets X and Y Velocity based on angles
1166
function Player_HandleOnGround
1167
Player.TrackScroll = false
1168
1169
Cos256(TempValue0, Player.Angle)
1170
TempValue0 *= Player.Speed
1171
TempValue0 >>= 8
1172
Player.XVelocity = TempValue0
1173
1174
Sin256(TempValue0, Player.Angle)
1175
TempValue0 *= Player.Speed
1176
TempValue0 >>= 8
1177
Player.YVelocity = TempValue0
1178
end function
1179
1180
// A classic move
1181
function Player_Action_Jump
1182
CheckResult = false
1183
if Player.CollisionMode == CMODE_FLOOR
1184
TempValue6 = Object.XPos
1185
TempValue7 = Object.YPos
1186
1187
Object.XPos = Player.XPos
1188
Object.YPos = Player.YPos
1189
TempValue0 = Player.CollisionTop
1190
TempValue0 -= 2
1191
ObjectTileCollision(CSIDE_RWALL, 0, TempValue0, 0)
1192
1193
Object.XPos = TempValue6
1194
Object.YPos = TempValue7
1195
end if
1196
1197
if CheckResult == false
1198
Player.ControlLock = 0
1199
Player.Gravity = GRAVITY_AIR
1200
Player.AbilityTimer = 8
1201
1202
Sin256(Player.XVelocity, Player.Angle)
1203
Player.XVelocity *= Player.JumpStrength
1204
Cos256(TempValue0, Player.Angle)
1205
TempValue0 *= Player.Speed
1206
Player.XVelocity += TempValue0
1207
Player.XVelocity >>= 8
1208
1209
Sin256(Player.YVelocity, Player.Angle)
1210
Player.YVelocity *= Player.Speed
1211
Cos256(TempValue0, Player.Angle)
1212
TempValue0 *= Player.JumpStrength
1213
Player.YVelocity -= TempValue0
1214
Player.YVelocity >>= 8
1215
1216
Player.Speed = Player.XVelocity
1217
Player.TrackScroll = true
1218
Player.Animation = ANI_JUMPING
1219
Player.Angle = 0
1220
Player.CollisionMode = CMODE_FLOOR
1221
Player.Timer = 1
1222
CallFunction(Player_HandleRollAnimSpeed)
1223
1224
Player.State = Player_State_Air
1225
1226
PlaySfx(SFX_G_JUMP, false)
1227
end if
1228
1229
#platform: Use_Origins
1230
if game.playMode == BOOT_PLAYMODE_CLASSIC
1231
Player.DropDashCharge = -1
1232
else
1233
Player.DropDashCharge = 0
1234
end if
1235
#endplatform
1236
end function
1237
1238
// A true Classic, but the actual spindash is set here, this only starts it
1239
function Player_Action_Spindash_S2
1240
Player.State = Player_State_Spindash_S2
1241
Player.Animation = ANI_SPINDASH
1242
Player.AbilityTimer = 0
1243
1244
PlaySfx(SFX_G_CHARGE, false)
1245
// Dust Puff Code
1246
CreateTempObject(TypeName[Dust Puff], Object.EntityNo, Player.XPos, Player.YPos)
1247
Object[TempObjectPos].iYPos = Player.CollisionBottom
1248
Object[TempObjectPos].YPos += Player.YPos
1249
Object[TempObjectPos].Frame = 4
1250
Object[TempObjectPos].DrawOrder = 4
1251
Object[TempObjectPos].Direction = Player.Direction
1252
1253
#platform: Use_Haptics
1254
HapticEffect(112, 0, 0, 0)
1255
#endplatform
1256
end function
1257
1258
// Not so classic, but the actual spindash is set here, this only starts it
1259
function Player_Action_Spindash_CD
1260
Player.State = Player_State_Spindash_CD
1261
Player.Animation = ANI_JUMPING
1262
Player.YPos += 0x50000
1263
Player.AbilityTimer = 0
1264
1265
PlaySfx(SFX_G_CHARGE, false)
1266
1267
#platform: Use_Haptics
1268
HapticEffect(112, 0, 0, 0)
1269
#endplatform
1270
end function
1271
1272
// um yesh, Sonic 2 Peel Out, this just starts it
1273
function Player_Action_Peelout_S2
1274
Player.State = Player_State_Peelout_S2
1275
Player.AbilityTimer = 0
1276
PlaySfx(SFX_G_CHARGE, false)
1277
1278
#platform: Use_Haptics
1279
HapticEffect(115, 0, 0, 0)
1280
#endplatform
1281
end function
1282
1283
// A true classic, this just starts it tho
1284
function Player_Action_Peelout_CD
1285
Player.State = Player_State_Peelout_CD
1286
Player.AbilityTimer = 0
1287
PlaySfx(SFX_G_CHARGE, false)
1288
1289
#platform: Use_Haptics
1290
HapticEffect(115, 0, 0, 0)
1291
#endplatform
1292
end function
1293
1294
// Starts flying state
1295
function Player_Action_DblJumpTails
1296
if Player.AbilityTimer > 0
1297
Player.AbilityTimer--
1298
else
1299
if Player.JumpPress == true
1300
Player.Timer = 0
1301
Player.State = Player_State_Fly
1302
Player.FlightVelocity = 0x800
1303
1304
#platform: Use_Origins
1305
game.callbackParam0 = 0 // Turned into Super Sonic (not in this game LOL)
1306
game.callbackParam1 = 1 // Used Tails' Flight
1307
game.callbackParam2 = 0 // Used Knux's Glide
1308
EngineCallback(NOTIFY_STATS_CHARA_ACTION)
1309
#endplatform
1310
1311
// check that you're not in water
1312
if Player.GravityStrength == 0x3800
1313
PlaySfx(SFX_G_FLYING, true)
1314
Player.Animation = ANI_FLYING
1315
else
1316
Player.Animation = ANI_SWIMMING
1317
end if
1318
end if
1319
end if
1320
end function
1321
1322
function Player_State_Ground
1323
if Player.Animation != ANI_SKIDDING // This handles that the skid only plays sfx once
1324
TempValue7 = true
1325
else
1326
TempValue7 = false
1327
end if
1328
1329
CallFunction(Player_HandleGroundMovement)
1330
1331
if Player.Gravity == GRAVITY_AIR
1332
1333
#platform: Use_Origins
1334
Player.State = Player_State_Air_NoDropDash
1335
#endplatform
1336
1337
#platform: Use_Standalone
1338
Player.State = Player_State_Air
1339
#endplatform
1340
1341
CallFunction(Player_HandleAirMovement)
1342
else
1343
CallFunction(Player_HandleOnGround)
1344
if Player.Speed == 0
1345
// Consumes the warp if you stop too late during warping run
1346
if Warp.Destination > WARPDEST_NONE
1347
if Warp.Timer > 99
1348
if Warp.Timer < 220
1349
Warp.Destination = WARPDEST_NONE
1350
end if
1351
end if
1352
Warp.Timer = 0
1353
end if
1354
1355
if Player.CollisionMode == CMODE_FLOOR
1356
#platform: Use_Origins
1357
switch Stage.PlayerListPos
1358
case PLAYER_SONIC_A
1359
case PLAYER_TAILS_A
1360
// Original behaviour - Outta Here (Sonic, Classic Mode only)
1361
if Player.Timer < 240
1362
Player.Animation = ANI_STOPPED
1363
Player.Timer++
1364
else // Waiting animation
1365
Player.Animation = ANI_WAITING
1366
if Stage.PlayerListPos == PLAYER_SONIC
1367
Player.Timer++
1368
if game.playMode == BOOT_PLAYMODE_CLASSIC
1369
if Player.Timer == 10620 // 177 seconds (2 minutes, 57 seconds)
1370
Player.Timer = 0
1371
1372
// This SFX is muted in Origins
1373
PlaySfx(SFX_G_OUTTAHERE, false)
1374
1375
Player.State = Player_State_OuttaHere
1376
Player.Animation = ANI_BORED
1377
end if
1378
end if
1379
end if
1380
end if
1381
break
1382
case PLAYER_KNUCKLES_A
1383
// Knuckles sparring with the air
1384
if Player.Timer < 240
1385
Player.Animation = ANI_STOPPED
1386
Player.Timer++
1387
else
1388
if Player.Timer < 570
1389
Player.Animation = ANI_WAITING
1390
Player.Timer++
1391
else
1392
if Mini_PlayerFlag == false
1393
Player.Animation = ANI_BORED
1394
Player.Timer++
1395
if Player.Timer == 842
1396
Player.Timer = 0
1397
Player.Animation = ANI_STOPPED
1398
end if
1399
else
1400
Player.Timer = 0
1401
Player.Animation = ANI_STOPPED
1402
end if
1403
end if
1404
end if
1405
break
1406
case PLAYER_AMY_A
1407
// Amy daydreaming
1408
if Player.Timer < 240
1409
Player.Animation = ANI_STOPPED
1410
Player.Timer++
1411
else
1412
if Player.Timer < 1107
1413
Player.Animation = ANI_WAITING
1414
Player.Timer++
1415
else
1416
if Mini_PlayerFlag == false
1417
Player.Animation = ANI_BORED
1418
Player.Timer++
1419
if Player.Timer >= 1152
1420
Player.Timer = 1107
1421
end if
1422
end if
1423
end if
1424
end if
1425
break
1426
end switch
1427
#endplatform
1428
1429
#platform: Use_Standalone
1430
if Player.Timer < 240
1431
Player.Animation = ANI_STOPPED
1432
Player.Timer++
1433
else // Waiting animation
1434
Player.Animation = ANI_WAITING
1435
if Stage.PlayerListPos == PLAYER_SONIC_A
1436
Player.Timer++
1437
if Player.Timer == 10620 // I'm Outta Here!
1438
Player.Timer = 0
1439
1440
PlaySfx(SFX_G_OUTTAHERE, false)
1441
1442
Player.State = Player_State_OuttaHere
1443
Player.Animation = ANI_BORED
1444
end if
1445
end if
1446
end if
1447
#endplatform
1448
1449
if Player.FloorSensorC == false
1450
if Player.FloorSensorR == false
1451
Player.Timer = 0
1452
1453
if Player.Direction == FACING_LEFT
1454
Player.Animation = ANI_FLAILINGLEFT
1455
else
1456
Player.Animation = ANI_FLAILINGRIGHT
1457
end if
1458
end if
1459
1460
if Player.FloorSensorL == false
1461
Player.Timer = 0
1462
1463
if Player.Direction == FACING_RIGHT
1464
Player.Animation = ANI_FLAILINGLEFT
1465
else
1466
Player.Animation = ANI_FLAILINGRIGHT
1467
end if
1468
end if
1469
1470
end if
1471
1472
end if
1473
else
1474
Player.Timer = 0
1475
if Player.Speed > 0
1476
if Player.Speed < 0x5F5C2
1477
Player.Animation = ANI_WALKING
1478
CallFunction(Player_HandleWalkAnimSpeed)
1479
// Consumes the warp if you stop too late during warping run, plus deletes the warp star
1480
if Warp.Destination > WARPDEST_NONE
1481
if Warp.Timer > 99
1482
if Warp.Timer < 204
1483
Warp.Destination = WARPDEST_NONE
1484
end if
1485
end if
1486
Warp.Timer = 0
1487
Object[3].Type = TypeName[Blank Object]
1488
end if
1489
else
1490
// Spawns the Warp Stars
1491
if Warp.Destination > WARPDEST_NONE
1492
if Warp.Timer == 0
1493
Warp.Timer = 1
1494
ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)
1495
WarpStar.Timer = 7
1496
WarpStar.DrawOrder = 4
1497
end if
1498
end if
1499
1500
if Player.Speed > 0x9FFFF
1501
Player.Animation = ANI_PEELOUT
1502
else
1503
Player.Animation = ANI_RUNNING
1504
end if
1505
CallFunction(Player_HandleRunAnimSpeed)
1506
end if
1507
else
1508
if Player.Speed > -0x5F5C2
1509
Player.Animation = ANI_WALKING
1510
CallFunction(Player_HandleWalkAnimSpeed)
1511
// Consumes the warp if you stop too late during warping run, plus deletes the warp star
1512
if Warp.Destination > WARPDEST_NONE
1513
if Warp.Timer > 99
1514
if Warp.Timer < 204
1515
Warp.Destination = WARPDEST_NONE
1516
end if
1517
end if
1518
Warp.Timer = 0
1519
Object[3].Type = TypeName[Blank Object]
1520
end if
1521
else
1522
// Spawns the Warp Stars
1523
if Warp.Destination > WARPDEST_NONE
1524
if Warp.Timer == 0
1525
Warp.Timer = 1
1526
ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)
1527
WarpStar.Timer = 7
1528
WarpStar.DrawOrder = 4
1529
end if
1530
end if
1531
1532
if Player.Speed < -0x9FFFF
1533
Player.Animation = ANI_PEELOUT
1534
else
1535
Player.Animation = ANI_RUNNING
1536
end if
1537
CallFunction(Player_HandleRunAnimSpeed)
1538
end if
1539
1540
end if
1541
1542
end if
1543
1544
// Skidding
1545
if Player.Skidding > 0
1546
if TempValue7 == true
1547
PlaySfx(SFX_G_SKIDDING, false)
1548
end if
1549
Player.Animation = ANI_SKIDDING
1550
Player.AnimationSpeed = 0
1551
Player.Skidding--
1552
1553
if Ring.AniCount == 0
1554
CreateTempObject(TypeName[Dust Puff], 0, Player.XPos, Player.YPos)
1555
Object[TempObjectPos].iYPos += Player.CollisionBottom
1556
Object[TempObjectPos].DrawOrder = Player.DrawOrder
1557
end if
1558
1559
if Player.Speed > 0
1560
Player.Direction = FACING_RIGHT
1561
else
1562
Player.Direction = FACING_LEFT
1563
end if
1564
end if
1565
1566
// Push, there's a small delay so 2 is our "true"
1567
if Player.CollisionMode == CMODE_FLOOR
1568
if Player.Pushing == 2
1569
Player.Animation = ANI_PUSHING
1570
Player.AnimationSpeed = 0
1571
end if
1572
end if
1573
1574
// Jump
1575
if Player.JumpPress == true
1576
CallFunction(Player_Action_Jump)
1577
else
1578
// Look Up
1579
if Player.Up == true
1580
if Player.Speed == 0
1581
if Player.Animation != ANI_FLAILINGLEFT
1582
if Player.Animation != ANI_FLAILINGRIGHT
1583
Player.State = Player_State_LookUp
1584
Player.Animation = ANI_LOOKINGUP
1585
Player.Timer = 0
1586
end if
1587
end if
1588
end if
1589
end if
1590
1591
// Crouch
1592
if Player.Down == true
1593
if Player.Speed == 0
1594
if Player.Animation != ANI_FLAILINGLEFT
1595
if Player.Animation != ANI_FLAILINGRIGHT
1596
Player.State = Player_State_Crouch
1597
Player.Animation = ANI_LOOKINGDOWN
1598
Player.Timer = 0
1599
end if
1600
end if
1601
else
1602
// Roll
1603
if Player.Left == false
1604
if Player.Right == false
1605
if Player.Speed > 0
1606
if Player.Speed > 0x8800
1607
Player.State = Player_State_Roll
1608
Player.Animation = ANI_JUMPING
1609
Player.iYPos -= Player.JumpOffset
1610
Player.AbilityTimer = 1024
1611
end if
1612
else
1613
if Player.Speed < -0x8800
1614
Player.State = Player_State_Roll
1615
Player.Animation = ANI_JUMPING
1616
Player.iYPos -= Player.JumpOffset
1617
Player.AbilityTimer = 1024
1618
end if
1619
end if
1620
end if
1621
end if
1622
end if
1623
end if
1624
end if
1625
end if
1626
end function
1627
1628
function Player_State_Air_NoDropDash // Origins function, prevents Sonic from drop dashing without jumping
1629
1630
Player.DropDashCharge = -1
1631
Player.State = Player_State_Air
1632
CallFunction(Player_State_Air)
1633
end function
1634
1635
function Player_State_Air
1636
CallFunction(Player_HandleAirFriction)
1637
#platform: Use_Origins
1638
if Stage.PlayerListPos == PLAYER_TAILS
1639
CallFunction(Player_HandleDropDash)
1640
end if
1641
#endplatform
1642
if Player.Gravity == GRAVITY_AIR // Check that you're truly in the air
1643
CallFunction(Player_HandleAirMovement)
1644
1645
// More warp stuff
1646
if Warp.Destination > WARPDEST_NONE
1647
TempValue0 = Player.YVelocity
1648
if TempValue0 < 0
1649
FlipSign(TempValue0)
1650
end if
1651
1652
if TempValue0 < 0x60000
1653
TempValue0 = Player.XVelocity
1654
if TempValue0 < 0
1655
FlipSign(TempValue0)
1656
end if
1657
1658
if TempValue0 < 0x60000
1659
TempValue0 = Player.XVelocity
1660
TempValue0 -= Warp.SpeedCompare
1661
if TempValue0 < 0
1662
FlipSign(TempValue0)
1663
end if
1664
1665
if TempValue0 > 0x40000
1666
if Warp.Timer > 99
1667
if Warp.Timer < 204
1668
Warp.Destination = WARPDEST_NONE
1669
end if
1670
end if
1671
Warp.Timer = 0
1672
end if
1673
end if
1674
end if
1675
Warp.SpeedCompare = Player.XVelocity
1676
end if
1677
1678
// changes the flailing with the walking, not sure when this is used
1679
if Player.YVelocity > 0x20000
1680
if Player.Animation == ANI_FLAILINGLEFT
1681
Player.Animation = ANI_WALKING
1682
end if
1683
if Player.Animation == ANI_FLAILINGRIGHT
1684
Player.Animation = ANI_WALKING
1685
end if
1686
end if
1687
1688
// Post-Hitting a spring
1689
if Player.Animation == ANI_BOUNCING
1690
if Player.YVelocity >= 0
1691
if Player.AnimationReserve == ANI_STOPPED
1692
Player.AnimationReserve = ANI_WALKING
1693
end if
1694
Player.Animation = Player.AnimationReserve
1695
end if
1696
end if
1697
1698
// Post Getting hurt
1699
if Player.Animation == ANI_HURT
1700
if Player.YVelocity >= 0
1701
if Player.AnimationReserve == ANI_STOPPED
1702
Player.AnimationReserve = ANI_WALKING
1703
end if
1704
Player.Animation = Player.AnimationReserve
1705
end if
1706
end if
1707
1708
// Calls the player flight function
1709
#platform: Use_Origins
1710
// Bug Details:
1711
// This segment of code was backported from Sonic 1 to (presumably) prevent the ledge roll-off ability bug that's from 2011.
1712
// -> However, this code is missing the Player.JumpAbilityState check before the second ANI_JUMPING check.
1713
// -> This basically makes it still behave like 2011 does, just more advanced (?).
1714
// -> The other checks from S1 that also do things with Player.JumpAbilityState are missing too...
1715
// -> Not really sure why it turned out this way.
1716
if Stage.PlayerListPos == PLAYER_TAILS
1717
if Player.Animation == ANI_JUMPING
1718
CallFunction(Player.JumpAbility)
1719
end if
1720
else
1721
if Player.YVelocity >= Player.JumpCap
1722
CallFunction(Player_HandleDropDash)
1723
if Player.Animation == ANI_JUMPING
1724
CallFunction(Player.JumpAbility)
1725
end if
1726
end if
1727
end if
1728
#endplatform
1729
1730
#platform: Use_Standalone
1731
if Player.Animation == ANI_JUMPING
1732
CallFunction(Player.JumpAbility)
1733
end if
1734
#endplatform
1735
else
1736
// go back to the ground silly
1737
#platform: Use_Origins
1738
if Player.DropDashCharge >= 20
1739
if Stage.PlayerListPos == PLAYER_AMY
1740
CallFunction(Player_Action_HammerDash)
1741
else
1742
CallFunction(Player_Action_Spindash_S2)
1743
end if
1744
else
1745
Player.State = Player_State_Ground
1746
CallFunction(Player_HandleOnGround)
1747
Player.Skidding = 0
1748
end if
1749
#endplatform
1750
1751
#platform: Use_Standalone
1752
Player.State = Player_State_Ground
1753
CallFunction(Player_HandleOnGround)
1754
Player.Skidding = 0
1755
#endplatform
1756
end if
1757
end function
1758
1759
function Player_State_Roll
1760
CallFunction(Player_HandleRollDeceleration)
1761
#platform: Use_Origins
1762
if Player.ForceGrounded > 0
1763
Player.Gravity = GRAVITY_GROUND
1764
Player.ForceGrounded -= 1 // ig a normal "--" wasn't good enough, huh?
1765
end if
1766
#endplatform
1767
1768
if Player.Gravity == GRAVITY_AIR
1769
1770
#platform: Use_Origins
1771
Player.State = Player_State_Air_NoDropDash
1772
#endplatform
1773
1774
#platform: Use_Standalone
1775
Player.State = Player_State_Air
1776
#endplatform
1777
1778
Player.Timer = 0
1779
CallFunction(Player_HandleAirMovement)
1780
else
1781
CallFunction(Player_HandleRollAnimSpeed)
1782
Player.AnimationSpeed = Player.RollAnimationSpeed
1783
1784
TempValue0 = Player.Speed
1785
if TempValue0 < 0
1786
FlipSign(TempValue0)
1787
end if
1788
1789
// Warp-Consuming
1790
if TempValue0 < 0x5F5C2
1791
if Warp.Destination > WARPDEST_NONE
1792
if Warp.Timer > 99
1793
if Warp.Timer < 204
1794
Warp.Destination = WARPDEST_NONE
1795
end if
1796
end if
1797
Warp.Timer = 0
1798
end if
1799
else
1800
// Spawn Warp Stars
1801
if Warp.Destination > WARPDEST_NONE
1802
if Warp.Timer == 0
1803
Warp.Timer = 1
1804
ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)
1805
WarpStar.Timer = 7
1806
WarpStar.DrawOrder = 4
1807
end if
1808
end if
1809
end if
1810
1811
CallFunction(Player_HandleOnGround)
1812
1813
if Player.JumpPress == true
1814
CallFunction(Player_Action_Jump)
1815
end if
1816
end if
1817
end function
1818
1819
// Cancels input movement (Unused leftover from Sonic Nexus (2008))
1820
function Player_State_RollJump
1821
#platform: Use_Origins
1822
// they removed roll jump lock in Plus lol
1823
if Options.AttractMode == true
1824
Player.Left = false
1825
Player.Right = false
1826
end if
1827
1828
CallFunction(Player_HandleAirFriction)
1829
if Stage.PlayerListPos == PLAYER_TAILS
1830
CallFunction(Player_HandleDropDash)
1831
else
1832
if Player.YVelocity >= Player.JumpCap
1833
CallFunction(Player_HandleDropDash)
1834
end if
1835
end if
1836
#endplatform
1837
1838
#platform: Use_Standalone
1839
Player.Left = false
1840
Player.Right = false
1841
CallFunction(Player_HandleAirFriction)
1842
#endplatform
1843
1844
1845
if Player.Gravity == GRAVITY_AIR
1846
CallFunction(Player_HandleAirMovement)
1847
else
1848
1849
#platform: Use_Origins
1850
if Player.DropDashCharge >= 20
1851
if Stage.PlayerListPos == PLAYER_AMY
1852
CallFunction(Player_Action_HammerDash)
1853
else
1854
CallFunction(Player_Action_Spindash_S2)
1855
end if
1856
else
1857
Player.State = Player_State_Ground
1858
CallFunction(Player_HandleOnGround)
1859
Player.Skidding = 0
1860
end if
1861
#endplatform
1862
1863
#platform: Use_Standalone
1864
Player.State = Player_State_Ground
1865
CallFunction(Player_HandleOnGround)
1866
Player.Skidding = 0
1867
#endplatform
1868
1869
end if
1870
end function
1871
1872
// Hey look up
1873
function Player_State_LookUp
1874
if Player.Up == false
1875
Player.State = Player_State_Ground
1876
Player.Timer = 0
1877
else
1878
if Player.Timer < 60
1879
Player.Timer++
1880
else
1881
if Player.LookPos > -112
1882
Player.LookPos -= 2
1883
end if
1884
end if
1885
1886
if Player.Gravity == GRAVITY_AIR
1887
1888
#platform: Use_Origins
1889
Player.State = Player_State_Air_NoDropDash
1890
#endplatform
1891
1892
#platform: Use_Standalone
1893
Player.State = Player_State_Air
1894
#endplatform
1895
1896
Player.Timer = 0
1897
else
1898
if Player.JumpPress == true
1899
CallFunction(Player.ActionPeelout)
1900
end if
1901
end if
1902
end if
1903
end function
1904
1905
// Hey look down
1906
function Player_State_Crouch
1907
if Player.Down == false
1908
Player.State = Player_State_Ground
1909
Player.Timer = 0
1910
else
1911
if Player.Timer < 60
1912
Player.Timer++
1913
else
1914
if Player.LookPos < 96
1915
Player.LookPos += 2
1916
end if
1917
end if
1918
1919
if Player.Gravity == GRAVITY_AIR
1920
1921
#platform: Use_Origins
1922
Player.State = Player_State_Air_NoDropDash
1923
#endplatform
1924
1925
#platform: Use_Standalone
1926
Player.State = Player_State_Air
1927
#endplatform
1928
1929
Player.Timer = 0
1930
else
1931
if Player.JumpPress == true
1932
CallFunction(Player.ActionSpindash)
1933
end if
1934
end if
1935
end if
1936
end function
1937
1938
// S2 Spin Dash code
1939
function Player_State_Spindash_S2
1940
// Keep the camera lock, cancel the spin dash
1941
if Player.Gravity == GRAVITY_AIR
1942
1943
#platform: Use_Origins
1944
Player.State = Player_State_Air_NoDropDash
1945
#endplatform
1946
1947
#platform: Use_Standalone
1948
Player.State = Player_State_Air
1949
#endplatform
1950
1951
Player.Speed = 0
1952
end if
1953
1954
// Mashing
1955
if Player.JumpPress == true
1956
if Player.AbilityTimer < 512
1957
Player.AbilityTimer += 64
1958
end if
1959
Player.Frame = 0
1960
1961
PlaySfx(SFX_G_CHARGE, false)
1962
else
1963
if Player.AbilityTimer > 0
1964
Player.AbilityTimer--
1965
end if
1966
end if
1967
1968
#platform: Use_Origins
1969
TempValue1 = Player.Down
1970
if Player.DropDashCharge >= 20
1971
Player.DropDashCharge = -1
1972
Sin256(TempValue0, Player.Angle)
1973
if Player.Direction == FACING_RIGHT
1974
if TempValue0 >= 0
1975
TempValue0 <<= 2
1976
else
1977
TempValue0 <<= 1
1978
end if
1979
else
1980
if TempValue0 >= 0
1981
TempValue0 <<= 1
1982
else
1983
TempValue0 <<= 2
1984
end if
1985
FlipSign(TempValue0)
1986
end if
1987
1988
if TempValue0 > 512
1989
TempValue0 = 512
1990
end if
1991
1992
Player.AbilityTimer = TempValue0
1993
TempValue1 = false
1994
end if
1995
1996
CheckEqual(TempValue1, false)
1997
#endplatform
1998
1999
#platform: Use_Standalone
2000
CheckEqual(Player.Down, false)
2001
#endplatform
2002
// Work around to adapt it to origins
2003
// Spin Dash release
2004
if CheckResult == true
2005
Player.Timer = 0
2006
Player.State = Player_State_Roll
2007
Player.Animation = ANI_JUMPING
2008
Player.iYPos -= Player.JumpOffset
2009
2010
Player.ScrollDelay = 15
2011
Screen.CameraStyle = CAMERASTYLE_HLOCKED
2012
2013
TempValue0 = Player.AbilityTimer
2014
TempValue0 <<= 9
2015
TempValue0 += 0x80000
2016
2017
if Player.Direction == FACING_RIGHT
2018
Player.Speed = TempValue0
2019
else
2020
Player.Speed = TempValue0
2021
FlipSign(Player.Speed)
2022
end if
2023
2024
PlaySfx(SFX_G_RELEASE, false)
2025
2026
CallFunction(Player_HandleOnGround)
2027
2028
#platform: Use_Origins
2029
Player.ForceGrounded = 6
2030
#endplatform
2031
2032
#platform: Use_Haptics
2033
HapticEffect(42, 0, 0, 0)
2034
#endplatform
2035
2036
end if
2037
end function
2038
2039
function Player_State_Spindash_CD
2040
if Player.Direction == FACING_RIGHT
2041
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L
2042
else
2043
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R
2044
end if
2045
2046
// Keep the camera lock, cancel the spin dash
2047
if Player.Gravity == GRAVITY_AIR
2048
2049
#platform: Use_Origins
2050
Player.State = Player_State_Air_NoDropDash
2051
#endplatform
2052
2053
#platform: Use_Standalone
2054
Player.State = Player_State_Air
2055
#endplatform
2056
2057
Player.Speed = 0
2058
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2059
end if
2060
2061
// Charge
2062
if Player.GravityStrength == 0x1000
2063
if Player.AbilityTimer < 0x80000
2064
Player.AbilityTimer += 0x6000
2065
end if
2066
else
2067
if Player.AbilityTimer < 0xC0000
2068
Player.AbilityTimer += 0x6000
2069
end if
2070
end if
2071
2072
// Release
2073
if Player.Down == false
2074
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2075
Player.Timer = 0
2076
2077
if Player.AbilityTimer < 0x2FAE1
2078
Player.Speed = 0
2079
Player.State = Player_State_Ground
2080
else
2081
Player.State = Player_State_Roll
2082
Player.Animation = ANI_JUMPING
2083
Player.Speed = Player.AbilityTimer
2084
2085
if Player.Direction == FACING_LEFT
2086
FlipSign(Player.Speed)
2087
end if
2088
2089
PlaySfx(SFX_G_RELEASE, false)
2090
end if
2091
CallFunction(Player_HandleOnGround)
2092
2093
#platform: Use_Haptics
2094
HapticEffect(42, 0, 0, 0)
2095
#endplatform
2096
2097
end if
2098
end function
2099
2100
2101
function Player_State_Peelout_S2
2102
// Cancels the Peel Out, keeps the camera
2103
if Player.Gravity == GRAVITY_AIR
2104
2105
#platform: Use_Origins
2106
Player.State = Player_State_Air_NoDropDash
2107
#endplatform
2108
2109
#platform: Use_Standalone
2110
Player.State = Player_State_Air
2111
#endplatform
2112
2113
Player.Speed = 0
2114
end if
2115
// Charge
2116
if Player.GravityStrength == 0x1000
2117
if Player.AbilityTimer < 0x60000
2118
Player.AbilityTimer += 0x6000
2119
end if
2120
else
2121
if Player.AbilityTimer < 0xC0000
2122
Player.AbilityTimer += 0x6000
2123
end if
2124
end if
2125
// Speed building, from walking to running then peelout
2126
if Player.AbilityTimer < 0x5F5C2
2127
Player.Animation = ANI_WALKING
2128
TempValue0 = Player.AbilityTimer
2129
TempValue0 >>= 16
2130
TempValue0 *= 80
2131
TempValue0 /= 6
2132
TempValue0 += 20
2133
else
2134
TempValue0 = Player.AbilityTimer
2135
TempValue0 >>= 16
2136
TempValue0 *= 80
2137
TempValue0 /= 6
2138
if Player.AbilityTimer > 0x9FFFF
2139
Player.Animation = ANI_PEELOUT
2140
else
2141
Player.Animation = ANI_RUNNING
2142
end if
2143
end if
2144
2145
// Release
2146
if Player.Up == false
2147
Player.ScrollDelay = 15
2148
Screen.CameraStyle = CAMERASTYLE_HLOCKED
2149
2150
Player.State = Player_State_Ground
2151
// Cancels the peel out if you didn't charged it enough
2152
if Player.AbilityTimer < 0x5F5C2
2153
Player.Speed = 0
2154
else
2155
Player.Speed = Player.AbilityTimer
2156
if Player.Direction == FACING_LEFT
2157
FlipSign(Player.Speed)
2158
end if
2159
PlaySfx(SFX_G_RELEASE, false)
2160
end if
2161
CallFunction(Player_HandleOnGround)
2162
2163
#platform: Use_Haptics
2164
HapticEffect(42, 0, 0, 0)
2165
#endplatform
2166
2167
end if
2168
Player.AnimationSpeed = TempValue0
2169
end function
2170
2171
2172
function Player_State_Peelout_CD
2173
// Moves the camera
2174
if Player.Direction == FACING_RIGHT
2175
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L
2176
else
2177
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R
2178
end if
2179
// Cancels the Peel Out, keeps the camera
2180
if Player.Gravity == GRAVITY_AIR
2181
2182
#platform: Use_Origins
2183
Player.State = Player_State_Air_NoDropDash
2184
#endplatform
2185
2186
#platform: Use_Standalone
2187
Player.State = Player_State_Air
2188
#endplatform
2189
2190
Player.Speed = 0
2191
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2192
end if
2193
2194
// Charge
2195
if Player.GravityStrength == 0x1000
2196
if Player.AbilityTimer < 0x60000
2197
Player.AbilityTimer += 0x6000
2198
end if
2199
else
2200
if Player.AbilityTimer < 0xC0000
2201
Player.AbilityTimer += 0x6000
2202
end if
2203
end if
2204
2205
// Speed building, from walking to running then peelout
2206
if Player.AbilityTimer < 0x5F5C2
2207
Player.Animation = ANI_WALKING
2208
TempValue0 = Player.AbilityTimer
2209
TempValue0 >>= 16
2210
TempValue0 *= 80
2211
TempValue0 /= 6
2212
TempValue0 += 20
2213
else
2214
TempValue0 = Player.AbilityTimer
2215
TempValue0 >>= 16
2216
TempValue0 *= 80
2217
TempValue0 /= 6
2218
if Player.AbilityTimer > 0x9FFFF
2219
Player.Animation = ANI_PEELOUT
2220
else
2221
Player.Animation = ANI_RUNNING
2222
end if
2223
end if
2224
2225
// Release
2226
if Player.Up == false
2227
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2228
2229
Player.State = Player_State_Ground
2230
// Cancels the peel out if you didn't charged it enough
2231
if Player.AbilityTimer < 0x5F5C2
2232
Player.Speed = 0
2233
else
2234
Player.Speed = Player.AbilityTimer
2235
if Player.Direction == FACING_LEFT
2236
FlipSign(Player.Speed)
2237
end if
2238
2239
PlaySfx(SFX_G_RELEASE, false)
2240
end if
2241
CallFunction(Player_HandleOnGround)
2242
2243
#platform: Use_Haptics
2244
HapticEffect(42, 0, 0, 0)
2245
#endplatform
2246
2247
end if
2248
Player.AnimationSpeed = TempValue0
2249
end function
2250
2251
// Tails flight
2252
function Player_State_Fly
2253
CallFunction(Player_HandleAirFriction)
2254
if Player.Gravity == GRAVITY_AIR
2255
Player.XVelocity = Player.Speed
2256
// Check if you have enough speed while flying to keep the warp
2257
if Warp.Destination > WARPDEST_NONE
2258
TempValue0 = Player.XVelocity
2259
if TempValue0 < 0
2260
FlipSign(TempValue0)
2261
end if
2262
2263
TempValue1 = Player.YVelocity
2264
if TempValue1 < 0
2265
FlipSign(TempValue1)
2266
end if
2267
2268
TempValue0 += TempValue1
2269
if TempValue0 < 0x40000
2270
if Warp.Timer > 99
2271
if Warp.Timer < 220
2272
Warp.Destination = WARPDEST_NONE
2273
end if
2274
end if
2275
Warp.Timer = 0
2276
end if
2277
end if
2278
2279
if Player.YVelocity < -0x10000
2280
Player.FlightVelocity = 0x800
2281
else
2282
if Player.YVelocity < 1
2283
if Player.AbilityTimer < 60
2284
Player.AbilityTimer++
2285
else
2286
Player.FlightVelocity = 0x800
2287
end if
2288
end if
2289
end if
2290
2291
Player.YVelocity += Player.FlightVelocity
2292
if Player.Timer < 480
2293
if Player.GravityStrength == 0x3800
2294
Player.Animation = ANI_FLYING
2295
else
2296
Player.Animation = ANI_SWIMMING
2297
end if
2298
2299
Player.Timer++
2300
if Player.Timer == 480
2301
if Player.GravityStrength == 0x3800
2302
Player.Animation = ANI_FLYINGTIRED
2303
StopSfx(SFX_G_FLYING)
2304
PlaySfx(SFX_G_TIRED, true)
2305
else
2306
Player.Animation = ANI_SWIMMINGTIRED
2307
end if
2308
else
2309
if Player.JumpPress == true
2310
Player.FlightVelocity = -0x2000
2311
Player.AbilityTimer = 0
2312
end if
2313
end if
2314
else
2315
if Player.GravityStrength == 0x3800
2316
Player.Animation = ANI_FLYINGTIRED
2317
else
2318
Player.Animation = ANI_SWIMMINGTIRED
2319
end if
2320
end if
2321
else
2322
Player.State = Player_State_Ground
2323
CallFunction(Player_HandleOnGround)
2324
end if
2325
2326
// If the level has a roof barrier, you're not getting too far
2327
if Player.RoofBarrier == true
2328
TempValue0 = Player.YPos
2329
TempValue0 >>= 16
2330
if TempValue0 < Player.CollisionBottom
2331
Player.YPos = Player.CollisionBottom
2332
Player.YPos <<= 16
2333
end if
2334
end if
2335
end function
2336
2337
// Player Damage
2338
function Player_State_GotHit
2339
#platform: Use_Origins
2340
TempValue1 = false
2341
if game.playMode == BOOT_PLAYMODE_MISSION
2342
if game.missionFunctionNo == RULE_MERCY_BADNIKS
2343
if game.missionValue == 1
2344
game.missionValue = 0
2345
TempValue1 = true
2346
end if
2347
end if
2348
end if
2349
#endplatform
2350
2351
ArrayPos0 = Player.EntityNo
2352
ArrayPos0 += 2
2353
// if you had a shield, remove it
2354
if Object[ArrayPos0].PropertyValue > 0
2355
TempValue0 = DAMAGE_SHIELDED
2356
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
2357
PlaySfx(SFX_G_HURT, false)
2358
else
2359
if Player.Rings == 0
2360
PlaySfx(SFX_G_HURT, false)
2361
TempValue0 = DAMAGE_DEATH
2362
else
2363
#platform: Use_Origins
2364
if TempValue1 == false
2365
PlaySfx(SFX_G_LOSERINGS, false)
2366
TempValue0 = DAMAGE_HURT
2367
end if
2368
#endplatform
2369
2370
#platform: Use_Standalone
2371
PlaySfx(SFX_G_LOSERINGS, false)
2372
TempValue0 = DAMAGE_HURT
2373
#endplatform
2374
end if
2375
end if
2376
2377
#platform: Use_Origins
2378
if TempValue1 != false
2379
TempValue0 = DAMAGE_DEATH
2380
end if
2381
#endplatform
2382
2383
switch TempValue0
2384
case DAMAGE_SHIELDED
2385
#platform: Use_Haptics
2386
HapticEffect(16, 0, 0, 0)
2387
#endplatform
2388
2389
Player.State = Player_State_Hurt
2390
Player.Animation = ANI_HURT
2391
Player.YVelocity = -0x40000
2392
Player.Gravity = GRAVITY_AIR
2393
Player.TrackScroll = true
2394
Player.InvincibleTimer = 8000
2395
2396
if Player.GravityStrength == 0x1000
2397
Player.Speed >>= 1
2398
Player.YVelocity >>= 1
2399
end if
2400
break
2401
2402
case DAMAGE_HURT
2403
#platform: Use_Haptics
2404
HapticEffect(16, 0, 0, 0)
2405
#endplatform
2406
2407
if Player.CollisionPlane == COLLISION_PLANE_A
2408
TempValue4 = 3
2409
else
2410
TempValue4 = 1
2411
end if
2412
2413
Player.State = Player_State_Hurt
2414
Player.Animation = ANI_HURT
2415
Player.YVelocity = -0x40000
2416
Player.Gravity = GRAVITY_AIR
2417
Player.TrackScroll = true
2418
Player.InvincibleTimer = 8000
2419
2420
if Player.GravityStrength == 0x1000
2421
Player.Speed >>= 1
2422
Player.YVelocity >>= 1
2423
end if
2424
// Lose ring code
2425
TempValue0 = Player.Rings
2426
if TempValue0 > 16
2427
TempValue1 = TempValue0
2428
TempValue1 -= 16
2429
TempValue0 = 16
2430
else
2431
TempValue1 = 0
2432
end if
2433
2434
if TempValue1 > 16
2435
TempValue1 = 16
2436
end if
2437
2438
TempValue3 = TempValue1
2439
TempValue3 >>= 1
2440
TempValue3 <<= 5
2441
2442
TempValue2 = 384
2443
TempValue2 -= TempValue3
2444
2445
TempValue3 >>= 4
2446
if TempValue3 == TempValue1
2447
TempValue2 += 16
2448
else
2449
TempValue2 -= 16
2450
end if
2451
2452
TempValue3 = 0
2453
while TempValue3 < TempValue1
2454
CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)
2455
Cos(Object[TempObjectPos].XVelocity, TempValue2)
2456
Sin(Object[TempObjectPos].YVelocity, TempValue2)
2457
Object[TempObjectPos].XVelocity <<= 8
2458
Object[TempObjectPos].YVelocity <<= 8
2459
Object[TempObjectPos].DrawOrder = TempValue4
2460
Object[TempObjectPos].AnimationSpeed = 256
2461
TempValue3++
2462
TempValue2 += 32
2463
loop
2464
TempValue3 = TempValue0
2465
TempValue3 >>= 1
2466
TempValue3 <<= 5
2467
2468
TempValue2 = 384
2469
TempValue2 -= TempValue3
2470
2471
TempValue3 >>= 4
2472
if TempValue3 == TempValue0
2473
TempValue2 += 16
2474
else
2475
TempValue2 -= 16
2476
end if
2477
TempValue3 = 0
2478
2479
while TempValue3 < TempValue0
2480
CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)
2481
Cos(Object[TempObjectPos].XVelocity, TempValue2)
2482
Sin(Object[TempObjectPos].YVelocity, TempValue2)
2483
Object[TempObjectPos].XVelocity <<= 9
2484
Object[TempObjectPos].YVelocity <<= 9
2485
Object[TempObjectPos].DrawOrder = TempValue4
2486
Object[TempObjectPos].AnimationSpeed = 256
2487
TempValue3++
2488
TempValue2 += 32
2489
loop
2490
Player.Rings = 0
2491
Ring.ExtraLife = 100
2492
break
2493
2494
case DAMAGE_DEATH
2495
#platform: Use_Haptics
2496
HapticEffect(28, 0, 0, 0)
2497
#endplatform
2498
2499
Object.DrawOrder = 5
2500
Player.Speed = 0
2501
Player.YVelocity = -0x70000
2502
Player.XVelocity = 0
2503
Player.State = Player_State_Death
2504
Player.Animation = ANI_DYING
2505
2506
Player.TileCollisions = false
2507
Player.ObjectInteraction = false
2508
if Player.EntityNo == 0 // Check if it's was player 1 who died......what?
2509
Screen.CameraEnabled = false
2510
end if
2511
break
2512
end switch
2513
// lose your warp-run if you receive damage
2514
if Warp.Destination > WARPDEST_NONE
2515
if Warp.Timer > 99
2516
if Warp.Timer < 204
2517
Warp.Destination = WARPDEST_NONE
2518
end if
2519
end if
2520
Warp.Timer = 0
2521
end if
2522
end function
2523
2524
2525
function Player_State_Hurt
2526
#platform: Use_Origins
2527
Player.TileCollisions = true
2528
#endplatform
2529
if Player.Gravity == GRAVITY_AIR
2530
Player.TrackScroll = true
2531
if Player.GravityStrength == 0x3800
2532
Player.YVelocity += 0x3000
2533
else
2534
Player.YVelocity += 0xF00
2535
end if
2536
Player.XVelocity = Player.Speed
2537
else
2538
Player.State = Player_State_Ground
2539
Player.InvincibleTimer = 120
2540
Player.BlinkTimer = 3
2541
Player.Speed = 0
2542
Player.XVelocity = 0
2543
CallFunction(Player_HandleOnGround)
2544
end if
2545
end function
2546
2547
2548
function Player_State_OuttaHere
2549
// preparing to jump
2550
if Player.Timer < 140
2551
Player.Timer++
2552
else
2553
// The Jump.
2554
Player.Timer = 0
2555
Player.DrawOrder = 5
2556
2557
if Player.Direction == FACING_RIGHT
2558
Player.Speed = 0x10000
2559
Player.XVelocity = 0x10000
2560
else
2561
Player.Speed = -0x10000
2562
Player.XVelocity = -0x10000
2563
end if
2564
Player.YVelocity = -0x58000
2565
Player.State = Player_State_Death
2566
2567
Player.TileCollisions = false
2568
Player.ObjectInteraction = false
2569
2570
Screen.CameraEnabled = false
2571
end if
2572
end function
2573
2574
// YOU DIED.
2575
function Player_State_Death
2576
Player.ControlMode = CONTROLMODE_NONE
2577
Player.YVelocity += 0x3800
2578
// Don't override the bored animation
2579
if Player.Animation != ANI_BORED
2580
Player.Animation = ANI_DYING
2581
end if
2582
2583
if Player.YVelocity > 0x100000
2584
#platform: Use_Origins
2585
EngineCallback(NOTIFY_DEATH_EVENT)
2586
#endplatform
2587
2588
if Player.Lives > 0
2589
if Player.Animation == ANI_BORED // Outta Here makes an automatic game over, no lifes will save you
2590
Player.Lives = 0
2591
else
2592
2593
#platform: Use_Origins
2594
// Check that we are actually in a mode where we use lives
2595
if game.coinMode == false
2596
if game.playMode != BOOT_PLAYMODE_MISSION
2597
CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
2598
TempValue0 = CheckResult
2599
CheckEqual(game.oneStageFlag, false)
2600
TempValue0 |= CheckResult
2601
if TempValue0 != 0
2602
Player.Lives--
2603
end if
2604
end if
2605
end if
2606
#endplatform
2607
2608
#platform: Use_Standalone
2609
// In Standalone, we don't have any extra things to worry about
2610
Player.Lives--
2611
#endplatform
2612
end if
2613
end if
2614
2615
Stage.TimeEnabled = false
2616
2617
#platform: Use_Origins
2618
CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
2619
TempValue0 = CheckResult
2620
CheckNotEqual(Player.Lives, 0)
2621
TempValue0 |= CheckResult
2622
// Check if the player is replaying the stage from My Data & Rankings
2623
CheckEqual(game.oneStageFlag, false)
2624
CheckResult |= TempValue0
2625
#endplatform
2626
2627
#platform: Use_Standalone
2628
// Slight workaround to make this cleaner - the check below this comes from Origins, but we need it to always be true on standalone
2629
2630
CheckResult = true
2631
#endplatform
2632
2633
// Again, this check is new to Origins and doesn't exist in Standalone
2634
if CheckResult != false
2635
Object.Type = TypeName[Death Event]
2636
DeathEvent.DrawOrder = 7
2637
DeathEvent.Text1XPos = Screen.CenterX
2638
DeathEvent.Text1XPos -= 232
2639
DeathEvent.Text2XPos = Screen.CenterX
2640
DeathEvent.Text2XPos += 232
2641
end if
2642
2643
if Options.GameMode == MODE_TIMEATTACK
2644
DeathEvent.Timer = 0
2645
DeathEvent.State = DEATHEVENT_TIMEATTACK
2646
else
2647
if Player.Lives == 0
2648
DeathEvent.Timer = -2880
2649
DeathEvent.State = DEATHEVENT_GAMEOVER
2650
// *Technically it goes to the traditional game over in the same state
2651
PlayMusic(5)
2652
Stage.PauseEnabled = false
2653
2654
#platform: Use_Origins
2655
if game.oneStageFlag != false
2656
game.callbackResult = -1 // Reset any callback result
2657
game.callbackParam0 = 0 // 0 - Normal Retry, anything else - Show current and best time
2658
game.callbackParam1 = Stage.ListPos // Get current stage
2659
game.callbackParam2 = 0 // Unknown
2660
EngineCallback(NOTIFY_STAGE_RETRY)
2661
end if
2662
#endplatform
2663
2664
else
2665
DeathEvent.Timer = 0
2666
DeathEvent.State = DEATHEVENT_FADEOUT
2667
2668
#platform: Use_Origins
2669
// Lots of checks here, before we do anything else
2670
2671
if game.coinMode == false
2672
if game.playMode != BOOT_PLAYMODE_BOSSRUSH
2673
if Stage.Minutes == 9
2674
if Stage.Seconds == 59
2675
// Check if the player is replaying the stage from My Data & Rankings
2676
if game.oneStageFlag == false
2677
DeathEvent.Timer = -2880
2678
DeathEvent.State = DEATHEVENT_TIMEOVER
2679
2680
PlayMusic(5)
2681
Stage.PauseEnabled = false
2682
end if
2683
end if
2684
end if
2685
end if
2686
end if
2687
#endplatform
2688
2689
#platform: Use_Standalone
2690
if Stage.Minutes == 9
2691
if Stage.Seconds == 59
2692
DeathEvent.Timer = -2880
2693
DeathEvent.State = DEATHEVENT_TIMEOVER
2694
2695
PlayMusic(5)
2696
Stage.PauseEnabled = false
2697
end if
2698
end if
2699
#endplatform
2700
end if
2701
end if
2702
end if
2703
end function
2704
2705
// Same as death, just slower and without the bored or time over stuff
2706
function Player_State_Drown
2707
Player.ControlMode = CONTROLMODE_NONE
2708
Player.YVelocity += Player.GravityStrength
2709
Player.Animation = ANI_DROWNING
2710
2711
if Player.YVelocity > 0x80000
2712
#platform: Use_Origins
2713
EngineCallback(NOTIFY_DEATH_EVENT)
2714
2715
// We only subtract lives sometimes in Origins
2716
if game.coinMode == false
2717
if game.playMode != BOOT_PLAYMODE_MISSION
2718
CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
2719
TempValue0 = CheckResult
2720
CheckEqual(game.oneStageFlag, false)
2721
TempValue0 |= CheckResult
2722
if TempValue0 != false
2723
if Player.Lives > 0
2724
Player.Lives--
2725
end if
2726
end if
2727
end if
2728
end if
2729
#endplatform
2730
2731
#platform: Use_Standalone
2732
if Player.Lives > 0
2733
Player.Lives--
2734
end if
2735
#endplatform
2736
2737
Stage.TimeEnabled = false
2738
2739
Object.Type = TypeName[DeathEvent]
2740
DeathEvent.DrawOrder = 7
2741
DeathEvent.Text1XPos = Screen.CenterX
2742
DeathEvent.Text1XPos -= 232
2743
DeathEvent.Text2XPos = Screen.CenterX
2744
DeathEvent.Text2XPos += 232
2745
2746
if Options.GameMode == MODE_TIMEATTACK
2747
DeathEvent.Timer = 0
2748
DeathEvent.State = DEATHEVENT_TIMEATTACK
2749
else
2750
if Player.Lives == 0
2751
DeathEvent.Timer = -2880
2752
DeathEvent.State = DEATHEVENT_GAMEOVER
2753
2754
PlayMusic(5)
2755
Stage.PauseEnabled = false
2756
else
2757
DeathEvent.Timer = 0
2758
DeathEvent.State = DEATHEVENT_FADEOUT
2759
end if
2760
end if
2761
end if
2762
end function
2763
2764
// Wacky Workbench hanging bar gimmick
2765
function Player_State_HangBar
2766
if Player.Left == true
2767
Player.Direction = FACING_LEFT
2768
Player.Speed = -0x20000
2769
Player.AnimationSpeed = 30
2770
else
2771
if Player.Right == true
2772
Player.Direction = FACING_RIGHT
2773
Player.Speed = 0x20000
2774
Player.AnimationSpeed = 30
2775
else
2776
Player.Speed = 0
2777
Player.AnimationSpeed = 0
2778
end if
2779
end if
2780
2781
TempValue1 = Player.XPos
2782
TempValue1 >>= 16
2783
2784
TempValue2 = Player.YPos
2785
TempValue2 >>= 16
2786
TempValue2 += Player.CollisionTop
2787
// Check that you are in the hanging bar
2788
Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)
2789
if TempValue0 != 3 // seems like you're not
2790
2791
#platform: Use_Origins
2792
Player.State = Player_State_Air_NoDropDash
2793
#endplatform
2794
2795
#platform: Use_Standalone
2796
Player.State = Player_State_Air
2797
#endplatform
2798
2799
Player.Speed = 0
2800
Player.AnimationSpeed = 0
2801
Player.YVelocity = 0
2802
end if
2803
2804
// Manual Drop
2805
if Player.JumpPress == true
2806
2807
Player.State = Player_State_Air
2808
Player.YVelocity = 0
2809
Player.Speed = 0
2810
Player.AnimationSpeed = 0
2811
Player.YPos += 0x40000
2812
end if
2813
Player.XVelocity = Player.Speed
2814
// Cancel warp
2815
if Warp.Destination > WARPDEST_NONE
2816
if Warp.Timer > 99
2817
if Warp.Timer < 204
2818
Warp.Destination = WARPDEST_NONE
2819
end if
2820
end if
2821
2822
Warp.Timer = 0
2823
end if
2824
end function
2825
2826
// Unused leftover from Sonic Nexus (2008)
2827
function Player_State_CorkscrewRun
2828
Player.Angle = 0
2829
CallFunction(Player_HandleGroundMovement)
2830
Player.Animation = 34 // Corkscrew animation, it uses Nexus values and as such, it just looks like a jumbled mess in-game
2831
2832
if Player.Speed < 0x60000
2833
if Player.Speed > -0x60000
2834
Player.Animation = ANI_WALKING
2835
2836
#platform: Use_Origins
2837
Player.State = Player_State_Air_NoDropDash
2838
#endplatform
2839
2840
#platform: Use_Standalone
2841
Player.State = Player_State_Air
2842
#endplatform
2843
2844
Player.Rotation = 0
2845
2846
if Player.Speed < 0
2847
Player.Direction = FACING_LEFT
2848
end if
2849
end if
2850
end if
2851
2852
if Player.Down == true
2853
if Player.Speed > 0x199A
2854
Player.State = Player_State_CorkscrewRoll
2855
Player.Animation = ANI_JUMPING
2856
end if
2857
2858
if Player.Speed < -0x199A
2859
Player.State = Player_State_CorkscrewRoll
2860
Player.Animation = ANI_JUMPING
2861
end if
2862
end if
2863
2864
if Player.Skidding > 0
2865
if Player.Skidding == 16
2866
PlaySfx(SFX_G_DESTROY, false) // Would be Skidding SFX if using Nexus SFX list
2867
end if
2868
Player.Animation = ANI_SKIDDING
2869
Player.Skidding--
2870
end if
2871
2872
if Player.JumpPress == true
2873
CallFunction(Player_Action_Jump)
2874
else
2875
CallFunction(Player_HandleOnGround)
2876
end if
2877
end function
2878
2879
// Unused leftover from Sonic Nexus (2008)
2880
function Player_State_CorkscrewRoll
2881
Player.Angle = 0
2882
CallFunction(Player_HandleRollDeceleration)
2883
2884
if Player.Speed < 0x60000
2885
if Player.Speed > -0x60000
2886
2887
#platform: Use_Origins
2888
Player.State = Player_State_Air_NoDropDash
2889
#endplatform
2890
2891
#platform: Use_Standalone
2892
Player.State = Player_State_Air
2893
#endplatform
2894
2895
end if
2896
end if
2897
2898
if Player.JumpPress == true
2899
CallFunction(Player_Action_Jump)
2900
else
2901
CallFunction(Player_HandleOnGround)
2902
end if
2903
end function
2904
2905
// Tube Switch function
2906
function Player_State_TubeRoll
2907
#platform: Use_Origins
2908
Player.DropDashCharge = -1
2909
#endplatform
2910
if Player.Gravity == GRAVITY_AIR // end the function if you are in the air
2911
2912
#platform: Use_Origins
2913
Player.State = Player_State_Air_NoDropDash
2914
#endplatform
2915
2916
#platform: Use_Standalone
2917
Player.State = Player_State_Air
2918
#endplatform
2919
2920
Player.Timer = 0
2921
CallFunction(Player_HandleAirMovement)
2922
else
2923
if Player.Speed > 0
2924
if Player.Speed < Player.MinRollSpeed
2925
Player.Speed = Player.MinRollSpeed
2926
end if
2927
2928
if Player.Speed > 0x100000
2929
Player.Speed = 0x100000
2930
end if
2931
else
2932
TempValue0 = Player.MinRollSpeed
2933
FlipSign(TempValue0)
2934
if Player.Speed > TempValue0
2935
Player.Speed = TempValue0
2936
CallFunction(Player_HandleOnGround)
2937
end if
2938
2939
if Player.Speed < -0x100000
2940
Player.Speed = -0x100000
2941
end if
2942
end if
2943
2944
TempValue0 = Player.Speed
2945
if TempValue0 < 0
2946
FlipSign(TempValue0)
2947
end if
2948
2949
if TempValue0 < 0x5F5C2
2950
// Warp Star delete checks
2951
if Warp.Destination > WARPDEST_NONE
2952
if Warp.Timer > 99
2953
if Warp.Timer < 204
2954
Warp.Destination = WARPDEST_NONE
2955
end if
2956
end if
2957
Warp.Timer = 0
2958
end if
2959
else
2960
// Warp Star spawnning
2961
if Warp.Destination > WARPDEST_NONE
2962
if Warp.Timer == 0
2963
Warp.Timer = 1
2964
CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)
2965
WarpStar.Timer = 7
2966
WarpStar.DrawOrder = 4
2967
end if
2968
end if
2969
end if
2970
2971
CallFunction(Player_HandleRollDeceleration)
2972
CallFunction(Player_HandleRollAnimSpeed)
2973
Player.AnimationSpeed = Player.RollAnimationSpeed
2974
CallFunction(Player_HandleOnGround)
2975
end if
2976
end function
2977
2978
function Player_State_TubeAirRoll
2979
#platform: Use_Origins
2980
Player.DropDashCharge = -1
2981
#endplatform
2982
Player.Right = false
2983
Player.Left = false
2984
if Player.Gravity == GRAVITY_AIR
2985
2986
#platform: Use_Origins
2987
Player.State = Player_State_Air_NoDropDash
2988
#endplatform
2989
2990
#platform: Use_Standalone
2991
Player.State = Player_State_Air
2992
#endplatform
2993
2994
Player.Timer = 0
2995
CallFunction(Player_HandleAirMovement)
2996
else
2997
if Player.Speed > 0
2998
Player.Speed = Player.MinRollSpeed
2999
else
3000
TempValue0 = Player.MinRollSpeed
3001
FlipSign(TempValue0)
3002
Player.Speed = TempValue0
3003
end if
3004
3005
TempValue0 = Player.Speed
3006
if TempValue0 < 0
3007
FlipSign(TempValue0)
3008
end if
3009
3010
if TempValue0 < 0x5F5C2
3011
if Warp.Destination > WARPDEST_NONE
3012
if Warp.Timer > 99
3013
if Warp.Timer < 204
3014
Warp.Destination = WARPDEST_NONE
3015
end if
3016
end if
3017
Warp.Timer = 0
3018
end if
3019
else
3020
if Warp.Destination > WARPDEST_NONE
3021
if Warp.Timer == 0
3022
Warp.Timer = 1
3023
CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)
3024
WarpStar.Timer = 7
3025
WarpStar.DrawOrder = 4
3026
end if
3027
end if
3028
end if
3029
CallFunction(Player_HandleRollDeceleration)
3030
CallFunction(Player_HandleRollAnimSpeed)
3031
Player.AnimationSpeed = Player.RollAnimationSpeed
3032
CallFunction(Player_HandleOnGround)
3033
end if
3034
end function
3035
3036
// Palmtree Panic and Wacky Workbench spinning tops
3037
function Player_State_SpinningTop
3038
Player.Timer += Player.MinRollSpeed
3039
if Player.Gravity == GRAVITY_AIR // Drop from them if you get out of range
3040
3041
#platform: Use_Origins
3042
Player.State = Player_State_Air_NoDropDash
3043
#endplatform
3044
3045
#platform: Use_Standalone
3046
Player.State = Player_State_Air
3047
#endplatform
3048
3049
Player.Animation = ANI_WALKING
3050
Player.Timer = 0
3051
CallFunction(Player_HandleAirMovement)
3052
else
3053
CallFunction(Player_HandleOnGround)
3054
end if
3055
end function
3056
3057
// Amy Rose's favorite function
3058
function Player_State_Hugged
3059
if Player.Gravity == GRAVITY_AIR // No hugs if you're in the air
3060
3061
#platform: Use_Origins
3062
Player.State = Player_State_Air_NoDropDash
3063
#endplatform
3064
3065
#platform: Use_Standalone
3066
Player.State = Player_State_Air
3067
#endplatform
3068
3069
Player.Animation = ANI_WALKING
3070
Player.Timer = 0
3071
CallFunction(Player_HandleAirMovement)
3072
else
3073
CallFunction(Player_HandleOnGround)
3074
// Yes, the only thing the function does is make you wait
3075
if Player.Timer < 240
3076
Player.Animation = ANI_STOPPED
3077
Player.Timer++
3078
else
3079
Player.Animation = ANI_WAITING
3080
end if
3081
3082
// Warp cancel check
3083
if Warp.Destination > WARPDEST_NONE
3084
if Warp.Timer > 99
3085
if Warp.Timer < 204
3086
Warp.Destination = WARPDEST_NONE
3087
end if
3088
end if
3089
Warp.Timer = 0
3090
end if
3091
3092
// Get free from Amy
3093
if Player.JumpPress == true
3094
CallFunction(Player_Action_Jump)
3095
end if
3096
end if
3097
end function
3098
3099
// Palmtree Panic Ramp
3100
function Player_State_Ramp3D
3101
CallFunction(Player_HandleGroundMovement)
3102
if Player.Gravity == GRAVITY_AIR
3103
3104
#platform: Use_Origins
3105
Player.State = Player_State_Air_NoDropDash
3106
#endplatform
3107
3108
#platform: Use_Standalone
3109
Player.State = Player_State_Air
3110
#endplatform
3111
3112
Player.Timer = 0
3113
CallFunction(Player_HandleAirMovement)
3114
// Set the equivalent animation for looking to the left
3115
if Player.Direction == FACING_LEFT
3116
3117
if Player.Animation == ANI_RAMP_RUNNING3
3118
Player.Animation = ANI_RAMP_RUNNING5
3119
end if
3120
3121
if Player.Animation == ANI_RAMP_RUNNING2
3122
Player.Animation = ANI_RAMP_RUNNING6
3123
end if
3124
3125
end if
3126
else
3127
#platform: Use_Origins
3128
if Player.Animation == ANI_GLIDING
3129
Player.XVelocity = 0
3130
Player.YVelocity = 0
3131
Player.Speed = 0
3132
Player.Animation = ANI_GLIDING_STOP
3133
end if
3134
#endplatform
3135
CallFunction(Player_HandleOnGround)
3136
if Player.Speed == 0
3137
// Warp Star erase check
3138
if Warp.Destination > WARPDEST_NONE
3139
if Warp.Timer > 99
3140
if Warp.Timer < 204
3141
Warp.Destination = WARPDEST_NONE
3142
end if
3143
end if
3144
Warp.Timer = 0
3145
end if
3146
// Waiting timer while in the ramp
3147
if Player.Timer < 240
3148
Player.Animation = ANI_STOPPED
3149
Player.Timer++
3150
else
3151
Player.Animation = ANI_WAITING
3152
end if
3153
else
3154
// Set animation based on angle
3155
if Player.Angle == 0
3156
Player.Animation = ANI_RAMP_RUNNING1
3157
end if
3158
3159
if Player.Angle > 200
3160
if Player.Direction == FACING_RIGHT
3161
Player.Animation = ANI_RAMP_RUNNING3
3162
else
3163
Player.Animation = ANI_RAMP_RUNNING5
3164
end if
3165
end if
3166
3167
if Player.Angle > 216
3168
if Player.Direction == FACING_RIGHT
3169
Player.Animation = ANI_RAMP_RUNNING2
3170
else
3171
Player.Animation = ANI_RAMP_RUNNING6
3172
end if
3173
end if
3174
3175
if Player.Angle > 232
3176
Player.Animation = ANI_RAMP_RUNNING1
3177
end if
3178
3179
if Player.Angle == 192
3180
Player.Animation = ANI_RAMP_RUNNING4
3181
end if
3182
end if
3183
3184
if Player.JumpPress == true
3185
CallFunction(Player_Action_Jump)
3186
else
3187
if Player.Up == true
3188
if Player.Speed == 0
3189
Player.State = Player_State_LookUp
3190
Player.Animation = ANI_LOOKINGUP
3191
Player.Timer = 0
3192
end if
3193
end if
3194
if Player.Down == true
3195
if Player.Speed == 0
3196
Player.State = Player_State_Crouch
3197
Player.Animation = ANI_LOOKINGDOWN
3198
Player.Timer = 0
3199
else
3200
if Player.Speed > 0x199A
3201
Player.ControlLock = 0
3202
Player.State = Player_State_Roll
3203
Player.Animation = ANI_JUMPING
3204
end if
3205
3206
if Player.Speed < -0x199A
3207
Player.ControlLock = 0
3208
Player.State = Player_State_Roll
3209
Player.Animation = ANI_JUMPING
3210
end if
3211
end if
3212
end if
3213
end if
3214
end if
3215
3216
if Player.Animation != ANI_STOPPED
3217
Player.AnimationSpeed = Player.Speed
3218
if Player.AnimationSpeed < 0
3219
FlipSign(Player.AnimationSpeed)
3220
end if
3221
Player.AnimationSpeed *= 60
3222
Player.AnimationSpeed /= 0x60000
3223
Player.AnimationSpeed += 20
3224
else
3225
Player.AnimationSpeed = 0
3226
end if
3227
end function
3228
3229
3230
function Player_State_WaterCurrent
3231
Player.Gravity = GRAVITY_AIR
3232
3233
if Player.Up == true
3234
Player.YPos -= 0x20000
3235
end if
3236
3237
if Player.Down == true
3238
Player.YPos += 0x20000
3239
end if
3240
3241
if Player.Left == true
3242
Player.XPos -= 0x20000
3243
end if
3244
3245
if Player.Right == true
3246
Player.XPos += 0x20000
3247
end if
3248
end function
3249
3250
function Player_SetJumpOffset
3251
#platform: Use_Origins
3252
if Mini_PlayerFlag == true
3253
Player.JumpOffset = -1
3254
else
3255
if Stage.PlayerListPos == PLAYER_SONIC
3256
Player.JumpOffset = -5
3257
end if
3258
3259
if Stage.PlayerListPos == PLAYER_TAILS
3260
Player.JumpOffset = -1
3261
end if
3262
3263
if Stage.PlayerListPos == PLAYER_KNUCKLES
3264
Player.JumpOffset = -5
3265
end if
3266
3267
if Stage.PlayerListPos == PLAYER_AMY
3268
Player.JumpOffset = -4
3269
end if
3270
end if
3271
#endplatform
3272
end function
3273
3274
function Player_State_SizeChange
3275
Player.TileCollisions = true
3276
if Player.Gravity == GRAVITY_AIR // Knockback after touching the laser
3277
Player.TrackScroll = true
3278
Player.YVelocity += 0x3000
3279
Player.XVelocity = Player.Speed
3280
else
3281
Player.State = Player_State_Ground
3282
3283
Player.InvincibleTimer = 120
3284
Player.BlinkTimer = 3
3285
3286
Player.Speed = 0
3287
Player.XVelocity = 0
3288
3289
CallFunction(Player_HandleOnGround)
3290
if Mini_PlayerFlag == false
3291
Mini_PlayerFlag = true
3292
3293
#platform: Use_Standalone
3294
Player.JumpOffset = -1
3295
switch Stage.PlayerListPos
3296
case PLAYER_SONIC_A
3297
LoadAnimation("MiniSonic.Ani")
3298
break
3299
3300
case PLAYER_TAILS_A
3301
LoadAnimation("MiniTails.Ani")
3302
Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites
3303
break
3304
end switch
3305
#endplatform
3306
3307
#platform: Use_Origins
3308
switch Stage.PlayerListPos
3309
case PLAYER_SONIC_A
3310
LoadAnimation("MiniSonic.Ani")
3311
break
3312
3313
case PLAYER_TAILS_A
3314
LoadAnimation("MiniTails.Ani")
3315
Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites
3316
break
3317
3318
case PLAYER_KNUCKLES_A
3319
LoadAnimation("MiniKnuckles.Ani")
3320
Object[1].Type = TypeName[Blank Object] // Mini Knuckles... doesn't have tails, but set the object to blank anyway, I guess
3321
break
3322
3323
case PLAYER_AMY_A
3324
LoadAnimation("MiniAmy.Ani")
3325
Object[1].Type = TypeName[Blank Object] // Mini Amy... doesn't have tails, but set the object to blank anyway, I guess
3326
break
3327
end switch
3328
#endplatform
3329
else
3330
Mini_PlayerFlag = false
3331
3332
#platform: Use_Standalone
3333
switch Stage.PlayerListPos
3334
case PLAYER_SONIC_A
3335
LoadAnimation("Sonic.Ani")
3336
Player.JumpOffset = -5
3337
break
3338
3339
case PLAYER_TAILS_A
3340
LoadAnimation("Tails.Ani")
3341
Player.JumpOffset = -1
3342
Object[1].Type = TypeName[Tails Object] // Restore Tails's tails
3343
break
3344
end switch
3345
#endplatform
3346
3347
#platform: Use_Origins
3348
if Stage.PlayerListPos == PLAYER_SONIC
3349
LoadAnimation("Sonic.Ani")
3350
end if
3351
3352
if Stage.PlayerListPos == PLAYER_TAILS
3353
LoadAnimation("Tails.Ani")
3354
Object[1].Type = TypeName[Tails Object] // Restore Tails's tails
3355
end if
3356
3357
if Stage.PlayerListPos == PLAYER_KNUCKLES
3358
LoadAnimation("Knuckles.Ani")
3359
end if
3360
3361
if Stage.PlayerListPos == PLAYER_AMY
3362
LoadAnimation("Amy.Ani")
3363
end if
3364
#endplatform
3365
end if
3366
3367
#platform: Use_Origins
3368
CallFunction(Player_SetJumpOffset)
3369
#endplatform
3370
3371
BindPlayerToObject(0, 0)
3372
end if
3373
end function
3374
3375
3376
function Player_HandleDropDash
3377
#platform: Use_Origins
3378
if Player.DropDashCharge >= 0
3379
if Player.DropDashCharge == 0
3380
if Player.JumpPress == true
3381
if Stage.PlayerListPos == PLAYER_SONIC
3382
Player.DropDashCharge = 1
3383
else
3384
if Stage.PlayerListPos == PLAYER_AMY
3385
Player.DropDashCharge = 1
3386
else
3387
Player.DropDashCharge = -1
3388
end if
3389
end if
3390
end if
3391
else
3392
if Player.JumpHold == false
3393
if Stage.PlayerListPos == PLAYER_TAILS
3394
Player.DropDashCharge = -1
3395
else
3396
if Player.DropDashCharge >= 20
3397
Player.DropDashCharge = -1
3398
end if
3399
end if
3400
else
3401
Player.DropDashCharge++
3402
if Player.DropDashCharge == 20
3403
PlaySfx(SFX_G_DROPDASH, false)
3404
end if
3405
3406
if Player.DropDashCharge >= 20
3407
if Player.Animation == ANI_JUMPING
3408
Player.Frame = 0
3409
Player.AnimationTimer = 0
3410
Player.AnimationSpeed = 1
3411
end if
3412
end if
3413
end if
3414
end if
3415
end if
3416
#endplatform
3417
end function
3418
3419
function Player_Action_DblJumpKnux
3420
#platform: Use_Origins
3421
if Player.YVelocity >= Player.JumpCap
3422
if Player.JumpPress == true
3423
game.callbackParam0 = 1
3424
game.callbackParam1 = 0
3425
game.callbackParam2 = 0
3426
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
3427
Player.Speed = 0x40000
3428
if Player.YVelocity < 0
3429
Player.YVelocity = 0
3430
end if
3431
if Player.Direction == FACING_RIGHT
3432
Player.State = Player_State_GlideRight
3433
Player.XVelocity = 0x40000
3434
Player.Timer = 0
3435
else
3436
Player.State = Player_State_GlideLeft
3437
Player.XVelocity = -0x40000
3438
Player.Timer = 256
3439
end if
3440
Player.Animation = ANI_GLIDING
3441
Player.Frame = 2
3442
Object.Frame = 2
3443
end if
3444
end if
3445
#endplatform
3446
end function
3447
3448
3449
function Player_State_GlideLeft
3450
#platform: Use_Origins
3451
if Player.Speed == 0
3452
if Warp.Destination > 0
3453
if Warp.Timer > 99
3454
if Warp.Timer < 204
3455
Warp.Destination = 0
3456
end if
3457
end if
3458
Warp.Timer = 0
3459
end if
3460
end if
3461
3462
if Player.Gravity == GRAVITY_AIR
3463
if Player.JumpHold == true
3464
if Player.Timer == 256
3465
if Player.Speed < 0x180000
3466
Player.Speed += 0x400
3467
end if
3468
else
3469
if Player.Speed < 0x40000
3470
Player.Speed += 0x1000
3471
end if
3472
end if
3473
3474
if Player.YVelocity > 0x8000
3475
Player.YVelocity -= 0x2000
3476
else
3477
Player.YVelocity += 0x2000
3478
end if
3479
3480
if Player.Timer < 256
3481
Player.Timer += 4
3482
end if
3483
3484
if Player.Timer < 170
3485
if Player.Timer > 86
3486
Player.Frame = 0
3487
else
3488
if Player.Timer > 44
3489
Player.Frame = 1
3490
else
3491
Player.Frame = 2
3492
end if
3493
end if
3494
else
3495
if Player.Timer < 212
3496
Player.Frame = 1
3497
else
3498
Player.Frame = 2
3499
end if
3500
end if
3501
3502
TempValue7 = Player.XPos
3503
if Player.Timer < 128
3504
Player.Direction = FACING_RIGHT
3505
TempValue0 = false
3506
TempValue1 = false
3507
else
3508
Player.Direction = FACING_LEFT
3509
Player.XPos = TempValue7
3510
Player.XPos += Player.XVelocity
3511
Player.YPos = Player.YPos
3512
Object.XPos = Player.XPos
3513
Object.YPos = Player.YPos
3514
ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)
3515
Player.XPos = Object.XPos
3516
TempValue0 = CheckResult
3517
TempValue2 = Player.XPos
3518
Player.XPos = TempValue7
3519
Player.XPos += Player.XVelocity
3520
Object.XPos = Player.XPos
3521
Object.YPos = Player.YPos
3522
ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)
3523
Player.XPos = Object.XPos
3524
TempValue1 = CheckResult
3525
TempValue3 = Player.XPos
3526
end if
3527
3528
Cos(Player.XVelocity, Player.Timer)
3529
Player.XVelocity *= Player.Speed
3530
Player.XVelocity >>= 9
3531
if Player.Right == true
3532
Player.State = Player_State_GlideRight
3533
3534
if Warp.Destination > 0
3535
if Warp.Timer > 99
3536
if Warp.Timer < 204
3537
Warp.Destination = 0
3538
end if
3539
end if
3540
Warp.Timer = 0
3541
end if
3542
end if
3543
3544
Player.XPos = TempValue7
3545
CheckResult = TempValue0
3546
CheckResult &= TempValue1
3547
if CheckResult == true
3548
if TempValue2 == TempValue3
3549
if Player.XVelocity > 0
3550
Player.Direction = FACING_RIGHT
3551
end if
3552
Player.State = Player_State_Climb
3553
Player.Speed = 0
3554
Player.XVelocity = 0
3555
Player.YVelocity = 0
3556
Player.Timer = 0
3557
PlaySfx(SFX_G_GRAB, false)
3558
game.callbackParam0 = 2
3559
game.callbackParam1 = 0
3560
game.callbackParam2 = 0
3561
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
3562
if Warp.Destination > 0
3563
if Warp.Timer > 99
3564
if Warp.Timer < 204
3565
Warp.Destination = 0
3566
end if
3567
end if
3568
Warp.Timer = 0
3569
end if
3570
else
3571
Player.XVelocity >>= 2
3572
Player.Speed = Player.XVelocity
3573
CallFunction(Player_Action_GlideDrop)
3574
end if
3575
else
3576
if TempValue0 == true
3577
if TempValue1 == false
3578
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)
3579
end if
3580
3581
if CheckResult == false
3582
Player.XVelocity >>= 2
3583
Player.Speed = Player.XVelocity
3584
CallFunction(Player_Action_GlideDrop)
3585
end if
3586
end if
3587
end if
3588
else
3589
Player.XVelocity >>= 2
3590
Player.Speed = Player.XVelocity
3591
CallFunction(Player_Action_GlideDrop)
3592
end if
3593
else
3594
if Player.CollisionMode == CMODE_FLOOR
3595
Player.Timer = 0
3596
Player.State = Player_State_GlideSlide
3597
Player.Animation = ANI_GLIDING_STOP
3598
Player.Speed = Player.XVelocity
3599
else
3600
Player.State = Player_State_Ground
3601
CallFunction(Player_HandleOnGround)
3602
Player.Skidding = 0
3603
end if
3604
end if
3605
3606
CallFunction(Player_CheckRoofGlide)
3607
#endplatform
3608
end function
3609
3610
3611
function Player_State_GlideRight
3612
#platform: Use_Origins
3613
if Player.Speed == 0
3614
if Warp.Destination > 0
3615
if Warp.Timer > 99
3616
if Warp.Timer < 204
3617
Warp.Destination = 0
3618
end if
3619
end if
3620
Warp.Timer = 0
3621
end if
3622
end if
3623
3624
if Player.Gravity == GRAVITY_AIR
3625
if Player.JumpHold == true
3626
if Player.Timer == 0
3627
if Player.Speed < 0x180000
3628
Player.Speed += 0x400
3629
end if
3630
else
3631
if Player.Speed < 0x40000
3632
Player.Speed += 0x1000
3633
end if
3634
end if
3635
3636
if Player.YVelocity > 0x8000
3637
Player.YVelocity -= 0x2000
3638
else
3639
Player.YVelocity += 0x2000
3640
end if
3641
3642
if Player.Timer > 0
3643
Player.Timer -= 4
3644
end if
3645
3646
if Player.Timer < 170
3647
if Player.Timer > 86
3648
Player.Frame = 0
3649
else
3650
if Player.Timer > 44
3651
Player.Frame = 1
3652
else
3653
Player.Frame = 2
3654
end if
3655
end if
3656
else
3657
if Player.Timer < 212
3658
Player.Frame = 1
3659
else
3660
Player.Frame = 2
3661
end if
3662
end if
3663
3664
TempValue7 = Player.XPos
3665
if Player.Timer < 128
3666
Player.Direction = FACING_RIGHT
3667
Player.XPos = TempValue7
3668
Player.XPos += Player.XVelocity
3669
Player.YPos = Player.YPos
3670
Object.XPos = Player.XPos
3671
Object.YPos = Player.YPos
3672
ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)
3673
Player.XPos = Object.XPos
3674
TempValue0 = CheckResult
3675
TempValue2 = Player.XPos
3676
Player.XPos = TempValue7
3677
Player.XPos += Player.XVelocity
3678
Object.XPos = Player.XPos
3679
Object.YPos = Player.YPos
3680
ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)
3681
Player.XPos = Object.XPos
3682
TempValue1 = CheckResult
3683
TempValue3 = Player.XPos
3684
else
3685
Player.Direction = FACING_LEFT
3686
TempValue0 = false
3687
TempValue1 = false
3688
end if
3689
3690
Cos(Player.XVelocity, Player.Timer)
3691
Player.XVelocity *= Player.Speed
3692
Player.XVelocity >>= 9
3693
if Player.Left == true
3694
Player.State = Player_State_GlideLeft
3695
3696
if Warp.Destination > 0
3697
if Warp.Timer > 99
3698
if Warp.Timer < 204
3699
Warp.Destination = 0
3700
end if
3701
end if
3702
Warp.Timer = 0
3703
end if
3704
end if
3705
3706
Player.XPos = TempValue7
3707
CheckResult = TempValue0
3708
CheckResult &= TempValue1
3709
if CheckResult == true
3710
TempValue2 >>= 1
3711
TempValue3 >>= 1
3712
if TempValue2 == TempValue3
3713
if Player.XVelocity < 0
3714
Player.Direction = FACING_LEFT
3715
end if
3716
Player.State = Player_State_Climb
3717
Player.Speed = 0
3718
Player.XVelocity = 0
3719
Player.YVelocity = 0
3720
Player.Timer = 0
3721
PlaySfx(SFX_G_GRAB, false)
3722
game.callbackParam0 = 2
3723
game.callbackParam1 = 0
3724
game.callbackParam2 = 0
3725
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
3726
if Warp.Destination > 0
3727
if Warp.Timer > 99
3728
if Warp.Timer < 204
3729
Warp.Destination = 0
3730
end if
3731
end if
3732
Warp.Timer = 0
3733
end if
3734
else
3735
Player.XVelocity >>= 2
3736
Player.Speed = Player.XVelocity
3737
CallFunction(Player_Action_GlideDrop)
3738
end if
3739
else
3740
if TempValue0 == true
3741
if TempValue1 == false
3742
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)
3743
end if
3744
3745
if CheckResult == false
3746
Player.Speed = 0
3747
Player.XVelocity >>= 2
3748
Player.Speed = Player.XVelocity
3749
CallFunction(Player_Action_GlideDrop)
3750
end if
3751
end if
3752
end if
3753
else
3754
Player.XVelocity >>= 2
3755
Player.Speed = Player.XVelocity
3756
CallFunction(Player_Action_GlideDrop)
3757
end if
3758
else
3759
if Player.CollisionMode == CMODE_FLOOR
3760
Player.Timer = 0
3761
Player.State = Player_State_GlideSlide
3762
Player.Animation = ANI_GLIDING_STOP
3763
Player.Speed = Player.XVelocity
3764
else
3765
Player.State = Player_State_Ground
3766
CallFunction(Player_HandleOnGround)
3767
Player.Skidding = 0
3768
end if
3769
end if
3770
3771
CallFunction(Player_CheckRoofGlide)
3772
#endplatform
3773
end function
3774
3775
3776
function Player_State_GlideDrop
3777
#platform: Use_Origins
3778
if Player.Gravity == GRAVITY_AIR
3779
CallFunction(Player_HandleAirFriction)
3780
CallFunction(Player_HandleAirMovement)
3781
else
3782
if Player.JumpPress == true
3783
Player.XVelocity = 0
3784
Player.Speed = 0
3785
if Player.Down == true
3786
CallFunction(Player.ActionSpindash)
3787
else
3788
CallFunction(Player_Action_Jump)
3789
end if
3790
else
3791
if Player.AbilityTimer == 0
3792
PlaySfx(SFX_G_GLIDEDROPLAND, false)
3793
end if
3794
3795
Player.TrackScroll = false
3796
Player.Speed = 0
3797
Player.XVelocity = 0
3798
Player.Animation = ANI_LOOKINGDOWN
3799
Player.PrevAnimation = ANI_LOOKINGDOWN
3800
Player.Frame = 2
3801
3802
if Player.AbilityTimer < 16
3803
Player.AbilityTimer++
3804
else
3805
Player.AbilityTimer = 0
3806
Player.State = Player_State_Ground
3807
CallFunction(Player_HandleOnGround)
3808
Player.Skidding = 0
3809
if Warp.Destination > 0
3810
if Warp.Timer > 99
3811
if Warp.Timer < 204
3812
Warp.Destination = 0
3813
end if
3814
end if
3815
Warp.Timer = 0
3816
end if
3817
end if
3818
end if
3819
end if
3820
#endplatform
3821
end function
3822
3823
3824
function Player_State_GlideSlide
3825
#platform: Use_Origins
3826
if Player.Gravity == GRAVITY_GROUND
3827
if Player.Speed == 0
3828
if Player.JumpPress == true
3829
if Player.Down == true
3830
CallFunction(Player.ActionSpindash)
3831
else
3832
CallFunction(Player_Action_Jump)
3833
end if
3834
else
3835
Player.TrackScroll = false
3836
Player.Frame = 1
3837
if Player.Timer < 16
3838
Player.Timer++
3839
else
3840
Player.State = Player_State_Ground
3841
CallFunction(Player_HandleOnGround)
3842
Player.Skidding = 0
3843
end if
3844
end if
3845
else
3846
Player.Timer++
3847
TempValue0 = Player.Timer
3848
TempValue0 %= 4
3849
if TempValue0 == 0
3850
CreateTempObject(TypeName[Dust Puff], 0, Player.XPos, Player.YPos)
3851
Object[TempObjectPos].iYPos += Player.CollisionBottom
3852
Object[TempObjectPos].DrawOrder = Player.DrawOrder
3853
end if
3854
3855
Player.Timer %= 8
3856
if Player.Timer == 0
3857
PlaySfx(SFX_G_SLIDE, false)
3858
end if
3859
3860
Player.Frame = 0
3861
if Player.Speed > 0
3862
Player.Speed -= 0x2000
3863
if Player.Speed < 0
3864
Player.Speed = 0
3865
Player.Timer = 0
3866
end if
3867
else
3868
Player.Speed += 0x2000
3869
if Player.Speed > 0
3870
Player.Speed = 0
3871
Player.Timer = 0
3872
end if
3873
end if
3874
if Player.JumpHold == 0
3875
Player.Speed = 0
3876
Player.Timer = 0
3877
end if
3878
end if
3879
3880
Player.XVelocity = Player.Speed
3881
else
3882
CallFunction(Player_Action_GlideDrop)
3883
end if
3884
#endplatform
3885
end function
3886
3887
3888
function Player_State_Climb
3889
#platform: Use_Origins
3890
if Player.Gravity == GRAVITY_AIR
3891
Player.Animation = ANI_CLIMBING
3892
if Player.Up == true
3893
Player.YVelocity = -0x10000
3894
TempValue0 = Player.CollisionTop
3895
TempValue0 *= -0x10000
3896
if Player.YPos < TempValue0
3897
Player.YPos = TempValue0
3898
end if
3899
3900
Player.Timer++
3901
if Player.Timer == 4
3902
Player.Timer = 0
3903
Player.Frame++
3904
if Mini_PlayerFlag == true
3905
Player.Frame %= 2
3906
else
3907
Player.Frame %= 6
3908
end if
3909
end if
3910
else
3911
if Player.Down == true
3912
Player.YVelocity = 0x10000
3913
Player.Timer++
3914
if Player.Timer == 4
3915
Player.Timer = 0
3916
if Player.Frame < 1
3917
if Mini_PlayerFlag == true
3918
Player.Frame += 2
3919
else
3920
Player.Frame += 6
3921
end if
3922
end if
3923
Player.Frame--
3924
end if
3925
else
3926
Player.YVelocity = 0
3927
end if
3928
end if
3929
3930
if Player.JumpPress == true
3931
Player.Animation = ANI_JUMPING
3932
Player.State = Player_State_Air_NoDropDash
3933
Player.Timer = 0
3934
if Player.Direction == FACING_LEFT
3935
Player.XVelocity = 0x40000
3936
Player.Speed = 0x40000
3937
Player.Direction = FACING_RIGHT
3938
else
3939
Player.XVelocity = -0x40000
3940
Player.Speed = -0x40000
3941
Player.Direction = FACING_LEFT
3942
end if
3943
3944
Player.YVelocity = -0x40000
3945
if Player.GravityStrength != 0x3800 // (see if Knuckles is underwater)
3946
Player.XVelocity >>= 1
3947
Player.Speed >>= 1
3948
Player.YVelocity >>= 1
3949
end if
3950
else
3951
if Mini_PlayerFlag == true
3952
TempValue4 = 7
3953
TempValue5 = -6
3954
else
3955
TempValue4 = 10
3956
TempValue5 = -10
3957
end if
3958
3959
if Player.Direction == FACING_RIGHT
3960
TempValue2 = Player.XPos
3961
Object.XPos = Player.XPos
3962
Object.YPos = Player.YPos
3963
ObjectTileGrip(CSIDE_LWALL, TempValue4, TempValue5, Player.CollisionPlane)
3964
TempValue0 = CheckResult
3965
if TempValue0 == 0
3966
Player.XPos = TempValue2
3967
Object.XPos = Player.XPos
3968
ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)
3969
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, true, ECEFFECT_NONE)
3970
TempValue0 = CheckResult
3971
end if
3972
Player.XPos = Object.XPos
3973
TempValue3 = Player.XPos
3974
Player.XPos = TempValue2
3975
Object.XPos = Player.XPos
3976
Object.YPos = Player.YPos
3977
ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)
3978
Player.XPos = Object.XPos
3979
TempValue1 = CheckResult
3980
if TempValue1 == 0
3981
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)
3982
TempValue1 = CheckResult
3983
end if
3984
if Player.XPos > TempValue3
3985
Player.XPos = TempValue3
3986
end if
3987
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_RESETSTORAGE)
3988
else
3989
if Mini_PlayerFlag == true
3990
TempValue4 = -7
3991
else
3992
TempValue4 = -10
3993
end if
3994
3995
TempValue2 = Player.XPos
3996
Object.XPos = Player.XPos
3997
Object.YPos = Player.YPos
3998
ObjectTileGrip(CSIDE_RWALL, TempValue4, TempValue5, Player.CollisionPlane)
3999
TempValue0 = CheckResult
4000
if TempValue0 == 0
4001
Player.XPos = TempValue2
4002
Object.XPos = Player.XPos
4003
ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)
4004
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, true, ECEFFECT_NONE)
4005
TempValue0 = CheckResult
4006
end if
4007
Player.XPos = Object.XPos
4008
TempValue3 = Player.XPos
4009
Player.XPos = TempValue2
4010
Object.XPos = Player.XPos
4011
Object.YPos = Player.YPos
4012
ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)
4013
Player.XPos = Object.XPos
4014
TempValue1 = CheckResult
4015
if TempValue1 == 0
4016
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)
4017
TempValue1 = CheckResult
4018
end if
4019
if Player.XPos < TempValue3
4020
Player.XPos = TempValue3
4021
end if
4022
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_RESETSTORAGE)
4023
end if
4024
if TempValue0 == 0
4025
if Player.YVelocity < 0
4026
Player.XPos = TempValue2
4027
Player.Animation = ANI_LEDGEPULLUP
4028
Player.YVelocity = 0
4029
Player.Timer = 0
4030
Player.State = Player_State_LedgePullUp
4031
Player.TileCollisions = false
4032
if Player.Direction == FACING_RIGHT
4033
Player.XPos += 0x10000
4034
end if
4035
end if
4036
else
4037
if TempValue1 == 0
4038
Player.PrevAnimation = ANI_GLIDING_DROP
4039
Player.Frame = 2
4040
CallFunction(Player_Action_GlideDrop)
4041
end if
4042
end if
4043
end if
4044
else
4045
Player.Animation = ANI_WALKING
4046
Player.State = Player_State_Ground
4047
CallFunction(Player_HandleOnGround)
4048
end if
4049
#endplatform
4050
end function
4051
4052
4053
function Player_State_LedgePullUp
4054
#platform: Use_Origins
4055
switch Player.Frame
4056
case 0
4057
if Player.Timer < 5
4058
ObjectTileGrip(CSIDE_FLOOR, 12, -9, Player.CollisionPlane)
4059
Player.Timer++
4060
else
4061
Player.Timer = 0
4062
Player.Frame++
4063
if Player.Direction == FACING_RIGHT
4064
Player.XPos += 0x90000
4065
else
4066
Player.XPos -= 0x90000
4067
end if
4068
Player.YPos -= 0xA0000
4069
end if
4070
break
4071
4072
case 1
4073
if Player.Timer < 5
4074
Player.Timer++
4075
else
4076
Player.Timer = 0
4077
Player.Frame++
4078
if Player.Direction == FACING_RIGHT
4079
Player.XPos += 0x50000
4080
else
4081
Player.XPos -= 0x50000
4082
end if
4083
end if
4084
break
4085
4086
case 2
4087
if Player.Timer < 5
4088
Player.Timer++
4089
else
4090
Player.Timer = 0
4091
Player.Animation = ANI_STOPPED
4092
Player.State = Player_State_Air_NoDropDash
4093
Player.YPos -= 0x80000
4094
Player.TileCollisions = true
4095
end if
4096
break
4097
4098
end switch
4099
#endplatform
4100
end function
4101
4102
4103
function Player_State_GlideLeftNoGrip
4104
#platform: Use_Origins
4105
if Player.Gravity == GRAVITY_AIR
4106
if Player.JumpHold == true
4107
if Player.Timer == 256
4108
if Player.Speed < 0x180000
4109
Player.Speed += 0x400
4110
end if
4111
else
4112
if Player.Speed < 0x40000
4113
Player.Speed += 0x1000
4114
end if
4115
end if
4116
4117
if Player.YVelocity > 0x8000
4118
Player.YVelocity -= 0x2000
4119
else
4120
Player.YVelocity += 0x2000
4121
end if
4122
4123
if Player.Timer < 256
4124
Player.Timer += 4
4125
end if
4126
4127
if Player.Timer < 170
4128
if Player.Timer > 86
4129
Player.Frame = 0
4130
else
4131
if Player.Timer > 44
4132
Player.Frame = 1
4133
else
4134
Player.Frame = 2
4135
end if
4136
end if
4137
else
4138
if Player.Timer < 212
4139
Player.Frame = 1
4140
else
4141
Player.Frame = 2
4142
end if
4143
end if
4144
4145
TempValue7 = Player.XPos
4146
if Player.Timer < 128
4147
Player.Direction = FACING_RIGHT
4148
TempValue0 = false
4149
TempValue1 = false
4150
else
4151
Player.Direction = FACING_LEFT
4152
Player.XPos = TempValue7
4153
Player.XPos += Player.XVelocity
4154
Player.YPos = Player.YPos
4155
Object.XPos = Player.XPos
4156
Object.YPos = Player.YPos
4157
ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)
4158
Player.XPos = Object.XPos
4159
TempValue0 = CheckResult
4160
TempValue2 = Player.XPos
4161
Player.XPos = TempValue7
4162
Player.XPos += Player.XVelocity
4163
Object.XPos = Player.XPos
4164
Object.YPos = Player.YPos
4165
ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)
4166
Player.XPos = Object.XPos
4167
TempValue1 = CheckResult
4168
TempValue3 = Player.XPos
4169
end if
4170
4171
Cos(Player.XVelocity, Player.Timer)
4172
Player.XVelocity *= Player.Speed
4173
Player.XVelocity >>= 9
4174
if Player.Right == true
4175
Player.State = Player_State_GlideRightNoGrip
4176
end if
4177
4178
Player.XPos = TempValue7
4179
CheckResult = TempValue0
4180
CheckResult &= TempValue1
4181
if CheckResult == true
4182
TempValue0 = false
4183
ArrayPos0 = 32
4184
while ArrayPos0 < 1056
4185
CheckEqual(Object[ArrayPos0].Type, TypeName[Blank Object]) // huh? maybe this is supposed to be [NoGripArea], but you can't use stage object TypeNames in global objects...
4186
if CheckResult == true
4187
if Object[ArrayPos0].Value0 == true
4188
TempValue0 = true
4189
end if
4190
end if
4191
ArrayPos0++
4192
loop
4193
4194
if TempValue0 == false
4195
if TempValue2 == TempValue3
4196
else
4197
Player.XVelocity >>= 2
4198
Player.Speed = Player.XVelocity
4199
CallFunction(Player_Action_GlideDrop)
4200
end if
4201
end if
4202
end if
4203
else
4204
Player.XVelocity >>= 2
4205
Player.Speed = Player.XVelocity
4206
CallFunction(Player_Action_GlideDrop)
4207
end if
4208
else
4209
if Player.CollisionMode == CMODE_FLOOR
4210
Player.Timer = 0
4211
Player.State = Player_State_GlideSlide
4212
Player.Animation = ANI_GLIDING_STOP
4213
Player.Speed = Player.XVelocity
4214
else
4215
Player.State = Player_State_Ground
4216
CallFunction(Player_HandleOnGround)
4217
Player.Skidding = 0
4218
end if
4219
end if
4220
4221
CallFunction(Player_CheckRoofGlide)
4222
#endplatform
4223
end function
4224
4225
4226
function Player_State_GlideRightNoGrip
4227
#platform: Use_Origins
4228
if Player.Gravity == GRAVITY_AIR
4229
if Player.JumpHold == true
4230
if Player.Timer == 0
4231
if Player.Speed < 0x180000
4232
Player.Speed += 0x400
4233
end if
4234
else
4235
if Player.Speed < 0x40000
4236
Player.Speed += 0x1000
4237
end if
4238
end if
4239
4240
if Player.YVelocity > 0x8000
4241
Player.YVelocity -= 0x2000
4242
else
4243
Player.YVelocity += 0x2000
4244
end if
4245
4246
if Player.Timer > 0
4247
Player.Timer -= 4
4248
end if
4249
4250
if Player.Timer < 170
4251
if Player.Timer > 86
4252
Player.Frame = 0
4253
else
4254
if Player.Timer > 44
4255
Player.Frame = 1
4256
else
4257
Player.Frame = 2
4258
end if
4259
end if
4260
else
4261
if Player.Timer < 212
4262
Player.Frame = 1
4263
else
4264
Player.Frame = 2
4265
end if
4266
end if
4267
4268
TempValue7 = Player.XPos
4269
if Player.Timer < 128
4270
Player.Direction = FACING_RIGHT
4271
Player.XPos = TempValue7
4272
Player.XPos += Player.XVelocity
4273
Player.YPos = Player.YPos
4274
Object.XPos = Player.XPos
4275
Object.YPos = Player.YPos
4276
ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)
4277
Player.XPos = Object.XPos
4278
TempValue0 = CheckResult
4279
TempValue2 = Player.XPos
4280
Player.XPos = TempValue7
4281
Player.XPos += Player.XVelocity
4282
Object.XPos = Player.XPos
4283
Object.YPos = Player.YPos
4284
ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)
4285
Player.XPos = Object.XPos
4286
TempValue1 = CheckResult
4287
TempValue3 = Player.XPos
4288
else
4289
Player.Direction = FACING_LEFT
4290
TempValue0 = false
4291
TempValue1 = false
4292
end if
4293
4294
Cos(Player.XVelocity, Player.Timer)
4295
Player.XVelocity *= Player.Speed
4296
Player.XVelocity >>= 9
4297
if Player.Left == true
4298
Player.State = Player_State_GlideLeftNoGrip
4299
end if
4300
4301
Player.XPos = TempValue7
4302
CheckResult = TempValue0
4303
CheckResult &= TempValue1
4304
if CheckResult == true
4305
TempValue2 >>= 1
4306
TempValue3 >>= 1
4307
if TempValue2 == TempValue3
4308
else
4309
Player.XVelocity >>= 2
4310
Player.Speed = Player.XVelocity
4311
CallFunction(Player_Action_GlideDrop)
4312
end if
4313
end if
4314
else
4315
Player.XVelocity >>= 2
4316
Player.Speed = Player.XVelocity
4317
CallFunction(Player_Action_GlideDrop)
4318
end if
4319
else
4320
if Player.CollisionMode == CMODE_FLOOR
4321
Player.Timer = 0
4322
Player.State = Player_State_GlideSlide
4323
Player.Animation = ANI_GLIDING_STOP
4324
Player.Speed = Player.XVelocity
4325
else
4326
Player.State = Player_State_Ground
4327
CallFunction(Player_HandleOnGround)
4328
Player.Skidding = 0
4329
end if
4330
end if
4331
4332
CallFunction(Player_CheckRoofGlide)
4333
#endplatform
4334
end function
4335
4336
4337
function Player_CheckRoofGlide
4338
#platform: Use_Origins
4339
// This function's just here to make sure that Knuckles doesn't go above the stage in MMZ3 (not a good thing)
4340
if Stage.ActiveList == REGULAR_STAGE
4341
CheckEqual(Stage.ListPos, 68) // MMZ3C
4342
TempValue0 = CheckResult
4343
CheckEqual(Stage.ListPos, 69) // MMZ3D
4344
TempValue0 |= CheckResult
4345
if TempValue0 != false
4346
if Stage.PlayerListPos == PLAYER_KNUCKLES // a bit redundant, this func is only called in glide functions anyways..
4347
if Player.RoofBarrier == true
4348
TempValue0 = Player.YPos
4349
TempValue0 >>= 16
4350
if TempValue0 < Player.CollisionBottom
4351
Player.YPos = Player.CollisionBottom
4352
Player.YPos <<= 16
4353
end if
4354
end if
4355
end if
4356
end if
4357
end if
4358
#endplatform
4359
end function
4360
4361
4362
function Player_Action_GlideDrop
4363
#platform: Use_Origins
4364
// Bug Details:
4365
// Player.Timer should probably be cleared here, but it isn't
4366
// Because of this, doing things like landing from a drop after a left-facing glide will make Knuckles skip to the middle of his idle animation immediately
4367
4368
Player.Animation = ANI_GLIDING_DROP
4369
Player.AbilityTimer = 0
4370
Player.State = Player_State_GlideDrop
4371
#endplatform
4372
end function
4373
4374
4375
function Player_Action_DblJumpAmy
4376
#platform: Use_Origins
4377
if Player.JumpPress == true
4378
PlaySfx(SFX_G_HAMMERJUMP, false)
4379
game.callbackParam0 = 0
4380
game.callbackParam1 = 1
4381
game.callbackParam2 = 0
4382
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
4383
TempValue0 = Player.AnimationSpeed
4384
TempValue1 = Player.Frame
4385
Player.Animation = ANI_HAMMER_JUMP
4386
ProcessAnimation()
4387
Player.AnimationSpeed = TempValue0
4388
Player.Frame = TempValue1
4389
end if
4390
#endplatform
4391
end function
4392
4393
4394
function Player_Action_HammerDash
4395
#platform: Use_Origins
4396
PlaySfx(SFX_G_HAMMERDASH, false)
4397
Player.State = Player_State_HammerDash
4398
Player.Animation = ANI_HAMMER_DASH
4399
Player.Timer = 0
4400
Player.DropDashCharge = -1
4401
CallFunction(Player_SetHammerDashSpeed)
4402
#endplatform
4403
end function
4404
4405
4406
function Player_State_HammerDash
4407
#platform: Use_Origins
4408
if Player.Right == true
4409
Player.Direction = FACING_RIGHT
4410
else
4411
if Player.Left == true
4412
Player.Direction = FACING_LEFT
4413
end if
4414
end if
4415
4416
TempValue0 = true
4417
4418
if Player.Speed != 0
4419
Player.Timer++
4420
if Player.JumpHold == true
4421
if Player.Timer < 60
4422
CallFunction(Player_SetHammerDashSpeed)
4423
if Player.Gravity == GRAVITY_AIR
4424
CallFunction(Player_HandleAirMovement)
4425
else
4426
CallFunction(Player_HandleOnGround)
4427
end if
4428
TempValue0 = false
4429
end if
4430
end if
4431
end if
4432
4433
// If Amy is on a steep enough slope, cancel the move
4434
// (Despite the patch notes for version 2.0.1 claiming this was removed, it's very much still here)
4435
Cos256(TempValue1, Player.Angle)
4436
if TempValue1 <= 0
4437
TempValue0 = true
4438
end if
4439
4440
if TempValue0 == true
4441
Player.State = Player_State_Ground
4442
end if
4443
#endplatform
4444
end function
4445
4446
4447
function Player_SetHammerDashSpeed
4448
#platform: Use_Origins
4449
if Player.Direction == FACING_RIGHT
4450
Player.Speed = 0x60000
4451
else
4452
// Could they not have just set it to -0x60000?
4453
Player.Speed = 0
4454
Player.Speed -= 0x60000
4455
end if
4456
#endplatform
4457
end function
4458
4459
4460
function Player_Setup_Startup
4461
#platform: Use_Origins
4462
ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)
4463
4464
Player.XPos = Object[ArrayPos0].XPos
4465
Player.YPos = Object[ArrayPos0].YPos
4466
4467
if Mini_PlayerFlag == false
4468
if Stage.PlayerListPos == PLAYER_SONIC
4469
LoadAnimation("Sonic.Ani")
4470
end if
4471
4472
if Stage.PlayerListPos == PLAYER_TAILS
4473
LoadAnimation("Tails.Ani")
4474
end if
4475
4476
if Stage.PlayerListPos == PLAYER_KNUCKLES
4477
LoadAnimation("Knuckles.Ani")
4478
end if
4479
4480
if Stage.PlayerListPos == PLAYER_AMY
4481
LoadAnimation("Amy.Ani")
4482
end if
4483
else
4484
if Stage.PlayerListPos == PLAYER_SONIC
4485
LoadAnimation("MiniSonic.Ani")
4486
end if
4487
4488
if Stage.PlayerListPos == PLAYER_TAILS
4489
LoadAnimation("MiniTails.Ani")
4490
Object[1].Type = TypeName[Blank Object]
4491
end if
4492
4493
// it's not like Knuckles or Amy have any tails to worry about...
4494
if Stage.PlayerListPos == PLAYER_KNUCKLES
4495
LoadAnimation("MiniKnuckles.Ani")
4496
Object[1].Type = TypeName[Blank Object]
4497
end if
4498
4499
if Stage.PlayerListPos == PLAYER_AMY
4500
LoadAnimation("MiniAmy.Ani")
4501
Object[1].Type = TypeName[Blank Object]
4502
end if
4503
end if
4504
4505
BindPlayerToObject(0, 0)
4506
4507
Player.State = Player_State_Air_NoDropDash
4508
Player.Priority = PRIORITY_ACTIVE
4509
Player.DrawOrder = 4
4510
4511
Player.TopSpeed = 0x60000
4512
Player.Acceleration = 0xC00
4513
Player.Deceleration = 0xC00
4514
Player.AirAcceleration = 0x1800
4515
Player.AirDeceleration = 0x600
4516
Player.GravityStrength = 0x3800
4517
Player.JumpStrength = 0x68000
4518
Player.JumpCap = -0x40000
4519
Player.RollingDeceleration = 0x2000
4520
4521
if Stage.PlayerListPos == PLAYER_SONIC
4522
Player.JumpAbility = Player_State_Static
4523
if Options.OriginalControls == false
4524
Player.ActionPeelout = Player_Action_Peelout_S2
4525
Player.ActionSpindash = Player_Action_Spindash_S2
4526
else
4527
Player.ActionPeelout = Player_Action_Peelout_CD
4528
Player.ActionSpindash = Player_Action_Spindash_CD
4529
end if
4530
end if
4531
4532
if Stage.PlayerListPos == PLAYER_TAILS
4533
Player.JumpAbility = Player_Action_DblJumpTails
4534
Player.ActionPeelout = Player_Action_Jump
4535
if Options.OriginalControls == false
4536
Player.ActionSpindash = Player_Action_Spindash_S2
4537
else
4538
Player.ActionSpindash = Player_Action_Spindash_CD
4539
end if
4540
end if
4541
4542
if Stage.PlayerListPos == PLAYER_KNUCKLES
4543
Player.JumpStrength = 0x60000
4544
Player.JumpAbility = Player_Action_DblJumpKnux
4545
Player.ActionPeelout = Player_Action_Jump
4546
if Options.OriginalControls == false
4547
Player.ActionSpindash = Player_Action_Spindash_S2
4548
else
4549
Player.ActionSpindash = Player_Action_Spindash_CD
4550
end if
4551
end if
4552
4553
if Stage.PlayerListPos == PLAYER_AMY
4554
Player.JumpAbility = Player_Action_DblJumpAmy
4555
Player.ActionPeelout = Player_Action_Jump
4556
if Options.OriginalControls == false
4557
Player.ActionSpindash = Player_Action_Spindash_S2
4558
else
4559
Player.ActionSpindash = Player_Action_Spindash_CD
4560
end if
4561
end if
4562
4563
CallFunction(Player_SetJumpOffset)
4564
4565
GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")
4566
GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")
4567
GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")
4568
GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")
4569
GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")
4570
GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")
4571
GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")
4572
GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")
4573
GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")
4574
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
4575
#endplatform
4576
end function
4577
4578
sub ObjectMain
4579
// Only PC had access to debug mode, so here's a hack to prevent it on mobile
4580
TempValue0 = false
4581
#platform: Standard
4582
TempValue0 = Stage.DebugMode
4583
#endplatform
4584
4585
if TempValue0 == true
4586
if KeyPress[1].ButtonB == true // Turn Debug Mode
4587
Object.Type = TypeName[Debug Mode]
4588
4589
if Stage.PlayerListPos != PLAYER_SONIC_A // PLAYER_SONIC in origins
4590
Object[+1].Type = TypeName[Blank Object]
4591
end if
4592
4593
Player.YVelocity = 0
4594
Player.State = Player_State_Static
4595
Player.Frame = 0
4596
Player.Rotation = 0
4597
4598
Player.ObjectInteraction = false
4599
Player.TileCollisions = true
4600
Player.DrawOrder = 4
4601
4602
Player.AbilityTimer = 0
4603
Player.MinRollSpeed = 0
4604
4605
Screen.CameraEnabled = true
4606
Screen.CameraStyle = Options.OriginalControls
4607
else
4608
// Handle Player
4609
CallFunction(Player_ProcessUpdate)
4610
CallFunction(Player.State)
4611
ProcessAnimation()
4612
4613
if Player.Animation == ANI_JUMPING
4614
Screen.AdjustCameraY = Player.JumpOffset
4615
else
4616
if Screen.AdjustCameraY == Player.JumpOffset
4617
Screen.AdjustCameraY = 0
4618
Player.iYPos += Player.JumpOffset
4619
end if
4620
end if
4621
4622
if Player.YVelocity > 0x100000
4623
Player.YVelocity = 0x100000
4624
end if
4625
4626
PlayerTileCollision()
4627
4628
if CheckResult == true
4629
if Player.Animation == ANI_JUMPING
4630
if Player.Down == false
4631
Player.Animation = ANI_WALKING
4632
Screen.AdjustCameraY = 0
4633
Player.iYPos += Player.JumpOffset
4634
end if
4635
end if
4636
end if
4637
end if
4638
else
4639
// Mobile version ObjectMain starts here, since there wasn't a debug mode
4640
// Handle Player
4641
CallFunction(Player_ProcessUpdate)
4642
CallFunction(Player.State)
4643
4644
#platform: Use_Origins
4645
if Player.DropDashCharge >= 20
4646
if Player.Animation == ANI_JUMPING
4647
Player.Frame = 0
4648
Player.AnimationTimer = 0
4649
Player.AnimationSpeed = 1
4650
end if
4651
end if
4652
#endplatform
4653
4654
ProcessAnimation()
4655
4656
if Player.Animation == ANI_JUMPING
4657
Screen.AdjustCameraY = Player.JumpOffset
4658
else
4659
if Screen.AdjustCameraY == Player.JumpOffset
4660
Screen.AdjustCameraY = 0
4661
Player.iYPos += Player.JumpOffset
4662
end if
4663
end if
4664
4665
if Player.YVelocity > 0x100000
4666
Player.YVelocity = 0x100000
4667
end if
4668
4669
PlayerTileCollision()
4670
if CheckResult == true
4671
if Player.Animation == ANI_JUMPING
4672
if Player.Down == false
4673
Player.Animation = ANI_WALKING
4674
Screen.AdjustCameraY = 0
4675
Player.iYPos += Player.JumpOffset
4676
end if
4677
end if
4678
end if
4679
end if
4680
end sub
4681
4682
4683
sub ObjectDraw
4684
if Player.Animation != Player.PrevAnimation
4685
Player.PrevAnimation = Player.Animation
4686
Player.Frame = 0
4687
Player.AnimationTimer = 0
4688
Player.AnimationSpeed = 0
4689
end if
4690
4691
DrawPlayerAnimation()
4692
end sub
4693
4694
4695
sub ObjectStartup
4696
#platform: Use_Origins
4697
// I feel like I got spoiled on a Knuckles route...
4698
TempValue0 = false
4699
CheckGreater(Warp.Timer, 204)
4700
TempValue0 |= CheckResult
4701
TempValue0 &= Mini_PlayerFlag
4702
Mini_PlayerFlag = TempValue0
4703
Warp.Timer = 0
4704
4705
if Options.AttractMode == false
4706
if Options.StageSelectFlag == false
4707
ReadSaveRAM()
4708
end if
4709
end if
4710
4711
// Origins Plus includes new start positions for Knuckles in some levels
4712
ArrayPos1 = 32
4713
TempValue5 = 0
4714
TempValue6 = 0
4715
while ArrayPos1 < 1056
4716
// So now we have to check how many player objects the game found
4717
if Object[ArrayPos1].Type == TypeName[Player Object]
4718
TempValue5++
4719
end if
4720
ArrayPos1++
4721
loop
4722
4723
// We found multiple spawn points, now check which one to use
4724
if TempValue5 > 1
4725
ArrayPos1 = 32
4726
TempValue7 = 0
4727
while ArrayPos1 < 1056
4728
if Object[ArrayPos1].Type == TypeName[Player Object]
4729
// The standard spawnpoint
4730
if Object[ArrayPos1].PropertyValue == 0
4731
TempValue7 = ArrayPos1
4732
end if
4733
4734
// Character specific spawnpoint
4735
if Object[ArrayPos1].PropertyValue == Stage.PlayerListPos
4736
TempValue6 = ArrayPos1
4737
ArrayPos1 = 1056
4738
end if
4739
end if
4740
ArrayPos1++
4741
loop
4742
4743
// If we didn't find a special spawnpoint, just use the regular one
4744
if TempValue6 == 0
4745
TempValue6 = TempValue7
4746
end if
4747
end if
4748
4749
// Get rid of all spawnpoints except the one we're going to use
4750
TempValue7 = 0
4751
ArrayPos0 = 32
4752
while ArrayPos0 < 1056
4753
if Object[ArrayPos0].Type == TypeName[Player Object]
4754
if TempValue5 > 1
4755
if ArrayPos0 == TempValue6
4756
CallFunction(Player_Setup_Startup)
4757
else
4758
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
4759
end if
4760
else
4761
TempValue7 = ArrayPos0
4762
end if
4763
end if
4764
ArrayPos0++
4765
loop
4766
4767
if TempValue7 > 0
4768
ArrayPos0 = TempValue7
4769
CallFunction(Player_Setup_Startup)
4770
end if
4771
#endplatform
4772
4773
#platform: Use_Standalone
4774
ArrayPos0 = 32
4775
while ArrayPos0 < 1056
4776
if Object[ArrayPos0].Type == TypeName[Player Object]
4777
switch Stage.PlayerListPos
4778
case PLAYER_SONIC_A
4779
ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)
4780
Player.XPos = Object[ArrayPos0].XPos
4781
Player.YPos = Object[ArrayPos0].YPos
4782
4783
LoadAnimation("Sonic.Ani")
4784
BindPlayerToObject(0, 0)
4785
4786
Player.State = Player_State_Air
4787
4788
Player.Priority = PRIORITY_ACTIVE
4789
4790
Player.DrawOrder = 4
4791
4792
Player.TopSpeed = 0x60000
4793
Player.Acceleration = 0xC00
4794
Player.Deceleration = 0xC00
4795
Player.AirAcceleration = 0x1800
4796
Player.AirDeceleration = 0x600
4797
Player.GravityStrength = 0x3800
4798
Player.JumpStrength = 0x68000
4799
Player.JumpCap = -0x40000
4800
Player.RollingDeceleration = 0x2000
4801
4802
Player.JumpOffset = -5
4803
4804
Player.JumpAbility = Player_State_Static
4805
if Options.OriginalControls == false
4806
Player.ActionPeelout = Player_Action_Peelout_S2
4807
Player.ActionSpindash = Player_Action_Spindash_S2
4808
else
4809
Player.ActionPeelout = Player_Action_Peelout_CD
4810
Player.ActionSpindash = Player_Action_Spindash_CD
4811
end if
4812
break
4813
4814
case PLAYER_TAILS_A
4815
ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)
4816
Player.XPos = Object[ArrayPos0].XPos
4817
Player.YPos = Object[ArrayPos0].YPos
4818
4819
LoadAnimation("Tails.Ani")
4820
BindPlayerToObject(0, 0)
4821
4822
Player.State = Player_State_Air
4823
Player.Priority = PRIORITY_ACTIVE
4824
Player.DrawOrder = 4
4825
4826
Player.TopSpeed = 0x60000
4827
Player.Acceleration = 0xC00
4828
Player.Deceleration = 0xC00
4829
Player.AirAcceleration = 0x1800
4830
Player.AirDeceleration = 0x600
4831
Player.GravityStrength = 0x3800
4832
Player.JumpStrength = 0x68000
4833
Player.JumpCap = -0x40000
4834
Player.RollingDeceleration = 0x2000
4835
4836
Player.JumpOffset = -1
4837
4838
Player.JumpAbility = Player_Action_DblJumpTails
4839
Player.ActionPeelout = Player_Action_Jump
4840
if Options.OriginalControls == false
4841
Player.ActionSpindash = Player_Action_Spindash_S2
4842
else
4843
Player.ActionSpindash = Player_Action_Spindash_CD
4844
end if
4845
break
4846
4847
end switch
4848
4849
GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")
4850
GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")
4851
GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")
4852
GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")
4853
GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")
4854
GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")
4855
GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")
4856
GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")
4857
GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")
4858
4859
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
4860
end if
4861
4862
ArrayPos0++
4863
loop
4864
#endplatform
4865
end sub
4866
4867
4868
// ========================
4869
// Editor Subs
4870
// ========================
4871
4872
// All of the Character ID stuff is specific to Origins Plus, other versions of the game don't check or use the PropertyValue
4873
4874
sub RSDKEdit
4875
if Editor.ReturnVariable == true
4876
switch Editor.VariableID
4877
case EDIT_VAR_PROPVAL // Property Value
4878
CheckResult = Object.PropertyValue
4879
break
4880
case 0 // Character ID
4881
CheckResult = Object.PropertyValue
4882
break
4883
end switch
4884
else
4885
switch Editor.VariableID
4886
case EDIT_VAR_PROPVAL // Property Value
4887
Object.PropertyValue = Editor.VariableValue
4888
break
4889
case 0 // Character ID
4890
Object.PropertyValue = Editor.VariableValue
4891
break
4892
end switch
4893
end if
4894
end sub
4895
4896
4897
sub RSDKDraw
4898
switch Object.PropertyValue
4899
default
4900
LoadSpriteSheet("Players/Sonic1.gif")
4901
DrawSprite(0)
4902
break
4903
4904
case 1
4905
LoadSpriteSheet("Players/Tails1.gif")
4906
DrawSprite(1)
4907
break
4908
4909
case 2
4910
LoadSpriteSheet("Players/KTE1.gif")
4911
DrawSprite(2)
4912
break
4913
4914
case 5
4915
LoadSpriteSheet("Players/Amy1.gif")
4916
DrawSprite(3)
4917
break
4918
end switch
4919
end sub
4920
4921
4922
sub RSDKLoad
4923
LoadSpriteSheet("Players/Sonic1.gif")
4924
SpriteFrame(-16, -19, 28, 39, 1, 1) // Sonic Standing Frame
4925
4926
LoadSpriteSheet("Players/Tails1.gif")
4927
SpriteFrame(-12, -12, 24, 32, 1, 1) // Tails Standing Frame
4928
4929
LoadSpriteSheet("Players/KTE1.gif")
4930
SpriteFrame(-14, -20, 26, 40, 1, 1) // Knuckles Standing Frame
4931
4932
LoadSpriteSheet("Players/Amy1.gif")
4933
SpriteFrame(-12, -15, 21, 35, 45, 1) // Amy Standing Frame
4934
4935
AddEditorVariable("Character ID (Origins Plus)")
4936
SetActiveVariable("Character ID (Origins Plus)")
4937
AddEnumVariable("Sonic", PLAYER_SONIC_A)
4938
AddEnumVariable("Tails", PLAYER_TAILS_A)
4939
AddEnumVariable("Knuckles", PLAYER_KNUCKLES_A)
4940
AddEnumVariable("Amy", PLAYER_AMY_A)
4941
end sub
4942
4943