Path: blob/main/Scripts/R5/ConveyorBelt.txt
1319 views
//----------------Sonic CD ConveyorBelt Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.BeltFrame7// HUD Alias8#alias Object[24].PropertyValue : HUD.CurrentTimePeriod910// Tile Aliases11#alias 1 : TILE_CONVEYORBELT1213// Gravity14#alias 0 : GRAVITY_GROUND1516// Time Periods17#alias 0 : TIME_PRESENT18#alias 1 : TIME_PAST19#alias 2 : TIME_GOOD_FUTURE20#alias 3 : TIME_BAD_FUTURE2122// Priority23#alias 1 : PRIORITY_ACTIVE2425// Tile Info26#alias 8 : TILEINFO_ANGLEB272829sub ObjectPlayerInteraction3031// Only affect the Player if they're on the Ground32if Player.Gravity == GRAVITY_GROUND3334// The Tunnel state makes Players intangible to Conveyor Belts35if Player.State != Player_State_TubeRoll3637// Get the X Position of the tile on the Player's right side38TempValue1 = Player.XPos39TempValue1 >>= 1640TempValue1 += Player.CollisionRight4142// Get the Y Position of the tile right underneath tthe Player43TempValue2 = Player.YPos44TempValue2 >>= 1645TempValue2 += Player.CollisionBottom46TempValue2 += 24748// Get the B Angle/Flags value of the Tile at the specified positions49Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)5051// See if it's a Conveyor Belt tile52if TempValue0 == TILE_CONVEYORBELT5354// If it is, then move the Player in the corresponding direction and at the corresponding rate55if ConveyorBelt_Flag == FACING_RIGHT56Player.XPos += ConveyorBelt_Speed57else58Player.XPos -= ConveyorBelt_Speed59end if6061else6263// If the right tile did't have anything, then check the one to the Player's left64TempValue1 = Player.XPos65TempValue1 >>= 1666TempValue1 += Player.CollisionLeft6768Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)6970if TempValue0 == TILE_CONVEYORBELT7172// If this one is a Conveyer tile, then convey the player73if ConveyorBelt_Flag == FACING_RIGHT74Player.XPos += ConveyorBelt_Speed75else76Player.XPos -= ConveyorBelt_Speed77end if7879end if80end if81end if8283end if8485end sub868788sub ObjectDraw8990// Some palette cycling to make the Conveyer Belts look like they're moving9192Object.Timer++93if Object.Timer == 594Object.Timer = 095Object.BeltFrame++96Object.BeltFrame %= 397end if9899TempValue0 = Object.BeltFrame100TempValue0 += ConveyorBelt_Flag101102SetActivePalette(TempValue0, 0, 240)103104end sub105106107sub ObjectStartup108109// Place a ConveyorBelt Object into the scene110Object[19].Type = TypeName[ConveyorBelt]111112// Make it active, because Conveyor Belts should always be pushing the Player113Object[19].Priority = PRIORITY_ACTIVE114115// And give it a low Draw Order as well, but not too low!116// That's because, this Object's Draw Order has to be above the one used by the R5A Glow Effect!117// They both do palette trickery, so they have separate draw orders to make sure they don't interfere with each other118Object[19].DrawOrder = 1119120// Setup the alternate palettes for the Conveyer Belt121CopyPalette(0, 1)122CopyPalette(0, 2)123CopyPalette(0, 3)124CopyPalette(0, 4)125CopyPalette(0, 5)126127TempValue0 = 0128TempValue1 = 0129TempValue2 = 16130131ConveyorBelt_Flag = 0132ConveyorBelt_Frame = 0133134// Some Conveyor Belt properties that are different between time period135switch HUD.CurrentTimePeriod136case TIME_PRESENT137138// Give the Conveyer Belts a speed of 1 pixel per frame139ConveyorBelt_Speed = 0x10000140141// Setup the palette cycle for them, using the R5A bank142while TempValue0 < 6143LoadPalette("R5A_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)144TempValue1 += 16145TempValue2 += 16146147LoadPalette("R5A_PalCycle.act", TempValue0, 192, TempValue1, TempValue2)148TempValue1 += 16149TempValue2 += 16150TempValue0++151loop152break153154case TIME_PAST155156// In the Past, technology wasn't as developed, so give the Conveyer Belts a slower speed of 0.5 pixels per frame157ConveyorBelt_Speed = 0x8000158159// The Past's palette cycle should pull from the R5B palette bank160while TempValue0 < 6161LoadPalette("R5B_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)162TempValue1 += 16163TempValue2 += 16164TempValue0++165loop166break167168case TIME_GOOD_FUTURE169170// Technology is pretty advanced in the future, the Conveyer Belts have grown so much to have a speed of 2 pixels per frame now!171ConveyorBelt_Speed = 0x20000172173// The Good Future uses the R5C bank174while TempValue0 < 6175LoadPalette("R5C_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)176TempValue1 += 16177TempValue2 += 16178TempValue0++179loop180break181182case TIME_BAD_FUTURE183184// Even after taking over the world, Eggman was kind enough to let Conveyer Belt innovations still continue!185// What a kind man, Conveyer Belts still go at a speed of 2 pixels per frame now!186ConveyorBelt_Speed = 0x20000187188// Bad Future pulls from the R5D bank189while TempValue0 < 6190LoadPalette("R5D_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)191TempValue1 += 16192TempValue2 += 16193TempValue0++194loop195break196197end switch198199end sub200201202// ========================203// Editor Subs204// ========================205206sub RSDKDraw207DrawSprite(0)208end sub209210211sub RSDKLoad212LoadSpriteSheet("Global/Display.gif")213SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Icon214215SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")216end sub217218219