Path: blob/main/Scripts/Players/PlayerObject.txt
1319 views
//----------------Sonic CD Player Object Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Player.Value0 : Player.Rings6#alias Player.Value1 : Player.AbilityTimer7#alias Player.Value2 : Player.RollAnimationSpeed8#alias Player.Value3 : Player.SpeedShoesTimer9#alias Player.Value4 : Player.InvincibleTimer10#alias Player.Value5 : Player.BlinkTimer11#alias Player.Value6 : Player.MinRollSpeed12#alias Player.Value7 : Player.AnimationReserve13#alias Player.Value8 : Player.ScrollDelay14#alias Player.Value9 : Player.JumpOffset15#alias Player.Value10 : Player.JumpAbility16#alias Player.Value11 : Player.ActionPeelout17#alias Player.Value12 : Player.ActionSpindash1819// Originally unused in the 2011 release, but Origins gave them a purpose20#alias Player.Value13 : Player.ForceGrounded21#alias Player.Value14 : Player.DropDashCharge2223#alias Player.Value15 : Player.FlightVelocity2425// Flailing states, v4 names explains this much better26#alias Player.Flailing[0] : Player.FloorSensorL27#alias Player.Flailing[1] : Player.FloorSensorC28#alias Player.Flailing[2] : Player.FloorSensorR2930// LoseRing Aliases31#alias Object.Value0 : Object.XVelocity32#alias Object.Value1 : Object.YVelocity3334// Warp Star Aliases35#alias Object[3].Value0 : WarpStar.Timer36#alias Object[3].DrawOrder : WarpStar.DrawOrder3738// Object Score Alias39#alias Object[26].Value0 : ObjectScore.BadnikBonus4041// Pause Menu Aliases42#alias Object[9].DrawOrder : PauseMenu.DrawOrder43#alias Object[9].Priority : PauseMenu.Priority4445// Debug Mode Alias46#alias Object[25].Value7 : DebugMode.ButtonA4748// Death Event Aliases49#alias Object.Value1 : DeathEvent.Text1XPos // Game or Time50#alias Object.Value2 : DeathEvent.Text2XPos // Over51#alias Object.Value3 : DeathEvent.Timer // Also used for fading52#alias Object.DrawOrder : DeathEvent.DrawOrder53#alias Object.State : DeathEvent.State5455// Death Event States56#alias 0 : DEATHEVENT_GAMEOVER57#alias 1 : DEATHEVENT_TIMEOVER58#alias 2 : DEATHEVENT_FADEOUT59#alias 3 : DEATHEVENT_TIMEATTACK6061// Priority62#alias 1 : PRIORITY_ACTIVE63#alias 2 : PRIORITY_ALWAYS6465// Gravity66#alias 0 : GRAVITY_GROUND67#alias 1 : GRAVITY_AIR6869// Player List Pos Aliases70#alias 0 : PLAYER_SONIC_A71#alias 1 : PLAYER_TAILS_A72#alias 2 : PLAYER_KNUCKLES_A73#alias 5 : PLAYER_AMY_A7475// Ink76#alias 2 : INK_ALPHA7778// Callbacks & Messages79#alias 2 : MESSAGE_LOSTFOCUS8081// Cameras82#alias 0 : CAMERASTYLE_FOLLOW83#alias 1 : CAMERASTYLE_EXTENDED84#alias 2 : CAMERASTYLE_EXTENDED_OFFSET_L85#alias 3 : CAMERASTYLE_EXTENDED_OFFSET_R86#alias 4 : CAMERASTYLE_HLOCKED8788// Damage Type89#alias 1 : DAMAGE_SHIELDED90#alias 2 : DAMAGE_HURT91#alias 3 : DAMAGE_DEATH9293// Collision Modes94#alias 0 : CMODE_FLOOR95#alias 1 : CMODE_LWALL96#alias 2 : CMODE_ROOF97#alias 3 : CMODE_RWALL9899// Collision Planes100#alias 0 : COLLISION_PLANE_A101102// Collision Sides103#alias 0 : CSIDE_FLOOR104#alias 1 : CSIDE_LWALL105#alias 2 : CSIDE_RWALL106#alias 3 : CSIDE_ROOF107#alias 4 : CSIDE_ENTITY108109// Entity Collision Effects110#alias 0 : ECEFFECT_NONE111#alias 1 : ECEFFECT_RESETSTORAGE112#alias 2 : ECEFFECT_BOXCOL3113114// Control Modes115#alias -1 : CONTROLMODE_NONE116#alias 0 : CONTROLMODE_NORMAL117118// Shield status119#alias 0 : NO_SHIELD120#alias 1 : ACTIVE_SHIELD121122// Global SFX123#alias 0 : SFX_G_JUMP124#alias 3 : SFX_G_SKIDDING125#alias 4 : SFX_G_LOSERINGS126#alias 5 : SFX_G_HURT127#alias 6 : SFX_G_CHARGE128#alias 7 : SFX_G_RELEASE129#alias 8 : SFX_G_DESTROY130#alias 24 : SFX_G_FLYING131#alias 25 : SFX_G_TIRED132#alias 26 : SFX_G_OUTTAHERE133#alias 27 : SFX_G_SELECT134#alias 28 : SFX_G_DROPDASH // Origins-exclusive SFX start here135#alias 29 : SFX_G_HAMMERJUMP136#alias 30 : SFX_G_HAMMERDASH137#alias 31 : SFX_G_HAMMERHIT138#alias 32 : SFX_G_SLIDE139#alias 33 : SFX_G_GLIDEDROPLAND140#alias 34 : SFX_G_GRAB141142// Game Mode Aliases143#alias 2 : MODE_TIMEATTACK144145// Warp Destination146#alias 0 : WARPDEST_NONE147148// Mission Functions149#alias 8 : RULE_MERCY_BADNIKS150151// Engine Callbacks152#alias 13 : CALLBACK_PAUSE_REQUESTED153154// Tile Info155#alias 8 : TILEINFO_ANGLEB156157158// Function declarations159160// Main functions161#function Player_BadnikBreak162#function Player_Hit163#function Player_Kill164#function Player_ProcessUpdate165#function Player_State_Static166167// "Physics" functions168#function Player_HandleRollAnimSpeed169#function Player_HandleWalkAnimSpeed170#function Player_HandleRunAnimSpeed171#function Player_HandleGroundMovement172#function Player_HandleAirFriction173#function Player_HandleRollDeceleration174#function Player_HandleAirMovement175#function Player_HandleOnGround176177// Move Starters functions178#function Player_Action_Jump179#function Player_Action_Spindash_S2180#function Player_Action_Spindash_CD181#function Player_Action_Peelout_S2182#function Player_Action_Peelout_CD183#function Player_Action_DblJumpTails184185// Player Movements186#function Player_State_Ground187#function Player_State_Air_NoDropDash // Origins function188#function Player_State_Air189#function Player_State_Roll190#function Player_State_RollJump // Unused - Leftover from Sonic Nexus191#function Player_State_LookUp192#function Player_State_Crouch193#function Player_State_Spindash_S2194#function Player_State_Spindash_CD195#function Player_State_Peelout_S2196#function Player_State_Peelout_CD197#function Player_State_Fly198199// Damage and death200#function Player_State_GotHit201#function Player_State_Hurt202#function Player_State_OuttaHere203#function Player_State_Death204#function Player_State_Drown205206// Level Gimmicks207#function Player_State_HangBar208#function Player_State_CorkscrewRun // Unused - Leftover from Sonic Nexus209#function Player_State_CorkscrewRoll // Unused - Leftover from Sonic Nexus210#function Player_State_TubeRoll211#function Player_State_TubeAirRoll212#function Player_State_SpinningTop213#function Player_State_Hugged214#function Player_State_Ramp3D215#function Player_State_WaterCurrent216#function Player_SetJumpOffset217#function Player_State_SizeChange218219// Origins Functions220#function Player_HandleDropDash221#function Player_Action_DblJumpKnux222#function Player_State_GlideLeft223#function Player_State_GlideRight224#function Player_State_GlideDrop225#function Player_State_GlideSlide226#function Player_State_Climb227#function Player_State_LedgePullUp228#function Player_State_GlideLeftNoGrip229#function Player_State_GlideRightNoGrip230#function Player_CheckRoofGlide231#function Player_Action_GlideDrop232#function Player_Action_DblJumpAmy233#function Player_Action_HammerDash234#function Player_State_HammerDash235#function Player_SetHammerDashSpeed236#function Player_Setup_Startup237238#function Player_ClimbBlock239#function Player_Unstick240#function Player_CancelClimb241#function Player_ForceNoGrip242#function Player_ForceGrip243244// Used by badniks, if the conditions are met, they get destroyed, otherwise you get hurt245function Player_BadnikBreak246CheckEqual(Player.Animation, ANI_JUMPING)247TempValue0 = CheckResult248#platform: Use_Origins249CheckEqual(Player.Animation, ANI_HAMMER_JUMP)250TempValue0 |= CheckResult251CheckEqual(Player.Animation, ANI_HAMMER_DASH)252TempValue0 |= CheckResult253#endplatform254CheckEqual(Player.Animation, ANI_SPINDASH)255TempValue0 |= CheckResult256#platform: Use_Origins257CheckEqual(Player.Animation, ANI_GLIDING)258TempValue0 |= CheckResult259CheckEqual(Player.Animation, ANI_GLIDING_STOP)260TempValue0 |= CheckResult261#endplatform262263ArrayPos0 = Player.EntityNo264ArrayPos0 += 2265CheckEqual(Object[ArrayPos0].Type, TypeName[Invincibility])266TempValue0 |= CheckResult267268// you're invincible to badniks during the warping run269if Warp.Timer > 0270TempValue0 |= true271end if272273if Player.Animation == ANI_FLYING274CheckGreater(Player.YPos, Object.YPos)275TempValue0 |= CheckResult276end if277278#platform: Use_Origins279if game.playMode == BOOT_PLAYMODE_MISSION280if Stage.TimeEnabled == false281TempValue0 = false282end if283end if284#endplatform285286if TempValue0 == true287ResetObjectEntity(Object.EntityNo, Flower_TypeNo, 0, Object.XPos, Object.YPos)288Object.DrawOrder = 4289290CreateTempObject(TypeName[Smoke Puff], 0, Object.XPos, Object.YPos)291Object[TempObjectPos].DrawOrder = 4292293CreateTempObject(TypeName[Object Score], ObjectScore.BadnikBonus, Object.XPos, Object.YPos)294Object[TempObjectPos].DrawOrder = 4295296#platform: Use_Origins297TempValue0 = false298299if Player.Animation == ANI_HAMMER_JUMP300TempValue0 = true301end if302303if Player.Animation == ANI_HAMMER_DASH304TempValue0 = true305end if306307if TempValue0 == true308PlaySfx(SFX_G_HAMMERHIT, false)309else310PlaySfx(SFX_G_DESTROY, false)311end if312#endplatform313314#platform: Use_Standalone315PlaySfx(SFX_G_DESTROY, false)316#endplatform317318if Player.YVelocity > 0319FlipSign(Player.YVelocity)320else321Player.YVelocity += 0xC000322end if323324switch ObjectScore.BadnikBonus325case 0326Player.Score += 100327break328case 1329Player.Score += 200330break331case 2332Player.Score += 500333break334case 3335Player.Score += 1000336break337end switch338339// (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)340341#platform: Use_Haptics342HapticEffect(10, 0, 0, 0)343#endplatform344345#platform: Use_Origins346TempValue0 = 0347game.callbackParam0 = 0348CheckEqual(Player.State, Player_State_Roll)349TempValue0 = CheckResult350CheckEqual(Player.State, Player_State_RollJump)351TempValue0 |= CheckResult352if TempValue0 == true353if Stage.PlayerListPos == PLAYER_SONIC354game.callbackParam0 = KILL_ENEMY_ATTR_SPINDASH355StageStatsUsabilityParam2 += 1356end if357end if358359StageStatsUsabilityParam1 += 1360EngineCallback(NOTIFY_KILL_ENEMY)361if game.playMode == BOOT_PLAYMODE_MISSION362// Set during "M097 - Mercy"363if game.missionFunctionNo == RULE_MERCY_BADNIKS364game.forceKillPlayer = true365end if366end if367#endplatform368else369if Player.InvincibleTimer == 0370Player.State = Player_State_GotHit371372#platform: Use_Origins373if game.playMode == BOOT_PLAYMODE_MISSION374if game.missionFunctionNo == RULE_MERCY_BADNIKS375game.missionValue = 1376end if377end if378#endplatform379380if Player.XPos > Object.XPos381Player.Speed = 0x20000382else383Player.Speed = -0x20000384end if385end if386end if387end function388389// Do you really need an explanation?390function Player_Hit391ArrayPos0 = Player.EntityNo392ArrayPos0 += 2393if Object[ArrayPos0].Type != TypeName[Invincibility]394if Player.InvincibleTimer == 0395Player.State = Player_State_GotHit396if Player.XPos > Object.XPos397Player.Speed = 0x20000398else399Player.Speed = -0x20000400end if401end if402end if403end function404405// Called by block objects to see if Knuckles should climb them406// (Note that the block object needs to have called C_BOX3 before calling this function)407function Player_ClimbBlock408#platform: Use_Origins409if Player.State != Player_State_Climb410TempValue0 = false411ArrayPos0 = 32412if Player.State == Player_State_GlideRightNoGrip // Nothing for a left glide?413TempValue0 = true414else415while ArrayPos0 < 1056416if 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...417if Object[ArrayPos0].Value0 == true418TempValue0 = true419end if420end if421ArrayPos0++422loop423end if424425if TempValue0 == false426if Player.Direction == FACING_LEFT427ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_BOXCOL3)428else429ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_BOXCOL3)430end if431PlaySfx(SFX_G_GRAB, false)432Player.State = Player_State_Climb433Player.Speed = 0434Player.XVelocity = 0435Player.YVelocity = 0436Player.Timer = 0437Player.Gravity = GRAVITY_AIR438game.callbackParam0 = 2439game.callbackParam1 = 0440game.callbackParam2 = 0441EngineCallback(NOTIFY_STATS_CHARA_ACTION2)442if Warp.Destination > 0443if Warp.Timer > 99444if Warp.Timer < 204445Warp.Destination = 0446end if447end if448Warp.Timer = 0449end if450end if451end if452#endplatform453end function454455// 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, instead456457// See above, this one's p much only called by NoGripArea's458function Player_Unstick459#platform: Use_Origins460CallFunction(Player_Action_GlideDrop)461Player.PrevAnimation = ANI_GLIDING_DROP462Player.Frame = 2463#endplatform464end function465466// See above, this one's p much only called by Bumpers467function Player_CancelClimb468#platform: Use_Origins469Player.Animation = ANI_WALKING470Player.Timer = 0471Player.State = Player_State_Air_NoDropDash472#endplatform473end function474475// Called by No Grip Area objects to, well, force No Grip gliding476function Player_ForceNoGrip477#platform: Use_Origins478if Player.State == Player_State_GlideLeft479Player.State = Player_State_GlideLeftNoGrip480end if481482if Player.State == Player_State_GlideRight483Player.State = Player_State_GlideRightNoGrip484end if485#endplatform486end function487488// Called by No Grip Area objects to restore normal gliding489function Player_ForceGrip490#platform: Use_Origins491if Player.State == Player_State_GlideLeftNoGrip492Player.State = Player_State_GlideLeft493end if494495if Player.State == Player_State_GlideRightNoGrip496Player.State = Player_State_GlideRight497end if498#endplatform499end function500501502// YOU DIED503function Player_Kill504PlaySfx(SFX_G_HURT, false)505506Player.DrawOrder = 5507508Player.Speed = 0509Player.XVelocity = 0510Player.YVelocity = -0x68000511512Player.State = Player_State_Death513Player.Animation = ANI_DYING514515Player.TileCollisions = false516Player.ObjectInteraction = false517Screen.CameraEnabled = false518519#platform: Use_Haptics520HapticEffect(28, 0, 0, 0)521#endplatform522end function523524function Player_ProcessUpdate525#platform: Standard526if Options.AttractMode == false527if Player.ControlMode == CONTROLMODE_NORMAL528if Object[9].Type == TypeName[Blank Object]529if KeyPress[1].Start == true530KeyPress[1].Start = false531if Options.DevMenuFlag == true532Stage.State = STAGE_PAUSED533PauseMusic()534PlaySfx(SFX_G_SELECT, false)535StopSFX(SFX_G_FLYING)536StopSFX(SFX_G_TIRED)537Object[9].Type = TypeName[Pause Menu]538PauseMenu.DrawOrder = 7539PauseMenu.Priority = PRIORITY_ALWAYS540else541EngineCallback(CALLBACK_PAUSE_REQUESTED) // ask the engine to open the "native" pause menu542end if543end if544end if545end if546547ProcessPlayerControl()548end if549#endplatform550551#platform: Use_Decomp552if Options.AttractMode == false553if Player.ControlMode == CONTROLMODE_NORMAL554if Object[9].Type == TypeName[Blank Object]555if Engine.Message == MESSAGE_LOSTFOCUS556Stage.State = STAGE_PAUSED557PauseMusic()558PlaySfx(SFX_G_SELECT, false)559StopSFX(SFX_G_FLYING)560StopSFX(SFX_G_TIRED)561Object[9].Type = TypeName[Pause Menu]562PauseMenu.DrawOrder = 7563PauseMenu.Priority = PRIORITY_ALWAYS564if Engine.FrameSkipTimer > -1565Engine.FrameSkipTimer = -1566end if567end if568end if569end if570end if571#endplatform572573#platform: Mobile574if Options.AttractMode == false575if Options.TouchControls == true576if Player.ControlMode == CONTROLMODE_NORMAL577CheckTouchRect(0, 96, Screen.CenterX, Screen.YSize)578if CheckResult > -1579ArrayPos0 = CheckResult580// D-Pad XPos581TempValue0 = TouchScreen[ArrayPos0].XPos582TempValue0 -= Options.DPadX583// D-Pad YPos584TempValue1 = TouchScreen[ArrayPos0].YPos585TempValue1 -= 192586587// tldr; check what did you touch in the d-pad588ATan2(TempValue2, TempValue0, TempValue1)589TempValue2 += 32590TempValue2 &= 255591TempValue2 >>= 6592switch TempValue2593case 0594KeyDown[1].Right = true595break596case 1597KeyDown[1].Down = true598break599case 2600KeyDown[1].Left = true601break602case 3603KeyDown[1].Up = true604break605end switch606end if607608CheckTouchRect(Screen.CenterX, 96, Screen.XSize, 240)609if CheckResult > -1610KeyDown[1].ButtonA = true611end if612613if DebugMode.ButtonA == false614KeyPress[1].ButtonA |= KeyDown[1].ButtonA615end if616617DebugMode.ButtonA = KeyDown[1].ButtonA618if Object[9].Type == TypeName[Blank Object]619620CheckTouchRect(240, 0, Screen.XSize, 40)621if CheckResult > -1622Stage.State = STAGE_PAUSED623PauseMusic()624PlaySfx(SFX_G_SELECT, false)625StopSFX(SFX_G_FLYING)626StopSFX(SFX_G_TIRED)627Object[9].Type = TypeName[Pause Menu]628PauseMenu.DrawOrder = 7629PauseMenu.Priority = PRIORITY_ALWAYS630if Engine.FrameSkipTimer > -1631Engine.FrameSkipTimer = -1632end if633634end if635636if Engine.Message == MESSAGE_LOSTFOCUS637Stage.State = STAGE_PAUSED638PauseMusic()639PlaySfx(SFX_G_SELECT, false)640StopSFX(SFX_G_FLYING)641StopSFX(SFX_G_TIRED)642Object[9].Type = TypeName[Pause Menu]643PauseMenu.DrawOrder = 7644PauseMenu.Priority = PRIORITY_ALWAYS645if Engine.FrameSkipTimer > -1646Engine.FrameSkipTimer = -1647end if648end if649end if650end if651else652if Player.ControlMode == CONTROLMODE_NORMAL653if Object[9].Type == TypeName[Blank Object]654if KeyPress[1].Start == true655656KeyPress[1].Start = false657Stage.State = STAGE_PAUSED658PauseMusic()659PlaySfx(SFX_G_SELECT, false)660StopSFX(SFX_G_FLYING)661StopSFX(SFX_G_TIRED)662Object[9].Type = TypeName[Pause Menu]663PauseMenu.DrawOrder = 7664PauseMenu.Priority = PRIORITY_ALWAYS665if Engine.FrameSkipTimer > -1666Engine.FrameSkipTimer = -1667end if668end if669670if Engine.Message == MESSAGE_LOSTFOCUS671Stage.State = STAGE_PAUSED672PauseMusic()673PlaySfx(SFX_G_SELECT, false)674StopSFX(SFX_G_FLYING)675StopSFX(SFX_G_TIRED)676Object[9].Type = TypeName[Pause Menu]677PauseMenu.DrawOrder = 7678PauseMenu.Priority = PRIORITY_ALWAYS679if Engine.FrameSkipTimer > -1680Engine.FrameSkipTimer = -1681end if682end if683end if684end if685end if686687ProcessPlayerControl()688end if689#endplatform690691// Speed Shoes control692if Player.SpeedShoesTimer > 0693Player.SpeedShoesTimer--694if Player.SpeedShoesTimer == 0695Player.Acceleration = 0xC00696Player.AirAcceleration = 0x1800697Player.TopSpeed = 0x60000698if Music.CurrentTrack == 3 // Speed Shoes699PlayMusic(0)700end if701end if702end if703704// Invincibility Control705if Player.InvincibleTimer > 0706if Player.State != Player_State_Hurt707if Player.InvincibleTimer > 2000708Player.InvincibleTimer = 120709Player.BlinkTimer = 3710end if711end if712713if Player.BlinkTimer > 0714Player.BlinkTimer++715if Player.BlinkTimer > 8716Player.BlinkTimer = 1717end if718if Player.BlinkTimer > 4719Player.Visible = false720else721Player.Visible = true722end if723end if724725Player.InvincibleTimer--726if Player.InvincibleTimer == 0727Player.BlinkTimer = 0728Player.Visible = true729if Music.CurrentTrack == 2 // Invincibility730PlayMusic(0)731end if732if Object[+2].Type == TypeName[Invincibility]733switch Object[+2].PropertyValue734case NO_SHIELD735TempValue0 = Player.EntityNo736TempValue0 += 2737ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)738break739740case ACTIVE_SHIELD741TempValue0 = Player.EntityNo742TempValue0 += 2743ResetObjectEntity(TempValue0, TypeName[Blank Object], 0, 0, 0)744Object[+2].Type = TypeName[Blue Shield]745Object[+2].PropertyValue = ACTIVE_SHIELD746Object[+2].Priority = PRIORITY_ACTIVE747Object[+2].DrawOrder = 4748Object[+2].InkEffect = INK_ALPHA749Object[+2].Alpha = 160750Object[+2].XPos = Player.XPos751Object[+2].YPos = Player.YPos752break753754end switch755end if756end if757end if758759// Restore camera position after looking up / crounching760if Player.State != Player_State_LookUp761if Player.State != Player_State_Crouch762if Player.LookPos > 0763Player.LookPos -= 2764end if765766if Player.LookPos < 0767Player.LookPos += 2768end if769end if770end if771772if Warp.Timer > 0773Warp.Timer++774775if Warp.Timer == 204776Screen.CameraEnabled = false777CreateTempObject(TypeName[Time Warp], 0, 0, 0)778#platform: Use_Standalone779Object[TempObjectPos].DrawOrder = 6780#endplatform781#platform: Use_Origins782Object[TempObjectPos].DrawOrder = 7783#endplatform784end if785end if786787// Keeps the camera in place for a bit after releasing S2 Spin Dash788if Player.ScrollDelay > 0789Player.ScrollDelay--790if Player.ScrollDelay == 0791Screen.CameraStyle = CAMERASTYLE_FOLLOW792end if793end if794795// Resets FlightVelocity796if Player.State != Player_State_Fly797if Player.FlightVelocity != 0798StopSFX(SFX_G_FLYING)799StopSFX(SFX_G_TIRED)800Player.FlightVelocity = 0801end if802end if803804end function805806// Do nothing!!807function Player_State_Static808CheckResult = false809end function810811812// Updates animation speed while rolling813function Player_HandleRollAnimSpeed814if Stage.PlayerListPos == PLAYER_TAILS_A815Player.RollAnimationSpeed = 120816else817Player.RollAnimationSpeed = Player.Speed818if Player.RollAnimationSpeed < 0819FlipSign(Player.RollAnimationSpeed)820end if821Player.RollAnimationSpeed *= 240822Player.RollAnimationSpeed /= 0x60000823Player.RollAnimationSpeed += 48824end if825end function826827828// Animation speed while walking829function Player_HandleWalkAnimSpeed830Player.AnimationSpeed = Player.Speed831if Player.AnimationSpeed < 0832FlipSign(Player.AnimationSpeed)833end if834Player.AnimationSpeed *= 60835Player.AnimationSpeed /= 0x60000836Player.AnimationSpeed += 20837end function838839// Animation speed while running840function Player_HandleRunAnimSpeed841Player.AnimationSpeed = Player.Speed842if Player.AnimationSpeed < 0843FlipSign(Player.AnimationSpeed)844end if845Player.AnimationSpeed *= 80846Player.AnimationSpeed /= 0x60000847end function848849// This makes you move850function Player_HandleGroundMovement851if Player.ControlLock > 0852Player.ControlLock--853Sin256(TempValue0, Player.Angle)854TempValue0 *= 0x2000855TempValue0 >>= 8856Player.Speed += TempValue0857else858if Player.Left == true859TempValue0 = Player.TopSpeed860FlipSign(TempValue0)861if Player.Speed > TempValue0862if Player.Speed > 0863if Player.CollisionMode == CMODE_FLOOR864// Skid865if Player.Speed > 0x40000866Player.Skidding = 16867end if868end if869870if Player.Speed < 0x8000871Player.Speed = -0x8000872Player.Skidding = 0873else874Player.Speed -= 0x8000875end if876else877Player.Speed -= Player.Acceleration878Player.Skidding = 0879end if880end if881882if Player.Speed <= 0883Player.Direction = FACING_LEFT884end if885end if886887if Player.Right == true888if Player.Speed < Player.TopSpeed889if Player.Speed < 0890if Player.CollisionMode == CMODE_FLOOR891// Skid892if Player.Speed < -0x40000893Player.Skidding = 16894end if895end if896897if Player.Speed > -0x8000898Player.Speed = 0x8000899Player.Skidding = 0900else901Player.Speed += 0x8000902end if903else904Player.Speed += Player.Acceleration905Player.Skidding = 0906end if907end if908909if Player.Speed >= 0910Player.Direction = FACING_RIGHT911end if912end if913914TempValue0 = Player.Left915TempValue0 |= Player.Right916if TempValue0 == false917//tldr, reduce speed with desaceleration, or based on angle918if Player.Speed > 0919Player.Speed -= Player.Deceleration920if Player.Speed < 0921Player.Speed = 0922end if923else924Player.Speed += Player.Deceleration925if Player.Speed > 0926Player.Speed = 0927end if928end if929930if Player.Speed > 0x2000931Sin256(TempValue0, Player.Angle)932TempValue0 *= 0x2000933TempValue0 >>= 8934Player.Speed += TempValue0935end if936937if Player.Speed < -0x2000938Sin256(TempValue0, Player.Angle)939TempValue0 *= 0x2000940TempValue0 >>= 8941Player.Speed += TempValue0942end if943944if Player.Angle > 192945if Player.Angle < 228946if Player.Speed > -0x10000947if Player.Speed < 0x10000948Player.ControlLock = 30 // Lock the player to move out of the angle949end if950end if951end if952end if953954if Player.Angle > 28955if Player.Angle < 64956if Player.Speed > -0x10000957if Player.Speed < 0x10000958Player.ControlLock = 30 // Lock the player to move out of the angle959end if960end if961end if962end if963else964Sin256(TempValue0, Player.Angle)965TempValue0 *= 0x2000966TempValue0 >>= 8967Player.Speed += TempValue0968969if Player.Right == true970if Player.Left == false971if Player.Angle > 192972if Player.Angle < 228973if Player.Speed < 0x28000974if Player.Speed > -0x20000975Player.ControlLock = 30 // Lock the player to move out of the angle976end if977end if978end if979end if980end if981else982if Player.Left == true983if Player.Angle > 28984if Player.Angle < 64985if Player.Speed > -0x28000986if Player.Speed < 0x20000987Player.ControlLock = 30 // Lock the player to move out of the angle988end if989end if990end if991end if992end if993end if994end if995end if996end function997998// Handle movement in the air999function Player_HandleAirFriction1000if Player.YVelocity > -0x400001001if Player.YVelocity < 01002TempValue0 = Player.Speed1003TempValue0 >>= 51004Player.Speed -= TempValue01005end if1006end if1007TempValue0 = Player.TopSpeed1008FlipSign(TempValue0)10091010if Player.Speed > TempValue01011if Player.Left == true1012Player.Speed -= Player.AirAcceleration1013Player.Direction = FACING_LEFT1014end if1015else1016if Player.Left == true1017Player.Direction = FACING_LEFT1018end if1019end if10201021if Player.Speed < Player.TopSpeed1022if Player.Right == true1023Player.Speed += Player.AirAcceleration1024Player.Direction = FACING_RIGHT1025end if1026else1027if Player.Right == true1028Player.Direction = FACING_RIGHT1029end if1030end if10311032if Options.OriginalControls == true1033if Player.Left == true1034TempValue0 = Player.TopSpeed1035FlipSign(TempValue0)1036if Player.Speed < TempValue01037Player.Speed = TempValue01038end if1039end if10401041if Player.Right == true1042if Player.Speed > Player.TopSpeed1043Player.Speed = Player.TopSpeed1044end if1045end if1046end if1047end function10481049// Handles desaceleration while rolling1050function Player_HandleRollDeceleration10511052if Player.Right == true1053if Player.Speed < 01054Player.Speed += Player.RollingDeceleration1055end if1056end if10571058if Player.Left == true1059if Player.Speed > 01060Player.Speed -= Player.RollingDeceleration1061end if1062end if10631064if Player.Speed > 01065Player.Speed -= Player.AirDeceleration1066if Player.Speed < 01067Player.Speed = 01068end if10691070if Player.Speed == 01071if Player.Angle > 2241072Player.State = Player_State_Ground1073end if1074if Player.Angle < 321075Player.State = Player_State_Ground1076end if1077end if10781079Sin256(TempValue0, Player.Angle)1080if TempValue0 > 01081Sin256(TempValue0, Player.Angle)1082TempValue0 *= 0x50001083else1084Sin256(TempValue0, Player.Angle)1085TempValue0 *= 0x1E001086end if10871088TempValue0 >>= 81089Player.Speed += TempValue01090else1091Player.Speed += Player.AirDeceleration1092if Player.Speed > 01093Player.Speed = 01094end if10951096if Player.Speed == 01097if Player.Angle > 2241098Player.State = Player_State_Ground1099end if1100if Player.Angle < 321101Player.State = Player_State_Ground1102end if1103end if11041105Sin256(TempValue0, Player.Angle)1106if TempValue0 < 01107Sin256(TempValue0, Player.Angle)1108TempValue0 *= 0x50001109else1110Sin256(TempValue0, Player.Angle)1111TempValue0 *= 0x1E001112end if11131114TempValue0 >>= 81115Player.Speed += TempValue01116end if11171118if Player.Speed > 0x1800001119Player.Speed = 0x1800001120end if11211122if Player.Speed < -0x1800001123Player.Speed = -0x1800001124end if1125end function11261127// Movement when you fall from a cliff1128function Player_HandleAirMovement1129Player.TrackScroll = true11301131Player.YVelocity += Player.GravityStrength1132if Player.YVelocity < Player.JumpCap1133if Player.JumpHold == false1134if Player.Timer > 01135Player.YVelocity = Player.JumpCap1136TempValue0 = Player.Speed1137TempValue0 >>= 51138Player.Speed -= TempValue01139end if1140end if1141end if1142Player.XVelocity = Player.Speed11431144if Player.Rotation < 2561145if Player.Rotation > 01146Player.Rotation -= 41147else1148Player.Rotation = 01149end if1150else1151if Player.Rotation < 5121152Player.Rotation += 41153else1154Player.Rotation = 01155end if1156end if11571158Player.CollisionMode = CMODE_FLOOR1159if Player.Animation == ANI_JUMPING1160Player.AnimationSpeed = Player.RollAnimationSpeed1161end if1162end function11631164// Gets X and Y Velocity based on angles1165function Player_HandleOnGround1166Player.TrackScroll = false11671168Cos256(TempValue0, Player.Angle)1169TempValue0 *= Player.Speed1170TempValue0 >>= 81171Player.XVelocity = TempValue011721173Sin256(TempValue0, Player.Angle)1174TempValue0 *= Player.Speed1175TempValue0 >>= 81176Player.YVelocity = TempValue01177end function11781179// A classic move1180function Player_Action_Jump1181CheckResult = false1182if Player.CollisionMode == CMODE_FLOOR1183TempValue6 = Object.XPos1184TempValue7 = Object.YPos11851186Object.XPos = Player.XPos1187Object.YPos = Player.YPos1188TempValue0 = Player.CollisionTop1189TempValue0 -= 21190ObjectTileCollision(CSIDE_RWALL, 0, TempValue0, 0)11911192Object.XPos = TempValue61193Object.YPos = TempValue71194end if11951196if CheckResult == false1197Player.ControlLock = 01198Player.Gravity = GRAVITY_AIR1199Player.AbilityTimer = 812001201Sin256(Player.XVelocity, Player.Angle)1202Player.XVelocity *= Player.JumpStrength1203Cos256(TempValue0, Player.Angle)1204TempValue0 *= Player.Speed1205Player.XVelocity += TempValue01206Player.XVelocity >>= 812071208Sin256(Player.YVelocity, Player.Angle)1209Player.YVelocity *= Player.Speed1210Cos256(TempValue0, Player.Angle)1211TempValue0 *= Player.JumpStrength1212Player.YVelocity -= TempValue01213Player.YVelocity >>= 812141215Player.Speed = Player.XVelocity1216Player.TrackScroll = true1217Player.Animation = ANI_JUMPING1218Player.Angle = 01219Player.CollisionMode = CMODE_FLOOR1220Player.Timer = 11221CallFunction(Player_HandleRollAnimSpeed)12221223Player.State = Player_State_Air12241225PlaySfx(SFX_G_JUMP, false)1226end if12271228#platform: Use_Origins1229if game.playMode == BOOT_PLAYMODE_CLASSIC1230Player.DropDashCharge = -11231else1232Player.DropDashCharge = 01233end if1234#endplatform1235end function12361237// A true Classic, but the actual spindash is set here, this only starts it1238function Player_Action_Spindash_S21239Player.State = Player_State_Spindash_S21240Player.Animation = ANI_SPINDASH1241Player.AbilityTimer = 012421243PlaySfx(SFX_G_CHARGE, false)1244// Dust Puff Code1245CreateTempObject(TypeName[Dust Puff], Object.EntityNo, Player.XPos, Player.YPos)1246Object[TempObjectPos].iYPos = Player.CollisionBottom1247Object[TempObjectPos].YPos += Player.YPos1248Object[TempObjectPos].Frame = 41249Object[TempObjectPos].DrawOrder = 41250Object[TempObjectPos].Direction = Player.Direction12511252#platform: Use_Haptics1253HapticEffect(112, 0, 0, 0)1254#endplatform1255end function12561257// Not so classic, but the actual spindash is set here, this only starts it1258function Player_Action_Spindash_CD1259Player.State = Player_State_Spindash_CD1260Player.Animation = ANI_JUMPING1261Player.YPos += 0x500001262Player.AbilityTimer = 012631264PlaySfx(SFX_G_CHARGE, false)12651266#platform: Use_Haptics1267HapticEffect(112, 0, 0, 0)1268#endplatform1269end function12701271// um yesh, Sonic 2 Peel Out, this just starts it1272function Player_Action_Peelout_S21273Player.State = Player_State_Peelout_S21274Player.AbilityTimer = 01275PlaySfx(SFX_G_CHARGE, false)12761277#platform: Use_Haptics1278HapticEffect(115, 0, 0, 0)1279#endplatform1280end function12811282// A true classic, this just starts it tho1283function Player_Action_Peelout_CD1284Player.State = Player_State_Peelout_CD1285Player.AbilityTimer = 01286PlaySfx(SFX_G_CHARGE, false)12871288#platform: Use_Haptics1289HapticEffect(115, 0, 0, 0)1290#endplatform1291end function12921293// Starts flying state1294function Player_Action_DblJumpTails1295if Player.AbilityTimer > 01296Player.AbilityTimer--1297else1298if Player.JumpPress == true1299Player.Timer = 01300Player.State = Player_State_Fly1301Player.FlightVelocity = 0x80013021303#platform: Use_Origins1304game.callbackParam0 = 0 // Turned into Super Sonic (not in this game LOL)1305game.callbackParam1 = 1 // Used Tails' Flight1306game.callbackParam2 = 0 // Used Knux's Glide1307EngineCallback(NOTIFY_STATS_CHARA_ACTION)1308#endplatform13091310// check that you're not in water1311if Player.GravityStrength == 0x38001312PlaySfx(SFX_G_FLYING, true)1313Player.Animation = ANI_FLYING1314else1315Player.Animation = ANI_SWIMMING1316end if1317end if1318end if1319end function13201321function Player_State_Ground1322if Player.Animation != ANI_SKIDDING // This handles that the skid only plays sfx once1323TempValue7 = true1324else1325TempValue7 = false1326end if13271328CallFunction(Player_HandleGroundMovement)13291330if Player.Gravity == GRAVITY_AIR13311332#platform: Use_Origins1333Player.State = Player_State_Air_NoDropDash1334#endplatform13351336#platform: Use_Standalone1337Player.State = Player_State_Air1338#endplatform13391340CallFunction(Player_HandleAirMovement)1341else1342CallFunction(Player_HandleOnGround)1343if Player.Speed == 01344// Consumes the warp if you stop too late during warping run1345if Warp.Destination > WARPDEST_NONE1346if Warp.Timer > 991347if Warp.Timer < 2201348Warp.Destination = WARPDEST_NONE1349end if1350end if1351Warp.Timer = 01352end if13531354if Player.CollisionMode == CMODE_FLOOR1355#platform: Use_Origins1356switch Stage.PlayerListPos1357case PLAYER_SONIC_A1358case PLAYER_TAILS_A1359// Original behaviour - Outta Here (Sonic, Classic Mode only)1360if Player.Timer < 2401361Player.Animation = ANI_STOPPED1362Player.Timer++1363else // Waiting animation1364Player.Animation = ANI_WAITING1365if Stage.PlayerListPos == PLAYER_SONIC1366Player.Timer++1367if game.playMode == BOOT_PLAYMODE_CLASSIC1368if Player.Timer == 10620 // 177 seconds (2 minutes, 57 seconds)1369Player.Timer = 013701371// This SFX is muted in Origins1372PlaySfx(SFX_G_OUTTAHERE, false)13731374Player.State = Player_State_OuttaHere1375Player.Animation = ANI_BORED1376end if1377end if1378end if1379end if1380break1381case PLAYER_KNUCKLES_A1382// Knuckles sparring with the air1383if Player.Timer < 2401384Player.Animation = ANI_STOPPED1385Player.Timer++1386else1387if Player.Timer < 5701388Player.Animation = ANI_WAITING1389Player.Timer++1390else1391if Mini_PlayerFlag == false1392Player.Animation = ANI_BORED1393Player.Timer++1394if Player.Timer == 8421395Player.Timer = 01396Player.Animation = ANI_STOPPED1397end if1398else1399Player.Timer = 01400Player.Animation = ANI_STOPPED1401end if1402end if1403end if1404break1405case PLAYER_AMY_A1406// Amy daydreaming1407if Player.Timer < 2401408Player.Animation = ANI_STOPPED1409Player.Timer++1410else1411if Player.Timer < 11071412Player.Animation = ANI_WAITING1413Player.Timer++1414else1415if Mini_PlayerFlag == false1416Player.Animation = ANI_BORED1417Player.Timer++1418if Player.Timer >= 11521419Player.Timer = 11071420end if1421end if1422end if1423end if1424break1425end switch1426#endplatform14271428#platform: Use_Standalone1429if Player.Timer < 2401430Player.Animation = ANI_STOPPED1431Player.Timer++1432else // Waiting animation1433Player.Animation = ANI_WAITING1434if Stage.PlayerListPos == PLAYER_SONIC_A1435Player.Timer++1436if Player.Timer == 10620 // I'm Outta Here!1437Player.Timer = 014381439PlaySfx(SFX_G_OUTTAHERE, false)14401441Player.State = Player_State_OuttaHere1442Player.Animation = ANI_BORED1443end if1444end if1445end if1446#endplatform14471448if Player.FloorSensorC == false1449if Player.FloorSensorR == false1450Player.Timer = 014511452if Player.Direction == FACING_LEFT1453Player.Animation = ANI_FLAILINGLEFT1454else1455Player.Animation = ANI_FLAILINGRIGHT1456end if1457end if14581459if Player.FloorSensorL == false1460Player.Timer = 014611462if Player.Direction == FACING_RIGHT1463Player.Animation = ANI_FLAILINGLEFT1464else1465Player.Animation = ANI_FLAILINGRIGHT1466end if1467end if14681469end if14701471end if1472else1473Player.Timer = 01474if Player.Speed > 01475if Player.Speed < 0x5F5C21476Player.Animation = ANI_WALKING1477CallFunction(Player_HandleWalkAnimSpeed)1478// Consumes the warp if you stop too late during warping run, plus deletes the warp star1479if Warp.Destination > WARPDEST_NONE1480if Warp.Timer > 991481if Warp.Timer < 2041482Warp.Destination = WARPDEST_NONE1483end if1484end if1485Warp.Timer = 01486Object[3].Type = TypeName[Blank Object]1487end if1488else1489// Spawns the Warp Stars1490if Warp.Destination > WARPDEST_NONE1491if Warp.Timer == 01492Warp.Timer = 11493ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)1494WarpStar.Timer = 71495WarpStar.DrawOrder = 41496end if1497end if14981499if Player.Speed > 0x9FFFF1500Player.Animation = ANI_PEELOUT1501else1502Player.Animation = ANI_RUNNING1503end if1504CallFunction(Player_HandleRunAnimSpeed)1505end if1506else1507if Player.Speed > -0x5F5C21508Player.Animation = ANI_WALKING1509CallFunction(Player_HandleWalkAnimSpeed)1510// Consumes the warp if you stop too late during warping run, plus deletes the warp star1511if Warp.Destination > WARPDEST_NONE1512if Warp.Timer > 991513if Warp.Timer < 2041514Warp.Destination = WARPDEST_NONE1515end if1516end if1517Warp.Timer = 01518Object[3].Type = TypeName[Blank Object]1519end if1520else1521// Spawns the Warp Stars1522if Warp.Destination > WARPDEST_NONE1523if Warp.Timer == 01524Warp.Timer = 11525ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)1526WarpStar.Timer = 71527WarpStar.DrawOrder = 41528end if1529end if15301531if Player.Speed < -0x9FFFF1532Player.Animation = ANI_PEELOUT1533else1534Player.Animation = ANI_RUNNING1535end if1536CallFunction(Player_HandleRunAnimSpeed)1537end if15381539end if15401541end if15421543// Skidding1544if Player.Skidding > 01545if TempValue7 == true1546PlaySfx(SFX_G_SKIDDING, false)1547end if1548Player.Animation = ANI_SKIDDING1549Player.AnimationSpeed = 01550Player.Skidding--15511552if Ring.AniCount == 01553CreateTempObject(TypeName[Dust Puff], 0, Player.XPos, Player.YPos)1554Object[TempObjectPos].iYPos += Player.CollisionBottom1555Object[TempObjectPos].DrawOrder = Player.DrawOrder1556end if15571558if Player.Speed > 01559Player.Direction = FACING_RIGHT1560else1561Player.Direction = FACING_LEFT1562end if1563end if15641565// Push, there's a small delay so 2 is our "true"1566if Player.CollisionMode == CMODE_FLOOR1567if Player.Pushing == 21568Player.Animation = ANI_PUSHING1569Player.AnimationSpeed = 01570end if1571end if15721573// Jump1574if Player.JumpPress == true1575CallFunction(Player_Action_Jump)1576else1577// Look Up1578if Player.Up == true1579if Player.Speed == 01580if Player.Animation != ANI_FLAILINGLEFT1581if Player.Animation != ANI_FLAILINGRIGHT1582Player.State = Player_State_LookUp1583Player.Animation = ANI_LOOKINGUP1584Player.Timer = 01585end if1586end if1587end if1588end if15891590// Crouch1591if Player.Down == true1592if Player.Speed == 01593if Player.Animation != ANI_FLAILINGLEFT1594if Player.Animation != ANI_FLAILINGRIGHT1595Player.State = Player_State_Crouch1596Player.Animation = ANI_LOOKINGDOWN1597Player.Timer = 01598end if1599end if1600else1601// Roll1602if Player.Left == false1603if Player.Right == false1604if Player.Speed > 01605if Player.Speed > 0x88001606Player.State = Player_State_Roll1607Player.Animation = ANI_JUMPING1608Player.iYPos -= Player.JumpOffset1609Player.AbilityTimer = 10241610end if1611else1612if Player.Speed < -0x88001613Player.State = Player_State_Roll1614Player.Animation = ANI_JUMPING1615Player.iYPos -= Player.JumpOffset1616Player.AbilityTimer = 10241617end if1618end if1619end if1620end if1621end if1622end if1623end if1624end if1625end function16261627function Player_State_Air_NoDropDash // Origins function, prevents Sonic from drop dashing without jumping16281629Player.DropDashCharge = -11630Player.State = Player_State_Air1631CallFunction(Player_State_Air)1632end function16331634function Player_State_Air1635CallFunction(Player_HandleAirFriction)1636#platform: Use_Origins1637if Stage.PlayerListPos == PLAYER_TAILS1638CallFunction(Player_HandleDropDash)1639end if1640#endplatform1641if Player.Gravity == GRAVITY_AIR // Check that you're truly in the air1642CallFunction(Player_HandleAirMovement)16431644// More warp stuff1645if Warp.Destination > WARPDEST_NONE1646TempValue0 = Player.YVelocity1647if TempValue0 < 01648FlipSign(TempValue0)1649end if16501651if TempValue0 < 0x600001652TempValue0 = Player.XVelocity1653if TempValue0 < 01654FlipSign(TempValue0)1655end if16561657if TempValue0 < 0x600001658TempValue0 = Player.XVelocity1659TempValue0 -= Warp.SpeedCompare1660if TempValue0 < 01661FlipSign(TempValue0)1662end if16631664if TempValue0 > 0x400001665if Warp.Timer > 991666if Warp.Timer < 2041667Warp.Destination = WARPDEST_NONE1668end if1669end if1670Warp.Timer = 01671end if1672end if1673end if1674Warp.SpeedCompare = Player.XVelocity1675end if16761677// changes the flailing with the walking, not sure when this is used1678if Player.YVelocity > 0x200001679if Player.Animation == ANI_FLAILINGLEFT1680Player.Animation = ANI_WALKING1681end if1682if Player.Animation == ANI_FLAILINGRIGHT1683Player.Animation = ANI_WALKING1684end if1685end if16861687// Post-Hitting a spring1688if Player.Animation == ANI_BOUNCING1689if Player.YVelocity >= 01690if Player.AnimationReserve == ANI_STOPPED1691Player.AnimationReserve = ANI_WALKING1692end if1693Player.Animation = Player.AnimationReserve1694end if1695end if16961697// Post Getting hurt1698if Player.Animation == ANI_HURT1699if Player.YVelocity >= 01700if Player.AnimationReserve == ANI_STOPPED1701Player.AnimationReserve = ANI_WALKING1702end if1703Player.Animation = Player.AnimationReserve1704end if1705end if17061707// Calls the player flight function1708#platform: Use_Origins1709// Bug Details:1710// This segment of code was backported from Sonic 1 to (presumably) prevent the ledge roll-off ability bug that's from 2011.1711// -> However, this code is missing the Player.JumpAbilityState check before the second ANI_JUMPING check.1712// -> This basically makes it still behave like 2011 does, just more advanced (?).1713// -> The other checks from S1 that also do things with Player.JumpAbilityState are missing too...1714// -> Not really sure why it turned out this way.1715if Stage.PlayerListPos == PLAYER_TAILS1716if Player.Animation == ANI_JUMPING1717CallFunction(Player.JumpAbility)1718end if1719else1720if Player.YVelocity >= Player.JumpCap1721CallFunction(Player_HandleDropDash)1722if Player.Animation == ANI_JUMPING1723CallFunction(Player.JumpAbility)1724end if1725end if1726end if1727#endplatform17281729#platform: Use_Standalone1730if Player.Animation == ANI_JUMPING1731CallFunction(Player.JumpAbility)1732end if1733#endplatform1734else1735// go back to the ground silly1736#platform: Use_Origins1737if Player.DropDashCharge >= 201738if Stage.PlayerListPos == PLAYER_AMY1739CallFunction(Player_Action_HammerDash)1740else1741CallFunction(Player_Action_Spindash_S2)1742end if1743else1744Player.State = Player_State_Ground1745CallFunction(Player_HandleOnGround)1746Player.Skidding = 01747end if1748#endplatform17491750#platform: Use_Standalone1751Player.State = Player_State_Ground1752CallFunction(Player_HandleOnGround)1753Player.Skidding = 01754#endplatform1755end if1756end function17571758function Player_State_Roll1759CallFunction(Player_HandleRollDeceleration)1760#platform: Use_Origins1761if Player.ForceGrounded > 01762Player.Gravity = GRAVITY_GROUND1763Player.ForceGrounded -= 1 // ig a normal "--" wasn't good enough, huh?1764end if1765#endplatform17661767if Player.Gravity == GRAVITY_AIR17681769#platform: Use_Origins1770Player.State = Player_State_Air_NoDropDash1771#endplatform17721773#platform: Use_Standalone1774Player.State = Player_State_Air1775#endplatform17761777Player.Timer = 01778CallFunction(Player_HandleAirMovement)1779else1780CallFunction(Player_HandleRollAnimSpeed)1781Player.AnimationSpeed = Player.RollAnimationSpeed17821783TempValue0 = Player.Speed1784if TempValue0 < 01785FlipSign(TempValue0)1786end if17871788// Warp-Consuming1789if TempValue0 < 0x5F5C21790if Warp.Destination > WARPDEST_NONE1791if Warp.Timer > 991792if Warp.Timer < 2041793Warp.Destination = WARPDEST_NONE1794end if1795end if1796Warp.Timer = 01797end if1798else1799// Spawn Warp Stars1800if Warp.Destination > WARPDEST_NONE1801if Warp.Timer == 01802Warp.Timer = 11803ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)1804WarpStar.Timer = 71805WarpStar.DrawOrder = 41806end if1807end if1808end if18091810CallFunction(Player_HandleOnGround)18111812if Player.JumpPress == true1813CallFunction(Player_Action_Jump)1814end if1815end if1816end function18171818// Cancels input movement (Unused leftover from Sonic Nexus (2008))1819function Player_State_RollJump1820#platform: Use_Origins1821// they removed roll jump lock in Plus lol1822if Options.AttractMode == true1823Player.Left = false1824Player.Right = false1825end if18261827CallFunction(Player_HandleAirFriction)1828if Stage.PlayerListPos == PLAYER_TAILS1829CallFunction(Player_HandleDropDash)1830else1831if Player.YVelocity >= Player.JumpCap1832CallFunction(Player_HandleDropDash)1833end if1834end if1835#endplatform18361837#platform: Use_Standalone1838Player.Left = false1839Player.Right = false1840CallFunction(Player_HandleAirFriction)1841#endplatform184218431844if Player.Gravity == GRAVITY_AIR1845CallFunction(Player_HandleAirMovement)1846else18471848#platform: Use_Origins1849if Player.DropDashCharge >= 201850if Stage.PlayerListPos == PLAYER_AMY1851CallFunction(Player_Action_HammerDash)1852else1853CallFunction(Player_Action_Spindash_S2)1854end if1855else1856Player.State = Player_State_Ground1857CallFunction(Player_HandleOnGround)1858Player.Skidding = 01859end if1860#endplatform18611862#platform: Use_Standalone1863Player.State = Player_State_Ground1864CallFunction(Player_HandleOnGround)1865Player.Skidding = 01866#endplatform18671868end if1869end function18701871// Hey look up1872function Player_State_LookUp1873if Player.Up == false1874Player.State = Player_State_Ground1875Player.Timer = 01876else1877if Player.Timer < 601878Player.Timer++1879else1880if Player.LookPos > -1121881Player.LookPos -= 21882end if1883end if18841885if Player.Gravity == GRAVITY_AIR18861887#platform: Use_Origins1888Player.State = Player_State_Air_NoDropDash1889#endplatform18901891#platform: Use_Standalone1892Player.State = Player_State_Air1893#endplatform18941895Player.Timer = 01896else1897if Player.JumpPress == true1898CallFunction(Player.ActionPeelout)1899end if1900end if1901end if1902end function19031904// Hey look down1905function Player_State_Crouch1906if Player.Down == false1907Player.State = Player_State_Ground1908Player.Timer = 01909else1910if Player.Timer < 601911Player.Timer++1912else1913if Player.LookPos < 961914Player.LookPos += 21915end if1916end if19171918if Player.Gravity == GRAVITY_AIR19191920#platform: Use_Origins1921Player.State = Player_State_Air_NoDropDash1922#endplatform19231924#platform: Use_Standalone1925Player.State = Player_State_Air1926#endplatform19271928Player.Timer = 01929else1930if Player.JumpPress == true1931CallFunction(Player.ActionSpindash)1932end if1933end if1934end if1935end function19361937// S2 Spin Dash code1938function Player_State_Spindash_S21939// Keep the camera lock, cancel the spin dash1940if Player.Gravity == GRAVITY_AIR19411942#platform: Use_Origins1943Player.State = Player_State_Air_NoDropDash1944#endplatform19451946#platform: Use_Standalone1947Player.State = Player_State_Air1948#endplatform19491950Player.Speed = 01951end if19521953// Mashing1954if Player.JumpPress == true1955if Player.AbilityTimer < 5121956Player.AbilityTimer += 641957end if1958Player.Frame = 019591960PlaySfx(SFX_G_CHARGE, false)1961else1962if Player.AbilityTimer > 01963Player.AbilityTimer--1964end if1965end if19661967#platform: Use_Origins1968TempValue1 = Player.Down1969if Player.DropDashCharge >= 201970Player.DropDashCharge = -11971Sin256(TempValue0, Player.Angle)1972if Player.Direction == FACING_RIGHT1973if TempValue0 >= 01974TempValue0 <<= 21975else1976TempValue0 <<= 11977end if1978else1979if TempValue0 >= 01980TempValue0 <<= 11981else1982TempValue0 <<= 21983end if1984FlipSign(TempValue0)1985end if19861987if TempValue0 > 5121988TempValue0 = 5121989end if19901991Player.AbilityTimer = TempValue01992TempValue1 = false1993end if19941995CheckEqual(TempValue1, false)1996#endplatform19971998#platform: Use_Standalone1999CheckEqual(Player.Down, false)2000#endplatform2001// Work around to adapt it to origins2002// Spin Dash release2003if CheckResult == true2004Player.Timer = 02005Player.State = Player_State_Roll2006Player.Animation = ANI_JUMPING2007Player.iYPos -= Player.JumpOffset20082009Player.ScrollDelay = 152010Screen.CameraStyle = CAMERASTYLE_HLOCKED20112012TempValue0 = Player.AbilityTimer2013TempValue0 <<= 92014TempValue0 += 0x8000020152016if Player.Direction == FACING_RIGHT2017Player.Speed = TempValue02018else2019Player.Speed = TempValue02020FlipSign(Player.Speed)2021end if20222023PlaySfx(SFX_G_RELEASE, false)20242025CallFunction(Player_HandleOnGround)20262027#platform: Use_Origins2028Player.ForceGrounded = 62029#endplatform20302031#platform: Use_Haptics2032HapticEffect(42, 0, 0, 0)2033#endplatform20342035end if2036end function20372038function Player_State_Spindash_CD2039if Player.Direction == FACING_RIGHT2040Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L2041else2042Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R2043end if20442045// Keep the camera lock, cancel the spin dash2046if Player.Gravity == GRAVITY_AIR20472048#platform: Use_Origins2049Player.State = Player_State_Air_NoDropDash2050#endplatform20512052#platform: Use_Standalone2053Player.State = Player_State_Air2054#endplatform20552056Player.Speed = 02057Screen.CameraStyle = CAMERASTYLE_EXTENDED2058end if20592060// Charge2061if Player.GravityStrength == 0x10002062if Player.AbilityTimer < 0x800002063Player.AbilityTimer += 0x60002064end if2065else2066if Player.AbilityTimer < 0xC00002067Player.AbilityTimer += 0x60002068end if2069end if20702071// Release2072if Player.Down == false2073Screen.CameraStyle = CAMERASTYLE_EXTENDED2074Player.Timer = 020752076if Player.AbilityTimer < 0x2FAE12077Player.Speed = 02078Player.State = Player_State_Ground2079else2080Player.State = Player_State_Roll2081Player.Animation = ANI_JUMPING2082Player.Speed = Player.AbilityTimer20832084if Player.Direction == FACING_LEFT2085FlipSign(Player.Speed)2086end if20872088PlaySfx(SFX_G_RELEASE, false)2089end if2090CallFunction(Player_HandleOnGround)20912092#platform: Use_Haptics2093HapticEffect(42, 0, 0, 0)2094#endplatform20952096end if2097end function209820992100function Player_State_Peelout_S22101// Cancels the Peel Out, keeps the camera2102if Player.Gravity == GRAVITY_AIR21032104#platform: Use_Origins2105Player.State = Player_State_Air_NoDropDash2106#endplatform21072108#platform: Use_Standalone2109Player.State = Player_State_Air2110#endplatform21112112Player.Speed = 02113end if2114// Charge2115if Player.GravityStrength == 0x10002116if Player.AbilityTimer < 0x600002117Player.AbilityTimer += 0x60002118end if2119else2120if Player.AbilityTimer < 0xC00002121Player.AbilityTimer += 0x60002122end if2123end if2124// Speed building, from walking to running then peelout2125if Player.AbilityTimer < 0x5F5C22126Player.Animation = ANI_WALKING2127TempValue0 = Player.AbilityTimer2128TempValue0 >>= 162129TempValue0 *= 802130TempValue0 /= 62131TempValue0 += 202132else2133TempValue0 = Player.AbilityTimer2134TempValue0 >>= 162135TempValue0 *= 802136TempValue0 /= 62137if Player.AbilityTimer > 0x9FFFF2138Player.Animation = ANI_PEELOUT2139else2140Player.Animation = ANI_RUNNING2141end if2142end if21432144// Release2145if Player.Up == false2146Player.ScrollDelay = 152147Screen.CameraStyle = CAMERASTYLE_HLOCKED21482149Player.State = Player_State_Ground2150// Cancels the peel out if you didn't charged it enough2151if Player.AbilityTimer < 0x5F5C22152Player.Speed = 02153else2154Player.Speed = Player.AbilityTimer2155if Player.Direction == FACING_LEFT2156FlipSign(Player.Speed)2157end if2158PlaySfx(SFX_G_RELEASE, false)2159end if2160CallFunction(Player_HandleOnGround)21612162#platform: Use_Haptics2163HapticEffect(42, 0, 0, 0)2164#endplatform21652166end if2167Player.AnimationSpeed = TempValue02168end function216921702171function Player_State_Peelout_CD2172// Moves the camera2173if Player.Direction == FACING_RIGHT2174Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L2175else2176Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R2177end if2178// Cancels the Peel Out, keeps the camera2179if Player.Gravity == GRAVITY_AIR21802181#platform: Use_Origins2182Player.State = Player_State_Air_NoDropDash2183#endplatform21842185#platform: Use_Standalone2186Player.State = Player_State_Air2187#endplatform21882189Player.Speed = 02190Screen.CameraStyle = CAMERASTYLE_EXTENDED2191end if21922193// Charge2194if Player.GravityStrength == 0x10002195if Player.AbilityTimer < 0x600002196Player.AbilityTimer += 0x60002197end if2198else2199if Player.AbilityTimer < 0xC00002200Player.AbilityTimer += 0x60002201end if2202end if22032204// Speed building, from walking to running then peelout2205if Player.AbilityTimer < 0x5F5C22206Player.Animation = ANI_WALKING2207TempValue0 = Player.AbilityTimer2208TempValue0 >>= 162209TempValue0 *= 802210TempValue0 /= 62211TempValue0 += 202212else2213TempValue0 = Player.AbilityTimer2214TempValue0 >>= 162215TempValue0 *= 802216TempValue0 /= 62217if Player.AbilityTimer > 0x9FFFF2218Player.Animation = ANI_PEELOUT2219else2220Player.Animation = ANI_RUNNING2221end if2222end if22232224// Release2225if Player.Up == false2226Screen.CameraStyle = CAMERASTYLE_EXTENDED22272228Player.State = Player_State_Ground2229// Cancels the peel out if you didn't charged it enough2230if Player.AbilityTimer < 0x5F5C22231Player.Speed = 02232else2233Player.Speed = Player.AbilityTimer2234if Player.Direction == FACING_LEFT2235FlipSign(Player.Speed)2236end if22372238PlaySfx(SFX_G_RELEASE, false)2239end if2240CallFunction(Player_HandleOnGround)22412242#platform: Use_Haptics2243HapticEffect(42, 0, 0, 0)2244#endplatform22452246end if2247Player.AnimationSpeed = TempValue02248end function22492250// Tails flight2251function Player_State_Fly2252CallFunction(Player_HandleAirFriction)2253if Player.Gravity == GRAVITY_AIR2254Player.XVelocity = Player.Speed2255// Check if you have enough speed while flying to keep the warp2256if Warp.Destination > WARPDEST_NONE2257TempValue0 = Player.XVelocity2258if TempValue0 < 02259FlipSign(TempValue0)2260end if22612262TempValue1 = Player.YVelocity2263if TempValue1 < 02264FlipSign(TempValue1)2265end if22662267TempValue0 += TempValue12268if TempValue0 < 0x400002269if Warp.Timer > 992270if Warp.Timer < 2202271Warp.Destination = WARPDEST_NONE2272end if2273end if2274Warp.Timer = 02275end if2276end if22772278if Player.YVelocity < -0x100002279Player.FlightVelocity = 0x8002280else2281if Player.YVelocity < 12282if Player.AbilityTimer < 602283Player.AbilityTimer++2284else2285Player.FlightVelocity = 0x8002286end if2287end if2288end if22892290Player.YVelocity += Player.FlightVelocity2291if Player.Timer < 4802292if Player.GravityStrength == 0x38002293Player.Animation = ANI_FLYING2294else2295Player.Animation = ANI_SWIMMING2296end if22972298Player.Timer++2299if Player.Timer == 4802300if Player.GravityStrength == 0x38002301Player.Animation = ANI_FLYINGTIRED2302StopSfx(SFX_G_FLYING)2303PlaySfx(SFX_G_TIRED, true)2304else2305Player.Animation = ANI_SWIMMINGTIRED2306end if2307else2308if Player.JumpPress == true2309Player.FlightVelocity = -0x20002310Player.AbilityTimer = 02311end if2312end if2313else2314if Player.GravityStrength == 0x38002315Player.Animation = ANI_FLYINGTIRED2316else2317Player.Animation = ANI_SWIMMINGTIRED2318end if2319end if2320else2321Player.State = Player_State_Ground2322CallFunction(Player_HandleOnGround)2323end if23242325// If the level has a roof barrier, you're not getting too far2326if Player.RoofBarrier == true2327TempValue0 = Player.YPos2328TempValue0 >>= 162329if TempValue0 < Player.CollisionBottom2330Player.YPos = Player.CollisionBottom2331Player.YPos <<= 162332end if2333end if2334end function23352336// Player Damage2337function Player_State_GotHit2338#platform: Use_Origins2339TempValue1 = false2340if game.playMode == BOOT_PLAYMODE_MISSION2341if game.missionFunctionNo == RULE_MERCY_BADNIKS2342if game.missionValue == 12343game.missionValue = 02344TempValue1 = true2345end if2346end if2347end if2348#endplatform23492350ArrayPos0 = Player.EntityNo2351ArrayPos0 += 22352// if you had a shield, remove it2353if Object[ArrayPos0].PropertyValue > 02354TempValue0 = DAMAGE_SHIELDED2355ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)2356PlaySfx(SFX_G_HURT, false)2357else2358if Player.Rings == 02359PlaySfx(SFX_G_HURT, false)2360TempValue0 = DAMAGE_DEATH2361else2362#platform: Use_Origins2363if TempValue1 == false2364PlaySfx(SFX_G_LOSERINGS, false)2365TempValue0 = DAMAGE_HURT2366end if2367#endplatform23682369#platform: Use_Standalone2370PlaySfx(SFX_G_LOSERINGS, false)2371TempValue0 = DAMAGE_HURT2372#endplatform2373end if2374end if23752376#platform: Use_Origins2377if TempValue1 != false2378TempValue0 = DAMAGE_DEATH2379end if2380#endplatform23812382switch TempValue02383case DAMAGE_SHIELDED2384#platform: Use_Haptics2385HapticEffect(16, 0, 0, 0)2386#endplatform23872388Player.State = Player_State_Hurt2389Player.Animation = ANI_HURT2390Player.YVelocity = -0x400002391Player.Gravity = GRAVITY_AIR2392Player.TrackScroll = true2393Player.InvincibleTimer = 800023942395if Player.GravityStrength == 0x10002396Player.Speed >>= 12397Player.YVelocity >>= 12398end if2399break24002401case DAMAGE_HURT2402#platform: Use_Haptics2403HapticEffect(16, 0, 0, 0)2404#endplatform24052406if Player.CollisionPlane == COLLISION_PLANE_A2407TempValue4 = 32408else2409TempValue4 = 12410end if24112412Player.State = Player_State_Hurt2413Player.Animation = ANI_HURT2414Player.YVelocity = -0x400002415Player.Gravity = GRAVITY_AIR2416Player.TrackScroll = true2417Player.InvincibleTimer = 800024182419if Player.GravityStrength == 0x10002420Player.Speed >>= 12421Player.YVelocity >>= 12422end if2423// Lose ring code2424TempValue0 = Player.Rings2425if TempValue0 > 162426TempValue1 = TempValue02427TempValue1 -= 162428TempValue0 = 162429else2430TempValue1 = 02431end if24322433if TempValue1 > 162434TempValue1 = 162435end if24362437TempValue3 = TempValue12438TempValue3 >>= 12439TempValue3 <<= 524402441TempValue2 = 3842442TempValue2 -= TempValue324432444TempValue3 >>= 42445if TempValue3 == TempValue12446TempValue2 += 162447else2448TempValue2 -= 162449end if24502451TempValue3 = 02452while TempValue3 < TempValue12453CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)2454Cos(Object[TempObjectPos].XVelocity, TempValue2)2455Sin(Object[TempObjectPos].YVelocity, TempValue2)2456Object[TempObjectPos].XVelocity <<= 82457Object[TempObjectPos].YVelocity <<= 82458Object[TempObjectPos].DrawOrder = TempValue42459Object[TempObjectPos].AnimationSpeed = 2562460TempValue3++2461TempValue2 += 322462loop2463TempValue3 = TempValue02464TempValue3 >>= 12465TempValue3 <<= 524662467TempValue2 = 3842468TempValue2 -= TempValue324692470TempValue3 >>= 42471if TempValue3 == TempValue02472TempValue2 += 162473else2474TempValue2 -= 162475end if2476TempValue3 = 024772478while TempValue3 < TempValue02479CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)2480Cos(Object[TempObjectPos].XVelocity, TempValue2)2481Sin(Object[TempObjectPos].YVelocity, TempValue2)2482Object[TempObjectPos].XVelocity <<= 92483Object[TempObjectPos].YVelocity <<= 92484Object[TempObjectPos].DrawOrder = TempValue42485Object[TempObjectPos].AnimationSpeed = 2562486TempValue3++2487TempValue2 += 322488loop2489Player.Rings = 02490Ring.ExtraLife = 1002491break24922493case DAMAGE_DEATH2494#platform: Use_Haptics2495HapticEffect(28, 0, 0, 0)2496#endplatform24972498Object.DrawOrder = 52499Player.Speed = 02500Player.YVelocity = -0x700002501Player.XVelocity = 02502Player.State = Player_State_Death2503Player.Animation = ANI_DYING25042505Player.TileCollisions = false2506Player.ObjectInteraction = false2507if Player.EntityNo == 0 // Check if it's was player 1 who died......what?2508Screen.CameraEnabled = false2509end if2510break2511end switch2512// lose your warp-run if you receive damage2513if Warp.Destination > WARPDEST_NONE2514if Warp.Timer > 992515if Warp.Timer < 2042516Warp.Destination = WARPDEST_NONE2517end if2518end if2519Warp.Timer = 02520end if2521end function252225232524function Player_State_Hurt2525#platform: Use_Origins2526Player.TileCollisions = true2527#endplatform2528if Player.Gravity == GRAVITY_AIR2529Player.TrackScroll = true2530if Player.GravityStrength == 0x38002531Player.YVelocity += 0x30002532else2533Player.YVelocity += 0xF002534end if2535Player.XVelocity = Player.Speed2536else2537Player.State = Player_State_Ground2538Player.InvincibleTimer = 1202539Player.BlinkTimer = 32540Player.Speed = 02541Player.XVelocity = 02542CallFunction(Player_HandleOnGround)2543end if2544end function254525462547function Player_State_OuttaHere2548// preparing to jump2549if Player.Timer < 1402550Player.Timer++2551else2552// The Jump.2553Player.Timer = 02554Player.DrawOrder = 525552556if Player.Direction == FACING_RIGHT2557Player.Speed = 0x100002558Player.XVelocity = 0x100002559else2560Player.Speed = -0x100002561Player.XVelocity = -0x100002562end if2563Player.YVelocity = -0x580002564Player.State = Player_State_Death25652566Player.TileCollisions = false2567Player.ObjectInteraction = false25682569Screen.CameraEnabled = false2570end if2571end function25722573// YOU DIED.2574function Player_State_Death2575Player.ControlMode = CONTROLMODE_NONE2576Player.YVelocity += 0x38002577// Don't override the bored animation2578if Player.Animation != ANI_BORED2579Player.Animation = ANI_DYING2580end if25812582if Player.YVelocity > 0x1000002583#platform: Use_Origins2584EngineCallback(NOTIFY_DEATH_EVENT)2585#endplatform25862587if Player.Lives > 02588if Player.Animation == ANI_BORED // Outta Here makes an automatic game over, no lifes will save you2589Player.Lives = 02590else25912592#platform: Use_Origins2593// Check that we are actually in a mode where we use lives2594if game.coinMode == false2595if game.playMode != BOOT_PLAYMODE_MISSION2596CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)2597TempValue0 = CheckResult2598CheckEqual(game.oneStageFlag, false)2599TempValue0 |= CheckResult2600if TempValue0 != 02601Player.Lives--2602end if2603end if2604end if2605#endplatform26062607#platform: Use_Standalone2608// In Standalone, we don't have any extra things to worry about2609Player.Lives--2610#endplatform2611end if2612end if26132614Stage.TimeEnabled = false26152616#platform: Use_Origins2617CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)2618TempValue0 = CheckResult2619CheckNotEqual(Player.Lives, 0)2620TempValue0 |= CheckResult2621// Check if the player is replaying the stage from My Data & Rankings2622CheckEqual(game.oneStageFlag, false)2623CheckResult |= TempValue02624#endplatform26252626#platform: Use_Standalone2627// Slight workaround to make this cleaner - the check below this comes from Origins, but we need it to always be true on standalone26282629CheckResult = true2630#endplatform26312632// Again, this check is new to Origins and doesn't exist in Standalone2633if CheckResult != false2634Object.Type = TypeName[Death Event]2635DeathEvent.DrawOrder = 72636DeathEvent.Text1XPos = Screen.CenterX2637DeathEvent.Text1XPos -= 2322638DeathEvent.Text2XPos = Screen.CenterX2639DeathEvent.Text2XPos += 2322640end if26412642if Options.GameMode == MODE_TIMEATTACK2643DeathEvent.Timer = 02644DeathEvent.State = DEATHEVENT_TIMEATTACK2645else2646if Player.Lives == 02647DeathEvent.Timer = -28802648DeathEvent.State = DEATHEVENT_GAMEOVER2649// *Technically it goes to the traditional game over in the same state2650PlayMusic(5)2651Stage.PauseEnabled = false26522653#platform: Use_Origins2654if game.oneStageFlag != false2655game.callbackResult = -1 // Reset any callback result2656game.callbackParam0 = 0 // 0 - Normal Retry, anything else - Show current and best time2657game.callbackParam1 = Stage.ListPos // Get current stage2658game.callbackParam2 = 0 // Unknown2659EngineCallback(NOTIFY_STAGE_RETRY)2660end if2661#endplatform26622663else2664DeathEvent.Timer = 02665DeathEvent.State = DEATHEVENT_FADEOUT26662667#platform: Use_Origins2668// Lots of checks here, before we do anything else26692670if game.coinMode == false2671if game.playMode != BOOT_PLAYMODE_BOSSRUSH2672if Stage.Minutes == 92673if Stage.Seconds == 592674// Check if the player is replaying the stage from My Data & Rankings2675if game.oneStageFlag == false2676DeathEvent.Timer = -28802677DeathEvent.State = DEATHEVENT_TIMEOVER26782679PlayMusic(5)2680Stage.PauseEnabled = false2681end if2682end if2683end if2684end if2685end if2686#endplatform26872688#platform: Use_Standalone2689if Stage.Minutes == 92690if Stage.Seconds == 592691DeathEvent.Timer = -28802692DeathEvent.State = DEATHEVENT_TIMEOVER26932694PlayMusic(5)2695Stage.PauseEnabled = false2696end if2697end if2698#endplatform2699end if2700end if2701end if2702end function27032704// Same as death, just slower and without the bored or time over stuff2705function Player_State_Drown2706Player.ControlMode = CONTROLMODE_NONE2707Player.YVelocity += Player.GravityStrength2708Player.Animation = ANI_DROWNING27092710if Player.YVelocity > 0x800002711#platform: Use_Origins2712EngineCallback(NOTIFY_DEATH_EVENT)27132714// We only subtract lives sometimes in Origins2715if game.coinMode == false2716if game.playMode != BOOT_PLAYMODE_MISSION2717CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)2718TempValue0 = CheckResult2719CheckEqual(game.oneStageFlag, false)2720TempValue0 |= CheckResult2721if TempValue0 != false2722if Player.Lives > 02723Player.Lives--2724end if2725end if2726end if2727end if2728#endplatform27292730#platform: Use_Standalone2731if Player.Lives > 02732Player.Lives--2733end if2734#endplatform27352736Stage.TimeEnabled = false27372738Object.Type = TypeName[DeathEvent]2739DeathEvent.DrawOrder = 72740DeathEvent.Text1XPos = Screen.CenterX2741DeathEvent.Text1XPos -= 2322742DeathEvent.Text2XPos = Screen.CenterX2743DeathEvent.Text2XPos += 23227442745if Options.GameMode == MODE_TIMEATTACK2746DeathEvent.Timer = 02747DeathEvent.State = DEATHEVENT_TIMEATTACK2748else2749if Player.Lives == 02750DeathEvent.Timer = -28802751DeathEvent.State = DEATHEVENT_GAMEOVER27522753PlayMusic(5)2754Stage.PauseEnabled = false2755else2756DeathEvent.Timer = 02757DeathEvent.State = DEATHEVENT_FADEOUT2758end if2759end if2760end if2761end function27622763// Wacky Workbench hanging bar gimmick2764function Player_State_HangBar2765if Player.Left == true2766Player.Direction = FACING_LEFT2767Player.Speed = -0x200002768Player.AnimationSpeed = 302769else2770if Player.Right == true2771Player.Direction = FACING_RIGHT2772Player.Speed = 0x200002773Player.AnimationSpeed = 302774else2775Player.Speed = 02776Player.AnimationSpeed = 02777end if2778end if27792780TempValue1 = Player.XPos2781TempValue1 >>= 1627822783TempValue2 = Player.YPos2784TempValue2 >>= 162785TempValue2 += Player.CollisionTop2786// Check that you are in the hanging bar2787Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)2788if TempValue0 != 3 // seems like you're not27892790#platform: Use_Origins2791Player.State = Player_State_Air_NoDropDash2792#endplatform27932794#platform: Use_Standalone2795Player.State = Player_State_Air2796#endplatform27972798Player.Speed = 02799Player.AnimationSpeed = 02800Player.YVelocity = 02801end if28022803// Manual Drop2804if Player.JumpPress == true28052806Player.State = Player_State_Air2807Player.YVelocity = 02808Player.Speed = 02809Player.AnimationSpeed = 02810Player.YPos += 0x400002811end if2812Player.XVelocity = Player.Speed2813// Cancel warp2814if Warp.Destination > WARPDEST_NONE2815if Warp.Timer > 992816if Warp.Timer < 2042817Warp.Destination = WARPDEST_NONE2818end if2819end if28202821Warp.Timer = 02822end if2823end function28242825// Unused leftover from Sonic Nexus (2008)2826function Player_State_CorkscrewRun2827Player.Angle = 02828CallFunction(Player_HandleGroundMovement)2829Player.Animation = 34 // Corkscrew animation, it uses Nexus values and as such, it just looks like a jumbled mess in-game28302831if Player.Speed < 0x600002832if Player.Speed > -0x600002833Player.Animation = ANI_WALKING28342835#platform: Use_Origins2836Player.State = Player_State_Air_NoDropDash2837#endplatform28382839#platform: Use_Standalone2840Player.State = Player_State_Air2841#endplatform28422843Player.Rotation = 028442845if Player.Speed < 02846Player.Direction = FACING_LEFT2847end if2848end if2849end if28502851if Player.Down == true2852if Player.Speed > 0x199A2853Player.State = Player_State_CorkscrewRoll2854Player.Animation = ANI_JUMPING2855end if28562857if Player.Speed < -0x199A2858Player.State = Player_State_CorkscrewRoll2859Player.Animation = ANI_JUMPING2860end if2861end if28622863if Player.Skidding > 02864if Player.Skidding == 162865PlaySfx(SFX_G_DESTROY, false) // Would be Skidding SFX if using Nexus SFX list2866end if2867Player.Animation = ANI_SKIDDING2868Player.Skidding--2869end if28702871if Player.JumpPress == true2872CallFunction(Player_Action_Jump)2873else2874CallFunction(Player_HandleOnGround)2875end if2876end function28772878// Unused leftover from Sonic Nexus (2008)2879function Player_State_CorkscrewRoll2880Player.Angle = 02881CallFunction(Player_HandleRollDeceleration)28822883if Player.Speed < 0x600002884if Player.Speed > -0x6000028852886#platform: Use_Origins2887Player.State = Player_State_Air_NoDropDash2888#endplatform28892890#platform: Use_Standalone2891Player.State = Player_State_Air2892#endplatform28932894end if2895end if28962897if Player.JumpPress == true2898CallFunction(Player_Action_Jump)2899else2900CallFunction(Player_HandleOnGround)2901end if2902end function29032904// Tube Switch function2905function Player_State_TubeRoll2906#platform: Use_Origins2907Player.DropDashCharge = -12908#endplatform2909if Player.Gravity == GRAVITY_AIR // end the function if you are in the air29102911#platform: Use_Origins2912Player.State = Player_State_Air_NoDropDash2913#endplatform29142915#platform: Use_Standalone2916Player.State = Player_State_Air2917#endplatform29182919Player.Timer = 02920CallFunction(Player_HandleAirMovement)2921else2922if Player.Speed > 02923if Player.Speed < Player.MinRollSpeed2924Player.Speed = Player.MinRollSpeed2925end if29262927if Player.Speed > 0x1000002928Player.Speed = 0x1000002929end if2930else2931TempValue0 = Player.MinRollSpeed2932FlipSign(TempValue0)2933if Player.Speed > TempValue02934Player.Speed = TempValue02935CallFunction(Player_HandleOnGround)2936end if29372938if Player.Speed < -0x1000002939Player.Speed = -0x1000002940end if2941end if29422943TempValue0 = Player.Speed2944if TempValue0 < 02945FlipSign(TempValue0)2946end if29472948if TempValue0 < 0x5F5C22949// Warp Star delete checks2950if Warp.Destination > WARPDEST_NONE2951if Warp.Timer > 992952if Warp.Timer < 2042953Warp.Destination = WARPDEST_NONE2954end if2955end if2956Warp.Timer = 02957end if2958else2959// Warp Star spawnning2960if Warp.Destination > WARPDEST_NONE2961if Warp.Timer == 02962Warp.Timer = 12963CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)2964WarpStar.Timer = 72965WarpStar.DrawOrder = 42966end if2967end if2968end if29692970CallFunction(Player_HandleRollDeceleration)2971CallFunction(Player_HandleRollAnimSpeed)2972Player.AnimationSpeed = Player.RollAnimationSpeed2973CallFunction(Player_HandleOnGround)2974end if2975end function29762977function Player_State_TubeAirRoll2978#platform: Use_Origins2979Player.DropDashCharge = -12980#endplatform2981Player.Right = false2982Player.Left = false2983if Player.Gravity == GRAVITY_AIR29842985#platform: Use_Origins2986Player.State = Player_State_Air_NoDropDash2987#endplatform29882989#platform: Use_Standalone2990Player.State = Player_State_Air2991#endplatform29922993Player.Timer = 02994CallFunction(Player_HandleAirMovement)2995else2996if Player.Speed > 02997Player.Speed = Player.MinRollSpeed2998else2999TempValue0 = Player.MinRollSpeed3000FlipSign(TempValue0)3001Player.Speed = TempValue03002end if30033004TempValue0 = Player.Speed3005if TempValue0 < 03006FlipSign(TempValue0)3007end if30083009if TempValue0 < 0x5F5C23010if Warp.Destination > WARPDEST_NONE3011if Warp.Timer > 993012if Warp.Timer < 2043013Warp.Destination = WARPDEST_NONE3014end if3015end if3016Warp.Timer = 03017end if3018else3019if Warp.Destination > WARPDEST_NONE3020if Warp.Timer == 03021Warp.Timer = 13022CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)3023WarpStar.Timer = 73024WarpStar.DrawOrder = 43025end if3026end if3027end if3028CallFunction(Player_HandleRollDeceleration)3029CallFunction(Player_HandleRollAnimSpeed)3030Player.AnimationSpeed = Player.RollAnimationSpeed3031CallFunction(Player_HandleOnGround)3032end if3033end function30343035// Palmtree Panic and Wacky Workbench spinning tops3036function Player_State_SpinningTop3037Player.Timer += Player.MinRollSpeed3038if Player.Gravity == GRAVITY_AIR // Drop from them if you get out of range30393040#platform: Use_Origins3041Player.State = Player_State_Air_NoDropDash3042#endplatform30433044#platform: Use_Standalone3045Player.State = Player_State_Air3046#endplatform30473048Player.Animation = ANI_WALKING3049Player.Timer = 03050CallFunction(Player_HandleAirMovement)3051else3052CallFunction(Player_HandleOnGround)3053end if3054end function30553056// Amy Rose's favorite function3057function Player_State_Hugged3058if Player.Gravity == GRAVITY_AIR // No hugs if you're in the air30593060#platform: Use_Origins3061Player.State = Player_State_Air_NoDropDash3062#endplatform30633064#platform: Use_Standalone3065Player.State = Player_State_Air3066#endplatform30673068Player.Animation = ANI_WALKING3069Player.Timer = 03070CallFunction(Player_HandleAirMovement)3071else3072CallFunction(Player_HandleOnGround)3073// Yes, the only thing the function does is make you wait3074if Player.Timer < 2403075Player.Animation = ANI_STOPPED3076Player.Timer++3077else3078Player.Animation = ANI_WAITING3079end if30803081// Warp cancel check3082if Warp.Destination > WARPDEST_NONE3083if Warp.Timer > 993084if Warp.Timer < 2043085Warp.Destination = WARPDEST_NONE3086end if3087end if3088Warp.Timer = 03089end if30903091// Get free from Amy3092if Player.JumpPress == true3093CallFunction(Player_Action_Jump)3094end if3095end if3096end function30973098// Palmtree Panic Ramp3099function Player_State_Ramp3D3100CallFunction(Player_HandleGroundMovement)3101if Player.Gravity == GRAVITY_AIR31023103#platform: Use_Origins3104Player.State = Player_State_Air_NoDropDash3105#endplatform31063107#platform: Use_Standalone3108Player.State = Player_State_Air3109#endplatform31103111Player.Timer = 03112CallFunction(Player_HandleAirMovement)3113// Set the equivalent animation for looking to the left3114if Player.Direction == FACING_LEFT31153116if Player.Animation == ANI_RAMP_RUNNING33117Player.Animation = ANI_RAMP_RUNNING53118end if31193120if Player.Animation == ANI_RAMP_RUNNING23121Player.Animation = ANI_RAMP_RUNNING63122end if31233124end if3125else3126#platform: Use_Origins3127if Player.Animation == ANI_GLIDING3128Player.XVelocity = 03129Player.YVelocity = 03130Player.Speed = 03131Player.Animation = ANI_GLIDING_STOP3132end if3133#endplatform3134CallFunction(Player_HandleOnGround)3135if Player.Speed == 03136// Warp Star erase check3137if Warp.Destination > WARPDEST_NONE3138if Warp.Timer > 993139if Warp.Timer < 2043140Warp.Destination = WARPDEST_NONE3141end if3142end if3143Warp.Timer = 03144end if3145// Waiting timer while in the ramp3146if Player.Timer < 2403147Player.Animation = ANI_STOPPED3148Player.Timer++3149else3150Player.Animation = ANI_WAITING3151end if3152else3153// Set animation based on angle3154if Player.Angle == 03155Player.Animation = ANI_RAMP_RUNNING13156end if31573158if Player.Angle > 2003159if Player.Direction == FACING_RIGHT3160Player.Animation = ANI_RAMP_RUNNING33161else3162Player.Animation = ANI_RAMP_RUNNING53163end if3164end if31653166if Player.Angle > 2163167if Player.Direction == FACING_RIGHT3168Player.Animation = ANI_RAMP_RUNNING23169else3170Player.Animation = ANI_RAMP_RUNNING63171end if3172end if31733174if Player.Angle > 2323175Player.Animation = ANI_RAMP_RUNNING13176end if31773178if Player.Angle == 1923179Player.Animation = ANI_RAMP_RUNNING43180end if3181end if31823183if Player.JumpPress == true3184CallFunction(Player_Action_Jump)3185else3186if Player.Up == true3187if Player.Speed == 03188Player.State = Player_State_LookUp3189Player.Animation = ANI_LOOKINGUP3190Player.Timer = 03191end if3192end if3193if Player.Down == true3194if Player.Speed == 03195Player.State = Player_State_Crouch3196Player.Animation = ANI_LOOKINGDOWN3197Player.Timer = 03198else3199if Player.Speed > 0x199A3200Player.ControlLock = 03201Player.State = Player_State_Roll3202Player.Animation = ANI_JUMPING3203end if32043205if Player.Speed < -0x199A3206Player.ControlLock = 03207Player.State = Player_State_Roll3208Player.Animation = ANI_JUMPING3209end if3210end if3211end if3212end if3213end if32143215if Player.Animation != ANI_STOPPED3216Player.AnimationSpeed = Player.Speed3217if Player.AnimationSpeed < 03218FlipSign(Player.AnimationSpeed)3219end if3220Player.AnimationSpeed *= 603221Player.AnimationSpeed /= 0x600003222Player.AnimationSpeed += 203223else3224Player.AnimationSpeed = 03225end if3226end function322732283229function Player_State_WaterCurrent3230Player.Gravity = GRAVITY_AIR32313232if Player.Up == true3233Player.YPos -= 0x200003234end if32353236if Player.Down == true3237Player.YPos += 0x200003238end if32393240if Player.Left == true3241Player.XPos -= 0x200003242end if32433244if Player.Right == true3245Player.XPos += 0x200003246end if3247end function32483249function Player_SetJumpOffset3250#platform: Use_Origins3251if Mini_PlayerFlag == true3252Player.JumpOffset = -13253else3254if Stage.PlayerListPos == PLAYER_SONIC3255Player.JumpOffset = -53256end if32573258if Stage.PlayerListPos == PLAYER_TAILS3259Player.JumpOffset = -13260end if32613262if Stage.PlayerListPos == PLAYER_KNUCKLES3263Player.JumpOffset = -53264end if32653266if Stage.PlayerListPos == PLAYER_AMY3267Player.JumpOffset = -43268end if3269end if3270#endplatform3271end function32723273function Player_State_SizeChange3274Player.TileCollisions = true3275if Player.Gravity == GRAVITY_AIR // Knockback after touching the laser3276Player.TrackScroll = true3277Player.YVelocity += 0x30003278Player.XVelocity = Player.Speed3279else3280Player.State = Player_State_Ground32813282Player.InvincibleTimer = 1203283Player.BlinkTimer = 332843285Player.Speed = 03286Player.XVelocity = 032873288CallFunction(Player_HandleOnGround)3289if Mini_PlayerFlag == false3290Mini_PlayerFlag = true32913292#platform: Use_Standalone3293Player.JumpOffset = -13294switch Stage.PlayerListPos3295case PLAYER_SONIC_A3296LoadAnimation("MiniSonic.Ani")3297break32983299case PLAYER_TAILS_A3300LoadAnimation("MiniTails.Ani")3301Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites3302break3303end switch3304#endplatform33053306#platform: Use_Origins3307switch Stage.PlayerListPos3308case PLAYER_SONIC_A3309LoadAnimation("MiniSonic.Ani")3310break33113312case PLAYER_TAILS_A3313LoadAnimation("MiniTails.Ani")3314Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites3315break33163317case PLAYER_KNUCKLES_A3318LoadAnimation("MiniKnuckles.Ani")3319Object[1].Type = TypeName[Blank Object] // Mini Knuckles... doesn't have tails, but set the object to blank anyway, I guess3320break33213322case PLAYER_AMY_A3323LoadAnimation("MiniAmy.Ani")3324Object[1].Type = TypeName[Blank Object] // Mini Amy... doesn't have tails, but set the object to blank anyway, I guess3325break3326end switch3327#endplatform3328else3329Mini_PlayerFlag = false33303331#platform: Use_Standalone3332switch Stage.PlayerListPos3333case PLAYER_SONIC_A3334LoadAnimation("Sonic.Ani")3335Player.JumpOffset = -53336break33373338case PLAYER_TAILS_A3339LoadAnimation("Tails.Ani")3340Player.JumpOffset = -13341Object[1].Type = TypeName[Tails Object] // Restore Tails's tails3342break3343end switch3344#endplatform33453346#platform: Use_Origins3347if Stage.PlayerListPos == PLAYER_SONIC3348LoadAnimation("Sonic.Ani")3349end if33503351if Stage.PlayerListPos == PLAYER_TAILS3352LoadAnimation("Tails.Ani")3353Object[1].Type = TypeName[Tails Object] // Restore Tails's tails3354end if33553356if Stage.PlayerListPos == PLAYER_KNUCKLES3357LoadAnimation("Knuckles.Ani")3358end if33593360if Stage.PlayerListPos == PLAYER_AMY3361LoadAnimation("Amy.Ani")3362end if3363#endplatform3364end if33653366#platform: Use_Origins3367CallFunction(Player_SetJumpOffset)3368#endplatform33693370BindPlayerToObject(0, 0)3371end if3372end function337333743375function Player_HandleDropDash3376#platform: Use_Origins3377if Player.DropDashCharge >= 03378if Player.DropDashCharge == 03379if Player.JumpPress == true3380if Stage.PlayerListPos == PLAYER_SONIC3381Player.DropDashCharge = 13382else3383if Stage.PlayerListPos == PLAYER_AMY3384Player.DropDashCharge = 13385else3386Player.DropDashCharge = -13387end if3388end if3389end if3390else3391if Player.JumpHold == false3392if Stage.PlayerListPos == PLAYER_TAILS3393Player.DropDashCharge = -13394else3395if Player.DropDashCharge >= 203396Player.DropDashCharge = -13397end if3398end if3399else3400Player.DropDashCharge++3401if Player.DropDashCharge == 203402PlaySfx(SFX_G_DROPDASH, false)3403end if34043405if Player.DropDashCharge >= 203406if Player.Animation == ANI_JUMPING3407Player.Frame = 03408Player.AnimationTimer = 03409Player.AnimationSpeed = 13410end if3411end if3412end if3413end if3414end if3415#endplatform3416end function34173418function Player_Action_DblJumpKnux3419#platform: Use_Origins3420if Player.YVelocity >= Player.JumpCap3421if Player.JumpPress == true3422game.callbackParam0 = 13423game.callbackParam1 = 03424game.callbackParam2 = 03425EngineCallback(NOTIFY_STATS_CHARA_ACTION2)3426Player.Speed = 0x400003427if Player.YVelocity < 03428Player.YVelocity = 03429end if3430if Player.Direction == FACING_RIGHT3431Player.State = Player_State_GlideRight3432Player.XVelocity = 0x400003433Player.Timer = 03434else3435Player.State = Player_State_GlideLeft3436Player.XVelocity = -0x400003437Player.Timer = 2563438end if3439Player.Animation = ANI_GLIDING3440Player.Frame = 23441Object.Frame = 23442end if3443end if3444#endplatform3445end function344634473448function Player_State_GlideLeft3449#platform: Use_Origins3450if Player.Speed == 03451if Warp.Destination > 03452if Warp.Timer > 993453if Warp.Timer < 2043454Warp.Destination = 03455end if3456end if3457Warp.Timer = 03458end if3459end if34603461if Player.Gravity == GRAVITY_AIR3462if Player.JumpHold == true3463if Player.Timer == 2563464if Player.Speed < 0x1800003465Player.Speed += 0x4003466end if3467else3468if Player.Speed < 0x400003469Player.Speed += 0x10003470end if3471end if34723473if Player.YVelocity > 0x80003474Player.YVelocity -= 0x20003475else3476Player.YVelocity += 0x20003477end if34783479if Player.Timer < 2563480Player.Timer += 43481end if34823483if Player.Timer < 1703484if Player.Timer > 863485Player.Frame = 03486else3487if Player.Timer > 443488Player.Frame = 13489else3490Player.Frame = 23491end if3492end if3493else3494if Player.Timer < 2123495Player.Frame = 13496else3497Player.Frame = 23498end if3499end if35003501TempValue7 = Player.XPos3502if Player.Timer < 1283503Player.Direction = FACING_RIGHT3504TempValue0 = false3505TempValue1 = false3506else3507Player.Direction = FACING_LEFT3508Player.XPos = TempValue73509Player.XPos += Player.XVelocity3510Player.YPos = Player.YPos3511Object.XPos = Player.XPos3512Object.YPos = Player.YPos3513ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)3514Player.XPos = Object.XPos3515TempValue0 = CheckResult3516TempValue2 = Player.XPos3517Player.XPos = TempValue73518Player.XPos += Player.XVelocity3519Object.XPos = Player.XPos3520Object.YPos = Player.YPos3521ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)3522Player.XPos = Object.XPos3523TempValue1 = CheckResult3524TempValue3 = Player.XPos3525end if35263527Cos(Player.XVelocity, Player.Timer)3528Player.XVelocity *= Player.Speed3529Player.XVelocity >>= 93530if Player.Right == true3531Player.State = Player_State_GlideRight35323533if Warp.Destination > 03534if Warp.Timer > 993535if Warp.Timer < 2043536Warp.Destination = 03537end if3538end if3539Warp.Timer = 03540end if3541end if35423543Player.XPos = TempValue73544CheckResult = TempValue03545CheckResult &= TempValue13546if CheckResult == true3547if TempValue2 == TempValue33548if Player.XVelocity > 03549Player.Direction = FACING_RIGHT3550end if3551Player.State = Player_State_Climb3552Player.Speed = 03553Player.XVelocity = 03554Player.YVelocity = 03555Player.Timer = 03556PlaySfx(SFX_G_GRAB, false)3557game.callbackParam0 = 23558game.callbackParam1 = 03559game.callbackParam2 = 03560EngineCallback(NOTIFY_STATS_CHARA_ACTION2)3561if Warp.Destination > 03562if Warp.Timer > 993563if Warp.Timer < 2043564Warp.Destination = 03565end if3566end if3567Warp.Timer = 03568end if3569else3570Player.XVelocity >>= 23571Player.Speed = Player.XVelocity3572CallFunction(Player_Action_GlideDrop)3573end if3574else3575if TempValue0 == true3576if TempValue1 == false3577ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)3578end if35793580if CheckResult == false3581Player.XVelocity >>= 23582Player.Speed = Player.XVelocity3583CallFunction(Player_Action_GlideDrop)3584end if3585end if3586end if3587else3588Player.XVelocity >>= 23589Player.Speed = Player.XVelocity3590CallFunction(Player_Action_GlideDrop)3591end if3592else3593if Player.CollisionMode == CMODE_FLOOR3594Player.Timer = 03595Player.State = Player_State_GlideSlide3596Player.Animation = ANI_GLIDING_STOP3597Player.Speed = Player.XVelocity3598else3599Player.State = Player_State_Ground3600CallFunction(Player_HandleOnGround)3601Player.Skidding = 03602end if3603end if36043605CallFunction(Player_CheckRoofGlide)3606#endplatform3607end function360836093610function Player_State_GlideRight3611#platform: Use_Origins3612if Player.Speed == 03613if Warp.Destination > 03614if Warp.Timer > 993615if Warp.Timer < 2043616Warp.Destination = 03617end if3618end if3619Warp.Timer = 03620end if3621end if36223623if Player.Gravity == GRAVITY_AIR3624if Player.JumpHold == true3625if Player.Timer == 03626if Player.Speed < 0x1800003627Player.Speed += 0x4003628end if3629else3630if Player.Speed < 0x400003631Player.Speed += 0x10003632end if3633end if36343635if Player.YVelocity > 0x80003636Player.YVelocity -= 0x20003637else3638Player.YVelocity += 0x20003639end if36403641if Player.Timer > 03642Player.Timer -= 43643end if36443645if Player.Timer < 1703646if Player.Timer > 863647Player.Frame = 03648else3649if Player.Timer > 443650Player.Frame = 13651else3652Player.Frame = 23653end if3654end if3655else3656if Player.Timer < 2123657Player.Frame = 13658else3659Player.Frame = 23660end if3661end if36623663TempValue7 = Player.XPos3664if Player.Timer < 1283665Player.Direction = FACING_RIGHT3666Player.XPos = TempValue73667Player.XPos += Player.XVelocity3668Player.YPos = Player.YPos3669Object.XPos = Player.XPos3670Object.YPos = Player.YPos3671ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)3672Player.XPos = Object.XPos3673TempValue0 = CheckResult3674TempValue2 = Player.XPos3675Player.XPos = TempValue73676Player.XPos += Player.XVelocity3677Object.XPos = Player.XPos3678Object.YPos = Player.YPos3679ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)3680Player.XPos = Object.XPos3681TempValue1 = CheckResult3682TempValue3 = Player.XPos3683else3684Player.Direction = FACING_LEFT3685TempValue0 = false3686TempValue1 = false3687end if36883689Cos(Player.XVelocity, Player.Timer)3690Player.XVelocity *= Player.Speed3691Player.XVelocity >>= 93692if Player.Left == true3693Player.State = Player_State_GlideLeft36943695if Warp.Destination > 03696if Warp.Timer > 993697if Warp.Timer < 2043698Warp.Destination = 03699end if3700end if3701Warp.Timer = 03702end if3703end if37043705Player.XPos = TempValue73706CheckResult = TempValue03707CheckResult &= TempValue13708if CheckResult == true3709TempValue2 >>= 13710TempValue3 >>= 13711if TempValue2 == TempValue33712if Player.XVelocity < 03713Player.Direction = FACING_LEFT3714end if3715Player.State = Player_State_Climb3716Player.Speed = 03717Player.XVelocity = 03718Player.YVelocity = 03719Player.Timer = 03720PlaySfx(SFX_G_GRAB, false)3721game.callbackParam0 = 23722game.callbackParam1 = 03723game.callbackParam2 = 03724EngineCallback(NOTIFY_STATS_CHARA_ACTION2)3725if Warp.Destination > 03726if Warp.Timer > 993727if Warp.Timer < 2043728Warp.Destination = 03729end if3730end if3731Warp.Timer = 03732end if3733else3734Player.XVelocity >>= 23735Player.Speed = Player.XVelocity3736CallFunction(Player_Action_GlideDrop)3737end if3738else3739if TempValue0 == true3740if TempValue1 == false3741ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)3742end if37433744if CheckResult == false3745Player.Speed = 03746Player.XVelocity >>= 23747Player.Speed = Player.XVelocity3748CallFunction(Player_Action_GlideDrop)3749end if3750end if3751end if3752else3753Player.XVelocity >>= 23754Player.Speed = Player.XVelocity3755CallFunction(Player_Action_GlideDrop)3756end if3757else3758if Player.CollisionMode == CMODE_FLOOR3759Player.Timer = 03760Player.State = Player_State_GlideSlide3761Player.Animation = ANI_GLIDING_STOP3762Player.Speed = Player.XVelocity3763else3764Player.State = Player_State_Ground3765CallFunction(Player_HandleOnGround)3766Player.Skidding = 03767end if3768end if37693770CallFunction(Player_CheckRoofGlide)3771#endplatform3772end function377337743775function Player_State_GlideDrop3776#platform: Use_Origins3777if Player.Gravity == GRAVITY_AIR3778CallFunction(Player_HandleAirFriction)3779CallFunction(Player_HandleAirMovement)3780else3781if Player.JumpPress == true3782Player.XVelocity = 03783Player.Speed = 03784if Player.Down == true3785CallFunction(Player.ActionSpindash)3786else3787CallFunction(Player_Action_Jump)3788end if3789else3790if Player.AbilityTimer == 03791PlaySfx(SFX_G_GLIDEDROPLAND, false)3792end if37933794Player.TrackScroll = false3795Player.Speed = 03796Player.XVelocity = 03797Player.Animation = ANI_LOOKINGDOWN3798Player.PrevAnimation = ANI_LOOKINGDOWN3799Player.Frame = 238003801if Player.AbilityTimer < 163802Player.AbilityTimer++3803else3804Player.AbilityTimer = 03805Player.State = Player_State_Ground3806CallFunction(Player_HandleOnGround)3807Player.Skidding = 03808if Warp.Destination > 03809if Warp.Timer > 993810if Warp.Timer < 2043811Warp.Destination = 03812end if3813end if3814Warp.Timer = 03815end if3816end if3817end if3818end if3819#endplatform3820end function382138223823function Player_State_GlideSlide3824#platform: Use_Origins3825if Player.Gravity == GRAVITY_GROUND3826if Player.Speed == 03827if Player.JumpPress == true3828if Player.Down == true3829CallFunction(Player.ActionSpindash)3830else3831CallFunction(Player_Action_Jump)3832end if3833else3834Player.TrackScroll = false3835Player.Frame = 13836if Player.Timer < 163837Player.Timer++3838else3839Player.State = Player_State_Ground3840CallFunction(Player_HandleOnGround)3841Player.Skidding = 03842end if3843end if3844else3845Player.Timer++3846TempValue0 = Player.Timer3847TempValue0 %= 43848if TempValue0 == 03849CreateTempObject(TypeName[Dust Puff], 0, Player.XPos, Player.YPos)3850Object[TempObjectPos].iYPos += Player.CollisionBottom3851Object[TempObjectPos].DrawOrder = Player.DrawOrder3852end if38533854Player.Timer %= 83855if Player.Timer == 03856PlaySfx(SFX_G_SLIDE, false)3857end if38583859Player.Frame = 03860if Player.Speed > 03861Player.Speed -= 0x20003862if Player.Speed < 03863Player.Speed = 03864Player.Timer = 03865end if3866else3867Player.Speed += 0x20003868if Player.Speed > 03869Player.Speed = 03870Player.Timer = 03871end if3872end if3873if Player.JumpHold == 03874Player.Speed = 03875Player.Timer = 03876end if3877end if38783879Player.XVelocity = Player.Speed3880else3881CallFunction(Player_Action_GlideDrop)3882end if3883#endplatform3884end function388538863887function Player_State_Climb3888#platform: Use_Origins3889if Player.Gravity == GRAVITY_AIR3890Player.Animation = ANI_CLIMBING3891if Player.Up == true3892Player.YVelocity = -0x100003893TempValue0 = Player.CollisionTop3894TempValue0 *= -0x100003895if Player.YPos < TempValue03896Player.YPos = TempValue03897end if38983899Player.Timer++3900if Player.Timer == 43901Player.Timer = 03902Player.Frame++3903if Mini_PlayerFlag == true3904Player.Frame %= 23905else3906Player.Frame %= 63907end if3908end if3909else3910if Player.Down == true3911Player.YVelocity = 0x100003912Player.Timer++3913if Player.Timer == 43914Player.Timer = 03915if Player.Frame < 13916if Mini_PlayerFlag == true3917Player.Frame += 23918else3919Player.Frame += 63920end if3921end if3922Player.Frame--3923end if3924else3925Player.YVelocity = 03926end if3927end if39283929if Player.JumpPress == true3930Player.Animation = ANI_JUMPING3931Player.State = Player_State_Air_NoDropDash3932Player.Timer = 03933if Player.Direction == FACING_LEFT3934Player.XVelocity = 0x400003935Player.Speed = 0x400003936Player.Direction = FACING_RIGHT3937else3938Player.XVelocity = -0x400003939Player.Speed = -0x400003940Player.Direction = FACING_LEFT3941end if39423943Player.YVelocity = -0x400003944if Player.GravityStrength != 0x3800 // (see if Knuckles is underwater)3945Player.XVelocity >>= 13946Player.Speed >>= 13947Player.YVelocity >>= 13948end if3949else3950if Mini_PlayerFlag == true3951TempValue4 = 73952TempValue5 = -63953else3954TempValue4 = 103955TempValue5 = -103956end if39573958if Player.Direction == FACING_RIGHT3959TempValue2 = Player.XPos3960Object.XPos = Player.XPos3961Object.YPos = Player.YPos3962ObjectTileGrip(CSIDE_LWALL, TempValue4, TempValue5, Player.CollisionPlane)3963TempValue0 = CheckResult3964if TempValue0 == 03965Player.XPos = TempValue23966Object.XPos = Player.XPos3967ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)3968ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, true, ECEFFECT_NONE)3969TempValue0 = CheckResult3970end if3971Player.XPos = Object.XPos3972TempValue3 = Player.XPos3973Player.XPos = TempValue23974Object.XPos = Player.XPos3975Object.YPos = Player.YPos3976ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)3977Player.XPos = Object.XPos3978TempValue1 = CheckResult3979if TempValue1 == 03980ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)3981TempValue1 = CheckResult3982end if3983if Player.XPos > TempValue33984Player.XPos = TempValue33985end if3986ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_RESETSTORAGE)3987else3988if Mini_PlayerFlag == true3989TempValue4 = -73990else3991TempValue4 = -103992end if39933994TempValue2 = Player.XPos3995Object.XPos = Player.XPos3996Object.YPos = Player.YPos3997ObjectTileGrip(CSIDE_RWALL, TempValue4, TempValue5, Player.CollisionPlane)3998TempValue0 = CheckResult3999if TempValue0 == 04000Player.XPos = TempValue24001Object.XPos = Player.XPos4002ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)4003ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, true, ECEFFECT_NONE)4004TempValue0 = CheckResult4005end if4006Player.XPos = Object.XPos4007TempValue3 = Player.XPos4008Player.XPos = TempValue24009Object.XPos = Player.XPos4010Object.YPos = Player.YPos4011ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)4012Player.XPos = Object.XPos4013TempValue1 = CheckResult4014if TempValue1 == 04015ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)4016TempValue1 = CheckResult4017end if4018if Player.XPos < TempValue34019Player.XPos = TempValue34020end if4021ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_RESETSTORAGE)4022end if4023if TempValue0 == 04024if Player.YVelocity < 04025Player.XPos = TempValue24026Player.Animation = ANI_LEDGEPULLUP4027Player.YVelocity = 04028Player.Timer = 04029Player.State = Player_State_LedgePullUp4030Player.TileCollisions = false4031if Player.Direction == FACING_RIGHT4032Player.XPos += 0x100004033end if4034end if4035else4036if TempValue1 == 04037Player.PrevAnimation = ANI_GLIDING_DROP4038Player.Frame = 24039CallFunction(Player_Action_GlideDrop)4040end if4041end if4042end if4043else4044Player.Animation = ANI_WALKING4045Player.State = Player_State_Ground4046CallFunction(Player_HandleOnGround)4047end if4048#endplatform4049end function405040514052function Player_State_LedgePullUp4053#platform: Use_Origins4054switch Player.Frame4055case 04056if Player.Timer < 54057ObjectTileGrip(CSIDE_FLOOR, 12, -9, Player.CollisionPlane)4058Player.Timer++4059else4060Player.Timer = 04061Player.Frame++4062if Player.Direction == FACING_RIGHT4063Player.XPos += 0x900004064else4065Player.XPos -= 0x900004066end if4067Player.YPos -= 0xA00004068end if4069break40704071case 14072if Player.Timer < 54073Player.Timer++4074else4075Player.Timer = 04076Player.Frame++4077if Player.Direction == FACING_RIGHT4078Player.XPos += 0x500004079else4080Player.XPos -= 0x500004081end if4082end if4083break40844085case 24086if Player.Timer < 54087Player.Timer++4088else4089Player.Timer = 04090Player.Animation = ANI_STOPPED4091Player.State = Player_State_Air_NoDropDash4092Player.YPos -= 0x800004093Player.TileCollisions = true4094end if4095break40964097end switch4098#endplatform4099end function410041014102function Player_State_GlideLeftNoGrip4103#platform: Use_Origins4104if Player.Gravity == GRAVITY_AIR4105if Player.JumpHold == true4106if Player.Timer == 2564107if Player.Speed < 0x1800004108Player.Speed += 0x4004109end if4110else4111if Player.Speed < 0x400004112Player.Speed += 0x10004113end if4114end if41154116if Player.YVelocity > 0x80004117Player.YVelocity -= 0x20004118else4119Player.YVelocity += 0x20004120end if41214122if Player.Timer < 2564123Player.Timer += 44124end if41254126if Player.Timer < 1704127if Player.Timer > 864128Player.Frame = 04129else4130if Player.Timer > 444131Player.Frame = 14132else4133Player.Frame = 24134end if4135end if4136else4137if Player.Timer < 2124138Player.Frame = 14139else4140Player.Frame = 24141end if4142end if41434144TempValue7 = Player.XPos4145if Player.Timer < 1284146Player.Direction = FACING_RIGHT4147TempValue0 = false4148TempValue1 = false4149else4150Player.Direction = FACING_LEFT4151Player.XPos = TempValue74152Player.XPos += Player.XVelocity4153Player.YPos = Player.YPos4154Object.XPos = Player.XPos4155Object.YPos = Player.YPos4156ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)4157Player.XPos = Object.XPos4158TempValue0 = CheckResult4159TempValue2 = Player.XPos4160Player.XPos = TempValue74161Player.XPos += Player.XVelocity4162Object.XPos = Player.XPos4163Object.YPos = Player.YPos4164ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)4165Player.XPos = Object.XPos4166TempValue1 = CheckResult4167TempValue3 = Player.XPos4168end if41694170Cos(Player.XVelocity, Player.Timer)4171Player.XVelocity *= Player.Speed4172Player.XVelocity >>= 94173if Player.Right == true4174Player.State = Player_State_GlideRightNoGrip4175end if41764177Player.XPos = TempValue74178CheckResult = TempValue04179CheckResult &= TempValue14180if CheckResult == true4181TempValue0 = false4182ArrayPos0 = 324183while ArrayPos0 < 10564184CheckEqual(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...4185if CheckResult == true4186if Object[ArrayPos0].Value0 == true4187TempValue0 = true4188end if4189end if4190ArrayPos0++4191loop41924193if TempValue0 == false4194if TempValue2 == TempValue34195else4196Player.XVelocity >>= 24197Player.Speed = Player.XVelocity4198CallFunction(Player_Action_GlideDrop)4199end if4200end if4201end if4202else4203Player.XVelocity >>= 24204Player.Speed = Player.XVelocity4205CallFunction(Player_Action_GlideDrop)4206end if4207else4208if Player.CollisionMode == CMODE_FLOOR4209Player.Timer = 04210Player.State = Player_State_GlideSlide4211Player.Animation = ANI_GLIDING_STOP4212Player.Speed = Player.XVelocity4213else4214Player.State = Player_State_Ground4215CallFunction(Player_HandleOnGround)4216Player.Skidding = 04217end if4218end if42194220CallFunction(Player_CheckRoofGlide)4221#endplatform4222end function422342244225function Player_State_GlideRightNoGrip4226#platform: Use_Origins4227if Player.Gravity == GRAVITY_AIR4228if Player.JumpHold == true4229if Player.Timer == 04230if Player.Speed < 0x1800004231Player.Speed += 0x4004232end if4233else4234if Player.Speed < 0x400004235Player.Speed += 0x10004236end if4237end if42384239if Player.YVelocity > 0x80004240Player.YVelocity -= 0x20004241else4242Player.YVelocity += 0x20004243end if42444245if Player.Timer > 04246Player.Timer -= 44247end if42484249if Player.Timer < 1704250if Player.Timer > 864251Player.Frame = 04252else4253if Player.Timer > 444254Player.Frame = 14255else4256Player.Frame = 24257end if4258end if4259else4260if Player.Timer < 2124261Player.Frame = 14262else4263Player.Frame = 24264end if4265end if42664267TempValue7 = Player.XPos4268if Player.Timer < 1284269Player.Direction = FACING_RIGHT4270Player.XPos = TempValue74271Player.XPos += Player.XVelocity4272Player.YPos = Player.YPos4273Object.XPos = Player.XPos4274Object.YPos = Player.YPos4275ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)4276Player.XPos = Object.XPos4277TempValue0 = CheckResult4278TempValue2 = Player.XPos4279Player.XPos = TempValue74280Player.XPos += Player.XVelocity4281Object.XPos = Player.XPos4282Object.YPos = Player.YPos4283ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)4284Player.XPos = Object.XPos4285TempValue1 = CheckResult4286TempValue3 = Player.XPos4287else4288Player.Direction = FACING_LEFT4289TempValue0 = false4290TempValue1 = false4291end if42924293Cos(Player.XVelocity, Player.Timer)4294Player.XVelocity *= Player.Speed4295Player.XVelocity >>= 94296if Player.Left == true4297Player.State = Player_State_GlideLeftNoGrip4298end if42994300Player.XPos = TempValue74301CheckResult = TempValue04302CheckResult &= TempValue14303if CheckResult == true4304TempValue2 >>= 14305TempValue3 >>= 14306if TempValue2 == TempValue34307else4308Player.XVelocity >>= 24309Player.Speed = Player.XVelocity4310CallFunction(Player_Action_GlideDrop)4311end if4312end if4313else4314Player.XVelocity >>= 24315Player.Speed = Player.XVelocity4316CallFunction(Player_Action_GlideDrop)4317end if4318else4319if Player.CollisionMode == CMODE_FLOOR4320Player.Timer = 04321Player.State = Player_State_GlideSlide4322Player.Animation = ANI_GLIDING_STOP4323Player.Speed = Player.XVelocity4324else4325Player.State = Player_State_Ground4326CallFunction(Player_HandleOnGround)4327Player.Skidding = 04328end if4329end if43304331CallFunction(Player_CheckRoofGlide)4332#endplatform4333end function433443354336function Player_CheckRoofGlide4337#platform: Use_Origins4338// This function's just here to make sure that Knuckles doesn't go above the stage in MMZ3 (not a good thing)4339if Stage.ActiveList == REGULAR_STAGE4340CheckEqual(Stage.ListPos, 68) // MMZ3C4341TempValue0 = CheckResult4342CheckEqual(Stage.ListPos, 69) // MMZ3D4343TempValue0 |= CheckResult4344if TempValue0 != false4345if Stage.PlayerListPos == PLAYER_KNUCKLES // a bit redundant, this func is only called in glide functions anyways..4346if Player.RoofBarrier == true4347TempValue0 = Player.YPos4348TempValue0 >>= 164349if TempValue0 < Player.CollisionBottom4350Player.YPos = Player.CollisionBottom4351Player.YPos <<= 164352end if4353end if4354end if4355end if4356end if4357#endplatform4358end function435943604361function Player_Action_GlideDrop4362#platform: Use_Origins4363// Bug Details:4364// Player.Timer should probably be cleared here, but it isn't4365// 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 immediately43664367Player.Animation = ANI_GLIDING_DROP4368Player.AbilityTimer = 04369Player.State = Player_State_GlideDrop4370#endplatform4371end function437243734374function Player_Action_DblJumpAmy4375#platform: Use_Origins4376if Player.JumpPress == true4377PlaySfx(SFX_G_HAMMERJUMP, false)4378game.callbackParam0 = 04379game.callbackParam1 = 14380game.callbackParam2 = 04381EngineCallback(NOTIFY_STATS_CHARA_ACTION2)4382TempValue0 = Player.AnimationSpeed4383TempValue1 = Player.Frame4384Player.Animation = ANI_HAMMER_JUMP4385ProcessAnimation()4386Player.AnimationSpeed = TempValue04387Player.Frame = TempValue14388end if4389#endplatform4390end function439143924393function Player_Action_HammerDash4394#platform: Use_Origins4395PlaySfx(SFX_G_HAMMERDASH, false)4396Player.State = Player_State_HammerDash4397Player.Animation = ANI_HAMMER_DASH4398Player.Timer = 04399Player.DropDashCharge = -14400CallFunction(Player_SetHammerDashSpeed)4401#endplatform4402end function440344044405function Player_State_HammerDash4406#platform: Use_Origins4407if Player.Right == true4408Player.Direction = FACING_RIGHT4409else4410if Player.Left == true4411Player.Direction = FACING_LEFT4412end if4413end if44144415TempValue0 = true44164417if Player.Speed != 04418Player.Timer++4419if Player.JumpHold == true4420if Player.Timer < 604421CallFunction(Player_SetHammerDashSpeed)4422if Player.Gravity == GRAVITY_AIR4423CallFunction(Player_HandleAirMovement)4424else4425CallFunction(Player_HandleOnGround)4426end if4427TempValue0 = false4428end if4429end if4430end if44314432// If Amy is on a steep enough slope, cancel the move4433// (Despite the patch notes for version 2.0.1 claiming this was removed, it's very much still here)4434Cos256(TempValue1, Player.Angle)4435if TempValue1 <= 04436TempValue0 = true4437end if44384439if TempValue0 == true4440Player.State = Player_State_Ground4441end if4442#endplatform4443end function444444454446function Player_SetHammerDashSpeed4447#platform: Use_Origins4448if Player.Direction == FACING_RIGHT4449Player.Speed = 0x600004450else4451// Could they not have just set it to -0x60000?4452Player.Speed = 04453Player.Speed -= 0x600004454end if4455#endplatform4456end function445744584459function Player_Setup_Startup4460#platform: Use_Origins4461ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)44624463Player.XPos = Object[ArrayPos0].XPos4464Player.YPos = Object[ArrayPos0].YPos44654466if Mini_PlayerFlag == false4467if Stage.PlayerListPos == PLAYER_SONIC4468LoadAnimation("Sonic.Ani")4469end if44704471if Stage.PlayerListPos == PLAYER_TAILS4472LoadAnimation("Tails.Ani")4473end if44744475if Stage.PlayerListPos == PLAYER_KNUCKLES4476LoadAnimation("Knuckles.Ani")4477end if44784479if Stage.PlayerListPos == PLAYER_AMY4480LoadAnimation("Amy.Ani")4481end if4482else4483if Stage.PlayerListPos == PLAYER_SONIC4484LoadAnimation("MiniSonic.Ani")4485end if44864487if Stage.PlayerListPos == PLAYER_TAILS4488LoadAnimation("MiniTails.Ani")4489Object[1].Type = TypeName[Blank Object]4490end if44914492// it's not like Knuckles or Amy have any tails to worry about...4493if Stage.PlayerListPos == PLAYER_KNUCKLES4494LoadAnimation("MiniKnuckles.Ani")4495Object[1].Type = TypeName[Blank Object]4496end if44974498if Stage.PlayerListPos == PLAYER_AMY4499LoadAnimation("MiniAmy.Ani")4500Object[1].Type = TypeName[Blank Object]4501end if4502end if45034504BindPlayerToObject(0, 0)45054506Player.State = Player_State_Air_NoDropDash4507Player.Priority = PRIORITY_ACTIVE4508Player.DrawOrder = 445094510Player.TopSpeed = 0x600004511Player.Acceleration = 0xC004512Player.Deceleration = 0xC004513Player.AirAcceleration = 0x18004514Player.AirDeceleration = 0x6004515Player.GravityStrength = 0x38004516Player.JumpStrength = 0x680004517Player.JumpCap = -0x400004518Player.RollingDeceleration = 0x200045194520if Stage.PlayerListPos == PLAYER_SONIC4521Player.JumpAbility = Player_State_Static4522if Options.OriginalControls == false4523Player.ActionPeelout = Player_Action_Peelout_S24524Player.ActionSpindash = Player_Action_Spindash_S24525else4526Player.ActionPeelout = Player_Action_Peelout_CD4527Player.ActionSpindash = Player_Action_Spindash_CD4528end if4529end if45304531if Stage.PlayerListPos == PLAYER_TAILS4532Player.JumpAbility = Player_Action_DblJumpTails4533Player.ActionPeelout = Player_Action_Jump4534if Options.OriginalControls == false4535Player.ActionSpindash = Player_Action_Spindash_S24536else4537Player.ActionSpindash = Player_Action_Spindash_CD4538end if4539end if45404541if Stage.PlayerListPos == PLAYER_KNUCKLES4542Player.JumpStrength = 0x600004543Player.JumpAbility = Player_Action_DblJumpKnux4544Player.ActionPeelout = Player_Action_Jump4545if Options.OriginalControls == false4546Player.ActionSpindash = Player_Action_Spindash_S24547else4548Player.ActionSpindash = Player_Action_Spindash_CD4549end if4550end if45514552if Stage.PlayerListPos == PLAYER_AMY4553Player.JumpAbility = Player_Action_DblJumpAmy4554Player.ActionPeelout = Player_Action_Jump4555if Options.OriginalControls == false4556Player.ActionSpindash = Player_Action_Spindash_S24557else4558Player.ActionSpindash = Player_Action_Spindash_CD4559end if4560end if45614562CallFunction(Player_SetJumpOffset)45634564GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")4565GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")4566GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")4567GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")4568GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")4569GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")4570GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")4571GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")4572GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")4573ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)4574#endplatform4575end function45764577sub ObjectMain4578// Only PC had access to debug mode, so here's a hack to prevent it on mobile4579TempValue0 = false4580#platform: Standard4581TempValue0 = Stage.DebugMode4582#endplatform45834584if TempValue0 == true4585if KeyPress[1].ButtonB == true // Turn Debug Mode4586Object.Type = TypeName[Debug Mode]45874588if Stage.PlayerListPos != PLAYER_SONIC_A // PLAYER_SONIC in origins4589Object[+1].Type = TypeName[Blank Object]4590end if45914592Player.YVelocity = 04593Player.State = Player_State_Static4594Player.Frame = 04595Player.Rotation = 045964597Player.ObjectInteraction = false4598Player.TileCollisions = true4599Player.DrawOrder = 446004601Player.AbilityTimer = 04602Player.MinRollSpeed = 046034604Screen.CameraEnabled = true4605Screen.CameraStyle = Options.OriginalControls4606else4607// Handle Player4608CallFunction(Player_ProcessUpdate)4609CallFunction(Player.State)4610ProcessAnimation()46114612if Player.Animation == ANI_JUMPING4613Screen.AdjustCameraY = Player.JumpOffset4614else4615if Screen.AdjustCameraY == Player.JumpOffset4616Screen.AdjustCameraY = 04617Player.iYPos += Player.JumpOffset4618end if4619end if46204621if Player.YVelocity > 0x1000004622Player.YVelocity = 0x1000004623end if46244625PlayerTileCollision()46264627if CheckResult == true4628if Player.Animation == ANI_JUMPING4629if Player.Down == false4630Player.Animation = ANI_WALKING4631Screen.AdjustCameraY = 04632Player.iYPos += Player.JumpOffset4633end if4634end if4635end if4636end if4637else4638// Mobile version ObjectMain starts here, since there wasn't a debug mode4639// Handle Player4640CallFunction(Player_ProcessUpdate)4641CallFunction(Player.State)46424643#platform: Use_Origins4644if Player.DropDashCharge >= 204645if Player.Animation == ANI_JUMPING4646Player.Frame = 04647Player.AnimationTimer = 04648Player.AnimationSpeed = 14649end if4650end if4651#endplatform46524653ProcessAnimation()46544655if Player.Animation == ANI_JUMPING4656Screen.AdjustCameraY = Player.JumpOffset4657else4658if Screen.AdjustCameraY == Player.JumpOffset4659Screen.AdjustCameraY = 04660Player.iYPos += Player.JumpOffset4661end if4662end if46634664if Player.YVelocity > 0x1000004665Player.YVelocity = 0x1000004666end if46674668PlayerTileCollision()4669if CheckResult == true4670if Player.Animation == ANI_JUMPING4671if Player.Down == false4672Player.Animation = ANI_WALKING4673Screen.AdjustCameraY = 04674Player.iYPos += Player.JumpOffset4675end if4676end if4677end if4678end if4679end sub468046814682sub ObjectDraw4683if Player.Animation != Player.PrevAnimation4684Player.PrevAnimation = Player.Animation4685Player.Frame = 04686Player.AnimationTimer = 04687Player.AnimationSpeed = 04688end if46894690DrawPlayerAnimation()4691end sub469246934694sub ObjectStartup4695#platform: Use_Origins4696// I feel like I got spoiled on a Knuckles route...4697TempValue0 = false4698CheckGreater(Warp.Timer, 204)4699TempValue0 |= CheckResult4700TempValue0 &= Mini_PlayerFlag4701Mini_PlayerFlag = TempValue04702Warp.Timer = 047034704if Options.AttractMode == false4705if Options.StageSelectFlag == false4706ReadSaveRAM()4707end if4708end if47094710// Origins Plus includes new start positions for Knuckles in some levels4711ArrayPos1 = 324712TempValue5 = 04713TempValue6 = 04714while ArrayPos1 < 10564715// So now we have to check how many player objects the game found4716if Object[ArrayPos1].Type == TypeName[Player Object]4717TempValue5++4718end if4719ArrayPos1++4720loop47214722// We found multiple spawn points, now check which one to use4723if TempValue5 > 14724ArrayPos1 = 324725TempValue7 = 04726while ArrayPos1 < 10564727if Object[ArrayPos1].Type == TypeName[Player Object]4728// The standard spawnpoint4729if Object[ArrayPos1].PropertyValue == 04730TempValue7 = ArrayPos14731end if47324733// Character specific spawnpoint4734if Object[ArrayPos1].PropertyValue == Stage.PlayerListPos4735TempValue6 = ArrayPos14736ArrayPos1 = 10564737end if4738end if4739ArrayPos1++4740loop47414742// If we didn't find a special spawnpoint, just use the regular one4743if TempValue6 == 04744TempValue6 = TempValue74745end if4746end if47474748// Get rid of all spawnpoints except the one we're going to use4749TempValue7 = 04750ArrayPos0 = 324751while ArrayPos0 < 10564752if Object[ArrayPos0].Type == TypeName[Player Object]4753if TempValue5 > 14754if ArrayPos0 == TempValue64755CallFunction(Player_Setup_Startup)4756else4757ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)4758end if4759else4760TempValue7 = ArrayPos04761end if4762end if4763ArrayPos0++4764loop47654766if TempValue7 > 04767ArrayPos0 = TempValue74768CallFunction(Player_Setup_Startup)4769end if4770#endplatform47714772#platform: Use_Standalone4773ArrayPos0 = 324774while ArrayPos0 < 10564775if Object[ArrayPos0].Type == TypeName[Player Object]4776switch Stage.PlayerListPos4777case PLAYER_SONIC_A4778ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)4779Player.XPos = Object[ArrayPos0].XPos4780Player.YPos = Object[ArrayPos0].YPos47814782LoadAnimation("Sonic.Ani")4783BindPlayerToObject(0, 0)47844785Player.State = Player_State_Air47864787Player.Priority = PRIORITY_ACTIVE47884789Player.DrawOrder = 447904791Player.TopSpeed = 0x600004792Player.Acceleration = 0xC004793Player.Deceleration = 0xC004794Player.AirAcceleration = 0x18004795Player.AirDeceleration = 0x6004796Player.GravityStrength = 0x38004797Player.JumpStrength = 0x680004798Player.JumpCap = -0x400004799Player.RollingDeceleration = 0x200048004801Player.JumpOffset = -548024803Player.JumpAbility = Player_State_Static4804if Options.OriginalControls == false4805Player.ActionPeelout = Player_Action_Peelout_S24806Player.ActionSpindash = Player_Action_Spindash_S24807else4808Player.ActionPeelout = Player_Action_Peelout_CD4809Player.ActionSpindash = Player_Action_Spindash_CD4810end if4811break48124813case PLAYER_TAILS_A4814ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)4815Player.XPos = Object[ArrayPos0].XPos4816Player.YPos = Object[ArrayPos0].YPos48174818LoadAnimation("Tails.Ani")4819BindPlayerToObject(0, 0)48204821Player.State = Player_State_Air4822Player.Priority = PRIORITY_ACTIVE4823Player.DrawOrder = 448244825Player.TopSpeed = 0x600004826Player.Acceleration = 0xC004827Player.Deceleration = 0xC004828Player.AirAcceleration = 0x18004829Player.AirDeceleration = 0x6004830Player.GravityStrength = 0x38004831Player.JumpStrength = 0x680004832Player.JumpCap = -0x400004833Player.RollingDeceleration = 0x200048344835Player.JumpOffset = -148364837Player.JumpAbility = Player_Action_DblJumpTails4838Player.ActionPeelout = Player_Action_Jump4839if Options.OriginalControls == false4840Player.ActionSpindash = Player_Action_Spindash_S24841else4842Player.ActionSpindash = Player_Action_Spindash_CD4843end if4844break48454846end switch48474848GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")4849GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")4850GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")4851GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")4852GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")4853GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")4854GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")4855GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")4856GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")48574858ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)4859end if48604861ArrayPos0++4862loop4863#endplatform4864end sub486548664867// ========================4868// Editor Subs4869// ========================48704871// All of the Character ID stuff is specific to Origins Plus, other versions of the game don't check or use the PropertyValue48724873sub RSDKEdit4874if Editor.ReturnVariable == true4875switch Editor.VariableID4876case EDIT_VAR_PROPVAL // Property Value4877CheckResult = Object.PropertyValue4878break4879case 0 // Character ID4880CheckResult = Object.PropertyValue4881break4882end switch4883else4884switch Editor.VariableID4885case EDIT_VAR_PROPVAL // Property Value4886Object.PropertyValue = Editor.VariableValue4887break4888case 0 // Character ID4889Object.PropertyValue = Editor.VariableValue4890break4891end switch4892end if4893end sub489448954896sub RSDKDraw4897switch Object.PropertyValue4898default4899LoadSpriteSheet("Players/Sonic1.gif")4900DrawSprite(0)4901break49024903case 14904LoadSpriteSheet("Players/Tails1.gif")4905DrawSprite(1)4906break49074908case 24909LoadSpriteSheet("Players/KTE1.gif")4910DrawSprite(2)4911break49124913case 54914LoadSpriteSheet("Players/Amy1.gif")4915DrawSprite(3)4916break4917end switch4918end sub491949204921sub RSDKLoad4922LoadSpriteSheet("Players/Sonic1.gif")4923SpriteFrame(-16, -19, 28, 39, 1, 1) // Sonic Standing Frame49244925LoadSpriteSheet("Players/Tails1.gif")4926SpriteFrame(-12, -12, 24, 32, 1, 1) // Tails Standing Frame49274928LoadSpriteSheet("Players/KTE1.gif")4929SpriteFrame(-14, -20, 26, 40, 1, 1) // Knuckles Standing Frame49304931LoadSpriteSheet("Players/Amy1.gif")4932SpriteFrame(-12, -15, 21, 35, 45, 1) // Amy Standing Frame49334934AddEditorVariable("Character ID (Origins Plus)")4935SetActiveVariable("Character ID (Origins Plus)")4936AddEnumVariable("Sonic", PLAYER_SONIC_A)4937AddEnumVariable("Tails", PLAYER_TAILS_A)4938AddEnumVariable("Knuckles", PLAYER_KNUCKLES_A)4939AddEnumVariable("Amy", PLAYER_AMY_A)4940end sub494149424943