Path: blob/master/Sonic 2/Scripts/Global/HUD.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: HUD Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.drawFunction12private alias object.value1 : object.flashingTimer13private alias object.value2 : object.timeOver1415// Player Aliases16private alias object.type : player.type17private alias object.xpos : player.xpos18private alias object.ypos : player.ypos19private alias object.value0 : player.rings2021// Game Mode Aliases22private alias 2 : MODE_TIMEATTACK2324// Global Variable ID Aliases25private alias 22 : GLOBAL_PLAYERSCORE26private alias 25 : GLOBAL_PLAYERLIVES272829// ========================30// Function Declarations31// ========================3233reserve function HUD_Draw_Standard34reserve function HUD_Draw_Mobile353637// ========================38// Function Definitions39// ========================4041private function HUD_Draw_Standard4243#platform: USE_ORIGINS44// temp4 will tell whether to draw lives or coins45temp4 = game.coinMode4647if game.playMode == BOOT_PLAYMODE_MISSION48if game.missionEnd == false49game.hudEnable = HUDENABLE_ON50end if51temp4 = true52else53if game.playMode == BOOT_PLAYMODE_BOSSRUSH54game.hudEnable = HUDENABLE_ON55temp4 = false56else57if game.coinMode != false58game.hudEnable = HUDENABLE_ON59end if60#endplatform6162// Draw the base SCORE/TIME/RINGS text63DrawSpriteScreenXY(10, 17, 13)6465#platform: USE_ORIGINS66temp2 = stage.minutes67temp3 = stage.seconds6869CheckGreater(temp2, 9)70temp5 = checkResult71CheckNotEqual(object.timeOver, false)72checkResult |= temp57374if checkResult != false75temp2 = 976temp3 = 5977end if7879if temp2 == 980#endplatform81#platform: USE_STANDALONE82if stage.minutes == 983#endplatform84// Overlay the red TIME text85if object.flashingTimer > 786DrawSpriteScreenXY(11, 17, 29)87end if88end if8990// Overlay the red RINGS text if needed as well91#platform: USE_STANDALONE92if player[0].rings == 093#endplatform94#platform: USE_ORIGINS95if player[currentPlayer].rings == 096#endplatform97if object.flashingTimer > 798DrawSpriteScreenXY(12, 17, 45)99end if100end if101102#platform: USE_STANDALONE103DrawNumbers(0, 104, 13, player.score, 6, 8, false)104#endplatform105#platform: USE_ORIGINS106arrayPos0 = GLOBAL_PLAYERSCORE // VarName[player.score]107arrayPos0 += currentPlayer108DrawNumbers(0, 104, 13, global[arrayPos0], 6, 8, false)109#endplatform110111if options.gameMode < MODE_TIMEATTACK112// Normal game - only minutes and seconds are shown113DrawSpriteScreenXY(14, 67, 29)114else115// Time attack - draw milliseconds alongside of the other values116DrawSpriteScreenXY(13, 67, 29)117DrawNumbers(0, 104, 29, stage.milliSeconds, 2, 8, true)118end if119120// Rest of the time display121#platform: USE_STANDALONE122DrawNumbers(0, 80, 29, stage.seconds, 2, 8, true)123DrawNumbers(0, 56, 29, stage.minutes, 1, 8, true)124DrawNumbers(0, 80, 45, player[0].rings, 3, 8, false)125#endplatform126#platform: USE_ORIGINS127DrawNumbers(0, 80, 29, temp3, 2, 8, true)128DrawNumbers(0, 56, 29, temp2, 1, 8, true)129DrawNumbers(0, 80, 45, player[currentPlayer].rings, 3, 8, false)130#endplatform131132if stage.debugMode == true133// Player position display134135// XPos display136#platform: USE_STANDALONE137temp0 = player[0].xpos138#endplatform139#platform: USE_ORIGINS140temp0 = player[currentPlayer].xpos141#endplatform142temp0 >>= 16143Abs(temp0)144temp1 = screen.xsize145temp1 -= 24146DrawNumbers(0, temp1, 13, temp0, 5, 8, true)147148// YPos display149#platform: USE_STANDALONE150temp0 = player[0].ypos151#endplatform152#platform: USE_ORIGINS153temp0 = player[currentPlayer].ypos154#endplatform155temp0 >>= 16156Abs(temp0)157DrawNumbers(0, temp1, 29, temp0, 5, 8, true)158159// Move 42 pixels to the left160temp1 -= 42161162// Draw the "X:" and "Y:" icons163164// Use red variant if player is in a negative pos165#platform: USE_STANDALONE166if player[0].xpos >= 0167#endplatform168#platform: USE_ORIGINS169if player[currentPlayer].xpos >= 0170#endplatform171DrawSpriteScreenXY(18, temp1, 15)172else173DrawSpriteScreenXY(36, temp1, 15)174end if175176#platform: USE_STANDALONE177if player[0].ypos >= 0178#endplatform179#platform: USE_ORIGINS180if player[currentPlayer].ypos >= 0181#endplatform182DrawSpriteScreenXY(19, temp1, 31)183else184DrawSpriteScreenXY(37, temp1, 31)185end if186end if187188#platform: USE_STANDALONE189// Lives icon190temp0 = stage.playerListPos191temp0 += 15192DrawSpriteScreenXY(temp0, 16, 212)193194// Character text195temp0 += 6196DrawSpriteScreenXY(temp0, 33, 213)197198// X between icon and number199DrawSpriteScreenXY(20, 38, 222)200201// The actual player lives number202DrawNumbers(24, 56, 220, player.lives, 2, 8, false)203#endplatform204205#platform: USE_ORIGINS206end if207end if208209if temp4 == false210// Get the character sprites211if currentPlayer == 0 // If this is Player 1212temp0 = stage.playerListPos213else214temp0 = vs.player2Type215end if216217if temp0 == PLAYER_AMY218temp0 = 40219temp1 = 41220else221temp0 += 15222temp1 = temp0223temp1 += 6224end if225226DrawSpriteScreenXY(temp0, 16, 212) // Life icon227DrawSpriteScreenXY(temp1, 33, 213) // Character name tag228229// X between icon and number230DrawSpriteScreenXY(20, 38, 222)231232// The actual player lives number233arrayPos0 = GLOBAL_PLAYERLIVES // VarName[player.lives]234arrayPos0 += currentPlayer235DrawNumbers(24, 56, 220, global[arrayPos0], 2, 8, false)236else237if game.playMode != BOOT_PLAYMODE_MISSION238// Draw the Coins counter239DrawSpriteScreenXY(38, 16, 212)240DrawSpriteScreenXY(39, 33, 213)241DrawSpriteScreenXY(20, 36, 222)242DrawNumbers(24, 59, 220, game.coinCount, 3, 8, false)243end if244end if245#endplatform246end function247248249private function HUD_Draw_Mobile250DrawSpriteScreenXY(10, 17, 9)251252if stage.minutes == 9253if object.flashingTimer > 7254DrawSpriteScreenXY(11, 17, 25)255end if256end if257258if player[0].rings == 0259if object.flashingTimer > 7260DrawSpriteScreenXY(12, 17, 41)261end if262end if263264DrawNumbers(0, 104, 9, player.score, 6, 8, false)265266if options.gameMode < MODE_TIMEATTACK267DrawSpriteScreenXY(14, 67, 25)268else269DrawSpriteScreenXY(13, 67, 25)270DrawNumbers(0, 104, 25, stage.milliSeconds, 2, 8, true)271end if272273DrawNumbers(0, 80, 25, stage.seconds, 2, 8, true)274DrawNumbers(0, 56, 25, stage.minutes, 1, 8, true)275DrawNumbers(0, 80, 41, player[0].rings, 3, 8, false)276277if player[0].type == TypeName[Debug Mode]278// Player position display, only show it when the player is in Debug Mode (as opposed to Standard's, where it's drawn if Debug Mode is active at all)279280temp0 = player[0].xpos281temp0 >>= 16282Abs(temp0)283temp1 = screen.xsize284temp1 -= 16285DrawNumbers(0, temp1, 25, temp0, 5, 8, true)286287temp0 = player[0].ypos288temp0 >>= 16289Abs(temp0)290DrawNumbers(0, temp1, 41, temp0, 5, 8, true)291292temp1 -= 42293if player[0].xpos >= 0294DrawSpriteScreenXY(18, temp1, 27)295else296DrawSpriteScreenXY(36, temp1, 27)297end if298299if player[0].ypos >= 0300DrawSpriteScreenXY(19, temp1, 43)301else302DrawSpriteScreenXY(37, temp1, 43)303end if304305DrawSpriteScreenXY(34, screen.xcenter, 16)306DrawSpriteScreenXY(35, screen.xcenter, 16)307end if308309temp1 = screen.xsize310temp1 -= 64311312temp0 = stage.playerListPos313314#platform: USE_STANDALONE315temp0 += 15316DrawSpriteScreenXY(temp0, temp1, 8)317#endplatform318319#platform: USE_ORIGINS320// You never see the mobile HUD in Origins yet they updated it in Plus LOL321// It wasn't even properly updated, since temp1 is being overwritten the x position of the sprites are now broken322if temp0 == PLAYER_AMY323temp0 = 40324temp1 = 41325else326temp0 += 15327temp1 = temp0328temp1 += 6329end if330DrawSpriteScreenXY(temp0, temp1, 8)331#endplatform332333temp1 += 17334#platform: USE_STANDALONE335temp0 += 6336DrawSpriteScreenXY(temp0, temp1, 9)337#endplatform338#platform: USE_ORIGINS339DrawSpriteScreenXY(temp1, temp1, 9) // Using the same value for both spriteframe and xpos LOL340#endplatform341342temp1 += 5343DrawSpriteScreenXY(20, temp1, 18)344345temp1 += 18346DrawNumbers(24, temp1, 16, player.lives, 2, 8, false)347end function348349350// ========================351// Events352// ========================353354event ObjectDraw355// Update flashing red texts356#platform: USE_STANDALONE357if player[0].rings == 0358object.flashingTimer++359360if object.flashingTimer == 16361object.flashingTimer = 0362end if363else364if stage.minutes == 9365object.flashingTimer++366367if object.flashingTimer == 16368object.flashingTimer = 0369end if370end if371end if372#endplatform373374#platform: USE_ORIGINS375currentPlayer = screen.currentID376377if player[currentPlayer].rings == 0378object.flashingTimer = oscillation379object.flashingTimer &= 15380else381if stage.minutes == 9382object.flashingTimer = oscillation383object.flashingTimer &= 15384end if385end if386387if game.timeOver != false388object.timeOver = true389end if390#endplatform391392CallFunction(object.drawFunction)393end event394395396event ObjectStartup397LoadSpriteSheet("Global/Display.gif")398399// HUD frames400SpriteFrame(0, 0, 8, 11, 1, 50) // #0 - Number 0401SpriteFrame(0, 0, 8, 11, 10, 50) // #1 - Number 1402SpriteFrame(0, 0, 8, 11, 19, 50) // #2 - Number 2403SpriteFrame(0, 0, 8, 11, 28, 50) // #3 - Number 3404SpriteFrame(0, 0, 8, 11, 1, 62) // #4 - Number 4405SpriteFrame(0, 0, 8, 11, 10, 62) // #5 - Number 5406SpriteFrame(0, 0, 8, 11, 19, 62) // #6 - Number 6407SpriteFrame(0, 0, 8, 11, 28, 62) // #7 - Number 7408SpriteFrame(0, 0, 8, 11, 1, 74) // #8 - Number 8409SpriteFrame(0, 0, 8, 11, 10, 74) // #9 - Number 9410411// A-F digits are unused412413SpriteFrame(0, 0, 40, 43, 1, 1) // #10 - Score, Time, Rings HUD text414SpriteFrame(0, 0, 31, 11, 1, 119) // #11 - Red Time text415SpriteFrame(0, 0, 39, 11, 1, 131) // #12 - Red Rings text416SpriteFrame(0, 0, 29, 4, 1, 45) // #13 - Timer ticks417SpriteFrame(0, 0, 3, 11, 37, 50) // #14 - Timer colon418SpriteFrame(0, 0, 16, 16, 83, 18) // #15 - Sonic life icon419SpriteFrame(0, 0, 16, 16, 100, 18) // #16 - Tails life icon420SpriteFrame(0, 0, 16, 16, 117, 18) // #17 - Knuckles life icon421SpriteFrame(0, 0, 8, 8, 1, 98) // #18 - Yellow X Debug Icon422SpriteFrame(0, 0, 8, 8, 10, 98) // #19 - Yellow Y Debug Icon423SpriteFrame(0, 0, 6, 6, 19, 98) // #20 - Small white x Debug Icon424425SpriteFrame(0, 0, 31, 7, 185, 18) // #21 - Sonic name tag426427// Tails or Miles428if options.region == false429SpriteFrame(0, 0, 31, 7, 217, 18) // #22 - Tails name tag430else431SpriteFrame(0, 0, 31, 7, 185, 26) // #22 - Miles name tag432end if433434SpriteFrame(0, 0, 31, 7, 217, 26) // #23 - Knuckles name tag435436SpriteFrame(0, 0, 8, 8, 37, 64) // #24 - Small number 0437SpriteFrame(0, 0, 8, 8, 46, 64) // #25 - Small number 1438SpriteFrame(0, 0, 8, 8, 55, 64) // #26 - Small number 2439SpriteFrame(0, 0, 8, 8, 64, 64) // #27 - Small number 3440SpriteFrame(0, 0, 8, 8, 73, 64) // #28 - Small number 4441SpriteFrame(0, 0, 8, 8, 82, 64) // #29 - Small number 5442SpriteFrame(0, 0, 8, 8, 91, 64) // #30 - Small number 6443SpriteFrame(0, 0, 8, 8, 100, 64) // #31 - Small number 7444SpriteFrame(0, 0, 8, 8, 109, 64) // #32 - Small number 8445SpriteFrame(0, 0, 8, 8, 118, 64) // #33 - Small number 9446447SpriteFrame(-16, 0, 8, 8, 127, 64) // #34 - Small debug Plus sign448SpriteFrame(8, 0, 8, 8, 136, 64) // #35 - Small debug Minus sign449SpriteFrame(0, 0, 8, 8, 25, 98) // #36 - Red X Debug Icon450SpriteFrame(0, 0, 8, 8, 34, 98) // #37 - Red Y Debug Icon451452#platform: USE_ORIGINS453SpriteFrame(0, 0, 16, 16, 179, 180) // #38 - Coins life icon454SpriteFrame(0, 0, 39, 7, 179, 197) // #39 - Coins name tag455456SpriteFrame(0, 0, 16, 16, 120, 47) // #40 - Amy life icon457SpriteFrame(0, 0, 31, 7, 217, 34) // #41 - Amy name tag458#endplatform459460// Set the HUD's draw function based on the current platform461foreach (TypeName[HUD], arrayPos0, ALL_ENTITIES)462if engine.deviceType == STANDARD463object[arrayPos0].drawFunction = HUD_Draw_Standard464else465object[arrayPos0].drawFunction = HUD_Draw_Mobile466end if467next468end event469470471// ========================472// Editor Events473// ========================474475event RSDKDraw476DrawSprite(0)477end event478479480event RSDKLoad481LoadSpriteSheet("Global/Display.gif")482SpriteFrame(0, 0, 40, 43, 1, 1)483484// This gets set in Stage Setup, but it's just an old CD leftover for time periods and doesn't do anything in this game485SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")486end event487488489