Path: blob/main/Scripts/Global/YellowSpring.txt
1319 views
//---------------Sonic CD Yellow Spring Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.ActiveSpring6#alias Object.Value2 : Object.Unused // "introduced" in Origins Plus but it isn't really used for anything78// Player Aliases9#alias Player.Value7 : Player.AnimationReserve1011// Gravity12#alias 0 : GRAVITY_GROUND13#alias 1 : GRAVITY_AIR1415// Collision Modes16#alias 0 : CMODE_FLOOR17#alias 2 : CMODE_ROOF1819// Directions20#alias 2 : FLIP_Y2122// Global SFX23#alias 11 : SFX_G_SPRING2425// Property Values26#alias 0 : FACE_FACING_UP27#alias 1 : FACE_FACING_RIGHT28#alias 2 : FACE_FACING_LEFT29#alias 3 : FACE_FACING_DOWN30#alias 4 : FACE_FACING_DIAGONAL_UR31#alias 5 : FACE_FACING_DIAGONAL_UL32#alias 6 : FACE_FACING_DIAGONAL_DR // Not actually facing down when spawned from debug mode33#alias 7 : FACE_FACING_DIAGONAL_DL // Not actually facing down when spawned from debug mode343536sub ObjectPlayerInteraction37switch Object.PropertyValue38case FACE_FACING_UP39TempValue0 = false4041if Player.Gravity == GRAVITY_AIR42TempValue0 = true43end if4445if Player.CollisionMode > CMODE_FLOOR46if Player.YVelocity < 047TempValue0 = true48end if49end if5051if TempValue0 == false52PlayerObjectCollision(C_BOX, -16, -8, 16, 8)5354PlayerObjectCollision(C_TOUCH, -16, -10, 16, -6)55#platform: Use_Origins56if CheckResult == true57if Stage.PlayerListPos == PLAYER_KNUCKLES58if Player.State == Player_State_LedgePullUp59CheckResult = false60Object.Unused = 161end if62end if63end if64#endplatform65if CheckResult == true66Player.AnimationReserve = ANI_WALKING6768if Player.Animation == ANI_RUNNING69Player.AnimationReserve = ANI_RUNNING70end if7172if Player.Animation == ANI_PEELOUT73Player.AnimationReserve = ANI_PEELOUT74end if7576Object.ActiveSpring = true7778#platform: Use_Origins79Player.State = Player_State_Air_NoDropDash80#endplatform8182#platform: Use_Standalone83Player.State = Player_State_Air84#endplatform8586Player.Gravity = GRAVITY_AIR87Player.YVelocity = -0xA000088Player.Animation = ANI_BOUNCING89Player.Timer = 09091PlaySfx(SFX_G_SPRING, false)9293#platform: Use_Haptics94HapticEffect(10, 0, 0, 0)95#endplatform9697end if98else99if Player.YVelocity >= 0100PlayerObjectCollision(C_PLATFORM, -16, -8, 16, 8)101102PlayerObjectCollision(C_TOUCH, -16, -10, 16, -6)103#platform: Use_Origins104if CheckResult == true105if Stage.PlayerListPos == PLAYER_KNUCKLES106if Player.State == Player_State_LedgePullUp107CheckResult = false108Object.Unused = 1109end if110end if111end if112#endplatform113if CheckResult == true114Player.AnimationReserve = ANI_WALKING115116if Player.Animation == ANI_RUNNING117Player.AnimationReserve = ANI_RUNNING118end if119120if Player.Animation == ANI_PEELOUT121Player.AnimationReserve = ANI_PEELOUT122end if123124Object.ActiveSpring = true125126#platform: Use_Origins127Player.State = Player_State_Air_NoDropDash128#endplatform129130#platform: Use_Standalone131Player.State = Player_State_Air132#endplatform133134Player.Gravity = GRAVITY_AIR135Player.YVelocity = -0xA0000136Player.Animation = ANI_BOUNCING137Player.Timer = 0138139PlaySfx(SFX_G_SPRING, false)140141#platform: Use_Haptics142HapticEffect(10, 0, 0, 0)143#endplatform144145end if146end if147end if148break149150case FACE_FACING_RIGHT151PlayerObjectCollision(C_BOX, -8, -16, 8, 16)152#platform: Use_Origins153if Player.Animation != ANI_GLIDING154#endplatform155if Player.Gravity == GRAVITY_GROUND156157PlayerObjectCollision(C_TOUCH, 6, -15, 10, 15)158if CheckResult == true159#platform: Use_Origins160CheckResult = false161if Player.State == Player_State_GlideSlide162CheckResult = true163end if164if Player.State == Player_State_HammerDash165CheckResult = true166end if167if CheckResult == true168Player.State = Player_State_Ground169end if170#endplatform171Object.ActiveSpring = true172173Player.Speed = 0xA0000174Player.CollisionMode = CMODE_FLOOR175Player.Pushing = false176Player.Direction = FACING_RIGHT177Player.ControlLock = 16178179PlaySfx(SFX_G_SPRING, false)180181#platform: Use_Haptics182HapticEffect(10, 0, 0, 0)183#endplatform184185end if186end if187#platform: Use_Origins188end if189#endplatform190break191192case FACE_FACING_LEFT193PlayerObjectCollision(C_BOX, -8, -16, 8, 16)194#platform: Use_Origins195if Player.Animation != ANI_GLIDING196#endplatform197if Player.Gravity == GRAVITY_GROUND198199PlayerObjectCollision(C_TOUCH, -10, -15, -6, 15)200if CheckResult == true201#platform: Use_Origins202CheckResult = false203if Player.State == Player_State_GlideSlide204CheckResult = true205end if206if Player.State == Player_State_HammerDash207CheckResult = true208end if209if CheckResult == true210Player.State = Player_State_Ground211end if212#endplatform213Object.ActiveSpring = true214Player.Speed = -0xA0000215Player.CollisionMode = CMODE_FLOOR216Player.Pushing = false217Player.Direction = FACING_LEFT218Player.ControlLock = 16219220PlaySfx(SFX_G_SPRING, false)221222#platform: Use_Haptics223HapticEffect(10, 0, 0, 0)224#endplatform225226end if227end if228#platform: Use_Origins229end if230#endplatform231break232233case FACE_FACING_DOWN234PlayerObjectCollision(C_BOX, -16, -8, 16, 8)235236PlayerObjectCollision(C_TOUCH, -15, 6, 15, 10)237if CheckResult == true238Object.ActiveSpring = true239if Player.CollisionMode == CMODE_ROOF240FlipSign(Player.Speed)241FlipSign(Player.XVelocity)242end if243244#platform: Use_Origins245Player.State = Player_State_Air_NoDropDash246#endplatform247248#platform: Use_Standalone249Player.State = Player_State_Air250#endplatform251252Player.Gravity = GRAVITY_AIR253Player.YVelocity = 0xA0000254Player.Timer = 0255256PlaySfx(SFX_G_SPRING, false)257258#platform: Use_Haptics259HapticEffect(10, 0, 0, 0)260#endplatform261262end if263break264case FACE_FACING_DIAGONAL_UR265PlayerObjectCollision(C_TOUCH, -12, -16, 12, 12)266#platform: Use_Origins267if CheckResult == true268if Stage.PlayerListPos == PLAYER_KNUCKLES269if Player.State == Player_State_LedgePullUp270CheckResult = false271Object.Unused = 1272end if273end if274end if275#endplatform276if Player.Gravity == GRAVITY_GROUND277if CheckResult == true278Object.ActiveSpring = true279280#platform: Use_Origins281Player.State = Player_State_Air_NoDropDash282#endplatform283284#platform: Use_Standalone285Player.State = Player_State_Air286#endplatform287288Player.Gravity = GRAVITY_AIR289Player.Speed = 0x74000290Player.YVelocity = -0x74000291Player.Animation = ANI_WALKING292Player.Direction = FACING_RIGHT293Player.Timer = 0294295PlaySfx(SFX_G_SPRING, false)296297#platform: Use_Haptics298HapticEffect(10, 0, 0, 0)299#endplatform300301end if302end if303304if Player.YVelocity >= 0305if CheckResult == true306Object.ActiveSpring = true307308#platform: Use_Origins309Player.State = Player_State_Air_NoDropDash310#endplatform311312#platform: Use_Standalone313Player.State = Player_State_Air314#endplatform315316Player.Gravity = GRAVITY_AIR317Player.Speed = 0x74000318Player.YVelocity = -0x74000319Player.Animation = ANI_WALKING320Player.Direction = FACING_RIGHT321Player.Timer = 0322323PlaySfx(SFX_G_SPRING, false)324325#platform: Use_Haptics326HapticEffect(10, 0, 0, 0)327#endplatform328329end if330end if331break332333case FACE_FACING_DIAGONAL_UL334PlayerObjectCollision(C_TOUCH, -12, -16, 12, 12)335#platform: Use_Origins336if CheckResult == true337if Stage.PlayerListPos == PLAYER_KNUCKLES338if Player.State == Player_State_LedgePullUp339CheckResult = false340Object.Unused = 1341end if342end if343end if344#endplatform345if Player.Gravity == GRAVITY_GROUND346if CheckResult == true347Object.ActiveSpring = true348349#platform: Use_Origins350Player.State = Player_State_Air_NoDropDash351#endplatform352353#platform: Use_Standalone354Player.State = Player_State_Air355#endplatform356357Player.Gravity = GRAVITY_AIR358Player.Speed = -0x74000359Player.YVelocity = -0x74000360Player.Animation = ANI_WALKING361Player.Direction = FACING_LEFT362Player.Timer = 0363364PlaySfx(SFX_G_SPRING, false)365366#platform: Use_Haptics367HapticEffect(10, 0, 0, 0)368#endplatform369370end if371end if372373if Player.YVelocity >= 0374if CheckResult == true375Object.ActiveSpring = true376377#platform: Use_Origins378Player.State = Player_State_Air_NoDropDash379#endplatform380381#platform: Use_Standalone382Player.State = Player_State_Air383#endplatform384385Player.Gravity = GRAVITY_AIR386Player.Speed = -0x74000387Player.YVelocity = -0x74000388Player.Animation = ANI_WALKING389Player.Direction = FACING_LEFT390Player.Timer = 0391392PlaySfx(SFX_G_SPRING, false)393394#platform: Use_Haptics395HapticEffect(10, 0, 0, 0)396#endplatform397398end if399end if400break401402case FACE_FACING_DIAGONAL_DR403PlayerObjectCollision(C_TOUCH, -12, -12, 12, 12)404#platform: Use_Origins405if CheckResult == true406if Stage.PlayerListPos == PLAYER_KNUCKLES407if Player.State == Player_State_LedgePullUp408CheckResult = false409Object.Unused = 1410end if411end if412end if413#endplatform414if CheckResult == true415Object.ActiveSpring = true416417#platform: Use_Origins418Player.State = Player_State_Air_NoDropDash419#endplatform420421#platform: Use_Standalone422Player.State = Player_State_Air423#endplatform424Player.Gravity = GRAVITY_AIR425Player.Speed = 0x74000426Player.YVelocity = 0x74000427Player.Timer = 0428429PlaySfx(SFX_G_SPRING, false)430431#platform: Use_Haptics432HapticEffect(10, 0, 0, 0)433#endplatform434435end if436break437438case FACE_FACING_DIAGONAL_DL439PlayerObjectCollision(C_TOUCH, -12, -12, 12, 12)440if CheckResult == true441Object.ActiveSpring = true442443#platform: Use_Origins444Player.State = Player_State_Air_NoDropDash445#endplatform446447#platform: Use_Standalone448Player.State = Player_State_Air449#endplatform450Player.Gravity = GRAVITY_AIR451Player.Speed = -0x74000452Player.YVelocity = 0x74000453Player.Timer = 0454455PlaySfx(SFX_G_SPRING, false)456457#platform: Use_Haptics458HapticEffect(10, 0, 0, 0)459#endplatform460461end if462break463end switch464end sub465466467sub ObjectDraw468if Object.ActiveSpring == false469DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)470else471Object.ActiveSpring++472473TempValue0 = Object.ActiveSpring474TempValue0 >>= 1475switch TempValue0476case 0477case 1478DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)479break480481case 2482case 6483TempValue1 = Object.PropertyValue484TempValue1 += 8485DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)486break487488case 3489case 4490case 5491TempValue1 = Object.PropertyValue492TempValue1 += 16493DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)494break495496end switch497498if Object.ActiveSpring > 12499Object.ActiveSpring = false500end if501end if502end sub503504505sub ObjectStartup506LoadSpriteSheet("Global/Items.gif")507508// Springs509SpriteFrame(-16, -8, 32, 16, 84, 183) // #0 - Yellow Spring facing up510SpriteFrame(-8, -16, 16, 32, 215, 116) // #1 - Yellow Spring facing right511SpriteFrame(-8, -16, 16, 32, 232, 116) // #2 - Yellow Spring facing left512SpriteFrame(-16, -8, 32, 16, 184, 239) // #3 - Yellow Spring facing down513SpriteFrame(-16, -16, 32, 32, 183, 165) // #4 - Yellow Spring facing diagonal right514SpriteFrame(-16, -16, 32, 32, 216, 182) // #5 - Yellow Spring facing diagonal left515SpriteFrame(-16, -16, 32, 32, 183, 165) // #6 - Yellow Spring facing diagonal right 2516SpriteFrame(-16, -16, 32, 32, 216, 182) // #7 - Yellow Spring facing diagonal left 2517518// Spring Recoil519SpriteFrame(-16, 0, 32, 8, 84, 183) // #8 - Yellow Spring Head facing up520SpriteFrame(-8, -16, 8, 32, 223, 116) // #9 - Yellow Spring Head facing right521SpriteFrame(0, -16, 8, 32, 232, 116) // #10 - Yellow Spring Head facing left522SpriteFrame(-16, -8, 32, 8, 215, 107) // #11 - Yellow Spring Head facing down523SpriteFrame(-16, -16, 32, 32, 216, 149) // #12 - Yellow Spring Recoiled diagonal right524SpriteFrame(-16, -16, 32, 32, 218, 215) // #13 - Yellow Spring Recoiled diagonal left525SpriteFrame(-16, -16, 32, 32, 216, 149) // #14 - Yellow Spring Recoiled diagonal right 2526SpriteFrame(-16, -16, 32, 32, 218, 215) // #15 - Yellow Spring Recoiled diagonal left 2527// Spring Launch528SpriteFrame(-16, -32, 32, 40, 215, 34) // #16 - Yellow Spring Launch facing up529SpriteFrame(-8, -16, 40, 32, 134, 198) // #17 - Yellow Spring Launch facing right530SpriteFrame(-16, -16, 40, 32, 175, 198) // #18 - Yellow Spring Launch facing left531SpriteFrame(-16, -8, 32, 40, 215, 75) // #19 - Yellow Spring Launch facing down532SpriteFrame(-16, -32, 48, 48, 117, 83) // #20 - Yellow Spring Launch diagonal right533SpriteFrame(-32, -32, 48, 48, 166, 83) // #21 - Yellow Spring Launch diagonal left534SpriteFrame(-16, -32, 48, 48, 117, 83) // #22 - Yellow Spring Launch diagonal right 2535SpriteFrame(-32, -32, 48, 48, 166, 83) // #23 - Yellow Spring Launch diagonal left 2536537538// Used to be below LoadSpriteSheet, moved here for consistency539ArrayPos0 = 32540while ArrayPos0 < 1056541if Object[ArrayPos0].Type == TypeName[Yellow Spring]542if Object[ArrayPos0].PropertyValue > 5543Object[ArrayPos0].Direction = FLIP_Y544end if545end if546ArrayPos0++547loop548549end sub550551552// ========================553// Editor Subs554// ========================555556sub RSDKEdit557if Editor.ReturnVariable == true558switch Editor.VariableID559case EDIT_VAR_PROPVAL // Property Value560CheckResult = Object.PropertyValue561break562case 0 // Type563CheckResult = Object.PropertyValue564CheckResult &= 7565break566end switch567else568switch Editor.VariableID569case EDIT_VAR_PROPVAL // Property Value570Object.PropertyValue = Editor.VariableValue571break572case 0 // Type573Object.PropertyValue = Editor.VariableValue574Object.PropertyValue &= 7575break576end switch577end if578end sub579580581sub RSDKDraw582if Object.PropertyValue > 5583// Fun little fact - the official RSDKv3 editor displayed down diagonal springs wrong584// Here though, we may as well right that585Object.Direction = 2 // FLIP_Y586else587Object.Direction = 0 // FLIP_NONE588end if589590DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)591end sub592593594sub RSDKLoad595LoadSpriteSheet("Global/Items.gif")596SpriteFrame(-16, -8, 32, 16, 84, 183) // #0 - Yellow Spring facing up597SpriteFrame(-8, -16, 16, 32, 215, 116) // #1 - Yellow Spring facing right598SpriteFrame(-8, -16, 16, 32, 232, 116) // #2 - Yellow Spring facing left599SpriteFrame(-16, -8, 32, 16, 184, 239) // #3 - Yellow Spring facing down600SpriteFrame(-16, -16, 32, 32, 183, 165) // #4 - Yellow Spring facing diagonal right601SpriteFrame(-16, -16, 32, 32, 216, 182) // #5 - Yellow Spring facing diagonal left602SpriteFrame(-16, -16, 32, 32, 183, 165) // #6 - Yellow Spring facing diagonal right 2603SpriteFrame(-16, -16, 32, 32, 216, 182) // #7 - Yellow Spring facing diagonal left 2604605AddEditorVariable("Type")606SetActiveVariable("Type")607AddEnumVariable("Up", 0)608AddEnumVariable("Right", 1)609AddEnumVariable("Left", 2)610AddEnumVariable("Down", 3)611AddEnumVariable("Diagonal (Up Right)", 4)612AddEnumVariable("Diagonal (Up Left)", 5)613AddEnumVariable("Diagonal (Down Right)", 6)614AddEnumVariable("Diagonal (Down Right)", 7)615end sub616617618