Path: blob/main/Scripts/R5/DoublePlatform.txt
1319 views
//--------------Sonic CD Double 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// HUD Alias12#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1314// Time Period Aliases15#alias 0 : TIME_PRESENT16#alias 1 : TIME_PAST17#alias 2 : TIME_GOOD_FUTURE18#alias 3 : TIME_BAD_FUTURE192021sub ObjectMain2223Object.Angle += 224Object.Angle &= 5112526if Object.Angle > 027Object.ChangeX = Object.Angle28Object.ChangeX *= -0x400029Object.ChangeX += Object.XPos30Object.ChangeX &= 0xFFFF0000 // Truncate the value31Object.ChangeX -= Object.PlatformX32else33Object.ChangeX = 034end if3536Cos(Object.ChangeY, Object.Angle)37Object.ChangeY *= 0x300038Object.ChangeY += Object.YPos39Object.ChangeY &= 0xFFFF0000 // Truncate the value40Object.ChangeY -= Object.PlatformY4142end sub434445sub ObjectPlayerInteraction4647// First, backup the Object's base position48TempValue0 = Object.XPos49TempValue1 = Object.YPos5051// Now, move the Object to where it's Platforms really are52Object.XPos = Object.PlatformX53Object.YPos = Object.PlatformY5455// Check Platform 156PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 16)57if CheckResult == true58Player.XPos += Object.ChangeX59Player.YPos += Object.ChangeY60end if6162// Check Platform 263PlayerObjectCollision(C_PLATFORM, 96, -16, 160, 16)64if CheckResult == true65Player.XPos += Object.ChangeX66Player.YPos += Object.ChangeY67end if6869// We can restore the Object's base position now70Object.XPos = TempValue071Object.YPos = TempValue17273end sub747576sub ObjectDraw7778Object.PlatformX = Object.Angle79Object.PlatformX *= -0x400080Object.PlatformX += Object.XPos81Object.PlatformX &= 0xFFFF0000 // Truncate the value8283Cos(Object.PlatformY, Object.Angle)84Object.PlatformY *= 0x300085Object.PlatformY += Object.YPos86Object.PlatformY &= 0xFFFF0000 // Truncate the value8788DrawSpriteXY(0, Object.PlatformX, Object.PlatformY)89DrawSpriteXY(1, Object.PlatformX, Object.PlatformY)9091end sub929394sub ObjectStartup95LoadSpriteSheet("R5/Objects3.gif")9697// Use different sprites for the different time periods98switch HUD.CurrentTimePeriod99case TIME_PRESENT100SpriteFrame(-32, -16, 64, 32, 66, 98)101SpriteFrame(96, -16, 64, 32, 66, 98)102break103104case TIME_PAST105SpriteFrame(-32, -16, 64, 32, 66, 98)106SpriteFrame(96, -16, 64, 32, 66, 98)107break108109case TIME_GOOD_FUTURE110SpriteFrame(-32, -16, 64, 32, 66, 98)111SpriteFrame(96, -16, 64, 32, 66, 98)112break113114case TIME_BAD_FUTURE115SpriteFrame(-32, -16, 64, 32, 131, 98)116SpriteFrame(96, -16, 64, 32, 131, 98)117break118119end switch120121end sub122123124// ========================125// Editor Subs126// ========================127128sub RSDKDraw129TempValue1 = Object.XPos130TempValue1 &= 0xFFFF0000 // Truncate the value131Cos(TempValue2, 0)132TempValue2 *= 0x3000133TempValue2 += Object.YPos134TempValue2 &= 0xFFFF0000 // Truncate the value135DrawSpriteXY(0, TempValue1, TempValue2)136DrawSpriteXY(1, TempValue1, TempValue2)137end sub138139140sub RSDKLoad141LoadSpriteSheet("R5/Objects3.gif")142143// TODO: support other time periods144// Surely there's a better way to do it than a bunch of unique and boring checkCurrentStageFolder checks?145SpriteFrame(-32, -16, 64, 32, 66, 98)146SpriteFrame(96, -16, 64, 32, 66, 98)147148SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")149end sub150151152