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
1843 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
#platform: Use_Origins
1630
Player.DropDashCharge = -1
1631
Player.State = Player_State_Air
1632
CallFunction(Player_State_Air)
1633
#endplatform
1634
end function
1635
1636
function Player_State_Air
1637
CallFunction(Player_HandleAirFriction)
1638
#platform: Use_Origins
1639
if Stage.PlayerListPos == PLAYER_TAILS
1640
CallFunction(Player_HandleDropDash)
1641
end if
1642
#endplatform
1643
if Player.Gravity == GRAVITY_AIR // Check that you're truly in the air
1644
CallFunction(Player_HandleAirMovement)
1645
1646
// More warp stuff
1647
if Warp.Destination > WARPDEST_NONE
1648
TempValue0 = Player.YVelocity
1649
if TempValue0 < 0
1650
FlipSign(TempValue0)
1651
end if
1652
1653
if TempValue0 < 0x60000
1654
TempValue0 = Player.XVelocity
1655
if TempValue0 < 0
1656
FlipSign(TempValue0)
1657
end if
1658
1659
if TempValue0 < 0x60000
1660
TempValue0 = Player.XVelocity
1661
TempValue0 -= Warp.SpeedCompare
1662
if TempValue0 < 0
1663
FlipSign(TempValue0)
1664
end if
1665
1666
if TempValue0 > 0x40000
1667
if Warp.Timer > 99
1668
if Warp.Timer < 204
1669
Warp.Destination = WARPDEST_NONE
1670
end if
1671
end if
1672
Warp.Timer = 0
1673
end if
1674
end if
1675
end if
1676
Warp.SpeedCompare = Player.XVelocity
1677
end if
1678
1679
// changes the flailing with the walking, not sure when this is used
1680
if Player.YVelocity > 0x20000
1681
if Player.Animation == ANI_FLAILINGLEFT
1682
Player.Animation = ANI_WALKING
1683
end if
1684
if Player.Animation == ANI_FLAILINGRIGHT
1685
Player.Animation = ANI_WALKING
1686
end if
1687
end if
1688
1689
// Post-Hitting a spring
1690
if Player.Animation == ANI_BOUNCING
1691
if Player.YVelocity >= 0
1692
if Player.AnimationReserve == ANI_STOPPED
1693
Player.AnimationReserve = ANI_WALKING
1694
end if
1695
Player.Animation = Player.AnimationReserve
1696
end if
1697
end if
1698
1699
// Post Getting hurt
1700
if Player.Animation == ANI_HURT
1701
if Player.YVelocity >= 0
1702
if Player.AnimationReserve == ANI_STOPPED
1703
Player.AnimationReserve = ANI_WALKING
1704
end if
1705
Player.Animation = Player.AnimationReserve
1706
end if
1707
end if
1708
1709
// Calls the player flight function
1710
#platform: Use_Origins
1711
// Bug Details:
1712
// This segment of code was backported from Sonic 1 to (presumably) prevent the ledge roll-off ability bug that's from 2011.
1713
// -> However, this code is missing the Player.JumpAbilityState check before the second ANI_JUMPING check.
1714
// -> This basically makes it still behave like 2011 does, just more advanced (?).
1715
// -> The other checks from S1 that also do things with Player.JumpAbilityState are missing too...
1716
// -> Not really sure why it turned out this way.
1717
if Stage.PlayerListPos == PLAYER_TAILS
1718
if Player.Animation == ANI_JUMPING
1719
CallFunction(Player.JumpAbility)
1720
end if
1721
else
1722
if Player.YVelocity >= Player.JumpCap
1723
CallFunction(Player_HandleDropDash)
1724
if Player.Animation == ANI_JUMPING
1725
CallFunction(Player.JumpAbility)
1726
end if
1727
end if
1728
end if
1729
#endplatform
1730
1731
#platform: Use_Standalone
1732
if Player.Animation == ANI_JUMPING
1733
CallFunction(Player.JumpAbility)
1734
end if
1735
#endplatform
1736
else
1737
// go back to the ground silly
1738
#platform: Use_Origins
1739
if Player.DropDashCharge >= 20
1740
if Stage.PlayerListPos == PLAYER_AMY
1741
CallFunction(Player_Action_HammerDash)
1742
else
1743
CallFunction(Player_Action_Spindash_S2)
1744
end if
1745
else
1746
Player.State = Player_State_Ground
1747
CallFunction(Player_HandleOnGround)
1748
Player.Skidding = 0
1749
end if
1750
#endplatform
1751
1752
#platform: Use_Standalone
1753
Player.State = Player_State_Ground
1754
CallFunction(Player_HandleOnGround)
1755
Player.Skidding = 0
1756
#endplatform
1757
end if
1758
end function
1759
1760
function Player_State_Roll
1761
CallFunction(Player_HandleRollDeceleration)
1762
#platform: Use_Origins
1763
if Player.ForceGrounded > 0
1764
Player.Gravity = GRAVITY_GROUND
1765
Player.ForceGrounded -= 1 // ig a normal "--" wasn't good enough, huh?
1766
end if
1767
#endplatform
1768
1769
if Player.Gravity == GRAVITY_AIR
1770
1771
#platform: Use_Origins
1772
Player.State = Player_State_Air_NoDropDash
1773
#endplatform
1774
1775
#platform: Use_Standalone
1776
Player.State = Player_State_Air
1777
#endplatform
1778
1779
Player.Timer = 0
1780
CallFunction(Player_HandleAirMovement)
1781
else
1782
CallFunction(Player_HandleRollAnimSpeed)
1783
Player.AnimationSpeed = Player.RollAnimationSpeed
1784
1785
TempValue0 = Player.Speed
1786
if TempValue0 < 0
1787
FlipSign(TempValue0)
1788
end if
1789
1790
// Warp-Consuming
1791
if TempValue0 < 0x5F5C2
1792
if Warp.Destination > WARPDEST_NONE
1793
if Warp.Timer > 99
1794
if Warp.Timer < 204
1795
Warp.Destination = WARPDEST_NONE
1796
end if
1797
end if
1798
Warp.Timer = 0
1799
end if
1800
else
1801
// Spawn Warp Stars
1802
if Warp.Destination > WARPDEST_NONE
1803
if Warp.Timer == 0
1804
Warp.Timer = 1
1805
ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)
1806
WarpStar.Timer = 7
1807
WarpStar.DrawOrder = 4
1808
end if
1809
end if
1810
end if
1811
1812
CallFunction(Player_HandleOnGround)
1813
1814
if Player.JumpPress == true
1815
CallFunction(Player_Action_Jump)
1816
end if
1817
end if
1818
end function
1819
1820
// Cancels input movement (Unused leftover from Sonic Nexus (2008))
1821
function Player_State_RollJump
1822
#platform: Use_Origins
1823
// they removed roll jump lock in Plus lol
1824
if Options.AttractMode == true
1825
Player.Left = false
1826
Player.Right = false
1827
end if
1828
1829
CallFunction(Player_HandleAirFriction)
1830
if Stage.PlayerListPos == PLAYER_TAILS
1831
CallFunction(Player_HandleDropDash)
1832
else
1833
if Player.YVelocity >= Player.JumpCap
1834
CallFunction(Player_HandleDropDash)
1835
end if
1836
end if
1837
#endplatform
1838
1839
#platform: Use_Standalone
1840
Player.Left = false
1841
Player.Right = false
1842
CallFunction(Player_HandleAirFriction)
1843
#endplatform
1844
1845
1846
if Player.Gravity == GRAVITY_AIR
1847
CallFunction(Player_HandleAirMovement)
1848
else
1849
1850
#platform: Use_Origins
1851
if Player.DropDashCharge >= 20
1852
if Stage.PlayerListPos == PLAYER_AMY
1853
CallFunction(Player_Action_HammerDash)
1854
else
1855
CallFunction(Player_Action_Spindash_S2)
1856
end if
1857
else
1858
Player.State = Player_State_Ground
1859
CallFunction(Player_HandleOnGround)
1860
Player.Skidding = 0
1861
end if
1862
#endplatform
1863
1864
#platform: Use_Standalone
1865
Player.State = Player_State_Ground
1866
CallFunction(Player_HandleOnGround)
1867
Player.Skidding = 0
1868
#endplatform
1869
1870
end if
1871
end function
1872
1873
// Hey look up
1874
function Player_State_LookUp
1875
if Player.Up == false
1876
Player.State = Player_State_Ground
1877
Player.Timer = 0
1878
else
1879
if Player.Timer < 60
1880
Player.Timer++
1881
else
1882
if Player.LookPos > -112
1883
Player.LookPos -= 2
1884
end if
1885
end if
1886
1887
if Player.Gravity == GRAVITY_AIR
1888
1889
#platform: Use_Origins
1890
Player.State = Player_State_Air_NoDropDash
1891
#endplatform
1892
1893
#platform: Use_Standalone
1894
Player.State = Player_State_Air
1895
#endplatform
1896
1897
Player.Timer = 0
1898
else
1899
if Player.JumpPress == true
1900
CallFunction(Player.ActionPeelout)
1901
end if
1902
end if
1903
end if
1904
end function
1905
1906
// Hey look down
1907
function Player_State_Crouch
1908
if Player.Down == false
1909
Player.State = Player_State_Ground
1910
Player.Timer = 0
1911
else
1912
if Player.Timer < 60
1913
Player.Timer++
1914
else
1915
if Player.LookPos < 96
1916
Player.LookPos += 2
1917
end if
1918
end if
1919
1920
if Player.Gravity == GRAVITY_AIR
1921
1922
#platform: Use_Origins
1923
Player.State = Player_State_Air_NoDropDash
1924
#endplatform
1925
1926
#platform: Use_Standalone
1927
Player.State = Player_State_Air
1928
#endplatform
1929
1930
Player.Timer = 0
1931
else
1932
if Player.JumpPress == true
1933
CallFunction(Player.ActionSpindash)
1934
end if
1935
end if
1936
end if
1937
end function
1938
1939
// S2 Spin Dash code
1940
function Player_State_Spindash_S2
1941
// Keep the camera lock, cancel the spin dash
1942
if Player.Gravity == GRAVITY_AIR
1943
1944
#platform: Use_Origins
1945
Player.State = Player_State_Air_NoDropDash
1946
#endplatform
1947
1948
#platform: Use_Standalone
1949
Player.State = Player_State_Air
1950
#endplatform
1951
1952
Player.Speed = 0
1953
end if
1954
1955
// Mashing
1956
if Player.JumpPress == true
1957
if Player.AbilityTimer < 512
1958
Player.AbilityTimer += 64
1959
end if
1960
Player.Frame = 0
1961
1962
PlaySfx(SFX_G_CHARGE, false)
1963
else
1964
if Player.AbilityTimer > 0
1965
Player.AbilityTimer--
1966
end if
1967
end if
1968
1969
#platform: Use_Origins
1970
TempValue1 = Player.Down
1971
if Player.DropDashCharge >= 20
1972
Player.DropDashCharge = -1
1973
Sin256(TempValue0, Player.Angle)
1974
if Player.Direction == FACING_RIGHT
1975
if TempValue0 >= 0
1976
TempValue0 <<= 2
1977
else
1978
TempValue0 <<= 1
1979
end if
1980
else
1981
if TempValue0 >= 0
1982
TempValue0 <<= 1
1983
else
1984
TempValue0 <<= 2
1985
end if
1986
FlipSign(TempValue0)
1987
end if
1988
1989
if TempValue0 > 512
1990
TempValue0 = 512
1991
end if
1992
1993
Player.AbilityTimer = TempValue0
1994
TempValue1 = false
1995
end if
1996
1997
CheckEqual(TempValue1, false)
1998
#endplatform
1999
2000
#platform: Use_Standalone
2001
CheckEqual(Player.Down, false)
2002
#endplatform
2003
// Work around to adapt it to origins
2004
// Spin Dash release
2005
if CheckResult == true
2006
Player.Timer = 0
2007
Player.State = Player_State_Roll
2008
Player.Animation = ANI_JUMPING
2009
Player.iYPos -= Player.JumpOffset
2010
2011
Player.ScrollDelay = 15
2012
Screen.CameraStyle = CAMERASTYLE_HLOCKED
2013
2014
TempValue0 = Player.AbilityTimer
2015
TempValue0 <<= 9
2016
TempValue0 += 0x80000
2017
2018
if Player.Direction == FACING_RIGHT
2019
Player.Speed = TempValue0
2020
else
2021
Player.Speed = TempValue0
2022
FlipSign(Player.Speed)
2023
end if
2024
2025
PlaySfx(SFX_G_RELEASE, false)
2026
2027
CallFunction(Player_HandleOnGround)
2028
2029
#platform: Use_Origins
2030
Player.ForceGrounded = 6
2031
#endplatform
2032
2033
#platform: Use_Haptics
2034
HapticEffect(42, 0, 0, 0)
2035
#endplatform
2036
2037
end if
2038
end function
2039
2040
function Player_State_Spindash_CD
2041
if Player.Direction == FACING_RIGHT
2042
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L
2043
else
2044
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R
2045
end if
2046
2047
// Keep the camera lock, cancel the spin dash
2048
if Player.Gravity == GRAVITY_AIR
2049
2050
#platform: Use_Origins
2051
Player.State = Player_State_Air_NoDropDash
2052
#endplatform
2053
2054
#platform: Use_Standalone
2055
Player.State = Player_State_Air
2056
#endplatform
2057
2058
Player.Speed = 0
2059
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2060
end if
2061
2062
// Charge
2063
if Player.GravityStrength == 0x1000
2064
if Player.AbilityTimer < 0x80000
2065
Player.AbilityTimer += 0x6000
2066
end if
2067
else
2068
if Player.AbilityTimer < 0xC0000
2069
Player.AbilityTimer += 0x6000
2070
end if
2071
end if
2072
2073
// Release
2074
if Player.Down == false
2075
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2076
Player.Timer = 0
2077
2078
if Player.AbilityTimer < 0x2FAE1
2079
Player.Speed = 0
2080
Player.State = Player_State_Ground
2081
else
2082
Player.State = Player_State_Roll
2083
Player.Animation = ANI_JUMPING
2084
Player.Speed = Player.AbilityTimer
2085
2086
if Player.Direction == FACING_LEFT
2087
FlipSign(Player.Speed)
2088
end if
2089
2090
PlaySfx(SFX_G_RELEASE, false)
2091
end if
2092
CallFunction(Player_HandleOnGround)
2093
2094
#platform: Use_Haptics
2095
HapticEffect(42, 0, 0, 0)
2096
#endplatform
2097
2098
end if
2099
end function
2100
2101
2102
function Player_State_Peelout_S2
2103
// Cancels the Peel Out, keeps the camera
2104
if Player.Gravity == GRAVITY_AIR
2105
2106
#platform: Use_Origins
2107
Player.State = Player_State_Air_NoDropDash
2108
#endplatform
2109
2110
#platform: Use_Standalone
2111
Player.State = Player_State_Air
2112
#endplatform
2113
2114
Player.Speed = 0
2115
end if
2116
// Charge
2117
if Player.GravityStrength == 0x1000
2118
if Player.AbilityTimer < 0x60000
2119
Player.AbilityTimer += 0x6000
2120
end if
2121
else
2122
if Player.AbilityTimer < 0xC0000
2123
Player.AbilityTimer += 0x6000
2124
end if
2125
end if
2126
// Speed building, from walking to running then peelout
2127
if Player.AbilityTimer < 0x5F5C2
2128
Player.Animation = ANI_WALKING
2129
TempValue0 = Player.AbilityTimer
2130
TempValue0 >>= 16
2131
TempValue0 *= 80
2132
TempValue0 /= 6
2133
TempValue0 += 20
2134
else
2135
TempValue0 = Player.AbilityTimer
2136
TempValue0 >>= 16
2137
TempValue0 *= 80
2138
TempValue0 /= 6
2139
if Player.AbilityTimer > 0x9FFFF
2140
Player.Animation = ANI_PEELOUT
2141
else
2142
Player.Animation = ANI_RUNNING
2143
end if
2144
end if
2145
2146
// Release
2147
if Player.Up == false
2148
Player.ScrollDelay = 15
2149
Screen.CameraStyle = CAMERASTYLE_HLOCKED
2150
2151
Player.State = Player_State_Ground
2152
// Cancels the peel out if you didn't charged it enough
2153
if Player.AbilityTimer < 0x5F5C2
2154
Player.Speed = 0
2155
else
2156
Player.Speed = Player.AbilityTimer
2157
if Player.Direction == FACING_LEFT
2158
FlipSign(Player.Speed)
2159
end if
2160
PlaySfx(SFX_G_RELEASE, false)
2161
end if
2162
CallFunction(Player_HandleOnGround)
2163
2164
#platform: Use_Haptics
2165
HapticEffect(42, 0, 0, 0)
2166
#endplatform
2167
2168
end if
2169
Player.AnimationSpeed = TempValue0
2170
end function
2171
2172
2173
function Player_State_Peelout_CD
2174
// Moves the camera
2175
if Player.Direction == FACING_RIGHT
2176
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L
2177
else
2178
Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R
2179
end if
2180
// Cancels the Peel Out, keeps the camera
2181
if Player.Gravity == GRAVITY_AIR
2182
2183
#platform: Use_Origins
2184
Player.State = Player_State_Air_NoDropDash
2185
#endplatform
2186
2187
#platform: Use_Standalone
2188
Player.State = Player_State_Air
2189
#endplatform
2190
2191
Player.Speed = 0
2192
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2193
end if
2194
2195
// Charge
2196
if Player.GravityStrength == 0x1000
2197
if Player.AbilityTimer < 0x60000
2198
Player.AbilityTimer += 0x6000
2199
end if
2200
else
2201
if Player.AbilityTimer < 0xC0000
2202
Player.AbilityTimer += 0x6000
2203
end if
2204
end if
2205
2206
// Speed building, from walking to running then peelout
2207
if Player.AbilityTimer < 0x5F5C2
2208
Player.Animation = ANI_WALKING
2209
TempValue0 = Player.AbilityTimer
2210
TempValue0 >>= 16
2211
TempValue0 *= 80
2212
TempValue0 /= 6
2213
TempValue0 += 20
2214
else
2215
TempValue0 = Player.AbilityTimer
2216
TempValue0 >>= 16
2217
TempValue0 *= 80
2218
TempValue0 /= 6
2219
if Player.AbilityTimer > 0x9FFFF
2220
Player.Animation = ANI_PEELOUT
2221
else
2222
Player.Animation = ANI_RUNNING
2223
end if
2224
end if
2225
2226
// Release
2227
if Player.Up == false
2228
Screen.CameraStyle = CAMERASTYLE_EXTENDED
2229
2230
Player.State = Player_State_Ground
2231
// Cancels the peel out if you didn't charged it enough
2232
if Player.AbilityTimer < 0x5F5C2
2233
Player.Speed = 0
2234
else
2235
Player.Speed = Player.AbilityTimer
2236
if Player.Direction == FACING_LEFT
2237
FlipSign(Player.Speed)
2238
end if
2239
2240
PlaySfx(SFX_G_RELEASE, false)
2241
end if
2242
CallFunction(Player_HandleOnGround)
2243
2244
#platform: Use_Haptics
2245
HapticEffect(42, 0, 0, 0)
2246
#endplatform
2247
2248
end if
2249
Player.AnimationSpeed = TempValue0
2250
end function
2251
2252
// Tails flight
2253
function Player_State_Fly
2254
CallFunction(Player_HandleAirFriction)
2255
if Player.Gravity == GRAVITY_AIR
2256
Player.XVelocity = Player.Speed
2257
// Check if you have enough speed while flying to keep the warp
2258
if Warp.Destination > WARPDEST_NONE
2259
TempValue0 = Player.XVelocity
2260
if TempValue0 < 0
2261
FlipSign(TempValue0)
2262
end if
2263
2264
TempValue1 = Player.YVelocity
2265
if TempValue1 < 0
2266
FlipSign(TempValue1)
2267
end if
2268
2269
TempValue0 += TempValue1
2270
if TempValue0 < 0x40000
2271
if Warp.Timer > 99
2272
if Warp.Timer < 220
2273
Warp.Destination = WARPDEST_NONE
2274
end if
2275
end if
2276
Warp.Timer = 0
2277
end if
2278
end if
2279
2280
if Player.YVelocity < -0x10000
2281
Player.FlightVelocity = 0x800
2282
else
2283
if Player.YVelocity < 1
2284
if Player.AbilityTimer < 60
2285
Player.AbilityTimer++
2286
else
2287
Player.FlightVelocity = 0x800
2288
end if
2289
end if
2290
end if
2291
2292
Player.YVelocity += Player.FlightVelocity
2293
if Player.Timer < 480
2294
if Player.GravityStrength == 0x3800
2295
Player.Animation = ANI_FLYING
2296
else
2297
Player.Animation = ANI_SWIMMING
2298
end if
2299
2300
Player.Timer++
2301
if Player.Timer == 480
2302
if Player.GravityStrength == 0x3800
2303
Player.Animation = ANI_FLYINGTIRED
2304
StopSfx(SFX_G_FLYING)
2305
PlaySfx(SFX_G_TIRED, true)
2306
else
2307
Player.Animation = ANI_SWIMMINGTIRED
2308
end if
2309
else
2310
if Player.JumpPress == true
2311
Player.FlightVelocity = -0x2000
2312
Player.AbilityTimer = 0
2313
end if
2314
end if
2315
else
2316
if Player.GravityStrength == 0x3800
2317
Player.Animation = ANI_FLYINGTIRED
2318
else
2319
Player.Animation = ANI_SWIMMINGTIRED
2320
end if
2321
end if
2322
else
2323
Player.State = Player_State_Ground
2324
CallFunction(Player_HandleOnGround)
2325
end if
2326
2327
// If the level has a roof barrier, you're not getting too far
2328
if Player.RoofBarrier == true
2329
TempValue0 = Player.YPos
2330
TempValue0 >>= 16
2331
if TempValue0 < Player.CollisionBottom
2332
Player.YPos = Player.CollisionBottom
2333
Player.YPos <<= 16
2334
end if
2335
end if
2336
end function
2337
2338
// Player Damage
2339
function Player_State_GotHit
2340
#platform: Use_Origins
2341
TempValue1 = false
2342
if game.playMode == BOOT_PLAYMODE_MISSION
2343
if game.missionFunctionNo == RULE_MERCY_BADNIKS
2344
if game.missionValue == 1
2345
game.missionValue = 0
2346
TempValue1 = true
2347
end if
2348
end if
2349
end if
2350
#endplatform
2351
2352
ArrayPos0 = Player.EntityNo
2353
ArrayPos0 += 2
2354
// if you had a shield, remove it
2355
if Object[ArrayPos0].PropertyValue > 0
2356
TempValue0 = DAMAGE_SHIELDED
2357
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
2358
PlaySfx(SFX_G_HURT, false)
2359
else
2360
if Player.Rings == 0
2361
PlaySfx(SFX_G_HURT, false)
2362
TempValue0 = DAMAGE_DEATH
2363
else
2364
#platform: Use_Origins
2365
if TempValue1 == false
2366
PlaySfx(SFX_G_LOSERINGS, false)
2367
TempValue0 = DAMAGE_HURT
2368
end if
2369
#endplatform
2370
2371
#platform: Use_Standalone
2372
PlaySfx(SFX_G_LOSERINGS, false)
2373
TempValue0 = DAMAGE_HURT
2374
#endplatform
2375
end if
2376
end if
2377
2378
#platform: Use_Origins
2379
if TempValue1 != false
2380
TempValue0 = DAMAGE_DEATH
2381
end if
2382
#endplatform
2383
2384
switch TempValue0
2385
case DAMAGE_SHIELDED
2386
#platform: Use_Haptics
2387
HapticEffect(16, 0, 0, 0)
2388
#endplatform
2389
2390
Player.State = Player_State_Hurt
2391
Player.Animation = ANI_HURT
2392
Player.YVelocity = -0x40000
2393
Player.Gravity = GRAVITY_AIR
2394
Player.TrackScroll = true
2395
Player.InvincibleTimer = 8000
2396
2397
if Player.GravityStrength == 0x1000
2398
Player.Speed >>= 1
2399
Player.YVelocity >>= 1
2400
end if
2401
break
2402
2403
case DAMAGE_HURT
2404
#platform: Use_Haptics
2405
HapticEffect(16, 0, 0, 0)
2406
#endplatform
2407
2408
if Player.CollisionPlane == COLLISION_PLANE_A
2409
TempValue4 = 3
2410
else
2411
TempValue4 = 1
2412
end if
2413
2414
Player.State = Player_State_Hurt
2415
Player.Animation = ANI_HURT
2416
Player.YVelocity = -0x40000
2417
Player.Gravity = GRAVITY_AIR
2418
Player.TrackScroll = true
2419
Player.InvincibleTimer = 8000
2420
2421
if Player.GravityStrength == 0x1000
2422
Player.Speed >>= 1
2423
Player.YVelocity >>= 1
2424
end if
2425
// Lose ring code
2426
TempValue0 = Player.Rings
2427
if TempValue0 > 16
2428
TempValue1 = TempValue0
2429
TempValue1 -= 16
2430
TempValue0 = 16
2431
else
2432
TempValue1 = 0
2433
end if
2434
2435
if TempValue1 > 16
2436
TempValue1 = 16
2437
end if
2438
2439
TempValue3 = TempValue1
2440
TempValue3 >>= 1
2441
TempValue3 <<= 5
2442
2443
TempValue2 = 384
2444
TempValue2 -= TempValue3
2445
2446
TempValue3 >>= 4
2447
if TempValue3 == TempValue1
2448
TempValue2 += 16
2449
else
2450
TempValue2 -= 16
2451
end if
2452
2453
TempValue3 = 0
2454
while TempValue3 < TempValue1
2455
CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)
2456
Cos(Object[TempObjectPos].XVelocity, TempValue2)
2457
Sin(Object[TempObjectPos].YVelocity, TempValue2)
2458
Object[TempObjectPos].XVelocity <<= 8
2459
Object[TempObjectPos].YVelocity <<= 8
2460
Object[TempObjectPos].DrawOrder = TempValue4
2461
Object[TempObjectPos].AnimationSpeed = 256
2462
TempValue3++
2463
TempValue2 += 32
2464
loop
2465
TempValue3 = TempValue0
2466
TempValue3 >>= 1
2467
TempValue3 <<= 5
2468
2469
TempValue2 = 384
2470
TempValue2 -= TempValue3
2471
2472
TempValue3 >>= 4
2473
if TempValue3 == TempValue0
2474
TempValue2 += 16
2475
else
2476
TempValue2 -= 16
2477
end if
2478
TempValue3 = 0
2479
2480
while TempValue3 < TempValue0
2481
CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)
2482
Cos(Object[TempObjectPos].XVelocity, TempValue2)
2483
Sin(Object[TempObjectPos].YVelocity, TempValue2)
2484
Object[TempObjectPos].XVelocity <<= 9
2485
Object[TempObjectPos].YVelocity <<= 9
2486
Object[TempObjectPos].DrawOrder = TempValue4
2487
Object[TempObjectPos].AnimationSpeed = 256
2488
TempValue3++
2489
TempValue2 += 32
2490
loop
2491
Player.Rings = 0
2492
Ring.ExtraLife = 100
2493
break
2494
2495
case DAMAGE_DEATH
2496
#platform: Use_Haptics
2497
HapticEffect(28, 0, 0, 0)
2498
#endplatform
2499
2500
Object.DrawOrder = 5
2501
Player.Speed = 0
2502
Player.YVelocity = -0x70000
2503
Player.XVelocity = 0
2504
Player.State = Player_State_Death
2505
Player.Animation = ANI_DYING
2506
2507
Player.TileCollisions = false
2508
Player.ObjectInteraction = false
2509
if Player.EntityNo == 0 // Check if it's was player 1 who died......what?
2510
Screen.CameraEnabled = false
2511
end if
2512
break
2513
end switch
2514
// lose your warp-run if you receive damage
2515
if Warp.Destination > WARPDEST_NONE
2516
if Warp.Timer > 99
2517
if Warp.Timer < 204
2518
Warp.Destination = WARPDEST_NONE
2519
end if
2520
end if
2521
Warp.Timer = 0
2522
end if
2523
end function
2524
2525
2526
function Player_State_Hurt
2527
#platform: Use_Origins
2528
Player.TileCollisions = true
2529
#endplatform
2530
if Player.Gravity == GRAVITY_AIR
2531
Player.TrackScroll = true
2532
if Player.GravityStrength == 0x3800
2533
Player.YVelocity += 0x3000
2534
else
2535
Player.YVelocity += 0xF00
2536
end if
2537
Player.XVelocity = Player.Speed
2538
else
2539
Player.State = Player_State_Ground
2540
Player.InvincibleTimer = 120
2541
Player.BlinkTimer = 3
2542
Player.Speed = 0
2543
Player.XVelocity = 0
2544
CallFunction(Player_HandleOnGround)
2545
end if
2546
end function
2547
2548
2549
function Player_State_OuttaHere
2550
// preparing to jump
2551
if Player.Timer < 140
2552
Player.Timer++
2553
else
2554
// The Jump.
2555
Player.Timer = 0
2556
Player.DrawOrder = 5
2557
2558
if Player.Direction == FACING_RIGHT
2559
Player.Speed = 0x10000
2560
Player.XVelocity = 0x10000
2561
else
2562
Player.Speed = -0x10000
2563
Player.XVelocity = -0x10000
2564
end if
2565
Player.YVelocity = -0x58000
2566
Player.State = Player_State_Death
2567
2568
Player.TileCollisions = false
2569
Player.ObjectInteraction = false
2570
2571
Screen.CameraEnabled = false
2572
end if
2573
end function
2574
2575
// YOU DIED.
2576
function Player_State_Death
2577
Player.ControlMode = CONTROLMODE_NONE
2578
Player.YVelocity += 0x3800
2579
// Don't override the bored animation
2580
if Player.Animation != ANI_BORED
2581
Player.Animation = ANI_DYING
2582
end if
2583
2584
if Player.YVelocity > 0x100000
2585
#platform: Use_Origins
2586
EngineCallback(NOTIFY_DEATH_EVENT)
2587
#endplatform
2588
2589
if Player.Lives > 0
2590
if Player.Animation == ANI_BORED // Outta Here makes an automatic game over, no lifes will save you
2591
Player.Lives = 0
2592
else
2593
2594
#platform: Use_Origins
2595
// Check that we are actually in a mode where we use lives
2596
if game.coinMode == false
2597
if game.playMode != BOOT_PLAYMODE_MISSION
2598
CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
2599
TempValue0 = CheckResult
2600
CheckEqual(game.oneStageFlag, false)
2601
TempValue0 |= CheckResult
2602
if TempValue0 != 0
2603
Player.Lives--
2604
end if
2605
end if
2606
end if
2607
#endplatform
2608
2609
#platform: Use_Standalone
2610
// In Standalone, we don't have any extra things to worry about
2611
Player.Lives--
2612
#endplatform
2613
end if
2614
end if
2615
2616
Stage.TimeEnabled = false
2617
2618
#platform: Use_Origins
2619
CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
2620
TempValue0 = CheckResult
2621
CheckNotEqual(Player.Lives, 0)
2622
TempValue0 |= CheckResult
2623
// Check if the player is replaying the stage from My Data & Rankings
2624
CheckEqual(game.oneStageFlag, false)
2625
CheckResult |= TempValue0
2626
#endplatform
2627
2628
#platform: Use_Standalone
2629
// Slight workaround to make this cleaner - the check below this comes from Origins, but we need it to always be true on standalone
2630
2631
CheckResult = true
2632
#endplatform
2633
2634
// Again, this check is new to Origins and doesn't exist in Standalone
2635
if CheckResult != false
2636
Object.Type = TypeName[Death Event]
2637
DeathEvent.DrawOrder = 7
2638
DeathEvent.Text1XPos = Screen.CenterX
2639
DeathEvent.Text1XPos -= 232
2640
DeathEvent.Text2XPos = Screen.CenterX
2641
DeathEvent.Text2XPos += 232
2642
end if
2643
2644
if Options.GameMode == MODE_TIMEATTACK
2645
DeathEvent.Timer = 0
2646
DeathEvent.State = DEATHEVENT_TIMEATTACK
2647
else
2648
if Player.Lives == 0
2649
DeathEvent.Timer = -2880
2650
DeathEvent.State = DEATHEVENT_GAMEOVER
2651
// *Technically it goes to the traditional game over in the same state
2652
PlayMusic(5)
2653
Stage.PauseEnabled = false
2654
2655
#platform: Use_Origins
2656
if game.oneStageFlag != false
2657
game.callbackResult = -1 // Reset any callback result
2658
game.callbackParam0 = 0 // 0 - Normal Retry, anything else - Show current and best time
2659
game.callbackParam1 = Stage.ListPos // Get current stage
2660
game.callbackParam2 = 0 // Unknown
2661
EngineCallback(NOTIFY_STAGE_RETRY)
2662
end if
2663
#endplatform
2664
2665
else
2666
DeathEvent.Timer = 0
2667
DeathEvent.State = DEATHEVENT_FADEOUT
2668
2669
#platform: Use_Origins
2670
// Lots of checks here, before we do anything else
2671
2672
if game.coinMode == false
2673
if game.playMode != BOOT_PLAYMODE_BOSSRUSH
2674
if Stage.Minutes == 9
2675
if Stage.Seconds == 59
2676
// Check if the player is replaying the stage from My Data & Rankings
2677
if game.oneStageFlag == false
2678
DeathEvent.Timer = -2880
2679
DeathEvent.State = DEATHEVENT_TIMEOVER
2680
2681
PlayMusic(5)
2682
Stage.PauseEnabled = false
2683
end if
2684
end if
2685
end if
2686
end if
2687
end if
2688
#endplatform
2689
2690
#platform: Use_Standalone
2691
if Stage.Minutes == 9
2692
if Stage.Seconds == 59
2693
DeathEvent.Timer = -2880
2694
DeathEvent.State = DEATHEVENT_TIMEOVER
2695
2696
PlayMusic(5)
2697
Stage.PauseEnabled = false
2698
end if
2699
end if
2700
#endplatform
2701
end if
2702
end if
2703
end if
2704
end function
2705
2706
// Same as death, just slower and without the bored or time over stuff
2707
function Player_State_Drown
2708
Player.ControlMode = CONTROLMODE_NONE
2709
Player.YVelocity += Player.GravityStrength
2710
Player.Animation = ANI_DROWNING
2711
2712
if Player.YVelocity > 0x80000
2713
#platform: Use_Origins
2714
EngineCallback(NOTIFY_DEATH_EVENT)
2715
2716
// We only subtract lives sometimes in Origins
2717
if game.coinMode == false
2718
if game.playMode != BOOT_PLAYMODE_MISSION
2719
CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
2720
TempValue0 = CheckResult
2721
CheckEqual(game.oneStageFlag, false)
2722
TempValue0 |= CheckResult
2723
if TempValue0 != false
2724
if Player.Lives > 0
2725
Player.Lives--
2726
end if
2727
end if
2728
end if
2729
end if
2730
#endplatform
2731
2732
#platform: Use_Standalone
2733
if Player.Lives > 0
2734
Player.Lives--
2735
end if
2736
#endplatform
2737
2738
Stage.TimeEnabled = false
2739
2740
Object.Type = TypeName[DeathEvent]
2741
DeathEvent.DrawOrder = 7
2742
DeathEvent.Text1XPos = Screen.CenterX
2743
DeathEvent.Text1XPos -= 232
2744
DeathEvent.Text2XPos = Screen.CenterX
2745
DeathEvent.Text2XPos += 232
2746
2747
if Options.GameMode == MODE_TIMEATTACK
2748
DeathEvent.Timer = 0
2749
DeathEvent.State = DEATHEVENT_TIMEATTACK
2750
else
2751
if Player.Lives == 0
2752
DeathEvent.Timer = -2880
2753
DeathEvent.State = DEATHEVENT_GAMEOVER
2754
2755
PlayMusic(5)
2756
Stage.PauseEnabled = false
2757
else
2758
DeathEvent.Timer = 0
2759
DeathEvent.State = DEATHEVENT_FADEOUT
2760
end if
2761
end if
2762
end if
2763
end function
2764
2765
// Wacky Workbench hanging bar gimmick
2766
function Player_State_HangBar
2767
if Player.Left == true
2768
Player.Direction = FACING_LEFT
2769
Player.Speed = -0x20000
2770
Player.AnimationSpeed = 30
2771
else
2772
if Player.Right == true
2773
Player.Direction = FACING_RIGHT
2774
Player.Speed = 0x20000
2775
Player.AnimationSpeed = 30
2776
else
2777
Player.Speed = 0
2778
Player.AnimationSpeed = 0
2779
end if
2780
end if
2781
2782
TempValue1 = Player.XPos
2783
TempValue1 >>= 16
2784
2785
TempValue2 = Player.YPos
2786
TempValue2 >>= 16
2787
TempValue2 += Player.CollisionTop
2788
// Check that you are in the hanging bar
2789
Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)
2790
if TempValue0 != 3 // seems like you're not
2791
2792
#platform: Use_Origins
2793
Player.State = Player_State_Air_NoDropDash
2794
#endplatform
2795
2796
#platform: Use_Standalone
2797
Player.State = Player_State_Air
2798
#endplatform
2799
2800
Player.Speed = 0
2801
Player.AnimationSpeed = 0
2802
Player.YVelocity = 0
2803
end if
2804
2805
// Manual Drop
2806
if Player.JumpPress == true
2807
2808
Player.State = Player_State_Air
2809
Player.YVelocity = 0
2810
Player.Speed = 0
2811
Player.AnimationSpeed = 0
2812
Player.YPos += 0x40000
2813
end if
2814
Player.XVelocity = Player.Speed
2815
// Cancel warp
2816
if Warp.Destination > WARPDEST_NONE
2817
if Warp.Timer > 99
2818
if Warp.Timer < 204
2819
Warp.Destination = WARPDEST_NONE
2820
end if
2821
end if
2822
2823
Warp.Timer = 0
2824
end if
2825
end function
2826
2827
// Unused leftover from Sonic Nexus (2008)
2828
function Player_State_CorkscrewRun
2829
Player.Angle = 0
2830
CallFunction(Player_HandleGroundMovement)
2831
Player.Animation = 34 // Corkscrew animation, it uses Nexus values and as such, it just looks like a jumbled mess in-game
2832
2833
if Player.Speed < 0x60000
2834
if Player.Speed > -0x60000
2835
Player.Animation = ANI_WALKING
2836
2837
#platform: Use_Origins
2838
Player.State = Player_State_Air_NoDropDash
2839
#endplatform
2840
2841
#platform: Use_Standalone
2842
Player.State = Player_State_Air
2843
#endplatform
2844
2845
Player.Rotation = 0
2846
2847
if Player.Speed < 0
2848
Player.Direction = FACING_LEFT
2849
end if
2850
end if
2851
end if
2852
2853
if Player.Down == true
2854
if Player.Speed > 0x199A
2855
Player.State = Player_State_CorkscrewRoll
2856
Player.Animation = ANI_JUMPING
2857
end if
2858
2859
if Player.Speed < -0x199A
2860
Player.State = Player_State_CorkscrewRoll
2861
Player.Animation = ANI_JUMPING
2862
end if
2863
end if
2864
2865
if Player.Skidding > 0
2866
if Player.Skidding == 16
2867
PlaySfx(SFX_G_DESTROY, false) // Would be Skidding SFX if using Nexus SFX list
2868
end if
2869
Player.Animation = ANI_SKIDDING
2870
Player.Skidding--
2871
end if
2872
2873
if Player.JumpPress == true
2874
CallFunction(Player_Action_Jump)
2875
else
2876
CallFunction(Player_HandleOnGround)
2877
end if
2878
end function
2879
2880
// Unused leftover from Sonic Nexus (2008)
2881
function Player_State_CorkscrewRoll
2882
Player.Angle = 0
2883
CallFunction(Player_HandleRollDeceleration)
2884
2885
if Player.Speed < 0x60000
2886
if Player.Speed > -0x60000
2887
2888
#platform: Use_Origins
2889
Player.State = Player_State_Air_NoDropDash
2890
#endplatform
2891
2892
#platform: Use_Standalone
2893
Player.State = Player_State_Air
2894
#endplatform
2895
2896
end if
2897
end if
2898
2899
if Player.JumpPress == true
2900
CallFunction(Player_Action_Jump)
2901
else
2902
CallFunction(Player_HandleOnGround)
2903
end if
2904
end function
2905
2906
// Tube Switch function
2907
function Player_State_TubeRoll
2908
#platform: Use_Origins
2909
Player.DropDashCharge = -1
2910
#endplatform
2911
if Player.Gravity == GRAVITY_AIR // end the function if you are in the air
2912
2913
#platform: Use_Origins
2914
Player.State = Player_State_Air_NoDropDash
2915
#endplatform
2916
2917
#platform: Use_Standalone
2918
Player.State = Player_State_Air
2919
#endplatform
2920
2921
Player.Timer = 0
2922
CallFunction(Player_HandleAirMovement)
2923
else
2924
if Player.Speed > 0
2925
if Player.Speed < Player.MinRollSpeed
2926
Player.Speed = Player.MinRollSpeed
2927
end if
2928
2929
if Player.Speed > 0x100000
2930
Player.Speed = 0x100000
2931
end if
2932
else
2933
TempValue0 = Player.MinRollSpeed
2934
FlipSign(TempValue0)
2935
if Player.Speed > TempValue0
2936
Player.Speed = TempValue0
2937
CallFunction(Player_HandleOnGround)
2938
end if
2939
2940
if Player.Speed < -0x100000
2941
Player.Speed = -0x100000
2942
end if
2943
end if
2944
2945
TempValue0 = Player.Speed
2946
if TempValue0 < 0
2947
FlipSign(TempValue0)
2948
end if
2949
2950
if TempValue0 < 0x5F5C2
2951
// Warp Star delete checks
2952
if Warp.Destination > WARPDEST_NONE
2953
if Warp.Timer > 99
2954
if Warp.Timer < 204
2955
Warp.Destination = WARPDEST_NONE
2956
end if
2957
end if
2958
Warp.Timer = 0
2959
end if
2960
else
2961
// Warp Star spawnning
2962
if Warp.Destination > WARPDEST_NONE
2963
if Warp.Timer == 0
2964
Warp.Timer = 1
2965
CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)
2966
WarpStar.Timer = 7
2967
WarpStar.DrawOrder = 4
2968
end if
2969
end if
2970
end if
2971
2972
CallFunction(Player_HandleRollDeceleration)
2973
CallFunction(Player_HandleRollAnimSpeed)
2974
Player.AnimationSpeed = Player.RollAnimationSpeed
2975
CallFunction(Player_HandleOnGround)
2976
end if
2977
end function
2978
2979
function Player_State_TubeAirRoll
2980
#platform: Use_Origins
2981
Player.DropDashCharge = -1
2982
#endplatform
2983
Player.Right = false
2984
Player.Left = false
2985
if Player.Gravity == GRAVITY_AIR
2986
2987
#platform: Use_Origins
2988
Player.State = Player_State_Air_NoDropDash
2989
#endplatform
2990
2991
#platform: Use_Standalone
2992
Player.State = Player_State_Air
2993
#endplatform
2994
2995
Player.Timer = 0
2996
CallFunction(Player_HandleAirMovement)
2997
else
2998
if Player.Speed > 0
2999
Player.Speed = Player.MinRollSpeed
3000
else
3001
TempValue0 = Player.MinRollSpeed
3002
FlipSign(TempValue0)
3003
Player.Speed = TempValue0
3004
end if
3005
3006
TempValue0 = Player.Speed
3007
if TempValue0 < 0
3008
FlipSign(TempValue0)
3009
end if
3010
3011
if TempValue0 < 0x5F5C2
3012
if Warp.Destination > WARPDEST_NONE
3013
if Warp.Timer > 99
3014
if Warp.Timer < 204
3015
Warp.Destination = WARPDEST_NONE
3016
end if
3017
end if
3018
Warp.Timer = 0
3019
end if
3020
else
3021
if Warp.Destination > WARPDEST_NONE
3022
if Warp.Timer == 0
3023
Warp.Timer = 1
3024
CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)
3025
WarpStar.Timer = 7
3026
WarpStar.DrawOrder = 4
3027
end if
3028
end if
3029
end if
3030
CallFunction(Player_HandleRollDeceleration)
3031
CallFunction(Player_HandleRollAnimSpeed)
3032
Player.AnimationSpeed = Player.RollAnimationSpeed
3033
CallFunction(Player_HandleOnGround)
3034
end if
3035
end function
3036
3037
// Palmtree Panic and Wacky Workbench spinning tops
3038
function Player_State_SpinningTop
3039
Player.Timer += Player.MinRollSpeed
3040
if Player.Gravity == GRAVITY_AIR // Drop from them if you get out of range
3041
3042
#platform: Use_Origins
3043
Player.State = Player_State_Air_NoDropDash
3044
#endplatform
3045
3046
#platform: Use_Standalone
3047
Player.State = Player_State_Air
3048
#endplatform
3049
3050
Player.Animation = ANI_WALKING
3051
Player.Timer = 0
3052
CallFunction(Player_HandleAirMovement)
3053
else
3054
CallFunction(Player_HandleOnGround)
3055
end if
3056
end function
3057
3058
// Amy Rose's favorite function
3059
function Player_State_Hugged
3060
if Player.Gravity == GRAVITY_AIR // No hugs if you're in the air
3061
3062
#platform: Use_Origins
3063
Player.State = Player_State_Air_NoDropDash
3064
#endplatform
3065
3066
#platform: Use_Standalone
3067
Player.State = Player_State_Air
3068
#endplatform
3069
3070
Player.Animation = ANI_WALKING
3071
Player.Timer = 0
3072
CallFunction(Player_HandleAirMovement)
3073
else
3074
CallFunction(Player_HandleOnGround)
3075
// Yes, the only thing the function does is make you wait
3076
if Player.Timer < 240
3077
Player.Animation = ANI_STOPPED
3078
Player.Timer++
3079
else
3080
Player.Animation = ANI_WAITING
3081
end if
3082
3083
// Warp cancel check
3084
if Warp.Destination > WARPDEST_NONE
3085
if Warp.Timer > 99
3086
if Warp.Timer < 204
3087
Warp.Destination = WARPDEST_NONE
3088
end if
3089
end if
3090
Warp.Timer = 0
3091
end if
3092
3093
// Get free from Amy
3094
if Player.JumpPress == true
3095
CallFunction(Player_Action_Jump)
3096
end if
3097
end if
3098
end function
3099
3100
// Palmtree Panic Ramp
3101
function Player_State_Ramp3D
3102
CallFunction(Player_HandleGroundMovement)
3103
if Player.Gravity == GRAVITY_AIR
3104
3105
#platform: Use_Origins
3106
Player.State = Player_State_Air_NoDropDash
3107
#endplatform
3108
3109
#platform: Use_Standalone
3110
Player.State = Player_State_Air
3111
#endplatform
3112
3113
Player.Timer = 0
3114
CallFunction(Player_HandleAirMovement)
3115
// Set the equivalent animation for looking to the left
3116
if Player.Direction == FACING_LEFT
3117
3118
if Player.Animation == ANI_RAMP_RUNNING3
3119
Player.Animation = ANI_RAMP_RUNNING5
3120
end if
3121
3122
if Player.Animation == ANI_RAMP_RUNNING2
3123
Player.Animation = ANI_RAMP_RUNNING6
3124
end if
3125
3126
end if
3127
else
3128
#platform: Use_Origins
3129
if Player.Animation == ANI_GLIDING
3130
Player.XVelocity = 0
3131
Player.YVelocity = 0
3132
Player.Speed = 0
3133
Player.Animation = ANI_GLIDING_STOP
3134
end if
3135
#endplatform
3136
CallFunction(Player_HandleOnGround)
3137
if Player.Speed == 0
3138
// Warp Star erase check
3139
if Warp.Destination > WARPDEST_NONE
3140
if Warp.Timer > 99
3141
if Warp.Timer < 204
3142
Warp.Destination = WARPDEST_NONE
3143
end if
3144
end if
3145
Warp.Timer = 0
3146
end if
3147
// Waiting timer while in the ramp
3148
if Player.Timer < 240
3149
Player.Animation = ANI_STOPPED
3150
Player.Timer++
3151
else
3152
Player.Animation = ANI_WAITING
3153
end if
3154
else
3155
// Set animation based on angle
3156
if Player.Angle == 0
3157
Player.Animation = ANI_RAMP_RUNNING1
3158
end if
3159
3160
if Player.Angle > 200
3161
if Player.Direction == FACING_RIGHT
3162
Player.Animation = ANI_RAMP_RUNNING3
3163
else
3164
Player.Animation = ANI_RAMP_RUNNING5
3165
end if
3166
end if
3167
3168
if Player.Angle > 216
3169
if Player.Direction == FACING_RIGHT
3170
Player.Animation = ANI_RAMP_RUNNING2
3171
else
3172
Player.Animation = ANI_RAMP_RUNNING6
3173
end if
3174
end if
3175
3176
if Player.Angle > 232
3177
Player.Animation = ANI_RAMP_RUNNING1
3178
end if
3179
3180
if Player.Angle == 192
3181
Player.Animation = ANI_RAMP_RUNNING4
3182
end if
3183
end if
3184
3185
if Player.JumpPress == true
3186
CallFunction(Player_Action_Jump)
3187
else
3188
if Player.Up == true
3189
if Player.Speed == 0
3190
Player.State = Player_State_LookUp
3191
Player.Animation = ANI_LOOKINGUP
3192
Player.Timer = 0
3193
end if
3194
end if
3195
if Player.Down == true
3196
if Player.Speed == 0
3197
Player.State = Player_State_Crouch
3198
Player.Animation = ANI_LOOKINGDOWN
3199
Player.Timer = 0
3200
else
3201
if Player.Speed > 0x199A
3202
Player.ControlLock = 0
3203
Player.State = Player_State_Roll
3204
Player.Animation = ANI_JUMPING
3205
end if
3206
3207
if Player.Speed < -0x199A
3208
Player.ControlLock = 0
3209
Player.State = Player_State_Roll
3210
Player.Animation = ANI_JUMPING
3211
end if
3212
end if
3213
end if
3214
end if
3215
end if
3216
3217
if Player.Animation != ANI_STOPPED
3218
Player.AnimationSpeed = Player.Speed
3219
if Player.AnimationSpeed < 0
3220
FlipSign(Player.AnimationSpeed)
3221
end if
3222
Player.AnimationSpeed *= 60
3223
Player.AnimationSpeed /= 0x60000
3224
Player.AnimationSpeed += 20
3225
else
3226
Player.AnimationSpeed = 0
3227
end if
3228
end function
3229
3230
3231
function Player_State_WaterCurrent
3232
Player.Gravity = GRAVITY_AIR
3233
3234
if Player.Up == true
3235
Player.YPos -= 0x20000
3236
end if
3237
3238
if Player.Down == true
3239
Player.YPos += 0x20000
3240
end if
3241
3242
if Player.Left == true
3243
Player.XPos -= 0x20000
3244
end if
3245
3246
if Player.Right == true
3247
Player.XPos += 0x20000
3248
end if
3249
end function
3250
3251
function Player_SetJumpOffset
3252
#platform: Use_Origins
3253
if Mini_PlayerFlag == true
3254
Player.JumpOffset = -1
3255
else
3256
if Stage.PlayerListPos == PLAYER_SONIC
3257
Player.JumpOffset = -5
3258
end if
3259
3260
if Stage.PlayerListPos == PLAYER_TAILS
3261
Player.JumpOffset = -1
3262
end if
3263
3264
if Stage.PlayerListPos == PLAYER_KNUCKLES
3265
Player.JumpOffset = -5
3266
end if
3267
3268
if Stage.PlayerListPos == PLAYER_AMY
3269
Player.JumpOffset = -4
3270
end if
3271
end if
3272
#endplatform
3273
end function
3274
3275
function Player_State_SizeChange
3276
Player.TileCollisions = true
3277
if Player.Gravity == GRAVITY_AIR // Knockback after touching the laser
3278
Player.TrackScroll = true
3279
Player.YVelocity += 0x3000
3280
Player.XVelocity = Player.Speed
3281
else
3282
Player.State = Player_State_Ground
3283
3284
Player.InvincibleTimer = 120
3285
Player.BlinkTimer = 3
3286
3287
Player.Speed = 0
3288
Player.XVelocity = 0
3289
3290
CallFunction(Player_HandleOnGround)
3291
if Mini_PlayerFlag == false
3292
Mini_PlayerFlag = true
3293
3294
#platform: Use_Standalone
3295
Player.JumpOffset = -1
3296
switch Stage.PlayerListPos
3297
case PLAYER_SONIC_A
3298
LoadAnimation("MiniSonic.Ani")
3299
break
3300
3301
case PLAYER_TAILS_A
3302
LoadAnimation("MiniTails.Ani")
3303
Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites
3304
break
3305
end switch
3306
#endplatform
3307
3308
#platform: Use_Origins
3309
switch Stage.PlayerListPos
3310
case PLAYER_SONIC_A
3311
LoadAnimation("MiniSonic.Ani")
3312
break
3313
3314
case PLAYER_TAILS_A
3315
LoadAnimation("MiniTails.Ani")
3316
Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites
3317
break
3318
3319
case PLAYER_KNUCKLES_A
3320
LoadAnimation("MiniKnuckles.Ani")
3321
Object[1].Type = TypeName[Blank Object] // Mini Knuckles... doesn't have tails, but set the object to blank anyway, I guess
3322
break
3323
3324
case PLAYER_AMY_A
3325
LoadAnimation("MiniAmy.Ani")
3326
Object[1].Type = TypeName[Blank Object] // Mini Amy... doesn't have tails, but set the object to blank anyway, I guess
3327
break
3328
end switch
3329
#endplatform
3330
else
3331
Mini_PlayerFlag = false
3332
3333
#platform: Use_Standalone
3334
switch Stage.PlayerListPos
3335
case PLAYER_SONIC_A
3336
LoadAnimation("Sonic.Ani")
3337
Player.JumpOffset = -5
3338
break
3339
3340
case PLAYER_TAILS_A
3341
LoadAnimation("Tails.Ani")
3342
Player.JumpOffset = -1
3343
Object[1].Type = TypeName[Tails Object] // Restore Tails's tails
3344
break
3345
end switch
3346
#endplatform
3347
3348
#platform: Use_Origins
3349
if Stage.PlayerListPos == PLAYER_SONIC
3350
LoadAnimation("Sonic.Ani")
3351
end if
3352
3353
if Stage.PlayerListPos == PLAYER_TAILS
3354
LoadAnimation("Tails.Ani")
3355
Object[1].Type = TypeName[Tails Object] // Restore Tails's tails
3356
end if
3357
3358
if Stage.PlayerListPos == PLAYER_KNUCKLES
3359
LoadAnimation("Knuckles.Ani")
3360
end if
3361
3362
if Stage.PlayerListPos == PLAYER_AMY
3363
LoadAnimation("Amy.Ani")
3364
end if
3365
#endplatform
3366
end if
3367
3368
#platform: Use_Origins
3369
CallFunction(Player_SetJumpOffset)
3370
#endplatform
3371
3372
BindPlayerToObject(0, 0)
3373
end if
3374
end function
3375
3376
3377
function Player_HandleDropDash
3378
#platform: Use_Origins
3379
if Player.DropDashCharge >= 0
3380
if Player.DropDashCharge == 0
3381
if Player.JumpPress == true
3382
if Stage.PlayerListPos == PLAYER_SONIC
3383
Player.DropDashCharge = 1
3384
else
3385
if Stage.PlayerListPos == PLAYER_AMY
3386
Player.DropDashCharge = 1
3387
else
3388
Player.DropDashCharge = -1
3389
end if
3390
end if
3391
end if
3392
else
3393
if Player.JumpHold == false
3394
if Stage.PlayerListPos == PLAYER_TAILS
3395
Player.DropDashCharge = -1
3396
else
3397
if Player.DropDashCharge >= 20
3398
Player.DropDashCharge = -1
3399
end if
3400
end if
3401
else
3402
Player.DropDashCharge++
3403
if Player.DropDashCharge == 20
3404
PlaySfx(SFX_G_DROPDASH, false)
3405
end if
3406
3407
if Player.DropDashCharge >= 20
3408
if Player.Animation == ANI_JUMPING
3409
Player.Frame = 0
3410
Player.AnimationTimer = 0
3411
Player.AnimationSpeed = 1
3412
end if
3413
end if
3414
end if
3415
end if
3416
end if
3417
#endplatform
3418
end function
3419
3420
function Player_Action_DblJumpKnux
3421
#platform: Use_Origins
3422
if Player.YVelocity >= Player.JumpCap
3423
if Player.JumpPress == true
3424
game.callbackParam0 = 1
3425
game.callbackParam1 = 0
3426
game.callbackParam2 = 0
3427
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
3428
Player.Speed = 0x40000
3429
if Player.YVelocity < 0
3430
Player.YVelocity = 0
3431
end if
3432
if Player.Direction == FACING_RIGHT
3433
Player.State = Player_State_GlideRight
3434
Player.XVelocity = 0x40000
3435
Player.Timer = 0
3436
else
3437
Player.State = Player_State_GlideLeft
3438
Player.XVelocity = -0x40000
3439
Player.Timer = 256
3440
end if
3441
Player.Animation = ANI_GLIDING
3442
Player.Frame = 2
3443
Object.Frame = 2
3444
end if
3445
end if
3446
#endplatform
3447
end function
3448
3449
3450
function Player_State_GlideLeft
3451
#platform: Use_Origins
3452
if Player.Speed == 0
3453
if Warp.Destination > 0
3454
if Warp.Timer > 99
3455
if Warp.Timer < 204
3456
Warp.Destination = 0
3457
end if
3458
end if
3459
Warp.Timer = 0
3460
end if
3461
end if
3462
3463
if Player.Gravity == GRAVITY_AIR
3464
if Player.JumpHold == true
3465
if Player.Timer == 256
3466
if Player.Speed < 0x180000
3467
Player.Speed += 0x400
3468
end if
3469
else
3470
if Player.Speed < 0x40000
3471
Player.Speed += 0x1000
3472
end if
3473
end if
3474
3475
if Player.YVelocity > 0x8000
3476
Player.YVelocity -= 0x2000
3477
else
3478
Player.YVelocity += 0x2000
3479
end if
3480
3481
if Player.Timer < 256
3482
Player.Timer += 4
3483
end if
3484
3485
if Player.Timer < 170
3486
if Player.Timer > 86
3487
Player.Frame = 0
3488
else
3489
if Player.Timer > 44
3490
Player.Frame = 1
3491
else
3492
Player.Frame = 2
3493
end if
3494
end if
3495
else
3496
if Player.Timer < 212
3497
Player.Frame = 1
3498
else
3499
Player.Frame = 2
3500
end if
3501
end if
3502
3503
TempValue7 = Player.XPos
3504
if Player.Timer < 128
3505
Player.Direction = FACING_RIGHT
3506
TempValue0 = false
3507
TempValue1 = false
3508
else
3509
Player.Direction = FACING_LEFT
3510
Player.XPos = TempValue7
3511
Player.XPos += Player.XVelocity
3512
Player.YPos = Player.YPos
3513
Object.XPos = Player.XPos
3514
Object.YPos = Player.YPos
3515
ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)
3516
Player.XPos = Object.XPos
3517
TempValue0 = CheckResult
3518
TempValue2 = Player.XPos
3519
Player.XPos = TempValue7
3520
Player.XPos += Player.XVelocity
3521
Object.XPos = Player.XPos
3522
Object.YPos = Player.YPos
3523
ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)
3524
Player.XPos = Object.XPos
3525
TempValue1 = CheckResult
3526
TempValue3 = Player.XPos
3527
end if
3528
3529
Cos(Player.XVelocity, Player.Timer)
3530
Player.XVelocity *= Player.Speed
3531
Player.XVelocity >>= 9
3532
if Player.Right == true
3533
Player.State = Player_State_GlideRight
3534
3535
if Warp.Destination > 0
3536
if Warp.Timer > 99
3537
if Warp.Timer < 204
3538
Warp.Destination = 0
3539
end if
3540
end if
3541
Warp.Timer = 0
3542
end if
3543
end if
3544
3545
Player.XPos = TempValue7
3546
CheckResult = TempValue0
3547
CheckResult &= TempValue1
3548
if CheckResult == true
3549
if TempValue2 == TempValue3
3550
if Player.XVelocity > 0
3551
Player.Direction = FACING_RIGHT
3552
end if
3553
Player.State = Player_State_Climb
3554
Player.Speed = 0
3555
Player.XVelocity = 0
3556
Player.YVelocity = 0
3557
Player.Timer = 0
3558
PlaySfx(SFX_G_GRAB, false)
3559
game.callbackParam0 = 2
3560
game.callbackParam1 = 0
3561
game.callbackParam2 = 0
3562
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
3563
if Warp.Destination > 0
3564
if Warp.Timer > 99
3565
if Warp.Timer < 204
3566
Warp.Destination = 0
3567
end if
3568
end if
3569
Warp.Timer = 0
3570
end if
3571
else
3572
Player.XVelocity >>= 2
3573
Player.Speed = Player.XVelocity
3574
CallFunction(Player_Action_GlideDrop)
3575
end if
3576
else
3577
if TempValue0 == true
3578
if TempValue1 == false
3579
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)
3580
end if
3581
3582
if CheckResult == false
3583
Player.XVelocity >>= 2
3584
Player.Speed = Player.XVelocity
3585
CallFunction(Player_Action_GlideDrop)
3586
end if
3587
end if
3588
end if
3589
else
3590
Player.XVelocity >>= 2
3591
Player.Speed = Player.XVelocity
3592
CallFunction(Player_Action_GlideDrop)
3593
end if
3594
else
3595
if Player.CollisionMode == CMODE_FLOOR
3596
Player.Timer = 0
3597
Player.State = Player_State_GlideSlide
3598
Player.Animation = ANI_GLIDING_STOP
3599
Player.Speed = Player.XVelocity
3600
else
3601
Player.State = Player_State_Ground
3602
CallFunction(Player_HandleOnGround)
3603
Player.Skidding = 0
3604
end if
3605
end if
3606
3607
CallFunction(Player_CheckRoofGlide)
3608
#endplatform
3609
end function
3610
3611
3612
function Player_State_GlideRight
3613
#platform: Use_Origins
3614
if Player.Speed == 0
3615
if Warp.Destination > 0
3616
if Warp.Timer > 99
3617
if Warp.Timer < 204
3618
Warp.Destination = 0
3619
end if
3620
end if
3621
Warp.Timer = 0
3622
end if
3623
end if
3624
3625
if Player.Gravity == GRAVITY_AIR
3626
if Player.JumpHold == true
3627
if Player.Timer == 0
3628
if Player.Speed < 0x180000
3629
Player.Speed += 0x400
3630
end if
3631
else
3632
if Player.Speed < 0x40000
3633
Player.Speed += 0x1000
3634
end if
3635
end if
3636
3637
if Player.YVelocity > 0x8000
3638
Player.YVelocity -= 0x2000
3639
else
3640
Player.YVelocity += 0x2000
3641
end if
3642
3643
if Player.Timer > 0
3644
Player.Timer -= 4
3645
end if
3646
3647
if Player.Timer < 170
3648
if Player.Timer > 86
3649
Player.Frame = 0
3650
else
3651
if Player.Timer > 44
3652
Player.Frame = 1
3653
else
3654
Player.Frame = 2
3655
end if
3656
end if
3657
else
3658
if Player.Timer < 212
3659
Player.Frame = 1
3660
else
3661
Player.Frame = 2
3662
end if
3663
end if
3664
3665
TempValue7 = Player.XPos
3666
if Player.Timer < 128
3667
Player.Direction = FACING_RIGHT
3668
Player.XPos = TempValue7
3669
Player.XPos += Player.XVelocity
3670
Player.YPos = Player.YPos
3671
Object.XPos = Player.XPos
3672
Object.YPos = Player.YPos
3673
ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)
3674
Player.XPos = Object.XPos
3675
TempValue0 = CheckResult
3676
TempValue2 = Player.XPos
3677
Player.XPos = TempValue7
3678
Player.XPos += Player.XVelocity
3679
Object.XPos = Player.XPos
3680
Object.YPos = Player.YPos
3681
ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)
3682
Player.XPos = Object.XPos
3683
TempValue1 = CheckResult
3684
TempValue3 = Player.XPos
3685
else
3686
Player.Direction = FACING_LEFT
3687
TempValue0 = false
3688
TempValue1 = false
3689
end if
3690
3691
Cos(Player.XVelocity, Player.Timer)
3692
Player.XVelocity *= Player.Speed
3693
Player.XVelocity >>= 9
3694
if Player.Left == true
3695
Player.State = Player_State_GlideLeft
3696
3697
if Warp.Destination > 0
3698
if Warp.Timer > 99
3699
if Warp.Timer < 204
3700
Warp.Destination = 0
3701
end if
3702
end if
3703
Warp.Timer = 0
3704
end if
3705
end if
3706
3707
Player.XPos = TempValue7
3708
CheckResult = TempValue0
3709
CheckResult &= TempValue1
3710
if CheckResult == true
3711
TempValue2 >>= 1
3712
TempValue3 >>= 1
3713
if TempValue2 == TempValue3
3714
if Player.XVelocity < 0
3715
Player.Direction = FACING_LEFT
3716
end if
3717
Player.State = Player_State_Climb
3718
Player.Speed = 0
3719
Player.XVelocity = 0
3720
Player.YVelocity = 0
3721
Player.Timer = 0
3722
PlaySfx(SFX_G_GRAB, false)
3723
game.callbackParam0 = 2
3724
game.callbackParam1 = 0
3725
game.callbackParam2 = 0
3726
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
3727
if Warp.Destination > 0
3728
if Warp.Timer > 99
3729
if Warp.Timer < 204
3730
Warp.Destination = 0
3731
end if
3732
end if
3733
Warp.Timer = 0
3734
end if
3735
else
3736
Player.XVelocity >>= 2
3737
Player.Speed = Player.XVelocity
3738
CallFunction(Player_Action_GlideDrop)
3739
end if
3740
else
3741
if TempValue0 == true
3742
if TempValue1 == false
3743
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)
3744
end if
3745
3746
if CheckResult == false
3747
Player.Speed = 0
3748
Player.XVelocity >>= 2
3749
Player.Speed = Player.XVelocity
3750
CallFunction(Player_Action_GlideDrop)
3751
end if
3752
end if
3753
end if
3754
else
3755
Player.XVelocity >>= 2
3756
Player.Speed = Player.XVelocity
3757
CallFunction(Player_Action_GlideDrop)
3758
end if
3759
else
3760
if Player.CollisionMode == CMODE_FLOOR
3761
Player.Timer = 0
3762
Player.State = Player_State_GlideSlide
3763
Player.Animation = ANI_GLIDING_STOP
3764
Player.Speed = Player.XVelocity
3765
else
3766
Player.State = Player_State_Ground
3767
CallFunction(Player_HandleOnGround)
3768
Player.Skidding = 0
3769
end if
3770
end if
3771
3772
CallFunction(Player_CheckRoofGlide)
3773
#endplatform
3774
end function
3775
3776
3777
function Player_State_GlideDrop
3778
#platform: Use_Origins
3779
if Player.Gravity == GRAVITY_AIR
3780
CallFunction(Player_HandleAirFriction)
3781
CallFunction(Player_HandleAirMovement)
3782
else
3783
if Player.JumpPress == true
3784
Player.XVelocity = 0
3785
Player.Speed = 0
3786
if Player.Down == true
3787
CallFunction(Player.ActionSpindash)
3788
else
3789
CallFunction(Player_Action_Jump)
3790
end if
3791
else
3792
if Player.AbilityTimer == 0
3793
PlaySfx(SFX_G_GLIDEDROPLAND, false)
3794
end if
3795
3796
Player.TrackScroll = false
3797
Player.Speed = 0
3798
Player.XVelocity = 0
3799
Player.Animation = ANI_LOOKINGDOWN
3800
Player.PrevAnimation = ANI_LOOKINGDOWN
3801
Player.Frame = 2
3802
3803
if Player.AbilityTimer < 16
3804
Player.AbilityTimer++
3805
else
3806
Player.AbilityTimer = 0
3807
Player.State = Player_State_Ground
3808
CallFunction(Player_HandleOnGround)
3809
Player.Skidding = 0
3810
if Warp.Destination > 0
3811
if Warp.Timer > 99
3812
if Warp.Timer < 204
3813
Warp.Destination = 0
3814
end if
3815
end if
3816
Warp.Timer = 0
3817
end if
3818
end if
3819
end if
3820
end if
3821
#endplatform
3822
end function
3823
3824
3825
function Player_State_GlideSlide
3826
#platform: Use_Origins
3827
if Player.Gravity == GRAVITY_GROUND
3828
if Player.Speed == 0
3829
if Player.JumpPress == true
3830
if Player.Down == true
3831
CallFunction(Player.ActionSpindash)
3832
else
3833
CallFunction(Player_Action_Jump)
3834
end if
3835
else
3836
Player.TrackScroll = false
3837
Player.Frame = 1
3838
if Player.Timer < 16
3839
Player.Timer++
3840
else
3841
Player.State = Player_State_Ground
3842
CallFunction(Player_HandleOnGround)
3843
Player.Skidding = 0
3844
end if
3845
end if
3846
else
3847
Player.Timer++
3848
TempValue0 = Player.Timer
3849
TempValue0 %= 4
3850
if TempValue0 == 0
3851
CreateTempObject(TypeName[Dust Puff], 0, Player.XPos, Player.YPos)
3852
Object[TempObjectPos].iYPos += Player.CollisionBottom
3853
Object[TempObjectPos].DrawOrder = Player.DrawOrder
3854
end if
3855
3856
Player.Timer %= 8
3857
if Player.Timer == 0
3858
PlaySfx(SFX_G_SLIDE, false)
3859
end if
3860
3861
Player.Frame = 0
3862
if Player.Speed > 0
3863
Player.Speed -= 0x2000
3864
if Player.Speed < 0
3865
Player.Speed = 0
3866
Player.Timer = 0
3867
end if
3868
else
3869
Player.Speed += 0x2000
3870
if Player.Speed > 0
3871
Player.Speed = 0
3872
Player.Timer = 0
3873
end if
3874
end if
3875
if Player.JumpHold == 0
3876
Player.Speed = 0
3877
Player.Timer = 0
3878
end if
3879
end if
3880
3881
Player.XVelocity = Player.Speed
3882
else
3883
CallFunction(Player_Action_GlideDrop)
3884
end if
3885
#endplatform
3886
end function
3887
3888
3889
function Player_State_Climb
3890
#platform: Use_Origins
3891
if Player.Gravity == GRAVITY_AIR
3892
Player.Animation = ANI_CLIMBING
3893
if Player.Up == true
3894
Player.YVelocity = -0x10000
3895
TempValue0 = Player.CollisionTop
3896
TempValue0 *= -0x10000
3897
if Player.YPos < TempValue0
3898
Player.YPos = TempValue0
3899
end if
3900
3901
Player.Timer++
3902
if Player.Timer == 4
3903
Player.Timer = 0
3904
Player.Frame++
3905
if Mini_PlayerFlag == true
3906
Player.Frame %= 2
3907
else
3908
Player.Frame %= 6
3909
end if
3910
end if
3911
else
3912
if Player.Down == true
3913
Player.YVelocity = 0x10000
3914
Player.Timer++
3915
if Player.Timer == 4
3916
Player.Timer = 0
3917
if Player.Frame < 1
3918
if Mini_PlayerFlag == true
3919
Player.Frame += 2
3920
else
3921
Player.Frame += 6
3922
end if
3923
end if
3924
Player.Frame--
3925
end if
3926
else
3927
Player.YVelocity = 0
3928
end if
3929
end if
3930
3931
if Player.JumpPress == true
3932
Player.Animation = ANI_JUMPING
3933
Player.State = Player_State_Air_NoDropDash
3934
Player.Timer = 0
3935
if Player.Direction == FACING_LEFT
3936
Player.XVelocity = 0x40000
3937
Player.Speed = 0x40000
3938
Player.Direction = FACING_RIGHT
3939
else
3940
Player.XVelocity = -0x40000
3941
Player.Speed = -0x40000
3942
Player.Direction = FACING_LEFT
3943
end if
3944
3945
Player.YVelocity = -0x40000
3946
if Player.GravityStrength != 0x3800 // (see if Knuckles is underwater)
3947
Player.XVelocity >>= 1
3948
Player.Speed >>= 1
3949
Player.YVelocity >>= 1
3950
end if
3951
else
3952
if Mini_PlayerFlag == true
3953
TempValue4 = 7
3954
TempValue5 = -6
3955
else
3956
TempValue4 = 10
3957
TempValue5 = -10
3958
end if
3959
3960
if Player.Direction == FACING_RIGHT
3961
TempValue2 = Player.XPos
3962
Object.XPos = Player.XPos
3963
Object.YPos = Player.YPos
3964
ObjectTileGrip(CSIDE_LWALL, TempValue4, TempValue5, Player.CollisionPlane)
3965
TempValue0 = CheckResult
3966
if TempValue0 == 0
3967
Player.XPos = TempValue2
3968
Object.XPos = Player.XPos
3969
ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)
3970
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, true, ECEFFECT_NONE)
3971
TempValue0 = CheckResult
3972
end if
3973
Player.XPos = Object.XPos
3974
TempValue3 = Player.XPos
3975
Player.XPos = TempValue2
3976
Object.XPos = Player.XPos
3977
Object.YPos = Player.YPos
3978
ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)
3979
Player.XPos = Object.XPos
3980
TempValue1 = CheckResult
3981
if TempValue1 == 0
3982
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)
3983
TempValue1 = CheckResult
3984
end if
3985
if Player.XPos > TempValue3
3986
Player.XPos = TempValue3
3987
end if
3988
ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_RESETSTORAGE)
3989
else
3990
if Mini_PlayerFlag == true
3991
TempValue4 = -7
3992
else
3993
TempValue4 = -10
3994
end if
3995
3996
TempValue2 = Player.XPos
3997
Object.XPos = Player.XPos
3998
Object.YPos = Player.YPos
3999
ObjectTileGrip(CSIDE_RWALL, TempValue4, TempValue5, Player.CollisionPlane)
4000
TempValue0 = CheckResult
4001
if TempValue0 == 0
4002
Player.XPos = TempValue2
4003
Object.XPos = Player.XPos
4004
ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)
4005
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, true, ECEFFECT_NONE)
4006
TempValue0 = CheckResult
4007
end if
4008
Player.XPos = Object.XPos
4009
TempValue3 = Player.XPos
4010
Player.XPos = TempValue2
4011
Object.XPos = Player.XPos
4012
Object.YPos = Player.YPos
4013
ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)
4014
Player.XPos = Object.XPos
4015
TempValue1 = CheckResult
4016
if TempValue1 == 0
4017
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)
4018
TempValue1 = CheckResult
4019
end if
4020
if Player.XPos < TempValue3
4021
Player.XPos = TempValue3
4022
end if
4023
ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_RESETSTORAGE)
4024
end if
4025
if TempValue0 == 0
4026
if Player.YVelocity < 0
4027
Player.XPos = TempValue2
4028
Player.Animation = ANI_LEDGEPULLUP
4029
Player.YVelocity = 0
4030
Player.Timer = 0
4031
Player.State = Player_State_LedgePullUp
4032
Player.TileCollisions = false
4033
if Player.Direction == FACING_RIGHT
4034
Player.XPos += 0x10000
4035
end if
4036
end if
4037
else
4038
if TempValue1 == 0
4039
Player.PrevAnimation = ANI_GLIDING_DROP
4040
Player.Frame = 2
4041
CallFunction(Player_Action_GlideDrop)
4042
end if
4043
end if
4044
end if
4045
else
4046
Player.Animation = ANI_WALKING
4047
Player.State = Player_State_Ground
4048
CallFunction(Player_HandleOnGround)
4049
end if
4050
#endplatform
4051
end function
4052
4053
4054
function Player_State_LedgePullUp
4055
#platform: Use_Origins
4056
switch Player.Frame
4057
case 0
4058
if Player.Timer < 5
4059
ObjectTileGrip(CSIDE_FLOOR, 12, -9, Player.CollisionPlane)
4060
Player.Timer++
4061
else
4062
Player.Timer = 0
4063
Player.Frame++
4064
if Player.Direction == FACING_RIGHT
4065
Player.XPos += 0x90000
4066
else
4067
Player.XPos -= 0x90000
4068
end if
4069
Player.YPos -= 0xA0000
4070
end if
4071
break
4072
4073
case 1
4074
if Player.Timer < 5
4075
Player.Timer++
4076
else
4077
Player.Timer = 0
4078
Player.Frame++
4079
if Player.Direction == FACING_RIGHT
4080
Player.XPos += 0x50000
4081
else
4082
Player.XPos -= 0x50000
4083
end if
4084
end if
4085
break
4086
4087
case 2
4088
if Player.Timer < 5
4089
Player.Timer++
4090
else
4091
Player.Timer = 0
4092
Player.Animation = ANI_STOPPED
4093
Player.State = Player_State_Air_NoDropDash
4094
Player.YPos -= 0x80000
4095
Player.TileCollisions = true
4096
end if
4097
break
4098
4099
end switch
4100
#endplatform
4101
end function
4102
4103
4104
function Player_State_GlideLeftNoGrip
4105
#platform: Use_Origins
4106
if Player.Gravity == GRAVITY_AIR
4107
if Player.JumpHold == true
4108
if Player.Timer == 256
4109
if Player.Speed < 0x180000
4110
Player.Speed += 0x400
4111
end if
4112
else
4113
if Player.Speed < 0x40000
4114
Player.Speed += 0x1000
4115
end if
4116
end if
4117
4118
if Player.YVelocity > 0x8000
4119
Player.YVelocity -= 0x2000
4120
else
4121
Player.YVelocity += 0x2000
4122
end if
4123
4124
if Player.Timer < 256
4125
Player.Timer += 4
4126
end if
4127
4128
if Player.Timer < 170
4129
if Player.Timer > 86
4130
Player.Frame = 0
4131
else
4132
if Player.Timer > 44
4133
Player.Frame = 1
4134
else
4135
Player.Frame = 2
4136
end if
4137
end if
4138
else
4139
if Player.Timer < 212
4140
Player.Frame = 1
4141
else
4142
Player.Frame = 2
4143
end if
4144
end if
4145
4146
TempValue7 = Player.XPos
4147
if Player.Timer < 128
4148
Player.Direction = FACING_RIGHT
4149
TempValue0 = false
4150
TempValue1 = false
4151
else
4152
Player.Direction = FACING_LEFT
4153
Player.XPos = TempValue7
4154
Player.XPos += Player.XVelocity
4155
Player.YPos = Player.YPos
4156
Object.XPos = Player.XPos
4157
Object.YPos = Player.YPos
4158
ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)
4159
Player.XPos = Object.XPos
4160
TempValue0 = CheckResult
4161
TempValue2 = Player.XPos
4162
Player.XPos = TempValue7
4163
Player.XPos += Player.XVelocity
4164
Object.XPos = Player.XPos
4165
Object.YPos = Player.YPos
4166
ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)
4167
Player.XPos = Object.XPos
4168
TempValue1 = CheckResult
4169
TempValue3 = Player.XPos
4170
end if
4171
4172
Cos(Player.XVelocity, Player.Timer)
4173
Player.XVelocity *= Player.Speed
4174
Player.XVelocity >>= 9
4175
if Player.Right == true
4176
Player.State = Player_State_GlideRightNoGrip
4177
end if
4178
4179
Player.XPos = TempValue7
4180
CheckResult = TempValue0
4181
CheckResult &= TempValue1
4182
if CheckResult == true
4183
TempValue0 = false
4184
ArrayPos0 = 32
4185
while ArrayPos0 < 1056
4186
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...
4187
if CheckResult == true
4188
if Object[ArrayPos0].Value0 == true
4189
TempValue0 = true
4190
end if
4191
end if
4192
ArrayPos0++
4193
loop
4194
4195
if TempValue0 == false
4196
if TempValue2 == TempValue3
4197
else
4198
Player.XVelocity >>= 2
4199
Player.Speed = Player.XVelocity
4200
CallFunction(Player_Action_GlideDrop)
4201
end if
4202
end if
4203
end if
4204
else
4205
Player.XVelocity >>= 2
4206
Player.Speed = Player.XVelocity
4207
CallFunction(Player_Action_GlideDrop)
4208
end if
4209
else
4210
if Player.CollisionMode == CMODE_FLOOR
4211
Player.Timer = 0
4212
Player.State = Player_State_GlideSlide
4213
Player.Animation = ANI_GLIDING_STOP
4214
Player.Speed = Player.XVelocity
4215
else
4216
Player.State = Player_State_Ground
4217
CallFunction(Player_HandleOnGround)
4218
Player.Skidding = 0
4219
end if
4220
end if
4221
4222
CallFunction(Player_CheckRoofGlide)
4223
#endplatform
4224
end function
4225
4226
4227
function Player_State_GlideRightNoGrip
4228
#platform: Use_Origins
4229
if Player.Gravity == GRAVITY_AIR
4230
if Player.JumpHold == true
4231
if Player.Timer == 0
4232
if Player.Speed < 0x180000
4233
Player.Speed += 0x400
4234
end if
4235
else
4236
if Player.Speed < 0x40000
4237
Player.Speed += 0x1000
4238
end if
4239
end if
4240
4241
if Player.YVelocity > 0x8000
4242
Player.YVelocity -= 0x2000
4243
else
4244
Player.YVelocity += 0x2000
4245
end if
4246
4247
if Player.Timer > 0
4248
Player.Timer -= 4
4249
end if
4250
4251
if Player.Timer < 170
4252
if Player.Timer > 86
4253
Player.Frame = 0
4254
else
4255
if Player.Timer > 44
4256
Player.Frame = 1
4257
else
4258
Player.Frame = 2
4259
end if
4260
end if
4261
else
4262
if Player.Timer < 212
4263
Player.Frame = 1
4264
else
4265
Player.Frame = 2
4266
end if
4267
end if
4268
4269
TempValue7 = Player.XPos
4270
if Player.Timer < 128
4271
Player.Direction = FACING_RIGHT
4272
Player.XPos = TempValue7
4273
Player.XPos += Player.XVelocity
4274
Player.YPos = Player.YPos
4275
Object.XPos = Player.XPos
4276
Object.YPos = Player.YPos
4277
ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)
4278
Player.XPos = Object.XPos
4279
TempValue0 = CheckResult
4280
TempValue2 = Player.XPos
4281
Player.XPos = TempValue7
4282
Player.XPos += Player.XVelocity
4283
Object.XPos = Player.XPos
4284
Object.YPos = Player.YPos
4285
ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)
4286
Player.XPos = Object.XPos
4287
TempValue1 = CheckResult
4288
TempValue3 = Player.XPos
4289
else
4290
Player.Direction = FACING_LEFT
4291
TempValue0 = false
4292
TempValue1 = false
4293
end if
4294
4295
Cos(Player.XVelocity, Player.Timer)
4296
Player.XVelocity *= Player.Speed
4297
Player.XVelocity >>= 9
4298
if Player.Left == true
4299
Player.State = Player_State_GlideLeftNoGrip
4300
end if
4301
4302
Player.XPos = TempValue7
4303
CheckResult = TempValue0
4304
CheckResult &= TempValue1
4305
if CheckResult == true
4306
TempValue2 >>= 1
4307
TempValue3 >>= 1
4308
if TempValue2 == TempValue3
4309
else
4310
Player.XVelocity >>= 2
4311
Player.Speed = Player.XVelocity
4312
CallFunction(Player_Action_GlideDrop)
4313
end if
4314
end if
4315
else
4316
Player.XVelocity >>= 2
4317
Player.Speed = Player.XVelocity
4318
CallFunction(Player_Action_GlideDrop)
4319
end if
4320
else
4321
if Player.CollisionMode == CMODE_FLOOR
4322
Player.Timer = 0
4323
Player.State = Player_State_GlideSlide
4324
Player.Animation = ANI_GLIDING_STOP
4325
Player.Speed = Player.XVelocity
4326
else
4327
Player.State = Player_State_Ground
4328
CallFunction(Player_HandleOnGround)
4329
Player.Skidding = 0
4330
end if
4331
end if
4332
4333
CallFunction(Player_CheckRoofGlide)
4334
#endplatform
4335
end function
4336
4337
4338
function Player_CheckRoofGlide
4339
#platform: Use_Origins
4340
// This function's just here to make sure that Knuckles doesn't go above the stage in MMZ3 (not a good thing)
4341
if Stage.ActiveList == REGULAR_STAGE
4342
CheckEqual(Stage.ListPos, 68) // MMZ3C
4343
TempValue0 = CheckResult
4344
CheckEqual(Stage.ListPos, 69) // MMZ3D
4345
TempValue0 |= CheckResult
4346
if TempValue0 != false
4347
if Stage.PlayerListPos == PLAYER_KNUCKLES // a bit redundant, this func is only called in glide functions anyways..
4348
if Player.RoofBarrier == true
4349
TempValue0 = Player.YPos
4350
TempValue0 >>= 16
4351
if TempValue0 < Player.CollisionBottom
4352
Player.YPos = Player.CollisionBottom
4353
Player.YPos <<= 16
4354
end if
4355
end if
4356
end if
4357
end if
4358
end if
4359
#endplatform
4360
end function
4361
4362
4363
function Player_Action_GlideDrop
4364
#platform: Use_Origins
4365
// Bug Details:
4366
// Player.Timer should probably be cleared here, but it isn't
4367
// 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
4368
4369
Player.Animation = ANI_GLIDING_DROP
4370
Player.AbilityTimer = 0
4371
Player.State = Player_State_GlideDrop
4372
#endplatform
4373
end function
4374
4375
4376
function Player_Action_DblJumpAmy
4377
#platform: Use_Origins
4378
if Player.JumpPress == true
4379
PlaySfx(SFX_G_HAMMERJUMP, false)
4380
game.callbackParam0 = 0
4381
game.callbackParam1 = 1
4382
game.callbackParam2 = 0
4383
EngineCallback(NOTIFY_STATS_CHARA_ACTION2)
4384
TempValue0 = Player.AnimationSpeed
4385
TempValue1 = Player.Frame
4386
Player.Animation = ANI_HAMMER_JUMP
4387
ProcessAnimation()
4388
Player.AnimationSpeed = TempValue0
4389
Player.Frame = TempValue1
4390
end if
4391
#endplatform
4392
end function
4393
4394
4395
function Player_Action_HammerDash
4396
#platform: Use_Origins
4397
PlaySfx(SFX_G_HAMMERDASH, false)
4398
Player.State = Player_State_HammerDash
4399
Player.Animation = ANI_HAMMER_DASH
4400
Player.Timer = 0
4401
Player.DropDashCharge = -1
4402
CallFunction(Player_SetHammerDashSpeed)
4403
#endplatform
4404
end function
4405
4406
4407
function Player_State_HammerDash
4408
#platform: Use_Origins
4409
if Player.Right == true
4410
Player.Direction = FACING_RIGHT
4411
else
4412
if Player.Left == true
4413
Player.Direction = FACING_LEFT
4414
end if
4415
end if
4416
4417
TempValue0 = true
4418
4419
if Player.Speed != 0
4420
Player.Timer++
4421
if Player.JumpHold == true
4422
if Player.Timer < 60
4423
CallFunction(Player_SetHammerDashSpeed)
4424
if Player.Gravity == GRAVITY_AIR
4425
CallFunction(Player_HandleAirMovement)
4426
else
4427
CallFunction(Player_HandleOnGround)
4428
end if
4429
TempValue0 = false
4430
end if
4431
end if
4432
end if
4433
4434
// If Amy is on a steep enough slope, cancel the move
4435
// (Despite the patch notes for version 2.0.1 claiming this was removed, it's very much still here)
4436
Cos256(TempValue1, Player.Angle)
4437
if TempValue1 <= 0
4438
TempValue0 = true
4439
end if
4440
4441
if TempValue0 == true
4442
Player.State = Player_State_Ground
4443
end if
4444
#endplatform
4445
end function
4446
4447
4448
function Player_SetHammerDashSpeed
4449
#platform: Use_Origins
4450
if Player.Direction == FACING_RIGHT
4451
Player.Speed = 0x60000
4452
else
4453
// Could they not have just set it to -0x60000?
4454
Player.Speed = 0
4455
Player.Speed -= 0x60000
4456
end if
4457
#endplatform
4458
end function
4459
4460
4461
function Player_Setup_Startup
4462
#platform: Use_Origins
4463
ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)
4464
4465
Player.XPos = Object[ArrayPos0].XPos
4466
Player.YPos = Object[ArrayPos0].YPos
4467
4468
if Mini_PlayerFlag == false
4469
if Stage.PlayerListPos == PLAYER_SONIC
4470
LoadAnimation("Sonic.Ani")
4471
end if
4472
4473
if Stage.PlayerListPos == PLAYER_TAILS
4474
LoadAnimation("Tails.Ani")
4475
end if
4476
4477
if Stage.PlayerListPos == PLAYER_KNUCKLES
4478
LoadAnimation("Knuckles.Ani")
4479
end if
4480
4481
if Stage.PlayerListPos == PLAYER_AMY
4482
LoadAnimation("Amy.Ani")
4483
end if
4484
else
4485
if Stage.PlayerListPos == PLAYER_SONIC
4486
LoadAnimation("MiniSonic.Ani")
4487
end if
4488
4489
if Stage.PlayerListPos == PLAYER_TAILS
4490
LoadAnimation("MiniTails.Ani")
4491
Object[1].Type = TypeName[Blank Object]
4492
end if
4493
4494
// it's not like Knuckles or Amy have any tails to worry about...
4495
if Stage.PlayerListPos == PLAYER_KNUCKLES
4496
LoadAnimation("MiniKnuckles.Ani")
4497
Object[1].Type = TypeName[Blank Object]
4498
end if
4499
4500
if Stage.PlayerListPos == PLAYER_AMY
4501
LoadAnimation("MiniAmy.Ani")
4502
Object[1].Type = TypeName[Blank Object]
4503
end if
4504
end if
4505
4506
BindPlayerToObject(0, 0)
4507
4508
Player.State = Player_State_Air_NoDropDash
4509
Player.Priority = PRIORITY_ACTIVE
4510
Player.DrawOrder = 4
4511
4512
Player.TopSpeed = 0x60000
4513
Player.Acceleration = 0xC00
4514
Player.Deceleration = 0xC00
4515
Player.AirAcceleration = 0x1800
4516
Player.AirDeceleration = 0x600
4517
Player.GravityStrength = 0x3800
4518
Player.JumpStrength = 0x68000
4519
Player.JumpCap = -0x40000
4520
Player.RollingDeceleration = 0x2000
4521
4522
if Stage.PlayerListPos == PLAYER_SONIC
4523
Player.JumpAbility = Player_State_Static
4524
if Options.OriginalControls == false
4525
Player.ActionPeelout = Player_Action_Peelout_S2
4526
Player.ActionSpindash = Player_Action_Spindash_S2
4527
else
4528
Player.ActionPeelout = Player_Action_Peelout_CD
4529
Player.ActionSpindash = Player_Action_Spindash_CD
4530
end if
4531
end if
4532
4533
if Stage.PlayerListPos == PLAYER_TAILS
4534
Player.JumpAbility = Player_Action_DblJumpTails
4535
Player.ActionPeelout = Player_Action_Jump
4536
if Options.OriginalControls == false
4537
Player.ActionSpindash = Player_Action_Spindash_S2
4538
else
4539
Player.ActionSpindash = Player_Action_Spindash_CD
4540
end if
4541
end if
4542
4543
if Stage.PlayerListPos == PLAYER_KNUCKLES
4544
Player.JumpStrength = 0x60000
4545
Player.JumpAbility = Player_Action_DblJumpKnux
4546
Player.ActionPeelout = Player_Action_Jump
4547
if Options.OriginalControls == false
4548
Player.ActionSpindash = Player_Action_Spindash_S2
4549
else
4550
Player.ActionSpindash = Player_Action_Spindash_CD
4551
end if
4552
end if
4553
4554
if Stage.PlayerListPos == PLAYER_AMY
4555
Player.JumpAbility = Player_Action_DblJumpAmy
4556
Player.ActionPeelout = Player_Action_Jump
4557
if Options.OriginalControls == false
4558
Player.ActionSpindash = Player_Action_Spindash_S2
4559
else
4560
Player.ActionSpindash = Player_Action_Spindash_CD
4561
end if
4562
end if
4563
4564
CallFunction(Player_SetJumpOffset)
4565
4566
GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")
4567
GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")
4568
GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")
4569
GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")
4570
GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")
4571
GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")
4572
GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")
4573
GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")
4574
GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")
4575
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
4576
#endplatform
4577
end function
4578
4579
sub ObjectMain
4580
// Only PC had access to debug mode, so here's a hack to prevent it on mobile
4581
TempValue0 = false
4582
#platform: Standard
4583
TempValue0 = Stage.DebugMode
4584
#endplatform
4585
4586
if TempValue0 == true
4587
if KeyPress[1].ButtonB == true // Turn Debug Mode
4588
Object.Type = TypeName[Debug Mode]
4589
4590
if Stage.PlayerListPos != PLAYER_SONIC_A // PLAYER_SONIC in origins
4591
Object[+1].Type = TypeName[Blank Object]
4592
end if
4593
4594
Player.YVelocity = 0
4595
Player.State = Player_State_Static
4596
Player.Frame = 0
4597
Player.Rotation = 0
4598
4599
Player.ObjectInteraction = false
4600
Player.TileCollisions = true
4601
Player.DrawOrder = 4
4602
4603
Player.AbilityTimer = 0
4604
Player.MinRollSpeed = 0
4605
4606
Screen.CameraEnabled = true
4607
Screen.CameraStyle = Options.OriginalControls
4608
else
4609
// Handle Player
4610
CallFunction(Player_ProcessUpdate)
4611
CallFunction(Player.State)
4612
ProcessAnimation()
4613
4614
if Player.Animation == ANI_JUMPING
4615
Screen.AdjustCameraY = Player.JumpOffset
4616
else
4617
if Screen.AdjustCameraY == Player.JumpOffset
4618
Screen.AdjustCameraY = 0
4619
Player.iYPos += Player.JumpOffset
4620
end if
4621
end if
4622
4623
if Player.YVelocity > 0x100000
4624
Player.YVelocity = 0x100000
4625
end if
4626
4627
PlayerTileCollision()
4628
4629
if CheckResult == true
4630
if Player.Animation == ANI_JUMPING
4631
if Player.Down == false
4632
Player.Animation = ANI_WALKING
4633
Screen.AdjustCameraY = 0
4634
Player.iYPos += Player.JumpOffset
4635
end if
4636
end if
4637
end if
4638
end if
4639
else
4640
// Mobile version ObjectMain starts here, since there wasn't a debug mode
4641
// Handle Player
4642
CallFunction(Player_ProcessUpdate)
4643
CallFunction(Player.State)
4644
4645
#platform: Use_Origins
4646
if Player.DropDashCharge >= 20
4647
if Player.Animation == ANI_JUMPING
4648
Player.Frame = 0
4649
Player.AnimationTimer = 0
4650
Player.AnimationSpeed = 1
4651
end if
4652
end if
4653
#endplatform
4654
4655
ProcessAnimation()
4656
4657
if Player.Animation == ANI_JUMPING
4658
Screen.AdjustCameraY = Player.JumpOffset
4659
else
4660
if Screen.AdjustCameraY == Player.JumpOffset
4661
Screen.AdjustCameraY = 0
4662
Player.iYPos += Player.JumpOffset
4663
end if
4664
end if
4665
4666
if Player.YVelocity > 0x100000
4667
Player.YVelocity = 0x100000
4668
end if
4669
4670
PlayerTileCollision()
4671
if CheckResult == true
4672
if Player.Animation == ANI_JUMPING
4673
if Player.Down == false
4674
Player.Animation = ANI_WALKING
4675
Screen.AdjustCameraY = 0
4676
Player.iYPos += Player.JumpOffset
4677
end if
4678
end if
4679
end if
4680
end if
4681
end sub
4682
4683
4684
sub ObjectDraw
4685
if Player.Animation != Player.PrevAnimation
4686
Player.PrevAnimation = Player.Animation
4687
Player.Frame = 0
4688
Player.AnimationTimer = 0
4689
Player.AnimationSpeed = 0
4690
end if
4691
4692
DrawPlayerAnimation()
4693
end sub
4694
4695
4696
sub ObjectStartup
4697
#platform: Use_Origins
4698
// I feel like I got spoiled on a Knuckles route...
4699
TempValue0 = false
4700
CheckGreater(Warp.Timer, 204)
4701
TempValue0 |= CheckResult
4702
TempValue0 &= Mini_PlayerFlag
4703
Mini_PlayerFlag = TempValue0
4704
Warp.Timer = 0
4705
4706
if Options.AttractMode == false
4707
if Options.StageSelectFlag == false
4708
ReadSaveRAM()
4709
end if
4710
end if
4711
4712
// Origins Plus includes new start positions for Knuckles in some levels
4713
ArrayPos1 = 32
4714
TempValue5 = 0
4715
TempValue6 = 0
4716
while ArrayPos1 < 1056
4717
// So now we have to check how many player objects the game found
4718
if Object[ArrayPos1].Type == TypeName[Player Object]
4719
TempValue5++
4720
end if
4721
ArrayPos1++
4722
loop
4723
4724
// We found multiple spawn points, now check which one to use
4725
if TempValue5 > 1
4726
ArrayPos1 = 32
4727
TempValue7 = 0
4728
while ArrayPos1 < 1056
4729
if Object[ArrayPos1].Type == TypeName[Player Object]
4730
// The standard spawnpoint
4731
if Object[ArrayPos1].PropertyValue == 0
4732
TempValue7 = ArrayPos1
4733
end if
4734
4735
// Character specific spawnpoint
4736
if Object[ArrayPos1].PropertyValue == Stage.PlayerListPos
4737
TempValue6 = ArrayPos1
4738
ArrayPos1 = 1056
4739
end if
4740
end if
4741
ArrayPos1++
4742
loop
4743
4744
// If we didn't find a special spawnpoint, just use the regular one
4745
if TempValue6 == 0
4746
TempValue6 = TempValue7
4747
end if
4748
end if
4749
4750
// Get rid of all spawnpoints except the one we're going to use
4751
TempValue7 = 0
4752
ArrayPos0 = 32
4753
while ArrayPos0 < 1056
4754
if Object[ArrayPos0].Type == TypeName[Player Object]
4755
if TempValue5 > 1
4756
if ArrayPos0 == TempValue6
4757
CallFunction(Player_Setup_Startup)
4758
else
4759
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
4760
end if
4761
else
4762
TempValue7 = ArrayPos0
4763
end if
4764
end if
4765
ArrayPos0++
4766
loop
4767
4768
if TempValue7 > 0
4769
ArrayPos0 = TempValue7
4770
CallFunction(Player_Setup_Startup)
4771
end if
4772
#endplatform
4773
4774
#platform: Use_Standalone
4775
ArrayPos0 = 32
4776
while ArrayPos0 < 1056
4777
if Object[ArrayPos0].Type == TypeName[Player Object]
4778
switch Stage.PlayerListPos
4779
case PLAYER_SONIC_A
4780
ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)
4781
Player.XPos = Object[ArrayPos0].XPos
4782
Player.YPos = Object[ArrayPos0].YPos
4783
4784
LoadAnimation("Sonic.Ani")
4785
BindPlayerToObject(0, 0)
4786
4787
Player.State = Player_State_Air
4788
4789
Player.Priority = PRIORITY_ACTIVE
4790
4791
Player.DrawOrder = 4
4792
4793
Player.TopSpeed = 0x60000
4794
Player.Acceleration = 0xC00
4795
Player.Deceleration = 0xC00
4796
Player.AirAcceleration = 0x1800
4797
Player.AirDeceleration = 0x600
4798
Player.GravityStrength = 0x3800
4799
Player.JumpStrength = 0x68000
4800
Player.JumpCap = -0x40000
4801
Player.RollingDeceleration = 0x2000
4802
4803
Player.JumpOffset = -5
4804
4805
Player.JumpAbility = Player_State_Static
4806
if Options.OriginalControls == false
4807
Player.ActionPeelout = Player_Action_Peelout_S2
4808
Player.ActionSpindash = Player_Action_Spindash_S2
4809
else
4810
Player.ActionPeelout = Player_Action_Peelout_CD
4811
Player.ActionSpindash = Player_Action_Spindash_CD
4812
end if
4813
break
4814
4815
case PLAYER_TAILS_A
4816
ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)
4817
Player.XPos = Object[ArrayPos0].XPos
4818
Player.YPos = Object[ArrayPos0].YPos
4819
4820
LoadAnimation("Tails.Ani")
4821
BindPlayerToObject(0, 0)
4822
4823
Player.State = Player_State_Air
4824
Player.Priority = PRIORITY_ACTIVE
4825
Player.DrawOrder = 4
4826
4827
Player.TopSpeed = 0x60000
4828
Player.Acceleration = 0xC00
4829
Player.Deceleration = 0xC00
4830
Player.AirAcceleration = 0x1800
4831
Player.AirDeceleration = 0x600
4832
Player.GravityStrength = 0x3800
4833
Player.JumpStrength = 0x68000
4834
Player.JumpCap = -0x40000
4835
Player.RollingDeceleration = 0x2000
4836
4837
Player.JumpOffset = -1
4838
4839
Player.JumpAbility = Player_Action_DblJumpTails
4840
Player.ActionPeelout = Player_Action_Jump
4841
if Options.OriginalControls == false
4842
Player.ActionSpindash = Player_Action_Spindash_S2
4843
else
4844
Player.ActionSpindash = Player_Action_Spindash_CD
4845
end if
4846
break
4847
4848
end switch
4849
4850
GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")
4851
GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")
4852
GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")
4853
GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")
4854
GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")
4855
GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")
4856
GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")
4857
GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")
4858
GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")
4859
4860
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
4861
end if
4862
4863
ArrayPos0++
4864
loop
4865
#endplatform
4866
end sub
4867
4868
4869
// ========================
4870
// Editor Subs
4871
// ========================
4872
4873
// All of the Character ID stuff is specific to Origins Plus, other versions of the game don't check or use the PropertyValue
4874
4875
sub RSDKEdit
4876
if Editor.ReturnVariable == true
4877
switch Editor.VariableID
4878
case EDIT_VAR_PROPVAL // Property Value
4879
CheckResult = Object.PropertyValue
4880
break
4881
case 0 // Character ID
4882
CheckResult = Object.PropertyValue
4883
break
4884
end switch
4885
else
4886
switch Editor.VariableID
4887
case EDIT_VAR_PROPVAL // Property Value
4888
Object.PropertyValue = Editor.VariableValue
4889
break
4890
case 0 // Character ID
4891
Object.PropertyValue = Editor.VariableValue
4892
break
4893
end switch
4894
end if
4895
end sub
4896
4897
4898
sub RSDKDraw
4899
switch Object.PropertyValue
4900
default
4901
LoadSpriteSheet("Players/Sonic1.gif")
4902
DrawSprite(0)
4903
break
4904
4905
case 1
4906
LoadSpriteSheet("Players/Tails1.gif")
4907
DrawSprite(1)
4908
break
4909
4910
case 2
4911
LoadSpriteSheet("Players/KTE1.gif")
4912
DrawSprite(2)
4913
break
4914
4915
case 5
4916
LoadSpriteSheet("Players/Amy1.gif")
4917
DrawSprite(3)
4918
break
4919
end switch
4920
end sub
4921
4922
4923
sub RSDKLoad
4924
LoadSpriteSheet("Players/Sonic1.gif")
4925
SpriteFrame(-16, -19, 28, 39, 1, 1) // Sonic Standing Frame
4926
4927
LoadSpriteSheet("Players/Tails1.gif")
4928
SpriteFrame(-12, -12, 24, 32, 1, 1) // Tails Standing Frame
4929
4930
LoadSpriteSheet("Players/KTE1.gif")
4931
SpriteFrame(-14, -20, 26, 40, 1, 1) // Knuckles Standing Frame
4932
4933
LoadSpriteSheet("Players/Amy1.gif")
4934
SpriteFrame(-12, -15, 21, 35, 45, 1) // Amy Standing Frame
4935
4936
AddEditorVariable("Character ID (Origins Plus)")
4937
SetActiveVariable("Character ID (Origins Plus)")
4938
AddEnumVariable("Sonic", PLAYER_SONIC_A)
4939
AddEnumVariable("Tails", PLAYER_TAILS_A)
4940
AddEnumVariable("Knuckles", PLAYER_KNUCKLES_A)
4941
AddEnumVariable("Amy", PLAYER_AMY_A)
4942
end sub
4943
4944