Path: blob/main/Scripts/R5/BGSwapper.txt
1319 views
//-----------------Sonic CD BG Swapper Script-----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// ========================5// Aliases6// ========================78// Layer Aliases, correspond to BG layers in the scene file9#alias 1 : LAYER_INSIDE10#alias 2 : LAYER_OUTSIDE111213// ========================14// Events15// ========================1617sub ObjectDraw18if Object.PropertyValue == 019// Inside to the left of the BG Swapper object, outside to the right2021if Player.XPos > Object.XPos22Stage.ActiveLayer[0] = LAYER_OUTSIDE23else24Stage.ActiveLayer[0] = LAYER_INSIDE25end if26else27// Outside to the left of the BG Swapper object, inside to the right2829if Player.XPos > Object.XPos30Stage.ActiveLayer[0] = LAYER_INSIDE31else32Stage.ActiveLayer[0] = LAYER_OUTSIDE33end if34end if35end sub363738sub ObjectStartup39// In this setup, we're gonna find what the initial BG should be when starting the level40// This is based on seeing what BG Swapper checkpoints the player spawns between4142// TempValue0 is iXPos of first BG Swapper43// (Default of 64 chunks in)44// TempValue1 is iXPos of last BG Swapper45// (Default of level's start itself)46TempValue0 = 0x400047TempValue1 = 04849// (We can use iXPos because the last few bytes of the BG Swapper's position aren't important)5051// Cycle throuh all BG Swapper Objects in the level52ArrayPos0 = 3253while ArrayPos0 < 105654if Object[ArrayPos0].Type == TypeName[BG Swapper]55if Object[ArrayPos0].iXPos < TempValue056TempValue0 = Object[ArrayPos0].iXPos57end if5859if Object[ArrayPos0].iXPos > TempValue160TempValue1 = Object[ArrayPos0].iXPos61end if62end if6364ArrayPos0++65loop6667// Get the Player's truncated XPos68// In this case, we can't use iXPos because Player position is too important to shave the last few bits off of69TempValue2 = Player.XPos70TempValue2 >>= 167172// See which BG Swappers the player is inbetween and set the Background accordingly73if TempValue2 > TempValue074if TempValue2 > TempValue175Stage.ActiveLayer[0] = LAYER_INSIDE76else77Stage.ActiveLayer[0] = LAYER_OUTSIDE78end if79else80Stage.ActiveLayer[0] = LAYER_INSIDE81end if82end sub838485// ========================86// Editor Subs87// ========================8889sub RSDKEdit90if Editor.ReturnVariable == true91switch Editor.VariableID92case EDIT_VAR_PROPVAL // Property Value93CheckResult = Object.PropertyValue94break9596case 0 // Type97CheckResult = Object.PropertyValue98break99100end switch101else102switch Editor.VariableID103case EDIT_VAR_PROPVAL // Property Value104Object.PropertyValue = Editor.VariableValue105break106107case 0 // Type108Object.PropertyValue = Editor.VariableValue109break110111end switch112end if113end sub114115116sub RSDKDraw117Editor.DrawingOverlay = true118119// draw a cool little line behind the Trigger icon120TempValue0 = Object.YPos121TempValue0 -= 0x80000122123DrawRectWorld(Object.XPos, TempValue0, 1, 16, 255, 255, 255, 255)124125Editor.DrawingOverlay = false126127// and then draw the Trigger icon, atop the line128DrawSprite(0)129end sub130131132sub RSDKLoad133LoadSpriteSheet("Global/Display.gif")134SpriteFrame(-8, -8, 16, 16, 173, 67) // "T" (rigger) icon135136AddEditorVariable("Type")137SetActiveVariable("Type")138AddEnumVariable("Inside on left, Outside on right", 0)139AddEnumVariable("Outside on left, Inside on right", 1)140end sub141142143