Path: blob/master/Sonic 2/Scripts/2PVS/2PVSMenu2.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: 2P VS Menu 2 Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value1 : object.iconSheet13private alias object.value2 : object.textSheet // Set, but never used14private alias object.value3 : object.selection15private alias object.value4 : object.selectionTimer16private alias object.value5 : object.charBox.x17private alias object.value6 : object.charBox.y18private alias object.value7 : object.sonicAlpha19private alias object.value8 : object.tailsAlpha20private alias object.value9 : object.knuxAlpha2122// States23private alias 0 : 2PVSMENU2_SETUP24private alias 1 : 2PVSMENU2_SELECTING25private alias 2 : 2PVSMENU2_SELECTEDPLAYER26private alias 3 : 2PVSMENU2_SELECTEDBACK27private alias 4 : 2PVSMENU2_TOVSMENU328private alias 5 : 2PVSMENU2_TOVSMENU12930// Selections31private alias 0 : 2PVSMENU2_SEL_NONE32private alias 1 : 2PVSMENU2_SEL_SONIC33private alias 2 : 2PVSMENU2_SEL_TAILS34private alias 3 : 2PVSMENU2_SEL_KNUX35private alias 4 : 2PVSMENU2_SEL_BACK3637// 2PVSMenu1 Aliases38private alias object.value0 : 2PVSMenu1.timer3940// 2PVSMenu1 States41private alias 1 : 2PVSMENU1_SELECTING4243// 2PVSMenu3 Aliases44private alias object.value0 : 2PVSMenu3.timer4546// 2PVSMenu3 States47private alias 1 : 2PVSMENU3_SELECTING484950// ========================51// Function Declarations52// ========================5354reserve function 2PVSMenu2_DrawSonicBox55reserve function 2PVSMenu2_DrawTailsBox56reserve function 2PVSMenu2_DrawKnuxBox575859// ========================60// Function Definitions61// ========================6263private function 2PVSMenu2_DrawSonicBox64temp0 = screen.xcenter65temp0 -= object.charBox.x66if object.selection == 2PVSMENU2_SEL_SONIC67if object.state == 2PVSMENU2_SELECTING68temp1 = 369else70temp1 = object.selectionTimer71temp1 >>= 172temp1 &= 173temp1 += 274end if75else76temp1 = 277end if78object.alpha = object.sonicAlpha79DrawSpriteScreenFX(temp1, FX_INK, temp0, object.charBox.y)80DrawSpriteScreenFX(4, FX_INK, temp0, object.charBox.y)81end function828384private function 2PVSMenu2_DrawTailsBox85if object.selection == 2PVSMENU2_SEL_TAILS86if object.state == 2PVSMENU2_SELECTING87temp1 = 388else89temp1 = object.selectionTimer90temp1 >>= 191temp1 &= 192temp1 += 293end if94else95temp1 = 296end if97object.alpha = object.tailsAlpha98DrawSpriteScreenFX(temp1, FX_INK, screen.xcenter, object.charBox.y)99DrawSpriteScreenFX(5, FX_INK, screen.xcenter, object.charBox.y)100end function101102103private function 2PVSMenu2_DrawKnuxBox104temp0 = screen.xcenter105temp0 += object.charBox.x106if object.selection == 2PVSMENU2_SEL_KNUX107if object.state == 2PVSMENU2_SELECTING108temp1 = 3109else110temp1 = object.selectionTimer111temp1 >>= 1112temp1 &= 1113temp1 += 2114end if115else116temp1 = 2117end if118object.alpha = object.knuxAlpha119DrawSpriteScreenFX(temp1, FX_INK, temp0, object.charBox.y)120DrawSpriteScreenFX(6, FX_INK, temp0, object.charBox.y)121end function122123124// ========================125// Events126// ========================127128event ObjectUpdate129switch object.state130case 2PVSMENU2_SETUP131LoadSpriteSheet("LevelSelect/Icons.gif")132object.iconSheet = object.spriteSheet133134// Even if we're setting everything up for it, this 2PVS Menu in particular doesn't have any menus to draw so this goes unused135LoadSpriteSheet("LevelSelect/Text.gif")136object.textSheet = object.spriteSheet137138if engine.deviceType == STANDARD139options.physicalControls = true140end if141142if options.physicalControls == false143object.selection = 2PVSMENU2_SEL_NONE144else145object.selection = 2PVSMENU2_SEL_SONIC146end if147148object.charBox.x = 80149object.charBox.y = 120150object.sonicAlpha = 0x100151object.tailsAlpha = 0x100152object.knuxAlpha = 0x100153object.inkEffect = INK_ALPHA154object.state++155break156157case 2PVSMENU2_SELECTING158if options.physicalControls == false159CheckTouchRect(0, 0, screen.xsize, screen.ysize)160if checkResult > -1161temp0 = screen.xcenter162temp0 -= object.charBox.x163temp0 -= 32164165temp1 = temp0166temp1 += 64167temp2 = object.charBox.y168temp2 -= 32169temp3 = temp2170temp3 += 64171object.selection = 2PVSMENU2_SEL_NONE172CheckTouchRect(temp0, temp2, temp1, temp3)173if checkResult > -1174object.selection = 2PVSMENU2_SEL_SONIC175end if176177temp0 = screen.xcenter178temp0 -= 32179temp1 = temp0180temp1 += 64181CheckTouchRect(temp0, temp2, temp1, temp3)182if checkResult > -1183object.selection = 2PVSMENU2_SEL_TAILS184end if185186temp0 = screen.xcenter187temp0 += object.charBox.x188temp0 -= 32189temp1 = temp0190temp1 += 64191CheckTouchRect(temp0, temp2, temp1, temp3)192if checkResult > -1193object.selection = 2PVSMENU2_SEL_KNUX194end if195196temp0 = screen.xcenter197temp0 -= 24198temp1 = temp0199temp1 += 48200CheckTouchRect(temp0, 192, temp1, 224)201if checkResult > -1202object.selection = 2PVSMENU2_SEL_BACK203end if204else205switch object.selection206default207case 2PVSMENU2_SEL_NONE208break209210case 2PVSMENU2_SEL_SONIC211case 2PVSMENU2_SEL_TAILS212case 2PVSMENU2_SEL_KNUX213object.state = 2PVSMENU2_SELECTEDPLAYER214object.selectionTimer = 0215PlaySfx(SfxName[Star Post], false)216break217218case 2PVSMENU2_SEL_BACK219object.state = 2PVSMENU2_SELECTEDBACK220object.selectionTimer = 0221PlaySfx(SfxName[Menu Back], false)222break223224end switch225end if226227if object.state != 2PVSMENU2_SELECTEDPLAYER228if keyPress[0].left == true229options.physicalControls = true230object.selection = 2PVSMENU2_SEL_KNUX231end if232233if keyPress[0].right == true234options.physicalControls = true235object.selection = 2PVSMENU2_SEL_SONIC236end if237238if keyPress[0].up == true239options.physicalControls = true240object.selection = 2PVSMENU2_SEL_BACK241end if242243if keyPress[0].down == true244options.physicalControls = true245object.selection = 2PVSMENU2_SEL_TAILS246end if247end if248else249if keyPress[0].left == true250object.selection--251if object.selection < 2PVSMENU2_SEL_SONIC252object.selection = 2PVSMENU2_SEL_KNUX253end if254255PlaySfx(SfxName[Menu Move], false)256end if257258if keyPress[0].right == true259object.selection++260if object.selection > 2PVSMENU2_SEL_KNUX261object.selection = 2PVSMENU2_SEL_SONIC262end if263264PlaySfx(SfxName[Menu Move], false)265end if266267if keyPress[0].up == true268if object.selection < 2PVSMENU2_SEL_BACK269object.selection = 2PVSMENU2_SEL_BACK270else271object.selection = 2PVSMENU2_SEL_TAILS272end if273274PlaySfx(SfxName[Menu Move], false)275end if276277if keyPress[0].down == true278if object.selection < 2PVSMENU2_SEL_BACK279object.selection = 2PVSMENU2_SEL_BACK280else281object.selection = 2PVSMENU2_SEL_TAILS282end if283284PlaySfx(SfxName[Menu Move], false)285end if286287if keyPress[0].start == true288if object.selection < 2PVSMENU2_SEL_BACK289object.state = 2PVSMENU2_SELECTEDPLAYER290object.selectionTimer = 0291PlaySfx(SfxName[Star Post], false)292else293object.state = 2PVSMENU2_SELECTEDBACK294object.selectionTimer = 0295PlaySfx(SfxName[Menu Back], false)296end if297end if298299if keyPress[0].buttonA == true300object.state = 2PVSMENU2_SELECTEDPLAYER301object.selectionTimer = 0302PlaySfx(SfxName[Star Post], false)303end if304305if keyPress[0].buttonB == true306object.state = 2PVSMENU2_SELECTEDBACK307object.selection = 2PVSMENU2_SEL_BACK308object.selectionTimer = 0309PlaySfx(SfxName[Menu Back], false)310end if311312if object.state != 2PVSMENU2_SELECTEDPLAYER313CheckTouchRect(0, 0, screen.xsize, screen.ysize)314if checkResult > -1315options.physicalControls = false316object.selection = 2PVSMENU2_SEL_NONE317end if318end if319end if320break321322case 2PVSMENU2_SELECTEDPLAYER323switch object.selection324default325case 2PVSMENU2_SEL_NONE326case 2PVSMENU2_SEL_BACK327break328329case 2PVSMENU2_SEL_SONIC330object.tailsAlpha -= 8331object.knuxAlpha -= 8332break333334case 2PVSMENU2_SEL_TAILS335object.sonicAlpha -= 8336object.knuxAlpha -= 8337break338339case 2PVSMENU2_SEL_KNUX340object.sonicAlpha -= 8341object.tailsAlpha -= 8342break343344end switch345346if object.selectionTimer < 32347object.selectionTimer++348object.charBox.x = 32349object.charBox.x -= object.selectionTimer350object.charBox.x *= 80351object.charBox.x >>= 5352else353object.selectionTimer = 0354object.charBox.x = 0355object.timer = -256356object.state = 2PVSMENU2_TOVSMENU3357end if358break359360case 2PVSMENU2_SELECTEDBACK361if object.selectionTimer < 32362object.selectionTimer++363else364object.selectionTimer = 0365object.state = 2PVSMENU2_TOVSMENU1366end if367break368369case 2PVSMENU2_TOVSMENU3370if object.timer < 0x100371object.timer += 0x10372if object.timer > 0373SetScreenFade(0x00, 0x00, 0x00, object.timer)374end if375else376stage.playerListPos = object.selection377stage.playerListPos--378ResetObjectEntity(1, TypeName[2P VS Menu 3], 0, 0, 0)379object[1].priority = PRIORITY_ACTIVE380object[0].state = 2PVSMENU1_SELECTING3812PVSMenu3[0].timer = 384382SetScreenFade(0x00, 0x00, 0x00, 0xFF)383CallNativeFunction2(Connect2PVS, vs.gameLength, vs.itemMode)384end if385break386387case 2PVSMENU2_TOVSMENU1388if object.timer < 0x100389object.timer += 0x10390SetScreenFade(0x00, 0x00, 0x00, object.timer)391else392ResetObjectEntity(1, TypeName[2P VS Menu 1], 0, 0, 0)393object[1].priority = PRIORITY_ACTIVE394object[0].state = 2PVSMENU3_SELECTING3952PVSMenu1[0].timer = 384396SetScreenFade(0x00, 0x00, 0x00, 0xFF)397end if398break399400end switch401end event402403404event ObjectDraw405object.spriteSheet = object.iconSheet406407// PLAYER SELECT408DrawSpriteScreenXY(0, screen.xcenter, 17)409DrawSpriteScreenXY(1, screen.xcenter, 17)410411if object.state == 2PVSMENU2_SELECTEDBACK412temp0 = object.selectionTimer413temp0 >>= 1414temp0 &= 1415temp0 += 7416else417if options.physicalControls == false418if object.selection == 2PVSMENU2_SEL_BACK419temp0 = 1420else421temp0 = 0422end if423else424temp0 = 0425end if426427temp0 += 7428end if429430DrawSpriteScreenXY(temp0, screen.xcenter, 210)431switch object.selection432case 2PVSMENU2_SEL_NONE433case 2PVSMENU2_SEL_SONIC434CallFunction(2PVSMenu2_DrawTailsBox)435CallFunction(2PVSMenu2_DrawKnuxBox)436CallFunction(2PVSMenu2_DrawSonicBox)437break438439case 2PVSMENU2_SEL_TAILS440CallFunction(2PVSMenu2_DrawKnuxBox)441CallFunction(2PVSMenu2_DrawSonicBox)442CallFunction(2PVSMenu2_DrawTailsBox)443break444445case 2PVSMENU2_SEL_KNUX446CallFunction(2PVSMenu2_DrawTailsBox)447CallFunction(2PVSMenu2_DrawSonicBox)448CallFunction(2PVSMenu2_DrawKnuxBox)449break450451case 2PVSMENU2_SEL_BACK452CallFunction(2PVSMenu2_DrawSonicBox)453CallFunction(2PVSMenu2_DrawTailsBox)454CallFunction(2PVSMenu2_DrawKnuxBox)455456// Back Button Selection Box457if object.state != 2PVSMENU2_SELECTEDBACK458if options.physicalControls == true459DrawSpriteScreenXY(9, screen.xcenter, 210)460end if461end if462break463464end switch465end event466467468event ObjectStartup469LoadSpriteSheet("LevelSelect/Icons.gif")470LoadSpriteSheet("LevelSelect/Text.gif") // Unused here471SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0472SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1473SpriteFrame(-32, -32, 64, 64, 98, 249) // Details Border - #2474SpriteFrame(-32, -32, 64, 64, 163, 249) // Details Border (Selected) - #3475SpriteFrame(-12, -20, 24, 40, 1, 279) // Sonic - #4476SpriteFrame(-16, -20, 32, 40, 54, 279) // Tails - #5477SpriteFrame(-14, -20, 27, 40, 26, 279) // Knuckles - #6478SpriteFrame(-20, -10, 40, 20, 1, 341) // Back - #7479SpriteFrame(-20, -10, 40, 20, 42, 341) // Back (Selected) - #8480SpriteFrame(-22, -12, 42, 22, 1, 362) // Selection Box - #9481482foreach (TypeName[2P VS Menu 2], arrayPos0, ALL_ENTITIES)483object[arrayPos0].priority = PRIORITY_ACTIVE484next485end event486487488// ========================489// Editor Events490// ========================491492event RSDKDraw493DrawSprite(0)494DrawSprite(1)495end event496497498event RSDKLoad499LoadSpriteSheet("LevelSelect/Icons.gif")500SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0501SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1502503SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")504end event505506507