Path: blob/main/Scripts/R8/CrushingPlatform.txt
1319 views
//--------------Sonic CD Crush Platform Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.YDrawPos7#alias Object.Value2 : Object.YCollisionOffset8#alias Object.Value3 : Object.Oscillation9#alias Object.Value4 : Object.Speed10#alias Object.Value5 : Object.LargePlatform11#alias Object.Value6 : Object.IncreaseValue1213// Player Aliases14#alias Player.Value7 : Player.AnimationReserve1516#alias 0 : CRUSHPLATFORM_DESCEND17#alias 1 : CRUSHPLATFORM_WAIT18#alias 2 : CRUSHPLATFORM_ASCEND19#alias 3 : CRUSHPLATFORM_WAIT_22021// Property Values22#alias 0 : PLATFORM_START_TOP23#alias 1 : PLATFORM_START_BOTTOM2425// Collision26#alias 1 : PLAYER_COL_FLOOR27#alias 4 : PLAYER_COL_ROOF2829// Gravity30#alias 0 : GRAVITY_GROUND31#alias 1 : GRAVITY_AIR3233// Property Values34#alias 0 : NORMAL_SPEED35#alias 5 : LARGE_NORMAL_SPEED36#alias 69 : LARGE_FAST_SPEED37#alias 72 : NORMAL_FAST_LAUNCH383940sub ObjectMain41if Object.LargePlatform == false42Object.Oscillation += Object.IncreaseValue43Object.Oscillation &= 51144if Object.PropertyValue == PLATFORM_START_BOTTOM45Object.Oscillation += 25646end if4748Sin(Object.YCollisionOffset, Object.Oscillation)49Object.YCollisionOffset *= Object.Speed50Object.YCollisionOffset += Object.YPos51Object.YCollisionOffset &= 0xFFFF0000 // Truncate the value52Object.YCollisionOffset -= Object.YDrawPos53else54switch Object.State55case CRUSHPLATFORM_DESCEND56Object.Oscillation += 457Object.Oscillation &= 51158if Object.Oscillation == 12859Object.State++60end if61break6263case CRUSHPLATFORM_WAIT64if Object.Timer < 6465Object.Timer++66else67Object.Timer = 068Object.State++69end if70break7172case CRUSHPLATFORM_ASCEND73Object.Oscillation += 474Object.Oscillation &= 51175if Object.Oscillation == 38476Object.State++77end if78break7980case CRUSHPLATFORM_WAIT_281if Object.Timer < 6482Object.Timer++83else84Object.Timer = 085Object.State = CRUSHPLATFORM_DESCEND86end if87break88end switch8990Sin(Object.YCollisionOffset, Object.Oscillation)91Object.YCollisionOffset *= Object.Speed92Object.YCollisionOffset += Object.YPos93Object.YCollisionOffset &= 0xFFFF0000 // Truncate the value94Object.YCollisionOffset -= Object.YDrawPos95end if96end sub979899sub ObjectPlayerInteraction100TempValue0 = Object.YPos101TempValue1 = Player.YPos102Object.YPos = Object.YDrawPos103104if Object.LargePlatform == false105#platform: Use_Origins106PlayerObjectCollision(C_BOX2, -32, -32, 32, 32)107#endplatform108#platform: Use_Standalone109PlayerObjectCollision(C_BOX, -32, -32, 32, 32)110#endplatform111if CheckResult == PLAYER_COL_FLOOR112Player.YPos += Object.YCollisionOffset113else114if CheckResult == PLAYER_COL_ROOF115if Player.Gravity == GRAVITY_GROUND116if Object.YCollisionOffset > 0117CallFunction(Player_Kill)118else119Player.YPos = TempValue1120end if121else122#platform: Use_Origins123if Player.State == Player_State_LedgePullUp124CallFunction(Player_Kill)125end if126#endplatform127end if128end if129end if130else131#platform: Use_Origins132PlayerObjectCollision(C_BOX2, -32, -96, 32, 96)133#endplatform134#platform: Use_Standalone135PlayerObjectCollision(C_BOX, -32, -96, 32, 96)136#endplatform137if CheckResult == PLAYER_COL_FLOOR138Player.YPos += Object.YCollisionOffset139if Object.Oscillation == 320140141#platform: Use_Origins142Player.State = Player_State_Air_NoDropDash143#endplatform144145#platform: Use_Standalone146Player.State = Player_State_Air147#endplatform148Player.Timer = 0149Player.YVelocity = -0x100000150Player.Animation = ANI_BOUNCING151Player.Gravity = GRAVITY_AIR152Player.AnimationReserve = ANI_WALKING153end if154else155if CheckResult == PLAYER_COL_ROOF156if Player.Gravity == GRAVITY_GROUND157if Object.YCollisionOffset > 0158CallFunction(Player_Kill)159else160Player.YPos = TempValue1161end if162else163#platform: Use_Origins164if Player.State == Player_State_LedgePullUp165CallFunction(Player_Kill)166end if167#endplatform168end if169end if170end if171end if172Object.YPos = TempValue0173174end sub175176177sub ObjectDraw178Sin(Object.YDrawPos, Object.Oscillation)179Object.YDrawPos *= Object.Speed180Object.YDrawPos += Object.YPos181Object.YDrawPos &= 0xFFFF0000 // Truncate the value182DrawSpriteXY(0, Object.XPos, Object.YDrawPos)183if Object.LargePlatform == true184DrawSpriteXY(1, Object.XPos, Object.YDrawPos)185DrawSpriteXY(2, Object.XPos, Object.YDrawPos)186end if187end sub188189190sub ObjectStartup191LoadSpriteSheet("R8/Objects.gif")192193SpriteFrame(-32, -32, 64, 64, 1, 1) // #0 - Crush Platform (also the middle of the large Crush Platform)194SpriteFrame(-32, -96, 64, 64, 1, 1) // #1 - Large Crush Platform Top195SpriteFrame(-32, 32, 64, 64, 1, 1) // #2 - Large Crush Platform Bottom196197198ArrayPos0 = 32199while ArrayPos0 < 1056200if Object[ArrayPos0].Type == TypeName[Crush Platform]201Object[ArrayPos0].IncreaseValue = 2202if Object[ArrayPos0].PropertyValue == NORMAL_SPEED203Object[ArrayPos0].Speed = 0x1000204else205Object[ArrayPos0].Speed = 0x1800206end if207208if Object[ArrayPos0].PropertyValue == LARGE_NORMAL_SPEED209Object[ArrayPos0].LargePlatform = true210Object[ArrayPos0].Speed = 0x1000211end if212213if Object[ArrayPos0].PropertyValue == LARGE_FAST_SPEED214Object[ArrayPos0].LargePlatform = true215Object[ArrayPos0].Speed = 0x1800216end if217218if Object[ArrayPos0].PropertyValue == NORMAL_FAST_LAUNCH219Object[ArrayPos0].IncreaseValue = 6220end if221end if222ArrayPos0++223loop224end sub225226227// ========================228// Editor Subs229// ========================230231sub RSDKEdit232if Editor.ReturnVariable == true233switch Editor.VariableID234case EDIT_VAR_PROPVAL // Property Value235case 0 // Property Value236CheckResult = Object.PropertyValue237break238end switch239else240switch Editor.VariableID241case EDIT_VAR_PROPVAL // Property Value242if Editor.VariableValue >= 72243Object.PropertyValue = 72244else245if Editor.VariableValue >= 69246Object.PropertyValue = 69247else248if Editor.VariableValue >= 5249Object.PropertyValue = 5250else251if Editor.VariableValue >= 2252Object.PropertyValue = 2253else254Object.PropertyValue = Editor.VariableValue255end if256end if257end if258end if259break260case 0 // type261switch Editor.VariableValue262case 0263Object.PropertyValue = 0264break265case 1266Object.PropertyValue = 1267break268case 2269Object.PropertyValue = 5270break271case 3272Object.PropertyValue = 69273break274case 4275Object.PropertyValue = 72276break277end switch278break279end switch280end if281end sub282283284sub RSDKDraw285switch Object.PropertyValue286case NORMAL_SPEED287case LARGE_NORMAL_SPEED288TempValue2 = 0x1000289break290default291case LARGE_FAST_SPEED292TempValue2 = 0x1800293break294endswitch295296Sin(TempValue5, 0)297TempValue5 *= TempValue2298TempValue5 += Object.YPos299TempValue5 &= 0xFFFF0000 // Truncate the value300DrawSpriteXY(0, Object.XPos, TempValue5)301switch Object.PropertyValue302case LARGE_NORMAL_SPEED303case LARGE_FAST_SPEED304DrawSpriteXY(1, Object.XPos, TempValue5)305DrawSpriteXY(2, Object.XPos, TempValue5)306break307end switch308if Editor.ShowGizmos == true309Editor.DrawingOverlay = true310TempValue0 = Object.YPos311switch Object.PropertyValue312case NORMAL_SPEED313case NORMAL_FAST_LAUNCH314TempValue0 -= 0x400000315DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)316TempValue0 += 0x800000317DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)318break319case LARGE_NORMAL_SPEED320case LARGE_FAST_SPEED321TempValue0 -= 0x800000322DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)323TempValue0 += 0x1100000324DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)325break326end switch327Editor.DrawingOverlay = false328end if329end sub330331332sub RSDKLoad333LoadSpriteSheet("R8/Objects.gif")334335SpriteFrame(-32, -32, 64, 64, 1, 1) // #0 - Crush Platform (also the middle of the large Crush Platform)336SpriteFrame(-32, -96, 64, 64, 1, 1) // #1 - Large Crush Platform Top337SpriteFrame(-32, 32, 64, 64, 1, 1) // #2 - Large Crush Platform Bottom338339AddEditorVariable("type")340SetActiveVariable("type")341AddEnumVariable("Normal Speed", 0)342AddEnumVariable("Normal Speed, Start Bottom", 1)343AddEnumVariable("Large, Normal Speed", 2)344AddEnumVariable("Large, Fast Speed", 3)345AddEnumVariable("Normal Speed, Fast Launch", 4)346end sub347348349