Path: blob/master/Sonic 2/Scripts/SCZ/SCZSetup.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: SCZ Setup 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.palRotateTimer13private alias object.value2 : object.palRotateIndex1415private alias -1 : SCZSETUP_STATIC16private alias 0 : SCZSETUP_FORWARD17private alias 1 : SCZSETUP_WINGFORTRESS18private alias 2 : SCZSETUP_GIVECHASE19private alias 3 : SCZSETUP_TOWINGFORTRESS20private alias 4 : SCZSETUP_FADEOUT2122// Player Aliases23private alias object.xpos : player.xpos24private alias object.xvel : player.xvel25private alias object.yvel : player.yvel26private alias object.speed : player.speed27private alias object.gravity : player.gravity28private alias object.controlMode : player.controlMode29private alias object.tileCollisions : player.tileCollisions30private alias object.collisionRight : player.collisionRight31private alias object.jumpPress : player.jumpPress32private alias object.jumpHold : player.jumpHold33private alias object.up : player.up34private alias object.down : player.down35private alias object.left : player.left36private alias object.right : player.right3738private alias object.value0 : player.rings3940// Game Modes41private alias 0 : MODE_NOSAVE42private alias 1 : MODE_SAVEGAME43private alias 2 : MODE_TIMEATTACK4445// Tracks46private alias 0 : TRACK_STAGE4748// Reserved object slots49private alias 10 : SLOT_ZONESETUP5051// Music Loops52private alias 198253 : MUSIC_LOOP_SCZ535455// ========================56// Static Values57// ========================5859public value SCZSetup_scrollPos.x = 060public value SCZSetup_scrollPos.y = 061public value SCZSetup_scrollVelocity.x = 062public value SCZSetup_scrollVelocity.y = 063public value SCZSetup_hPropellerFrame = 064public value SCZSetup_hPropellerTimer = 065public value SCZSetup_vPropellerFrame = 066public value SCZSetup_vPropellerTimer = 0676869// ========================70// Tables71// ========================7273private table SCZSetup_palRotationTable740xE0E040, 0xE0A020, 0xE06000, 0xC02000750xE0E0E0, 0xE0E040, 0xE0A020, 0xE06000760xE0E040, 0xE0A020, 0xE06000, 0xC02000770xE0A020, 0xE06000, 0xC02000, 0x80200078end table798081// ========================82// Events83// ========================8485event ObjectUpdate86object.palRotateTimer++87if object.palRotateTimer == 288object.palRotateTimer = 08990GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)91SetPaletteEntry(0, 167, temp0)9293object.palRotateIndex++94object.palRotateIndex &= 1595GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)96SetPaletteEntry(0, 168, temp0)9798object.palRotateIndex++99object.palRotateIndex &= 15100GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)101SetPaletteEntry(0, 169, temp0)102103object.palRotateIndex++104object.palRotateIndex &= 15105GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)106SetPaletteEntry(0, 170, temp0)107108object.palRotateIndex++109object.palRotateIndex &= 15110end if111112// Always keep the camera moving113camera[0].style = CAMERASTYLE_FOLLOW114115player[0].gravity = GRAVITY_AIR116player[0].tileCollisions = false117118switch object.state119case SCZSETUP_FORWARD // initial flight120SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x121122temp0 = SCZSetup_scrollPos.x123temp0 >>= 16124stage.curXBoundary1 = temp0125126temp0 += screen.xsize127stage.curXBoundary2 = temp0128129if stage.curXBoundary1 >= 4480130object.state++131end if132break133134case SCZSETUP_WINGFORTRESS // see wing fortress "fly past" (we actually just move down+left LOL)135SCZSetup_scrollVelocity.x = -0x10000136SCZSetup_scrollVelocity.y = 0x10000137SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x138SCZSetup_scrollPos.y += SCZSetup_scrollVelocity.y139140temp0 = SCZSetup_scrollPos.x141temp0 >>= 16142stage.curXBoundary1 = temp0143144temp0 += screen.xsize145stage.curXBoundary2 = temp0146temp0 = SCZSetup_scrollPos.y147148temp0 >>= 16149stage.curYBoundary1 = temp0150151temp0 += screen.ysize152stage.curYBoundary2 = temp0153154temp0 <<= 16155stage.deathBoundary = temp0156157if stage.curYBoundary1 >= 1280158object.state++159end if160break161162case SCZSETUP_GIVECHASE // we saw wing fortress, continue to chase that egghead down!163SCZSetup_scrollVelocity.x = 0x10000164SCZSetup_scrollVelocity.y = 0165SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x166temp0 = SCZSetup_scrollPos.x167temp0 >>= 16168stage.curXBoundary1 = temp0169temp0 += screen.xsize170stage.curXBoundary2 = temp0171if stage.curXBoundary1 >= 5256172player[0].controlMode = CONTROLMODE_NONE173player[0].jumpPress = false174player[0].jumpHold = false175player[0].left = false176player[0].right = true177player[0].up = false178player[0].down = false179hParallax[0].scrollSpeed = 0180object.state++181end if182break183184case SCZSETUP_TOWINGFORTRESS // player holds right and goes off screen185SCZSetup_scrollVelocity.x = 0186temp0 = stage.curXBoundary2187temp0 -= 32188temp0 <<= 16189if player[0].xpos > temp0190object.state++191192#platform: USE_ORIGINS193stage.timeEnabled = false194CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)195if game.oneStageFlag != false196game.callbackResult = -1197CallNativeFunction4(NotifyCallback, NOTIFY_STAGE_RETRY, 1, stage.listPos, 0)198object.state = SCZSETUP_STATIC199end if200#endplatform201end if202break203204case SCZSETUP_FADEOUT // fade to WFZ205player[0].yvel = 0206object.timer += 4207music.volume -= 2208SetScreenFade(0, 0, 0, object.timer)209if object.timer == 320210fadeColor = 0x000000211object.timer = 0212starPostID = 0213214// This object's direction is never used, is it?215// I don't think this does anything...216object.direction = FACING_RIGHT217218stage.listPos++219220if options.gameMode == MODE_SAVEGAME221arrayPos1 = options.saveSlot222arrayPos1 <<= 3223if stage.player2Enabled == true224#platform: USE_STANDALONE225saveRAM[arrayPos1] = PLAYER_SONIC_TAILS_A226#endplatform227#platform: USE_ORIGINS228switch stage.playerListPos229case PLAYER_SONIC_A230saveRAM[arrayPos1] = PLAYER_SONIC_TAILS231break232233case PLAYER_KNUCKLES_A234saveRAM[arrayPos1] = PLAYER_KNUCKLES_TAILS235break236237case PLAYER_AMY_A238saveRAM[arrayPos1] = PLAYER_AMY_TAILS239break240end switch241#endplatform242else243saveRAM[arrayPos1] = stage.playerListPos244end if245arrayPos1++246saveRAM[arrayPos1] = player.lives247arrayPos1++248saveRAM[arrayPos1] = player.score249arrayPos1++250saveRAM[arrayPos1] = player.scoreBonus251arrayPos1++252253// Bug Details:254// This is missing the check for if your save file is already past the next act255// This means the save file's act will be overwritten to Wing Fortress Zone, even if you're on a Complete save file...256saveRAM[arrayPos1] = stage.listPos257saveRAM[arrayPos1]++258259arrayPos1++260saveRAM[arrayPos1] = specialStage.emeralds261arrayPos1++262saveRAM[arrayPos1] = specialStage.listPos263WriteSaveRAM()264end if265266// ???267// you cannot speedrun sky chase.268if options.gameMode == MODE_TIMEATTACK269timeAttack.result = stage.seconds270timeAttack.result *= 100271temp0 = stage.minutes272temp0 *= 6000273timeAttack.result += temp0274timeAttack.result += stage.milliSeconds275stage.listPos--276CallNativeFunction2(SetLeaderboard, stage.listPos, timeAttack.result)277engine.state = 8278else279temp0 = engine.trialMode280if stage.listPos >= stage.listSize281temp0 = true282end if283284if temp0 == false285#platform: USE_ORIGINS286CallNativeFunction4(NotifyCallback, NOTIFY_STATS_ENEMY, StageStatsUsabilityParam1, StageStatsUsabilityParam2, StageStatsUsabilityParam3)287CallNativeFunction2(NotifyCallback, NOTIFY_STATS_RING, player[0].rings)288temp0 = StageStatsUsabilityParam5289temp0 &= 1290temp1 = StageStatsUsabilityParam5291temp1 &= 2292temp2 = StageStatsUsabilityParam5293temp2 &= 4294CallNativeFunction4(NotifyCallback, NOTIFY_STATS_CHARA_ACTION, temp0, temp1, temp2)295CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)296StageStatsUsabilityParam1 = 0297StageStatsUsabilityParam2 = 0298StageStatsUsabilityParam3 = 0299StageStatsUsabilityParam4 = 0300StageStatsUsabilityParam5 = 0301StatsUsabilityParam1 = 0302StatsUsabilityParam2 = 0303StatsUsabilityParam3 = 0304StatsUsabilityParam4 = 0305StatsUsabilityParam5 = 0306#endplatform307308LoadStage()309else310stage.activeList = PRESENTATION_STAGE311stage.listPos = 0312LoadStage()313end if314end if315end if316break317318end switch319320// R Boundary321if object.state < SCZSETUP_TOWINGFORTRESS322foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)323temp0 = player[currentPlayer].collisionRight324temp0 <<= 16325temp0 += player[currentPlayer].xpos326temp1 = stage.curXBoundary2327temp1 <<= 16328if temp0 > temp1329player[currentPlayer].xvel = 0330player[currentPlayer].speed = 0331player[currentPlayer].xpos = temp1332temp0 = player[currentPlayer].collisionRight333temp0 <<= 16334player[currentPlayer].xpos -= temp0335end if336next337end if338339SCZSetup_hPropellerFrame = SCZSetup_hPropellerTimer340SCZSetup_hPropellerFrame >>= 1341SCZSetup_hPropellerTimer++342SCZSetup_hPropellerTimer %= 12343344SCZSetup_vPropellerFrame = SCZSetup_vPropellerTimer345SCZSetup_vPropellerFrame >>= 1346SCZSetup_vPropellerTimer++347SCZSetup_vPropellerTimer %= 6348end event349350351event ObjectStartup352SetMusicTrack("SkyChase.ogg", TRACK_STAGE, MUSIC_LOOP_SCZ)353354// Set the "inhabitants" of this zone355// I sure hope they can fly...356animalType1 = TypeName[Cucky]357animalType2 = TypeName[Tocky]358359object[SLOT_ZONESETUP].type = TypeName[SCZ Setup]360object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE361362SCZSetup_scrollPos.x = screen.xcenter363SCZSetup_scrollPos.x *= -0x10000364SCZSetup_scrollPos.x += player[0].xpos365366SCZSetup_scrollPos.y = 0367368SCZSetup_scrollVelocity.x = 0x10000369SCZSetup_scrollVelocity.y = 0370371SCZSetup_hPropellerFrame = 0372SCZSetup_hPropellerTimer = 0373SCZSetup_vPropellerFrame = 0374SCZSetup_vPropellerTimer = 0375376stage.curYBoundary2 = 240377stage.deathBoundary = 0xF00000378hParallax[0].scrollSpeed = 0x8000379end event380381382// ========================383// Editor Events384// ========================385386event RSDKDraw387DrawSprite(0)388end event389390391event RSDKLoad392LoadSpriteSheet("Global/Display.gif")393SpriteFrame(-16, -16, 32, 32, 1, 143)394395SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")396end event397398399