Path: blob/main/Scripts/R5/HPlatformSmall.txt
1319 views
//--------------Sonic CD HPlatform Small Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases56#alias Object.Value0 : Object.Pressed78#alias Object.Value1 : Object.PlatformY9#alias Object.Value2 : Object.ChangeY1011#alias Object.Value3 : Object.PlatformX12#alias Object.Value4 : Object.ChangeX1314#alias Object.Value5 : Object.Angle15#alias Object.Value6 : Object.Oscillation1617#alias Object.Value7 : Object.Cooldown1819// HUD Alias20#alias Object[24].PropertyValue : HUD.CurrentTimePeriod2122// Time Period Aliases23#alias 0 : TIME_PRESENT24#alias 1 : TIME_PAST25#alias 2 : TIME_GOOD_FUTURE26#alias 3 : TIME_BAD_FUTURE2728// Property Values29#alias 0 : START_MOVING_RIGHT30#alias 1 : START_MOVING_RIGHT_W/SPRING31#alias 2 : START_MOVING_RIGHT_W/CONV32#alias 3 : START_MOVING_LEFT33#alias 4 : START_MOVING_LEFT_W/SPRING34#alias 5 : START_MOVING_LEFT_W/CONV353637sub ObjectMain3839// Update the Platform's Oscillation value40Object.Oscillation++41if Object.Oscillation == 31242Object.Oscillation = 043end if4445// From that Oscillation value, get the Angle the Platform should be at46Object.Angle = Object.Oscillation47Object.Angle <<= 648Object.Angle /= 394950// And then from this Angle, get the base Change Value51Sin(Object.ChangeX, Object.Angle)5253switch Object.PropertyValue54case START_MOVING_RIGHT55case START_MOVING_RIGHT_W/CONV56// Going Right Platform57Object.ChangeX *= 0x180058Object.ChangeX += 0x30000059Object.ChangeX += Object.XPos60Object.ChangeX &= 0xFFFF0000 // Truncate the value61Object.ChangeX -= Object.PlatformX62break6364case START_MOVING_LEFT65case START_MOVING_LEFT_W/CONV66// Going Left Platform67Object.ChangeX *= -0x180068Object.ChangeX -= 0x30000069Object.ChangeX += Object.XPos70Object.ChangeX &= 0xFFFF0000 // Truncate the value71Object.ChangeX -= Object.PlatformX72break7374case START_MOVING_RIGHT_W/SPRING75// Going Right Platform, carrying an Object76Object.ChangeX *= 0x180077Object.ChangeX += 0x30000078Object.ChangeX += Object.XPos79Object.ChangeX &= 0xFFFF0000 // Truncate the value8081// Move the following Object along with the Platform82Object[+1].XPos = Object.ChangeX8384// Make it 24 pixels above this Platform85Object[+1].YPos = Object.YPos86Object[+1].YPos -= 0x1800008788// And then turn the "Change" value into the actual difference89Object.ChangeX -= Object.PlatformX90break9192case START_MOVING_LEFT_W/SPRING93// Platform going Left, with a rider Object94Object.ChangeX *= -0x180095Object.ChangeX -= 0x30000096Object.ChangeX += Object.XPos97Object.ChangeX &= 0xFFFF0000 // Truncate the value9899// Move the riding Object to match this Platform100Object[+1].XPos = Object.ChangeX101102// And make it 24 pixels above, so that its bottom is on this Platform's top103Object[+1].YPos = Object.YPos104Object[+1].YPos -= 0x180000105106// And with that, get the actual Change value107Object.ChangeX -= Object.PlatformX108break109110end switch111112// Update Platforming dipping113if Object.Pressed == true114if Object.PlatformY < 16115Object.PlatformY++116TempValue0 = Object.PlatformY117TempValue0 &= 3118if TempValue0 == 3119// Move down a pixel120Object.ChangeY = 0x10000121else122Object.ChangeY = 0123end if124else125Object.ChangeY = 0126end if127else128if Object.PlatformY > 0129Object.PlatformY--130TempValue0 = Object.PlatformY131TempValue0 &= 3132if TempValue0 == 3133// Recover back up a pixel134Object.ChangeY = -0x10000135else136Object.ChangeY = 0137end if138else139Object.ChangeY = 0140end if141end if142143Object.Pressed = false144145end sub146147148sub ObjectPlayerInteraction149150// First, backup the Object's base Position151TempValue0 = Object.XPos152153// Then, move it to where the Platform actually is154Object.XPos = Object.PlatformX155156// From here, jump to the handling type needed157switch Object.PropertyValue158case START_MOVING_RIGHT159case START_MOVING_LEFT160// Standard Platform161162PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)163164if CheckResult == true165166// The Player is on the Platform, so set the Platform's variable so that167// it can dip accordingly168Object.Pressed = true169170// And then move the Player with the Platform as needed171Player.XPos += Object.ChangeX172Player.YPos += Object.ChangeY173174end if175break176177case START_MOVING_RIGHT_W/CONV178case START_MOVING_LEFT_W/CONV179// Conveyor Platform180181if Object.Cooldown == 0182PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)183184if CheckResult == true185186// Let the Platform object know that the Player's mounted so that it can dip187Object.Pressed = true188189// Carry the Player along with the Platform's movement190Player.XPos += Object.ChangeX191Player.YPos += Object.ChangeY192193// And then update them for the Conveyor's movement too194if ConveyorBelt_Flag == 0195Player.XPos += ConveyorBelt_Speed196else197Player.XPos -= ConveyorBelt_Speed198end if199200// If the Player is in their balancing animation, then it means that they're on the edge of the Platform201// However, this is a Conveyor Platform!202203// To prevent an issue where204// the Player gets pushed off and then regrabbed by platform and then pushed off and then regrabbed and so on,205// there is a half second cooldown activated if the Player is noticed to be flailing on the edge206207if Player.Animation == ANI_FLAILINGLEFT208Object.Cooldown = 30209end if210211if Player.Animation == ANI_FLAILINGRIGHT212Object.Cooldown = 30213end if214end if215else216// Hold for a moment and decrease the countdown...217Object.Cooldown--218end if219break220221// cases 1 & 4 are skipped over - they have springs riding them so222// the Player should never be able to land on the Platform itself223224end switch225226// And now restore the Object's Position227Object.XPos = TempValue0228229end sub230231232sub ObjectDraw233234// Move the Object as needed for its dipping235Object.YPos += Object.ChangeY236237switch Object.PropertyValue238case START_MOVING_RIGHT239case START_MOVING_RIGHT_W/SPRING240// Right-moving Platform241Sin(Object.PlatformX, Object.Angle)242Object.PlatformX *= 0x1800243Object.PlatformX += 0x300000244Object.PlatformX += Object.XPos245Object.PlatformX &= 0xFFFF0000 // Truncate the value246DrawSpriteXY(0, Object.PlatformX, Object.YPos)247break248249case START_MOVING_RIGHT_W/CONV250// Right-moving Conveyor Platform251Sin(Object.PlatformX, Object.Angle)252Object.PlatformX *= 0x1800253Object.PlatformX += 0x300000254Object.PlatformX += Object.XPos255Object.PlatformX &= 0xFFFF0000 // Truncate the value256DrawSpriteXY(0, Object.PlatformX, Object.YPos)257DrawSpriteXY(1, Object.PlatformX, Object.YPos)258break259260case START_MOVING_LEFT261case START_MOVING_LEFT_W/SPRING262// Left-moving Platform263Sin(Object.PlatformX, Object.Angle)264Object.PlatformX *= -0x1800265Object.PlatformX -= 0x300000266Object.PlatformX += Object.XPos267Object.PlatformX &= 0xFFFF0000 // Truncate the value268DrawSpriteXY(0, Object.PlatformX, Object.YPos)269break270271case START_MOVING_LEFT_W/CONV272// Left-moving Conveyor Platform273Sin(Object.PlatformX, Object.Angle)274Object.PlatformX *= -0x1800275Object.PlatformX -= 0x300000276Object.PlatformX += Object.XPos277Object.PlatformX &= 0xFFFF0000 // Truncate the value278DrawSpriteXY(0, Object.PlatformX, Object.YPos)279DrawSpriteXY(1, Object.PlatformX, Object.YPos)280break281282end switch283284end sub285286287sub ObjectStartup288289LoadSpriteSheet("R5/Objects.gif")290291// Load the needed sprites based on the current Time Period292switch HUD.CurrentTimePeriod293case TIME_PRESENT294LoadSpriteSheet("R5/Objects.gif")295SpriteFrame(-16, -16, 32, 32, 1, 51)296SpriteFrame(-16, -16, 32, 16, 65, 208)297break298299case TIME_PAST300LoadSpriteSheet("R5/Objects3.gif")301SpriteFrame(-16, -16, 32, 32, 1, 170)302SpriteFrame(-16, -16, 32, 16, 223, 148)303break304305case TIME_GOOD_FUTURE306LoadSpriteSheet("R5/Objects3.gif")307SpriteFrame(-16, -16, 32, 32, 1, 170)308SpriteFrame(-16, -16, 32, 16, 223, 182)309break310311case TIME_BAD_FUTURE312LoadSpriteSheet("R5/Objects3.gif")313SpriteFrame(-16, -16, 32, 32, 1, 170)314SpriteFrame(-16, -16, 32, 16, 223, 216)315break316317end switch318319end sub320321322// ========================323// Editor Subs324// ========================325326sub RSDKEdit327if Editor.ReturnVariable == true328switch Editor.VariableID329case EDIT_VAR_PROPVAL // Property Value330CheckResult = Object.PropertyValue331break332case 0 // Direction333CheckResult = Object.PropertyValue334break335end switch336else337switch Editor.VariableID338case EDIT_VAR_PROPVAL // Property Value339Object.PropertyValue = Editor.VariableValue340break341case 0 // Direction342Object.PropertyValue = Editor.VariableValue343break344end switch345end if346end sub347348349sub RSDKDraw350351TempValue2 = 0352switch Object.PropertyValue353case 2354TempValue2 = 1355default356case 0357case 1358TempValue0 = 0x1800359TempValue1 = 0x300000360break361362case 5363TempValue2 = 1364case 3365case 4366TempValue0 = -0x1800367TempValue1 = -0x300000368break369370end switch371372TempValue3 = Object.XPos373TempValue3 &= 0xFFFF0000 // Truncate the value374DrawSpriteXY(0, TempValue3, Object.YPos)375DrawSpriteXY(TempValue2, TempValue3, Object.YPos)376377if Editor.ShowGizmos == true378379// Get the end destination for the Platform380Sin(TempValue4, 128)381TempValue4 *= TempValue0382TempValue4 += TempValue1383TempValue4 += Object.XPos384TempValue4 &= 0xFFFF0000 // Truncate the value385386Editor.DrawingOverlay = true387388DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)389390Editor.DrawingOverlay = false391end if392393end sub394395396sub RSDKLoad397LoadSpriteSheet("R5/Objects.gif")398// TODO: using present frames, adapt this for other time periods399SpriteFrame(-16, -16, 32, 32, 1, 51)400SpriteFrame(-16, -16, 32, 16, 65, 208)401402AddEditorVariable("Direction")403SetActiveVariable("Direction")404AddEnumVariable("Right", 0)405AddEnumVariable("Right (Spring)", 1)406AddEnumVariable("Right (Conveyor)", 2)407AddEnumVariable("Left", 3)408AddEnumVariable("Left (Spring)", 4)409AddEnumVariable("Left (Conveyor)", 5)410end sub411412413