Path: blob/master/Sonic 1/Scripts/SLZ/Staircase.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Staircase 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.stairPos1314private alias 0 : STAIRCASE_ACTIVATE_TOP15private alias 1 : STAIRCASE_ACTIVATING_TOP16private alias 2 : STAIRCASE_LOWERING17private alias 3 : STAIRCASE_LOWERED18private alias 4 : STAIRCASE_ACTIVATE_BOTTOM19private alias 5 : STAIRCASE_ACTIVATING_BOTTOM2021// Player Aliases22private alias object.ypos : player.ypos23private alias object.gravity : player.gravity242526// ========================27// Function Declarations28// ========================2930reserve function Staircase_DebugDraw31reserve function Staircase_DebugSpawn323334// ========================35// Function Definitions36// ========================3738private function Staircase_DebugDraw39DrawSprite(0)40end function414243private function Staircase_DebugSpawn44CreateTempObject(TypeName[Staircase], 0, object.xpos, object.ypos)45GetBit(temp0, object.direction, 0)46if temp0 == FLIP_NONE47object[tempObjectPos].direction = FLIP_NONE48else49object[tempObjectPos].direction = FLIP_X50end if51end function525354// ========================55// Events56// ========================5758event ObjectUpdate59object.priority = PRIORITY_ACTIVE60switch object.state61case STAIRCASE_ACTIVATE_TOP62foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)63BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)64if checkResult == COL_TOP65object.timer = 3266object.state++67end if68next69break7071case STAIRCASE_ACTIVATING_TOP72foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)73BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)74next7576object.timer--77if object.timer < 078object.timer = 12879object.state++80end if81break8283case STAIRCASE_LOWERING84temp0 = object.xpos85temp1 = object.ypos86if object.direction == FLIP_NONE87object.xpos += 0x60000088temp4 = -0x20000089else90temp4 = 0x20000091end if9293temp5 = object.stairPos94temp2 = 195while temp2 < 596object.ypos += temp597foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)98BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)99if checkResult == COL_TOP100temp6 = object.ypos101temp6 &= 0xFFFF0000102temp7 = 0x4000103temp7 *= temp2104temp7 += object.ypos105temp7 &= 0xFFFF0000106temp7 -= temp6107player[currentPlayer].ypos += temp7108end if109110if player[currentPlayer].gravity == 0111if checkResult == COL_BOTTOM112CallFunction(Player_Kill)113end if114end if115next116object.xpos += temp4117temp2++118loop119object.stairPos += 0x4000120object.xpos = temp0121object.ypos = temp1122123object.timer--124if object.timer <= 0125object.state++126end if127break128129case STAIRCASE_LOWERED130temp0 = object.xpos131temp1 = object.ypos132if object.direction == FLIP_NONE133object.xpos += 0x600000134temp4 = -0x200000135else136temp4 = 0x200000137end if138139temp5 = object.stairPos140temp2 = 1141while temp2 < 5142object.ypos += temp5143foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)144BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)145if player[currentPlayer].gravity == 0146if checkResult == COL_BOTTOM147CallFunction(Player_Kill)148end if149end if150next151object.xpos += temp4152temp2++153loop154object.xpos = temp0155object.ypos = temp1156break157158case STAIRCASE_ACTIVATE_BOTTOM159foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)160BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)161if checkResult == COL_BOTTOM162object.timer = 59163object.state++164end if165next166break167168case STAIRCASE_ACTIVATING_BOTTOM169foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)170BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)171next172173object.timer--174if object.timer < 0175object.timer = 128176object.state = STAIRCASE_LOWERING177end if178break179180end switch181182if object.outOfBounds == true183object.priority = PRIORITY_BOUNDS184object.state = STAIRCASE_ACTIVATE_TOP185object.stairPos = 0186if object.propertyValue == 2187object.state = STAIRCASE_ACTIVATE_BOTTOM188end if189end if190end event191192193event ObjectDraw194switch object.state195case STAIRCASE_ACTIVATE_TOP196case STAIRCASE_ACTIVATING_TOP197case STAIRCASE_ACTIVATE_BOTTOM198DrawSprite(0)199break200201case STAIRCASE_LOWERING202case STAIRCASE_LOWERED203temp2 = object.xpos204temp3 = object.ypos205if object.direction == FLIP_NONE206temp2 += 0x600000207temp4 = -0x200000208else209temp4 = 0x200000210end if211temp5 = object.stairPos212temp3 += temp5213DrawSpriteXY(1, temp2, temp3)214temp2 += temp4215temp3 += temp5216DrawSpriteXY(1, temp2, temp3)217temp2 += temp4218temp3 += temp5219DrawSpriteXY(1, temp2, temp3)220temp2 += temp4221temp3 += temp5222DrawSpriteXY(1, temp2, temp3)223break224225case STAIRCASE_ACTIVATING_BOTTOM226temp2 = object.xpos227if object.direction == FLIP_NONE228temp2 += 0x600000229temp4 = -0x200000230else231temp4 = 0x200000232end if233234GetBit(temp5, object.timer, 2)235temp5 <<= 16236temp6 = 0237while temp6 < 4238temp3 = object.ypos239temp3 += temp5240temp5 ^= 0x10000241DrawSpriteXY(1, temp2, temp3)242temp2 += temp4243temp6++244loop245break246247end switch248end event249250251event ObjectStartup252LoadSpriteSheet("SLZ/Objects.gif")253SpriteFrame(-16, -16, 128, 32, 67, 26)254SpriteFrame(-16, -16, 32, 32, 67, 26)255foreach (TypeName[Staircase], arrayPos0, ALL_ENTITIES)256if object[arrayPos0].propertyValue == 2257object[arrayPos0].state = STAIRCASE_ACTIVATE_BOTTOM258end if259next260SetTableValue(TypeName[Staircase], DebugMode_ObjCount, DebugMode_TypesTable)261SetTableValue(Staircase_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)262SetTableValue(Staircase_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)263DebugMode_ObjCount++264end event265266267// ========================268// Editor Events269// ========================270271event RSDKEdit272if editor.returnVariable == true273switch editor.variableID274case EDIT_VAR_PROPVAL // property value275checkResult = object.propertyValue276checkResult &= 3277break278279case 0 // type280checkResult = object.propertyValue281break282283end switch284else285switch editor.variableID286case EDIT_VAR_PROPVAL // property value287object.propertyValue = editor.variableValue288object.propertyValue &= 3289break290291case 0 // type292object.propertyValue = editor.variableValue293break294295end switch296end if297end event298299300event RSDKDraw301if editor.showGizmos == true302editor.drawingOverlay = true303304// Draw the activated Staircase305306object.inkEffect = INK_BLEND307temp2 = object.xpos308temp3 = object.ypos309if object.direction == FLIP_NONE310temp2 += 0x600000311temp4 = -0x200000312else313temp4 = 0x200000314end if315316temp5 = 0x200000317temp3 += temp5318DrawSpriteFX(1, FX_INK, temp2, temp3)319temp2 += temp4320temp3 += temp5321DrawSpriteFX(1, FX_INK, temp2, temp3)322temp2 += temp4323temp3 += temp5324DrawSpriteFX(1, FX_INK, temp2, temp3)325temp2 += temp4326temp3 += temp5327DrawSpriteFX(1, FX_INK, temp2, temp3)328329editor.drawingOverlay = false330end if331332// The Staircase's unactivated position333object.inkEffect = INK_NONE334DrawSprite(0)335end event336337338event RSDKLoad339LoadSpriteSheet("SLZ/Objects.gif")340SpriteFrame(-16, -16, 128, 32, 67, 26)341SpriteFrame(-16, -16, 32, 32, 67, 26)342343AddEditorVariable("type")344SetActiveVariable("type")345AddEnumVariable("Activate From Top", 0)346// 1 goes unused, it was prolly for directions before it was migrated to just object.direction directly347AddEnumVariable("Activate From Bottom", 2)348end event349350351