Path: blob/master/Sonic 2/Scripts/Mission/SCZMSetup.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: SCZSetup Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// This script is mostly just a copy of the standard [SCZ Setup] object, just with a few changes for Mission Mode8// Changes are marked throughout the script910// Everything here is still labelled under `SCZSetup` since only the script path is different - the object name is still the same (beyond removing the space for some reason)1112// ========================13// Aliases14// ========================1516private alias object.value0 : object.timer17private alias object.value1 : object.palRotateTimer18private alias object.value2 : object.palRotateIndex1920private alias -1 : SCZSETUP_STATIC21private alias 0 : SCZSETUP_FORWARD22private alias 1 : SCZSETUP_WINGFORTRESS23private alias 2 : SCZSETUP_GIVECHASE24private alias 3 : SCZSETUP_TOWINGFORTRESS25private alias 4 : SCZSETUP_FADEOUT26private alias 5 : SCZSETUP_RESULTS2728// Player Aliases29private alias object.xpos : player.xpos30private alias object.xvel : player.xvel31private alias object.yvel : player.yvel32private alias object.speed : player.speed33private alias object.gravity : player.gravity34private alias object.controlMode : player.controlMode35private alias object.tileCollisions : player.tileCollisions36private alias object.collisionRight : player.collisionRight37private alias object.jumpPress : player.jumpPress38private alias object.jumpHold : player.jumpHold39private alias object.up : player.up40private alias object.down : player.down41private alias object.left : player.left42private alias object.right : player.right4344// Game Modes45private alias 0 : MODE_NOSAVE46private alias 1 : MODE_SAVEGAME47private alias 2 : MODE_TIMEATTACK4849// Tracks50private alias 0 : TRACK_STAGE5152// Reserved object slots53private alias 10 : SLOT_ZONESETUP5455// Music Loops56private alias 198253 : MUSIC_LOOP_SCZ575859// ========================60// Static Values61// ========================6263public value SCZSetup_scrollPos.x = 064public value SCZSetup_scrollPos.y = 065public value SCZSetup_scrollVelocity.x = 066public value SCZSetup_scrollVelocity.y = 067public value SCZSetup_hPropellerFrame = 068public value SCZSetup_hPropellerTimer = 069public value SCZSetup_vPropellerFrame = 070public value SCZSetup_vPropellerTimer = 0717273// ========================74// Tables75// ========================7677private table SCZSetup_palRotationTable780xE0E040, 0xE0A020, 0xE06000, 0xC02000790xE0E0E0, 0xE0E040, 0xE0A020, 0xE06000800xE0E040, 0xE0A020, 0xE06000, 0xC02000810xE0A020, 0xE06000, 0xC02000, 0x80200082end table838485// ========================86// Events87// ========================8889event ObjectUpdate90object.palRotateTimer++91if object.palRotateTimer == 292object.palRotateTimer = 09394GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)95SetPaletteEntry(0, 167, temp0)9697object.palRotateIndex++98object.palRotateIndex &= 1599GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)100SetPaletteEntry(0, 168, temp0)101102object.palRotateIndex++103object.palRotateIndex &= 15104GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)105SetPaletteEntry(0, 169, temp0)106107object.palRotateIndex++108object.palRotateIndex &= 15109GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)110SetPaletteEntry(0, 170, temp0)111112object.palRotateIndex++113object.palRotateIndex &= 15114end if115116// Always keep the camera moving117camera[0].style = CAMERASTYLE_FOLLOW118119player[0].gravity = GRAVITY_AIR120player[0].tileCollisions = false121122switch object.state123case SCZSETUP_FORWARD // initial flight124SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x125126temp0 = SCZSetup_scrollPos.x127temp0 >>= 16128stage.curXBoundary1 = temp0129130temp0 += screen.xsize131stage.curXBoundary2 = temp0132133if stage.curXBoundary1 >= 4480134// The first of the SCZMSetup changes, additions were made here to lock player control135// Normally, it's just `object.state++` inside here, but we skip WFZ in Missions136137player[0].controlMode = CONTROLMODE_NONE138player[0].jumpPress = false139player[0].jumpHold = false140player[0].left = false141player[0].right = true142player[0].up = false143player[0].down = false144hParallax[0].scrollSpeed = 0145146// Let's skip the Wing Fortress passby states, just end the level here147object.state = SCZSETUP_TOWINGFORTRESS148end if149break150151case SCZSETUP_WINGFORTRESS152// This whole state is unused in this Mission script, it's skipped by the above153154SCZSetup_scrollVelocity.x = -0x10000155SCZSetup_scrollVelocity.y = 0x10000156SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x157SCZSetup_scrollPos.y += SCZSetup_scrollVelocity.y158159temp0 = SCZSetup_scrollPos.x160temp0 >>= 16161stage.curXBoundary1 = temp0162163temp0 += screen.xsize164stage.curXBoundary2 = temp0165temp0 = SCZSetup_scrollPos.y166167temp0 >>= 16168stage.curYBoundary1 = temp0169170temp0 += screen.ysize171stage.curYBoundary2 = temp0172173temp0 <<= 16174stage.deathBoundary = temp0175176if stage.curYBoundary1 >= 1280177object.state++178end if179break180181case SCZSETUP_GIVECHASE182// This whole state is unused here as well183184SCZSetup_scrollVelocity.x = 0x10000185SCZSetup_scrollVelocity.y = 0186SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x187temp0 = SCZSetup_scrollPos.x188temp0 >>= 16189stage.curXBoundary1 = temp0190temp0 += screen.xsize191stage.curXBoundary2 = temp0192if stage.curXBoundary1 >= 5256193player[0].controlMode = CONTROLMODE_NONE194player[0].jumpPress = false195player[0].jumpHold = false196player[0].left = false197player[0].right = true198player[0].up = false199player[0].down = false200hParallax[0].scrollSpeed = 0201object.state++202end if203break204205case SCZSETUP_TOWINGFORTRESS // player holds right and goes off screen206207// Another SCZMSetup change, the following two lines are just here to make the player go off screen a bit faster208player[0].right = true209player[0].xpos += player[0].xvel210211SCZSetup_scrollVelocity.x = 0212temp0 = stage.curXBoundary2213temp0 -= 32214temp0 <<= 16215if player[0].xpos > temp0216object.state++217end if218break219220case SCZSETUP_FADEOUT // fade to WFZ221222// One more SCZMSetup change, they added a line here to reset player xvel223// yvel reset is already part of the normal script, it's just this xvel part that's new224player[0].xvel = 0225226player[0].yvel = 0227object.timer += 4228music.volume -= 2229230// (Right here there would be a SetScreenFade to fade the screen to black, but SCZMSetup removed it)231232if object.timer == 320233fadeColor = 0x000000234object.timer = 0235starPostID = 0236object.direction = FACING_RIGHT // this object's direction doesn't even matter, i think?237238// Almost at the end of the SCZMSetup changes, the whole standard level end routine here was replaced239// with the following three lines, making the Origins mission complete HUD pop up instead240CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_SIGNPOST, 0)241object.state++242PlayMusic(1)243end if244break245246case SCZSETUP_RESULTS247// The final SCZMSetup change, this state is new in this script248// There's not much to it, just making sure the player doesn't go flying off or anything249player[0].gravity = GRAVITY_GROUND250player[0].xpos = 0251player[0].xvel = 0252break253254end switch255256// R Boundary257if object.state < SCZSETUP_TOWINGFORTRESS258foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)259temp0 = player[currentPlayer].collisionRight260temp0 <<= 16261temp0 += player[currentPlayer].xpos262temp1 = stage.curXBoundary2263temp1 <<= 16264if temp0 > temp1265player[currentPlayer].xvel = 0266player[currentPlayer].speed = 0267player[currentPlayer].xpos = temp1268temp0 = player[currentPlayer].collisionRight269temp0 <<= 16270player[currentPlayer].xpos -= temp0271end if272next273end if274275// The Missions never fly by WFZ, but this animation code is still here anyway cuz why not276SCZSetup_hPropellerFrame = SCZSetup_hPropellerTimer277SCZSetup_hPropellerFrame >>= 1278SCZSetup_hPropellerTimer++279SCZSetup_hPropellerTimer %= 12280281SCZSetup_vPropellerFrame = SCZSetup_vPropellerTimer282SCZSetup_vPropellerFrame >>= 1283SCZSetup_vPropellerTimer++284SCZSetup_vPropellerTimer %= 6285end event286287288event ObjectStartup289SetMusicTrack("SkyChase.ogg", TRACK_STAGE, MUSIC_LOOP_SCZ)290291// Set the "inhabitants" of this zone292// I sure hope they can fly...293animalType1 = TypeName[Cucky]294animalType2 = TypeName[Tocky]295296object[SLOT_ZONESETUP].type = TypeName[SCZSetup]297object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE298299SCZSetup_scrollPos.x = screen.xcenter300SCZSetup_scrollPos.x *= -0x10000301SCZSetup_scrollPos.x += player[0].xpos302303SCZSetup_scrollPos.y = 0304305SCZSetup_scrollVelocity.x = 0x10000306SCZSetup_scrollVelocity.y = 0307308// These values are essentially unused, the WFZ flyby never happens in Missions309SCZSetup_hPropellerFrame = 0310SCZSetup_hPropellerTimer = 0311SCZSetup_vPropellerFrame = 0312SCZSetup_vPropellerTimer = 0313314stage.curYBoundary2 = 240315stage.deathBoundary = 0xF00000316hParallax[0].scrollSpeed = 0x8000317end event318319320// ========================321// Editor Events322// ========================323324event RSDKDraw325DrawSprite(0)326end event327328329event RSDKLoad330LoadSpriteSheet("Global/Display.gif")331SpriteFrame(-16, -16, 32, 32, 1, 143)332333SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")334end event335336337