Path: blob/main/Scripts/R5/RotatingLog.txt
1319 views
//----------------Sonic CD Rotating Log Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Angle67#alias Object.Value1 : Object.LogX8#alias Object.Value2 : Object.LogY910#alias Object.Value3 : Object.ChangeX11#alias Object.Value4 : Object.ChangeY1213// Collision14#alias 1 : PLAYER_COL_FLOOR1516// Time Period Aliases17#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1819#alias 0 : TIME_PRESENT20#alias 1 : TIME_PAST21#alias 2 : TIME_GOOD_FUTURE22#alias 3 : TIME_BAD_FUTURE2324// Ink Effect25#alias 1 : INK_BLEND2627// Property Values28#alias 0 : CHILD_OBJECT29#alias 1 : PARENT_OBJECT303132sub ObjectMain3334Object.Angle++35Object.Angle &= 5113637// Radius value38TempValue1 = 963940// Get the X change for the platform41Cos(Object.ChangeX, Object.Angle)42Object.ChangeX *= TempValue143Object.ChangeX <<= 744Object.ChangeX += Object.XPos45Object.ChangeX &= 0xFFFF0000 // Truncate the value46Object.ChangeX -= Object.LogX4748// And then get the Y change for the platform49Sin(Object.ChangeY, Object.Angle)50Object.ChangeY *= TempValue151Object.ChangeY <<= 752Object.ChangeY += Object.YPos53Object.ChangeY &= 0xFFFF0000 // Truncate the value54Object.ChangeY -= Object.LogY5556end sub575859sub ObjectPlayerInteraction6061// Backup the Object's base position62TempValue0 = Object.XPos63TempValue1 = Object.YPos6465// And move the object to where the Log Platform actually is66Object.XPos = Object.LogX67Object.YPos = Object.LogY6869// Test to see if the Player's on the Log70PlayerObjectCollision(C_BOX, -8, -8, 8, 8)71if CheckResult == PLAYER_COL_FLOOR7273// Move them along if needed74Player.XPos += Object.ChangeX75Player.YPos += Object.ChangeY7677end if7879// Restore the Object to its base position80Object.XPos = TempValue081Object.YPos = TempValue18283end sub848586sub ObjectDraw8788// Radius value89TempValue1 = 969091// Get the X Position of the Log92Cos(Object.LogX, Object.Angle)93Object.LogX *= TempValue194Object.LogX <<= 795Object.LogX += Object.XPos96Object.LogX &= 0xFFFF0000 // Truncate the value9798// Get the Y Position of the Log99Sin(Object.LogY, Object.Angle)100Object.LogY *= TempValue1101Object.LogY <<= 7102Object.LogY += Object.YPos103Object.LogY &= 0xFFFF0000 // Truncate the value104105DrawSpriteXY(0, Object.LogX, Object.LogY)106107end sub108109110sub ObjectStartup111LoadSpriteSheet("R5/Objects.gif")112113// Rotating Log Frames114// Uses separate sprites for each time zone115switch HUD.CurrentTimePeriod116case TIME_PRESENT117SpriteFrame(-8, -8, 16, 16, 35, 1)118break119120case TIME_PAST121SpriteFrame(-8, -8, 16, 16, 67, 174)122break123124case TIME_GOOD_FUTURE125SpriteFrame(-8, -8, 16, 16, 83, 174)126break127128case TIME_BAD_FUTURE129SpriteFrame(-8, -8, 16, 16, 83, 158)130break131132end switch133134// Cycle through all Rotating Log objects in the level135ArrayPos0 = 32136while ArrayPos0 < 1056137if Object[ArrayPos0].Type == TypeName[Rotating Log]138139// See if the object is a Leading Log140switch Object[ArrayPos0].PropertyValue141case PARENT_OBJECT142// Set the starting angle of the next 7 Logs, as well as the current one143144Object[ArrayPos0].Angle = 504145ArrayPos0++146147Object[ArrayPos0].Angle = 8148ArrayPos0++149150Object[ArrayPos0].Angle = 120151ArrayPos0++152153Object[ArrayPos0].Angle = 136154ArrayPos0++155156Object[ArrayPos0].Angle = 248157ArrayPos0++158159Object[ArrayPos0].Angle = 264160ArrayPos0++161162Object[ArrayPos0].Angle = 376163ArrayPos0++164165Object[ArrayPos0].Angle = 392166break167end switch168end if169170ArrayPos0++171loop172173end sub174175176// ========================177// Editor Subs178// ========================179180sub RSDKEdit181if Editor.ReturnVariable == true182switch Editor.VariableID183case EDIT_VAR_PROPVAL // Property Value184CheckResult = Object.PropertyValue185break186case 0 // IsLeader187CheckResult = Object.PropertyValue188break189end switch190else191switch Editor.VariableID192case EDIT_VAR_PROPVAL // Property Value193Object.PropertyValue = Editor.VariableValue194break195case 0 // IsLeader196Object.PropertyValue = Editor.VariableValue197break198end switch199end if200end sub201202203sub RSDKDraw204DrawSprite(0)205206if Editor.ShowGizmos == true207Editor.DrawingOverlay = true208209if Object.PropertyValue == 1210TempValue0 = 504211else212GetObjectType(TempValue1, "Rotating Log")213ArrayPos0 = Object.EntityNo214TempValue0 = 0215216TempValue2 = false217218while TempValue2 == false219if TempValue0 == 8220TempValue2 = true221end if222223ArrayPos0--224TempValue0++225226CheckEqual(Object[ArrayPos0].Type, TempValue1)227TempValue2 = CheckResult228CheckEqual(Object[ArrayPos0].PropertyValue, true)229TempValue2 &= CheckResult230loop231232switch TempValue0233case 1234TempValue0 = 392; break235case 2236TempValue0 = 376; break237case 3238TempValue0 = 264; break239case 4240TempValue0 = 248; break241case 5242TempValue0 = 136; break243case 6244TempValue0 = 120; break245case 7246TempValue0 = 8; break247248// should never get here!249case 0250default251TempValue0 = 504; break252253end switch254end if255256Cos(TempValue1, TempValue0)257TempValue1 *= 96258TempValue1 <<= 7259TempValue1 += Object.XPos260TempValue1 &= 0xFFFF0000 // Truncate the value261262// Get the Y Position of the Log263Sin(TempValue2, TempValue0)264TempValue2 *= 96265TempValue2 <<= 7266TempValue2 += Object.YPos267TempValue2 &= 0xFFFF0000 // Truncate the value268269Object.InkEffect = INK_BLEND270271DrawSpriteFX(0, FX_INK, TempValue1, TempValue2)272273Editor.DrawingOverlay = false274end if275end sub276277278sub RSDKLoad279LoadSpriteSheet("R5/Objects.gif")280281// TODO: this is currently using the Present version of the sprite, with no heed for other time zones282// however, surely there's some better way to do this than 10 CheckCurrentStageFolder checks..?283SpriteFrame(-8, -8, 16, 16, 35, 1)284285AddEditorVariable("IsLeader")286SetActiveVariable("IsLeader")287AddEnumVariable("false", 0)288AddEnumVariable("true", 1)289end sub290291292