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