Path: blob/master/Sonic 2/Scripts/Global/Monitor.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Monitor Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.contentsPos.y12private alias object.value1 : object.timer13private alias object.value3 : object.rewardPlayer14private alias object.value31 : object.altContents1516// Monitor type aliases17private alias 0 : MONITOR_BLANK18private alias 1 : MONITOR_RINGS19private alias 2 : MONITOR_SHIELD_BLUE20private alias 3 : MONITOR_INVINCIBILITY21private alias 4 : MONITOR_SPEEDSHOES22private alias 5 : MONITOR_1UP_SONIC23private alias 6 : MONITOR_1UP_TAILS24private alias 7 : MONITOR_1UP_KNUX25private alias 8 : MONITOR_SUPER26private alias 9 : MONITOR_SHIELD_BUBBLE27private alias 10 : MONITOR_SHIELD_FIRE28private alias 11 : MONITOR_SHIELD_LIGHTNING29private alias 12 : MONITOR_EGGMAN30private alias 13 : MONITOR_TELEPORT31private alias 14 : MONITOR_RANDOM32private alias 15 : MONITOR_DEBUG_SHIELD33private alias 16 : MONITOR_DEBUG_EMERALDS34private alias 17 : MONITOR_1UP_AMY // Origins exclusive3536private alias 16 : MONITOR_COUNT3738// Monitor states39private alias 0 : MONITOR_STATE_IDLE40private alias 1 : MONITOR_STATE_FALL4142// Broken monitor states43private alias 0 : MONITOR_STATE_RISE4445// Player Aliases46private alias object.state : player.state47private alias object.controlMode : player.controlMode48private alias object.propertyValue : player.character49private alias object.yvel : player.yvel50private alias object.gravity : player.gravity51private alias object.animation : player.animation52private alias object.value16 : player.isSidekick53private alias object.value17 : debugMode.currentSelection54private alias object.value25 : player.gravityStrength55private alias object.value40 : player.hitboxLeft56private alias object.value38 : player.hitboxTop57private alias object.value41 : player.hitboxRight58private alias object.value39 : player.hitboxBottom5960// Game Modes61private alias 2 : MODE_TIMEATTACK6263// Shield Types Aliases64private alias 0 : SHIELDTYPE_S265private alias 1 : SHIELDTYPE_S366private alias 2 : SHIELDTYPE_RAND_S267private alias 3 : SHIELDTYPE_RAND_S36869// Item Mode Aliases70private alias 0 : ITEMMODE_NOPREFERENCE71private alias 1 : ITEMMODE_RANDOM72private alias 2 : ITEMMODE_TELEPORTONLY73private alias 3 : ITEMMODE_FIXED7475// Path ID Aliases76private alias 0 : PATH_A777879// ========================80// Function Declarations81// ========================8283reserve function Monitor_DebugDraw84reserve function Monitor_DebugSpawn858687// ========================88// Static Values89// ========================9091private value Monitor_startDebugID = 0929394// ========================95// Tables96// ========================9798// This variant uses S2 shields only99private table Monitor_randTypesTable_S21001 // MONITOR_RINGS1012 // MONITOR_SHIELD_BLUE1023 // MONITOR_INVINCIBILITY1034 // MONITOR_SPEEDSHOES1045 // MONITOR_1UP_SONIC10512 // MONITOR_EGGMAN10613 // MONITOR_TELEPORT1071 // MONITOR_RINGS1082 // MONITOR_SHIELD_BLUE1091 // MONITOR_RINGS110end table111112// This table uses S3 shields as well!113private table Monitor_randTypesTable_S31141 // MONITOR_RINGS1152 // MONITOR_SHIELD_BLUE1163 // MONITOR_INVINCIBILITY1174 // MONITOR_SPEEDSHOES1185 // MONITOR_1UP_SONIC1199 // MONITOR_SHIELD_BUBBLE12010 // MONITOR_SHIELD_FIRE12111 // MONITOR_SHIELD_LIGHTNING12212 // MONITOR_EGGMAN12313 // MONITOR_TELEPORT124end table125126127// ========================128// Function Definitions129// ========================130131private function Monitor_DebugDraw132DrawSprite(0)133134temp0 = debugMode[0].currentSelection135temp0 -= Monitor_startDebugID136if temp0 == MONITOR_1UP_SONIC137#platform: USE_STANDALONE138temp0 += stage.playerListPos139#endplatform140#platform: USE_ORIGINS141// Since Amy's monitor ID isn't with the other characters, just force her icon to show up if we're playing as her142// (Not sure why they bothered since you can't spawn life monitors in Origins but whatever)143if stage.playerListPos != PLAYER_AMY144temp0 += stage.playerListPos145else146temp0 = 19147end if148#endplatform149else150if temp0 > MONITOR_1UP_SONIC151temp0 += 2152end if153end if154155temp0 += 2156DrawSprite(temp0)157end function158159160private function Monitor_DebugSpawn161temp0 = debugMode[0].currentSelection162temp0 -= Monitor_startDebugID163if temp0 == MONITOR_1UP_SONIC164#platform: USE_STANDALONE165temp0 += stage.playerListPos166#endplatform167#platform: USE_ORIGINS168// Since Amy's monitor ID isn't with the other characters, just force her icon to show up if we're playing as her169// (Not sure why they bothered since you can't spawn life monitors in Origins but whatever)170if stage.playerListPos != PLAYER_AMY171temp0 += stage.playerListPos172else173temp0 = 19174end if175#endplatform176else177if temp0 > MONITOR_1UP_SONIC178temp0 += 2179end if180end if181182CreateTempObject(TypeName[Monitor], temp0, object.xpos, object.ypos)183object[tempObjectPos].frame = object[tempObjectPos].propertyValue184object[tempObjectPos].frame += 2185end function186187188// ========================189// Events190// ========================191192event ObjectUpdate193if object.state == MONITOR_STATE_FALL194object.yvel += 0x3800195object.ypos += object.yvel196if object.yvel >= 0197ObjectTileCollision(CSIDE_FLOOR, 0, 16, PATH_A)198if checkResult == true199object.yvel = 0200object.state = MONITOR_STATE_IDLE201end if202end if203end if204205foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)206CheckGreater(player[currentPlayer].yvel, -1)207temp0 = checkResult208CheckEqual(player[currentPlayer].gravity, GRAVITY_GROUND)209temp0 |= checkResult210if temp0 == true211CheckEqual(player[currentPlayer].animation, ANI_JUMPING)212temp0 = checkResult213CheckEqual(player[currentPlayer].animation, ANI_GLIDING)214temp0 |= checkResult215CheckEqual(player[currentPlayer].animation, ANI_GLIDING_STOP)216temp0 |= checkResult217#platform: USE_ORIGINS218CheckEqual(player[currentPlayer].animation, ANI_HAMMER_JUMP)219temp0 |= checkResult220CheckEqual(player[currentPlayer].animation, ANI_HAMMER_DASH)221temp0 |= checkResult222#endplatform223if temp0 == true224if player[currentPlayer].isSidekick == false225BoxCollisionTest(C_TOUCH, object.entityPos, -16, -14, 16, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)226if checkResult == true227object.state = MONITOR_STATE_RISE228CreateTempObject(TypeName[Smoke Puff], 0, object.xpos, object.ypos)229object[tempObjectPos].drawOrder = 4230player[currentPlayer].yvel += player[currentPlayer].gravityStrength231player[currentPlayer].yvel += player[currentPlayer].gravityStrength232FlipSign(player[currentPlayer].yvel)233234object.type = TypeName[Broken Monitor]235object.rewardPlayer = currentPlayer236if object.priority != PRIORITY_XBOUNDS_DESTROY237object.priority = PRIORITY_ACTIVE238end if239240object.alpha = 0xFF241object.contentsPos.y = object.ypos242object.timer = -0x30000243if object.propertyValue == MONITOR_RANDOM244vs.randomValue *= 1103515245245vs.randomValue += 12345246vs.randomValue &= 0x7FFFFFFF247temp0 = vs.randomValue248temp0 >>= 16249temp0 %= 10250251if options.vsMode == true252if player[currentPlayer].character == PLAYER_SONIC_A // only let Sonic have access to the elemental shields, they're useless to all other chars anyway253GetTableValue(object.propertyValue, temp0, Monitor_randTypesTable_S3)254else255GetTableValue(object.propertyValue, temp0, Monitor_randTypesTable_S2)256end if257258if object.propertyValue == MONITOR_TELEPORT259// If we have a Teleport monitor but either of the characters aren't ready to be teleported at the moment, then260// just transform the monitor into a more generic reward instead261262if player[0].controlMode == CONTROLMODE_NONE263object.propertyValue = MONITOR_SHIELD_BLUE264end if265266if player[1].controlMode == CONTROLMODE_NONE267object.propertyValue = MONITOR_SHIELD_BLUE268end if269270if player[0].state == Player_State_Static271object.propertyValue = MONITOR_RINGS272end if273274if player[1].state == Player_State_Static275object.propertyValue = MONITOR_RINGS276end if277end if278else279if options.shieldType == SHIELDTYPE_RAND_S3280GetTableValue(object.propertyValue, temp0, Monitor_randTypesTable_S3)281else282GetTableValue(object.propertyValue, temp0, Monitor_randTypesTable_S2)283end if284285if object.propertyValue == MONITOR_TELEPORT286object.propertyValue = MONITOR_RINGS287end if288end if289end if290291if options.vsMode == true292if vs.playerID == 0293if currentPlayer == 0294vs.items1P++295else296vs.items2P++297end if298else299if currentPlayer == 1300vs.items1P++301else302vs.items2P++303end if304end if305end if306307PlaySfx(SfxName[Destroy], false)308end if309else310BoxCollisionTest(C_SOLID, object.entityPos, -15, -14, 15, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)311end if312else313BoxCollisionTest(C_SOLID, object.entityPos, -15, -14, 15, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)314end if315else316BoxCollisionTest(C_SOLID, object.entityPos, -15, -16, 15, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)317if checkResult == COL_BOTTOM318object.state = MONITOR_STATE_FALL319object.yvel = -0x20000320player[currentPlayer].yvel = 0x20000321end if322end if323next324end event325326327event ObjectDraw328DrawSprite(0)329330switch StageSetup_monitorOverlayFrame331case 0332case 1333break334335case 6336case 7337DrawSprite(1)338break339340case 12341case 13342DrawSprite(2)343break344345default346DrawSprite(object.frame)347break348end switch349end event350351352event ObjectStartup353LoadSpriteSheet("Global/Items.gif")354SpriteFrame(-16, -16, 32, 32, 18, 1) // 0 - Base monitor sprite355SpriteFrame(-8, -9, 16, 14, 18, 51) // 1 - Static 1356SpriteFrame(-8, -9, 16, 14, 35, 51) // 2 - Static 2357SpriteFrame(-8, -9, 16, 14, 18, 66) // 3 - MONITOR_RINGS358SpriteFrame(-8, -9, 16, 14, 35, 66) // 4 - MONITOR_SHIELD_BLUE359SpriteFrame(-8, -9, 16, 14, 18, 81) // 5 - MONITOR_INVINCIBILITY360SpriteFrame(-8, -9, 16, 14, 35, 81) // 6 - MONITOR_SPEEDSHOES361362// Amy's monitor icon is at the end of the list363#platform: USE_ORIGINS364if game.coinMode == false365#endplatform366SpriteFrame(-8, -9, 16, 14, 18, 96) // 7 - MONITOR_1UP_SONIC367SpriteFrame(-8, -9, 16, 14, 35, 96) // 8 - MONITOR_1UP_TAILS368SpriteFrame(-8, -9, 16, 14, 18, 111) // 9 - MONITOR_1UP_KNUX369#platform: USE_ORIGINS370else371SpriteFrame(-8, -9, 16, 14, 35, 186) // 7 - MONITOR_1UP_SONIC (Coin)372SpriteFrame(-8, -9, 16, 14, 35, 186) // 8 - MONITOR_1UP_TAILS (Coin but again)373SpriteFrame(-8, -9, 16, 14, 35, 186) // 9 - MONITOR_1UP_KNUX (Coin but yet again)374end if375#endplatform376377SpriteFrame(-8, -9, 16, 14, 35, 111) // 10 - MONITOR_SUPER378SpriteFrame(-8, -9, 16, 14, 18, 141) // 11 - MONITOR_SHIELD_BUBBLE379SpriteFrame(-8, -9, 16, 14, 35, 126) // 12 - MONITOR_SHIELD_FIRE380SpriteFrame(-8, -9, 16, 14, 18, 126) // 13 - MONITOR_SHIELD_LIGHTNING381SpriteFrame(-8, -9, 16, 14, 35, 141) // 14 - MONITOR_EGGMAN382SpriteFrame(-8, -9, 16, 14, 18, 156) // 15 - MONITOR_TELEPORT383SpriteFrame(-8, -9, 16, 14, 35, 156) // 16 - MONITOR_RANDOM384SpriteFrame(-8, -9, 16, 14, 18, 171) // 17 - MONITOR_DEBUG_SHIELD385SpriteFrame(-8, -9, 16, 14, 35, 171) // 18 - MONITOR_DEBUG_EMERALDS386#platform: USE_ORIGINS387if game.coinMode == false388SpriteFrame(-8, -9, 16, 14, 18, 201) // 19 - MONITOR_1UP_AMY389else390SpriteFrame(-8, -9, 16, 14, 35, 186) // 19 - MONITOR_1UP_AMY (The long awaited return of Coin)391end if392#endplatform393394// (The Mania monitor in the Origins version's spritesheet is unused btw)395396Monitor_startDebugID = DebugMode_ObjCount397Monitor_startDebugID--398temp0 = MONITOR_BLANK399while temp0 < MONITOR_COUNT400temp2 = true401// Amy's monitor type isn't added here, instead the debug mode functions force it in when playing as her402if temp0 >= MONITOR_1UP_SONIC403if temp0 <= MONITOR_1UP_KNUX404temp1 = temp0405temp1 -= MONITOR_1UP_SONIC406if stage.playerListPos != temp1407temp2 = false408end if409end if410end if411412if temp2 == true413SetTableValue(TypeName[Monitor], DebugMode_ObjCount, DebugMode_TypesTable)414SetTableValue(Monitor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)415SetTableValue(Monitor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)416DebugMode_ObjCount++417end if418temp0++419loop420421foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)422object[arrayPos0].altContents = object[arrayPos0].propertyValue423object[arrayPos0].altContents >>= 4424object[arrayPos0].propertyValue &= 15425next426427// Turn all 1UP monitors into the icons of the appropriate character428if stage.playerListPos == PLAYER_TAILS_A429foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)430if object[arrayPos0].propertyValue == MONITOR_1UP_SONIC431object[arrayPos0].propertyValue = MONITOR_1UP_TAILS432end if433next434end if435436if stage.playerListPos == PLAYER_KNUCKLES_A437foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)438if object[arrayPos0].propertyValue == MONITOR_1UP_SONIC439object[arrayPos0].propertyValue = MONITOR_1UP_KNUX440end if441next442end if443444#platform: USE_ORIGINS445if stage.playerListPos == PLAYER_AMY446foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)447if object[arrayPos0].propertyValue == MONITOR_1UP_SONIC448object[arrayPos0].propertyValue = MONITOR_1UP_AMY449end if450next451end if452#endplatform453454// Only 1 life in Time Attack, remove all 1UP monitors455if options.gameMode == MODE_TIMEATTACK456foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)457if object[arrayPos0].propertyValue == MONITOR_1UP_SONIC458object[arrayPos0].type = TypeName[Blank Object]459end if460next461end if462463if options.vsMode == true464// Set up the monitors for VS mode465switch vs.itemMode466case ITEMMODE_RANDOM467foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)468object[arrayPos0].propertyValue = MONITOR_RANDOM469next470break471472case ITEMMODE_TELEPORTONLY473foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)474object[arrayPos0].propertyValue = MONITOR_TELEPORT475next476break477478// (nothing will happen for ITEMMODE_NOPREFERENCE and ITEMMODE_FIXED, since the monitors should be left alone)479480end switch481else482// Set up the shield monitors483if options.shieldType > SHIELDTYPE_S3484foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)485object[arrayPos0].propertyValue = MONITOR_RANDOM486next487else488if options.shieldType == SHIELDTYPE_S2489foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)490if object[arrayPos0].propertyValue >= MONITOR_SHIELD_BUBBLE491if object[arrayPos0].propertyValue <= MONITOR_SHIELD_LIGHTNING492if object[arrayPos0].altContents == MONITOR_BLANK493object[arrayPos0].type = TypeName[Blank Object]494else495object[arrayPos0].propertyValue = object[arrayPos0].altContents496end if497end if498end if499next500end if501end if502end if503504foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)505object[arrayPos0].frame = object[arrayPos0].propertyValue506object[arrayPos0].frame += 2507next508end event509510511// ========================512// Editor Events513// ========================514515event RSDKEdit516if editor.returnVariable == true517switch editor.variableID518case EDIT_VAR_PROPVAL // property value519checkResult = object.propertyValue520break521522case 0 // contents523checkResult = object.propertyValue524checkResult &= 0xF525break526527case 1 // altContents528checkResult = object.propertyValue529checkResult >>= 4530checkResult &= 0xF531break532533end switch534else535switch editor.variableID536case EDIT_VAR_PROPVAL // property value537object.propertyValue = editor.variableValue538break539540case 0 // contents541temp0 = editor.variableValue542temp0 &= 0xF543object.propertyValue &= 0xF0544object.propertyValue |= temp0545break546547case 1 // altContents548temp0 = editor.variableValue549temp0 &= 0xF550temp0 <<= 4551object.propertyValue &= 0xF552object.propertyValue |= temp0553break554end switch555end if556end event557558559event RSDKDraw560object.frame = object.propertyValue561object.frame &= 0xF562563DrawSprite(0)564DrawSprite(object.frame)565end event566567568event RSDKLoad569LoadSpriteSheet("Global/Items.gif")570SpriteFrame(-16, -16, 32, 32, 18, 1) // 0 - Base monitor sprite571SpriteFrame(-8, -9, 16, 14, 18, 66) // 1 - MONITOR_RINGS572SpriteFrame(-8, -9, 16, 14, 35, 66) // 2 - MONITOR_SHIELD_BLUE573SpriteFrame(-8, -9, 16, 14, 18, 81) // 3 - MONITOR_INVINCIBILITY574SpriteFrame(-8, -9, 16, 14, 35, 81) // 4 - MONITOR_SPEEDSHOES575SpriteFrame(-8, -9, 16, 14, 18, 96) // 5 - MONITOR_1UP_SONIC576SpriteFrame(-8, -9, 16, 14, 35, 96) // 6 - MONITOR_1UP_TAILS577SpriteFrame(-8, -9, 16, 14, 18, 111) // 7 - MONITOR_1UP_KNUX578SpriteFrame(-8, -9, 16, 14, 35, 111) // 8 - MONITOR_SUPER579SpriteFrame(-8, -9, 16, 14, 18, 141) // 9 - MONITOR_SHIELD_BUBBLE580SpriteFrame(-8, -9, 16, 14, 35, 126) // 10 - MONITOR_SHIELD_FIRE581SpriteFrame(-8, -9, 16, 14, 18, 126) // 11 - MONITOR_SHIELD_LIGHTNING582SpriteFrame(-8, -9, 16, 14, 35, 141) // 12 - MONITOR_EGGMAN583SpriteFrame(-8, -9, 16, 14, 18, 156) // 13 - MONITOR_TELEPORT584SpriteFrame(-8, -9, 16, 14, 35, 156) // 14 - MONITOR_RANDOM585SpriteFrame(-8, -9, 16, 14, 18, 171) // 15 - MONITOR_DEBUG_SHIELD586SpriteFrame(-8, -9, 16, 14, 35, 171) // 16 - MONITOR_DEBUG_EMERALDS587SpriteFrame(-8, -9, 16, 14, 18, 201) // 17 - MONITOR_1UP_AMY588589AddEditorVariable("contents")590SetActiveVariable("contents")591AddEnumVariable("None", MONITOR_BLANK)592AddEnumVariable("10 Rings", MONITOR_RINGS)593AddEnumVariable("Blue Shield", MONITOR_SHIELD_BLUE)594AddEnumVariable("Invincibility", MONITOR_INVINCIBILITY)595AddEnumVariable("Speed Shoes", MONITOR_SPEEDSHOES)596AddEnumVariable("1UP (Sonic)", MONITOR_1UP_SONIC)597AddEnumVariable("1UP (Tails)", MONITOR_1UP_TAILS)598AddEnumVariable("1UP (Knux)", MONITOR_1UP_KNUX)599AddEnumVariable("Super", MONITOR_SUPER)600AddEnumVariable("Bubble Shield", MONITOR_SHIELD_BUBBLE)601AddEnumVariable("Fire Shield", MONITOR_SHIELD_FIRE)602AddEnumVariable("Lightning Shield", MONITOR_SHIELD_LIGHTNING)603AddEnumVariable("Eggman", MONITOR_EGGMAN)604AddEnumVariable("Teleport", MONITOR_TELEPORT)605AddEnumVariable("Random", MONITOR_RANDOM)606AddEnumVariable("Shields Toggle", MONITOR_DEBUG_SHIELD)607608AddEditorVariable("altContents")609SetActiveVariable("altContents")610AddEnumVariable("None", MONITOR_BLANK)611AddEnumVariable("10 Rings", MONITOR_RINGS)612AddEnumVariable("Blue Shield", MONITOR_SHIELD_BLUE)613AddEnumVariable("Invincibility", MONITOR_INVINCIBILITY)614AddEnumVariable("Speed Shoes", MONITOR_SPEEDSHOES)615AddEnumVariable("1UP (Sonic)", MONITOR_1UP_SONIC)616AddEnumVariable("1UP (Tails)", MONITOR_1UP_TAILS)617AddEnumVariable("1UP (Knux)", MONITOR_1UP_KNUX)618AddEnumVariable("Super", MONITOR_SUPER)619AddEnumVariable("Bubble Shield", MONITOR_SHIELD_BUBBLE)620AddEnumVariable("Fire Shield", MONITOR_SHIELD_FIRE)621AddEnumVariable("Lightning Shield", MONITOR_SHIELD_LIGHTNING)622AddEnumVariable("Eggman", MONITOR_EGGMAN)623AddEnumVariable("Teleport", MONITOR_TELEPORT)624AddEnumVariable("Random", MONITOR_RANDOM)625AddEnumVariable("Shields Toggle", MONITOR_DEBUG_SHIELD)626end event627628629