Path: blob/master/Sonic 2/Scripts/2PVS/VSGame.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: VS Game Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// This object isn't only used for managing 2PVS things, but also for the (2013, not Origins) Boss Rush too89// ========================10// Aliases11// ========================1213private alias object.value0 : object.timer14private alias object.value1 : object.storedPosP1.x15private alias object.value2 : object.storedPosP1.y16private alias object.value3 : object.storedPosP2.x17private alias object.value4 : object.storedPosP2.y18private alias object.value5 : object.countdownPlayer19private alias object.value6 : object.countdownTimer20private alias object.value7 : object.waterSlotID2122// States23private alias 0 : VSGAME_DISPLAYTAGS24private alias 1 : VSGAME_TELEPORT25private alias 2 : VSGAME_FADEOUT26private alias 3 : VSGAME_FINISH_COUNTDOWN27private alias 4 : VSGAME_GOTOVSRESULTS28private alias 5 : VSGAME_BOSSATTACK_FADEIN29private alias 6 : VSGAME_BOSSATTACK_END30private alias 7 : VSGAME_SCREENFADE3132// Water Aliases33private alias object.value1 : object.constBubbleTimer3435// Player Aliases36private alias object.type : player.type37private alias object.state : player.state38private alias object.xpos : player.xpos39private alias object.ypos : player.ypos40private alias object.ixpos : player.ixpos41private alias object.iypos : player.iypos42private alias object.xvel : player.xvel43private alias object.yvel : player.yvel44private alias object.speed : player.speed45private alias object.gravity : player.gravity46private alias object.visible : player.visible47private alias object.collisionPlane : player.collisionPlane48private alias object.propertyValue : player.character49private alias object.value0 : player.rings50private alias object.value1 : player.timer51private alias object.value4 : player.drownLevel52private alias object.value6 : player.speedShoesTimer53private alias object.value7 : player.invincibleTimer54private alias object.value18 : player.sortedDrawOrder55private alias object.value37 : player.shield5657// Super States58private alias 1 : SUPERSTATE_SUPER5960// Shields61private alias 1 : SHIELD_NORMAL6263// Reserved Object Slots64private alias 0 : SLOT_PLAYER165private alias 1 : SLOT_PLAYER266private alias 30 : SLOT_VSGAME676869// ========================70// Events71// ========================7273event ObjectUpdate74switch object.state75case VSGAME_DISPLAYTAGS76if vs.playerID == 077if oscillation == 50078// Sync the two player's randomValue so that the same random events happen between them79CallNativeFunction2(TransmitGlobal, "vs.randomValue", vs.randomValue)80end if81end if8283if player[SLOT_PLAYER1].state != Player_State_Static84object.storedPosP1.x = player[SLOT_PLAYER1].xpos85object.storedPosP1.y = player[SLOT_PLAYER1].ypos86end if8788if player[SLOT_PLAYER2].state != Player_State_Static89object.storedPosP2.x = player[SLOT_PLAYER2].xpos90object.storedPosP2.y = player[SLOT_PLAYER2].ypos91end if92break9394case VSGAME_TELEPORT95if object.timer < 38496object.timer += 169798if player[SLOT_PLAYER1].state == Player_State_Static99object.state = VSGAME_FADEOUT100#platform: USE_ORIGINS101else102if player[SLOT_PLAYER1].state == Player_State_Death103object.state = VSGAME_FADEOUT104end if105#endplatform106107end if108109if player[SLOT_PLAYER2].state == Player_State_Static110object.state = VSGAME_FADEOUT111#platform: USE_ORIGINS112else113if player[SLOT_PLAYER2].state == Player_State_Death114object.state = VSGAME_FADEOUT115end if116#endplatform117end if118else119object.state = VSGAME_FADEOUT120if player[SLOT_PLAYER2].type != TypeName[Blank Object]121#platform: USE_STANDALONE122player[SLOT_PLAYER1].state = Player_State_Air123#endplatform124#platform: USE_ORIGINS125player[SLOT_PLAYER1].state = Player_State_Air_NoDropDash126#endplatform127player[SLOT_PLAYER1].xpos = object[SLOT_VSGAME].storedPosP2.x128player[SLOT_PLAYER1].ypos = object[SLOT_VSGAME].storedPosP2.y129130#platform: USE_STANDALONE131player[SLOT_PLAYER2].state = Player_State_Air132#endplatform133#platform: USE_ORIGINS134player[SLOT_PLAYER2].state = Player_State_Air_NoDropDash135#endplatform136player[SLOT_PLAYER2].xpos = object[SLOT_VSGAME].storedPosP1.x137player[SLOT_PLAYER2].ypos = object[SLOT_VSGAME].storedPosP1.y138#platform: USE_ORIGINS139camera[0].xpos = player[SLOT_PLAYER1].ixpos140camera[0].ypos = player[SLOT_PLAYER1].iypos141camera[1].xpos = player[SLOT_PLAYER2].ixpos142camera[1].ypos = player[SLOT_PLAYER2].iypos143#endplatform144#platform: USE_STANDALONE145screen.cameraX = player[SLOT_PLAYER1].ixpos146screen.cameraY = player[SLOT_PLAYER1].iypos147#endplatform148149temp0 = player[SLOT_PLAYER1].collisionPlane150player[SLOT_PLAYER1].collisionPlane = player[SLOT_PLAYER2].collisionPlane151player[SLOT_PLAYER2].collisionPlane = temp0152153temp0 = player[SLOT_PLAYER1].shield154player[SLOT_PLAYER1].shield = player[SLOT_PLAYER2].shield155player[SLOT_PLAYER2].shield = temp0156157#platform: USE_ORIGINS158if object[SLOT_VSGAME].waterSlotID != 0159arrayPos0 = 0160arrayPos1 = 0161162CheckNotEqual(player[SLOT_PLAYER1].drownLevel, 0)163temp0 = checkResult164CheckEqual(player[SLOT_PLAYER2].drownLevel, 0)165checkResult &= temp0166if checkResult != false167arrayPos0 = 0168arrayPos1 = 1169end if170171CheckEqual(player[SLOT_PLAYER1].drownLevel, 0)172temp0 = checkResult173CheckNotEqual(player[SLOT_PLAYER2].drownLevel, 0)174checkResult &= temp0175if checkResult != false176arrayPos0 = 1177arrayPos1 = 0178end if179180if arrayPos0 != arrayPos1181player[arrayPos0].drownLevel = 0182currentPlayer = arrayPos0183CallFunction(BrokenMonitor_ResetDrownMusic)184player[arrayPos0].yvel <<= 1185if player[arrayPos0].yvel < -0x100000186player[arrayPos0].yvel = -0x100000187end if188189if player[arrayPos0].state == Player_State_Fly190if player[arrayPos0].timer < 480191PlaySfx(SfxName[Flying], true)192else193PlaySfx(SfxName[Jump], true)194end if195end if196197if player[arrayPos1].yvel > 0198player[arrayPos1].yvel >>= 2199end if200201if player[arrayPos1].state == Player_State_Fly202StopSfx(SfxName[Flying])203StopSfx(SfxName[Jump])204end if205206player[arrayPos1].xvel >>= 1207player[arrayPos1].speed >>= 1208arrayPos0 = object.waterSlotID209arrayPos0 += 0 // the world would crumble if this wasn't here210object[arrayPos0].constBubbleTimer = 52211arrayPos0++212object[arrayPos0].constBubbleTimer = 52213end if214end if215#endplatform216217arrayPos0 = 0218arrayPos0 += playerCount219temp0 = object[arrayPos0].type220221// Normally players shouldn't be Super in 2PVS, but if they are then just make them have some invincibility222if Player_superState == SUPERSTATE_SUPER223temp0 = invincibilityType224player[SLOT_PLAYER1].invincibleTimer = 1260225end if226227arrayPos1 = 1228arrayPos1 += playerCount229temp1 = object[arrayPos1].type230if temp0 == temp1231if temp0 != invincibilityType232currentPlayer = 0233CallFunction(Player_ApplyShield)234currentPlayer = 1235arrayPos0 = arrayPos1236CallFunction(Player_ApplyShield)237else238temp0 = player[SLOT_PLAYER1].invincibleTimer239player[SLOT_PLAYER1].invincibleTimer = player[SLOT_PLAYER2].invincibleTimer240player[SLOT_PLAYER2].invincibleTimer = temp0241end if242else243if temp0 == invincibilityType244currentPlayer = 0245CallFunction(Player_ApplyShield)246ResetObjectEntity(arrayPos1, invincibilityType, 0, player[SLOT_PLAYER2].xpos, player[SLOT_PLAYER2].ypos)247object[arrayPos1].priority = PRIORITY_ACTIVE248249temp0 = player[SLOT_PLAYER1].invincibleTimer250player[SLOT_PLAYER1].invincibleTimer = player[SLOT_PLAYER2].invincibleTimer251player[SLOT_PLAYER2].invincibleTimer = temp0252else253if temp1 == invincibilityType254ResetObjectEntity(arrayPos0, invincibilityType, 0, player[SLOT_PLAYER1].xpos, player[SLOT_PLAYER1].ypos)255object[arrayPos0].priority = PRIORITY_ACTIVE256currentPlayer = 1257arrayPos0 = arrayPos1258CallFunction(Player_ApplyShield)259260temp0 = player[SLOT_PLAYER1].invincibleTimer261player[SLOT_PLAYER1].invincibleTimer = player[SLOT_PLAYER2].invincibleTimer262player[SLOT_PLAYER2].invincibleTimer = temp0263else264currentPlayer = 0265CallFunction(Player_ApplyShield)266currentPlayer = 1267arrayPos0 = arrayPos1268CallFunction(Player_ApplyShield)269end if270end if271end if272273temp0 = player[SLOT_PLAYER1].speedShoesTimer274player[SLOT_PLAYER1].speedShoesTimer = player[SLOT_PLAYER2].speedShoesTimer275player[SLOT_PLAYER2].speedShoesTimer = temp0276277#platform: USE_ORIGINS278temp0 = player[SLOT_PLAYER1].sortedDrawOrder279player[SLOT_PLAYER1].sortedDrawOrder = player[SLOT_PLAYER2].sortedDrawOrder280player[SLOT_PLAYER2].sortedDrawOrder = temp0281#endplatform282283currentPlayer = 0284CallFunction(Player_UpdatePhysicsState)285currentPlayer = 1286CallFunction(Player_UpdatePhysicsState)287288foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)289switch player[currentPlayer].character290case PLAYER_TAILS_A291case PLAYER_KNUCKLES_A292if player[currentPlayer].shield > SHIELD_NORMAL293player[currentPlayer].shield = SHIELD_NORMAL294arrayPos0 = currentPlayer295arrayPos0 += playerCount296if object[arrayPos0].type != invincibilityType297CallFunction(Player_ApplyShield)298end if299end if300// no break, but who cares301end switch302next303end if304end if305SetScreenFade(208, 255, 224, object.timer)306break307308case VSGAME_FADEOUT309if object.timer > 0310object.timer -= 16311else312object.type = TypeName[Blank Object]313end if314SetScreenFade(208, 255, 224, object.timer)315break316317case VSGAME_FINISH_COUNTDOWN318#platform: USE_STANDALONE319if object.countdownTimer > 0320object.timer++321if object.timer == 60322object.timer = 0323object.countdownTimer--324if object.countdownTimer == 0325currentPlayer = object.countdownPlayer326if player[currentPlayer].state != Player_State_Death327if player[currentPlayer].type != TypeName[Death Event]328#endplatform329#platform: USE_ORIGINS330currentPlayer = object.countdownPlayer331if player[currentPlayer].state != Player_State_Death332if player[currentPlayer].type != TypeName[Death Event]333if object.countdownTimer > 0334object.timer++335if object.timer == 60336object.timer = 0337object.countdownTimer--338if object.countdownTimer == 0339340#endplatform341342if currentPlayer == 0343if vs.playerID == 0344temp2 = 0345else346temp2 = 1347end if348else349if vs.playerID == 0350temp2 = 1351else352temp2 = 0353end if354end if355356if temp2 == 0357vs.time1P = stage.seconds358vs.time1P *= 100359temp2 = stage.minutes360temp2 *= 6000361vs.time1P += temp2362vs.time1P += stage.milliSeconds363else364vs.time2P = stage.seconds365vs.time2P *= 100366temp2 = stage.minutes367temp2 *= 6000368vs.time2P += temp2369vs.time2P += stage.milliSeconds370end if371372stage.timeOver = true373#platform: USE_ORIGINS374stage.timeEnabled = false375#endplatform376CallFunction(Player_Kill)377end if378end if379end if380end if381end if382break383384case VSGAME_GOTOVSRESULTS385if object.timer < 384386object.timer += 16387else388if vs.playerID == 0389vs.rings1P = player[SLOT_PLAYER1].rings390vs.rings2P = player[SLOT_PLAYER2].rings391else392vs.rings1P = player[SLOT_PLAYER2].rings393vs.rings2P = player[SLOT_PLAYER1].rings394end if395stage.activeList = PRESENTATION_STAGE396stage.listPos = 3397LoadStage()398end if399400if object.timer > 0401SetScreenFade(0, 0, 0, object.timer)402end if403break404405case VSGAME_BOSSATTACK_FADEIN406if object.timer == 320407player[SLOT_PLAYER1].rings = vs.rings1P408player[SLOT_PLAYER1].speed = vs.speed409player[SLOT_PLAYER1].xvel = vs.speed410player[SLOT_PLAYER1].yvel = 0411player[SLOT_PLAYER1].gravity = GRAVITY_GROUND412player[SLOT_PLAYER1].shield = vs.items1P413temp0 = currentPlayer414temp1 = arrayPos0415currentPlayer = 0416arrayPos0 = playerCount417arrayPos0 += currentPlayer418CallFunction(Player_ApplyShield)419currentPlayer = temp0420arrayPos0 = temp1421temp0 = vs.time1P422temp0 /= 6000423stage.minutes = temp0424temp0 = vs.time1P425temp0 /= 100426temp0 %= 60427stage.seconds = temp0428temp0 = vs.time1P429temp0 %= 100430stage.milliSeconds = temp0431TitleCard_showZoneText = true // (The EHZ Boss Rush file already has this set btw)432end if433434if object.timer < 256435stage.state = STAGE_RUNNING436stage.timeEnabled = true437player[SLOT_PLAYER1].visible = true438else439if stage.listPos == 2 // CPZ (Boss Rush)440player[SLOT_PLAYER1].ypos = object.ypos441end if442end if443444if object.timer > 0445object.timer -= 16446else447object.type = TypeName[Blank Object]448end if449450SetScreenFade(0, 0, 0, object.timer)451break452453case VSGAME_BOSSATTACK_END454if object.timer > -1455if object.timer < 320456object.timer += 16457else458vs.rings1P = player[SLOT_PLAYER1].rings459vs.time1P = stage.seconds460vs.time1P *= 100461temp2 = stage.minutes462temp2 *= 6000463vs.time1P += temp2464vs.time1P += stage.milliSeconds465vs.items1P = player[SLOT_PLAYER1].shield466vs.speed = player[SLOT_PLAYER1].speed467stage.listPos++468LoadStage()469end if470471SetScreenFade(0, 0, 0, object.timer)472else473if player[SLOT_PLAYER1].xpos > object.xpos474object.timer = 0475end if476end if477break478479#platform: USE_ORIGINS480case VSGAME_SCREENFADE481object.drawOrder = 6482483if object.timer > 0484object.timer -= 16485else486object.type = TypeName[Blank Object]487end if488break489#endplatform490end switch491end event492493494event ObjectDraw495switch object.state496case VSGAME_DISPLAYTAGS497#platform: USE_STANDALONE498temp0 = vs.playerID499temp0 ^= 1500DrawSpriteXY(temp0, player[SLOT_PLAYER2].xpos, player[SLOT_PLAYER2].ypos)501#endplatform502503#platform: USE_ORIGINS504currentPlayer = screen.currentID505currentPlayer ^= 1506if game.playMode == BOOT_PLAYMODE_MIRRORING507object.direction = FLIP_X508DrawSpriteFX(currentPlayer, FX_FLIP, player[currentPlayer].xpos, player[currentPlayer].ypos)509else510DrawSpriteXY(currentPlayer, player[currentPlayer].xpos, player[currentPlayer].ypos)511end if512#endplatform513break514515case VSGAME_FINISH_COUNTDOWN516#platform: USE_STANDALONE517temp0 = vs.playerID518temp0 ^= 1519DrawSpriteXY(temp0, player[SLOT_PLAYER2].xpos, player[SLOT_PLAYER2].ypos)520521temp0 = object.countdownTimer522temp0 /= 10523temp0 += 2524temp1 = screen.xcenter525temp1 -= 8526DrawSpriteScreenXY(temp0, temp1, 13)527528temp0 = object.countdownTimer529temp0 %= 10530temp0 += 2531temp1 += 8532DrawSpriteScreenXY(temp0, temp1, 13)533#endplatform534535#platform: USE_ORIGINS536currentPlayer = screen.currentID537currentPlayer ^= 1538if game.playMode == BOOT_PLAYMODE_MIRRORING539object.direction = FLIP_X540DrawSpriteFX(currentPlayer, FX_FLIP, player[currentPlayer].xpos, player[currentPlayer].ypos)541else542DrawSpriteXY(currentPlayer, player[currentPlayer].xpos, player[currentPlayer].ypos)543end if544545if screen.currentID == object.countdownPlayer546temp0 = object.countdownTimer547temp0 /= 10548temp0 += 2549temp1 = object.countdownTimer550temp1 %= 10551temp1 += 2552temp2 = screen.xcenter553temp2 -= 8554temp2 += 8555556if game.playMode == BOOT_PLAYMODE_MIRRORING557object.direction = FLIP_X558DrawSpriteScreenFX(temp1, FX_FLIP, temp2, 13)559temp2 += 8560DrawSpriteScreenFX(temp0, FX_FLIP, temp2, 13)561else562DrawSpriteScreenXY(temp0, temp2, 13)563temp2 += 8564DrawSpriteScreenXY(temp1, temp2, 13)565end if566end if567#endplatform568break569570case VSGAME_BOSSATTACK_FADEIN571if object.timer > 256572DrawRect(0, 0, screen.xsize, screen.ysize, 0x00, 0x00, 0x00, 0xFF)573end if574break575576#platform: USE_ORIGINS577case VSGAME_SCREENFADE578if object.propertyValue == screen.currentID579DrawRect(0, 0, screen.xsize, screen.ysize, 208, 255, 224, object.timer)580end if581break582#endplatform583end switch584end event585586587event ObjectStartup588LoadSpriteSheet("Global/Display.gif")589SpriteFrame(-8, -32, 16, 7, 103, 48) // 1P - #0590SpriteFrame(-8, -32, 16, 7, 103, 56) // 2P - #1591592SpriteFrame(0, 0, 8, 11, 1, 50) // 0 - #2593SpriteFrame(0, 0, 8, 11, 10, 50) // 1 - #3594SpriteFrame(0, 0, 8, 11, 19, 50) // 2 - #4595SpriteFrame(0, 0, 8, 11, 28, 50) // 3 - #5596SpriteFrame(0, 0, 8, 11, 1, 62) // 4 - #6597SpriteFrame(0, 0, 8, 11, 10, 62) // 5 - #7598SpriteFrame(0, 0, 8, 11, 19, 62) // 6 - #8599SpriteFrame(0, 0, 8, 11, 28, 62) // 7 - #9600SpriteFrame(0, 0, 8, 11, 1, 74) // 8 - #10601SpriteFrame(0, 0, 8, 11, 10, 74) // 9 - #11602603temp0 = false604foreach (TypeName[VS Game], arrayPos0, ALL_ENTITIES)605switch object[arrayPos0].propertyValue606case 1 // Boss Attack (Start)607object[arrayPos0].state = VSGAME_BOSSATTACK_FADEIN608object[arrayPos0].timer = 320609object[arrayPos0].priority = PRIORITY_ALWAYS610object[arrayPos0].drawOrder = 6611player[SLOT_PLAYER1].visible = false612stage.state = STAGE_PAUSED613temp0++614break615616case 2 // Boss Attack (End)617object[arrayPos0].state = VSGAME_BOSSATTACK_END618object[arrayPos0].timer = -1619object[arrayPos0].priority = PRIORITY_XBOUNDS620temp0++621break622623default624object[arrayPos0].type = TypeName[Blank Object]625break626end switch627next628629if temp0 == false630vs.bossAttack = false631end if632633if options.vsMode == true634object[SLOT_VSGAME].type = TypeName[VS Game]635object[SLOT_VSGAME].priority = PRIORITY_ACTIVE636object[SLOT_VSGAME].drawOrder = 5637object[SLOT_VSGAME].countdownTimer = 60638end if639end event640641642// ========================643// Editor Events644// ========================645646event RSDKEdit647if editor.returnVariable == true648switch editor.variableID649case EDIT_VAR_PROPVAL // property value650checkResult = object.propertyValue651break652653case 0 // type654checkResult = object.propertyValue655break656657end switch658else659switch editor.variableID660case EDIT_VAR_PROPVAL // property value661object.propertyValue = editor.variableValue662break663664case 0 // type665object.propertyValue = editor.variableValue666break667668end switch669end if670end event671672673event RSDKDraw674DrawSprite(0)675end event676677678event RSDKLoad679LoadSpriteSheet("Global/Display.gif")680SpriteFrame(-8, -32, 16, 7, 103, 56)681682AddEditorVariable("type")683SetActiveVariable("type")684// type 0 isn't to be placed in a level685AddEnumVariable("Boss Attack (Start)", 1)686AddEnumVariable("Boss Attack (End)", 2)687end event688689690