Path: blob/main/Scripts/R5/VPlatformMedium.txt
1319 views
//--------------Sonic CD VPlatform Medium Script--------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Oscillation6#alias Object.Value1 : Object.PlatformY7#alias Object.Value2 : Object.ChangeY8#alias Object.Value3 : Object.Angle910// Time Period Aliases11#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1213#alias 0 : TIME_PRESENT14#alias 1 : TIME_PAST15#alias 2 : TIME_GOOD_FUTURE16#alias 3 : TIME_BAD_FUTURE1718// Priority19#alias 3 : PRIORITY_XBOUNDS2021// Property Values22#alias 0 : DOWNWARDS_PLAT23#alias 1 : DOWNWARDS_PLAT_UNUSED // Unused24#alias 2 : DOWNWARDS_PLAT_CONV25#alias 3 : UPWARDS_PLAT26#alias 4 : UPWARDS_PLAT_UNUSED // Unused27#alias 5 : UPWARDS_PLAT_CONV282930sub ObjectMain3132// Update the Platform's Oscillation used for its movement33// Do note, that because this Oscillation is stored as a local Object Value,34// all the platforms across the stage won't have their movements synced35Object.Oscillation++36if Object.Oscillation == 31237Object.Oscillation = 038end if3940// Get the Platform's Angle41// It'll range from 0 to 51042Object.Angle = Object.Oscillation43Object.Angle <<= 644Object.Angle /= 394546// Use that Andle to get the base Y change for the Platform47Sin(Object.ChangeY, Object.Angle)4849// And then invert that50FlipSign(Object.ChangeY)5152switch Object.PropertyValue53case DOWNWARDS_PLAT54case DOWNWARDS_PLAT_CONV55// Upwards moving platform56Object.ChangeY *= 0x180057Object.ChangeY += 0x30000058Object.ChangeY += Object.YPos59Object.ChangeY &= 0xFFFF0000 // Truncate the value60Object.ChangeY -= Object.PlatformY61break6263case UPWARDS_PLAT64case UPWARDS_PLAT_CONV65// Downwards moving platform66Object.ChangeY *= -0x180067Object.ChangeY -= 0x30000068Object.ChangeY += Object.YPos69Object.ChangeY &= 0xFFFF0000 // Truncate the value70Object.ChangeY -= Object.PlatformY71break7273case DOWNWARDS_PLAT_UNUSED74// Unused duplicate of upwards version75Object.ChangeY *= 0x180076Object.ChangeY += 0x30000077Object.ChangeY += Object.YPos78Object.ChangeY &= 0xFFFF0000 // Truncate the value79Object.ChangeY -= Object.PlatformY80break8182case UPWARDS_PLAT_UNUSED83// Unused duplicate of downwards version84Object.ChangeY *= -0x180085Object.ChangeY -= 0x30000086Object.ChangeY += Object.YPos87Object.ChangeY &= 0xFFFF0000 // Truncate the value88Object.ChangeY -= Object.PlatformY89break9091end switch9293end sub949596sub ObjectPlayerInteraction9798// Backup the Object's current position99TempValue0 = Object.YPos100101// Move the Object to where the Platform is102Object.YPos = Object.PlatformY103104switch Object.PropertyValue105case DOWNWARDS_PLAT106case UPWARDS_PLAT107// Standard Platform108PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)109if CheckResult == true110// Move the Player vertically along with the Platform111Player.YPos += Object.ChangeY112end if113break114115case DOWNWARDS_PLAT_CONV116case UPWARDS_PLAT_CONV117// Conveyor Platform118PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)119if CheckResult == true120121// Move the Player up or down with the Platform as needed to keep them on122Player.YPos += Object.ChangeY123124// And them adjust them as needed with the Conveyor too125if ConveyorBelt_Flag == 0126Player.XPos += ConveyorBelt_Speed127else128Player.XPos -= ConveyorBelt_Speed129end if130131end if132break133134end switch135136// Now restore the Object back to its base Position137Object.YPos = TempValue0138139end sub140141142sub ObjectDraw143144Sin(Object.PlatformY, Object.Angle)145FlipSign(Object.PlatformY)146147switch Object.PropertyValue148case DOWNWARDS_PLAT149case DOWNWARDS_PLAT_UNUSED150// Standard, upwards Platform151Object.PlatformY *= 0x1800152Object.PlatformY += 0x300000153Object.PlatformY += Object.YPos154Object.PlatformY &= 0xFFFF0000 // Truncate the value155DrawSpriteXY(0, Object.XPos, Object.PlatformY)156break157158case DOWNWARDS_PLAT_CONV159// Upwards Conveyor Platform160Object.PlatformY *= 0x1800161Object.PlatformY += 0x300000162Object.PlatformY += Object.YPos163Object.PlatformY &= 0xFFFF0000 // Truncate the value164DrawSpriteXY(0, Object.XPos, Object.PlatformY)165DrawSpriteXY(1, Object.XPos, Object.PlatformY)166break167168case UPWARDS_PLAT169case UPWARDS_PLAT_UNUSED170// Standard, downwards Platform171Object.PlatformY *= -0x1800172Object.PlatformY -= 0x300000173Object.PlatformY += Object.YPos174Object.PlatformY &= 0xFFFF0000 // Truncate the value175DrawSpriteXY(0, Object.XPos, Object.PlatformY)176break177178case UPWARDS_PLAT_CONV179// Downwards conveyor Platform180Object.PlatformY *= -0x1800181Object.PlatformY -= 0x300000182Object.PlatformY += Object.YPos183Object.PlatformY &= 0xFFFF0000 // Truncate the value184DrawSpriteXY(0, Object.XPos, Object.PlatformY)185DrawSpriteXY(1, Object.XPos, Object.PlatformY)186break187188end switch189190end sub191192193sub ObjectStartup194195LoadSpriteSheet("R5/Objects.gif")196197// Use different sprites based on the current Time Periods198switch HUD.CurrentTimePeriod199case TIME_PRESENT200LoadSpriteSheet("R5/Objects.gif")201SpriteFrame(-32, -16, 64, 32, 34, 51)202SpriteFrame(-32, -16, 64, 16, 1, 208)203break204205case TIME_PAST206LoadSpriteSheet("R5/Objects3.gif")207SpriteFrame(-32, -16, 64, 32, 34, 170)208SpriteFrame(-32, -16, 64, 16, 159, 148)209break210211case TIME_GOOD_FUTURE212LoadSpriteSheet("R5/Objects3.gif")213SpriteFrame(-32, -16, 64, 32, 34, 170)214SpriteFrame(-32, -16, 64, 16, 159, 182)215break216217case TIME_BAD_FUTURE218LoadSpriteSheet("R5/Objects3.gif")219SpriteFrame(-32, -16, 64, 32, 34, 170)220SpriteFrame(-32, -16, 64, 16, 159, 216)221break222223end switch224225ArrayPos0 = 32226while ArrayPos0 < 1056227if Object[ArrayPos0].Type == TypeName[VPlatform Medium]228229// Is the Platform's Property Value 6 or above?230if Object[ArrayPos0].PropertyValue > 5231232// Bring it back down a bit233Object[ArrayPos0].PropertyValue -= 6234235// It's a vertical platform type, so it should be updated regardless how far vertically it may be,236// since it may still be within rnage of the player in its cycle237Object[ArrayPos0].Priority = PRIORITY_XBOUNDS238239end if240end if241242ArrayPos0++243loop244245end sub246247248// ========================249// Editor Subs250// ========================251252// TODO: please test this, I think this may be a bit broken...253254sub RSDKEdit255if Editor.ReturnVariable == true256switch Editor.VariableID257case EDIT_VAR_PROPVAL // Property Value258CheckResult = Object.PropertyValue259break260case 0 // Direction261CheckResult = Object.PropertyValue262CheckResult %= 6263break264case 1 // Priority265CheckGreater(Object.PropertyValue, 5)266break267end switch268else269switch Editor.VariableID270case EDIT_VAR_PROPVAL // Property Value271Object.PropertyValue = Editor.VariableValue272break273case 0 // Direction274// this is kinda shoddily-coded, very well could be improved...275if Object.PropertyValue > 5276Object.PropertyValue = Editor.VariableValue277Object.PropertyValue += 6278else279Object.PropertyValue = Editor.VariableValue280end if281break282case 1 // Priority283Object.PropertyValue %= 6284CheckNotEqual(Editor.VariableValue, false)285Editor.VariableValue *= 6286Object.PropertyValue += Editor.VariableValue287break288end switch289end if290end sub291292293sub RSDKDraw294TempValue2 = false295296TempValue0 = Object.PropertyValue297TempValue0 %= 6298299switch TempValue0300case 2301TempValue2 = true302case 0303TempValue0 = 0x1800304TempValue1 = 0x300000305break306307case 5308TempValue2 = true309case 3310TempValue0 = -0x1800311TempValue1 = -0x300000312break313314end switch315316TempValue3 = Object.YPos317TempValue3 &= 0xFFFF0000 // Truncate the value318DrawSpriteXY(0, Object.XPos, TempValue3)319320if TempValue2 == true321DrawSpriteXY(1, Object.XPos, TempValue3)322end if323324if Editor.ShowGizmos == true325326// Draw the path the Platform will follow327328Sin(TempValue4, 128)329TempValue4 *= TempValue0330TempValue4 += TempValue1331TempValue4 += Object.YPos332TempValue4 &= 0xFFFF0000 // Truncate the value333334Editor.DrawingOverlay = true335336DrawLine(Object.XPos, TempValue3, Object.XPos, TempValue4, 255, 255, 255)337338Editor.DrawingOverlay = false339340end if341end sub342343344sub RSDKLoad345LoadSpriteSheet("R5/Objects.gif")346// TODO: using the present version here, but do other time periods347SpriteFrame(-32, -16, 64, 32, 34, 51)348SpriteFrame(-32, -16, 64, 16, 1, 208)349350AddEditorVariable("Direction")351SetActiveVariable("Direction")352AddEnumVariable("Upwards", 0)353// 1 is unused354AddEnumVariable("Upwards (Conveyor)", 2)355AddEnumVariable("Downwards", 3)356// 4 is unused357AddEnumVariable("Downwards (Conveyor)", 5)358359AddEditorVariable("Priority")360SetActiveVariable("Priority")361AddEnumVariable("Normal", 0)362AddEnumVariable("XBounds", 1)363end sub364365366