You are on page 1of 3

//----------------Sonic CD Flying Bird Script-----------------//

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


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

// Aliases
#alias Object.Value0 : Object.Timer
#alias Object.Value1 : Object.Angle

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

// States
#alias 0 : BIRD_FLYRIGHT
#alias 1 : BIRD_FLYLEFT

// Time Period Aliases


#alias 2 : TIME_GOOD_FUTURE

sub ObjectMain
switch Object.State
case BIRD_FLYRIGHT
if Object.Angle > 0
Object.Angle -= 2
else
// Apex reached, turn around
Object.State = BIRD_FLYLEFT
Object.Direction = FACING_LEFT
end if
break

case BIRD_FLYLEFT
if Object.Angle < 256
Object.Angle += 2
else
// Other side's apex reached, (re)turn once again
Object.State = BIRD_FLYRIGHT
Object.Direction = FACING_RIGHT
end if
break

end switch

// Animate the Bird


Object.Timer++
if Object.Timer > 19
Object.Timer = 0
Object.Frame++
Object.Frame &= 1
end if

end sub

sub ObjectDraw
if MetalSonic_Destroyed == true
Cos(TempValue0, Object.Angle)
TempValue0 <<= 14
TempValue0 += Object.XPos
Sin(TempValue1, Object.Angle)
TempValue1 <<= 14
TempValue1 += Object.YPos

DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, TempValue1)


else

if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
Cos(TempValue0, Object.Angle)
TempValue0 <<= 14
TempValue0 += Object.XPos

Sin(TempValue1, Object.Angle)
TempValue1 <<= 14
TempValue1 += Object.YPos

DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, TempValue1)


end if

end if

end sub

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

// Bird Frames

SpriteFrame(-8, -8, 16, 16, 143, 110)


SpriteFrame(-8, -8, 16, 16, 143, 127)

// Find all Flying Birds in the level


ArrayPos0 = 32
while ArrayPos0 < 1056
if Object[ArrayPos0].Type == TypeName[Flying Bird]

// Give the Bird a high Draw Order


// Birds should fly above everything else, after all
Object[ArrayPos0].DrawOrder = 5

end if

ArrayPos0++
loop

end sub

// ========================
// Editor Subs
// ========================

sub RSDKDraw
DrawSprite(0)
end sub
sub RSDKLoad
LoadSpriteSheet("R8/Objects2.gif")
SpriteFrame(-8, -8, 16, 16, 143, 110)

SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end sub

You might also like