Path: blob/master/Sonic 2/Scripts/2PVS/2PVSMenu4.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: 2P VS Menu 4 Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// This script is exclusive to Sonic Origins8// It's a local multiplayer version of 2P VS Menu 2 (Character Select)910// Slot 0 = 2PVSSetup11// Slot 1 = Player 1's 2PVSMenu4 (prop val 1)12// Slot 2 = Player 2's 2PVSMenu4 (prop val 2)1314// ========================15// Aliases16// ========================1718private alias object.propertyValue : object.player1920private alias object.value0 : object.timer21private alias object.value1 : object.selection22private alias object.value2 : object.selectionTimer2324// States25private alias 0 : 2PVSMENU4_SETUP26private alias 1 : 2PVSMENU4_WAITFORINPUT27private alias 2 : 2PVSMENU4_SELECTING28private alias 3 : 2PVSMENU4_SELECTEDPLAYER29private alias 4 : 2PVSMENU4_WAITFORP130private alias 5 : 2PVSMENU4_WAITFORP231private alias 6 : 2PVSMENU4_TOVSMENU332private alias 7 : 2PVSMENU4_TOVSMENU13334// Selections35private alias 0 : 2PVSMENU4_SEL_NONE36private alias 1 : 2PVSMENU4_SEL_SONIC37private alias 2 : 2PVSMENU4_SEL_TAILS38private alias 3 : 2PVSMENU4_SEL_KNUX39private alias 4 : 2PVSMENU4_SEL_AMY40private alias 5 : 2PVSMENU4_SEL_BACK4142// 2PVSMenu1 Aliases43private alias object.value0 : 2PVSMenu1.timer4445private alias 1 : 2PVSMENU1_SELECTING4647// 2PVSMenu3 Aliases48private alias object.value0 : 2PVSMenu3.timer4950private alias 1 : 2PVSMENU3_SELECTING515253// ========================54// Events55// ========================5657event ObjectUpdate58switch object.state59case 2PVSMENU4_SETUP60AssignInputSlotToDevice(object.player, -1)61object.selection = 2PVSMENU4_SEL_NONE62object.state = 2PVSMENU4_WAITFORINPUT63break6465case 2PVSMENU4_WAITFORINPUT66arrayPos0 = object.player6768checkResult = keyPress[arrayPos0].up69checkResult |= keyPress[arrayPos0].down70checkResult |= keyPress[arrayPos0].left71checkResult |= keyPress[arrayPos0].right72checkResult |= keyPress[arrayPos0].buttonA73checkResult |= keyPress[arrayPos0].buttonC74checkResult |= keyPress[arrayPos0].start7576if checkResult == true77object.selection = 2PVSMENU4_SEL_SONIC78object.state = 2PVSMENU4_SELECTING79PlaySfx(SfxName[Menu Move], false)80end if8182if keyPress[0].buttonB == true83if object.entityPos == 1 // If this is the P1 box84if object.state == 2PVSMENU4_WAITFORINPUT85object.timer = 086object.state = 2PVSMENU4_TOVSMENU187end if88end if89end if90break9192case 2PVSMENU4_SELECTING93arrayPos0 = object.player9495temp0 = 09697if keyPress[arrayPos0].buttonB == true98object.selection = 2PVSMENU4_SEL_NONE99object.state = 2PVSMENU4_WAITFORINPUT100else101if keyPress[arrayPos0].left == true102temp0 = 1103object.selection--104if object.selection < 2PVSMENU4_SEL_SONIC105if game.hasPlusDLC == true106object.selection = 2PVSMENU4_SEL_AMY107else108object.selection = 2PVSMENU4_SEL_KNUX109end if110end if111PlaySfx(SfxName[Menu Move], false)112end if113114if keyPress[arrayPos0].right == true115temp0 = 2116object.selection++117if game.hasPlusDLC == true118if object.selection > 2PVSMENU4_SEL_AMY119object.selection = 2PVSMENU4_SEL_SONIC120end if121else122if object.selection > 2PVSMENU4_SEL_KNUX123object.selection = 2PVSMENU4_SEL_SONIC124end if125end if126PlaySfx(SfxName[Menu Move], false)127end if128129checkResult = keyPress[arrayPos0].start130checkResult |= keyPress[arrayPos0].buttonA131if checkResult == true132object.selectionTimer = 0133PlaySfx(SfxName[Star Post], false)134object.state = 2PVSMENU4_SELECTEDPLAYER135end if136end if137138foreach (TypeName[2P VS Menu 4], arrayPos0, ACTIVE_ENTITIES)139if arrayPos0 != object.entityPos140if object[arrayPos0].state > 2PVSMENU4_SELECTING141// If both players are highlighting the same character, change it so they aren't142if object[arrayPos0].selection == object.selection143if temp0 == 1144object.selection--145if object.value1 < 2PVSMENU4_SEL_SONIC146if game.hasPlusDLC == true147object.selection = 2PVSMENU4_SEL_AMY148else149object.selection = 2PVSMENU4_SEL_KNUX150end if151end if152else153object.selection++154if game.hasPlusDLC == true155if object.selection > 2PVSMENU4_SEL_AMY156object.selection = 2PVSMENU4_SEL_SONIC157end if158else159if object.selection > 2PVSMENU4_SEL_KNUX160object.selection = 2PVSMENU4_SEL_SONIC161end if162end if163end if164end if165end if166end if167next168break169170case 2PVSMENU4_SELECTEDPLAYER171if object.selectionTimer < 32172object.selectionTimer++173else174object.timer = -256175176if object.player == 1177object.state = 2PVSMENU4_WAITFORP2178if object.selection == 2PVSMENU4_SEL_AMY179stage.playerListPos = PLAYER_AMY180else181stage.playerListPos = object.selection182stage.playerListPos--183end if184else185object.state = 2PVSMENU4_WAITFORP1186if object.selection == 2PVSMENU4_SEL_AMY187vs.player2Type = PLAYER_AMY188else189vs.player2Type = object.selection190vs.player2Type--191end if192end if193end if194break195196case 2PVSMENU4_WAITFORP1197break198199case 2PVSMENU4_WAITFORP2200checkResult = true201foreach (TypeName[2P VS Menu 4], arrayPos0, ACTIVE_ENTITIES)202if object[arrayPos0].state < 2PVSMENU4_WAITFORP1203checkResult = false204end if205next206207if checkResult == true208object.state = 2PVSMENU4_TOVSMENU3209else210arrayPos0 = object.player211if keyPress[arrayPos0].buttonB == true212object.state = 2PVSMENU4_SELECTING213PlaySfx(SfxName[Menu Back], false)214end if215end if216break217218case 2PVSMENU4_TOVSMENU3219if object.timer < 256220object.timer += 16221if object.timer > 0222SetScreenFade(0, 0, 0, object.timer)223end if224else225ResetObjectEntity(1, TypeName[2P VS Menu 3], 0, 0, 0)226object[1].priority = PRIORITY_ACTIVE227ResetObjectEntity(2, TypeName[Blank Object], 0, 0, 0)228object[0].state = 2PVSMENU3_SELECTING2292PVSMenu3[0].timer = 384230SetScreenFade(0, 0, 0, 255)231end if232break233234case 2PVSMENU4_TOVSMENU1235if object.timer < 256236object.timer += 16237SetScreenFade(0, 0, 0, object.timer)238else239ResetObjectEntity(1, TypeName[2P VS Menu 1], 0, 0, 0)240object[1].priority = PRIORITY_ACTIVE241ResetObjectEntity(2, TypeName[Blank Object], 0, 0, 0)242object[0].state = 2PVSMENU1_SELECTING2432PVSMenu1[0].timer = 384244SetScreenFade(0, 0, 0, 255)245end if246break247248end switch249end event250251252event ObjectDraw253if object.player == 1254// For the main object, draw the "Player Select" text at the top of the screen255DrawSpriteScreenXY(0, screen.xcenter, 17)256DrawSpriteScreenXY(1, screen.xcenter, 17)257end if258259// Draw the Selection Box260// (This little bit of math is to make the selection box flash a little, after the character's been selected)261temp0 = object.selectionTimer262temp0 >>= 2263temp0 &= 1264temp0 += 2265DrawSpriteScreenXY(temp0, screen.xcenter, object.ypos)266267switch object.selection268case 2PVSMENU4_SEL_NONE269DrawSpriteScreenXY(11, screen.xcenter, object.ypos) // "Wating for"270temp0 = 11271temp0 += object.player272DrawSpriteScreenXY(temp0, screen.xcenter, object.ypos) // Either "P1" or "P2"273break274275case 2PVSMENU4_SEL_SONIC276DrawSpriteScreenXY(4, screen.xcenter, object.ypos)277break278279case 2PVSMENU4_SEL_TAILS280DrawSpriteScreenXY(5, screen.xcenter, object.ypos)281break282283case 2PVSMENU4_SEL_KNUX284DrawSpriteScreenXY(6, screen.xcenter, object.ypos)285break286287case 2PVSMENU4_SEL_AMY288DrawSpriteScreenXY(14, screen.xcenter, object.ypos)289break290end switch291292if object.state == 2PVSMENU4_SELECTING293arrayPos0 = object.player294295if keyDown[arrayPos0].left == true296DrawSpriteScreenXY(8, screen.xcenter, object.ypos)297else298DrawSpriteScreenXY(7, screen.xcenter, object.ypos)299end if300301if keyDown[arrayPos0].right == true302DrawSpriteScreenXY(10, screen.xcenter, object.ypos)303else304DrawSpriteScreenXY(9, screen.xcenter, object.ypos)305end if306end if307end event308309310event ObjectStartup311LoadSpriteSheet("LevelSelect/Icons.gif")312SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0313SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1314SpriteFrame(-32, -32, 64, 64, 98, 249) // Details Border - #2315SpriteFrame(-32, -32, 64, 64, 163, 249) // Details Border (Selected) - #3316SpriteFrame(-12, -20, 24, 40, 1, 279) // Sonic - #4317SpriteFrame(-16, -20, 32, 40, 54, 279) // Tails - #5318SpriteFrame(-14, -20, 27, 40, 26, 279) // Knuckles - #6319SpriteFrame(-56, -10, 20, 20, 138, 22) // Left Arrow - #7320SpriteFrame(-56, -10, 20, 20, 138, 64) // Right Arrow - #8321SpriteFrame(36, -10, 20, 20, 159, 22) // Left Arrow (Pressed) - #9322SpriteFrame(36, -10, 20, 20, 159, 64) // Right Arrow (Pressed) - #10323SpriteFrame(-28, -16, 56, 15, 44, 362) // WAITING FOR - #11324SpriteFrame(-8, 8, 16, 7, 218, 124) // 1P - #12325SpriteFrame(-8, 8, 16, 7, 218, 132) // 2P - #13326SpriteFrame(-10, -15, 21, 35, 1, 453) // Amy - #14327328// It still checks for 2P VS Menu 2 LOL329// (This object is never placed in a scene anyway, so this bit of code doesn't really matter)330foreach (TypeName[2P VS Menu 2], arrayPos0, ALL_ENTITIES)331object[arrayPos0].priority = PRIORITY_ACTIVE332next333end event334335336// ========================337// Editor Events338// ========================339340event RSDKDraw341DrawSprite(0)342DrawSprite(1)343end event344345346event RSDKLoad347LoadSpriteSheet("LevelSelect/Icons.gif")348SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0349SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1350351// Although used by the object, it's not to be set from the editor352SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")353end event354355356