Path: blob/master/Sonic 2/Scripts/Players/TailsObject.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Tails Object Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.type : player.type12private alias object.entityPos : player.entityPos13private alias object.state : player.state14private alias object.visible : player.visible15private alias object.priority : player.priority16private alias object.xpos : player.xpos17private alias object.ypos : player.ypos18private alias object.iypos : player.iypos19private alias object.xvel : player.xvel20private alias object.yvel : player.yvel21private alias object.rotation : player.rotation22private alias object.direction : player.direction23private alias object.gravity : player.gravity24private alias object.frame : player.frame25private alias object.animation : player.animation26private alias object.prevAnimation : player.prevAnimation27private alias object.animationSpeed : player.animationSpeed28private alias object.animationTimer : player.animationTimer29private alias object.drawOrder : player.drawOrder30private alias object.interaction : player.interaction31private alias object.down : player.down3233private alias object.value2 : player.abilityTimer // Note: Also used by death/drowning state34private alias object.value3 : player.drownTimer // Countdown before player moves to next drown "level"35private alias object.value4 : player.drownLevel36private alias object.value8 : player.blinkTimer37private alias object.value12 : player.tailFrame38private alias object.value13 : player.tailAnim39private alias object.value17 : debugMode.currentSelection40private alias object.value19 : player.badnikBonus41private alias object.value30 : player.jumpOffset42private alias object.value34 : player.collisionDisabled43private alias object.value35 : player.jumpAbilityState44private alias object.value42 : player.prevGravity4546// Reserved Object Slots47private alias 1 : SLOT_PLAYER2484950// ========================51// Function Declarations52// ========================5354reserve function TailsObject_ProcessTailSprite555657// ========================58// Function Definitions59// ========================6061public function TailsObject_ProcessTailSprite62switch player.tailAnim63case 0 // ANI_STOPPED64if player.frame == 065player.tailFrame++66player.tailFrame %= 4067end if68break6970case 1 // ANI_WAITING71case 3 // ANI_LOOKINGUP72case 4 // ANI_LOOKINGDOWN73case 21 // ANI_HANGING74case 36 // ANI_CONTINUE75case 37 // ANI_CONTINUE_UP76player.tailFrame++77player.tailFrame %= 4078break7980case 7 // ANI_SKIDDING81case 9 // ANI_SPINDASH82case 10 // ANI_JUMPING83case 43 // Unknown, this was probably "SSRoll" in Sonic 1 before it got moved to its own ani file in that game84player.tailFrame++85player.tailFrame %= 1286break8788case 17 // ANI_PUSHING89player.tailFrame++90player.tailFrame %= 3091break9293end switch94end function959697// ========================98// Events99// ========================100101event ObjectUpdate102#platform: USE_ORIGINS103currentPlayer = player.entityPos // Added here in Origins 2.0.2, fixes issues with Tails (see Player_HandleAirMovement in Player Object)104#endplatform105106if stage.debugMode == true107CallFunction(Player_ProcessUpdate)108109CheckEqual(options.attractMode, false)110temp0 = checkResult111CheckEqual(keyPress[0].buttonB, true)112temp0 &= checkResult113114if temp0 == true115player.type = TypeName[Debug Mode]116player.yvel = 0117player.state = Player_State_Static118player.frame = 0119player.rotation = 0120player.interaction = false121player.drawOrder = 4122player.priority = PRIORITY_ACTIVE123player.blinkTimer = 0124player.visible = true125player.abilityTimer = 0126player.drownTimer = 0127player.drownLevel = 0128player.frame = debugMode.currentSelection129camera[0].enabled = true130camera[0].style = CAMERASTYLE_FOLLOW131132StopSfx(SfxName[Flying])133StopSfx(SfxName[Jump])134135if stage.state == STAGE_FROZEN136stage.state = STAGE_RUNNING137end if138139if player[SLOT_PLAYER2].type == TypeName[Player 2 Object]140player[SLOT_PLAYER2].priority = PRIORITY_ACTIVE141end if142143if object[+playerCount].propertyValue == 3144object[+playerCount].type = TypeName[Invincibility]145object[+playerCount].propertyValue = 0146end if147else148if player.gravity == GRAVITY_GROUND149player.jumpAbilityState = 0150end if151152CallFunction(player.state)153ProcessAnimation()154CallFunction(TailsObject_ProcessTailSprite)155156if player.animation == ANI_JUMPING157camera[0].adjustY = player.jumpOffset158else159if camera[0].adjustY == player.jumpOffset160camera[0].adjustY = 0161player.iypos += player.jumpOffset162end if163end if164165if player.collisionDisabled == false166temp0 = player.prevGravity167player.prevGravity = player.gravity168ProcessObjectMovement()169player.prevGravity ^= GRAVITY_AIR170CheckEqual(player.gravity, GRAVITY_GROUND)171player.prevGravity |= checkResult172player.prevGravity ^= GRAVITY_AIR173174if temp0 == GRAVITY_AIR175if player.prevGravity == GRAVITY_GROUND176player.badnikBonus = 0177if player.animation == ANI_JUMPING178if player.down == false179if player.state != Player_State_Roll180if player.state != Player_State_TubeRoll181player.animation = ANI_WALKING182if player.entityPos == camera[0].target183camera[0].adjustY = 0184end if185186player.iypos += player.jumpOffset187end if188end if189end if190end if191end if192end if193else194player.collisionDisabled = false195end if196end if197else198CallFunction(Player_ProcessUpdate)199200if player.gravity == GRAVITY_GROUND201player.jumpAbilityState = 0202end if203204CallFunction(player.state)205ProcessAnimation()206CallFunction(TailsObject_ProcessTailSprite)207208if player.animation == ANI_JUMPING209camera[0].adjustY = player.jumpOffset210else211if camera[0].adjustY == player.jumpOffset212camera[0].adjustY = 0213player.iypos += player.jumpOffset214end if215end if216217if player.collisionDisabled == false218temp0 = player.prevGravity219player.prevGravity = player.gravity220ProcessObjectMovement()221player.prevGravity ^= GRAVITY_AIR222CheckEqual(player.gravity, GRAVITY_GROUND)223player.prevGravity |= checkResult224player.prevGravity ^= GRAVITY_AIR225226if temp0 == GRAVITY_AIR227if player.prevGravity == GRAVITY_GROUND228player.badnikBonus = 0229if player.animation == ANI_JUMPING230if player.down == false231if player.state != Player_State_Roll232if player.state != Player_State_TubeRoll233player.animation = ANI_WALKING234if player.entityPos == camera[0].target235camera[0].adjustY = 0236end if237238player.iypos += player.jumpOffset239end if240end if241end if242end if243end if244end if245else246player.collisionDisabled = false247end if248end if249250CallFunction(Player_HandleSuperForm)251end event252253254event ObjectDraw255if player.animation != player.prevAnimation256player.prevAnimation = player.animation257player.frame = 0258player.animationTimer = 0259player.animationSpeed = 0260end if261262if player.tailAnim != player.animation263if player.animation > 4 // Animation 4 is ANI_LOOKINGDOWN, it's notable they used a direct constant rather than the normal ANI_* variables264player.tailFrame = 0265end if266267if player.tailAnim > 4268player.tailFrame = 0269end if270271player.tailAnim = player.animation272end if273274// Draw the Tails part of Tails275switch player.tailAnim276case 0 // ANI_STOPPED277if player.frame == 0278temp0 = player.tailFrame279temp0 >>= 3280if player.visible == true281DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)282end if283end if284break285286case 1 // ANI_WAITING287case 3 // ANI_LOOKINGUP288case 4 // ANI_LOOKINGDOWN289case 21 // ANI_HANGING290case 36 // ANI_CONTINUE291case 37 // ANI_CONTINUE_UP292temp0 = player.tailFrame293temp0 >>= 3294if player.visible == true295DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)296end if297break298299case 7 // ANI_SKIDDING300case 9 // ANI_SPINDASH301temp0 = player.tailFrame302temp0 >>= 2303temp0 += 11304if player.visible == true305DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)306end if307break308309case 10 // ANI_JUMPING310case 43 // Unknown, this was probably "SSRoll" in Sonic 1 before it got moved to its own ani file in that game311temp0 = player.tailFrame312temp0 >>= 2313CheckEqual(player.xvel, 0)314temp1 = checkResult315CheckEqual(player.yvel, 0)316temp1 &= checkResult317temp2 = player.rotation318if temp1 == false319ATan2(player.rotation, player.xvel, player.yvel)320player.rotation += 0x10321player.rotation &= 0xFF322player.rotation >>= 5323switch player.rotation324case 0325case 8326temp0 += 5327player.rotation = 0x00328break329330case 1331temp0 += 8332if player.direction == FACING_RIGHT333player.rotation = 0x40334else335player.rotation = 0x00336end if337break338339case 2340temp0 += 5341player.rotation = 0x40342break343344case 3345temp0 += 8346if player.direction == FACING_RIGHT347player.rotation = 0x80348else349player.rotation = 0x40350end if351break352353case 4354temp0 += 5355player.rotation = 0x80356break357358case 5359temp0 += 8360if player.direction == FACING_RIGHT361player.rotation = 0xC0362else363player.rotation = 0x80364end if365break366367case 6368temp0 += 5369player.rotation = 0xC0370break371372case 7373temp0 += 8374if player.direction == FACING_RIGHT375player.rotation = 0x00376else377player.rotation = 0xC0378end if379break380end switch381382if player.direction == FACING_LEFT383player.rotation += 0x80384end if385else386temp0 += 5387player.rotation = 0x00388end if389390player.rotation <<= 1391if player.visible == true392DrawSpriteFX(temp0, FX_ROTATE, player.xpos, player.ypos)393end if394player.rotation = temp2395break396397case 17 // ANI_PUSHING398temp0 = player.tailFrame399temp0 /= 10400temp0 += 11401if player.visible == true402DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)403end if404break405end switch406407// Draw Tails himself (Separate tails are drawn in the process above)408DrawObjectAnimation()409end event410411412event ObjectStartup413if stage.playerListPos == PLAYER_TAILS_A414// Tails' main body uses the ani, the gif and SpriteFrames are for his tails415LoadSpriteSheet("Players/Tails1.gif")416LoadAnimation("Tails.ani")417418SpriteFrame(-22, -8, 16, 24, 82, 199)419SpriteFrame(-26, -8, 20, 24, 99, 199)420SpriteFrame(-26, -8, 20, 24, 120, 199)421SpriteFrame(-26, -8, 20, 24, 141, 199)422SpriteFrame(-26, -8, 20, 24, 162, 199)423SpriteFrame(-35, -8, 24, 16, 231, 166)424SpriteFrame(-35, -8, 24, 16, 231, 183)425SpriteFrame(-35, -8, 24, 16, 231, 200)426SpriteFrame(-25, 9, 20, 16, 235, 217)427SpriteFrame(-25, 9, 18, 16, 237, 234)428SpriteFrame(-25, 9, 20, 16, 216, 234)429SpriteFrame(-30, -6, 24, 16, 231, 166)430SpriteFrame(-30, -6, 24, 16, 231, 183)431SpriteFrame(-30, -6, 24, 16, 231, 200)432end if433end event434435436// ========================437// Editor Events438// ========================439440event RSDKDraw441DrawSprite(0)442end event443444445event RSDKLoad446LoadSpriteSheet("Players/Tails1.gif")447SpriteFrame(-16, -12, 24, 32, 1, 1)448449SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")450end event451452453