Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Players/TailsObject.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Tails Object Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.type : player.type
13
private alias object.entityPos : player.entityPos
14
private alias object.state : player.state
15
private alias object.visible : player.visible
16
private alias object.priority : player.priority
17
private alias object.xpos : player.xpos
18
private alias object.ypos : player.ypos
19
private alias object.iypos : player.iypos
20
private alias object.xvel : player.xvel
21
private alias object.yvel : player.yvel
22
private alias object.rotation : player.rotation
23
private alias object.direction : player.direction
24
private alias object.gravity : player.gravity
25
private alias object.frame : player.frame
26
private alias object.animation : player.animation
27
private alias object.prevAnimation : player.prevAnimation
28
private alias object.animationSpeed : player.animationSpeed
29
private alias object.animationTimer : player.animationTimer
30
private alias object.drawOrder : player.drawOrder
31
private alias object.interaction : player.interaction
32
private alias object.down : player.down
33
34
private alias object.value2 : player.abilityTimer // Note: Also used by death/drowning state
35
private alias object.value3 : player.drownTimer // Countdown before player moves to next drown "level"
36
private alias object.value4 : player.drownLevel
37
private alias object.value8 : player.blinkTimer
38
private alias object.value12 : player.tailFrame
39
private alias object.value13 : player.tailAnim
40
private alias object.value17 : debugMode.currentSelection
41
private alias object.value19 : player.badnikBonus
42
private alias object.value30 : player.jumpOffset
43
private alias object.value34 : player.collisionDisabled
44
private alias object.value35 : player.jumpAbilityState
45
private alias object.value42 : player.prevGravity
46
47
// Reserved Object Slots
48
private alias 1 : SLOT_PLAYER2
49
50
51
// ========================
52
// Function Declarations
53
// ========================
54
55
reserve function TailsObject_ProcessTailSprite
56
57
58
// ========================
59
// Function Definitions
60
// ========================
61
62
public function TailsObject_ProcessTailSprite
63
switch player.tailAnim
64
case 0 // ANI_STOPPED
65
if player.frame == 0
66
player.tailFrame++
67
player.tailFrame %= 40
68
end if
69
break
70
71
case 1 // ANI_WAITING
72
case 3 // ANI_LOOKINGUP
73
case 4 // ANI_LOOKINGDOWN
74
case 21 // ANI_HANGING
75
case 36 // ANI_CONTINUE
76
case 37 // ANI_CONTINUE_UP
77
player.tailFrame++
78
player.tailFrame %= 40
79
break
80
81
case 7 // ANI_SKIDDING
82
case 9 // ANI_SPINDASH
83
case 10 // ANI_JUMPING
84
case 43 // Unknown, this was probably "SSRoll" in Sonic 1 before it got moved to its own ani file in that game
85
player.tailFrame++
86
player.tailFrame %= 12
87
break
88
89
case 17 // ANI_PUSHING
90
player.tailFrame++
91
player.tailFrame %= 30
92
break
93
94
end switch
95
end function
96
97
98
// ========================
99
// Events
100
// ========================
101
102
event ObjectUpdate
103
#platform: USE_ORIGINS
104
currentPlayer = player.entityPos // Added here in Origins 2.0.2, fixes issues with Tails (see Player_HandleAirMovement in Player Object)
105
#endplatform
106
107
if stage.debugMode == true
108
CallFunction(Player_ProcessUpdate)
109
110
CheckEqual(options.attractMode, false)
111
temp0 = checkResult
112
CheckEqual(keyPress[0].buttonB, true)
113
temp0 &= checkResult
114
115
if temp0 == true
116
player.type = TypeName[Debug Mode]
117
player.yvel = 0
118
player.state = Player_State_Static
119
player.frame = 0
120
player.rotation = 0
121
player.interaction = false
122
player.drawOrder = 4
123
player.priority = PRIORITY_ACTIVE
124
player.blinkTimer = 0
125
player.visible = true
126
player.abilityTimer = 0
127
player.drownTimer = 0
128
player.drownLevel = 0
129
player.frame = debugMode.currentSelection
130
camera[0].enabled = true
131
camera[0].style = CAMERASTYLE_FOLLOW
132
133
StopSfx(SfxName[Flying])
134
StopSfx(SfxName[Jump])
135
136
if stage.state == STAGE_FROZEN
137
stage.state = STAGE_RUNNING
138
end if
139
140
if player[SLOT_PLAYER2].type == TypeName[Player 2 Object]
141
player[SLOT_PLAYER2].priority = PRIORITY_ACTIVE
142
end if
143
144
if object[+playerCount].propertyValue == 3
145
object[+playerCount].type = TypeName[Invincibility]
146
object[+playerCount].propertyValue = 0
147
end if
148
else
149
if player.gravity == GRAVITY_GROUND
150
player.jumpAbilityState = 0
151
end if
152
153
CallFunction(player.state)
154
ProcessAnimation()
155
CallFunction(TailsObject_ProcessTailSprite)
156
157
if player.animation == ANI_JUMPING
158
camera[0].adjustY = player.jumpOffset
159
else
160
if camera[0].adjustY == player.jumpOffset
161
camera[0].adjustY = 0
162
player.iypos += player.jumpOffset
163
end if
164
end if
165
166
if player.collisionDisabled == false
167
temp0 = player.prevGravity
168
player.prevGravity = player.gravity
169
ProcessObjectMovement()
170
player.prevGravity ^= GRAVITY_AIR
171
CheckEqual(player.gravity, GRAVITY_GROUND)
172
player.prevGravity |= checkResult
173
player.prevGravity ^= GRAVITY_AIR
174
175
if temp0 == GRAVITY_AIR
176
if player.prevGravity == GRAVITY_GROUND
177
player.badnikBonus = 0
178
if player.animation == ANI_JUMPING
179
if player.down == false
180
if player.state != Player_State_Roll
181
if player.state != Player_State_TubeRoll
182
player.animation = ANI_WALKING
183
if player.entityPos == camera[0].target
184
camera[0].adjustY = 0
185
end if
186
187
player.iypos += player.jumpOffset
188
end if
189
end if
190
end if
191
end if
192
end if
193
end if
194
else
195
player.collisionDisabled = false
196
end if
197
end if
198
else
199
CallFunction(Player_ProcessUpdate)
200
201
if player.gravity == GRAVITY_GROUND
202
player.jumpAbilityState = 0
203
end if
204
205
CallFunction(player.state)
206
ProcessAnimation()
207
CallFunction(TailsObject_ProcessTailSprite)
208
209
if player.animation == ANI_JUMPING
210
camera[0].adjustY = player.jumpOffset
211
else
212
if camera[0].adjustY == player.jumpOffset
213
camera[0].adjustY = 0
214
player.iypos += player.jumpOffset
215
end if
216
end if
217
218
if player.collisionDisabled == false
219
temp0 = player.prevGravity
220
player.prevGravity = player.gravity
221
ProcessObjectMovement()
222
player.prevGravity ^= GRAVITY_AIR
223
CheckEqual(player.gravity, GRAVITY_GROUND)
224
player.prevGravity |= checkResult
225
player.prevGravity ^= GRAVITY_AIR
226
227
if temp0 == GRAVITY_AIR
228
if player.prevGravity == GRAVITY_GROUND
229
player.badnikBonus = 0
230
if player.animation == ANI_JUMPING
231
if player.down == false
232
if player.state != Player_State_Roll
233
if player.state != Player_State_TubeRoll
234
player.animation = ANI_WALKING
235
if player.entityPos == camera[0].target
236
camera[0].adjustY = 0
237
end if
238
239
player.iypos += player.jumpOffset
240
end if
241
end if
242
end if
243
end if
244
end if
245
end if
246
else
247
player.collisionDisabled = false
248
end if
249
end if
250
251
CallFunction(Player_HandleSuperForm)
252
end event
253
254
255
event ObjectDraw
256
if player.animation != player.prevAnimation
257
player.prevAnimation = player.animation
258
player.frame = 0
259
player.animationTimer = 0
260
player.animationSpeed = 0
261
end if
262
263
if player.tailAnim != player.animation
264
if player.animation > 4 // Animation 4 is ANI_LOOKINGDOWN, it's notable they used a direct constant rather than the normal ANI_* variables
265
player.tailFrame = 0
266
end if
267
268
if player.tailAnim > 4
269
player.tailFrame = 0
270
end if
271
272
player.tailAnim = player.animation
273
end if
274
275
// Draw the Tails part of Tails
276
switch player.tailAnim
277
case 0 // ANI_STOPPED
278
if player.frame == 0
279
temp0 = player.tailFrame
280
temp0 >>= 3
281
if player.visible == true
282
DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)
283
end if
284
end if
285
break
286
287
case 1 // ANI_WAITING
288
case 3 // ANI_LOOKINGUP
289
case 4 // ANI_LOOKINGDOWN
290
case 21 // ANI_HANGING
291
case 36 // ANI_CONTINUE
292
case 37 // ANI_CONTINUE_UP
293
temp0 = player.tailFrame
294
temp0 >>= 3
295
if player.visible == true
296
DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)
297
end if
298
break
299
300
case 7 // ANI_SKIDDING
301
case 9 // ANI_SPINDASH
302
temp0 = player.tailFrame
303
temp0 >>= 2
304
temp0 += 11
305
if player.visible == true
306
DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)
307
end if
308
break
309
310
case 10 // ANI_JUMPING
311
case 43 // Unknown, this was probably "SSRoll" in Sonic 1 before it got moved to its own ani file in that game
312
temp0 = player.tailFrame
313
temp0 >>= 2
314
CheckEqual(player.xvel, 0)
315
temp1 = checkResult
316
CheckEqual(player.yvel, 0)
317
temp1 &= checkResult
318
temp2 = player.rotation
319
if temp1 == false
320
ATan2(player.rotation, player.xvel, player.yvel)
321
player.rotation += 0x10
322
player.rotation &= 0xFF
323
player.rotation >>= 5
324
switch player.rotation
325
case 0
326
case 8
327
temp0 += 5
328
player.rotation = 0x00
329
break
330
331
case 1
332
temp0 += 8
333
if player.direction == FACING_RIGHT
334
player.rotation = 0x40
335
else
336
player.rotation = 0x00
337
end if
338
break
339
340
case 2
341
temp0 += 5
342
player.rotation = 0x40
343
break
344
345
case 3
346
temp0 += 8
347
if player.direction == FACING_RIGHT
348
player.rotation = 0x80
349
else
350
player.rotation = 0x40
351
end if
352
break
353
354
case 4
355
temp0 += 5
356
player.rotation = 0x80
357
break
358
359
case 5
360
temp0 += 8
361
if player.direction == FACING_RIGHT
362
player.rotation = 0xC0
363
else
364
player.rotation = 0x80
365
end if
366
break
367
368
case 6
369
temp0 += 5
370
player.rotation = 0xC0
371
break
372
373
case 7
374
temp0 += 8
375
if player.direction == FACING_RIGHT
376
player.rotation = 0x00
377
else
378
player.rotation = 0xC0
379
end if
380
break
381
end switch
382
383
if player.direction == FACING_LEFT
384
player.rotation += 0x80
385
end if
386
else
387
temp0 += 5
388
player.rotation = 0x00
389
end if
390
391
player.rotation <<= 1
392
if player.visible == true
393
DrawSpriteFX(temp0, FX_ROTATE, player.xpos, player.ypos)
394
end if
395
player.rotation = temp2
396
break
397
398
case 17 // ANI_PUSHING
399
temp0 = player.tailFrame
400
temp0 /= 10
401
temp0 += 11
402
if player.visible == true
403
DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)
404
end if
405
break
406
end switch
407
408
// Draw Tails himself (Separate tails are drawn in the process above)
409
DrawObjectAnimation()
410
end event
411
412
413
event ObjectStartup
414
if stage.playerListPos == PLAYER_TAILS_A
415
// Tails' main body uses the ani, the gif and SpriteFrames are for his tails
416
LoadSpriteSheet("Players/Tails1.gif")
417
LoadAnimation("Tails.ani")
418
419
SpriteFrame(-22, -8, 16, 24, 82, 199)
420
SpriteFrame(-26, -8, 20, 24, 99, 199)
421
SpriteFrame(-26, -8, 20, 24, 120, 199)
422
SpriteFrame(-26, -8, 20, 24, 141, 199)
423
SpriteFrame(-26, -8, 20, 24, 162, 199)
424
SpriteFrame(-35, -8, 24, 16, 231, 166)
425
SpriteFrame(-35, -8, 24, 16, 231, 183)
426
SpriteFrame(-35, -8, 24, 16, 231, 200)
427
SpriteFrame(-25, 9, 20, 16, 235, 217)
428
SpriteFrame(-25, 9, 18, 16, 237, 234)
429
SpriteFrame(-25, 9, 20, 16, 216, 234)
430
SpriteFrame(-30, -6, 24, 16, 231, 166)
431
SpriteFrame(-30, -6, 24, 16, 231, 183)
432
SpriteFrame(-30, -6, 24, 16, 231, 200)
433
end if
434
end event
435
436
437
// ========================
438
// Editor Events
439
// ========================
440
441
event RSDKDraw
442
DrawSprite(0)
443
end event
444
445
446
event RSDKLoad
447
LoadSpriteSheet("Players/Tails1.gif")
448
SpriteFrame(-16, -12, 24, 32, 1, 1)
449
450
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
451
end event
452
453