Path: blob/master/Sonic 2/Scripts/CPZ/Staircase.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// 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.blockMovePos1314private alias 0 : STAIRCASE_015private alias 1 : STAIRCASE_116private alias 2 : STAIRCASE_217private alias 3 : STAIRCASE_318private alias 4 : STAIRCASE_STATIC1920// Player Aliases21private alias object.ypos : player.ypos22private alias object.gravity : player.gravity2324private alias object.value17 : debugMode.currentSelection252627// ========================28// Function Declarations29// ========================3031reserve function Staircase_DebugDraw32reserve function Staircase_DebugSpawn333435// ========================36// Static Values37// ========================3839private value Staircase_startDebugID = 0404142// ========================43// Function Definitions44// ========================4546private function Staircase_DebugDraw47DrawSprite(0)48end function495051private function Staircase_DebugSpawn52CreateTempObject(TypeName[Staircase], 0, object.xpos, object.ypos)53GetBit(object[tempObjectPos].direction, object.direction, 0)54object[tempObjectPos].propertyValue = debugMode[0].currentSelection55object[tempObjectPos].propertyValue -= Staircase_startDebugID56end function575859// ========================60// Events61// ========================6263event ObjectUpdate64object.priority = PRIORITY_ACTIVE65switch object.state66case STAIRCASE_067foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)68BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)69if checkResult == COL_TOP70object.priority = PRIORITY_ACTIVE71object.timer = 3272object.state++73end if74next75break7677case STAIRCASE_178foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)79BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)80next8182object.timer--83if object.timer < 084object.timer = 12885object.state++86end if87break8889case STAIRCASE_290temp0 = object.xpos91temp1 = object.ypos9293if object.direction == FLIP_NONE94object.xpos += 0x60000095temp4 = -0x20000096else97temp4 = 0x20000098end if99100temp5 = object.blockMovePos101temp2 = 1102while temp2 < 5103object.ypos += temp5104foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)105BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)106if checkResult == COL_TOP107temp6 = object.ypos108temp6 &= 0xFFFF0000109if object.propertyValue == 0110temp7 = 0x4000111else112temp7 = -0x4000113end if114temp7 *= temp2115temp7 += object.ypos116temp7 &= 0xFFFF0000117temp7 -= temp6118player[currentPlayer].ypos += temp7119end if120121if player[currentPlayer].gravity == GRAVITY_GROUND122if checkResult == COL_BOTTOM123if object.propertyValue == 0124CallFunction(Player_Kill)125end if126end if127end if128next129object.xpos += temp4130temp2++131loop132133if object.propertyValue == 0134object.blockMovePos += 0x4000135else136object.blockMovePos -= 0x4000137end if138139object.xpos = temp0140object.ypos = temp1141object.timer--142if object.timer <= 0143object.state++144end if145break146147case STAIRCASE_3148temp0 = object.xpos149temp1 = object.ypos150if object.direction == FLIP_NONE151object.xpos += 0x600000152temp4 = -0x200000153else154temp4 = 0x200000155end if156157temp5 = object.blockMovePos158temp2 = 1159while temp2 < 5160object.ypos += temp5161foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)162BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)163if player[currentPlayer].gravity == GRAVITY_GROUND164if checkResult == COL_BOTTOM165CallFunction(Player_Kill)166end if167end if168next169object.xpos += temp4170temp2++171loop172173object.xpos = temp0174object.ypos = temp1175break176177case STAIRCASE_STATIC178break179180end switch181182#platform: USE_STANDALONE183temp1 = 0184temp0 = camera[0].xpos185temp0 -= object.ixpos186Abs(temp0)187temp0 -= 192188if temp0 >= screen.xcenter189temp1 = true190end if191192temp0 = camera[0].ypos193temp0 -= object.iypos194Abs(temp0)195temp0 -= 192196if temp0 >= screen.ycenter197temp1 = true198end if199200if temp1 == true201object.priority = PRIORITY_BOUNDS202object.state = STAIRCASE_0203object.blockMovePos = 0204if object.propertyValue == 2205object.state = STAIRCASE_STATIC206end if207end if208#endplatform209210#platform: USE_ORIGINS211temp0 = screen.xcenter212temp0 += 192213temp1 = screen.ycenter214temp1 += 192215CheckCameraProximity(object.ixpos, object.iypos, temp0, temp1)216if checkResult == false217object.priority = PRIORITY_BOUNDS218object.state = STAIRCASE_0219object.blockMovePos = 0220if object.propertyValue == 2221object.state = STAIRCASE_STATIC222end if223end if224#endplatform225end event226227228event ObjectDraw229switch object.state230case STAIRCASE_0231case STAIRCASE_1232DrawSprite(0)233break234235case STAIRCASE_2236case STAIRCASE_3237temp2 = object.xpos238temp3 = object.ypos239if object.direction == FLIP_NONE240temp2 += 0x600000241temp4 = -0x200000242else243temp4 = 0x200000244end if245246temp5 = object.blockMovePos247temp3 += temp5248DrawSpriteXY(1, temp2, temp3)249250temp2 += temp4251temp3 += temp5252DrawSpriteXY(1, temp2, temp3)253254temp2 += temp4255temp3 += temp5256DrawSpriteXY(1, temp2, temp3)257258temp2 += temp4259temp3 += temp5260DrawSpriteXY(1, temp2, temp3)261break262263case STAIRCASE_STATIC264break265266end switch267end event268269270event ObjectStartup271LoadSpriteSheet("CPZ/Objects3.gif")272SpriteFrame(-16, -16, 128, 32, 1, 62)273SpriteFrame(-16, -16, 32, 32, 1, 62)274275foreach (TypeName[Staircase], arrayPos0, ALL_ENTITIES)276if object[arrayPos0].propertyValue == 2277object[arrayPos0].state = STAIRCASE_STATIC278end if279next280281temp0 = 0282Staircase_startDebugID = DebugMode_ObjCount283while temp0 < 2284SetTableValue(TypeName[Staircase], DebugMode_ObjCount, DebugMode_TypesTable)285SetTableValue(Staircase_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)286SetTableValue(Staircase_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)287DebugMode_ObjCount++288temp0++289loop290end event291292293// ========================294// Editor Events295// ========================296297event RSDKEdit298if editor.returnVariable == true299switch editor.variableID300case EDIT_VAR_PROPVAL // property value301checkResult = object.propertyValue302break303304case 0 // type305checkResult = object.propertyValue306checkResult &= 7307break308309end switch310else311switch editor.variableID312case EDIT_VAR_PROPVAL // property value313object.propertyValue = editor.variableValue314break315316case 0 // type317object.propertyValue = editor.variableValue318object.propertyValue &= 7319break320321end switch322end if323end event324325326event RSDKDraw327DrawSprite(0)328end event329330331event RSDKLoad332LoadSpriteSheet("CPZ/Objects3.gif")333SpriteFrame(-16, -16, 128, 32, 1, 62)334335AddEditorVariable("type")336SetActiveVariable("type")337AddEnumVariable("Extend Downwards", 0)338AddEnumVariable("Extend Upwards", 4) // idk why its 4, 1 also works but whatever floats your boat ig339AddEnumVariable("Static", 2)340end event341342343