R8 Sheep

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

//------------------Sonic CD Sheep Script---------------------//

//--------Scripted by Christian Whitehead 'The Taxman'--------//


//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

// Aliases
#alias Object.Value0 : Object.YVelocity

// HUD alias
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod

// States
#alias 0 : SHEEP_HOPRIGHT
#alias 1 : SHEEP_HOPLEFT

// Collision Side Aliases


#alias 0 : CSIDE_FLOOR

// Time Period Aliases


#alias 2 : TIME_GOOD_FUTURE

sub ObjectMain
Object.YPos += Object.YVelocity

// Gravity of around 0.156px


Object.YVelocity += 0x2800

switch Object.State
case SHEEP_HOPRIGHT

// Advance at a rate of 1px per frame


Object.XPos += 0x10000

// Only check for collision when going down


if Object.YVelocity > 0
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)

if CheckResult == true
// Turn around

Object.Direction = FACING_LEFT

// Bounce back up with a velocity of 5px per frame


Object.YVelocity = -0x50000

Object.State = SHEEP_HOPLEFT
end if
end if
break

case SHEEP_HOPLEFT

// Go left at a rate of 1px per frame


Object.XPos -= 0x10000

// Collision is only to be checked when falling


if Object.YVelocity > 0
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
if CheckResult == true
// Turn around again

Object.Direction = FACING_RIGHT

// Initial Y Velocity of 5px upwards again


Object.YVelocity = -0x50000

Object.State = SHEEP_HOPRIGHT
end if
end if
break

end switch

end sub

sub ObjectDraw
if MetalSonic_Destroyed == true
if Object.YVelocity < 0
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
else
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
end if
end if

if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
if Object.YVelocity < 0
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
else
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
end if
end if

end sub

sub ObjectStartup
LoadSpriteSheet("R8/Objects2.gif")

SpriteFrame(-10, -8, 24, 16, 160, 110)


SpriteFrame(-10, -8, 24, 16, 160, 127)

// Used to be below LoadSpriteSheet, moved here for consistency


// Setup all Sheep in the level
ArrayPos0 = 32
while ArrayPos0 < 1056
if Object[ArrayPos0].Type == TypeName[Sheep]

// Start the Sheep going upwards at 5px per frame


Object[ArrayPos0].YVelocity = -0x50000

end if

ArrayPos0++
loop

end sub
// ========================
// Editor Subs
// ========================

sub RSDKDraw
DrawSprite(0)
end sub

sub RSDKLoad
LoadSpriteSheet("R8/Objects2.gif")
SpriteFrame(-10, -8, 24, 16, 160, 110)

SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end sub

You might also like