Path: blob/main/Scripts/R5/HPlatformMedium1.txt
1319 views
//--------------Sonic CD HPlatformMedium1 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.Angle1415#alias Object.Value6 : Object.Cooldown1617// HUD Alias18#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1920// Time Period Aliases21#alias 0 : TIME_PRESENT22#alias 1 : TIME_PAST23#alias 2 : TIME_GOOD_FUTURE24#alias 3 : TIME_BAD_FUTURE2526// Property Values27#alias 0 : START_MOVING_RIGHT28#alias 1 : START_MOVING_RIGHT_W/SPRING29#alias 2 : START_MOVING_RIGHT_W/CONV30#alias 3 : START_MOVING_LEFT31#alias 4 : START_MOVING_LEFT_W/SPRING32#alias 5 : START_MOVING_LEFT_W/CONV333435sub ObjectMain3637Object.Angle += 238Object.Angle &= 5113940Sin(Object.ChangeX, Object.Angle)4142switch Object.PropertyValue43case START_MOVING_RIGHT44case START_MOVING_RIGHT_W/CONV45// Right-moving Platform46Object.ChangeX *= 0x100047Object.ChangeX += 0x20000048Object.ChangeX += Object.XPos49Object.ChangeX &= 0xFFFF0000 // Truncate the value50Object.ChangeX -= Object.PlatformX51break5253case START_MOVING_LEFT54case START_MOVING_LEFT_W/CONV55// Left-moving Platform56Object.ChangeX *= -0x100057Object.ChangeX -= 0x20000058Object.ChangeX += Object.XPos59Object.ChangeX &= 0xFFFF0000 // Truncate the value60Object.ChangeX -= Object.PlatformX61break6263case START_MOVING_RIGHT_W/SPRING64// Right-moving Carrier Object65Object.ChangeX *= 0x100066Object.ChangeX += 0x20000067Object.ChangeX += Object.XPos68Object.ChangeX &= 0xFFFF0000 // Truncate the value6970// Move the first Following Object7172// Make it 16 Pixels to the left73Object[+1].XPos = Object.ChangeX74Object[+1].XPos -= 0x1000007576// And 24 pixels above77Object[+1].YPos = Object.YPos78Object[+1].YPos -= 0x1800007980// And then move the next Follower Object8182// Make this one 16 pixels to the right83Object[+2].XPos = Object.ChangeX84Object[+2].XPos += 0x1000008586// And also 24 pixels above87Object[+2].YPos = Object.YPos88Object[+2].YPos -= 0x1800008990Object.ChangeX -= Object.PlatformX91break9293case START_MOVING_LEFT_W/SPRING94// Left-moving Carrier Object95Object.ChangeX *= -0x100096Object.ChangeX -= 0x20000097Object.ChangeX += Object.XPos98Object.ChangeX &= 0xFFFF0000 // Truncate the value99100// Moving the first Follower Object101102// Move it 16 pixels to the left from this Object103Object[+1].XPos = Object.ChangeX104Object[+1].XPos -= 0x100000105106// And 24 pixels above107Object[+1].YPos = Object.YPos108Object[+1].YPos -= 0x180000109110// And then the second Following Object111112// 16 pixels, but this time to the right!113Object[+2].XPos = Object.ChangeX114Object[+2].XPos += 0x100000115116// But this part's still 24 pixels up, yeah117Object[+2].YPos = Object.YPos118Object[+2].YPos -= 0x180000119120Object.ChangeX -= Object.PlatformX121break122123end switch124125// Object.Pressed is originally set in ObjectPlayerInteraction126127if Object.Pressed == true128if Object.PlatformY < 16129Object.PlatformY++130TempValue0 = Object.PlatformY131TempValue0 &= 3132if TempValue0 == 3133// Dip the Platform down by a pixel134Object.ChangeY = 0x10000135else136Object.ChangeY = 0137end if138else139Object.ChangeY = 0140end if141else142if Object.PlatformY > 0143Object.PlatformY--144TempValue0 = Object.PlatformY145TempValue0 &= 3146if TempValue0 == 3147// Restore the Platform upwards a little148Object.ChangeY = -0x10000149else150Object.ChangeY = 0151end if152else153Object.ChangeY = 0154end if155end if156157// Reset Object.Pressed to be set again later this frame by ObjectPlayerInteraction158Object.Pressed = false159160end sub161162163sub ObjectPlayerInteraction164165// First, back up the Object's base Position166TempValue0 = Object.XPos167168// Now, move the Object to where its Platform is169Object.XPos = Object.PlatformX170171// From here, jump to the further handling type needed172switch Object.PropertyValue173case START_MOVING_RIGHT174case START_MOVING_LEFT175// Standard Platform type176177PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)178179if CheckResult == true180181// Since the Player's on the Platform, let the Platform Object know so that it can dip if needed182Object.Pressed = true183184// And move the Player along with the Platform185Player.XPos += Object.ChangeX186Player.YPos += Object.ChangeY187188end if189break190191case START_MOVING_RIGHT_W/CONV192case START_MOVING_LEFT_W/CONV193// Conveyor Platform194195if Object.Cooldown == 0196PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)197198if CheckResult == true199200// The Player's on the Platform, let the Platform Object know so that it can dip as needed201Object.Pressed = true202203// Carry the Player along with the Platform in order to keep them on204Player.XPos += Object.ChangeX205Player.YPos += Object.ChangeY206207// And then push the Player as needed for the Conveyor208if ConveyorBelt_Flag == 0209Player.XPos += ConveyorBelt_Speed210else211Player.XPos -= ConveyorBelt_Speed212end if213214// If the Player is in a Flailing animation, then they're on the edge of the Platform215// However! This is a Conveyor Platform!216217// So to prevent an issue where the Player gets pushed off, regrabbed the next frame, then pushed off, then [...]218// There's a cooldown if the Player is detected to be on the edge219220// Perhaps half a second may be a bit long for the cooldown, but it serves its use nonetheless221222if Player.Animation == ANI_FLAILINGLEFT223Object.Cooldown = 30224end if225226if Player.Animation == ANI_FLAILINGRIGHT227Object.Cooldown = 30228end if229230end if231else232// Don't want to catch the Player again just yet, hold...233Object.Cooldown--234end if235break236237// cases 1/4 don't have anything238// They shouldn't interact with the Player, since they have Springs riding atop them239// so the Player shouldn't be able to land on the Platform itself240241end switch242243// And now restore the Object's Position244Object.XPos = TempValue0245246end sub247248249sub ObjectDraw250251// Move the Object to where its new Y position should be252Object.YPos += Object.ChangeY253254switch Object.PropertyValue255case START_MOVING_RIGHT256case START_MOVING_RIGHT_W/SPRING257// Right-moving Platform258Sin(Object.PlatformX, Object.Angle)259Object.PlatformX *= 0x1000260Object.PlatformX += 0x200000261Object.PlatformX += Object.XPos262Object.PlatformX &= 0xFFFF0000 // Truncate the value263DrawSpriteXY(0, Object.PlatformX, Object.YPos)264break265266case START_MOVING_RIGHT_W/CONV267// Right-moving Conveyor Platform268Sin(Object.PlatformX, Object.Angle)269Object.PlatformX *= 0x1000270Object.PlatformX += 0x200000271Object.PlatformX += Object.XPos272Object.PlatformX &= 0xFFFF0000 // Truncate the value273DrawSpriteXY(0, Object.PlatformX, Object.YPos)274DrawSpriteXY(1, Object.PlatformX, Object.YPos)275break276277case START_MOVING_LEFT278case START_MOVING_LEFT_W/SPRING279// Left-moving Platform280Sin(Object.PlatformX, Object.Angle)281Object.PlatformX *= -0x1000282Object.PlatformX -= 0x200000283Object.PlatformX += Object.XPos284Object.PlatformX &= 0xFFFF0000 // Truncate the value285DrawSpriteXY(0, Object.PlatformX, Object.YPos)286break287288case START_MOVING_LEFT_W/CONV289// Left-moving Conveyor Platform290Sin(Object.PlatformX, Object.Angle)291Object.PlatformX *= -0x1000292Object.PlatformX -= 0x200000293Object.PlatformX += Object.XPos294Object.PlatformX &= 0xFFFF0000 // Truncate the value295DrawSpriteXY(0, Object.PlatformX, Object.YPos)296DrawSpriteXY(1, Object.PlatformX, Object.YPos)297break298299end switch300301end sub302303304sub ObjectStartup305306LoadSpriteSheet("R5/Objects.gif")307308// Use different Sprites for the different Time Periods309switch HUD.CurrentTimePeriod310case TIME_PRESENT311LoadSpriteSheet("R5/Objects.gif")312SpriteFrame(-32, -16, 64, 32, 34, 51)313SpriteFrame(-32, -16, 64, 16, 1, 208)314break315316case TIME_PAST317LoadSpriteSheet("R5/Objects3.gif")318SpriteFrame(-32, -16, 64, 32, 34, 170)319SpriteFrame(-32, -16, 64, 16, 159, 148)320break321322case TIME_GOOD_FUTURE323LoadSpriteSheet("R5/Objects3.gif")324SpriteFrame(-32, -16, 64, 32, 34, 170)325SpriteFrame(-32, -16, 64, 16, 159, 182)326break327328case TIME_BAD_FUTURE329LoadSpriteSheet("R5/Objects3.gif")330SpriteFrame(-32, -16, 64, 32, 34, 170)331SpriteFrame(-32, -16, 64, 16, 159, 216)332break333334end switch335336end sub337338339// ========================340// Editor Subs341// ========================342343sub RSDKEdit344if Editor.ReturnVariable == true345switch Editor.VariableID346case EDIT_VAR_PROPVAL // Property Value347CheckResult = Object.PropertyValue348break349case 0 // Direction350CheckResult = Object.PropertyValue351break352end switch353else354switch Editor.VariableID355case EDIT_VAR_PROPVAL // Property Value356Object.PropertyValue = Editor.VariableValue357break358case 0 // Direction359Object.PropertyValue = Editor.VariableValue360break361end switch362end if363end sub364365366sub RSDKDraw367TempValue2 = 0368369switch Object.PropertyValue370case 2371TempValue2 = 1372default373case 0374case 1375TempValue0 = 0x1000376TempValue1 = 0x200000377break378379case 5380TempValue2 = 1381case 3382case 4383TempValue0 = -0x1000384TempValue1 = -0x200000385break386387end switch388389DrawSprite(0)390DrawSprite(TempValue2)391392if Editor.ShowGizmos == true393Editor.DrawingOverlay = true394395// Draw the Platform's path396397TempValue3 = Object.XPos398TempValue3 &= 0xFFFF0000 // Truncate the value399400Sin(TempValue4, 128)401TempValue4 *= TempValue0402TempValue4 += TempValue1403TempValue4 += Object.XPos404TempValue4 &= 0xFFFF0000 // Truncate the value405406DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)407408Editor.DrawingOverlay = false409end if410end sub411412413sub RSDKLoad414LoadSpriteSheet("R5/Objects.gif")415// TODO using present frames here, something something other time perids416SpriteFrame(-32, -16, 64, 32, 34, 51)417SpriteFrame(-32, -16, 64, 16, 1, 208)418419AddEditorVariable("Direction")420SetActiveVariable("Direction")421AddEnumVariable("Right", 0)422AddEnumVariable("Right (Spring)", 1)423AddEnumVariable("Right (Conveyor)", 2)424AddEnumVariable("Left", 3)425AddEnumVariable("Left (Spring)", 4)426AddEnumVariable("Left (Conveyor)", 5)427end sub428429430