Path: blob/main/Scripts/Animals/R7_Rabbit.txt
1319 views
//------------------Sonic CD Rabbit Script--------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.YVelocity6#alias Object.Value1 : Object.Bounces78// HUD alias9#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1011// States12#alias 0 : RABBIT_HOPRIGHT13#alias 1 : RABBIT_HOPLEFT1415// Collision Side Aliases16#alias 0 : CSIDE_FLOOR1718// Time Period Aliases19#alias 2 : TIME_GOOD_FUTURE202122sub ObjectMain2324// Note: As with the other animals, this Rabbit is always running, regardless of the stage's or generator's state25// However, it's just set not to draw if it's in a scenario it shouldn't, although it is always being updated all the same2627// Update the Y movement of the Rabbit28Object.YPos += Object.YVelocity2930// Apply a gravity of ~0.17 pixels per frame31Object.YVelocity += 0x2C003233switch Object.State34case RABBIT_HOPRIGHT3536// Move the Rabbit right at a speed of 1 pixel per frame37Object.XPos += 0x100003839// The Rabbit can only interact with the floor if it's falling at a rate of 4 pixels per frame or more40if Object.YVelocity > 0x400004142// Check to see if the Rabbit's landed43ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)4445if CheckResult == true46// If the Rabbit's landed, then bounce it back up again at a rate of 5 px per frame47Object.YVelocity = -0x500004849// Incerase the Bounce count so that the Rabbit will be able to turn around again when needed50Object.Bounces++5152if Object.Bounces == 253// If this is the Rabbit's third bounce in this direction, then turn it around5455Object.Bounces = 05657Object.State = RABBIT_HOPLEFT58Object.Direction = FACING_LEFT59end if60end if61end if62break6364case RABBIT_HOPLEFT6566// Move the Rabbit left at a 1 pixel per frame rate67Object.XPos -= 0x100006869// The Rabbit's only allowed to bounce when going downards at a rate of 4 pixels per frame or more70if Object.YVelocity > 0x400007172// Check to see if the Rabbit's landed73ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)7475if CheckResult == true76// The Rabbit's on the floor, so shoot it up again with a velocity of 5 pixels upwards per frame77Object.YVelocity = -0x500007879// Add to the Bounce count, in order to know when to turn around80Object.Bounces++8182if Object.Bounces == 283// The Rabbit should bounce twice, then turn around8485Object.Bounces = 08687Object.State = RABBIT_HOPRIGHT88Object.Direction = FACING_RIGHT89end if90end if91end if92break9394end switch9596end sub979899sub ObjectDraw100101// Only draw if the stage's generator has been destroyed or we're in the Good Future right now102103if MetalSonic_Destroyed == true104if Object.YVelocity < 0105DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)106else107DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)108end if109else110if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE111if Object.YVelocity < 0112DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)113else114DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)115end if116end if117end if118119end sub120121122sub ObjectStartup123LoadSpriteSheet("R7/Objects.gif")124125// Rabbit Frames126SpriteFrame(-8, -12, 16, 24, 1, 232)127SpriteFrame(-8, -12, 16, 24, 18, 232)128129// Used to be below LoadSpriteSheet, moved here for consistency130ArrayPos0 = 32131while ArrayPos0 < 1056132if Object[ArrayPos0].Type == TypeName[Rabbit]133Object[ArrayPos0].YVelocity = -0x50000134Object[ArrayPos0].Direction = FACING_RIGHT135end if136ArrayPos0++137loop138139end sub140141142// ========================143// Editor Subs144// ========================145146sub RSDKDraw147DrawSprite(0)148end sub149150151sub RSDKLoad152LoadSpriteSheet("R7/Objects.gif")153SpriteFrame(-8, -12, 16, 24, 1, 232)154155SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")156end sub157158159