Path: blob/main/Scripts/R5/RPlatform.txt
1319 views
//-----------------Sonic CD R Platform Script-----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Angle6#alias Object.Value1 : Object.PlatformX7#alias Object.Value2 : Object.PlatformY8#alias Object.Value3 : Object.ChangeX9#alias Object.Value4 : Object.ChangeY10#alias Object.Value5 : Object.AltAngle111213sub ObjectMain1415switch Object.PropertyValue16case 117// Full range version of the Platform, moving counter-clockwise1819Object.Angle -= 22021if Object.Angle < 022// Wrap around23Object.Angle += 51224end if25break2627case 228// Bottom half version of the Platform, swinging around the bottom 180 degrees2930Object.AltAngle += 231Object.AltAngle &= 5113233Sin(Object.Angle, Object.AltAngle)3435Object.Angle >>= 236Object.Angle += 12837break3839case 340// Top half version of the Platform, swinging around the top 180 degrees4142Object.AltAngle += 243Object.AltAngle &= 5114445Sin(Object.Angle, Object.AltAngle)4647FlipSign(Object.Angle)4849Object.Angle >>= 250Object.Angle += 38451Object.Angle &= 51152break5354end switch5556// Radius value57TempValue1 = 965859Cos(Object.ChangeX, Object.Angle)60Object.ChangeX *= TempValue161Object.ChangeX <<= 762Object.ChangeX += Object.XPos63Object.ChangeX &= 0xFFFF0000 // Truncate the value64Object.ChangeX -= Object.PlatformX6566Sin(Object.ChangeY, Object.Angle)67Object.ChangeY *= TempValue168Object.ChangeY <<= 769Object.ChangeY += Object.YPos70Object.ChangeY &= 0xFFFF0000 // Truncate the value71Object.ChangeY -= Object.PlatformY7273end sub747576sub ObjectPlayerInteraction7778// Backup the Object's base position79TempValue0 = Object.XPos80TempValue1 = Object.YPos8182// Move the Object to its Platform's position83Object.XPos = Object.PlatformX84Object.YPos = Object.PlatformY8586// Act as a Platform for the player87PlayerObjectCollision(C_PLATFORM, -32, -8, 32, 8)88if CheckResult == true8990// Move the Player along with the Platform91Player.XPos += Object.ChangeX92Player.YPos += Object.ChangeY9394// The Platform is a Conveyor Belt as well, so move the Player in accordance with that too95if ConveyorBelt_Flag == 096Player.XPos += ConveyorBelt_Speed97else98Player.XPos -= ConveyorBelt_Speed99end if100101end if102103// And now restore the Object back to its base position104Object.XPos = TempValue0105Object.YPos = TempValue1106107end sub108109110sub ObjectDraw111112// Draw the Post Frame113DrawSprite(0)114115// Draw all the Chains116TempValue0 = 0117TempValue1 = 16118while TempValue0 < 5119Cos(TempValue2, Object.Angle)120TempValue2 *= TempValue1121TempValue2 <<= 7122TempValue2 += Object.XPos123124Sin(TempValue3, Object.Angle)125TempValue3 *= TempValue1126TempValue3 <<= 7127TempValue3 += Object.YPos128129DrawSpriteXY(1, TempValue2, TempValue3)130131TempValue0++132TempValue1 += 16133loop134135136Cos(Object.PlatformX, Object.Angle)137Object.PlatformX *= TempValue1138Object.PlatformX <<= 7139Object.PlatformX += Object.XPos140Object.PlatformX &= 0xFFFF0000 // Truncate the value141142Sin(Object.PlatformY, Object.Angle)143Object.PlatformY *= TempValue1144Object.PlatformY <<= 7145Object.PlatformY += Object.YPos146Object.PlatformY &= 0xFFFF0000 // Truncate the value147148DrawSpriteXY(2, Object.PlatformX, Object.PlatformY)149150end sub151152153sub ObjectStartup154LoadSpriteSheet("R5/Objects.gif")155156// Post Frame157SpriteFrame(-8, -8, 16, 16, 1, 1)158159// Chain Frame160SpriteFrame(-8, -8, 16, 16, 18, 1)161162// Conveyor Platform Frame163SpriteFrame(-32, -8, 64, 16, 1, 208)164165end sub166167168// ========================169// Editor Subs170// ========================171172sub RSDKEdit173if Editor.ReturnVariable == true174switch Editor.VariableID175case EDIT_VAR_PROPVAL // Property Value176CheckResult = Object.PropertyValue177break178case 0 // Range179CheckResult = Object.PropertyValue180break181end switch182else183switch Editor.VariableID184case EDIT_VAR_PROPVAL // Property Value185Object.PropertyValue = Editor.VariableValue186break187case 0 // Range188Object.PropertyValue = Editor.VariableValue189break190end switch191end if192end sub193194195sub RSDKDraw196DrawSprite(0)197198TempValue0 = 0199TempValue1 = 16200while TempValue0 < 5201Cos(TempValue2, 128)202TempValue2 *= TempValue1203TempValue2 <<= 7204TempValue2 += Object.XPos205Sin(TempValue3, 128)206TempValue3 *= TempValue1207TempValue3 <<= 7208TempValue3 += Object.YPos209DrawSpriteXY(1, TempValue2, TempValue3)210TempValue0++211TempValue1 += 16212loop213214Cos(TempValue2, 128)215TempValue2 *= TempValue1216TempValue2 <<= 7217TempValue2 += Object.XPos218TempValue2 &= 0xFFFF0000 // Truncate the value219220Sin(TempValue3, 128)221TempValue3 *= TempValue1222TempValue3 <<= 7223TempValue3 += Object.YPos224TempValue3 &= 0xFFFF0000 // Truncate the value225226DrawSpriteXY(2, TempValue2, TempValue3)227end sub228229230sub RSDKLoad231LoadSpriteSheet("R5/Objects.gif")232SpriteFrame(-8, -8, 16, 16, 1, 1)233SpriteFrame(-8, -8, 16, 16, 18, 1)234SpriteFrame(-32, -8, 64, 16, 1, 208)235236AddEditorVariable("Range")237SetActiveVariable("Range")238// 0 technically exists as a "Static" type but it isn't used in the game so239AddEnumVariable("Full Rotation", 1)240AddEnumVariable("Bottom Half", 2)241AddEnumVariable("Top Half", 3)242end sub243244245