//---------------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 : FLYINGBIRD_FLYRIGHT
#alias 1 : FLYINGBIRD_FLYLEFT
// Time Period Aliases
#alias 2 : TIME_GOOD_FUTURE
sub ObjectMain
// Note about the Object:
// It's always running and animating, regardless of the stage's current
state,
// but it just hides itself in situations where it shouldn't show
switch Object.State
case FLYINGBIRD_FLYRIGHT
if Object.Angle > 0
Object.Angle -= 2
else
// Hit the peak, turn around
Object.State = FLYINGBIRD_FLYLEFT
Object.Direction = FACING_LEFT
end if
break
case FLYINGBIRD_FLYLEFT
if Object.Angle < 256
Object.Angle += 2
else
// Hit the other side of the peak, turn right around again
Object.State = FLYINGBIRD_FLYRIGHT
Object.Direction = FACING_RIGHT
end if
break
end switch
// Animate the object
Object.Timer++
if Object.Timer > 19
Object.Timer = 0
Object.Frame++
Object.Frame &= 1
end if
end sub
sub ObjectDraw
// Conditions for the Bird to show:
// Either have the Metal Sonic generator for the stage destroyed,
// or be in the Good Future of the Round
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("R7/Objects.gif")
// Bird Frames
SpriteFrame(-8, -8, 16, 16, 34, 186)
SpriteFrame(-8, -8, 16, 16, 34, 203)
// Find all Flying Bird Objects in the stage
ArrayPos0 = 32
while ArrayPos0 < 1056
if Object[ArrayPos0].Type == TypeName[Flying Bird]
// Set the Object's Draw Order to be above most other objects and
the stage
Object[ArrayPos0].DrawOrder = 5
end if
ArrayPos0++
loop
end sub
// ========================
// Editor Subs
// ========================
sub RSDKDraw
DrawSprite(0)
end sub
sub RSDKLoad
LoadSpriteSheet("R7/Objects.gif")
SpriteFrame(-8, -8, 16, 16, 34, 186)
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end sub