Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Animals/R7_Bird.txt
1319 views
1
//---------------Sonic CD Flying Bird Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.Angle
8
9
// HUD alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// States
13
#alias 0 : FLYINGBIRD_FLYRIGHT
14
#alias 1 : FLYINGBIRD_FLYLEFT
15
16
// Time Period Aliases
17
#alias 2 : TIME_GOOD_FUTURE
18
19
20
sub ObjectMain
21
22
// Note about the Object:
23
// It's always running and animating, regardless of the stage's current state,
24
// but it just hides itself in situations where it shouldn't show
25
26
switch Object.State
27
case FLYINGBIRD_FLYRIGHT
28
if Object.Angle > 0
29
Object.Angle -= 2
30
else
31
// Hit the peak, turn around
32
Object.State = FLYINGBIRD_FLYLEFT
33
Object.Direction = FACING_LEFT
34
end if
35
break
36
37
case FLYINGBIRD_FLYLEFT
38
if Object.Angle < 256
39
Object.Angle += 2
40
else
41
// Hit the other side of the peak, turn right around again
42
Object.State = FLYINGBIRD_FLYRIGHT
43
Object.Direction = FACING_RIGHT
44
end if
45
break
46
47
end switch
48
49
50
// Animate the object
51
Object.Timer++
52
if Object.Timer > 19
53
Object.Timer = 0
54
Object.Frame++
55
Object.Frame &= 1
56
end if
57
58
end sub
59
60
61
sub ObjectDraw
62
63
// Conditions for the Bird to show:
64
// Either have the Metal Sonic generator for the stage destroyed,
65
// or be in the Good Future of the Round
66
67
if MetalSonic_Destroyed == true
68
Cos(TempValue0, Object.Angle)
69
TempValue0 <<= 14
70
TempValue0 += Object.XPos
71
72
Sin(TempValue1, Object.Angle)
73
TempValue1 <<= 14
74
TempValue1 += Object.YPos
75
76
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, TempValue1)
77
else
78
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
79
Cos(TempValue0, Object.Angle)
80
TempValue0 <<= 14
81
TempValue0 += Object.XPos
82
83
Sin(TempValue1, Object.Angle)
84
TempValue1 <<= 14
85
TempValue1 += Object.YPos
86
87
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, TempValue1)
88
end if
89
end if
90
91
end sub
92
93
94
sub ObjectStartup
95
LoadSpriteSheet("R7/Objects.gif")
96
97
// Bird Frames
98
SpriteFrame(-8, -8, 16, 16, 34, 186)
99
SpriteFrame(-8, -8, 16, 16, 34, 203)
100
101
// Find all Flying Bird Objects in the stage
102
ArrayPos0 = 32
103
while ArrayPos0 < 1056
104
if Object[ArrayPos0].Type == TypeName[Flying Bird]
105
106
// Set the Object's Draw Order to be above most other objects and the stage
107
Object[ArrayPos0].DrawOrder = 5
108
109
end if
110
ArrayPos0++
111
loop
112
113
end sub
114
115
116
// ========================
117
// Editor Subs
118
// ========================
119
120
sub RSDKDraw
121
DrawSprite(0)
122
end sub
123
124
125
sub RSDKLoad
126
LoadSpriteSheet("R7/Objects.gif")
127
SpriteFrame(-8, -8, 16, 16, 34, 186)
128
129
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
130
end sub
131
132