Path: blob/main/Scripts/R3/R3Setup.txt
1319 views
//------------------Sonic CD R3 Setup Script------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.DeformTimer6#alias Object.Value2 : Object.BumperOscillation7#alias Object.Value3 : Object.TurnDirection89// HUD Alias10#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1112// Time Periods13#alias 1 : TIME_PAST1415// Gravity16#alias 1 : GRAVITY_AIR1718// Stage SFX19#alias 1 : SFX_S_BUMPER220#alias 6 : SFX_S_MINIBUMPER2122// Priority23#alias 1 : PRIORITY_ACTIVE2425// Tile Info26#alias 1 : TILEINFO_DIRECTION27#alias 6 : TILEINFO_ANGLEA2829// Deformation Layer30#alias 1 : DEFORM_FG_WATER31#alias 2 : DEFORM_BG323334sub ObjectMain35if Object.TurnDirection == false36if Object.BumperOscillation < 0x30000037Object.BumperOscillation += 0x1000038else39Object.TurnDirection = true40end if41else42if Object.BumperOscillation > -0x30000043Object.BumperOscillation -= 0x1000044else45Object.TurnDirection = false46end if47end if4849if HUD.CurrentTimePeriod != TIME_PAST50RotatingDrum_Timer++51RotatingDrum_Timer %= 2052end if53end sub545556sub ObjectPlayerInteraction57TempValue2 = Player.XPos58TempValue2 >>= 165960TempValue4 = TempValue261TempValue2 -= 862TempValue4 += 86364TempValue3 = Player.YPos65TempValue3 >>= 166667if Player.YVelocity >= 068TempValue3 += Player.CollisionBottom69TempValue3 -= 270else71TempValue3 += Player.CollisionTop72TempValue3 += 273end if7475TempValue5 = TempValue376TempValue7 = 077Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEA)78switch TempValue079case 180TempValue7 = 181break8283case 384TempValue7 = 385Get16x16TileInfo(TempValue6, TempValue2, TempValue3, TILEINFO_DIRECTION)86break8788case 589TempValue7 = 290break9192end switch9394// Note:95// So, funny story about this code segment here below, it has a bias.96// When you encounter the tiles using these values, like the ones in CCZ2A at x-3376 and y-1080, the right most two tiles will send the player right.97// While when you bounce on the left ones, the player will stay on top until they gets bounced by the tile that curves over to the left.9899100Get16x16TileInfo(TempValue0, TempValue4, TempValue5, TILEINFO_ANGLEA)101switch TempValue0102case 1103TempValue7 = 1104break105106case 3107#platform: Use_Origins108if Player.Animation == ANI_CLIMBING109// Before bouncing him away, let's make sure Knuckles is in his normal air state, first110CallFunction(Player_CancelClimb)111end if112#endplatform113TempValue7 = 3114Get16x16TileInfo(TempValue6, TempValue4, TempValue5, TILEINFO_DIRECTION)115break116117case 5118TempValue7 = 2119break120121end switch122123switch TempValue7124case 1125if Player.YVelocity >= 0126Player.Gravity = GRAVITY_AIR127PlayStageSfx(SFX_S_BUMPER2, false)128129130#platform: Use_Haptics131HapticEffect(11, 0, 0, 0)132#endplatform133134if Player.State == Player_State_Fly135Player.YVelocity = -0x40000136else137Player.YVelocity = -0x70000138end if139140if Player.State == Player_State_Hurt141142#platform: Use_Origins143Player.State = Player_State_Air_NoDropDash144#endplatform145146#platform: Use_Standalone147Player.State = Player_State_Air148#endplatform149Player.Timer = 0150end if151else152if Player.Gravity == GRAVITY_AIR153Player.YVelocity = 0x40000154PlayStageSfx(SFX_S_BUMPER2, false)155end if156end if157break158159case 2160if Player.Gravity == GRAVITY_AIR161PlayStageSfx(SFX_S_MINIBUMPER, false)162163#platform: Use_Haptics164HapticEffect(11, 0, 0, 0)165#endplatform166167if Player.YVelocity >= 0168Player.YVelocity = -0x40000169else170Player.YVelocity = 0x40000171end if172end if173break174175case 3176if Player.Gravity == GRAVITY_AIR177PlayStageSfx(SFX_S_BUMPER2, false)178179#platform: Use_Haptics180HapticEffect(11, 0, 0, 0)181#endplatform182183if Player.YVelocity >= 0184if Player.State == Player_State_Fly185Player.YVelocity = -0x40000186else187Player.YVelocity = -0x70000188end if189else190Player.YVelocity = 0x40000191end if192193if TempValue6 == 0194if Player.XVelocity > 0195FlipSign(Player.XVelocity)196Player.XVelocity *= 5197Player.XVelocity >>= 2198if Player.XVelocity > -0x20000199Player.XVelocity = -0x20000200end if201else202if Player.XVelocity > -0x20000203Player.XVelocity = -0x20000204end if205end if206else207if Player.XVelocity < 0208FlipSign(Player.XVelocity)209Player.XVelocity *= 5210Player.XVelocity >>= 2211if Player.XVelocity < 0x20000212Player.XVelocity = 0x20000213end if214else215if Player.XVelocity < 0x20000216Player.XVelocity = 0x20000217end if218end if219end if220Player.Speed = Player.XVelocity221end if222break223end switch224225TempValue3 = Player.YPos226TempValue3 >>= 16227228TempValue5 = TempValue3229TempValue3 -= 6230TempValue5 += 6231232TempValue2 = Player.XPos233TempValue2 >>= 16234235if Player.XVelocity > 0236TempValue2 += 8237else238TempValue2 -= 8239end if240241TempValue4 = TempValue2242TempValue7 = 0243Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEA)244switch TempValue0245case 3246TempValue7 = 1247break248249case 5250TempValue7 = 2251break252253case 7254TempValue7 = 1255break256257end switch258259Get16x16TileInfo(TempValue0, TempValue4, TempValue5, TILEINFO_ANGLEA)260switch TempValue0261case 3262TempValue7 = 1263break264265case 5266TempValue7 = 2267break268269case 7270TempValue7 = 1271break272273end switch274275switch TempValue7276case 1277#platform: Use_Origins278if Player.Animation == ANI_CLIMBING279// Before bouncing him away, let's make sure Knuckles is in his normal air state, first280CallFunction(Player_CancelClimb)281end if282#endplatform283if Player.XVelocity > 0284Player.XVelocity = -0x50000285else286Player.XVelocity = 0x50000287end if288Player.Speed = Player.XVelocity289#platform: Use_Origins290Player.Timer = 0291#endplatform292PlayStageSfx(SFX_S_BUMPER2, false)293break294295case 2296if Player.XVelocity > 0297Player.XVelocity = -0x40000298else299Player.XVelocity = 0x40000300end if301Player.Speed = Player.XVelocity302PlayStageSfx(SFX_S_MINIBUMPER, false)303304#platform: Use_Haptics305HapticEffect(11, 0, 0, 0)306#endplatform307break308309end switch310end sub311312313sub ObjectDraw314Object.DeformTimer++315if Object.DeformTimer > 3316TileLayer[0].DeformationOffsetW++317TileLayer[1].DeformationOffset++318Object.DeformTimer = 0319end if320end sub321322323sub ObjectStartup324Object[29].Type = TypeName[R3 Setup]325Object[29].Priority = PRIORITY_ACTIVE326Object[29].DrawOrder = 0327328SetLayerDeformation(DEFORM_BG, 128, 6, 0, 0, 0)329SetLayerDeformation(DEFORM_FG_WATER, 64, 4, 0, 0, 0)330331Stage.WaterLevel = 1472332333if HUD.CurrentTimePeriod == TIME_PAST334RotatingDrum_Timer = 1335else336RotatingDrum_Timer = 0337end if338end sub339340341// ========================342// Editor Subs343// ========================344345sub RSDKDraw346DrawSprite(0)347end sub348349350sub RSDKLoad351LoadSpriteSheet("Global/Display.gif")352SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon353354SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")355end sub356357358