Path: blob/main/Scripts/R4/RPlatform.txt
1319 views
//--------------Sonic CD Rotating 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.ChangeY1011// For the button mounted atop this Object, either true or false12#alias Object.PropertyValue : Object.Pressed1314// Stage SFX15#alias 8 : SFX_S_SWITCH161718sub ObjectMain1920Object.Angle += 221Object.Angle &= 5112223TempValue1 = 962425Cos(Object.ChangeX, Object.Angle)26Object.ChangeX *= TempValue127Object.ChangeX <<= 728Object.ChangeX += Object.XPos29Object.ChangeX &= 0xFFFF0000 // Truncate the value30Object.ChangeX -= Object.PlatformX3132Sin(Object.ChangeY, Object.Angle)33Object.ChangeY *= TempValue134Object.ChangeY <<= 735Object.ChangeY += Object.YPos36Object.ChangeY &= 0xFFFF0000 // Truncate the value37Object.ChangeY -= Object.PlatformY38end sub394041sub ObjectPlayerInteraction4243// Backup the Object's base position44TempValue0 = Object.XPos45TempValue1 = Object.YPos4647// Move to where the Object's Platform is48Object.XPos = Object.PlatformX49Object.YPos = Object.PlatformY5051// Check to see if the Player is riding on it52PlayerObjectCollision(C_PLATFORM, -32, -8, 32, 8)53if CheckResult == true54// Move the Player along with the Platform5556Player.XPos += Object.ChangeX57Player.YPos += Object.ChangeY58end if5960if Object.Pressed == false61PlayerObjectCollision(C_BOX, 0, -24, 32, 0)62if CheckResult == true63// The Player is on the button6465if Object.Pressed == false66PlayStageSfx(SFX_S_SWITCH, false)67end if6869Object.Pressed = true7071// Move the Player along with the Platform's movements72Player.YPos += 0x8000073Player.XPos += Object.ChangeX74Player.YPos += Object.ChangeY75else76Object.Pressed = false77end if78else79PlayerObjectCollision(C_BOX, 0, -16, 32, 0)80if CheckResult == true81Object.Pressed = true82Player.XPos += Object.ChangeX83Player.YPos += Object.ChangeY84else85Object.Pressed = false86end if87end if8889// Move the Object back to its base position90Object.XPos = TempValue091Object.YPos = TempValue19293end sub949596sub ObjectDraw9798// First, draw the Object's Joint99DrawSprite(2)100101// Then, draw all the Chains connecting the Platform to its Joint102TempValue0 = 0103TempValue1 = 16104while TempValue0 < 5105Cos(TempValue2, Object.Angle)106TempValue2 *= TempValue1107TempValue2 <<= 7108TempValue2 += Object.XPos109110Sin(TempValue3, Object.Angle)111TempValue3 *= TempValue1112TempValue3 <<= 7113TempValue3 += Object.YPos114115DrawSpriteXY(3, TempValue2, TempValue3)116117TempValue0++118TempValue1 += 16119loop120121// And now, find the positions to draw the Platform at122Cos(Object.PlatformX, Object.Angle)123Object.PlatformX *= TempValue1124Object.PlatformX <<= 7125Object.PlatformX += Object.XPos126Object.PlatformX &= 0xFFFF0000 // Truncate the value127128Sin(Object.PlatformY, Object.Angle)129Object.PlatformY *= TempValue1130Object.PlatformY <<= 7131Object.PlatformY += Object.YPos132Object.PlatformY &= 0xFFFF0000 // Truncate the value133134// Finally, draw the Platform itself135DrawSpriteXY(4, Object.PlatformX, Object.PlatformY)136137// But wait! There's a button that rides the Platform, so draw that too!138DrawSpriteXY(Object.Pressed, Object.PlatformX, Object.PlatformY)139140end sub141142143sub ObjectStartup144LoadSpriteSheet("R4/Objects.gif")145146SpriteFrame(0, -24, 32, 16, 130, 35) // #0 - Push Button147SpriteFrame(0, -24, 32, 16, 130, 52) // #1 - Push Button Pressed148SpriteFrame(-8, -8, 16, 16, 163, 52) // #2 - Platform Joint149SpriteFrame(-8, -8, 16, 16, 180, 52) // #3 - Platform Chain150SpriteFrame(-32, -8, 64, 16, 147, 69) // #4 - Platform151end sub152153154// ========================155// Editor Subs156// ========================157158sub RSDKDraw159DrawSprite(2)160161TempValue0 = 0162TempValue1 = 16163while TempValue0 < 5164Cos(TempValue2, 128)165TempValue2 *= TempValue1166TempValue2 <<= 7167TempValue2 += Object.XPos168169Sin(TempValue3, 128)170TempValue3 *= TempValue1171TempValue3 <<= 7172TempValue3 += Object.YPos173174DrawSpriteXY(3, TempValue2, TempValue3)175176TempValue0++177TempValue1 += 16178loop179180Cos(Object.PlatformX, 128)181Object.PlatformX *= TempValue1182Object.PlatformX <<= 7183Object.PlatformX += Object.XPos184Object.PlatformX &= 0xFFFF0000 // Truncate the value185186Sin(Object.PlatformY, 128)187Object.PlatformY *= TempValue1188Object.PlatformY <<= 7189Object.PlatformY += Object.YPos190Object.PlatformY &= 0xFFFF0000 // Truncate the value191192DrawSpriteXY(4, Object.PlatformX, Object.PlatformY)193194DrawSpriteXY(Object.Pressed, Object.PlatformX, Object.PlatformY)195end sub196197198sub RSDKLoad199LoadSpriteSheet("R4/Objects.gif")200201SpriteFrame(0, -24, 32, 16, 130, 35) // #0 - Push Button202SpriteFrame(0, -24, 32, 16, 130, 52) // #1 - Push Button Pressed203SpriteFrame(-8, -8, 16, 16, 163, 52) // #2 - Platform Joint204SpriteFrame(-8, -8, 16, 16, 180, 52) // #3 - Platform Chain205SpriteFrame(-32, -8, 64, 16, 147, 69) // #4 - Platform206207// Although used by the Object, it shouldn't be set from the editor208SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")209end sub210211212