Path: blob/main/Scripts/R5/VPlatformLarge.txt
1319 views
//--------------Sonic CD VPlatform Large 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// HUD Alias11#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1213// Time Period Aliases14#alias 0 : TIME_PRESENT15#alias 1 : TIME_PAST16#alias 2 : TIME_GOOD_FUTURE17#alias 3 : TIME_BAD_FUTURE1819// Property Values20#alias 0 : DOWNWARDS_PLAT21#alias 1 : DOWNWARDS_PLAT_UNUSED22#alias 2 : DOWNWARDS_PLAT_CONV23#alias 3 : UPWARDS_PLAT24#alias 4 : UPWARDS_PLAT_UNUSED25#alias 5 : UPWARDS_PLAT_CONV262728sub ObjectMain2930// Update the Platform's base Oscillation Value31Object.Oscillation++32if Object.Oscillation == 31233Object.Oscillation = 034end if3536// From that Oscillation Value, get the Angle for the Platform to be at37// The result will range somewhere from 0 to 51038Object.Angle = Object.Oscillation39Object.Angle <<= 640Object.Angle /= 394142// Get the base Y change value for the Platform43Sin(Object.ChangeY, Object.Angle)4445// And from here, jump to the specific handling case needed for the different Platform types46switch Object.PropertyValue47case DOWNWARDS_PLAT48case DOWNWARDS_PLAT_CONV49// Downwards Platform50Object.ChangeY *= 0x180051Object.ChangeY += 0x30000052Object.ChangeY += Object.YPos53Object.ChangeY &= 0xFFFF0000 // Truncate the value54Object.ChangeY -= Object.PlatformY55break5657case UPWARDS_PLAT58case UPWARDS_PLAT_CONV59// Upwards Platform60Object.ChangeY *= -0x180061Object.ChangeY -= 0x30000062Object.ChangeY += Object.YPos63Object.ChangeY &= 0xFFFF0000 // Truncate the value64Object.ChangeY -= Object.PlatformY65break6667case DOWNWARDS_PLAT_UNUSED68// Unused duplicate of down Platform69Object.ChangeY *= 0x180070Object.ChangeY += 0x30000071Object.ChangeY += Object.YPos72Object.ChangeY &= 0xFFFF0000 // Truncate the value73Object.ChangeY -= Object.PlatformY74break7576case UPWARDS_PLAT_UNUSED77// Unused duplicate of upwards Platform78Object.ChangeY *= -0x180079Object.ChangeY -= 0x30000080Object.ChangeY += Object.YPos81Object.ChangeY &= 0xFFFF0000 // Truncate the value82Object.ChangeY -= Object.PlatformY83break8485end switch8687end sub888990sub ObjectPlayerInteraction9192// First, back up the Object's base Y Position93TempValue0 = Object.YPos9495// Then, move the Object to where its Platform is96Object.YPos = Object.PlatformY9798// From here, jump as needed to the needed Platform type99switch Object.PropertyValue100case DOWNWARDS_PLAT101case UPWARDS_PLAT102// Standard Platform103PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)104if CheckResult == true105// Move the Player along with the Platform to keep them on106Player.YPos += Object.ChangeY107end if108break109110case DOWNWARDS_PLAT_CONV111case UPWARDS_PLAT_CONV112// Conveyor Platform113PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)114if CheckResult == true115116// Move the Player vertically to say with the Platform117Player.YPos += Object.ChangeY118119// And then move the player horizontally as needed with the Conveyor Belt120if ConveyorBelt_Flag == 0121Player.XPos += ConveyorBelt_Speed122else123Player.XPos -= ConveyorBelt_Speed124end if125126end if127break128129end switch130131// And now restore the Object's base Y Position132Object.YPos = TempValue0133134end sub135136137sub ObjectDraw138139switch Object.PropertyValue140case DOWNWARDS_PLAT141case DOWNWARDS_PLAT_UNUSED142// Standard downwards Platform143Sin(Object.PlatformY, Object.Angle)144Object.PlatformY *= 0x1800145Object.PlatformY += 0x300000146Object.PlatformY += Object.YPos147Object.PlatformY &= 0xFFFF0000 // Truncate the value148DrawSpriteXY(0, Object.XPos, Object.PlatformY)149break150151case DOWNWARDS_PLAT_CONV152// Downwards Conveyor Platform153Sin(Object.PlatformY, Object.Angle)154Object.PlatformY *= 0x1800155Object.PlatformY += 0x300000156Object.PlatformY += Object.YPos157Object.PlatformY &= 0xFFFF0000 // Truncate the value158DrawSpriteXY(0, Object.XPos, Object.PlatformY)159DrawSpriteXY(1, Object.XPos, Object.PlatformY)160break161162case UPWARDS_PLAT163case UPWARDS_PLAT_UNUSED164// Standard upwards Platform165Sin(Object.PlatformY, Object.Angle)166Object.PlatformY *= -0x1800167Object.PlatformY -= 0x300000168Object.PlatformY += Object.YPos169Object.PlatformY &= 0xFFFF0000 // Truncate the value170DrawSpriteXY(0, Object.XPos, Object.PlatformY)171break172173case UPWARDS_PLAT_CONV174// Upwards Conveyor Platform175Sin(Object.PlatformY, Object.Angle)176Object.PlatformY *= -0x1800177Object.PlatformY -= 0x300000178Object.PlatformY += Object.YPos179Object.PlatformY &= 0xFFFF0000 // Truncate the value180DrawSpriteXY(0, Object.XPos, Object.PlatformY)181DrawSpriteXY(1, Object.XPos, Object.PlatformY)182break183184end switch185186end sub187188189sub ObjectStartup190191// Use different Sprites for the different Time Periods192switch HUD.CurrentTimePeriod193case TIME_PRESENT194LoadSpriteSheet("R5/Objects.gif")195SpriteFrame(-48, -16, 96, 32, 1, 84)196SpriteFrame(-48, -16, 96, 16, 1, 191)197break198199case TIME_PAST200LoadSpriteSheet("R5/Objects3.gif")201SpriteFrame(-48, -16, 96, 32, 1, 203)202SpriteFrame(-48, -16, 96, 16, 159, 131)203break204205case TIME_GOOD_FUTURE206LoadSpriteSheet("R5/Objects3.gif")207SpriteFrame(-48, -16, 96, 32, 1, 203)208SpriteFrame(-48, -16, 96, 16, 159, 165)209break210211case TIME_BAD_FUTURE212LoadSpriteSheet("R5/Objects3.gif")213SpriteFrame(-48, -16, 96, 32, 1, 203)214SpriteFrame(-48, -16, 96, 16, 159, 199)215break216217end switch218219end sub220221222// ========================223// Editor Subs224// ========================225226sub RSDKEdit227if Editor.ReturnVariable == true228switch Editor.VariableID229case EDIT_VAR_PROPVAL // Property Value230CheckResult = Object.PropertyValue231break232case 0 // Direction233CheckResult = Object.PropertyValue234break235end switch236else237switch Editor.VariableID238case EDIT_VAR_PROPVAL // Property Value239Object.PropertyValue = Editor.VariableValue240break241case 0 // Direction242Object.PropertyValue = Editor.VariableValue243break244end switch245end if246end sub247248249sub RSDKDraw250TempValue2 = false251252switch Object.PropertyValue253case 2254TempValue2 = true255case 0256default257TempValue0 = 0x1800258TempValue1 = 0x300000259break260261case 5262TempValue2 = true263case 3264TempValue0 *= -0x1800265TempValue1 -= 0x300000266break267268end switch269270TempValue3 = Object.YPos271TempValue3 &= 0xFFFF0000 // Truncate the value272DrawSpriteXY(0, Object.XPos, TempValue3)273274if TempValue2 == true275DrawSpriteXY(1, Object.XPos, TempValue3)276end if277278if Editor.ShowGizmos == true279280// Draw the Platform's path as a line281282Sin(TempValue4, 128)283TempValue4 *= TempValue0284TempValue4 += TempValue1285TempValue4 += Object.YPos286TempValue4 &= 0xFFFF0000 // Truncate the value287288Editor.DrawingOverlay = true289290DrawLine(Object.XPos, TempValue3, Object.XPos, TempValue4, 255, 255, 255)291292Editor.DrawingOverlay = false293294end if295end sub296297298sub RSDKLoad299LoadSpriteSheet("R5/Objects.gif")300// TODO: using present frames here, do something for other time periods301SpriteFrame(-48, -16, 96, 32, 1, 84)302SpriteFrame(-48, -16, 96, 16, 1, 191)303304AddEditorVariable("Direction")305SetActiveVariable("Direction")306AddEnumVariable("Downwards", 0)307// 1 is unused308AddEnumVariable("Downwards (Conveyor)", 2)309AddEnumVariable("Upwards", 3)310// 4 is unused311AddEnumVariable("Upwards (Conveyor)", 5)312end sub313314315