Path: blob/master/Sonic 1/Scripts/Players/TailsObject.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// 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.interaction3132private alias object.down : player.down3334private alias object.value2 : player.abilityTimer // Note: Also used by death/drowning state35private alias object.value3 : player.drownTimer // Countdown before player moves to next drown "level"36private alias object.value4 : player.drownLevel37private alias object.value8 : player.blinkTimer38private alias object.value12 : player.tailFrame39private alias object.value13 : player.tailAnim40private alias object.value17 : debugMode.currentSelection41private alias object.value19 : player.badnikBonus42private alias object.value30 : player.jumpOffset43private alias object.value34 : player.collisionDisabled44private alias object.value35 : player.jumpAbilityState45private alias object.value42 : player.prevGravity4647// Reserved Object Slots48private alias 1 : SLOT_PLAYER24950// ========================51// Function Declarations52// ========================5354reserve function TailsObject_ProcessTailSprite555657// ========================58// Function Definitions59// ========================6061// Note - function is used by [Player 2 Object] too62public function TailsObject_ProcessTailSprite63switch player.tailAnim64case 0 // ANI_STOPPED65if player.frame == 066player.tailFrame++67player.tailFrame %= 4068end if69break7071case 1 // ANI_WAITING72case 3 // ANI_LOOKINGUP73case 4 // ANI_LOOKINGDOWN74player.tailFrame++75player.tailFrame %= 4076break7778case 7 // ANI_SKIDDING79case 9 // ANI_SPINDASH80case 10 // ANI_JUMPING81case 43 // Unknown, this was probably "SSRoll" before it got moved to its own ani file82player.tailFrame++83player.tailFrame %= 1284break8586case 17 // ANI_PUSHING87player.tailFrame++88player.tailFrame %= 3089break9091end switch92end function939495// ========================96// Events97// ========================9899event ObjectUpdate100#platform: USE_ORIGINS101currentPlayer = player.entityPos // Added here in Origins 2.0.2, fixes issues with Tails (see Player_HandleAirMovement in Player Object)102#endplatform103104if stage.debugMode == true105CallFunction(Player_ProcessUpdate)106107CheckEqual(options.attractMode, false)108temp0 = checkResult109CheckEqual(keyPress[0].buttonB, true)110temp0 &= checkResult111112if temp0 == true113player.type = TypeName[Debug Mode]114player.yvel = 0115player.state = Player_State_Static116player.frame = 0117player.rotation = 0118player.interaction = false119player.drawOrder = 4120player.priority = PRIORITY_ACTIVE121player.blinkTimer = 0122player.visible = true123player.abilityTimer = 0124player.drownTimer = 0125player.drownLevel = 0126player.frame = debugMode.currentSelection127camera[0].enabled = true128camera[0].style = CAMERASTYLE_FOLLOW129130StopSfx(SfxName[Flying])131StopSfx(SfxName[Jump])132133if stage.state == STAGE_FROZEN134stage.state = STAGE_RUNNING135end if136137if player[SLOT_PLAYER2].type == TypeName[Player 2 Object]138player[SLOT_PLAYER2].priority = PRIORITY_ACTIVE139end if140141if object[+playerCount].propertyValue == 3142object[+playerCount].type = TypeName[Invincibility]143object[+playerCount].propertyValue = 0144end if145else146if player.gravity == GRAVITY_GROUND147player.jumpAbilityState = 0148end if149150CallFunction(player.state)151ProcessAnimation()152CallFunction(TailsObject_ProcessTailSprite)153154if player.animation == ANI_JUMPING155camera[0].adjustY = player.jumpOffset156else157if camera[0].adjustY == player.jumpOffset158camera[0].adjustY = 0159player.iypos += player.jumpOffset160end if161end if162163if player.collisionDisabled == false164temp0 = player.prevGravity165player.prevGravity = player.gravity166ProcessObjectMovement()167player.prevGravity ^= GRAVITY_AIR168CheckEqual(player.gravity, GRAVITY_GROUND)169player.prevGravity |= checkResult170player.prevGravity ^= GRAVITY_AIR171172if temp0 == GRAVITY_AIR173if player.prevGravity == GRAVITY_GROUND174player.badnikBonus = 0175achieveRingCount = 0176if player.animation == ANI_JUMPING177if player.down == false178if player.state != Player_State_Roll179if player.state != Player_State_TubeRoll180player.animation = ANI_WALKING181if player.entityPos == camera[0].target182camera[0].adjustY = 0183end if184player.iypos += player.jumpOffset185end if186end if187end if188end if189end if190end if191else192player.collisionDisabled = false193end if194end if195else196CallFunction(Player_ProcessUpdate)197198if player.gravity == GRAVITY_GROUND199player.jumpAbilityState = 0200end if201202CallFunction(player.state)203ProcessAnimation()204CallFunction(TailsObject_ProcessTailSprite)205206if player.animation == ANI_JUMPING207camera[0].adjustY = player.jumpOffset208else209if camera[0].adjustY == player.jumpOffset210camera[0].adjustY = 0211player.iypos += player.jumpOffset212end if213end if214215if player.collisionDisabled == false216temp0 = player.prevGravity217player.prevGravity = player.gravity218ProcessObjectMovement()219player.prevGravity ^= GRAVITY_AIR220CheckEqual(player.gravity, GRAVITY_GROUND)221player.prevGravity |= checkResult222player.prevGravity ^= GRAVITY_AIR223224if temp0 == GRAVITY_AIR225if player.prevGravity == 0226player.badnikBonus = 0227achieveRingCount = 0228if player.animation == ANI_JUMPING229if player.down == false230if player.state != Player_State_Roll231if player.state != Player_State_TubeRoll232player.animation = ANI_WALKING233if player.entityPos == camera[0].target234camera[0].adjustY = 0235end if236player.iypos += player.jumpOffset237end if238end if239end if240end if241end if242end if243else244player.collisionDisabled = false245end if246end if247248CallFunction(Player_HandleSuperForm)249end event250251252event ObjectDraw253if player.animation != player.prevAnimation254player.prevAnimation = player.animation255player.frame = 0256player.animationTimer = 0257player.animationSpeed = 0258end if259260if player.tailAnim != player.animation261if player.animation > 4262player.tailFrame = 0263end if264265if player.tailAnim > 4266player.tailFrame = 0267end if268269player.tailAnim = player.animation270end if271272// Draw the Tails part of Tails273switch player.tailAnim274case 0 // ANI_STOPPED275if player.frame == 0276temp0 = player.tailFrame277temp0 >>= 3278if player.visible == true279DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)280end if281end if282break283284case 1 // ANI_WAITING285case 3 // ANI_LOOKINGUP286case 4 // ANI_LOOKINGDOWN287case 37 // ANI_CONTINUE_UP288temp0 = player.tailFrame289temp0 >>= 3290if player.visible == true291DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)292end if293break294295case 7 // ANI_SKIDDING296case 9 // ANI_SPINDASH297temp0 = player.tailFrame298temp0 >>= 2299temp0 += 11300if player.visible == true301DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)302end if303break304305case 10 // ANI_JUMPING306case 43 // Unknown, this was probably "SSRoll" before it got moved to its own ani file307temp0 = player.tailFrame308temp0 >>= 2309CheckEqual(player.xvel, 0)310temp1 = checkResult311CheckEqual(player.yvel, 0)312temp1 &= checkResult313temp2 = player.rotation314if temp1 == false315ATan2(player.rotation, player.xvel, player.yvel)316player.rotation += 0x10317player.rotation &= 0xFF318player.rotation >>= 5319switch player.rotation320case 0321case 8322temp0 += 5323player.rotation = 0x00324break325326case 1327temp0 += 8328if player.direction == FACING_RIGHT329player.rotation = 0x40330else331player.rotation = 0x00332end if333break334335case 2336temp0 += 5337player.rotation = 0x40338break339340case 3341temp0 += 8342if player.direction == FACING_RIGHT343player.rotation = 0x80344else345player.rotation = 0x40346end if347break348349case 4350temp0 += 5351player.rotation = 0x80352break353354case 5355temp0 += 8356if player.direction == FACING_RIGHT357player.rotation = 0xC0358else359player.rotation = 0x80360end if361break362363case 6364temp0 += 5365player.rotation = 0xC0366break367368case 7369temp0 += 8370if player.direction == FACING_RIGHT371player.rotation = 0x00372else373player.rotation = 0xC0374end if375break376end switch377378if player.direction == FACING_LEFT379player.rotation += 0x80380end if381else382temp0 += 5383player.rotation = 0x00384end if385386player.rotation <<= 1387if player.visible == true388DrawSpriteFX(temp0, FX_ROTATE, player.xpos, player.ypos)389end if390player.rotation = temp2391break392393case 17 // ANI_PUSHING394temp0 = player.tailFrame395temp0 /= 10396temp0 += 11397if player.visible == true398DrawSpriteFX(temp0, FX_FLIP, player.xpos, player.ypos)399end if400break401402end switch403404// Draw Tails himself405// (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)406DrawObjectAnimation()407end event408409410event ObjectStartup411if stage.playerListPos == true412LoadSpriteSheet("Players/Tails1.gif")413414LoadAnimation("Tails.ani")415416// Idle Tail Sprites - #0-4417SpriteFrame(-22, -8, 16, 24, 82, 199)418SpriteFrame(-26, -8, 20, 24, 99, 199)419SpriteFrame(-26, -8, 20, 24, 120, 199)420SpriteFrame(-26, -8, 20, 24, 141, 199)421SpriteFrame(-26, -8, 20, 24, 162, 199)422423// Jumping Tail Sprites - #5-7424SpriteFrame(-35, -8, 24, 16, 231, 166)425SpriteFrame(-35, -8, 24, 16, 231, 183)426SpriteFrame(-35, -8, 24, 16, 231, 200)427428// Jumping Tail Sprites (45 Degrees) - #8-10429SpriteFrame(-25, 9, 20, 16, 235, 217)430SpriteFrame(-25, 9, 18, 16, 237, 234)431SpriteFrame(-25, 9, 20, 16, 216, 234)432433// Pushing Tail Sprites - #11-13434SpriteFrame(-30, -6, 24, 16, 231, 166)435SpriteFrame(-30, -6, 24, 16, 231, 183)436SpriteFrame(-30, -6, 24, 16, 231, 200)437end if438end event439440441// ========================442// Editor Events443// ========================444445event RSDKDraw446DrawSprite(0)447end event448449450event RSDKLoad451LoadSpriteSheet("Players/Tails1.gif")452SpriteFrame(-22, -8, 16, 24, 82, 199) // snip453454SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")455end event456457458