Path: blob/master/Sonic 2/Scripts/CPZ/RotatingStair.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Rotating Stair Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.blockPos1.x12private alias object.value1 : object.blockPos1.y13private alias object.value2 : object.blockPos2.x14private alias object.value3 : object.blockPos2.y15private alias object.value4 : object.blockPos3.x16private alias object.value5 : object.blockPos3.y17private alias object.value6 : object.blockPos4.x18private alias object.value7 : object.blockPos4.y1920// Probably unused since this object was likely based off SLZ's RotatingStair21private alias object.value8 : object.blockPos5.x22private alias object.value9 : object.blockPos5.y23private alias object.value10 : object.blockPos6.x24private alias object.value11 : object.blockPos6.y25private alias object.value12 : object.blockPos7.x26private alias object.value13 : object.blockPos7.y27private alias object.value14 : object.blockPos8.x28private alias object.value15 : object.blockPos8.y2930private alias object.value16 : object.startPos.x31private alias object.value17 : object.startPos.y3233private alias object.value20 : object.playerCollisions // Introduced in Origins Plus, stores what side of the stairs each player is touching3435// Player Aliases36private alias object.state : player.state37private alias object.xpos : player.xpos38private alias object.ypos : player.ypos39private alias object.gravity : player.gravity40private alias object.animation : player.animation4142private alias object.value1 : player.timer43private alias object.value17 : debugMode.currentSelection4445// ========================46// Function Declarations47// ========================4849reserve function RotatingStair_DebugDraw50reserve function RotatingStair_DebugSpawn51reserve function RotatingStair_ProcessBlock525354// ========================55// Static Values56// ========================5758private value RotatingStair_debugStartID = 05960// Introduced in Origins Plus61private value RotatingStair_playerSideStore = 062private value RotatingStair_playerSideStore2 = 0636465// ========================66// Function Definitions67// ========================6869private function RotatingStair_DebugDraw70temp0 = object.xpos71temp0 -= 0x3000007273temp1 = object.ypos74temp1 -= 0x3000007576temp3 = debugMode[0].currentSelection77temp3 -= RotatingStair_debugStartID7879if temp3 < 280temp2 = 081while temp2 < 482DrawSpriteXY(0, temp0, temp1)83temp0 += 0x20000084temp1 += 0x20000085temp2++86loop87else88DrawSpriteXY(0, temp0, temp1)89temp0 += 0x60000090temp1 += 0x60000091DrawSpriteXY(0, temp0, temp1)92end if93end function949596private function RotatingStair_DebugSpawn97CreateTempObject(TypeName[Rotating Stair], 0, object.xpos, object.ypos)98object[tempObjectPos].startPos.x = object.xpos99object[tempObjectPos].startPos.y = object.ypos100object[tempObjectPos].propertyValue = debugMode[0].currentSelection101object[tempObjectPos].propertyValue -= RotatingStair_debugStartID102end function103104105private function RotatingStair_ProcessBlock106temp1 = temp5107GetTableValue(temp0, temp3, StageSetup_oscillationTable)108temp0 <<= 8109if temp3 == 20110temp0 >>= 1111end if112113switch temp4114case 0115temp0 -= temp1116temp0 += object.startPos.x117temp6 = temp0118FlipSign(temp1)119temp1 += object.startPos.y120temp7 = temp1121break122123case 1124temp0 -= temp1125FlipSign(temp0)126temp0 += object.startPos.y127temp7 = temp0128temp1 += object.startPos.x129temp6 = temp1130break131132case 2133temp0 -= temp1134FlipSign(temp0)135temp0 += object.startPos.x136temp6 = temp0137temp1 += object.startPos.y138temp7 = temp1139break140141case 3142temp0 -= temp1143temp0 += object.startPos.y144temp7 = temp0145FlipSign(temp1)146temp1 += object.startPos.x147temp6 = temp1148break149end switch150151temp6 &= 0xFFFF0000152temp7 &= 0xFFFF0000153temp0 = temp6154temp0 -= object.xpos155temp1 = temp7156temp1 -= object.ypos157158foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)159BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)160switch checkResult161case COL_TOP162player[currentPlayer].xpos += temp0163player[currentPlayer].ypos += temp1164break165166case COL_LEFT167case COL_RIGHT168#platform: USE_ORIGINS169if checkResult == COL_LEFT170RotatingStair_playerSideStore = 1171RotatingStair_playerSideStore <<= currentPlayer172RotatingStair_playerSideStore <<= currentPlayer173object.playerCollisions |= RotatingStair_playerSideStore174else175RotatingStair_playerSideStore = 2176RotatingStair_playerSideStore <<= currentPlayer177RotatingStair_playerSideStore <<= currentPlayer178object.playerCollisions |= RotatingStair_playerSideStore179end if180#endplatform181182if player[currentPlayer].state == Player_State_Climb183player[currentPlayer].timer = 0184player[currentPlayer].animation = ANI_GLIDING_DROP185player[currentPlayer].state = Player_State_GlideDrop186end if187break188189case COL_BOTTOM190if player[currentPlayer].gravity == GRAVITY_GROUND191if temp1 >= 0192CallFunction(Player_Kill)193end if194end if195break196end switch197next198end function199200201// ========================202// Events203// ========================204205event ObjectUpdate206temp4 = CPZSetup_rotatingStairTimer207GetBit(temp0, object.propertyValue, 0)208if temp0 == true209temp4 ^= 1210end if211212#platform: USE_ORIGINS213object.playerCollisions = 0214#endplatform215216GetBit(temp0, object.propertyValue, 1)217if temp0 == false218temp5 = 0x100000219temp3 = 20220object.xpos = object.blockPos1.x221object.ypos = object.blockpos1.y222CallFunction(RotatingStair_ProcessBlock)223object.blockPos1.x = temp6224object.blockpos1.y = temp7225226temp4 ^= 2227object.xpos = object.blockpos2.x228object.ypos = object.blockpos2.y229CallFunction(RotatingStair_ProcessBlock)230object.blockpos2.x = temp6231object.blockpos2.y = temp7232233temp4 ^= 2234end if235236temp5 = 0x300000237temp3 = 22238object.xpos = object.blockpos3.x239object.ypos = object.blockpos3.y240CallFunction(RotatingStair_ProcessBlock)241object.blockpos3.x = temp6242object.blockpos3.y = temp7243244temp4 ^= 2245object.xpos = object.blockpos4.x246object.ypos = object.blockpos4.y247CallFunction(RotatingStair_ProcessBlock)248object.blockpos4.x = temp6249object.blockpos4.y = temp7250251temp4 ^= 2252temp5 = 0x500000253temp3 = 24254// (normally in the SLZ script block 5 would be processed right here, but CPZ staris only have 4 blocks, so..)255256object.xpos = object.startPos.x257object.ypos = object.startPos.y258259#platform: USE_ORIGINS260foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)261RotatingStair_playerSideStore2 = object.playerCollisions262RotatingStair_playerSideStore2 >>= currentPlayer263RotatingStair_playerSideStore2 >>= currentPlayer264265if RotatingStair_playerSideStore2 > 0266temp6 = player[currentPlayer].xpos267temp7 = player[currentPlayer].ypos268269ObjectTileCollision(CSIDE_LENTITY, currentPlayer, object.collisionRight, 45)270if checkResult == true271RotatingStair_playerSideStore2 |= 1272end if273274ObjectTileCollision(CSIDE_RENTITY, currentPlayer, object.collisionLeft, 45)275if checkResult == true276RotatingStair_playerSideStore2 |= 2277end if278279if RotatingStair_playerSideStore2 == 3280CallFunction(Player_Kill)281end if282283player[currentPlayer].xpos = temp6284player[currentPlayer].ypos = temp7285end if286next287#endplatform288end event289290291event ObjectDraw292GetBit(temp0, object.propertyValue, 1)293if temp0 == false294DrawSpriteXY(0, object.blockPos1.x, object.blockPos1.y)295DrawSpriteXY(0, object.blockpos2.x, object.blockpos2.y)296end if297298DrawSpriteXY(0, object.blockpos3.x, object.blockpos3.y)299DrawSpriteXY(0, object.blockpos4.x, object.blockpos4.y)300end event301302303event ObjectStartup304CheckCurrentStageFolder("Zone02")305if checkResult == true306LoadSpriteSheet("CPZ/Objects3.gif")307SpriteFrame(-16, -16, 32, 32, 1, 62)308else309LoadSpriteSheet("MBZ/Objects.gif")310SpriteFrame(-16, -16, 32, 32, 130, 829)311end if312313foreach (TypeName[Rotating Stair], arrayPos0, ALL_ENTITIES)314object[arrayPos0].startPos.x = object[arrayPos0].xpos315object[arrayPos0].startPos.y = object[arrayPos0].ypos316next317318temp0 = 0319RotatingStair_debugStartID = DebugMode_ObjCount320while temp0 < 4321SetTableValue(TypeName[Rotating Stair], DebugMode_ObjCount, DebugMode_TypesTable)322SetTableValue(RotatingStair_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)323SetTableValue(RotatingStair_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)324DebugMode_ObjCount++325temp0++326loop327end event328329330// ========================331// Editor Events332// ========================333334event RSDKEdit335if editor.returnVariable == true336switch editor.variableID337case EDIT_VAR_PROPVAL // property value338checkResult = object.propertyValue339break340341case 0 // direction342GetBit(checkResult, object.propertyValue, 0)343break344345case 1 // type346GetBit(checkResult, object.propertyValue, 1)347break348349end switch350else351switch editor.variableID352case EDIT_VAR_PROPVAL // property value353object.propertyValue = editor.variableValue354break355356case 0 // direction357CheckNotEqual(editor.variableValue, 0)358SetBit(object.propertyValue, 0, checkResult)359break360361case 1 // type362CheckNotEqual(editor.variableValue, 0)363SetBit(object.propertyValue, 1, checkResult)364break365366end switch367end if368end event369370371event RSDKDraw372temp0 = object.xpos373temp0 -= 0x300000374375temp1 = object.ypos376temp1 -= 0x300000377378if object.propertyValue < 2379temp2 = 0380while temp2 < 4381DrawSpriteXY(0, temp0, temp1)382temp0 += 0x200000383temp1 += 0x200000384temp2++385loop386else387DrawSpriteXY(0, temp0, temp1)388temp0 += 0x600000389temp1 += 0x600000390DrawSpriteXY(0, temp0, temp1)391end if392end event393394395event RSDKLoad396CheckCurrentStageFolder("Zone02")397if checkResult == true398LoadSpriteSheet("CPZ/Objects3.gif")399SpriteFrame(-16, -16, 32, 32, 1, 62)400else401LoadSpriteSheet("MBZ/Objects.gif")402SpriteFrame(-16, -16, 32, 32, 130, 829)403end if404405AddEditorVariable("direction")406SetActiveVariable("direction")407AddEnumVariable("No Flip", 0)408AddEnumVariable("Flip X", 1)409410AddEditorVariable("type")411SetActiveVariable("type")412AddEnumVariable("4 Blocks", 0)413AddEnumVariable("2 Blocks", 1)414end event415416417