Path: blob/main/Scripts/R8/RPlaneShifter.txt
1319 views
//---------------Sonic CD R Plane Shifter Script--------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value1 : Object.AnimFrameTimer6#alias Object.Value2 : Object.OnObject78// States9#alias 0 : RPLANESHIFTER_IDLE10// Facing Right11#alias 1 : RPLANESHIFTER_PLANE_A_TO_B_R12#alias 2 : RPLANESHIFTER_PLANE_B_TO_A_R13// Facing Left14#alias 3 : RPLANESHIFTER_PLANE_A_TO_B_L15#alias 4 : RPLANESHIFTER_PLANE_B_TO_A_L1617// Property Values18#alias 0 : GIMMICK_PARENT19#alias 1 : GIMMICK_CHILD2021// Collision Planes22#alias 0 : COLLISION_PLANE_A23#alias 1 : COLLISION_PLANE_B242526sub ObjectMain27if Player.ObjectInteraction == true28if Object.PropertyValue == GIMMICK_PARENT29switch Object.State30case RPLANESHIFTER_PLANE_A_TO_B_R31if Object.AnimFrameTimer < 25632Object.AnimFrameTimer += 833else34Object.State = RPLANESHIFTER_IDLE35Player.State = Player_State_Ground36Player.Frame = 037Player.DrawOrder = 238Player.CollisionPlane = COLLISION_PLANE_B39end if4041TempValue0 = Object.AnimFrameTimer42TempValue0 >>= 643switch TempValue044case 045Player.Frame = 146break47case 148Player.Frame = 249break50case 251Player.Frame = 352break53case 354Player.Frame = 055Player.Direction = FACING_LEFT56break57end switch5859Object.AnimationTimer++60Object.AnimationTimer %= 661break6263case RPLANESHIFTER_PLANE_B_TO_A_R64if Object.AnimFrameTimer > 065Object.AnimFrameTimer -= 866else67Object.State = RPLANESHIFTER_IDLE68Player.State = Player_State_Ground69Player.Frame = 070Player.DrawOrder = 471Player.CollisionPlane = COLLISION_PLANE_A72end if7374TempValue0 = Object.AnimFrameTimer75TempValue0 >>= 676switch TempValue077case 078Player.Frame = 079Player.Direction = FACING_LEFT80break81case 182Player.Frame = 483break84case 285Player.Frame = 086break87case 388Player.Frame = 189break90end switch9192Object.AnimationTimer++93Object.AnimationTimer %= 694break9596case RPLANESHIFTER_PLANE_A_TO_B_L97if Object.AnimFrameTimer > 25698Object.AnimFrameTimer -= 899else100Object.State = RPLANESHIFTER_IDLE101Player.State = Player_State_Ground102Player.Frame = 0103Player.DrawOrder = 2104Player.CollisionPlane = COLLISION_PLANE_B105end if106107TempValue0 = 512108TempValue0 -= Object.AnimFrameTimer109TempValue0 >>= 6110switch TempValue0111case 0112Player.Frame = 1113break114case 1115Player.Frame = 2116break117case 2118Player.Frame = 3119break120case 3121Player.Frame = 0122Player.Direction = FACING_RIGHT123break124end switch125126Object.AnimationTimer++127Object.AnimationTimer %= 6128break129130case RPLANESHIFTER_PLANE_B_TO_A_L131if Object.AnimFrameTimer < 512132Object.AnimFrameTimer += 8133else134Object.AnimFrameTimer = 0135Object.State = RPLANESHIFTER_IDLE136Player.State = Player_State_Ground137Player.Frame = 0138Player.DrawOrder = 4139Player.CollisionPlane = COLLISION_PLANE_A140end if141142TempValue0 = 512143TempValue0 -= Object.AnimFrameTimer144TempValue0 >>= 6145switch TempValue0146case 0147Player.Frame = 0148Player.Direction = FACING_RIGHT149break150case 1151Player.Frame = 4152break153case 2154Player.Frame = 0155break156case 3157Player.Frame = 1158break159end switch160161Object.AnimationTimer++162Object.AnimationTimer %= 6163break164end switch165166// First Bar167Sin(Object[+1].XPos, Object.AnimFrameTimer)168Object[+1].XPos *= 0xC00169Object[+1].XPos += Object.XPos170Object[+1].YPos = Object.YPos171if Object.AnimFrameTimer > 128172if Object.AnimFrameTimer < 384173Object[+1].DrawOrder = 1174else175Object[+1].DrawOrder = 4176end if177else178Object[+1].DrawOrder = 4179end if180181// Second Bar182TempValue0 = Object.AnimFrameTimer183TempValue0 += 170184TempValue0 &= 511185Sin(Object[+2].XPos, TempValue0)186Object[+2].XPos *= 0xC00187Object[+2].XPos += Object.XPos188Object[+2].YPos = Object.YPos189if TempValue0 > 128190if TempValue0 < 384191Object[+2].DrawOrder = 1192else193Object[+2].DrawOrder = 4194end if195else196Object[+2].DrawOrder = 4197end if198199// Third Bar200TempValue0 = Object.AnimFrameTimer201TempValue0 += 341202TempValue0 &= 511203Sin(Object[+3].XPos, TempValue0)204Object[+3].XPos *= 0xC00205Object[+3].XPos += Object.XPos206Object[+3].YPos = Object.YPos207if TempValue0 > 128208if TempValue0 < 384209Object[+3].DrawOrder = 1210else211Object[+3].DrawOrder = 4212end if213else214Object[+3].DrawOrder = 4215end if216end if217end if218end sub219220221sub ObjectPlayerInteraction222if Object.PropertyValue == GIMMICK_PARENT223PlayerObjectCollision(C_PLATFORM, -40, -8, 40, 24)224TempValue1 = CheckResult225PlayerObjectCollision(C_BOX, -40, -184, 40, -168)226PlayerObjectCollision(C_TOUCH, -4, -48, 4, 8)227if CheckResult == true228if Object.OnObject == false229if TempValue1 == true230Object.OnObject = true231Player.State = Player_State_Static232Player.Animation = ANI_STOPPED233Player.XPos = Object.XPos234Player.Speed = 0235Player.XVelocity = 0236Player.YVelocity = 0237Player.TrackScroll = false238if Player.Direction == FACING_RIGHT239if Player.CollisionPlane == COLLISION_PLANE_A240Object.State = RPLANESHIFTER_PLANE_A_TO_B_R241Object.AnimFrameTimer = 0242else243Object.State = RPLANESHIFTER_PLANE_B_TO_A_R244Object.AnimFrameTimer = 256245end if246else247if Player.CollisionPlane == COLLISION_PLANE_A248Object.State = RPLANESHIFTER_PLANE_A_TO_B_L249Object.AnimFrameTimer = 512250else251Object.State = RPLANESHIFTER_PLANE_B_TO_A_L252Object.AnimFrameTimer = 256253end if254end if255end if256end if257else258Object.OnObject = false259end if260end if261end sub262263264sub ObjectDraw265if Object.PropertyValue == GIMMICK_PARENT266TempValue0 = Object.AnimationTimer267TempValue0 /= 3268DrawSprite(TempValue0)269TempValue0 += 2270DrawSprite(TempValue0)271else272DrawSprite(4)273DrawSprite(5)274DrawSprite(6)275DrawSprite(7)276DrawSprite(8)277end if278end sub279280281sub ObjectStartup282LoadSpriteSheet("R8/Objects2.gif")283284SpriteFrame(-40, -8, 80, 16, 1, 200) // #0 - R Plane Shifter Base frame 0285SpriteFrame(-40, -8, 80, 16, 1, 217) // #1 - R Plane Shifter Base frame 1286287SpriteFrame(-40, -184, 80, 16, 1, 200) // #2 - R Plane Shifter Roof frame 0288SpriteFrame(-40, -184, 80, 16, 1, 217) // #3 - R Plane Shifter Roof frame 1289290SpriteFrame(-4, -40, 8, 32, 100, 35) // #4 - R Plane Shifter Bars 0291SpriteFrame(-4, -72, 8, 32, 100, 35) // #5 - R Plane Shifter Bars 1292SpriteFrame(-4, -104, 8, 32, 100, 35) // #6 - R Plane Shifter Bars 2293SpriteFrame(-4, -136, 8, 32, 100, 35) // #7 - R Plane Shifter Bars 3294SpriteFrame(-4, -168, 8, 32, 100, 35) // #8 - R Plane Shifter Bars 4295end sub296297298// ========================299// Editor Subs300// ========================301302sub RSDKEdit303if Editor.ReturnVariable == true304switch Editor.VariableID305case EDIT_VAR_PROPVAL // Property Value306CheckResult = Object.PropertyValue307CheckResult &= 1308break309case 0 // type310CheckResult = Object.PropertyValue311CheckResult &= 1312break313end switch314else315switch Editor.VariableID316case EDIT_VAR_PROPVAL // Property Value317Object.PropertyValue = Editor.VariableValue318Object.PropertyValue &= 1319break320case 0 // type321Object.PropertyValue = Editor.VariableValue322Object.PropertyValue &= 1323break324end switch325end if326end sub327328sub RSDKDraw329if Object.PropertyValue == GIMMICK_PARENT330TempValue0 = Object.AnimationTimer331TempValue0 /= 3332DrawSprite(TempValue0)333TempValue0 += 2334DrawSprite(TempValue0)335else336ArrayPos0 = Object.EntityNo337TempValue0 = 0338TempValue1 = 0339while TempValue1 == false340if TempValue0 == 3341TempValue1 = true342end if343ArrayPos0--344TempValue0++345CheckEqual(Object[ArrayPos0].Type, TypeName[R Plane Shifter])346TempValue1 = CheckResult347CheckNotEqual(Object[ArrayPos0].PropertyValue, GIMMICK_CHILD)348TempValue1 &= CheckResult349loop350ArrayPos1 = Object.EntityNo351ArrayPos1 -= Object[ArrayPos0].EntityNo352switch ArrayPos1353case 0354TempValue0 = 0355break356case 1357TempValue0 = 0358TempValue0 += 170359TempValue0 &= 511360break361case 2362TempValue0 = 0363TempValue0 += 341364TempValue0 &= 511365break366end switch367Sin(TempValue2, TempValue0)368TempValue2 *= 0xC00369TempValue2 += Object[ArrayPos0].XPos370DrawSpriteXY(4, TempValue2, Object.YPos)371DrawSpriteXY(5, TempValue2, Object.YPos)372DrawSpriteXY(6, TempValue2, Object.YPos)373DrawSpriteXY(7, TempValue2, Object.YPos)374DrawSpriteXY(8, TempValue2, Object.YPos)375end if376end sub377378379sub RSDKLoad380LoadSpriteSheet("R8/Objects2.gif")381382SpriteFrame(-40, -8, 80, 16, 1, 200) // #0 - R Plane Shifter Base frame 0383SpriteFrame(-40, -8, 80, 16, 1, 217) // #1 - R Plane Shifter Base frame 1384385SpriteFrame(-40, -184, 80, 16, 1, 200) // #2 - R Plane Shifter Roof frame 0386SpriteFrame(-40, -184, 80, 16, 1, 217) // #3 - R Plane Shifter Roof frame 1387388SpriteFrame(-4, -40, 8, 32, 100, 35) // #4 - R Plane Shifter Bars 0389SpriteFrame(-4, -72, 8, 32, 100, 35) // #5 - R Plane Shifter Bars 1390SpriteFrame(-4, -104, 8, 32, 100, 35) // #6 - R Plane Shifter Bars 2391SpriteFrame(-4, -136, 8, 32, 100, 35) // #7 - R Plane Shifter Bars 3392SpriteFrame(-4, -168, 8, 32, 100, 35) // #8 - R Plane Shifter Bars 4393394AddEditorVariable("type")395SetActiveVariable("type")396AddEnumVariable("Parent Object", GIMMICK_PARENT)397AddEnumVariable("Child Object", GIMMICK_CHILD)398end sub399400401