Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/PataBata.txt
1319 views
1
//------------------Sonic CD PataBata Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Oscillation
7
#alias Object.Value1 : Object.YOriginPos
8
9
#alias Object.PropertyValue : Object.Quality
10
11
// States
12
#alias 0 : PATABATA_FLY_DOWN
13
#alias 1 : PATABATA_FLY_UP
14
15
// Badnik Quality / Property Values
16
#alias 0 : GOOD_QUALITY
17
#alias 1 : BAD_QUALITY
18
19
20
sub ObjectMain
21
if Object.Quality == GOOD_QUALITY
22
Object.Frame++
23
if Object.Frame > 39
24
Object.Frame = 0
25
end if
26
27
switch Object.State
28
case PATABATA_FLY_DOWN
29
Sin(Object.YPos, Object.Oscillation)
30
Object.YPos <<= 12
31
Object.YPos += Object.YOriginPos
32
33
Object.XPos -= 0x8000
34
35
Object.Oscillation -= 4
36
if Object.Oscillation == 0
37
Object.State = PATABATA_FLY_UP
38
Object.Direction = FACING_LEFT
39
end if
40
break
41
42
case PATABATA_FLY_UP
43
Sin(Object.YPos, Object.Oscillation)
44
FlipSign(Object.YPos)
45
Object.YPos <<= 12
46
Object.YPos += Object.YOriginPos
47
48
Object.XPos += 0x8000
49
50
Object.Oscillation += 4
51
if Object.Oscillation == 2048
52
Object.State = PATABATA_FLY_DOWN
53
Object.Direction = FACING_RIGHT
54
end if
55
break
56
57
end switch
58
else
59
Object.Frame++
60
if Object.Frame > 39
61
Object.Frame = 20
62
end if
63
64
switch Object.State
65
case PATABATA_FLY_DOWN
66
Sin(Object.YPos, Object.Oscillation)
67
Object.YPos <<= 11
68
Object.YPos += Object.YOriginPos
69
70
Object.XPos -= 0x4000
71
72
Object.Oscillation -= 2
73
if Object.Oscillation == 0
74
Object.State = PATABATA_FLY_UP
75
Object.Direction = FACING_LEFT
76
end if
77
break
78
79
case PATABATA_FLY_UP
80
Sin(Object.YPos, Object.Oscillation)
81
FlipSign(Object.YPos)
82
Object.YPos <<= 11
83
Object.YPos += Object.YOriginPos
84
85
Object.XPos += 0x4000
86
87
Object.Oscillation += 2
88
if Object.Oscillation == 2048
89
Object.State = PATABATA_FLY_DOWN
90
Object.Direction = FACING_RIGHT
91
end if
92
break
93
94
end switch
95
end if
96
97
CallFunction(StageSetup_CheckGoodFuture) // Check if it should be a flower
98
end sub
99
100
101
sub ObjectPlayerInteraction
102
#platform: Use_Standalone
103
PlayerObjectCollision(C_TOUCH, -14, -14, 14, 14)
104
#endplatform
105
#platform: Use_Origins
106
PlayerObjectCollision(C_ENEMY, -14, -14, 14, 14)
107
#endplatform
108
if CheckResult == true
109
CallFunction(Player_BadnikBreak)
110
end if
111
end sub
112
113
114
sub ObjectDraw
115
if Object.Quality == GOOD_QUALITY
116
TempValue0 = Object.Frame
117
TempValue0 >>= 3
118
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
119
else
120
TempValue0 = Object.Frame
121
TempValue0 >>= 2
122
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
123
end if
124
end sub
125
126
127
sub ObjectStartup
128
LoadSpriteSheet("R1/Objects.gif")
129
130
// Good PataBata
131
SpriteFrame(-16, -16, 32, 32, 1, 51) // #0 - PataBata Fly Frame 0
132
SpriteFrame(-16, -8, 32, 16, 1, 84) // #1 - PataBata Fly Frame 1
133
SpriteFrame(-16, -16, 32, 32, 117, 1) // #2 - PataBata Fly Frame 2
134
SpriteFrame(-16, -8, 32, 16, 1, 84) // #3 - PataBata Fly Frame 3
135
SpriteFrame(-16, -16, 32, 32, 1, 51) // #4 - PataBata Fly Frame 4
136
137
// Bad PataBata
138
SpriteFrame(-16, -16, 32, 32, 150, 1) // #5 - PataBata Fly Frame 0
139
SpriteFrame(-16, -8, 32, 16, 1, 84) // #6 - PataBata Fly Frame 1
140
SpriteFrame(-16, -16, 32, 32, 183, 1) // #7 - PataBata Fly Frame 2
141
SpriteFrame(-16, -8, 32, 16, 1, 84) // #8 - PataBata Fly Frame 3
142
SpriteFrame(-16, -16, 32, 32, 150, 1) // #9 - PataBata Fly Frame 4
143
144
// Used to be below LoadSpriteSheet, moved here for consistency
145
ArrayPos0 = 32
146
while ArrayPos0 < 1056
147
if Object[ArrayPos0].Type == TypeName[PataBata]
148
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
149
Object[ArrayPos0].Oscillation = 1024
150
Object[ArrayPos0].Frame = Object[ArrayPos0].Quality
151
Object[ArrayPos0].Frame *= 20
152
end if
153
ArrayPos0++
154
loop
155
end sub
156
157
158
// ========================
159
// Editor Subs
160
// ========================
161
162
sub RSDKEdit
163
if Editor.ReturnVariable == true
164
switch Editor.VariableID
165
case EDIT_VAR_PROPVAL // Property Value
166
CheckResult = Object.PropertyValue
167
CheckResult &= 1
168
break
169
case 0 // type
170
CheckResult = Object.PropertyValue
171
CheckResult &= 1
172
break
173
end switch
174
else
175
switch Editor.VariableID
176
case EDIT_VAR_PROPVAL // Property Value
177
Object.PropertyValue = Editor.VariableValue
178
Object.PropertyValue &= 1
179
break
180
case 0 // type
181
Object.PropertyValue = Editor.VariableValue
182
Object.PropertyValue &= 1
183
break
184
end switch
185
end if
186
end sub
187
188
189
sub RSDKDraw
190
DrawSprite(Object.PropertyValue)
191
end sub
192
193
194
sub RSDKLoad
195
LoadSpriteSheet("R1/Objects.gif")
196
197
// Good PataBata
198
SpriteFrame(-16, -16, 32, 32, 1, 51) // #0 - PataBata Fly Frame 0
199
200
// Bad PataBata
201
SpriteFrame(-16, -16, 32, 32, 150, 1) // #5 - PataBata Fly Frame 0
202
203
AddEditorVariable("condition")
204
SetActiveVariable("condition")
205
AddEnumVariable("Good Quality", GOOD_QUALITY)
206
AddEnumVariable("Bad Quality", BAD_QUALITY)
207
end sub
208
209