Path: blob/main/Scripts/Players/PlayerObject.txt
1843 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 jumping1628#platform: Use_Origins1629Player.DropDashCharge = -11630Player.State = Player_State_Air1631CallFunction(Player_State_Air)1632#endplatform1633end function16341635function Player_State_Air1636CallFunction(Player_HandleAirFriction)1637#platform: Use_Origins1638if Stage.PlayerListPos == PLAYER_TAILS1639CallFunction(Player_HandleDropDash)1640end if1641#endplatform1642if Player.Gravity == GRAVITY_AIR // Check that you're truly in the air1643CallFunction(Player_HandleAirMovement)16441645// More warp stuff1646if Warp.Destination > WARPDEST_NONE1647TempValue0 = Player.YVelocity1648if TempValue0 < 01649FlipSign(TempValue0)1650end if16511652if TempValue0 < 0x600001653TempValue0 = Player.XVelocity1654if TempValue0 < 01655FlipSign(TempValue0)1656end if16571658if TempValue0 < 0x600001659TempValue0 = Player.XVelocity1660TempValue0 -= Warp.SpeedCompare1661if TempValue0 < 01662FlipSign(TempValue0)1663end if16641665if TempValue0 > 0x400001666if Warp.Timer > 991667if Warp.Timer < 2041668Warp.Destination = WARPDEST_NONE1669end if1670end if1671Warp.Timer = 01672end if1673end if1674end if1675Warp.SpeedCompare = Player.XVelocity1676end if16771678// changes the flailing with the walking, not sure when this is used1679if Player.YVelocity > 0x200001680if Player.Animation == ANI_FLAILINGLEFT1681Player.Animation = ANI_WALKING1682end if1683if Player.Animation == ANI_FLAILINGRIGHT1684Player.Animation = ANI_WALKING1685end if1686end if16871688// Post-Hitting a spring1689if Player.Animation == ANI_BOUNCING1690if Player.YVelocity >= 01691if Player.AnimationReserve == ANI_STOPPED1692Player.AnimationReserve = ANI_WALKING1693end if1694Player.Animation = Player.AnimationReserve1695end if1696end if16971698// Post Getting hurt1699if Player.Animation == ANI_HURT1700if Player.YVelocity >= 01701if Player.AnimationReserve == ANI_STOPPED1702Player.AnimationReserve = ANI_WALKING1703end if1704Player.Animation = Player.AnimationReserve1705end if1706end if17071708// Calls the player flight function1709#platform: Use_Origins1710// Bug Details:1711// This segment of code was backported from Sonic 1 to (presumably) prevent the ledge roll-off ability bug that's from 2011.1712// -> However, this code is missing the Player.JumpAbilityState check before the second ANI_JUMPING check.1713// -> This basically makes it still behave like 2011 does, just more advanced (?).1714// -> The other checks from S1 that also do things with Player.JumpAbilityState are missing too...1715// -> Not really sure why it turned out this way.1716if Stage.PlayerListPos == PLAYER_TAILS1717if Player.Animation == ANI_JUMPING1718CallFunction(Player.JumpAbility)1719end if1720else1721if Player.YVelocity >= Player.JumpCap1722CallFunction(Player_HandleDropDash)1723if Player.Animation == ANI_JUMPING1724CallFunction(Player.JumpAbility)1725end if1726end if1727end if1728#endplatform17291730#platform: Use_Standalone1731if Player.Animation == ANI_JUMPING1732CallFunction(Player.JumpAbility)1733end if1734#endplatform1735else1736// go back to the ground silly1737#platform: Use_Origins1738if Player.DropDashCharge >= 201739if Stage.PlayerListPos == PLAYER_AMY1740CallFunction(Player_Action_HammerDash)1741else1742CallFunction(Player_Action_Spindash_S2)1743end if1744else1745Player.State = Player_State_Ground1746CallFunction(Player_HandleOnGround)1747Player.Skidding = 01748end if1749#endplatform17501751#platform: Use_Standalone1752Player.State = Player_State_Ground1753CallFunction(Player_HandleOnGround)1754Player.Skidding = 01755#endplatform1756end if1757end function17581759function Player_State_Roll1760CallFunction(Player_HandleRollDeceleration)1761#platform: Use_Origins1762if Player.ForceGrounded > 01763Player.Gravity = GRAVITY_GROUND1764Player.ForceGrounded -= 1 // ig a normal "--" wasn't good enough, huh?1765end if1766#endplatform17671768if Player.Gravity == GRAVITY_AIR17691770#platform: Use_Origins1771Player.State = Player_State_Air_NoDropDash1772#endplatform17731774#platform: Use_Standalone1775Player.State = Player_State_Air1776#endplatform17771778Player.Timer = 01779CallFunction(Player_HandleAirMovement)1780else1781CallFunction(Player_HandleRollAnimSpeed)1782Player.AnimationSpeed = Player.RollAnimationSpeed17831784TempValue0 = Player.Speed1785if TempValue0 < 01786FlipSign(TempValue0)1787end if17881789// Warp-Consuming1790if TempValue0 < 0x5F5C21791if Warp.Destination > WARPDEST_NONE1792if Warp.Timer > 991793if Warp.Timer < 2041794Warp.Destination = WARPDEST_NONE1795end if1796end if1797Warp.Timer = 01798end if1799else1800// Spawn Warp Stars1801if Warp.Destination > WARPDEST_NONE1802if Warp.Timer == 01803Warp.Timer = 11804ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)1805WarpStar.Timer = 71806WarpStar.DrawOrder = 41807end if1808end if1809end if18101811CallFunction(Player_HandleOnGround)18121813if Player.JumpPress == true1814CallFunction(Player_Action_Jump)1815end if1816end if1817end function18181819// Cancels input movement (Unused leftover from Sonic Nexus (2008))1820function Player_State_RollJump1821#platform: Use_Origins1822// they removed roll jump lock in Plus lol1823if Options.AttractMode == true1824Player.Left = false1825Player.Right = false1826end if18271828CallFunction(Player_HandleAirFriction)1829if Stage.PlayerListPos == PLAYER_TAILS1830CallFunction(Player_HandleDropDash)1831else1832if Player.YVelocity >= Player.JumpCap1833CallFunction(Player_HandleDropDash)1834end if1835end if1836#endplatform18371838#platform: Use_Standalone1839Player.Left = false1840Player.Right = false1841CallFunction(Player_HandleAirFriction)1842#endplatform184318441845if Player.Gravity == GRAVITY_AIR1846CallFunction(Player_HandleAirMovement)1847else18481849#platform: Use_Origins1850if Player.DropDashCharge >= 201851if Stage.PlayerListPos == PLAYER_AMY1852CallFunction(Player_Action_HammerDash)1853else1854CallFunction(Player_Action_Spindash_S2)1855end if1856else1857Player.State = Player_State_Ground1858CallFunction(Player_HandleOnGround)1859Player.Skidding = 01860end if1861#endplatform18621863#platform: Use_Standalone1864Player.State = Player_State_Ground1865CallFunction(Player_HandleOnGround)1866Player.Skidding = 01867#endplatform18681869end if1870end function18711872// Hey look up1873function Player_State_LookUp1874if Player.Up == false1875Player.State = Player_State_Ground1876Player.Timer = 01877else1878if Player.Timer < 601879Player.Timer++1880else1881if Player.LookPos > -1121882Player.LookPos -= 21883end if1884end if18851886if Player.Gravity == GRAVITY_AIR18871888#platform: Use_Origins1889Player.State = Player_State_Air_NoDropDash1890#endplatform18911892#platform: Use_Standalone1893Player.State = Player_State_Air1894#endplatform18951896Player.Timer = 01897else1898if Player.JumpPress == true1899CallFunction(Player.ActionPeelout)1900end if1901end if1902end if1903end function19041905// Hey look down1906function Player_State_Crouch1907if Player.Down == false1908Player.State = Player_State_Ground1909Player.Timer = 01910else1911if Player.Timer < 601912Player.Timer++1913else1914if Player.LookPos < 961915Player.LookPos += 21916end if1917end if19181919if Player.Gravity == GRAVITY_AIR19201921#platform: Use_Origins1922Player.State = Player_State_Air_NoDropDash1923#endplatform19241925#platform: Use_Standalone1926Player.State = Player_State_Air1927#endplatform19281929Player.Timer = 01930else1931if Player.JumpPress == true1932CallFunction(Player.ActionSpindash)1933end if1934end if1935end if1936end function19371938// S2 Spin Dash code1939function Player_State_Spindash_S21940// Keep the camera lock, cancel the spin dash1941if Player.Gravity == GRAVITY_AIR19421943#platform: Use_Origins1944Player.State = Player_State_Air_NoDropDash1945#endplatform19461947#platform: Use_Standalone1948Player.State = Player_State_Air1949#endplatform19501951Player.Speed = 01952end if19531954// Mashing1955if Player.JumpPress == true1956if Player.AbilityTimer < 5121957Player.AbilityTimer += 641958end if1959Player.Frame = 019601961PlaySfx(SFX_G_CHARGE, false)1962else1963if Player.AbilityTimer > 01964Player.AbilityTimer--1965end if1966end if19671968#platform: Use_Origins1969TempValue1 = Player.Down1970if Player.DropDashCharge >= 201971Player.DropDashCharge = -11972Sin256(TempValue0, Player.Angle)1973if Player.Direction == FACING_RIGHT1974if TempValue0 >= 01975TempValue0 <<= 21976else1977TempValue0 <<= 11978end if1979else1980if TempValue0 >= 01981TempValue0 <<= 11982else1983TempValue0 <<= 21984end if1985FlipSign(TempValue0)1986end if19871988if TempValue0 > 5121989TempValue0 = 5121990end if19911992Player.AbilityTimer = TempValue01993TempValue1 = false1994end if19951996CheckEqual(TempValue1, false)1997#endplatform19981999#platform: Use_Standalone2000CheckEqual(Player.Down, false)2001#endplatform2002// Work around to adapt it to origins2003// Spin Dash release2004if CheckResult == true2005Player.Timer = 02006Player.State = Player_State_Roll2007Player.Animation = ANI_JUMPING2008Player.iYPos -= Player.JumpOffset20092010Player.ScrollDelay = 152011Screen.CameraStyle = CAMERASTYLE_HLOCKED20122013TempValue0 = Player.AbilityTimer2014TempValue0 <<= 92015TempValue0 += 0x8000020162017if Player.Direction == FACING_RIGHT2018Player.Speed = TempValue02019else2020Player.Speed = TempValue02021FlipSign(Player.Speed)2022end if20232024PlaySfx(SFX_G_RELEASE, false)20252026CallFunction(Player_HandleOnGround)20272028#platform: Use_Origins2029Player.ForceGrounded = 62030#endplatform20312032#platform: Use_Haptics2033HapticEffect(42, 0, 0, 0)2034#endplatform20352036end if2037end function20382039function Player_State_Spindash_CD2040if Player.Direction == FACING_RIGHT2041Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L2042else2043Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R2044end if20452046// Keep the camera lock, cancel the spin dash2047if Player.Gravity == GRAVITY_AIR20482049#platform: Use_Origins2050Player.State = Player_State_Air_NoDropDash2051#endplatform20522053#platform: Use_Standalone2054Player.State = Player_State_Air2055#endplatform20562057Player.Speed = 02058Screen.CameraStyle = CAMERASTYLE_EXTENDED2059end if20602061// Charge2062if Player.GravityStrength == 0x10002063if Player.AbilityTimer < 0x800002064Player.AbilityTimer += 0x60002065end if2066else2067if Player.AbilityTimer < 0xC00002068Player.AbilityTimer += 0x60002069end if2070end if20712072// Release2073if Player.Down == false2074Screen.CameraStyle = CAMERASTYLE_EXTENDED2075Player.Timer = 020762077if Player.AbilityTimer < 0x2FAE12078Player.Speed = 02079Player.State = Player_State_Ground2080else2081Player.State = Player_State_Roll2082Player.Animation = ANI_JUMPING2083Player.Speed = Player.AbilityTimer20842085if Player.Direction == FACING_LEFT2086FlipSign(Player.Speed)2087end if20882089PlaySfx(SFX_G_RELEASE, false)2090end if2091CallFunction(Player_HandleOnGround)20922093#platform: Use_Haptics2094HapticEffect(42, 0, 0, 0)2095#endplatform20962097end if2098end function209921002101function Player_State_Peelout_S22102// Cancels the Peel Out, keeps the camera2103if Player.Gravity == GRAVITY_AIR21042105#platform: Use_Origins2106Player.State = Player_State_Air_NoDropDash2107#endplatform21082109#platform: Use_Standalone2110Player.State = Player_State_Air2111#endplatform21122113Player.Speed = 02114end if2115// Charge2116if Player.GravityStrength == 0x10002117if Player.AbilityTimer < 0x600002118Player.AbilityTimer += 0x60002119end if2120else2121if Player.AbilityTimer < 0xC00002122Player.AbilityTimer += 0x60002123end if2124end if2125// Speed building, from walking to running then peelout2126if Player.AbilityTimer < 0x5F5C22127Player.Animation = ANI_WALKING2128TempValue0 = Player.AbilityTimer2129TempValue0 >>= 162130TempValue0 *= 802131TempValue0 /= 62132TempValue0 += 202133else2134TempValue0 = Player.AbilityTimer2135TempValue0 >>= 162136TempValue0 *= 802137TempValue0 /= 62138if Player.AbilityTimer > 0x9FFFF2139Player.Animation = ANI_PEELOUT2140else2141Player.Animation = ANI_RUNNING2142end if2143end if21442145// Release2146if Player.Up == false2147Player.ScrollDelay = 152148Screen.CameraStyle = CAMERASTYLE_HLOCKED21492150Player.State = Player_State_Ground2151// Cancels the peel out if you didn't charged it enough2152if Player.AbilityTimer < 0x5F5C22153Player.Speed = 02154else2155Player.Speed = Player.AbilityTimer2156if Player.Direction == FACING_LEFT2157FlipSign(Player.Speed)2158end if2159PlaySfx(SFX_G_RELEASE, false)2160end if2161CallFunction(Player_HandleOnGround)21622163#platform: Use_Haptics2164HapticEffect(42, 0, 0, 0)2165#endplatform21662167end if2168Player.AnimationSpeed = TempValue02169end function217021712172function Player_State_Peelout_CD2173// Moves the camera2174if Player.Direction == FACING_RIGHT2175Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_L2176else2177Screen.CameraStyle = CAMERASTYLE_EXTENDED_OFFSET_R2178end if2179// Cancels the Peel Out, keeps the camera2180if Player.Gravity == GRAVITY_AIR21812182#platform: Use_Origins2183Player.State = Player_State_Air_NoDropDash2184#endplatform21852186#platform: Use_Standalone2187Player.State = Player_State_Air2188#endplatform21892190Player.Speed = 02191Screen.CameraStyle = CAMERASTYLE_EXTENDED2192end if21932194// Charge2195if Player.GravityStrength == 0x10002196if Player.AbilityTimer < 0x600002197Player.AbilityTimer += 0x60002198end if2199else2200if Player.AbilityTimer < 0xC00002201Player.AbilityTimer += 0x60002202end if2203end if22042205// Speed building, from walking to running then peelout2206if Player.AbilityTimer < 0x5F5C22207Player.Animation = ANI_WALKING2208TempValue0 = Player.AbilityTimer2209TempValue0 >>= 162210TempValue0 *= 802211TempValue0 /= 62212TempValue0 += 202213else2214TempValue0 = Player.AbilityTimer2215TempValue0 >>= 162216TempValue0 *= 802217TempValue0 /= 62218if Player.AbilityTimer > 0x9FFFF2219Player.Animation = ANI_PEELOUT2220else2221Player.Animation = ANI_RUNNING2222end if2223end if22242225// Release2226if Player.Up == false2227Screen.CameraStyle = CAMERASTYLE_EXTENDED22282229Player.State = Player_State_Ground2230// Cancels the peel out if you didn't charged it enough2231if Player.AbilityTimer < 0x5F5C22232Player.Speed = 02233else2234Player.Speed = Player.AbilityTimer2235if Player.Direction == FACING_LEFT2236FlipSign(Player.Speed)2237end if22382239PlaySfx(SFX_G_RELEASE, false)2240end if2241CallFunction(Player_HandleOnGround)22422243#platform: Use_Haptics2244HapticEffect(42, 0, 0, 0)2245#endplatform22462247end if2248Player.AnimationSpeed = TempValue02249end function22502251// Tails flight2252function Player_State_Fly2253CallFunction(Player_HandleAirFriction)2254if Player.Gravity == GRAVITY_AIR2255Player.XVelocity = Player.Speed2256// Check if you have enough speed while flying to keep the warp2257if Warp.Destination > WARPDEST_NONE2258TempValue0 = Player.XVelocity2259if TempValue0 < 02260FlipSign(TempValue0)2261end if22622263TempValue1 = Player.YVelocity2264if TempValue1 < 02265FlipSign(TempValue1)2266end if22672268TempValue0 += TempValue12269if TempValue0 < 0x400002270if Warp.Timer > 992271if Warp.Timer < 2202272Warp.Destination = WARPDEST_NONE2273end if2274end if2275Warp.Timer = 02276end if2277end if22782279if Player.YVelocity < -0x100002280Player.FlightVelocity = 0x8002281else2282if Player.YVelocity < 12283if Player.AbilityTimer < 602284Player.AbilityTimer++2285else2286Player.FlightVelocity = 0x8002287end if2288end if2289end if22902291Player.YVelocity += Player.FlightVelocity2292if Player.Timer < 4802293if Player.GravityStrength == 0x38002294Player.Animation = ANI_FLYING2295else2296Player.Animation = ANI_SWIMMING2297end if22982299Player.Timer++2300if Player.Timer == 4802301if Player.GravityStrength == 0x38002302Player.Animation = ANI_FLYINGTIRED2303StopSfx(SFX_G_FLYING)2304PlaySfx(SFX_G_TIRED, true)2305else2306Player.Animation = ANI_SWIMMINGTIRED2307end if2308else2309if Player.JumpPress == true2310Player.FlightVelocity = -0x20002311Player.AbilityTimer = 02312end if2313end if2314else2315if Player.GravityStrength == 0x38002316Player.Animation = ANI_FLYINGTIRED2317else2318Player.Animation = ANI_SWIMMINGTIRED2319end if2320end if2321else2322Player.State = Player_State_Ground2323CallFunction(Player_HandleOnGround)2324end if23252326// If the level has a roof barrier, you're not getting too far2327if Player.RoofBarrier == true2328TempValue0 = Player.YPos2329TempValue0 >>= 162330if TempValue0 < Player.CollisionBottom2331Player.YPos = Player.CollisionBottom2332Player.YPos <<= 162333end if2334end if2335end function23362337// Player Damage2338function Player_State_GotHit2339#platform: Use_Origins2340TempValue1 = false2341if game.playMode == BOOT_PLAYMODE_MISSION2342if game.missionFunctionNo == RULE_MERCY_BADNIKS2343if game.missionValue == 12344game.missionValue = 02345TempValue1 = true2346end if2347end if2348end if2349#endplatform23502351ArrayPos0 = Player.EntityNo2352ArrayPos0 += 22353// if you had a shield, remove it2354if Object[ArrayPos0].PropertyValue > 02355TempValue0 = DAMAGE_SHIELDED2356ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)2357PlaySfx(SFX_G_HURT, false)2358else2359if Player.Rings == 02360PlaySfx(SFX_G_HURT, false)2361TempValue0 = DAMAGE_DEATH2362else2363#platform: Use_Origins2364if TempValue1 == false2365PlaySfx(SFX_G_LOSERINGS, false)2366TempValue0 = DAMAGE_HURT2367end if2368#endplatform23692370#platform: Use_Standalone2371PlaySfx(SFX_G_LOSERINGS, false)2372TempValue0 = DAMAGE_HURT2373#endplatform2374end if2375end if23762377#platform: Use_Origins2378if TempValue1 != false2379TempValue0 = DAMAGE_DEATH2380end if2381#endplatform23822383switch TempValue02384case DAMAGE_SHIELDED2385#platform: Use_Haptics2386HapticEffect(16, 0, 0, 0)2387#endplatform23882389Player.State = Player_State_Hurt2390Player.Animation = ANI_HURT2391Player.YVelocity = -0x400002392Player.Gravity = GRAVITY_AIR2393Player.TrackScroll = true2394Player.InvincibleTimer = 800023952396if Player.GravityStrength == 0x10002397Player.Speed >>= 12398Player.YVelocity >>= 12399end if2400break24012402case DAMAGE_HURT2403#platform: Use_Haptics2404HapticEffect(16, 0, 0, 0)2405#endplatform24062407if Player.CollisionPlane == COLLISION_PLANE_A2408TempValue4 = 32409else2410TempValue4 = 12411end if24122413Player.State = Player_State_Hurt2414Player.Animation = ANI_HURT2415Player.YVelocity = -0x400002416Player.Gravity = GRAVITY_AIR2417Player.TrackScroll = true2418Player.InvincibleTimer = 800024192420if Player.GravityStrength == 0x10002421Player.Speed >>= 12422Player.YVelocity >>= 12423end if2424// Lose ring code2425TempValue0 = Player.Rings2426if TempValue0 > 162427TempValue1 = TempValue02428TempValue1 -= 162429TempValue0 = 162430else2431TempValue1 = 02432end if24332434if TempValue1 > 162435TempValue1 = 162436end if24372438TempValue3 = TempValue12439TempValue3 >>= 12440TempValue3 <<= 524412442TempValue2 = 3842443TempValue2 -= TempValue324442445TempValue3 >>= 42446if TempValue3 == TempValue12447TempValue2 += 162448else2449TempValue2 -= 162450end if24512452TempValue3 = 02453while TempValue3 < TempValue12454CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)2455Cos(Object[TempObjectPos].XVelocity, TempValue2)2456Sin(Object[TempObjectPos].YVelocity, TempValue2)2457Object[TempObjectPos].XVelocity <<= 82458Object[TempObjectPos].YVelocity <<= 82459Object[TempObjectPos].DrawOrder = TempValue42460Object[TempObjectPos].AnimationSpeed = 2562461TempValue3++2462TempValue2 += 322463loop2464TempValue3 = TempValue02465TempValue3 >>= 12466TempValue3 <<= 524672468TempValue2 = 3842469TempValue2 -= TempValue324702471TempValue3 >>= 42472if TempValue3 == TempValue02473TempValue2 += 162474else2475TempValue2 -= 162476end if2477TempValue3 = 024782479while TempValue3 < TempValue02480CreateTempObject(TypeName[Lose Ring], Player.CollisionPlane, Player.XPos, Player.YPos)2481Cos(Object[TempObjectPos].XVelocity, TempValue2)2482Sin(Object[TempObjectPos].YVelocity, TempValue2)2483Object[TempObjectPos].XVelocity <<= 92484Object[TempObjectPos].YVelocity <<= 92485Object[TempObjectPos].DrawOrder = TempValue42486Object[TempObjectPos].AnimationSpeed = 2562487TempValue3++2488TempValue2 += 322489loop2490Player.Rings = 02491Ring.ExtraLife = 1002492break24932494case DAMAGE_DEATH2495#platform: Use_Haptics2496HapticEffect(28, 0, 0, 0)2497#endplatform24982499Object.DrawOrder = 52500Player.Speed = 02501Player.YVelocity = -0x700002502Player.XVelocity = 02503Player.State = Player_State_Death2504Player.Animation = ANI_DYING25052506Player.TileCollisions = false2507Player.ObjectInteraction = false2508if Player.EntityNo == 0 // Check if it's was player 1 who died......what?2509Screen.CameraEnabled = false2510end if2511break2512end switch2513// lose your warp-run if you receive damage2514if Warp.Destination > WARPDEST_NONE2515if Warp.Timer > 992516if Warp.Timer < 2042517Warp.Destination = WARPDEST_NONE2518end if2519end if2520Warp.Timer = 02521end if2522end function252325242525function Player_State_Hurt2526#platform: Use_Origins2527Player.TileCollisions = true2528#endplatform2529if Player.Gravity == GRAVITY_AIR2530Player.TrackScroll = true2531if Player.GravityStrength == 0x38002532Player.YVelocity += 0x30002533else2534Player.YVelocity += 0xF002535end if2536Player.XVelocity = Player.Speed2537else2538Player.State = Player_State_Ground2539Player.InvincibleTimer = 1202540Player.BlinkTimer = 32541Player.Speed = 02542Player.XVelocity = 02543CallFunction(Player_HandleOnGround)2544end if2545end function254625472548function Player_State_OuttaHere2549// preparing to jump2550if Player.Timer < 1402551Player.Timer++2552else2553// The Jump.2554Player.Timer = 02555Player.DrawOrder = 525562557if Player.Direction == FACING_RIGHT2558Player.Speed = 0x100002559Player.XVelocity = 0x100002560else2561Player.Speed = -0x100002562Player.XVelocity = -0x100002563end if2564Player.YVelocity = -0x580002565Player.State = Player_State_Death25662567Player.TileCollisions = false2568Player.ObjectInteraction = false25692570Screen.CameraEnabled = false2571end if2572end function25732574// YOU DIED.2575function Player_State_Death2576Player.ControlMode = CONTROLMODE_NONE2577Player.YVelocity += 0x38002578// Don't override the bored animation2579if Player.Animation != ANI_BORED2580Player.Animation = ANI_DYING2581end if25822583if Player.YVelocity > 0x1000002584#platform: Use_Origins2585EngineCallback(NOTIFY_DEATH_EVENT)2586#endplatform25872588if Player.Lives > 02589if Player.Animation == ANI_BORED // Outta Here makes an automatic game over, no lifes will save you2590Player.Lives = 02591else25922593#platform: Use_Origins2594// Check that we are actually in a mode where we use lives2595if game.coinMode == false2596if game.playMode != BOOT_PLAYMODE_MISSION2597CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)2598TempValue0 = CheckResult2599CheckEqual(game.oneStageFlag, false)2600TempValue0 |= CheckResult2601if TempValue0 != 02602Player.Lives--2603end if2604end if2605end if2606#endplatform26072608#platform: Use_Standalone2609// In Standalone, we don't have any extra things to worry about2610Player.Lives--2611#endplatform2612end if2613end if26142615Stage.TimeEnabled = false26162617#platform: Use_Origins2618CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)2619TempValue0 = CheckResult2620CheckNotEqual(Player.Lives, 0)2621TempValue0 |= CheckResult2622// Check if the player is replaying the stage from My Data & Rankings2623CheckEqual(game.oneStageFlag, false)2624CheckResult |= TempValue02625#endplatform26262627#platform: Use_Standalone2628// Slight workaround to make this cleaner - the check below this comes from Origins, but we need it to always be true on standalone26292630CheckResult = true2631#endplatform26322633// Again, this check is new to Origins and doesn't exist in Standalone2634if CheckResult != false2635Object.Type = TypeName[Death Event]2636DeathEvent.DrawOrder = 72637DeathEvent.Text1XPos = Screen.CenterX2638DeathEvent.Text1XPos -= 2322639DeathEvent.Text2XPos = Screen.CenterX2640DeathEvent.Text2XPos += 2322641end if26422643if Options.GameMode == MODE_TIMEATTACK2644DeathEvent.Timer = 02645DeathEvent.State = DEATHEVENT_TIMEATTACK2646else2647if Player.Lives == 02648DeathEvent.Timer = -28802649DeathEvent.State = DEATHEVENT_GAMEOVER2650// *Technically it goes to the traditional game over in the same state2651PlayMusic(5)2652Stage.PauseEnabled = false26532654#platform: Use_Origins2655if game.oneStageFlag != false2656game.callbackResult = -1 // Reset any callback result2657game.callbackParam0 = 0 // 0 - Normal Retry, anything else - Show current and best time2658game.callbackParam1 = Stage.ListPos // Get current stage2659game.callbackParam2 = 0 // Unknown2660EngineCallback(NOTIFY_STAGE_RETRY)2661end if2662#endplatform26632664else2665DeathEvent.Timer = 02666DeathEvent.State = DEATHEVENT_FADEOUT26672668#platform: Use_Origins2669// Lots of checks here, before we do anything else26702671if game.coinMode == false2672if game.playMode != BOOT_PLAYMODE_BOSSRUSH2673if Stage.Minutes == 92674if Stage.Seconds == 592675// Check if the player is replaying the stage from My Data & Rankings2676if game.oneStageFlag == false2677DeathEvent.Timer = -28802678DeathEvent.State = DEATHEVENT_TIMEOVER26792680PlayMusic(5)2681Stage.PauseEnabled = false2682end if2683end if2684end if2685end if2686end if2687#endplatform26882689#platform: Use_Standalone2690if Stage.Minutes == 92691if Stage.Seconds == 592692DeathEvent.Timer = -28802693DeathEvent.State = DEATHEVENT_TIMEOVER26942695PlayMusic(5)2696Stage.PauseEnabled = false2697end if2698end if2699#endplatform2700end if2701end if2702end if2703end function27042705// Same as death, just slower and without the bored or time over stuff2706function Player_State_Drown2707Player.ControlMode = CONTROLMODE_NONE2708Player.YVelocity += Player.GravityStrength2709Player.Animation = ANI_DROWNING27102711if Player.YVelocity > 0x800002712#platform: Use_Origins2713EngineCallback(NOTIFY_DEATH_EVENT)27142715// We only subtract lives sometimes in Origins2716if game.coinMode == false2717if game.playMode != BOOT_PLAYMODE_MISSION2718CheckEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)2719TempValue0 = CheckResult2720CheckEqual(game.oneStageFlag, false)2721TempValue0 |= CheckResult2722if TempValue0 != false2723if Player.Lives > 02724Player.Lives--2725end if2726end if2727end if2728end if2729#endplatform27302731#platform: Use_Standalone2732if Player.Lives > 02733Player.Lives--2734end if2735#endplatform27362737Stage.TimeEnabled = false27382739Object.Type = TypeName[DeathEvent]2740DeathEvent.DrawOrder = 72741DeathEvent.Text1XPos = Screen.CenterX2742DeathEvent.Text1XPos -= 2322743DeathEvent.Text2XPos = Screen.CenterX2744DeathEvent.Text2XPos += 23227452746if Options.GameMode == MODE_TIMEATTACK2747DeathEvent.Timer = 02748DeathEvent.State = DEATHEVENT_TIMEATTACK2749else2750if Player.Lives == 02751DeathEvent.Timer = -28802752DeathEvent.State = DEATHEVENT_GAMEOVER27532754PlayMusic(5)2755Stage.PauseEnabled = false2756else2757DeathEvent.Timer = 02758DeathEvent.State = DEATHEVENT_FADEOUT2759end if2760end if2761end if2762end function27632764// Wacky Workbench hanging bar gimmick2765function Player_State_HangBar2766if Player.Left == true2767Player.Direction = FACING_LEFT2768Player.Speed = -0x200002769Player.AnimationSpeed = 302770else2771if Player.Right == true2772Player.Direction = FACING_RIGHT2773Player.Speed = 0x200002774Player.AnimationSpeed = 302775else2776Player.Speed = 02777Player.AnimationSpeed = 02778end if2779end if27802781TempValue1 = Player.XPos2782TempValue1 >>= 1627832784TempValue2 = Player.YPos2785TempValue2 >>= 162786TempValue2 += Player.CollisionTop2787// Check that you are in the hanging bar2788Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)2789if TempValue0 != 3 // seems like you're not27902791#platform: Use_Origins2792Player.State = Player_State_Air_NoDropDash2793#endplatform27942795#platform: Use_Standalone2796Player.State = Player_State_Air2797#endplatform27982799Player.Speed = 02800Player.AnimationSpeed = 02801Player.YVelocity = 02802end if28032804// Manual Drop2805if Player.JumpPress == true28062807Player.State = Player_State_Air2808Player.YVelocity = 02809Player.Speed = 02810Player.AnimationSpeed = 02811Player.YPos += 0x400002812end if2813Player.XVelocity = Player.Speed2814// Cancel warp2815if Warp.Destination > WARPDEST_NONE2816if Warp.Timer > 992817if Warp.Timer < 2042818Warp.Destination = WARPDEST_NONE2819end if2820end if28212822Warp.Timer = 02823end if2824end function28252826// Unused leftover from Sonic Nexus (2008)2827function Player_State_CorkscrewRun2828Player.Angle = 02829CallFunction(Player_HandleGroundMovement)2830Player.Animation = 34 // Corkscrew animation, it uses Nexus values and as such, it just looks like a jumbled mess in-game28312832if Player.Speed < 0x600002833if Player.Speed > -0x600002834Player.Animation = ANI_WALKING28352836#platform: Use_Origins2837Player.State = Player_State_Air_NoDropDash2838#endplatform28392840#platform: Use_Standalone2841Player.State = Player_State_Air2842#endplatform28432844Player.Rotation = 028452846if Player.Speed < 02847Player.Direction = FACING_LEFT2848end if2849end if2850end if28512852if Player.Down == true2853if Player.Speed > 0x199A2854Player.State = Player_State_CorkscrewRoll2855Player.Animation = ANI_JUMPING2856end if28572858if Player.Speed < -0x199A2859Player.State = Player_State_CorkscrewRoll2860Player.Animation = ANI_JUMPING2861end if2862end if28632864if Player.Skidding > 02865if Player.Skidding == 162866PlaySfx(SFX_G_DESTROY, false) // Would be Skidding SFX if using Nexus SFX list2867end if2868Player.Animation = ANI_SKIDDING2869Player.Skidding--2870end if28712872if Player.JumpPress == true2873CallFunction(Player_Action_Jump)2874else2875CallFunction(Player_HandleOnGround)2876end if2877end function28782879// Unused leftover from Sonic Nexus (2008)2880function Player_State_CorkscrewRoll2881Player.Angle = 02882CallFunction(Player_HandleRollDeceleration)28832884if Player.Speed < 0x600002885if Player.Speed > -0x6000028862887#platform: Use_Origins2888Player.State = Player_State_Air_NoDropDash2889#endplatform28902891#platform: Use_Standalone2892Player.State = Player_State_Air2893#endplatform28942895end if2896end if28972898if Player.JumpPress == true2899CallFunction(Player_Action_Jump)2900else2901CallFunction(Player_HandleOnGround)2902end if2903end function29042905// Tube Switch function2906function Player_State_TubeRoll2907#platform: Use_Origins2908Player.DropDashCharge = -12909#endplatform2910if Player.Gravity == GRAVITY_AIR // end the function if you are in the air29112912#platform: Use_Origins2913Player.State = Player_State_Air_NoDropDash2914#endplatform29152916#platform: Use_Standalone2917Player.State = Player_State_Air2918#endplatform29192920Player.Timer = 02921CallFunction(Player_HandleAirMovement)2922else2923if Player.Speed > 02924if Player.Speed < Player.MinRollSpeed2925Player.Speed = Player.MinRollSpeed2926end if29272928if Player.Speed > 0x1000002929Player.Speed = 0x1000002930end if2931else2932TempValue0 = Player.MinRollSpeed2933FlipSign(TempValue0)2934if Player.Speed > TempValue02935Player.Speed = TempValue02936CallFunction(Player_HandleOnGround)2937end if29382939if Player.Speed < -0x1000002940Player.Speed = -0x1000002941end if2942end if29432944TempValue0 = Player.Speed2945if TempValue0 < 02946FlipSign(TempValue0)2947end if29482949if TempValue0 < 0x5F5C22950// Warp Star delete checks2951if Warp.Destination > WARPDEST_NONE2952if Warp.Timer > 992953if Warp.Timer < 2042954Warp.Destination = WARPDEST_NONE2955end if2956end if2957Warp.Timer = 02958end if2959else2960// Warp Star spawnning2961if Warp.Destination > WARPDEST_NONE2962if Warp.Timer == 02963Warp.Timer = 12964CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)2965WarpStar.Timer = 72966WarpStar.DrawOrder = 42967end if2968end if2969end if29702971CallFunction(Player_HandleRollDeceleration)2972CallFunction(Player_HandleRollAnimSpeed)2973Player.AnimationSpeed = Player.RollAnimationSpeed2974CallFunction(Player_HandleOnGround)2975end if2976end function29772978function Player_State_TubeAirRoll2979#platform: Use_Origins2980Player.DropDashCharge = -12981#endplatform2982Player.Right = false2983Player.Left = false2984if Player.Gravity == GRAVITY_AIR29852986#platform: Use_Origins2987Player.State = Player_State_Air_NoDropDash2988#endplatform29892990#platform: Use_Standalone2991Player.State = Player_State_Air2992#endplatform29932994Player.Timer = 02995CallFunction(Player_HandleAirMovement)2996else2997if Player.Speed > 02998Player.Speed = Player.MinRollSpeed2999else3000TempValue0 = Player.MinRollSpeed3001FlipSign(TempValue0)3002Player.Speed = TempValue03003end if30043005TempValue0 = Player.Speed3006if TempValue0 < 03007FlipSign(TempValue0)3008end if30093010if TempValue0 < 0x5F5C23011if Warp.Destination > WARPDEST_NONE3012if Warp.Timer > 993013if Warp.Timer < 2043014Warp.Destination = WARPDEST_NONE3015end if3016end if3017Warp.Timer = 03018end if3019else3020if Warp.Destination > WARPDEST_NONE3021if Warp.Timer == 03022Warp.Timer = 13023CreateTempObject(TypeName[Warp Star], 0, Player.XPos, Player.YPos)3024WarpStar.Timer = 73025WarpStar.DrawOrder = 43026end if3027end if3028end if3029CallFunction(Player_HandleRollDeceleration)3030CallFunction(Player_HandleRollAnimSpeed)3031Player.AnimationSpeed = Player.RollAnimationSpeed3032CallFunction(Player_HandleOnGround)3033end if3034end function30353036// Palmtree Panic and Wacky Workbench spinning tops3037function Player_State_SpinningTop3038Player.Timer += Player.MinRollSpeed3039if Player.Gravity == GRAVITY_AIR // Drop from them if you get out of range30403041#platform: Use_Origins3042Player.State = Player_State_Air_NoDropDash3043#endplatform30443045#platform: Use_Standalone3046Player.State = Player_State_Air3047#endplatform30483049Player.Animation = ANI_WALKING3050Player.Timer = 03051CallFunction(Player_HandleAirMovement)3052else3053CallFunction(Player_HandleOnGround)3054end if3055end function30563057// Amy Rose's favorite function3058function Player_State_Hugged3059if Player.Gravity == GRAVITY_AIR // No hugs if you're in the air30603061#platform: Use_Origins3062Player.State = Player_State_Air_NoDropDash3063#endplatform30643065#platform: Use_Standalone3066Player.State = Player_State_Air3067#endplatform30683069Player.Animation = ANI_WALKING3070Player.Timer = 03071CallFunction(Player_HandleAirMovement)3072else3073CallFunction(Player_HandleOnGround)3074// Yes, the only thing the function does is make you wait3075if Player.Timer < 2403076Player.Animation = ANI_STOPPED3077Player.Timer++3078else3079Player.Animation = ANI_WAITING3080end if30813082// Warp cancel check3083if Warp.Destination > WARPDEST_NONE3084if Warp.Timer > 993085if Warp.Timer < 2043086Warp.Destination = WARPDEST_NONE3087end if3088end if3089Warp.Timer = 03090end if30913092// Get free from Amy3093if Player.JumpPress == true3094CallFunction(Player_Action_Jump)3095end if3096end if3097end function30983099// Palmtree Panic Ramp3100function Player_State_Ramp3D3101CallFunction(Player_HandleGroundMovement)3102if Player.Gravity == GRAVITY_AIR31033104#platform: Use_Origins3105Player.State = Player_State_Air_NoDropDash3106#endplatform31073108#platform: Use_Standalone3109Player.State = Player_State_Air3110#endplatform31113112Player.Timer = 03113CallFunction(Player_HandleAirMovement)3114// Set the equivalent animation for looking to the left3115if Player.Direction == FACING_LEFT31163117if Player.Animation == ANI_RAMP_RUNNING33118Player.Animation = ANI_RAMP_RUNNING53119end if31203121if Player.Animation == ANI_RAMP_RUNNING23122Player.Animation = ANI_RAMP_RUNNING63123end if31243125end if3126else3127#platform: Use_Origins3128if Player.Animation == ANI_GLIDING3129Player.XVelocity = 03130Player.YVelocity = 03131Player.Speed = 03132Player.Animation = ANI_GLIDING_STOP3133end if3134#endplatform3135CallFunction(Player_HandleOnGround)3136if Player.Speed == 03137// Warp Star erase check3138if Warp.Destination > WARPDEST_NONE3139if Warp.Timer > 993140if Warp.Timer < 2043141Warp.Destination = WARPDEST_NONE3142end if3143end if3144Warp.Timer = 03145end if3146// Waiting timer while in the ramp3147if Player.Timer < 2403148Player.Animation = ANI_STOPPED3149Player.Timer++3150else3151Player.Animation = ANI_WAITING3152end if3153else3154// Set animation based on angle3155if Player.Angle == 03156Player.Animation = ANI_RAMP_RUNNING13157end if31583159if Player.Angle > 2003160if Player.Direction == FACING_RIGHT3161Player.Animation = ANI_RAMP_RUNNING33162else3163Player.Animation = ANI_RAMP_RUNNING53164end if3165end if31663167if Player.Angle > 2163168if Player.Direction == FACING_RIGHT3169Player.Animation = ANI_RAMP_RUNNING23170else3171Player.Animation = ANI_RAMP_RUNNING63172end if3173end if31743175if Player.Angle > 2323176Player.Animation = ANI_RAMP_RUNNING13177end if31783179if Player.Angle == 1923180Player.Animation = ANI_RAMP_RUNNING43181end if3182end if31833184if Player.JumpPress == true3185CallFunction(Player_Action_Jump)3186else3187if Player.Up == true3188if Player.Speed == 03189Player.State = Player_State_LookUp3190Player.Animation = ANI_LOOKINGUP3191Player.Timer = 03192end if3193end if3194if Player.Down == true3195if Player.Speed == 03196Player.State = Player_State_Crouch3197Player.Animation = ANI_LOOKINGDOWN3198Player.Timer = 03199else3200if Player.Speed > 0x199A3201Player.ControlLock = 03202Player.State = Player_State_Roll3203Player.Animation = ANI_JUMPING3204end if32053206if Player.Speed < -0x199A3207Player.ControlLock = 03208Player.State = Player_State_Roll3209Player.Animation = ANI_JUMPING3210end if3211end if3212end if3213end if3214end if32153216if Player.Animation != ANI_STOPPED3217Player.AnimationSpeed = Player.Speed3218if Player.AnimationSpeed < 03219FlipSign(Player.AnimationSpeed)3220end if3221Player.AnimationSpeed *= 603222Player.AnimationSpeed /= 0x600003223Player.AnimationSpeed += 203224else3225Player.AnimationSpeed = 03226end if3227end function322832293230function Player_State_WaterCurrent3231Player.Gravity = GRAVITY_AIR32323233if Player.Up == true3234Player.YPos -= 0x200003235end if32363237if Player.Down == true3238Player.YPos += 0x200003239end if32403241if Player.Left == true3242Player.XPos -= 0x200003243end if32443245if Player.Right == true3246Player.XPos += 0x200003247end if3248end function32493250function Player_SetJumpOffset3251#platform: Use_Origins3252if Mini_PlayerFlag == true3253Player.JumpOffset = -13254else3255if Stage.PlayerListPos == PLAYER_SONIC3256Player.JumpOffset = -53257end if32583259if Stage.PlayerListPos == PLAYER_TAILS3260Player.JumpOffset = -13261end if32623263if Stage.PlayerListPos == PLAYER_KNUCKLES3264Player.JumpOffset = -53265end if32663267if Stage.PlayerListPos == PLAYER_AMY3268Player.JumpOffset = -43269end if3270end if3271#endplatform3272end function32733274function Player_State_SizeChange3275Player.TileCollisions = true3276if Player.Gravity == GRAVITY_AIR // Knockback after touching the laser3277Player.TrackScroll = true3278Player.YVelocity += 0x30003279Player.XVelocity = Player.Speed3280else3281Player.State = Player_State_Ground32823283Player.InvincibleTimer = 1203284Player.BlinkTimer = 332853286Player.Speed = 03287Player.XVelocity = 032883289CallFunction(Player_HandleOnGround)3290if Mini_PlayerFlag == false3291Mini_PlayerFlag = true32923293#platform: Use_Standalone3294Player.JumpOffset = -13295switch Stage.PlayerListPos3296case PLAYER_SONIC_A3297LoadAnimation("MiniSonic.Ani")3298break32993300case PLAYER_TAILS_A3301LoadAnimation("MiniTails.Ani")3302Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites3303break3304end switch3305#endplatform33063307#platform: Use_Origins3308switch Stage.PlayerListPos3309case PLAYER_SONIC_A3310LoadAnimation("MiniSonic.Ani")3311break33123313case PLAYER_TAILS_A3314LoadAnimation("MiniTails.Ani")3315Object[1].Type = TypeName[Blank Object] // Mini Tails's tails are built-in with his sprites3316break33173318case PLAYER_KNUCKLES_A3319LoadAnimation("MiniKnuckles.Ani")3320Object[1].Type = TypeName[Blank Object] // Mini Knuckles... doesn't have tails, but set the object to blank anyway, I guess3321break33223323case PLAYER_AMY_A3324LoadAnimation("MiniAmy.Ani")3325Object[1].Type = TypeName[Blank Object] // Mini Amy... doesn't have tails, but set the object to blank anyway, I guess3326break3327end switch3328#endplatform3329else3330Mini_PlayerFlag = false33313332#platform: Use_Standalone3333switch Stage.PlayerListPos3334case PLAYER_SONIC_A3335LoadAnimation("Sonic.Ani")3336Player.JumpOffset = -53337break33383339case PLAYER_TAILS_A3340LoadAnimation("Tails.Ani")3341Player.JumpOffset = -13342Object[1].Type = TypeName[Tails Object] // Restore Tails's tails3343break3344end switch3345#endplatform33463347#platform: Use_Origins3348if Stage.PlayerListPos == PLAYER_SONIC3349LoadAnimation("Sonic.Ani")3350end if33513352if Stage.PlayerListPos == PLAYER_TAILS3353LoadAnimation("Tails.Ani")3354Object[1].Type = TypeName[Tails Object] // Restore Tails's tails3355end if33563357if Stage.PlayerListPos == PLAYER_KNUCKLES3358LoadAnimation("Knuckles.Ani")3359end if33603361if Stage.PlayerListPos == PLAYER_AMY3362LoadAnimation("Amy.Ani")3363end if3364#endplatform3365end if33663367#platform: Use_Origins3368CallFunction(Player_SetJumpOffset)3369#endplatform33703371BindPlayerToObject(0, 0)3372end if3373end function337433753376function Player_HandleDropDash3377#platform: Use_Origins3378if Player.DropDashCharge >= 03379if Player.DropDashCharge == 03380if Player.JumpPress == true3381if Stage.PlayerListPos == PLAYER_SONIC3382Player.DropDashCharge = 13383else3384if Stage.PlayerListPos == PLAYER_AMY3385Player.DropDashCharge = 13386else3387Player.DropDashCharge = -13388end if3389end if3390end if3391else3392if Player.JumpHold == false3393if Stage.PlayerListPos == PLAYER_TAILS3394Player.DropDashCharge = -13395else3396if Player.DropDashCharge >= 203397Player.DropDashCharge = -13398end if3399end if3400else3401Player.DropDashCharge++3402if Player.DropDashCharge == 203403PlaySfx(SFX_G_DROPDASH, false)3404end if34053406if Player.DropDashCharge >= 203407if Player.Animation == ANI_JUMPING3408Player.Frame = 03409Player.AnimationTimer = 03410Player.AnimationSpeed = 13411end if3412end if3413end if3414end if3415end if3416#endplatform3417end function34183419function Player_Action_DblJumpKnux3420#platform: Use_Origins3421if Player.YVelocity >= Player.JumpCap3422if Player.JumpPress == true3423game.callbackParam0 = 13424game.callbackParam1 = 03425game.callbackParam2 = 03426EngineCallback(NOTIFY_STATS_CHARA_ACTION2)3427Player.Speed = 0x400003428if Player.YVelocity < 03429Player.YVelocity = 03430end if3431if Player.Direction == FACING_RIGHT3432Player.State = Player_State_GlideRight3433Player.XVelocity = 0x400003434Player.Timer = 03435else3436Player.State = Player_State_GlideLeft3437Player.XVelocity = -0x400003438Player.Timer = 2563439end if3440Player.Animation = ANI_GLIDING3441Player.Frame = 23442Object.Frame = 23443end if3444end if3445#endplatform3446end function344734483449function Player_State_GlideLeft3450#platform: Use_Origins3451if Player.Speed == 03452if Warp.Destination > 03453if Warp.Timer > 993454if Warp.Timer < 2043455Warp.Destination = 03456end if3457end if3458Warp.Timer = 03459end if3460end if34613462if Player.Gravity == GRAVITY_AIR3463if Player.JumpHold == true3464if Player.Timer == 2563465if Player.Speed < 0x1800003466Player.Speed += 0x4003467end if3468else3469if Player.Speed < 0x400003470Player.Speed += 0x10003471end if3472end if34733474if Player.YVelocity > 0x80003475Player.YVelocity -= 0x20003476else3477Player.YVelocity += 0x20003478end if34793480if Player.Timer < 2563481Player.Timer += 43482end if34833484if Player.Timer < 1703485if Player.Timer > 863486Player.Frame = 03487else3488if Player.Timer > 443489Player.Frame = 13490else3491Player.Frame = 23492end if3493end if3494else3495if Player.Timer < 2123496Player.Frame = 13497else3498Player.Frame = 23499end if3500end if35013502TempValue7 = Player.XPos3503if Player.Timer < 1283504Player.Direction = FACING_RIGHT3505TempValue0 = false3506TempValue1 = false3507else3508Player.Direction = FACING_LEFT3509Player.XPos = TempValue73510Player.XPos += Player.XVelocity3511Player.YPos = Player.YPos3512Object.XPos = Player.XPos3513Object.YPos = Player.YPos3514ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)3515Player.XPos = Object.XPos3516TempValue0 = CheckResult3517TempValue2 = Player.XPos3518Player.XPos = TempValue73519Player.XPos += Player.XVelocity3520Object.XPos = Player.XPos3521Object.YPos = Player.YPos3522ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)3523Player.XPos = Object.XPos3524TempValue1 = CheckResult3525TempValue3 = Player.XPos3526end if35273528Cos(Player.XVelocity, Player.Timer)3529Player.XVelocity *= Player.Speed3530Player.XVelocity >>= 93531if Player.Right == true3532Player.State = Player_State_GlideRight35333534if Warp.Destination > 03535if Warp.Timer > 993536if Warp.Timer < 2043537Warp.Destination = 03538end if3539end if3540Warp.Timer = 03541end if3542end if35433544Player.XPos = TempValue73545CheckResult = TempValue03546CheckResult &= TempValue13547if CheckResult == true3548if TempValue2 == TempValue33549if Player.XVelocity > 03550Player.Direction = FACING_RIGHT3551end if3552Player.State = Player_State_Climb3553Player.Speed = 03554Player.XVelocity = 03555Player.YVelocity = 03556Player.Timer = 03557PlaySfx(SFX_G_GRAB, false)3558game.callbackParam0 = 23559game.callbackParam1 = 03560game.callbackParam2 = 03561EngineCallback(NOTIFY_STATS_CHARA_ACTION2)3562if Warp.Destination > 03563if Warp.Timer > 993564if Warp.Timer < 2043565Warp.Destination = 03566end if3567end if3568Warp.Timer = 03569end if3570else3571Player.XVelocity >>= 23572Player.Speed = Player.XVelocity3573CallFunction(Player_Action_GlideDrop)3574end if3575else3576if TempValue0 == true3577if TempValue1 == false3578ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)3579end if35803581if CheckResult == false3582Player.XVelocity >>= 23583Player.Speed = Player.XVelocity3584CallFunction(Player_Action_GlideDrop)3585end if3586end if3587end if3588else3589Player.XVelocity >>= 23590Player.Speed = Player.XVelocity3591CallFunction(Player_Action_GlideDrop)3592end if3593else3594if Player.CollisionMode == CMODE_FLOOR3595Player.Timer = 03596Player.State = Player_State_GlideSlide3597Player.Animation = ANI_GLIDING_STOP3598Player.Speed = Player.XVelocity3599else3600Player.State = Player_State_Ground3601CallFunction(Player_HandleOnGround)3602Player.Skidding = 03603end if3604end if36053606CallFunction(Player_CheckRoofGlide)3607#endplatform3608end function360936103611function Player_State_GlideRight3612#platform: Use_Origins3613if Player.Speed == 03614if Warp.Destination > 03615if Warp.Timer > 993616if Warp.Timer < 2043617Warp.Destination = 03618end if3619end if3620Warp.Timer = 03621end if3622end if36233624if Player.Gravity == GRAVITY_AIR3625if Player.JumpHold == true3626if Player.Timer == 03627if Player.Speed < 0x1800003628Player.Speed += 0x4003629end if3630else3631if Player.Speed < 0x400003632Player.Speed += 0x10003633end if3634end if36353636if Player.YVelocity > 0x80003637Player.YVelocity -= 0x20003638else3639Player.YVelocity += 0x20003640end if36413642if Player.Timer > 03643Player.Timer -= 43644end if36453646if Player.Timer < 1703647if Player.Timer > 863648Player.Frame = 03649else3650if Player.Timer > 443651Player.Frame = 13652else3653Player.Frame = 23654end if3655end if3656else3657if Player.Timer < 2123658Player.Frame = 13659else3660Player.Frame = 23661end if3662end if36633664TempValue7 = Player.XPos3665if Player.Timer < 1283666Player.Direction = FACING_RIGHT3667Player.XPos = TempValue73668Player.XPos += Player.XVelocity3669Player.YPos = Player.YPos3670Object.XPos = Player.XPos3671Object.YPos = Player.YPos3672ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)3673Player.XPos = Object.XPos3674TempValue0 = CheckResult3675TempValue2 = Player.XPos3676Player.XPos = TempValue73677Player.XPos += Player.XVelocity3678Object.XPos = Player.XPos3679Object.YPos = Player.YPos3680ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)3681Player.XPos = Object.XPos3682TempValue1 = CheckResult3683TempValue3 = Player.XPos3684else3685Player.Direction = FACING_LEFT3686TempValue0 = false3687TempValue1 = false3688end if36893690Cos(Player.XVelocity, Player.Timer)3691Player.XVelocity *= Player.Speed3692Player.XVelocity >>= 93693if Player.Left == true3694Player.State = Player_State_GlideLeft36953696if Warp.Destination > 03697if Warp.Timer > 993698if Warp.Timer < 2043699Warp.Destination = 03700end if3701end if3702Warp.Timer = 03703end if3704end if37053706Player.XPos = TempValue73707CheckResult = TempValue03708CheckResult &= TempValue13709if CheckResult == true3710TempValue2 >>= 13711TempValue3 >>= 13712if TempValue2 == TempValue33713if Player.XVelocity < 03714Player.Direction = FACING_LEFT3715end if3716Player.State = Player_State_Climb3717Player.Speed = 03718Player.XVelocity = 03719Player.YVelocity = 03720Player.Timer = 03721PlaySfx(SFX_G_GRAB, false)3722game.callbackParam0 = 23723game.callbackParam1 = 03724game.callbackParam2 = 03725EngineCallback(NOTIFY_STATS_CHARA_ACTION2)3726if Warp.Destination > 03727if Warp.Timer > 993728if Warp.Timer < 2043729Warp.Destination = 03730end if3731end if3732Warp.Timer = 03733end if3734else3735Player.XVelocity >>= 23736Player.Speed = Player.XVelocity3737CallFunction(Player_Action_GlideDrop)3738end if3739else3740if TempValue0 == true3741if TempValue1 == false3742ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)3743end if37443745if CheckResult == false3746Player.Speed = 03747Player.XVelocity >>= 23748Player.Speed = Player.XVelocity3749CallFunction(Player_Action_GlideDrop)3750end if3751end if3752end if3753else3754Player.XVelocity >>= 23755Player.Speed = Player.XVelocity3756CallFunction(Player_Action_GlideDrop)3757end if3758else3759if Player.CollisionMode == CMODE_FLOOR3760Player.Timer = 03761Player.State = Player_State_GlideSlide3762Player.Animation = ANI_GLIDING_STOP3763Player.Speed = Player.XVelocity3764else3765Player.State = Player_State_Ground3766CallFunction(Player_HandleOnGround)3767Player.Skidding = 03768end if3769end if37703771CallFunction(Player_CheckRoofGlide)3772#endplatform3773end function377437753776function Player_State_GlideDrop3777#platform: Use_Origins3778if Player.Gravity == GRAVITY_AIR3779CallFunction(Player_HandleAirFriction)3780CallFunction(Player_HandleAirMovement)3781else3782if Player.JumpPress == true3783Player.XVelocity = 03784Player.Speed = 03785if Player.Down == true3786CallFunction(Player.ActionSpindash)3787else3788CallFunction(Player_Action_Jump)3789end if3790else3791if Player.AbilityTimer == 03792PlaySfx(SFX_G_GLIDEDROPLAND, false)3793end if37943795Player.TrackScroll = false3796Player.Speed = 03797Player.XVelocity = 03798Player.Animation = ANI_LOOKINGDOWN3799Player.PrevAnimation = ANI_LOOKINGDOWN3800Player.Frame = 238013802if Player.AbilityTimer < 163803Player.AbilityTimer++3804else3805Player.AbilityTimer = 03806Player.State = Player_State_Ground3807CallFunction(Player_HandleOnGround)3808Player.Skidding = 03809if Warp.Destination > 03810if Warp.Timer > 993811if Warp.Timer < 2043812Warp.Destination = 03813end if3814end if3815Warp.Timer = 03816end if3817end if3818end if3819end if3820#endplatform3821end function382238233824function Player_State_GlideSlide3825#platform: Use_Origins3826if Player.Gravity == GRAVITY_GROUND3827if Player.Speed == 03828if Player.JumpPress == true3829if Player.Down == true3830CallFunction(Player.ActionSpindash)3831else3832CallFunction(Player_Action_Jump)3833end if3834else3835Player.TrackScroll = false3836Player.Frame = 13837if Player.Timer < 163838Player.Timer++3839else3840Player.State = Player_State_Ground3841CallFunction(Player_HandleOnGround)3842Player.Skidding = 03843end if3844end if3845else3846Player.Timer++3847TempValue0 = Player.Timer3848TempValue0 %= 43849if TempValue0 == 03850CreateTempObject(TypeName[Dust Puff], 0, Player.XPos, Player.YPos)3851Object[TempObjectPos].iYPos += Player.CollisionBottom3852Object[TempObjectPos].DrawOrder = Player.DrawOrder3853end if38543855Player.Timer %= 83856if Player.Timer == 03857PlaySfx(SFX_G_SLIDE, false)3858end if38593860Player.Frame = 03861if Player.Speed > 03862Player.Speed -= 0x20003863if Player.Speed < 03864Player.Speed = 03865Player.Timer = 03866end if3867else3868Player.Speed += 0x20003869if Player.Speed > 03870Player.Speed = 03871Player.Timer = 03872end if3873end if3874if Player.JumpHold == 03875Player.Speed = 03876Player.Timer = 03877end if3878end if38793880Player.XVelocity = Player.Speed3881else3882CallFunction(Player_Action_GlideDrop)3883end if3884#endplatform3885end function388638873888function Player_State_Climb3889#platform: Use_Origins3890if Player.Gravity == GRAVITY_AIR3891Player.Animation = ANI_CLIMBING3892if Player.Up == true3893Player.YVelocity = -0x100003894TempValue0 = Player.CollisionTop3895TempValue0 *= -0x100003896if Player.YPos < TempValue03897Player.YPos = TempValue03898end if38993900Player.Timer++3901if Player.Timer == 43902Player.Timer = 03903Player.Frame++3904if Mini_PlayerFlag == true3905Player.Frame %= 23906else3907Player.Frame %= 63908end if3909end if3910else3911if Player.Down == true3912Player.YVelocity = 0x100003913Player.Timer++3914if Player.Timer == 43915Player.Timer = 03916if Player.Frame < 13917if Mini_PlayerFlag == true3918Player.Frame += 23919else3920Player.Frame += 63921end if3922end if3923Player.Frame--3924end if3925else3926Player.YVelocity = 03927end if3928end if39293930if Player.JumpPress == true3931Player.Animation = ANI_JUMPING3932Player.State = Player_State_Air_NoDropDash3933Player.Timer = 03934if Player.Direction == FACING_LEFT3935Player.XVelocity = 0x400003936Player.Speed = 0x400003937Player.Direction = FACING_RIGHT3938else3939Player.XVelocity = -0x400003940Player.Speed = -0x400003941Player.Direction = FACING_LEFT3942end if39433944Player.YVelocity = -0x400003945if Player.GravityStrength != 0x3800 // (see if Knuckles is underwater)3946Player.XVelocity >>= 13947Player.Speed >>= 13948Player.YVelocity >>= 13949end if3950else3951if Mini_PlayerFlag == true3952TempValue4 = 73953TempValue5 = -63954else3955TempValue4 = 103956TempValue5 = -103957end if39583959if Player.Direction == FACING_RIGHT3960TempValue2 = Player.XPos3961Object.XPos = Player.XPos3962Object.YPos = Player.YPos3963ObjectTileGrip(CSIDE_LWALL, TempValue4, TempValue5, Player.CollisionPlane)3964TempValue0 = CheckResult3965if TempValue0 == 03966Player.XPos = TempValue23967Object.XPos = Player.XPos3968ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)3969ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, true, ECEFFECT_NONE)3970TempValue0 = CheckResult3971end if3972Player.XPos = Object.XPos3973TempValue3 = Player.XPos3974Player.XPos = TempValue23975Object.XPos = Player.XPos3976Object.YPos = Player.YPos3977ObjectTileGrip(CSIDE_LWALL, TempValue4, 11, Player.CollisionPlane)3978Player.XPos = Object.XPos3979TempValue1 = CheckResult3980if TempValue1 == 03981ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_NONE)3982TempValue1 = CheckResult3983end if3984if Player.XPos > TempValue33985Player.XPos = TempValue33986end if3987ObjectTileGrip(CSIDE_ENTITY, FACING_RIGHT, false, ECEFFECT_RESETSTORAGE)3988else3989if Mini_PlayerFlag == true3990TempValue4 = -73991else3992TempValue4 = -103993end if39943995TempValue2 = Player.XPos3996Object.XPos = Player.XPos3997Object.YPos = Player.YPos3998ObjectTileGrip(CSIDE_RWALL, TempValue4, TempValue5, Player.CollisionPlane)3999TempValue0 = CheckResult4000if TempValue0 == 04001Player.XPos = TempValue24002Object.XPos = Player.XPos4003ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)4004ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, true, ECEFFECT_NONE)4005TempValue0 = CheckResult4006end if4007Player.XPos = Object.XPos4008TempValue3 = Player.XPos4009Player.XPos = TempValue24010Object.XPos = Player.XPos4011Object.YPos = Player.YPos4012ObjectTileGrip(CSIDE_RWALL, TempValue4, 11, Player.CollisionPlane)4013Player.XPos = Object.XPos4014TempValue1 = CheckResult4015if TempValue1 == 04016ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_NONE)4017TempValue1 = CheckResult4018end if4019if Player.XPos < TempValue34020Player.XPos = TempValue34021end if4022ObjectTileGrip(CSIDE_ENTITY, FACING_LEFT, false, ECEFFECT_RESETSTORAGE)4023end if4024if TempValue0 == 04025if Player.YVelocity < 04026Player.XPos = TempValue24027Player.Animation = ANI_LEDGEPULLUP4028Player.YVelocity = 04029Player.Timer = 04030Player.State = Player_State_LedgePullUp4031Player.TileCollisions = false4032if Player.Direction == FACING_RIGHT4033Player.XPos += 0x100004034end if4035end if4036else4037if TempValue1 == 04038Player.PrevAnimation = ANI_GLIDING_DROP4039Player.Frame = 24040CallFunction(Player_Action_GlideDrop)4041end if4042end if4043end if4044else4045Player.Animation = ANI_WALKING4046Player.State = Player_State_Ground4047CallFunction(Player_HandleOnGround)4048end if4049#endplatform4050end function405140524053function Player_State_LedgePullUp4054#platform: Use_Origins4055switch Player.Frame4056case 04057if Player.Timer < 54058ObjectTileGrip(CSIDE_FLOOR, 12, -9, Player.CollisionPlane)4059Player.Timer++4060else4061Player.Timer = 04062Player.Frame++4063if Player.Direction == FACING_RIGHT4064Player.XPos += 0x900004065else4066Player.XPos -= 0x900004067end if4068Player.YPos -= 0xA00004069end if4070break40714072case 14073if Player.Timer < 54074Player.Timer++4075else4076Player.Timer = 04077Player.Frame++4078if Player.Direction == FACING_RIGHT4079Player.XPos += 0x500004080else4081Player.XPos -= 0x500004082end if4083end if4084break40854086case 24087if Player.Timer < 54088Player.Timer++4089else4090Player.Timer = 04091Player.Animation = ANI_STOPPED4092Player.State = Player_State_Air_NoDropDash4093Player.YPos -= 0x800004094Player.TileCollisions = true4095end if4096break40974098end switch4099#endplatform4100end function410141024103function Player_State_GlideLeftNoGrip4104#platform: Use_Origins4105if Player.Gravity == GRAVITY_AIR4106if Player.JumpHold == true4107if Player.Timer == 2564108if Player.Speed < 0x1800004109Player.Speed += 0x4004110end if4111else4112if Player.Speed < 0x400004113Player.Speed += 0x10004114end if4115end if41164117if Player.YVelocity > 0x80004118Player.YVelocity -= 0x20004119else4120Player.YVelocity += 0x20004121end if41224123if Player.Timer < 2564124Player.Timer += 44125end if41264127if Player.Timer < 1704128if Player.Timer > 864129Player.Frame = 04130else4131if Player.Timer > 444132Player.Frame = 14133else4134Player.Frame = 24135end if4136end if4137else4138if Player.Timer < 2124139Player.Frame = 14140else4141Player.Frame = 24142end if4143end if41444145TempValue7 = Player.XPos4146if Player.Timer < 1284147Player.Direction = FACING_RIGHT4148TempValue0 = false4149TempValue1 = false4150else4151Player.Direction = FACING_LEFT4152Player.XPos = TempValue74153Player.XPos += Player.XVelocity4154Player.YPos = Player.YPos4155Object.XPos = Player.XPos4156Object.YPos = Player.YPos4157ObjectTileCollision(CSIDE_RWALL, -12, -2, Player.CollisionPlane)4158Player.XPos = Object.XPos4159TempValue0 = CheckResult4160TempValue2 = Player.XPos4161Player.XPos = TempValue74162Player.XPos += Player.XVelocity4163Object.XPos = Player.XPos4164Object.YPos = Player.YPos4165ObjectTileCollision(CSIDE_RWALL, -12, 11, Player.CollisionPlane)4166Player.XPos = Object.XPos4167TempValue1 = CheckResult4168TempValue3 = Player.XPos4169end if41704171Cos(Player.XVelocity, Player.Timer)4172Player.XVelocity *= Player.Speed4173Player.XVelocity >>= 94174if Player.Right == true4175Player.State = Player_State_GlideRightNoGrip4176end if41774178Player.XPos = TempValue74179CheckResult = TempValue04180CheckResult &= TempValue14181if CheckResult == true4182TempValue0 = false4183ArrayPos0 = 324184while ArrayPos0 < 10564185CheckEqual(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...4186if CheckResult == true4187if Object[ArrayPos0].Value0 == true4188TempValue0 = true4189end if4190end if4191ArrayPos0++4192loop41934194if TempValue0 == false4195if TempValue2 == TempValue34196else4197Player.XVelocity >>= 24198Player.Speed = Player.XVelocity4199CallFunction(Player_Action_GlideDrop)4200end if4201end if4202end if4203else4204Player.XVelocity >>= 24205Player.Speed = Player.XVelocity4206CallFunction(Player_Action_GlideDrop)4207end if4208else4209if Player.CollisionMode == CMODE_FLOOR4210Player.Timer = 04211Player.State = Player_State_GlideSlide4212Player.Animation = ANI_GLIDING_STOP4213Player.Speed = Player.XVelocity4214else4215Player.State = Player_State_Ground4216CallFunction(Player_HandleOnGround)4217Player.Skidding = 04218end if4219end if42204221CallFunction(Player_CheckRoofGlide)4222#endplatform4223end function422442254226function Player_State_GlideRightNoGrip4227#platform: Use_Origins4228if Player.Gravity == GRAVITY_AIR4229if Player.JumpHold == true4230if Player.Timer == 04231if Player.Speed < 0x1800004232Player.Speed += 0x4004233end if4234else4235if Player.Speed < 0x400004236Player.Speed += 0x10004237end if4238end if42394240if Player.YVelocity > 0x80004241Player.YVelocity -= 0x20004242else4243Player.YVelocity += 0x20004244end if42454246if Player.Timer > 04247Player.Timer -= 44248end if42494250if Player.Timer < 1704251if Player.Timer > 864252Player.Frame = 04253else4254if Player.Timer > 444255Player.Frame = 14256else4257Player.Frame = 24258end if4259end if4260else4261if Player.Timer < 2124262Player.Frame = 14263else4264Player.Frame = 24265end if4266end if42674268TempValue7 = Player.XPos4269if Player.Timer < 1284270Player.Direction = FACING_RIGHT4271Player.XPos = TempValue74272Player.XPos += Player.XVelocity4273Player.YPos = Player.YPos4274Object.XPos = Player.XPos4275Object.YPos = Player.YPos4276ObjectTileCollision(CSIDE_LWALL, 12, -2, Player.CollisionPlane)4277Player.XPos = Object.XPos4278TempValue0 = CheckResult4279TempValue2 = Player.XPos4280Player.XPos = TempValue74281Player.XPos += Player.XVelocity4282Object.XPos = Player.XPos4283Object.YPos = Player.YPos4284ObjectTileCollision(CSIDE_LWALL, 12, 11, Player.CollisionPlane)4285Player.XPos = Object.XPos4286TempValue1 = CheckResult4287TempValue3 = Player.XPos4288else4289Player.Direction = FACING_LEFT4290TempValue0 = false4291TempValue1 = false4292end if42934294Cos(Player.XVelocity, Player.Timer)4295Player.XVelocity *= Player.Speed4296Player.XVelocity >>= 94297if Player.Left == true4298Player.State = Player_State_GlideLeftNoGrip4299end if43004301Player.XPos = TempValue74302CheckResult = TempValue04303CheckResult &= TempValue14304if CheckResult == true4305TempValue2 >>= 14306TempValue3 >>= 14307if TempValue2 == TempValue34308else4309Player.XVelocity >>= 24310Player.Speed = Player.XVelocity4311CallFunction(Player_Action_GlideDrop)4312end if4313end if4314else4315Player.XVelocity >>= 24316Player.Speed = Player.XVelocity4317CallFunction(Player_Action_GlideDrop)4318end if4319else4320if Player.CollisionMode == CMODE_FLOOR4321Player.Timer = 04322Player.State = Player_State_GlideSlide4323Player.Animation = ANI_GLIDING_STOP4324Player.Speed = Player.XVelocity4325else4326Player.State = Player_State_Ground4327CallFunction(Player_HandleOnGround)4328Player.Skidding = 04329end if4330end if43314332CallFunction(Player_CheckRoofGlide)4333#endplatform4334end function433543364337function Player_CheckRoofGlide4338#platform: Use_Origins4339// This function's just here to make sure that Knuckles doesn't go above the stage in MMZ3 (not a good thing)4340if Stage.ActiveList == REGULAR_STAGE4341CheckEqual(Stage.ListPos, 68) // MMZ3C4342TempValue0 = CheckResult4343CheckEqual(Stage.ListPos, 69) // MMZ3D4344TempValue0 |= CheckResult4345if TempValue0 != false4346if Stage.PlayerListPos == PLAYER_KNUCKLES // a bit redundant, this func is only called in glide functions anyways..4347if Player.RoofBarrier == true4348TempValue0 = Player.YPos4349TempValue0 >>= 164350if TempValue0 < Player.CollisionBottom4351Player.YPos = Player.CollisionBottom4352Player.YPos <<= 164353end if4354end if4355end if4356end if4357end if4358#endplatform4359end function436043614362function Player_Action_GlideDrop4363#platform: Use_Origins4364// Bug Details:4365// Player.Timer should probably be cleared here, but it isn't4366// 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 immediately43674368Player.Animation = ANI_GLIDING_DROP4369Player.AbilityTimer = 04370Player.State = Player_State_GlideDrop4371#endplatform4372end function437343744375function Player_Action_DblJumpAmy4376#platform: Use_Origins4377if Player.JumpPress == true4378PlaySfx(SFX_G_HAMMERJUMP, false)4379game.callbackParam0 = 04380game.callbackParam1 = 14381game.callbackParam2 = 04382EngineCallback(NOTIFY_STATS_CHARA_ACTION2)4383TempValue0 = Player.AnimationSpeed4384TempValue1 = Player.Frame4385Player.Animation = ANI_HAMMER_JUMP4386ProcessAnimation()4387Player.AnimationSpeed = TempValue04388Player.Frame = TempValue14389end if4390#endplatform4391end function439243934394function Player_Action_HammerDash4395#platform: Use_Origins4396PlaySfx(SFX_G_HAMMERDASH, false)4397Player.State = Player_State_HammerDash4398Player.Animation = ANI_HAMMER_DASH4399Player.Timer = 04400Player.DropDashCharge = -14401CallFunction(Player_SetHammerDashSpeed)4402#endplatform4403end function440444054406function Player_State_HammerDash4407#platform: Use_Origins4408if Player.Right == true4409Player.Direction = FACING_RIGHT4410else4411if Player.Left == true4412Player.Direction = FACING_LEFT4413end if4414end if44154416TempValue0 = true44174418if Player.Speed != 04419Player.Timer++4420if Player.JumpHold == true4421if Player.Timer < 604422CallFunction(Player_SetHammerDashSpeed)4423if Player.Gravity == GRAVITY_AIR4424CallFunction(Player_HandleAirMovement)4425else4426CallFunction(Player_HandleOnGround)4427end if4428TempValue0 = false4429end if4430end if4431end if44324433// If Amy is on a steep enough slope, cancel the move4434// (Despite the patch notes for version 2.0.1 claiming this was removed, it's very much still here)4435Cos256(TempValue1, Player.Angle)4436if TempValue1 <= 04437TempValue0 = true4438end if44394440if TempValue0 == true4441Player.State = Player_State_Ground4442end if4443#endplatform4444end function444544464447function Player_SetHammerDashSpeed4448#platform: Use_Origins4449if Player.Direction == FACING_RIGHT4450Player.Speed = 0x600004451else4452// Could they not have just set it to -0x60000?4453Player.Speed = 04454Player.Speed -= 0x600004455end if4456#endplatform4457end function445844594460function Player_Setup_Startup4461#platform: Use_Origins4462ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)44634464Player.XPos = Object[ArrayPos0].XPos4465Player.YPos = Object[ArrayPos0].YPos44664467if Mini_PlayerFlag == false4468if Stage.PlayerListPos == PLAYER_SONIC4469LoadAnimation("Sonic.Ani")4470end if44714472if Stage.PlayerListPos == PLAYER_TAILS4473LoadAnimation("Tails.Ani")4474end if44754476if Stage.PlayerListPos == PLAYER_KNUCKLES4477LoadAnimation("Knuckles.Ani")4478end if44794480if Stage.PlayerListPos == PLAYER_AMY4481LoadAnimation("Amy.Ani")4482end if4483else4484if Stage.PlayerListPos == PLAYER_SONIC4485LoadAnimation("MiniSonic.Ani")4486end if44874488if Stage.PlayerListPos == PLAYER_TAILS4489LoadAnimation("MiniTails.Ani")4490Object[1].Type = TypeName[Blank Object]4491end if44924493// it's not like Knuckles or Amy have any tails to worry about...4494if Stage.PlayerListPos == PLAYER_KNUCKLES4495LoadAnimation("MiniKnuckles.Ani")4496Object[1].Type = TypeName[Blank Object]4497end if44984499if Stage.PlayerListPos == PLAYER_AMY4500LoadAnimation("MiniAmy.Ani")4501Object[1].Type = TypeName[Blank Object]4502end if4503end if45044505BindPlayerToObject(0, 0)45064507Player.State = Player_State_Air_NoDropDash4508Player.Priority = PRIORITY_ACTIVE4509Player.DrawOrder = 445104511Player.TopSpeed = 0x600004512Player.Acceleration = 0xC004513Player.Deceleration = 0xC004514Player.AirAcceleration = 0x18004515Player.AirDeceleration = 0x6004516Player.GravityStrength = 0x38004517Player.JumpStrength = 0x680004518Player.JumpCap = -0x400004519Player.RollingDeceleration = 0x200045204521if Stage.PlayerListPos == PLAYER_SONIC4522Player.JumpAbility = Player_State_Static4523if Options.OriginalControls == false4524Player.ActionPeelout = Player_Action_Peelout_S24525Player.ActionSpindash = Player_Action_Spindash_S24526else4527Player.ActionPeelout = Player_Action_Peelout_CD4528Player.ActionSpindash = Player_Action_Spindash_CD4529end if4530end if45314532if Stage.PlayerListPos == PLAYER_TAILS4533Player.JumpAbility = Player_Action_DblJumpTails4534Player.ActionPeelout = Player_Action_Jump4535if Options.OriginalControls == false4536Player.ActionSpindash = Player_Action_Spindash_S24537else4538Player.ActionSpindash = Player_Action_Spindash_CD4539end if4540end if45414542if Stage.PlayerListPos == PLAYER_KNUCKLES4543Player.JumpStrength = 0x600004544Player.JumpAbility = Player_Action_DblJumpKnux4545Player.ActionPeelout = Player_Action_Jump4546if Options.OriginalControls == false4547Player.ActionSpindash = Player_Action_Spindash_S24548else4549Player.ActionSpindash = Player_Action_Spindash_CD4550end if4551end if45524553if Stage.PlayerListPos == PLAYER_AMY4554Player.JumpAbility = Player_Action_DblJumpAmy4555Player.ActionPeelout = Player_Action_Jump4556if Options.OriginalControls == false4557Player.ActionSpindash = Player_Action_Spindash_S24558else4559Player.ActionSpindash = Player_Action_Spindash_CD4560end if4561end if45624563CallFunction(Player_SetJumpOffset)45644565GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")4566GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")4567GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")4568GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")4569GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")4570GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")4571GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")4572GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")4573GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")4574ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)4575#endplatform4576end function45774578sub ObjectMain4579// Only PC had access to debug mode, so here's a hack to prevent it on mobile4580TempValue0 = false4581#platform: Standard4582TempValue0 = Stage.DebugMode4583#endplatform45844585if TempValue0 == true4586if KeyPress[1].ButtonB == true // Turn Debug Mode4587Object.Type = TypeName[Debug Mode]45884589if Stage.PlayerListPos != PLAYER_SONIC_A // PLAYER_SONIC in origins4590Object[+1].Type = TypeName[Blank Object]4591end if45924593Player.YVelocity = 04594Player.State = Player_State_Static4595Player.Frame = 04596Player.Rotation = 045974598Player.ObjectInteraction = false4599Player.TileCollisions = true4600Player.DrawOrder = 446014602Player.AbilityTimer = 04603Player.MinRollSpeed = 046044605Screen.CameraEnabled = true4606Screen.CameraStyle = Options.OriginalControls4607else4608// Handle Player4609CallFunction(Player_ProcessUpdate)4610CallFunction(Player.State)4611ProcessAnimation()46124613if Player.Animation == ANI_JUMPING4614Screen.AdjustCameraY = Player.JumpOffset4615else4616if Screen.AdjustCameraY == Player.JumpOffset4617Screen.AdjustCameraY = 04618Player.iYPos += Player.JumpOffset4619end if4620end if46214622if Player.YVelocity > 0x1000004623Player.YVelocity = 0x1000004624end if46254626PlayerTileCollision()46274628if CheckResult == true4629if Player.Animation == ANI_JUMPING4630if Player.Down == false4631Player.Animation = ANI_WALKING4632Screen.AdjustCameraY = 04633Player.iYPos += Player.JumpOffset4634end if4635end if4636end if4637end if4638else4639// Mobile version ObjectMain starts here, since there wasn't a debug mode4640// Handle Player4641CallFunction(Player_ProcessUpdate)4642CallFunction(Player.State)46434644#platform: Use_Origins4645if Player.DropDashCharge >= 204646if Player.Animation == ANI_JUMPING4647Player.Frame = 04648Player.AnimationTimer = 04649Player.AnimationSpeed = 14650end if4651end if4652#endplatform46534654ProcessAnimation()46554656if Player.Animation == ANI_JUMPING4657Screen.AdjustCameraY = Player.JumpOffset4658else4659if Screen.AdjustCameraY == Player.JumpOffset4660Screen.AdjustCameraY = 04661Player.iYPos += Player.JumpOffset4662end if4663end if46644665if Player.YVelocity > 0x1000004666Player.YVelocity = 0x1000004667end if46684669PlayerTileCollision()4670if CheckResult == true4671if Player.Animation == ANI_JUMPING4672if Player.Down == false4673Player.Animation = ANI_WALKING4674Screen.AdjustCameraY = 04675Player.iYPos += Player.JumpOffset4676end if4677end if4678end if4679end if4680end sub468146824683sub ObjectDraw4684if Player.Animation != Player.PrevAnimation4685Player.PrevAnimation = Player.Animation4686Player.Frame = 04687Player.AnimationTimer = 04688Player.AnimationSpeed = 04689end if46904691DrawPlayerAnimation()4692end sub469346944695sub ObjectStartup4696#platform: Use_Origins4697// I feel like I got spoiled on a Knuckles route...4698TempValue0 = false4699CheckGreater(Warp.Timer, 204)4700TempValue0 |= CheckResult4701TempValue0 &= Mini_PlayerFlag4702Mini_PlayerFlag = TempValue04703Warp.Timer = 047044705if Options.AttractMode == false4706if Options.StageSelectFlag == false4707ReadSaveRAM()4708end if4709end if47104711// Origins Plus includes new start positions for Knuckles in some levels4712ArrayPos1 = 324713TempValue5 = 04714TempValue6 = 04715while ArrayPos1 < 10564716// So now we have to check how many player objects the game found4717if Object[ArrayPos1].Type == TypeName[Player Object]4718TempValue5++4719end if4720ArrayPos1++4721loop47224723// We found multiple spawn points, now check which one to use4724if TempValue5 > 14725ArrayPos1 = 324726TempValue7 = 04727while ArrayPos1 < 10564728if Object[ArrayPos1].Type == TypeName[Player Object]4729// The standard spawnpoint4730if Object[ArrayPos1].PropertyValue == 04731TempValue7 = ArrayPos14732end if47334734// Character specific spawnpoint4735if Object[ArrayPos1].PropertyValue == Stage.PlayerListPos4736TempValue6 = ArrayPos14737ArrayPos1 = 10564738end if4739end if4740ArrayPos1++4741loop47424743// If we didn't find a special spawnpoint, just use the regular one4744if TempValue6 == 04745TempValue6 = TempValue74746end if4747end if47484749// Get rid of all spawnpoints except the one we're going to use4750TempValue7 = 04751ArrayPos0 = 324752while ArrayPos0 < 10564753if Object[ArrayPos0].Type == TypeName[Player Object]4754if TempValue5 > 14755if ArrayPos0 == TempValue64756CallFunction(Player_Setup_Startup)4757else4758ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)4759end if4760else4761TempValue7 = ArrayPos04762end if4763end if4764ArrayPos0++4765loop47664767if TempValue7 > 04768ArrayPos0 = TempValue74769CallFunction(Player_Setup_Startup)4770end if4771#endplatform47724773#platform: Use_Standalone4774ArrayPos0 = 324775while ArrayPos0 < 10564776if Object[ArrayPos0].Type == TypeName[Player Object]4777switch Stage.PlayerListPos4778case PLAYER_SONIC_A4779ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)4780Player.XPos = Object[ArrayPos0].XPos4781Player.YPos = Object[ArrayPos0].YPos47824783LoadAnimation("Sonic.Ani")4784BindPlayerToObject(0, 0)47854786Player.State = Player_State_Air47874788Player.Priority = PRIORITY_ACTIVE47894790Player.DrawOrder = 447914792Player.TopSpeed = 0x600004793Player.Acceleration = 0xC004794Player.Deceleration = 0xC004795Player.AirAcceleration = 0x18004796Player.AirDeceleration = 0x6004797Player.GravityStrength = 0x38004798Player.JumpStrength = 0x680004799Player.JumpCap = -0x400004800Player.RollingDeceleration = 0x200048014802Player.JumpOffset = -548034804Player.JumpAbility = Player_State_Static4805if Options.OriginalControls == false4806Player.ActionPeelout = Player_Action_Peelout_S24807Player.ActionSpindash = Player_Action_Spindash_S24808else4809Player.ActionPeelout = Player_Action_Peelout_CD4810Player.ActionSpindash = Player_Action_Spindash_CD4811end if4812break48134814case PLAYER_TAILS_A4815ResetObjectEntity(0, TypeName[Player Object], 0, Object[ArrayPos0].XPos, Object[ArrayPos0].YPos)4816Player.XPos = Object[ArrayPos0].XPos4817Player.YPos = Object[ArrayPos0].YPos48184819LoadAnimation("Tails.Ani")4820BindPlayerToObject(0, 0)48214822Player.State = Player_State_Air4823Player.Priority = PRIORITY_ACTIVE4824Player.DrawOrder = 448254826Player.TopSpeed = 0x600004827Player.Acceleration = 0xC004828Player.Deceleration = 0xC004829Player.AirAcceleration = 0x18004830Player.AirDeceleration = 0x6004831Player.GravityStrength = 0x38004832Player.JumpStrength = 0x680004833Player.JumpCap = -0x400004834Player.RollingDeceleration = 0x200048354836Player.JumpOffset = -148374838Player.JumpAbility = Player_Action_DblJumpTails4839Player.ActionPeelout = Player_Action_Jump4840if Options.OriginalControls == false4841Player.ActionSpindash = Player_Action_Spindash_S24842else4843Player.ActionSpindash = Player_Action_Spindash_CD4844end if4845break48464847end switch48484849GetAnimationByName(ANI_SPINNING_TOP, "Spinning Top")4850GetAnimationByName(ANI_RAMP_RUNNING1, "3D Ramp 1")4851GetAnimationByName(ANI_RAMP_RUNNING2, "3D Ramp 2")4852GetAnimationByName(ANI_RAMP_RUNNING3, "3D Ramp 3")4853GetAnimationByName(ANI_RAMP_RUNNING4, "3D Ramp 4")4854GetAnimationByName(ANI_RAMP_RUNNING5, "3D Ramp 5")4855GetAnimationByName(ANI_RAMP_RUNNING6, "3D Ramp 6")4856GetAnimationByName(ANI_ROLL3D, "3D Ramp 7")4857GetAnimationByName(ANI_SIZE_CHANGE, "Size Change")48584859ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)4860end if48614862ArrayPos0++4863loop4864#endplatform4865end sub486648674868// ========================4869// Editor Subs4870// ========================48714872// All of the Character ID stuff is specific to Origins Plus, other versions of the game don't check or use the PropertyValue48734874sub RSDKEdit4875if Editor.ReturnVariable == true4876switch Editor.VariableID4877case EDIT_VAR_PROPVAL // Property Value4878CheckResult = Object.PropertyValue4879break4880case 0 // Character ID4881CheckResult = Object.PropertyValue4882break4883end switch4884else4885switch Editor.VariableID4886case EDIT_VAR_PROPVAL // Property Value4887Object.PropertyValue = Editor.VariableValue4888break4889case 0 // Character ID4890Object.PropertyValue = Editor.VariableValue4891break4892end switch4893end if4894end sub489548964897sub RSDKDraw4898switch Object.PropertyValue4899default4900LoadSpriteSheet("Players/Sonic1.gif")4901DrawSprite(0)4902break49034904case 14905LoadSpriteSheet("Players/Tails1.gif")4906DrawSprite(1)4907break49084909case 24910LoadSpriteSheet("Players/KTE1.gif")4911DrawSprite(2)4912break49134914case 54915LoadSpriteSheet("Players/Amy1.gif")4916DrawSprite(3)4917break4918end switch4919end sub492049214922sub RSDKLoad4923LoadSpriteSheet("Players/Sonic1.gif")4924SpriteFrame(-16, -19, 28, 39, 1, 1) // Sonic Standing Frame49254926LoadSpriteSheet("Players/Tails1.gif")4927SpriteFrame(-12, -12, 24, 32, 1, 1) // Tails Standing Frame49284929LoadSpriteSheet("Players/KTE1.gif")4930SpriteFrame(-14, -20, 26, 40, 1, 1) // Knuckles Standing Frame49314932LoadSpriteSheet("Players/Amy1.gif")4933SpriteFrame(-12, -15, 21, 35, 45, 1) // Amy Standing Frame49344935AddEditorVariable("Character ID (Origins Plus)")4936SetActiveVariable("Character ID (Origins Plus)")4937AddEnumVariable("Sonic", PLAYER_SONIC_A)4938AddEnumVariable("Tails", PLAYER_TAILS_A)4939AddEnumVariable("Knuckles", PLAYER_KNUCKLES_A)4940AddEnumVariable("Amy", PLAYER_AMY_A)4941end sub494249434944