Path: blob/main/Scripts/Special/Ring.txt
1319 views
//--------------------Sonic CD Ring Script--------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.ZPos6#alias Object.Value1 : Object.XVelocity7#alias Object.Value2 : Object.YVelocity8#alias Object.Value3 : Object.ZVelocity9#alias Object.Value4 : Object.Timer10#alias Object.Value5 : Object.ScreenDepth11#alias Object.Value6 : Object.ScreenXPos121314sub ObjectMain15// Update movements16Object.XPos += Object.XVelocity17Object.YPos += Object.YVelocity18Object.ZPos += Object.ZVelocity1920// Apply a gravity of an eight of a pixel per frame21Object.YVelocity -= 0x20002223if Object.YPos < 024// If the ring has hit the floor, then bounce back up2526Object.YPos = 027FlipSign(Object.YVelocity)28end if2930TempValue0 = Object.XPos31TempValue0 -= TileLayer[0].XPos32TempValue0 >>= 83334TempValue1 = Object.ZPos35TempValue1 -= TileLayer[0].ZPos36TempValue1 >>= 83738Sin(TempValue2, TileLayer[0].Angle)39TempValue2 *= TempValue140Cos(TempValue3, TileLayer[0].Angle)41TempValue3 *= TempValue04243Object.ScreenXPos = TempValue244Object.ScreenXPos -= TempValue345Object.ScreenXPos >>= 94647Cos(TempValue2, TileLayer[0].Angle)48TempValue2 *= TempValue149Sin(TempValue3, TileLayer[0].Angle)50TempValue3 *= TempValue05152Object.ScreenDepth = TempValue253Object.ScreenDepth += TempValue354Object.ScreenDepth >>= 95556// Make the ring despawn after a little bit57Object.Timer++58if Object.Timer == 16059Object.Type = TypeName[Blank Object]60end if6162end sub636465sub ObjectDraw66if Object.ScreenDepth > 256 // Don't draw if the Ring is too close to the screen6768// Do some maths to find the position & scale the Ring should be at6970Object.Scale = 0xC0000071Object.Scale /= Object.ScreenDepth7273TempValue0 = 76874TempValue0 -= Object.Scale75TempValue0 /= 67677TempValue1 = Object.ScreenDepth78TempValue1 >>= 127980if TempValue0 > 081Object.Scale += TempValue082Object.Scale -= TempValue183end if8485TempValue0 = Object.ScreenXPos86TempValue0 *= 19287TempValue0 /= Object.ScreenDepth88TempValue0 += Screen.CenterX8990TempValue1 = TileLayer[0].YPos91TempValue1 -= Object.YPos92TempValue1 >>= 893TempValue1 *= 9694TempValue1 /= Object.ScreenDepth95TempValue1 += 1289697// Find the sprite to draw the Ring with98TempValue2 = Object.Timer99TempValue2 &= 31100TempValue2 >>= 3101102DrawSpriteScreenFX(TempValue2, FX_SCALE, TempValue0, TempValue1)103104// Find the position of the ground where the ring is105TempValue1 = TileLayer[0].YPos106TempValue1 >>= 8107TempValue1 *= 96108TempValue1 /= Object.ScreenDepth109TempValue1 += 128110111// Draw a shadow there112DrawSpriteScreenFX(4, FX_SCALE, TempValue0, TempValue1)113114end if115116end sub117118119sub ObjectStartup120121LoadSpriteSheet("Special/Objects.gif")122123// Ring Frames124SpriteFrame(-10, -24, 20, 24, 52, 59)125SpriteFrame(-7, -24, 15, 24, 73, 59)126SpriteFrame(-4, -24, 9, 24, 89, 59)127SpriteFrame(-7, -24, 15, 24, 99, 59)128129// Shadow Frame130SpriteFrame(-9, -4, 18, 8, 83, 117)131132end sub133134135// ========================136// Editor Subs137// ========================138139sub RSDKDraw140DrawSprite(0)141end sub142143144sub RSDKLoad145LoadSpriteSheet("Special/Objects.gif")146SpriteFrame(-10, -24, 20, 24, 52, 59)147148SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")149end sub150151152