Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/Flower.txt
1319 views
1
//-------------------Sonic CD Flower 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
8
// States
9
#alias 0 : FLOWER_SEED_SPAWN
10
#alias 1 : FLOWER_SEED_FALL
11
12
#alias 2 : FLOWER_SEED_PLANTED_1
13
#alias 3 : FLOWER_SEED_PLANTED_2
14
#alias 4 : FLOWER_SEED_PLANTED_3
15
16
#alias 5 : FLOWER_ROOT_GROWTH_1
17
#alias 6 : FLOWER_ROOT_GROWTH_2
18
#alias 7 : FLOWER_ROOT_GROWTH_3
19
20
#alias 8 : FLOWER_ANIM_2
21
#alias 9 : FLOWER_ANIM_3
22
23
// Collision Sides
24
#alias 0 : CSIDE_FLOOR
25
26
27
sub ObjectMain
28
switch Object.State
29
case FLOWER_SEED_SPAWN
30
// Hover as a seed for a brief moment
31
32
// Frame 8 is the invisible frame
33
Object.Frame = 8
34
Object.Timer++
35
if Object.Timer == 20
36
Object.Timer = 0
37
Object.State++
38
end if
39
break
40
41
case FLOWER_SEED_FALL
42
Object.Frame = Object.Timer
43
Object.Frame >>= 2
44
45
Object.Timer++
46
Object.Timer &= 7
47
48
// Fall at a graceful speed of 2 pixels per frame
49
Object.YPos += 0x20000
50
51
// Check if the Flower has touched the ground
52
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
53
if CheckResult == true
54
// If it has, then turn it into a full-on Flower
55
56
// First, move the seed 8 pixels down since Flowers' offsets are further than that of seeds
57
Object.YPos += 0x80000
58
59
Object.State++
60
Object.Timer = 0
61
Object.Frame = 2
62
end if
63
break
64
65
// All the growth animation frames are their own mini-state, just about the same thing
66
67
case FLOWER_SEED_PLANTED_1
68
Object.Timer++
69
if Object.Timer == 4
70
Object.Timer = 0
71
Object.State++
72
Object.Frame = 3
73
end if
74
break
75
76
case FLOWER_SEED_PLANTED_2
77
Object.Timer++
78
if Object.Timer == 4
79
Object.Timer = 0
80
Object.State++
81
Object.Frame = 2
82
end if
83
break
84
85
case FLOWER_SEED_PLANTED_3
86
Object.Timer++
87
if Object.Timer == 4
88
Object.Timer = 0
89
Object.State++
90
Object.Frame = 3
91
end if
92
break
93
94
case FLOWER_ROOT_GROWTH_1
95
Object.Timer++
96
if Object.Timer == 5
97
Object.Timer = 0
98
Object.State++
99
Object.Frame = 4
100
end if
101
break
102
103
case FLOWER_ROOT_GROWTH_2
104
Object.Timer++
105
if Object.Timer == 4
106
Object.Timer = 0
107
Object.State++
108
Object.Frame = 5
109
end if
110
break
111
112
case FLOWER_ROOT_GROWTH_3
113
Object.Timer++
114
if Object.Timer == 2
115
Object.Timer = 0
116
Object.State++
117
Object.Frame = 6
118
end if
119
break
120
121
// Similarly, the main flower animation is also comprised of two near-identical states
122
123
case FLOWER_ANIM_2
124
Object.Timer++
125
if Object.Timer == 20
126
Object.Timer = 0
127
Object.State++
128
Object.Frame = 7
129
end if
130
break
131
132
case FLOWER_ANIM_3
133
Object.Timer++
134
if Object.Timer == 20
135
Object.Timer = 0
136
Object.State--
137
Object.Frame = 6
138
end if
139
break
140
141
end switch
142
end sub
143
144
145
sub ObjectDraw
146
DrawSprite(Object.Frame)
147
end sub
148
149
150
sub ObjectStartup
151
LoadSpriteSheet("R7/Objects2.gif")
152
153
SpriteFrame(-4, -8, 8, 16, 26, 170) // #0 - Seed Frame 0
154
SpriteFrame(-4, -8, 8, 16, 35, 170) // #1 - Seed Frame 1
155
156
SpriteFrame(-8, -8, 16, 16, 44, 170) // #2 - Planted Seed Frame 0
157
SpriteFrame(-8, -8, 16, 16, 26, 187) // #3 - Planted Seed Frame 1
158
159
SpriteFrame(0, -8, 8, 16, 66, 99) // #4 - Flower Growth Frame 0
160
SpriteFrame(-12, -24, 24, 24, 66, 25) // #5 - Flower Growth Frame 1
161
162
SpriteFrame(-12, -48, 24, 48, 66, 1) // #6 - Flower Frame 0
163
SpriteFrame(-12, -48, 24, 48, 66, 50) // #7 - Flower Frame 1
164
165
SpriteFrame(0, 0, 0, 0, 73, 132) // #8 - Cheat Sprite, blank frame
166
167
end sub
168
169
170
// ========================
171
// Editor Subs
172
// ========================
173
174
sub RSDKDraw
175
DrawSprite(0)
176
end sub
177
178
179
sub RSDKLoad
180
LoadSpriteSheet("R7/Objects2.gif")
181
SpriteFrame(-12, -48, 24, 48, 66, 1)
182
183
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
184
end sub
185
186