Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Animals/R8_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 : BIRD_FLYRIGHT
14
#alias 1 : BIRD_FLYLEFT
15
16
// Time Period Aliases
17
#alias 2 : TIME_GOOD_FUTURE
18
19
20
sub ObjectMain
21
switch Object.State
22
case BIRD_FLYRIGHT
23
if Object.Angle > 0
24
Object.Angle -= 2
25
else
26
// Apex reached, turn around
27
Object.State = BIRD_FLYLEFT
28
Object.Direction = FACING_LEFT
29
end if
30
break
31
32
case BIRD_FLYLEFT
33
if Object.Angle < 256
34
Object.Angle += 2
35
else
36
// Other side's apex reached, (re)turn once again
37
Object.State = BIRD_FLYRIGHT
38
Object.Direction = FACING_RIGHT
39
end if
40
break
41
42
end switch
43
44
// Animate the Bird
45
Object.Timer++
46
if Object.Timer > 19
47
Object.Timer = 0
48
Object.Frame++
49
Object.Frame &= 1
50
end if
51
52
end sub
53
54
55
sub ObjectDraw
56
if MetalSonic_Destroyed == true
57
Cos(TempValue0, Object.Angle)
58
TempValue0 <<= 14
59
TempValue0 += Object.XPos
60
61
Sin(TempValue1, Object.Angle)
62
TempValue1 <<= 14
63
TempValue1 += Object.YPos
64
65
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, TempValue1)
66
else
67
68
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
69
Cos(TempValue0, Object.Angle)
70
TempValue0 <<= 14
71
TempValue0 += Object.XPos
72
73
Sin(TempValue1, Object.Angle)
74
TempValue1 <<= 14
75
TempValue1 += Object.YPos
76
77
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, TempValue1)
78
end if
79
80
end if
81
82
end sub
83
84
85
sub ObjectStartup
86
LoadSpriteSheet("R8/Objects2.gif")
87
88
// Bird Frames
89
90
SpriteFrame(-8, -8, 16, 16, 143, 110)
91
SpriteFrame(-8, -8, 16, 16, 143, 127)
92
93
// Find all Flying Birds in the level
94
ArrayPos0 = 32
95
while ArrayPos0 < 1056
96
if Object[ArrayPos0].Type == TypeName[Flying Bird]
97
98
// Give the Bird a high Draw Order
99
// Birds should fly above everything else, after all
100
Object[ArrayPos0].DrawOrder = 5
101
102
end if
103
104
ArrayPos0++
105
loop
106
107
end sub
108
109
110
// ========================
111
// Editor Subs
112
// ========================
113
114
sub RSDKDraw
115
DrawSprite(0)
116
end sub
117
118
119
sub RSDKLoad
120
LoadSpriteSheet("R8/Objects2.gif")
121
SpriteFrame(-8, -8, 16, 16, 143, 110)
122
123
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
124
end sub
125
126