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