Path: blob/main/Scripts/R5/HPlatformLarge.txt
1319 views
//--------------Sonic CD HPlatform Large Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Pressed67#alias Object.Value1 : Object.PlatformY8#alias Object.Value2 : Object.ChangeY910#alias Object.Value3 : Object.PlatformX11#alias Object.Value4 : Object.ChangeX1213#alias Object.Value5 : Object.Angle14#alias Object.Value6 : Object.Oscillation1516#alias Object.Value7 : Object.Cooldown1718// HUD Alias19#alias Object[24].PropertyValue : HUD.CurrentTimePeriod2021// Time Period Aliases22#alias 0 : TIME_PRESENT23#alias 1 : TIME_PAST24#alias 2 : TIME_GOOD_FUTURE25#alias 3 : TIME_BAD_FUTURE2627// Property Values28#alias 0 : START_MOVING_RIGHT29#alias 1 : START_MOVING_RIGHT_W/SPRING30#alias 2 : START_MOVING_RIGHT_W/CONV31#alias 3 : START_MOVING_LEFT32#alias 4 : START_MOVING_LEFT_W/SPRING33#alias 5 : START_MOVING_LEFT_W/CONV34353637sub ObjectMain3839// Update this Object's Oscillation Value40// 312 may seem like a rather random value, but you'll see why it's used in a moment...41Object.Oscillation++42if Object.Oscillation == 31243Object.Oscillation = 044end if4546// From this Oscillation value, get the object's Angle47// This Angle will range from 0-51048Object.Angle = Object.Oscillation49Object.Angle <<= 650Object.Angle /= 395152// And then from this Angle, get the base X Change Value53Sin(Object.ChangeX, Object.Angle)5455switch Object.PropertyValue56case START_MOVING_RIGHT57case START_MOVING_RIGHT_W/CONV58// Right-moving Platform59Object.ChangeX *= 0x180060Object.ChangeX += 0x30000061Object.ChangeX += Object.XPos62Object.ChangeX &= 0xFFFF0000 // Truncate the value63Object.ChangeX -= Object.PlatformX64break6566case START_MOVING_LEFT67case START_MOVING_LEFT_W/CONV68// Left-moving Platform69Object.ChangeX *= -0x180070Object.ChangeX -= 0x30000071Object.ChangeX += Object.XPos72Object.ChangeX &= 0xFFFF0000 // Truncate the value73Object.ChangeX -= Object.PlatformX74break7576case START_MOVING_RIGHT_W/SPRING77// Right-moving Carrier Platform78Object.ChangeX *= 0x180079Object.ChangeX += 0x30000080Object.ChangeX += Object.XPos81Object.ChangeX &= 0xFFFF0000 // Truncate the value8283// Move the first following Object8485// Make it 32 pixels to the left of this Object86Object[+1].XPos = Object.ChangeX87Object[+1].XPos -= 0x2000008889// And 24 pixels above90Object[+1].YPos = Object.YPos91Object[+1].YPos -= 0x1800009293// And then comes the second following Object9495// This one will be in the center of the Platform96Object[+2].XPos = Object.ChangeX9798// And also 24 pixels above99Object[+2].YPos = Object.YPos100Object[+2].YPos -= 0x180000101102// And then the last, third riding Object103104// 32 pixels to the right105Object[+3].XPos = Object.ChangeX106Object[+3].XPos += 0x200000107108// And, of course, 24 pixels above again109Object[+3].YPos = Object.YPos110Object[+3].YPos -= 0x180000111112Object.ChangeX -= Object.PlatformX113break114115case START_MOVING_LEFT_W/SPRING116// Left-moving Carrier Platform117Object.ChangeX *= -0x1800118Object.ChangeX -= 0x300000119Object.ChangeX += Object.XPos120Object.ChangeX &= 0xFFFF0000 // Truncate the value121122// Move the first Following Object123124// 32 pixels to the left125Object[+1].XPos = Object.ChangeX126Object[+1].XPos -= 0x200000127128// 24 pixels above129Object[+1].YPos = Object.YPos130Object[+1].YPos -= 0x180000131132// Next Object!133134// Same X as the Platform135Object[+2].XPos = Object.ChangeX136137// 24 pixels above138Object[+2].YPos = Object.YPos139Object[+2].YPos -= 0x180000140141// Final Rider Object!142143// 32 pixels right144Object[+3].XPos = Object.ChangeX145Object[+3].XPos += 0x200000146147// And 24 pixels above148Object[+3].YPos = Object.YPos149Object[+3].YPos -= 0x180000150151Object.ChangeX -= Object.PlatformX152break153154end switch155156if Object.Pressed == true157if Object.PlatformY < 16158Object.PlatformY++159TempValue0 = Object.PlatformY160TempValue0 &= 3161if TempValue0 == 3162// Dip a pixel down163Object.ChangeY = 0x10000164else165Object.ChangeY = 0166end if167else168Object.ChangeY = 0169end if170else171if Object.PlatformY > 0172Object.PlatformY--173TempValue0 = Object.PlatformY174TempValue0 &= 3175if TempValue0 == 3176// Go back up a pixel177Object.ChangeY = -0x10000178else179Object.ChangeY = 0180end if181else182Object.ChangeY = 0183end if184end if185186Object.Pressed = false187188end sub189190191sub ObjectPlayerInteraction192193// Before doing anything else, back up the Object's base position194TempValue0 = Object.XPos195196// Then, move the Object to where its Platform is197Object.XPos = Object.PlatformX198199// And now, jump to the handling type needed200switch Object.PropertyValue201case START_MOVING_RIGHT202case START_MOVING_LEFT203// Standard Platform204205PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)206207if CheckResult == true208209// Since the Player's on the Platform, let the Platform Object know so it can dip210Object.Pressed = true211212// And carry the Player along with the Platform213Player.XPos += Object.ChangeX214Player.YPos += Object.ChangeY215216end if217break218219case START_MOVING_RIGHT_W/CONV220case START_MOVING_LEFT_W/CONV221// Conveyor Platform222223if Object.Cooldown == 0224PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)225226if CheckResult == true227228// Now that the Player's on the Platform, let the Platform Object know229Object.Pressed = true230231// Move the Player along with the Platform to keep them on232Player.XPos += Object.ChangeX233Player.YPos += Object.ChangeY234235if ConveyorBelt_Flag == false236Player.XPos += ConveyorBelt_Speed237else238Player.XPos -= ConveyorBelt_Speed239end if240241// On the note of keeping the Player on the Platform...242243// Activate a small cooldown if the Player is seen to be on the edge of this Platform244// This is to prevent an issue where the Player will repeatedly get pushed off and regrabbed by the Platform245246if Player.Animation == ANI_FLAILINGLEFT247Object.Cooldown = 30248end if249if Player.Animation == ANI_FLAILINGRIGHT250Object.Cooldown = 30251end if252end if253else254// Hold...255Object.Cooldown--256end if257break258259end switch260261// And now restore the Object's Position262Object.XPos = TempValue0263264end sub265266267sub ObjectDraw268269// Move the Object to match where it should be270Object.YPos += Object.ChangeY271272switch Object.PropertyValue273case START_MOVING_RIGHT274case START_MOVING_RIGHT_W/SPRING275// Right-moving Platform276Sin(Object.PlatformX, Object.Angle)277Object.PlatformX *= 0x1800278Object.PlatformX += 0x300000279Object.PlatformX += Object.XPos280Object.PlatformX &= 0xFFFF0000 // Truncate the value281DrawSpriteXY(0, Object.PlatformX, Object.YPos)282break283284case START_MOVING_RIGHT_W/CONV285// Right-moving Conveyor Platform286Sin(Object.PlatformX, Object.Angle)287Object.PlatformX *= 0x1800288Object.PlatformX += 0x300000289Object.PlatformX += Object.XPos290Object.PlatformX &= 0xFFFF0000 // Truncate the value291DrawSpriteXY(0, Object.PlatformX, Object.YPos)292DrawSpriteXY(1, Object.PlatformX, Object.YPos)293break294295case START_MOVING_LEFT296case START_MOVING_LEFT_W/SPRING297// Left-moving Platform298Sin(Object.PlatformX, Object.Angle)299Object.PlatformX *= -0x1800300Object.PlatformX -= 0x300000301Object.PlatformX += Object.XPos302Object.PlatformX &= 0xFFFF0000 // Truncate the value303DrawSpriteXY(0, Object.PlatformX, Object.YPos)304break305306case START_MOVING_LEFT_W/CONV307// Left-moving Conveyor Platform308Sin(Object.PlatformX, Object.Angle)309Object.PlatformX *= -0x1800310Object.PlatformX -= 0x300000311Object.PlatformX += Object.XPos312Object.PlatformX &= 0xFFFF0000 // Truncate the value313DrawSpriteXY(0, Object.PlatformX, Object.YPos)314DrawSpriteXY(1, Object.PlatformX, Object.YPos)315break316317end switch318319end sub320321322sub ObjectStartup323324LoadSpriteSheet("R5/Objects.gif")325326// Use different graphics for the different Time Periods327switch HUD.CurrentTimePeriod328case TIME_PRESENT329LoadSpriteSheet("R5/Objects.gif")330SpriteFrame(-48, -16, 96, 32, 1, 84)331SpriteFrame(-48, -16, 96, 16, 1, 191)332break333334case TIME_PAST335LoadSpriteSheet("R5/Objects3.gif")336SpriteFrame(-48, -16, 96, 32, 1, 203)337SpriteFrame(-48, -16, 96, 16, 159, 131)338break339340case TIME_GOOD_FUTURE341LoadSpriteSheet("R5/Objects3.gif")342SpriteFrame(-48, -16, 96, 32, 1, 203)343SpriteFrame(-48, -16, 96, 16, 159, 165)344break345346case TIME_BAD_FUTURE347LoadSpriteSheet("R5/Objects3.gif")348SpriteFrame(-48, -16, 96, 32, 1, 203)349SpriteFrame(-48, -16, 96, 16, 159, 199)350break351352end switch353354end sub355356357// ========================358// Editor Subs359// ========================360361sub RSDKDraw362363TempValue2 = false364365switch Object.PropertyValue366case 2367TempValue2 = true368case 0369case 1370TempValue0 = 0x1800371TempValue1 = 0x300000372break373374375case 5376TempValue2 = true377case 3378case 4379TempValue0 = -0x1800380TempValue1 = -0x300000381break382383end switch384385TempValue3 = Object.XPos386TempValue3 &= 0xFFFF0000 // Truncate the value387DrawSpriteXY(0, TempValue3, Object.YPos)388DrawSpriteXY(TempValue2, TempValue3, Object.YPos)389390if Editor.ShowGizmos == true391Editor.DrawingOverlay = true392393// Show the Platform's path394395Sin(TempValue4, 128)396TempValue4 *= TempValue0397TempValue4 += TempValue1398TempValue4 += Object.XPos399TempValue4 &= 0xFFFF0000 // Truncate the value400401DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)402403Editor.DrawingOverlay = false404end if405406end sub407408409sub RSDKLoad410LoadSpriteSheet("R5/Objects.gif")411// TODO: using present frames, why does r5 have like 20 platform objects i've wrote this comment like 19 times already412SpriteFrame(-48, -16, 96, 32, 1, 84)413SpriteFrame(-48, -16, 96, 16, 1, 191)414415AddEditorVariable("Direction")416SetActiveVariable("Direction")417AddEnumVariable("Right", 0)418AddEnumVariable("Right (Spring)", 1)419AddEnumVariable("Right (Conveyor)", 2)420AddEnumVariable("Left", 3)421AddEnumVariable("Left (Spring)", 4)422AddEnumVariable("Left (Conveyor)", 5)423end sub424425426