Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/BataPyon.txt
1319 views
1
//----------------Sonic CD Bata Pyon 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.XVelocity
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.XOriginPos
10
#alias Object.Value4 : Object.YOriginPos
11
#alias Object.Value5 : Object.TurnTimer
12
13
#alias Object.PropertyValue : Object.Quality
14
15
// States
16
#alias 0 : BATAPYON_JUMP
17
#alias 1 : BATAPYON_BOUNCE
18
#alias 2 : BATAPYON_BAD_RECOIL_1
19
#alias 3 : BATAPYON_BAD_RECOIL_2
20
#alias 4 : BATAPYON_BAD_RECOIL_3
21
#alias 5 : BATAPYON_BAD_RECOIL_4
22
#alias 6 : BATAPYON_BAD_BOUNCE
23
#alias 7 : BATAPYON_RESET
24
25
// Badnik Quality / Property Values
26
#alias 0 : GOOD_QUALITY
27
#alias 1 : BAD_QUALITY
28
29
// Collision Sides
30
#alias 0 : CSIDE_FLOOR
31
#alias 1 : CSIDE_LWALL
32
#alias 2 : CSIDE_RWALL
33
#alias 3 : CSIDE_ROOF
34
35
// Priority
36
#alias 0 : PRIORITY_BOUNDS
37
#alias 1 : PRIORITY_ACTIVE
38
39
40
sub ObjectMain
41
if Object.OutOfBounds == true
42
Object.State = BATAPYON_RESET
43
Object.Direction = FACING_RIGHT
44
Object.XPos = Object.XOriginPos
45
Object.YPos = Object.YOriginPos
46
Object.XVelocity = -0xA000
47
Object.YVelocity = 0x80000
48
Object.TurnTimer = 0
49
end if
50
51
switch Object.State
52
case BATAPYON_JUMP
53
Object.XPos += Object.XVelocity
54
55
Object.YPos += Object.YVelocity
56
Object.YVelocity += 0x2000
57
58
ObjectTileCollision(CSIDE_ROOF, 0, -18, 0)
59
if CheckResult == true
60
Object.YVelocity = 0
61
end if
62
63
if Object.YVelocity > 0
64
ObjectTileCollision(CSIDE_FLOOR, 0, 20, 0)
65
if CheckResult == true
66
if Object.Quality == GOOD_QUALITY
67
Object.State = BATAPYON_BOUNCE
68
Object.Priority = PRIORITY_ACTIVE
69
Object.TurnTimer++
70
if Object.TurnTimer == 8
71
Object.TurnTimer = 0
72
Object.Direction++
73
Object.Direction &= FACING_LEFT
74
FlipSign(Object.XVelocity)
75
end if
76
else
77
Object.State = BATAPYON_BAD_RECOIL_1
78
Object.Priority = PRIORITY_ACTIVE
79
Object.TurnTimer++
80
if Object.TurnTimer == 4
81
Object.TurnTimer = 0
82
Object.Direction++
83
Object.Direction &= FACING_LEFT
84
FlipSign(Object.XVelocity)
85
end if
86
end if
87
end if
88
end if
89
90
if Object.XVelocity > 0
91
ObjectTileCollision(CSIDE_LWALL, 16, 0, 0)
92
if CheckResult == true
93
Object.TurnTimer = 0
94
Object.Direction = FACING_RIGHT
95
FlipSign(Object.XVelocity)
96
end if
97
else
98
ObjectTileCollision(CSIDE_RWALL, -16, 0, 0)
99
if CheckResult == true
100
Object.TurnTimer = 0
101
Object.Direction = FACING_LEFT
102
FlipSign(Object.XVelocity)
103
end if
104
end if
105
106
Object.Frame = Object.Quality
107
Object.Frame <<= 1
108
109
if Object.YVelocity < 0
110
Object.Frame++
111
end if
112
break
113
114
case BATAPYON_BOUNCE
115
Object.XPos += Object.XVelocity
116
Object.YPos -= 0x120000
117
118
Object.YVelocity = -0x60000
119
120
Object.State = BATAPYON_JUMP
121
122
Object.Frame = Object.Quality
123
Object.Frame <<= 1
124
125
if Object.YVelocity < 0
126
Object.Frame++
127
end if
128
break
129
130
case BATAPYON_BAD_RECOIL_1
131
if Object.Timer < 3
132
Object.Timer++
133
else
134
Object.State++
135
Object.Frame = 3
136
Object.YPos -= 0x120000
137
end if
138
break
139
140
case BATAPYON_BAD_RECOIL_2
141
if Object.Timer < 6
142
Object.Timer++
143
else
144
Object.State++
145
Object.Frame = 2
146
Object.YPos += 0x120000
147
end if
148
break
149
150
case BATAPYON_BAD_RECOIL_3
151
if Object.Timer < 10
152
Object.Timer++
153
else
154
Object.State++
155
Object.Frame = 3
156
Object.YPos -= 0x120000
157
end if
158
break
159
160
case BATAPYON_BAD_RECOIL_4
161
if Object.Timer < 15
162
Object.Timer++
163
else
164
Object.State++
165
Object.Frame = 2
166
Object.YPos += 0x120000
167
end if
168
break
169
170
case BATAPYON_BAD_BOUNCE
171
if Object.Timer < 20
172
Object.Timer++
173
else
174
Object.Timer = 0
175
Object.Frame = 3
176
177
Object.YPos -= 0x120000
178
Object.YVelocity = -0x50000
179
180
Object.State = BATAPYON_JUMP
181
end if
182
break
183
184
case BATAPYON_RESET
185
if Object.OutOfBounds == true
186
Object.State = BATAPYON_JUMP
187
Object.Priority = PRIORITY_BOUNDS
188
end if
189
break
190
end switch
191
192
// Check if this badnik should be a flower
193
CallFunction(StageSetup_CheckGoodFuture)
194
end sub
195
196
197
sub ObjectPlayerInteraction
198
if Object.State < BATAPYON_RESET
199
#platform: Use_Standalone
200
PlayerObjectCollision(C_TOUCH, -14, -12, 14, 12)
201
#endplatform
202
#platform: Use_Origins
203
PlayerObjectCollision(C_ENEMY, -14, -12, 14, 12)
204
#endplatform
205
if CheckResult == true
206
CallFunction(Player_BadnikBreak)
207
end if
208
end if
209
end sub
210
211
212
sub ObjectDraw
213
if Object.State < BATAPYON_RESET
214
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
215
end if
216
end sub
217
218
219
sub ObjectStartup
220
LoadSpriteSheet("R6/Objects.gif")
221
222
// Good
223
SpriteFrame(-16, -18, 32, 40, 34, 134) // #0 - Pata Byon
224
SpriteFrame(-16, -18, 32, 56, 67, 167) // #1 - Pata Byon Jump
225
// Bad
226
SpriteFrame(-16, -18, 32, 40, 34, 175) // #2 - Pata Byon
227
SpriteFrame(-16, -18, 32, 56, 100, 167) // #3 - Pata Byon Jump
228
229
ArrayPos0 = 32
230
while ArrayPos0 < 1056
231
if Object[ArrayPos0].Type == TypeName[Bata Pyon]
232
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
233
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
234
235
Object[ArrayPos0].XVelocity = -0xA000
236
Object[ArrayPos0].YVelocity = 0x80000
237
end if
238
ArrayPos0++
239
loop
240
end sub
241
242
243
// ========================
244
// Editor Subs
245
// ========================
246
247
sub RSDKEdit
248
if Editor.ReturnVariable == true
249
switch Editor.VariableID
250
case EDIT_VAR_PROPVAL // Property Value
251
CheckResult = Object.PropertyValue
252
CheckResult &= 1
253
break
254
case 0 // condition
255
CheckResult = Object.PropertyValue
256
CheckResult &= 1
257
break
258
end switch
259
else
260
switch Editor.VariableID
261
case EDIT_VAR_PROPVAL // Property Value
262
Object.PropertyValue = Editor.VariableValue
263
Object.PropertyValue &= 1
264
break
265
case 0 // condition
266
Object.PropertyValue = Editor.VariableValue
267
Object.PropertyValue &= 1
268
break
269
end switch
270
end if
271
end sub
272
273
sub RSDKDraw
274
DrawSprite(Object.PropertyValue)
275
end sub
276
277
278
sub RSDKLoad
279
LoadSpriteSheet("R6/Objects.gif")
280
281
// Good
282
SpriteFrame(-16, -18, 32, 40, 34, 134) // #0 - Pata Byon
283
// Bad
284
SpriteFrame(-16, -18, 32, 40, 34, 175) // #1 - Pata Byon
285
286
AddEditorVariable("condition")
287
SetActiveVariable("condition")
288
AddEnumVariable("Good Quality", GOOD_QUALITY)
289
AddEnumVariable("Bad Quality", BAD_QUALITY)
290
end sub
291
292