Path: blob/main/Scripts/R5/VPlatformSmall.txt
1319 views
//--------------Sonic CD VPlatform Small 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 Oscillation Value31// (This value is stored per-Object, meaning that Platforms across the stage aren't synced)32Object.Oscillation++33if Object.Oscillation == 31234Object.Oscillation = 035end if3637// Get the Object's Angle value38// The final Angle value Will range from 0 to 51039Object.Angle = Object.Oscillation40Object.Angle <<= 641Object.Angle /= 394243// Calculate its base Change value44Sin(Object.ChangeY, Object.Angle)4546// From this base Change value, jump to the Platform handling type for what's further needed47switch Object.PropertyValue48case DOWNWARDS_PLAT49case DOWNWARDS_PLAT_CONV50// Downwards Platform51Object.ChangeY *= 0x180052Object.ChangeY += 0x30000053Object.ChangeY += Object.YPos54Object.ChangeY &= 0xFFFF0000 // Truncate the value55Object.ChangeY -= Object.PlatformY56break5758case UPWARDS_PLAT59case UPWARDS_PLAT_CONV60// Upwards Platform61Object.ChangeY *= -0x180062Object.ChangeY -= 0x30000063Object.ChangeY += Object.YPos64Object.ChangeY &= 0xFFFF0000 // Truncate the value65Object.ChangeY -= Object.PlatformY66break6768case DOWNWARDS_PLAT_UNUSED69// Unused duplicate of downwards platform70Object.ChangeY *= 0x180071Object.ChangeY += 0x30000072Object.ChangeY += Object.YPos73Object.ChangeY &= 0xFFFF0000 // Truncate the value74Object.ChangeY -= Object.PlatformY75break7677case UPWARDS_PLAT_UNUSED78// Unused duplicate of upwards platform79Object.ChangeY *= -0x180080Object.ChangeY -= 0x30000081Object.ChangeY += Object.YPos82Object.ChangeY &= 0xFFFF0000 // Truncate the value83Object.ChangeY -= Object.PlatformY84break8586end switch8788end sub899091sub ObjectPlayerInteraction9293// Back up the Object's position...94TempValue0 = Object.YPos9596// ...and move the Object to where the Platform actually is97Object.YPos = Object.PlatformY9899switch Object.PropertyValue100case DOWNWARDS_PLAT101case UPWARDS_PLAT102// Normal Platform103PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)104if CheckResult == true105// Move the Player along with the Platform106Player.YPos += Object.ChangeY107end if108break109110case DOWNWARDS_PLAT_CONV111case UPWARDS_PLAT_CONV112// Conveyor Platform113PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)114if CheckResult == true115116// Move the Player to match the Platform117Player.YPos += Object.ChangeY118119// And then push them along with the Conveyor Belt too as needed120if ConveyorBelt_Flag == 0121Player.XPos += ConveyorBelt_Speed122else123Player.XPos -= ConveyorBelt_Speed124end if125126end if127break128129end switch130131// Now that all the Collision's been done, it's safe to move the Object back now132Object.YPos = TempValue0133134end sub135136137sub ObjectDraw138139// All Platform types have their own Draw routines140switch Object.PropertyValue141case DOWNWARDS_PLAT142case DOWNWARDS_PLAT_UNUSED143// Standard Downards Platform144Sin(Object.PlatformY, Object.Angle)145Object.PlatformY *= 0x1800146Object.PlatformY += 0x300000147Object.PlatformY += Object.YPos148Object.PlatformY &= 0xFFFF0000 // Truncate the value149DrawSpriteXY(0, Object.XPos, Object.PlatformY)150break151152case DOWNWARDS_PLAT_CONV153// Downards Conveyor Platform154Sin(Object.PlatformY, Object.Angle)155Object.PlatformY *= 0x1800156Object.PlatformY += 0x300000157Object.PlatformY += Object.YPos158Object.PlatformY &= 0xFFFF0000 // Truncate the value159DrawSpriteXY(0, Object.XPos, Object.PlatformY)160DrawSpriteXY(1, Object.XPos, Object.PlatformY)161break162163case UPWARDS_PLAT164case UPWARDS_PLAT_UNUSED165// Standard Upwards Platform166Sin(Object.PlatformY, Object.Angle)167Object.PlatformY *= -0x1800168Object.PlatformY -= 0x300000169Object.PlatformY += Object.YPos170Object.PlatformY &= 0xFFFF0000 // Truncate the value171DrawSpriteXY(0, Object.XPos, Object.PlatformY)172break173174case UPWARDS_PLAT_CONV175// Upwards Conveyor Platform176Sin(Object.PlatformY, Object.Angle)177Object.PlatformY *= -0x1800178Object.PlatformY -= 0x300000179Object.PlatformY += Object.YPos180Object.PlatformY &= 0xFFFF0000 // Truncate the value181DrawSpriteXY(0, Object.XPos, Object.PlatformY)182DrawSpriteXY(1, Object.XPos, Object.PlatformY)183break184185end switch186187end sub188189190sub ObjectStartup191192LoadSpriteSheet("R5/Objects.gif")193194// Different sprites for different time periods195196// To avoid redundant labelling, the order of Sprite Frames will just be listed here197// 0 - Base Platform Frame198// 1 - Conveyor Frame, to be overlayed atop the base Platform Frame199200switch HUD.CurrentTimePeriod201case TIME_PRESENT202LoadSpriteSheet("R5/Objects.gif")203SpriteFrame(-16, -16, 32, 32, 1, 51)204SpriteFrame(-16, -16, 32, 16, 65, 208)205break206207case TIME_PAST208LoadSpriteSheet("R5/Objects3.gif")209SpriteFrame(-16, -16, 32, 32, 1, 170)210SpriteFrame(-16, -16, 32, 16, 223, 148)211break212213case TIME_GOOD_FUTURE214LoadSpriteSheet("R5/Objects3.gif")215SpriteFrame(-16, -16, 32, 32, 1, 170)216SpriteFrame(-16, -16, 32, 16, 223, 182)217break218219case TIME_BAD_FUTURE220LoadSpriteSheet("R5/Objects3.gif")221SpriteFrame(-16, -16, 32, 32, 1, 170)222SpriteFrame(-16, -16, 32, 16, 223, 216)223break224225end switch226227end sub228229230// ========================231// Editor Subs232// ========================233234sub RSDKEdit235if Editor.ReturnVariable == true236switch Editor.VariableID237case EDIT_VAR_PROPVAL // Property Value238CheckResult = Object.PropertyValue239break240case 0 // Direction241CheckResult = Object.PropertyValue242break243end switch244else245switch Editor.VariableID246case EDIT_VAR_PROPVAL // Property Value247Object.PropertyValue = Editor.VariableValue248break249case 0 // Direction250Object.PropertyValue = Editor.VariableValue251break252end switch253end if254end sub255256257sub RSDKDraw258TempValue2 = false259260// TempValue0 holds just about no use with this sytem, but may as well just grab it261262switch Object.PropertyValue263case 2264TempValue2 = true265case 0266default267TempValue0 = 0x1800268TempValue1 = 0x300000269break270271case 5272TempValue2 = true273case 3274TempValue0 = -0x1800275TempValue1 = -0x300000276break277278end switch279280TempValue3 = Object.YPos281TempValue3 &= 0xFFFF0000 // Truncate the value282DrawSpriteXY(0, Object.XPos, TempValue3)283284if TempValue2 == true285DrawSpriteXY(1, Object.XPos, TempValue3)286end if287288if Editor.ShowGizmos == true289290Editor.DrawingOverlay = true291292// Draw the Platform's path293294Sin(TempValue4, 128)295TempValue4 *= TempValue0296TempValue4 += TempValue1297TempValue4 += Object.YPos298TempValue4 &= 0xFFFF0000 // Truncate the value299300DrawLine(Object.XPos, TempValue3, Object.XPos, TempValue4, 255, 255, 255)301302Editor.DrawingOverlay = false303304end if305end sub306307308sub RSDKLoad309LoadSpriteSheet("R5/Objects.gif")310// Sticking with the Present version here...311// TODO: other time periods, hopefully there's some better method than 10 checkcurrentfolder checks?312SpriteFrame(-16, -16, 32, 32, 1, 51)313SpriteFrame(-16, -16, 32, 16, 65, 208)314315AddEditorVariable("Direction")316SetActiveVariable("Direction")317AddEnumVariable("Downwards", 0)318// 1 is unused319AddEnumVariable("Downwards (Conveyor)", 2)320AddEnumVariable("Upwards", 3)321// 4 is unused322AddEnumVariable("Upwards (Conveyor)", 5)323end sub324325326