Path: blob/main/Scripts/R8/Scarab.txt
1319 views
//-------------------Sonic CD Scarab 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.XVelocity7#alias Object.Value2 : Object.XOriginPos8#alias Object.Value3 : Object.YOriginPos9#alias Object.Value4 : Object.LaunchDelay10#alias Object.Value5 : Object.LaunchSpeed11#alias Object.Value6 : Object.OnObject12#alias Object.Value7 : Object.CaryingMonitor1314// States15#alias 0 : SCARAB_MOVE16#alias 1 : SCARAB_STOP1718// Property Values19#alias 0 : DIR_FACING_RIGHT20#alias 1 : DIR_FACING_LEFT21#alias 2 : DIR_FACING_RIGHT_S22#alias 3 : DIR_FACING_LEFT_S23#alias 4 : DIR_FACING_RIGHT_W_OBJ2425// Priority26#alias 0 : PRIORITY_BOUNDS27#alias 1 : PRIORITY_ACTIVE2829// Warp Destination30#alias 0 : WARPDEST_NONE3132// Collision Sides33#alias 0 : CSIDE_FLOOR343536sub ObjectMain37switch Object.State38case SCARAB_MOVE39Object.Priority = PRIORITY_ACTIVE4041if Object.Timer < 6042Object.Timer++43Object.XPos += Object.XVelocity44else45Object.Timer = 046Object.State = SCARAB_STOP47end if4849ObjectTileGrip(CSIDE_FLOOR, 0, 12, 0)50if Object.XVelocity > 051TempValue0 = Object.XPos52TempValue0 -= Object.XOriginPos53if TempValue0 > 0x40000054FlipSign(Object.XVelocity)55end if56else57TempValue0 = Object.XOriginPos58TempValue0 -= Object.XPos59if TempValue0 > 0x40000060FlipSign(Object.XVelocity)61end if62end if6364Object.AnimationTimer += Object.AnimationSpeed65Object.AnimationTimer %= 4066break6768case SCARAB_STOP69if Object.Timer < 3070Object.Timer++71else72Object.Timer = 073Object.State = SCARAB_MOVE74end if75break76end switch7778if Object.LaunchDelay > 079if Player.State == Player_State_Death80Object.LaunchDelay = 081else82if Object.Direction == FACING_RIGHT83Player.XPos = Object.XPos84Player.XPos -= 0x18000085Player.YPos = Object.YPos86Player.YPos -= 0x3000087else88Player.XPos = Object.XPos89Player.XPos += 0x18000090Player.YPos = Object.YPos91Player.YPos -= 0x3000092end if93Object.LaunchDelay--94if Object.LaunchDelay == 095Player.State = Player_State_Roll96Player.Speed = Object.LaunchSpeed97Player.XVelocity = Player.Speed98end if99end if100end if101102if Object.CaryingMonitor == true103if Object[+1].Type == TypeName[Monitor]104Object[+1].XPos = Object.XPos105Object[+1].XPos -= 0x180000106107Object[+1].YPos = Object.YPos108Object[+1].YPos -= 0x40000109else110Object[+1].Type = TypeName[Blank Object]111Object.CaryingMonitor = false112end if113end if114115CallFunction(StageSetup_CheckGoodFuture)116if Object.OutOfBounds == true117TempValue0 = Object.XPos118TempValue1 = Object.YPos119120Object.XPos = Object.XOriginPos121Object.YPos = Object.YOriginPos122123if Object.OutOfBounds == true // If starting position was out of bounds too, then we can safely go back124Object.Priority = PRIORITY_BOUNDS125Object.State = SCARAB_MOVE126Object.Timer = 0127Object.AnimationTimer = 0128129if Object.XVelocity < 0130FlipSign(Object.XVelocity)131end if132else133Object.XPos = TempValue0134Object.YPos = TempValue1135end if136end if137end sub138139140sub ObjectPlayerInteraction141if Object.State < 2 // This is always true142if Object.LaunchDelay == 0143if Object.Direction == FACING_RIGHT144PlayerObjectCollision(C_TOUCH, -32, -12, -12, 12)145if CheckResult == true146if Object.OnObject == false147Object.LaunchDelay = 120148149Player.Animation = ANI_JUMPING150Player.State = Player_State_Static151152Player.Speed = 0153Player.XVelocity = 0154Player.YVelocity = 0155156Player.XPos = Object.XPos157Player.XPos -= 0x180000158159Player.YPos = Object.YPos160Player.YPos -= 0x30000161162Player.Direction = FACING_RIGHT163164if Warp.Destination > WARPDEST_NONE165if Warp.Timer > 99166if Warp.Timer < 220 // They forgot to fix the warp timer here167Warp.Destination = WARPDEST_NONE168end if169end if170Warp.Timer = 0171end if172173Object.OnObject = true174end if175else176Object.OnObject = false177PlayerObjectCollision(C_TOUCH, -12, -12, 20, 12)178if CheckResult == true179CallFunction(Player_BadnikBreak)180end if181end if182else183PlayerObjectCollision(C_TOUCH, 12, -12, 32, 12)184if CheckResult == true185if Object.OnObject == false186Object.LaunchDelay = 120187188Player.Animation = ANI_JUMPING189Player.State = Player_State_Static190191Player.Speed = 0192Player.XVelocity = 0193Player.YVelocity = 0194195Player.XPos = Object.XPos196Player.XPos += 0x180000197198Player.YPos = Object.YPos199Player.YPos -= 0x30000200201Player.Direction = FACING_LEFT202203if Warp.Destination > WARPDEST_NONE204if Warp.Timer > 99205if Warp.Timer < 220 // They forgot to fix the warp timer here206Warp.Destination = WARPDEST_NONE207end if208end if209Warp.Timer = 0210end if211212Object.OnObject = true213end if214else215Object.OnObject = false216#platform: Use_Standalone217PlayerObjectCollision(C_TOUCH, -20, -12, 12, 12)218#endplatform219#platform: Use_Origins220PlayerObjectCollision(C_ENEMY, -20, -12, 12, 12)221#endplatform222if CheckResult == true223CallFunction(Player_BadnikBreak)224end if225end if226end if227end if228end if229end sub230231232sub ObjectDraw233if Object.State < 2 // This is always true234if Object.DrawOrder == 3235Object.Frame = Object.AnimationTimer236Object.Frame /= 20237Object.Frame += Object[ArrayPos0].PropertyValue // where's this ArrayPos0 even coming from..?238DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)239Object.Frame += 2240SetDrawListEntityRef(Object.EntityNo, 4, Screen.DrawListSize[4])241Screen.DrawListSize[4]++242Object.DrawOrder = 4243else244DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)245Object.DrawOrder = 3246end if247end if248end sub249250251sub ObjectStartup252LoadSpriteSheet("R8/Objects.gif")253254SpriteFrame(-24, -12, 24, 24, 107, 206) // #0 - Scarab Arms frame 0255SpriteFrame(-32, -12, 32, 24, 132, 206) // #1 - Scarab Arms frame 1256257SpriteFrame(-32, -12, 56, 24, 165, 206) // #2 - Scarab frame 0258SpriteFrame(-32, -12, 56, 24, 165, 231) // #3 - Scarab frame 1259260SpriteFrame(-24, -12, 24, 24, 107, 206) // #4 - Scarab Arms frame 0261SpriteFrame(-32, -12, 32, 16, 67, 240) // #5 - Scarab Arms frame 1262263SpriteFrame(-32, -12, 56, 24, 165, 206) // #6 - Scarab frame 0264SpriteFrame(-40, -12, 64, 24, 100, 231) // #7 - Scarab frame 1265266ArrayPos0 = 32267while ArrayPos0 < 1056268if Object[ArrayPos0].Type == TypeName[Scarab]269Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos270Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos271272switch Object[ArrayPos0].PropertyValue273case DIR_FACING_RIGHT274Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT // Set the animation to use un-streched arms275Object[ArrayPos0].XVelocity = 0x6000276Object[ArrayPos0].AnimationSpeed = 2277Object[ArrayPos0].Direction = FACING_RIGHT278Object[ArrayPos0].LaunchSpeed = -0xA0000279break280281case DIR_FACING_LEFT282Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT // Set the animation to use un-streched arms283Object[ArrayPos0].XVelocity = 0x6000284Object[ArrayPos0].AnimationSpeed = 2285Object[ArrayPos0].Direction = FACING_LEFT286Object[ArrayPos0].LaunchSpeed = 0xA0000287break288289case DIR_FACING_RIGHT_S290Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT_W_OBJ // Set the animation to use streched arms291Object[ArrayPos0].XVelocity = 0x3000292Object[ArrayPos0].AnimationSpeed = 1293Object[ArrayPos0].Direction = FACING_RIGHT294Object[ArrayPos0].LaunchSpeed = -0x50000295break296297case DIR_FACING_LEFT_S298Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT_W_OBJ // Set the animation to use streched arms299Object[ArrayPos0].XVelocity = 0x3000300Object[ArrayPos0].AnimationSpeed = 1301Object[ArrayPos0].Direction = FACING_LEFT302Object[ArrayPos0].LaunchSpeed = 0x50000303break304305case DIR_FACING_RIGHT_W_OBJ306Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT // Set the animation to use un-streched arms307Object[ArrayPos0].XVelocity = 0x6000308Object[ArrayPos0].AnimationSpeed = 2309Object[ArrayPos0].Direction = FACING_RIGHT310Object[ArrayPos0].LaunchSpeed = -0xA0000311Object[ArrayPos0].CaryingMonitor = true312break313end switch314end if315ArrayPos0++316loop317end sub318319320// ========================321// Editor Subs322// ========================323324sub RSDKEdit325if Editor.ReturnVariable == true326switch Editor.VariableID327case EDIT_VAR_PROPVAL // Property Value328CheckResult = Object.PropertyValue329CheckResult %= 5330break331case 0 // type332CheckResult = Object.PropertyValue333CheckResult %= 5334break335end switch336else337switch Editor.VariableID338case EDIT_VAR_PROPVAL // Property Value339Object.PropertyValue = Editor.VariableValue340Object.PropertyValue %= 5341break342case 0 // type343Object.PropertyValue = Editor.VariableValue344Object.PropertyValue %= 5345break346end switch347end if348end sub349350sub RSDKDraw351Object.Direction = FACING_RIGHT352switch Object.PropertyValue353case DIR_FACING_LEFT354Object.Direction = FACING_LEFT355case DIR_FACING_RIGHT356DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)357DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)358break359case DIR_FACING_LEFT_S360Object.Direction = FACING_LEFT361case DIR_FACING_RIGHT_S362DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)363DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)364break365case DIR_FACING_RIGHT_W_OBJ366DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)367DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)368if Editor.ShowGizmos == true369Editor.DrawingOverlay = true370if Object[+1].Type == TypeName[Monitor]371DrawLine(Object.XPos, Object.YPos, Object[+1].XPos, Object[+1].YPos, 0, 0, 255)372end if373Editor.DrawingOverlay = false374end if375break376end switch377end sub378379380sub RSDKLoad381LoadSpriteSheet("R8/Objects.gif")382383SpriteFrame(-24, -12, 24, 24, 107, 206) // #0 - Scarab Arms frame 0384SpriteFrame(-32, -12, 32, 24, 132, 206) // #1 - Scarab Arms frame 1385386SpriteFrame(-32, -12, 56, 24, 165, 206) // #2 - Scarab frame 0387SpriteFrame(-32, -12, 56, 24, 165, 231) // #3 - Scarab frame 1388389SpriteFrame(-24, -12, 24, 24, 107, 206) // #4 - Scarab Arms frame 0390SpriteFrame(-32, -12, 32, 16, 67, 240) // #5 - Scarab Arms frame 1391392SpriteFrame(-32, -12, 56, 24, 165, 206) // #6 - Scarab frame 0393SpriteFrame(-40, -12, 64, 24, 100, 231) // #7 - Scarab frame 1394395AddEditorVariable("type")396SetActiveVariable("type")397AddEnumVariable("Facing Right", DIR_FACING_RIGHT)398AddEnumVariable("Facing Left", DIR_FACING_LEFT)399AddEnumVariable("Facing Right (Streched arms)", DIR_FACING_RIGHT_S)400AddEnumVariable("Facing Left (Streched arms)", DIR_FACING_LEFT_S)401AddEnumVariable("Facing Right (Carrying Object)", DIR_FACING_RIGHT_W_OBJ)402end sub403404405