Path: blob/master/Sonic 1/Scripts/Global/HUD.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// 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.flashTimer13private 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 Modes Aliases22private alias 2 : MODE_TIMEATTACK232425// ========================26// Function Declarations27// ========================2829reserve function HUD_Draw_Standard30reserve function HUD_Draw_Mobile313233// ========================34// Function Definitions35// ========================3637private function HUD_Draw_Standard38#platform: USE_ORIGINS39// temp4 will tell whether to draw lives or coins40temp4 = game.coinMode4142if game.playMode == BOOT_PLAYMODE_MISSION43if game.missionEnd == false44game.hudEnable = HUDENABLE_ON45end if46temp4 = true47else4849if game.playMode == BOOT_PLAYMODE_BOSSRUSH50game.hudEnable = HUDENABLE_ON51temp4 = false52else5354if game.coinMode != false55game.hudEnable = HUDENABLE_ON56end if57#endplatform5859DrawSpriteScreenXY(10, 17, 13)6061#platform: USE_ORIGINS62temp1 = stage.minutes63temp2 = stage.seconds6465CheckGreater(temp1, 9)66temp3 = checkResult67CheckNotEqual(object.timeOver, false)68checkResult |= temp36970if checkResult != false71temp1 = 972temp2 = 5973end if7475if temp1 == 976#endplatform7778#platform: USE_STANDALONE79if stage.minutes == 980#endplatform81if object.flashTimer > 782DrawSpriteScreenXY(11, 17, 29)83end if84end if8586if player[0].rings == 087if object.flashTimer > 788DrawSpriteScreenXY(12, 17, 45)89end if90end if9192DrawNumbers(0, 104, 13, player.score, 6, 8, false)9394if options.gameMode < MODE_TIMEATTACK95// In standard mode, only seconds & minutes are shown, along with their corresponding ticks96DrawSpriteScreenXY(14, 67, 29)97else98// If in time attack, draw extended time with milliseconds (and its extra ticks)99DrawSpriteScreenXY(13, 67, 29)100DrawNumbers(0, 104, 29, stage.milliSeconds, 2, 8, true)101end if102103// Rest of the time display, kept the same between modes104#platform: USE_STANDALONE105DrawNumbers(0, 80, 29, stage.seconds, 2, 8, true)106DrawNumbers(0, 56, 29, stage.minutes, 1, 8, true)107#endplatform108#platform: USE_ORIGINS109DrawNumbers(0, 80, 29, temp2, 2, 8, true)110DrawNumbers(0, 56, 29, temp1, 1, 8, true)111#endplatform112113DrawNumbers(0, 80, 45, player[0].rings, 3, 8, false)114115if stage.debugMode == true116// If the player is in debug mode, draw X and Y positions117118// First get the absolute X pos value, truncated down to essentially ixpos119temp0 = player[0].xpos120temp0 >>= 16121Abs(temp0)122123// Get position to draw it124temp1 = screen.xsize125temp1 -= 24126127// Draw the XPos value128DrawNumbers(0, temp1, 13, temp0, 5, 8, true)129130// Then get absolute Y pos value, also truncated down to iypos131temp0 = player[0].ypos132temp0 >>= 16133Abs(temp0)134135// Draw the YPos value136DrawNumbers(0, temp1, 29, temp0, 5, 8, true)137138temp1 -= 42139140// If XPos is in the negatives, draw the red version of the "X:" icon141if player[0].xpos >= 0142#platform: USE_STANDALONE143DrawSpriteScreenXY(18, temp1, 15)144#endplatform145#platform: USE_ORIGINS146DrawSpriteScreenXY(21, temp1, 15)147#endplatform148else149#platform: USE_STANDALONE150DrawSpriteScreenXY(36, temp1, 15)151#endplatform152#platform: USE_ORIGINS153DrawSpriteScreenXY(42, temp1, 15)154#endplatform155end if156157// Same for YPos - if negative, draw red version of "Y:" icon158if player[0].ypos >= 0159#platform: USE_STANDALONE160DrawSpriteScreenXY(19, temp1, 31)161#endplatform162#platform: USE_ORIGINS163DrawSpriteScreenXY(22, temp1, 31)164#endplatform165else166#platform: USE_STANDALONE167DrawSpriteScreenXY(37, temp1, 31)168#endplatform169#platform: USE_ORIGINS170DrawSpriteScreenXY(43, temp1, 31)171#endplatform172end if173end if174#platform: USE_ORIGINS175end if176end if177178if temp4 == false179#endplatform180// Draw life indicator181temp0 = stage.playerListPos182temp0 += 15183DrawSpriteScreenXY(temp0, 16, 212)184#platform: USE_STANDALONE185temp0 += 6186#endplatform187#platform: USE_ORIGINS188temp0 += 9189#endplatform190191DrawSpriteScreenXY(temp0, 33, 213)192#platform: USE_STANDALONE193DrawSpriteScreenXY(20, 38, 222)194DrawNumbers(24, 56, 220, player.lives, 2, 8, false)195#endplatform196#platform: USE_ORIGINS197DrawSpriteScreenXY(23, 38, 222)198DrawNumbers(30, 56, 220, player.lives, 2, 8, false)199else200if game.playMode != BOOT_PLAYMODE_MISSION201// Draw coins indicator202DrawSpriteScreenXY(44, 16, 212)203DrawSpriteScreenXY(45, 33, 213)204DrawSpriteScreenXY(23, 36, 222)205DrawNumbers(30, 59, 220, game.coinCount, 3, 8, false)206end if207end if208#endplatform209end function210211212private function HUD_Draw_Mobile213DrawSpriteScreenXY(10, 17, 9)214215if stage.minutes == 9216if object.flashTimer > 7217DrawSpriteScreenXY(11, 17, 25)218end if219end if220221if player[0].rings == 0222if object.flashTimer > 7223DrawSpriteScreenXY(12, 17, 41)224end if225end if226227DrawNumbers(0, 104, 9, player.score, 6, 8, false)228if options.gameMode < MODE_TIMEATTACK229DrawSpriteScreenXY(14, 67, 25)230else231DrawSpriteScreenXY(13, 67, 25)232DrawNumbers(0, 104, 25, stage.milliSeconds, 2, 8, true)233end if234DrawNumbers(0, 80, 25, stage.seconds, 2, 8, true)235DrawNumbers(0, 56, 25, stage.minutes, 1, 8, true)236DrawNumbers(0, 80, 41, player[0].rings, 3, 8, false)237238if player[0].type == TypeName[Debug Mode]239temp0 = player[0].xpos240temp0 >>= 16241Abs(temp0)242temp1 = screen.xsize243temp1 -= 16244DrawNumbers(0, temp1, 25, temp0, 5, 8, true)245temp0 = player[0].ypos246temp0 >>= 16247Abs(temp0)248DrawNumbers(0, temp1, 41, temp0, 5, 8, true)249temp1 -= 42250if player[0].xpos >= 0251#platform: USE_STANDALONE252DrawSpriteScreenXY(18, temp1, 27)253#endplatform254#platform: USE_ORIGINS255DrawSpriteScreenXY(21, temp1, 27)256#endplatform257258else259#platform: USE_STANDALONE260DrawSpriteScreenXY(36, temp1, 27)261#endplatform262#platform: USE_ORIGINS263DrawSpriteScreenXY(42, temp1, 27)264#endplatform265end if266267// Same for YPos - if negative, draw red version of "Y:" icon268if player[0].ypos >= 0269270#platform: USE_STANDALONE271DrawSpriteScreenXY(19, temp1, 43)272#endplatform273#platform: USE_ORIGINS274DrawSpriteScreenXY(22, temp1, 43)275#endplatform276else277278#platform: USE_STANDALONE279DrawSpriteScreenXY(37, temp1, 43)280#endplatform281#platform: USE_ORIGINS282DrawSpriteScreenXY(43, temp1, 43)283#endplatform284end if285#platform: USE_STANDALONE286DrawSpriteScreenXY(34, screen.xcenter, 16)287DrawSpriteScreenXY(35, screen.xcenter, 16)288#endplatform289#platform: USE_ORIGINS290DrawSpriteScreenXY(40, screen.xcenter, 16)291DrawSpriteScreenXY(41, screen.xcenter, 16)292#endplatform293294end if295temp1 = screen.xsize296temp1 -= 64297temp0 = stage.playerListPos298temp0 += 15299DrawSpriteScreenXY(temp0, temp1, 8)300temp1 += 17301#platform: USE_STANDALONE302temp0 += 6303#endplatform304#platform: USE_ORIGINS305temp0 += 9306#endplatform307DrawSpriteScreenXY(temp0, temp1, 9)308temp1 += 5309#platform: USE_STANDALONE310DrawSpriteScreenXY(20, temp1, 18)311#endplatform312#platform: USE_ORIGINS313DrawSpriteScreenXY(23, temp1, 18)314#endplatform315316temp1 += 18317#platform: USE_STANDALONE318DrawNumbers(24, temp1, 16, player.lives, 2, 8, false)319#endplatform320#platform: USE_ORIGINS321DrawNumbers(30, temp1, 16, player.lives, 2, 8, false)322#endplatform323end function324325326// ========================327// Events328// ========================329330event ObjectDraw331// Progress HUD flashing332// 0 ring flashing takes priority over time over flashing333if player[0].rings == 0334object.flashTimer++335if object.flashTimer == 16336object.flashTimer = 0337end if338else339if stage.minutes == 9340object.flashTimer++341if object.flashTimer == 16342object.flashTimer = 0343end if344end if345end if346347#platform: USE_ORIGINS348if game.timeOver != false349object.timeOver = true350end if351#endplatform352353CallFunction(object.drawFunction)354end event355356357event ObjectStartup358LoadSpriteSheet("Global/Display.gif")359360// HUD frames (numbers are formatted as Standalone/Origins)361SpriteFrame(0, 0, 8, 11, 1, 50) // 0/ 0 - Number 0362SpriteFrame(0, 0, 8, 11, 10, 50) // 1/ 1 - Number 1363SpriteFrame(0, 0, 8, 11, 19, 50) // 2/ 2 - Number 2364SpriteFrame(0, 0, 8, 11, 28, 50) // 3/ 3 - Number 3365SpriteFrame(0, 0, 8, 11, 1, 62) // 4/ 4 - Number 4366SpriteFrame(0, 0, 8, 11, 10, 62) // 5/ 5 - Number 5367SpriteFrame(0, 0, 8, 11, 19, 62) // 6/ 6 - Number 6368SpriteFrame(0, 0, 8, 11, 28, 62) // 7/ 7 - Number 7369SpriteFrame(0, 0, 8, 11, 1, 74) // 8/ 8 - Number 8370SpriteFrame(0, 0, 8, 11, 10, 74) // 9/ 9 - Number 9371SpriteFrame(0, 0, 39, 43, 1, 1) // 10/10 - Score, Times, Ring text372SpriteFrame(0, 0, 31, 11, 1, 119) // 11/11 - Red Time text373SpriteFrame(0, 0, 39, 11, 1, 131) // 12/12 - Red Rings text374SpriteFrame(0, 0, 29, 4, 1, 45) // 13/13 - Timer tick marks375SpriteFrame(0, 0, 3, 11, 37, 50) // 14/14 - : (Colon)376SpriteFrame(0, 0, 16, 16, 43, 107) // 15/15 - Sonic life icon377SpriteFrame(0, 0, 16, 16, 60, 107) // 16/16 - Tails life icon378SpriteFrame(0, 0, 16, 16, 77, 107) // 17/17 - Knuckles life icon379#platform: USE_ORIGINS380SpriteFrame(0, 0, 16, 16, 0, 0) // XX/18 - Padding for Amy icon (her character ID is 5)381SpriteFrame(0, 0, 16, 16, 0, 0) // XX/19 - Padding for Amy icon (her character ID is 5)382SpriteFrame(0, 0, 16, 16, 239, 174) // XX/20 - Amy life icon383#endplatform384SpriteFrame(0, 0, 8, 8, 1, 98) // 18/21 - Yellow "X" debug icon385SpriteFrame(0, 0, 8, 8, 10, 98) // 19/22 - Yellow "Y" debug icon386SpriteFrame(0, 0, 6, 6, 19, 98) // 20/23 - White small x debug icon387SpriteFrame(0, 0, 31, 7, 144, 43) // 21/24 - Sonic name tag388389// Determine between Tails or Miles based on region setting390if options.region == 0391SpriteFrame(0, 0, 31, 7, 176, 43) // 22/25 - Tails name tag392else393SpriteFrame(0, 0, 31, 7, 176, 51) // 22/25 - Miles name tag394end if395396SpriteFrame(0, 0, 31, 7, 144, 51) // 23/26 - Knuckles name tag397#platform: USE_ORIGINS398SpriteFrame(0, 0, 31, 7, 0, 0) // XX/27 - Padding for Amy name tag (her character ID is 5)399SpriteFrame(0, 0, 31, 7, 0, 0) // XX/28 - Padding for Amy name tag (her character ID is 5)400SpriteFrame(0, 0, 31, 7, 182, 183) // XX/29 - Amy name tag401#endplatform402SpriteFrame(0, 0, 8, 8, 37, 64) // 24/30 - Small number 0403SpriteFrame(0, 0, 8, 8, 46, 64) // 25/31 - Small number 1404SpriteFrame(0, 0, 8, 8, 55, 64) // 26/32 - Small number 2405SpriteFrame(0, 0, 8, 8, 64, 64) // 27/33 - Small number 3406SpriteFrame(0, 0, 8, 8, 73, 64) // 28/34 - Small number 4407SpriteFrame(0, 0, 8, 8, 82, 64) // 29/35 - Small number 5408SpriteFrame(0, 0, 8, 8, 91, 64) // 30/36 - Small number 6409SpriteFrame(0, 0, 8, 8, 100, 64) // 31/37 - Small number 7410SpriteFrame(0, 0, 8, 8, 109, 64) // 32/38 - Small number 8411SpriteFrame(0, 0, 8, 8, 118, 64) // 33/39 - Small number 9412SpriteFrame(-16, 0, 8, 8, 127, 64) // 34/40 - Small debug minus sign413SpriteFrame(8, 0, 8, 8, 136, 64) // 35/41 - Small debug plus sign414SpriteFrame(0, 0, 8, 8, 145, 64) // 36/42 - Red "X" debug icon415SpriteFrame(0, 0, 8, 8, 154, 64) // 37/43 - Red "Y" debug icon416417#platform: USE_ORIGINS418SpriteFrame(0, 0, 16, 16, 199, 141) // XX/44 - Coins life icon419SpriteFrame(0, 0, 39, 7, 182, 158) // XX/45 - Coins name tag420#endplatform421422foreach (TypeName[HUD], arrayPos0, ALL_ENTITIES)423if engine.deviceType == STANDARD424object[arrayPos0].drawFunction = HUD_Draw_Standard425else426object[arrayPos0].drawFunction = HUD_Draw_Mobile427end if428next429end event430431432// ========================433// Editor Events434// ========================435436event RSDKDraw437DrawSprite(0)438end event439440441event RSDKLoad442LoadSpriteSheet("Global/Display.gif")443SpriteFrame(0, 0, 39, 43, 1, 1)444445// Strangely enough, this does get set in Stage Setup446// It's just an old leftover behaviour from CD, though, and has no real effect on anything447SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")448end event449450451