Path: blob/main/Scripts/Global/RedSpring.txt
1319 views
//----------------Sonic CD Red Spring Script------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.ActiveSpringFrame6#alias Object.Value2 : Object.Unused // "introduced" in Origins Plus but it isn't really used for anything7#alias Object.Value7 : Object.EnabledInAir // Only has effect on horizontal springs89// Player Aliases10#alias Player.Value7 : Player.AnimationReserve1112// Directions13#alias 0 : FLIP_NONE14#alias 2 : FLIP_Y1516// Gravity17#alias 0 : GRAVITY_GROUND18#alias 1 : GRAVITY_AIR1920// Collision Modes21#alias 0 : CMODE_FLOOR22#alias 2 : CMODE_ROOF2324// Global SFX25#alias 11 : SFX_G_SPRING2627// Property Values28#alias 0 : FACE_FACING_UP29#alias 1 : FACE_FACING_RIGHT30#alias 2 : FACE_FACING_LEFT31#alias 3 : FACE_FACING_DOWN32#alias 4 : FACE_FACING_DIAGONAL_UR33#alias 5 : FACE_FACING_DIAGONAL_UL34#alias 6 : FACE_FACING_DIAGONAL_DR // Actually not facing down when spawned from debug mode35#alias 7 : FACE_FACING_DIAGONAL_DL // Actually not facing down when spawned from debug mode363738sub ObjectPlayerInteraction39switch Object.PropertyValue40case FACE_FACING_UP41TempValue0 = false42if Player.Gravity == GRAVITY_AIR43TempValue0 = true44end if4546if Player.CollisionMode > CMODE_FLOOR47if Player.YVelocity < 048TempValue0 = true49end if50end if5152if TempValue0 == false53PlayerObjectCollision(C_BOX, -16, -8, 16, 8)5455PlayerObjectCollision(C_TOUCH, -16, -10, 16, -6)56#platform: Use_Origins57if CheckResult == true58if Stage.PlayerListPos == PLAYER_KNUCKLES59if Player.State == Player_State_LedgePullUp60CheckResult = false61Object.Unused = 162end if63end if64end if65#endplatform66if CheckResult == true67Player.AnimationReserve = ANI_WALKING6869if Player.Animation == ANI_RUNNING70Player.AnimationReserve = ANI_RUNNING71end if7273if Player.Animation == ANI_PEELOUT74Player.AnimationReserve = ANI_PEELOUT75end if7677Object.ActiveSpringFrame = 17879#platform: Use_Origins80Player.State = Player_State_Air_NoDropDash81#endplatform8283#platform: Use_Standalone84Player.State = Player_State_Air85#endplatform8687Player.Gravity = GRAVITY_AIR88Player.YVelocity = -0x10000089Player.Animation = ANI_BOUNCING90Player.Timer = 09192PlaySfx(SFX_G_SPRING, false)9394#platform: Use_Haptics95HapticEffect(9, 0, 0, 0)96#endplatform9798end if99else100if Player.YVelocity >= 0101PlayerObjectCollision(C_PLATFORM, -16, -8, 16, 8)102103PlayerObjectCollision(C_TOUCH, -16, -10, 16, -6)104#platform: Use_Origins105if CheckResult == true106if Stage.PlayerListPos == PLAYER_KNUCKLES107if Player.State == Player_State_LedgePullUp108CheckResult = false109Object.Unused = 1110end if111end if112end if113#endplatform114if CheckResult == true115116Player.AnimationReserve = ANI_WALKING117118if Player.Animation == ANI_RUNNING119Player.AnimationReserve = ANI_RUNNING120end if121122if Player.Animation == ANI_PEELOUT123Player.AnimationReserve = ANI_PEELOUT124end if125126Object.ActiveSpringFrame = 1127128#platform: Use_Origins129Player.State = Player_State_Air_NoDropDash130#endplatform131132#platform: Use_Standalone133Player.State = Player_State_Air134#endplatform135136Player.Gravity = GRAVITY_AIR137Player.YVelocity = -0x100000138Player.Animation = ANI_BOUNCING139Player.Timer = 0140141PlaySfx(SFX_G_SPRING, false)142143#platform: Use_Haptics144HapticEffect(9, 0, 0, 0)145#endplatform146147end if148end if149end if150break151152case FACE_FACING_RIGHT153PlayerObjectCollision(C_BOX, -8, -16, 8, 16)154#platform: Use_Origins155if Player.Animation != ANI_GLIDING156#endplatform157if Player.Gravity == GRAVITY_GROUND158159PlayerObjectCollision(C_TOUCH, 6, -15, 11, 15)160if CheckResult == true161#platform: Use_Origins162CheckResult = false163if Player.State == Player_State_GlideSlide164CheckResult = true165end if166if Player.State == Player_State_HammerDash167CheckResult = true168end if169if CheckResult == true170Player.State = Player_State_Ground171end if172#endplatform173Object.ActiveSpringFrame = 1174175Player.Angle = 0176Player.Speed = 0x100000177Player.CollisionMode = CMODE_FLOOR178Player.Pushing = false179Player.Direction = FACING_RIGHT180Player.ControlLock = 16181182PlaySfx(SFX_G_SPRING, false)183#platform: Use_Haptics184HapticEffect(9, 0, 0, 0)185#endplatform186end if187else188if Object.EnabledInAir == true189PlayerObjectCollision(C_TOUCH, 6, -15, 11, 15)190if CheckResult == true191#platform: Use_Origins192CheckResult = false193if Player.State == Player_State_GlideSlide194CheckResult = true195end if196if Player.State == Player_State_HammerDash197CheckResult = true198end if199if CheckResult == true200Player.State = Player_State_Ground201end if202#endplatform203Object.ActiveSpringFrame = 1204205Player.Angle = 0206Player.Speed = 0x100000207Player.CollisionMode = CMODE_FLOOR208Player.Pushing = false209Player.Direction = FACING_RIGHT210Player.ControlLock = 16211212PlaySfx(SFX_G_SPRING, false)213214#platform: Use_Haptics215HapticEffect(9, 0, 0, 0)216#endplatform217218end if219end if220end if221#platform: Use_Origins222end if223#endplatform224break225226case FACE_FACING_LEFT227PlayerObjectCollision(C_BOX, -8, -16, 8, 16)228#platform: Use_Origins229if Player.Animation != ANI_GLIDING230#endplatform231if Player.Gravity == GRAVITY_GROUND232233PlayerObjectCollision(C_TOUCH, -10, -15, -6, 15)234if CheckResult == true235#platform: Use_Origins236CheckResult = false237if Player.State == Player_State_GlideSlide238CheckResult = true239end if240if Player.State == Player_State_HammerDash241CheckResult = true242end if243if CheckResult == true244Player.State = Player_State_Ground245end if246#endplatform247Object.ActiveSpringFrame = 1248249Player.Speed = -0x100000250Player.CollisionMode = CMODE_FLOOR251Player.Pushing = false252Player.Direction = FACING_LEFT253Player.ControlLock = 16254255PlaySfx(SFX_G_SPRING, false)256#platform: Use_Haptics257HapticEffect(9, 0, 0, 0)258#endplatform259end if260else261if Object.EnabledInAir == true262PlayerObjectCollision(C_TOUCH, -10, -15, -6, 15)263if CheckResult == true264#platform: Use_Origins265CheckResult = false266if Player.State == Player_State_GlideSlide267CheckResult = true268end if269if Player.State == Player_State_HammerDash270CheckResult = true271end if272if CheckResult == true273Player.State = Player_State_Ground274end if275#endplatform276Object.ActiveSpringFrame = 1277278Player.Speed = -0x100000279Player.YVelocity = 0x20000280Player.CollisionMode = CMODE_FLOOR281Player.Pushing = false282Player.Direction = FACING_LEFT283Player.ControlLock = 16284285PlaySfx(SFX_G_SPRING, false)286287#platform: Use_Haptics288HapticEffect(9, 0, 0, 0)289#endplatform290291end if292end if293end if294#platform: Use_Origins295end if296#endplatform297break298299case FACE_FACING_DOWN300PlayerObjectCollision(C_BOX, -16, -8, 16, 8)301PlayerObjectCollision(C_TOUCH, -15, 6, 15, 10)302if CheckResult == true303if Player.CollisionMode == CMODE_ROOF304FlipSign(Player.Speed)305FlipSign(Player.XVelocity)306end if307Object.ActiveSpringFrame = 1308309#platform: Use_Origins310Player.State = Player_State_Air_NoDropDash311#endplatform312313#platform: Use_Standalone314Player.State = Player_State_Air315#endplatform316317Player.Gravity = GRAVITY_AIR318Player.YVelocity = 0x100000319Player.Timer = 0320321PlaySfx(SFX_G_SPRING, false)322323#platform: Use_Haptics324HapticEffect(9, 0, 0, 0)325#endplatform326327end if328break329330case FACE_FACING_DIAGONAL_UR331PlayerObjectCollision(C_TOUCH, -12, -16, 12, 12)332#platform: Use_Origins333if CheckResult == true334if Stage.PlayerListPos == PLAYER_KNUCKLES335if Player.State == Player_State_LedgePullUp336CheckResult = false337Object.Unused = 1338end if339end if340end if341#endplatform342if Player.Gravity == GRAVITY_GROUND343if CheckResult == true344Object.ActiveSpringFrame = 1345346#platform: Use_Origins347Player.State = Player_State_Air_NoDropDash348#endplatform349350#platform: Use_Standalone351Player.State = Player_State_Air352#endplatform353354Player.Gravity = GRAVITY_AIR355Player.Speed = 0xB4000356Player.YVelocity = -0xB4000357Player.Animation = ANI_WALKING358Player.Direction = FACING_RIGHT359Player.Timer = 0360361PlaySfx(SFX_G_SPRING, false)362363#platform: Use_Haptics364HapticEffect(9, 0, 0, 0)365#endplatform366367end if368end if369if Player.YVelocity >= 0370if CheckResult == true371Object.ActiveSpringFrame = 1372373#platform: Use_Origins374Player.State = Player_State_Air_NoDropDash375#endplatform376377#platform: Use_Standalone378Player.State = Player_State_Air379#endplatform380381Player.Gravity = GRAVITY_AIR382Player.Speed = 0xB4000383Player.YVelocity = -0xB4000384Player.Animation = ANI_WALKING385Player.Direction = FACING_RIGHT386Player.Timer = 0387388PlaySfx(SFX_G_SPRING, false)389390#platform: Use_Haptics391HapticEffect(9, 0, 0, 0)392#endplatform393394end if395end if396break397398case FACE_FACING_DIAGONAL_UL399PlayerObjectCollision(C_TOUCH, -12, -16, 12, 12)400#platform: Use_Origins401if CheckResult == true402if Stage.PlayerListPos == PLAYER_KNUCKLES403if Player.State == Player_State_LedgePullUp404CheckResult = false405Object.Unused = 1406end if407end if408end if409#endplatform410if Player.YVelocity >= 0411if CheckResult == true412Object.ActiveSpringFrame = 1413414#platform: Use_Origins415Player.State = Player_State_Air_NoDropDash416#endplatform417418#platform: Use_Standalone419Player.State = Player_State_Air420#endplatform421422Player.Gravity = GRAVITY_AIR423Player.Speed = -0xB4000424Player.YVelocity = -0xB4000425Player.Animation = ANI_WALKING426Player.Direction = FACING_LEFT427Player.Timer = 0428429PlaySfx(SFX_G_SPRING, false)430431#platform: Use_Haptics432HapticEffect(9, 0, 0, 0)433#endplatform434435end if436end if437if Player.Gravity == GRAVITY_GROUND438if CheckResult == true439Object.ActiveSpringFrame = 1440441#platform: Use_Origins442Player.State = Player_State_Air_NoDropDash443#endplatform444445#platform: Use_Standalone446Player.State = Player_State_Air447#endplatform448449Player.Gravity = GRAVITY_AIR450Player.Speed = -0xB4000451Player.YVelocity = -0xB4000452Player.Animation = ANI_WALKING453Player.Direction = FACING_LEFT454Player.Timer = 0455456PlaySfx(SFX_G_SPRING, false)457458#platform: Use_Haptics459HapticEffect(9, 0, 0, 0)460#endplatform461462end if463end if464break465466case FACE_FACING_DIAGONAL_DR467PlayerObjectCollision(C_TOUCH, -12, -12, 12, 12)468if CheckResult == true469Object.ActiveSpringFrame = 1470471#platform: Use_Origins472Player.State = Player_State_Air_NoDropDash473#endplatform474475#platform: Use_Standalone476Player.State = Player_State_Air477#endplatform478479Player.Gravity = GRAVITY_AIR480Player.Speed = 0xB4000481Player.YVelocity = 0xB4000482Player.Timer = 0483PlaySfx(SFX_G_SPRING, false)484485#platform: Use_Haptics486HapticEffect(9, 0, 0, 0)487#endplatform488489end if490break491492case FACE_FACING_DIAGONAL_DL493PlayerObjectCollision(C_TOUCH, -12, -12, 12, 12)494if CheckResult == true495Object.ActiveSpringFrame = 1496497#platform: Use_Origins498Player.State = Player_State_Air_NoDropDash499#endplatform500501#platform: Use_Standalone502Player.State = Player_State_Air503#endplatform504505Player.Gravity = GRAVITY_AIR506Player.Speed = -0xB4000507Player.YVelocity = 0xB4000508Player.Timer = 0509510PlaySfx(SFX_G_SPRING, false)511512#platform: Use_Haptics513HapticEffect(9, 0, 0, 0)514#endplatform515516end if517break518end switch519end sub520521522sub ObjectDraw523if Object.ActiveSpringFrame == 0524DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)525else526Object.ActiveSpringFrame++527528TempValue0 = Object.ActiveSpringFrame529TempValue0 >>= 1530switch TempValue0531case 0532case 1533DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)534break535536case 2537case 6538TempValue1 = Object.PropertyValue539TempValue1 += 8540DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)541break542543case 3544case 4545case 5546TempValue1 = Object.PropertyValue547TempValue1 += 16548DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)549break550551end switch552553if Object.ActiveSpringFrame > 12554Object.ActiveSpringFrame = 0555end if556end if557end sub558559560sub ObjectStartup561LoadSpriteSheet("Global/Items.gif")562563// Springs564SpriteFrame(-16, -8, 32, 16, 84, 1) // #0 - Red Spring facing up565SpriteFrame(-8, -16, 16, 32, 117, 1) // #1 - Red Spring facing right566SpriteFrame(-8, -16, 16, 32, 175, 1) // #2 - Red Spring facing left567SpriteFrame(-16, -8, 32, 16, 84, 59) // #3 - Red Spring facing down568SpriteFrame(-16, -16, 32, 32, 84, 117) // #4 - Red Spring facing diagonal right569SpriteFrame(-16, -16, 32, 32, 117, 165) // #5 - Red Spring facing diagonal left570SpriteFrame(-16, -16, 32, 32, 84, 117) // #6 - Red Spring facing diagonal right 2571SpriteFrame(-16, -16, 32, 32, 117, 165) // #7 - Red Spring facing diagonal left 2572573// Spring Recoil574SpriteFrame(-16, 0, 32, 8, 84, 1) // #8 - Red Spring Head facing up575SpriteFrame(-8, -16, 8, 32, 125, 1) // #9 - Red Spring Head facing right576SpriteFrame(0, -16, 8, 32, 175, 1) // #10 - Red Spring Head facing left577SpriteFrame(-16, -8, 32, 8, 84, 67) // #11 - Red Spring Head facing down578SpriteFrame(-16, -16, 32, 32, 84, 150) // #12 - Red Spring Recoiled diagonal right579SpriteFrame(-16, -16, 32, 32, 150, 165) // #13 - Red Spring Recoiled diagonal left580SpriteFrame(-16, -16, 32, 32, 84, 150) // #14 - Red Spring Recoiled diagonal right 2581SpriteFrame(-16, -16, 32, 32, 150, 165) // #15 - Red Spring Recoiled diagonal left 2582// Spring Launch583SpriteFrame(-16, -32, 32, 40, 84, 18) // #16 - Red Spring Launch facing up584SpriteFrame(-8, -16, 40, 32, 134, 1) // #17 - Red Spring Launch facing right585SpriteFrame(-16, -16, 40, 32, 192, 1) // #18 - Red Spring Launch facing left586SpriteFrame(-16, -8, 32, 40, 84, 76) // #19 - Red Spring Launch facing down587SpriteFrame(-16, -32, 48, 48, 117, 34) // #20 - Red Spring Launch diagonal right588SpriteFrame(-32, -32, 48, 48, 166, 34) // #21 - Red Spring Launch diagonal left589SpriteFrame(-16, -32, 48, 48, 117, 34) // #22 - Red Spring Launch diagonal right 2590SpriteFrame(-32, -32, 48, 48, 166, 34) // #23 - Red Spring Launch diagonal left 2591592// Used to be below LoadSpriteSheet, moved here for consistency593ArrayPos0 = 32594while ArrayPos0 < 1056595if Object[ArrayPos0].Type == TypeName[Red Spring]596if Object[ArrayPos0].PropertyValue > 7597Object[ArrayPos0].PropertyValue -= 8598Object[ArrayPos0].EnabledInAir = true599end if600601if Object[ArrayPos0].PropertyValue > 5602Object[ArrayPos0].Direction = FLIP_Y603end if604end if605ArrayPos0++606loop607end sub608609610// ========================611// Editor Subs612// ========================613614sub RSDKEdit615if Editor.ReturnVariable == true616switch Editor.VariableID617case EDIT_VAR_PROPVAL // property value618CheckResult = Object.PropertyValue619break620621case 0 // flipFlags622CheckResult = Object.PropertyValue623CheckResult &= 7624break625626case 1 // enabledInAir627GetBit(CheckResult, Object.PropertyValue, 3)628break629630end switch631else632switch Editor.VariableID633case EDIT_VAR_PROPVAL // property value634Object.PropertyValue = Editor.VariableValue635break636637case 0 // flipFlags638TempValue0 = 7639Not(TempValue0)640Object.PropertyValue &= TempValue0641Editor.VariableValue &= 7642643Object.PropertyValue |= Editor.VariableValue644break645646case 1 // enabledInAir647CheckNotEqual(Editor.VariableValue, false)648SetBit(Object.PropertyValue, 3, CheckResult)649break650651end switch652end if653end sub654655656sub RSDKDraw657if Object.PropertyValue > 5658// Fun little fact - the official RSDKv3 editor displayed down diagonal springs wrong659// Here though, we may as well right that660Object.Direction = FLIP_Y661else662Object.Direction = FLIP_NONE663end if664665TempValue0 = Object.PropertyValue666TempValue0 &= 7667668DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)669end sub670671672sub RSDKLoad673LoadSpriteSheet("Global/Items.gif")674SpriteFrame(-16, -8, 32, 16, 84, 1) // #0 - Red Spring facing up675SpriteFrame(-8, -16, 16, 32, 117, 1) // #1 - Red Spring facing right676SpriteFrame(-8, -16, 16, 32, 175, 1) // #2 - Red Spring facing left677SpriteFrame(-16, -8, 32, 16, 84, 59) // #3 - Red Spring facing down678SpriteFrame(-16, -16, 32, 32, 84, 117) // #4 - Red Spring facing diagonal right679SpriteFrame(-16, -16, 32, 32, 117, 165) // #5 - Red Spring facing diagonal left680SpriteFrame(-16, -16, 32, 32, 84, 117) // #6 - Red Spring facing diagonal right 2681SpriteFrame(-16, -16, 32, 32, 117, 165) // #7 - Red Spring facing diagonal left 2682683AddEditorVariable("Type")684SetActiveVariable("Type")685AddEnumVariable("Up", 0)686AddEnumVariable("Right", 1)687AddEnumVariable("Left", 2)688AddEnumVariable("Down", 3)689AddEnumVariable("Diagonal (Up Right)", 4)690AddEnumVariable("Diagonal (Up Left)", 5)691AddEnumVariable("Diagonal (Down Right)", 6)692AddEnumVariable("Diagonal (Down Right)", 7)693694AddEditorVariable("EnabledInAir")695SetActiveVariable("EnabledInAir")696AddEnumVariable("False", false)697AddEnumVariable("True", true)698end sub699700701