Path: blob/main/Scripts/Animals/Squirrel.txt
1319 views
//-----------------Sonic CD Squirrel Script-------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.YVelocity67// HUD alias8#alias Object[24].PropertyValue : HUD.CurrentTimePeriod910// States11#alias 0 : SQUIRREL_HOPRIGHT12#alias 1 : SQUIRREL_HOPLEFT1314// Collision Side Aliases15#alias 0 : CSIDE_FLOOR1617// Time Period18#alias 2 : TIME_GOOD_FUTURE192021sub ObjectMain22Object.YPos += Object.YVelocity2324// Apply a Gravity of about 0.156px25Object.YVelocity += 0x28002627switch Object.State28case SQUIRREL_HOPRIGHT2930// Move a pixel right31Object.XPos += 0x100003233// Only check for collision when going downwards34if Object.YVelocity > 035ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)3637if CheckResult == true38// Turn around3940Object.Direction = FACING_RIGHT4142// Bounce back up, at a starting rate of 5px per frame43Object.YVelocity = -0x500004445Object.State = SQUIRREL_HOPLEFT46end if47end if48break4950case SQUIRREL_HOPLEFT5152// Move a pixel to the left53Object.XPos -= 0x100005455// Collision's only checked when falling56if Object.YVelocity > 057ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)5859if CheckResult == true60// Turn right back around6162Object.Direction = FACING_LEFT6364// Starting Y Velocity of 5px upwards per frame65Object.YVelocity = -0x500006667Object.State = SQUIRREL_HOPRIGHT68end if69end if70break7172end switch7374end sub757677sub ObjectDraw78if MetalSonic_Destroyed == true79if Object.YVelocity < 080DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)81else82DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)83end if84end if8586if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE87if Object.YVelocity < 088DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)89else90DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)91end if92end if93end sub949596sub ObjectStartup97LoadSpriteSheet("Global/Items3.gif")9899SpriteFrame(-10, -8, 24, 16, 150, 35) // #0 - Squirrel frame 0100SpriteFrame(-10, -8, 24, 16, 150, 52) // #1 - Squirrel frame 1101102// Used to be below LoadSpriteSheet, moved here for consistency103// Locate all the stealthy Squirrels in the level104ArrayPos0 = 32105while ArrayPos0 < 1056106if Object[ArrayPos0].Type == TypeName[Squirrel]107108// Give the Squirrel a starting Y Velocity of 5px up109Object[ArrayPos0].YVelocity = -0x50000110111// Start the Squirrel facing Right112// (The base Sprite itself is facing towards the left, which is why this label may not seem right)113Object[ArrayPos0].Direction = FACING_LEFT114115end if116117ArrayPos0++118loop119120end sub121122123// ========================124// Editor Subs125// ========================126127sub RSDKDraw128DrawSprite(0)129end sub130131132sub RSDKLoad133LoadSpriteSheet("Global/Items3.gif")134SpriteFrame(-10, -8, 24, 16, 150, 35)135136SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")137end sub138139140