Path: blob/master/Sonic 1/Scripts/LZ/SecretPlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Moving Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// the script is called "SecretPlatform" but the game refers to it as "MovingPlatform"8// we're using the latter name here910// ========================11// Aliases12// ========================1314private alias object.value0 : object.collisionOffset.x1516private alias 0 : MOVINGPLATFORM_HIDDEN17private alias 1 : MOVINGPLATFORM_AWAITPLAYER18private alias 2 : MOVINGPLATFORM_MOVING_RIGHT19private alias 3 : MOVINGPLATFORM_FALLING20private alias 4 : MOVINGPLATFORM_STOPPED2122// Player Aliases23private alias object.xpos : player.xpos24private alias object.ypos : player.ypos25private alias object.gravity : player.gravity2627// Push Button Aliases28private alias object.value0 : pushButton.stood2930// Path ID Aliases31private alias 0 : PATH_A3233// Achievement Aliases34private alias 5 : ACHIEVEMENT_SECRETOFLZ353637// ========================38// Function Declarations39// ========================4041reserve function MovingBlock_DebugDraw42reserve function MovingBlock_DebugSpawn434445// ========================46// Function Definitions47// ========================4849private function MovingBlock_DebugDraw50DrawSprite(0)51end function525354private function MovingBlock_DebugSpawn55CreateTempObject(TypeName[Moving Block], 0, object.xpos, object.ypos)56object[tempObjectPos].priority = PRIORITY_XBOUNDS57object[tempObjectPos].state = MOVINGPLATFORM_AWAITPLAYER58end function596061// ========================62// Events63// ========================6465event ObjectUpdate66switch object.state67case MOVINGPLATFORM_HIDDEN68if pushButton[+2].stood == true69object.state++70end if71break7273case MOVINGPLATFORM_AWAITPLAYER74foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)75BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)76if checkResult == COL_TOP77object.state++78if stage.debugMode == false79if currentPlayer == 080// Grant the "Secret of Labyrinth Zone" Achievement81CallNativeFunction2(SetAchievement, ACHIEVEMENT_SECRETOFLZ, 100)82end if83end if84end if85next86break8788case MOVINGPLATFORM_MOVING_RIGHT89temp0 = object.xpos90temp0 &= 0xFFFF000091object.xpos += 0x100009293ObjectTileCollision(CSIDE_LWALL, 16, 0, PATH_A)94if checkResult == true95object.state++96end if9798object.collisionOffset.x = object.xpos99object.collisionOffset.x &= 0xFFFF0000100object.collisionOffset.x -= temp0101temp1 = object.xpos102object.xpos = temp0103104foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)105BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)106if checkResult == COL_TOP107player[currentPlayer].xpos += object.collisionOffset.x108end if109next110111object.xpos = temp1112break113114case MOVINGPLATFORM_FALLING115temp0 = object.ypos116temp0 &= 0xFFFF0000117object.ypos += object.yvel118object.yvel += 0x3800119120ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)121if checkResult == true122object.state++123object.priority = PRIORITY_BOUNDS124end if125126object.collisionOffset.x = object.ypos127object.collisionOffset.x &= 0xFFFF0000128object.collisionOffset.x -= temp0129temp1 = object.ypos130object.ypos = temp0131foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)132BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)133if checkResult == COL_TOP134player[currentPlayer].ypos += object.collisionOffset.x135end if136137if player[currentPlayer].gravity == GRAVITY_GROUND138if checkResult == COL_BOTTOM139CallFunction(Player_Kill)140end if141end if142next143object.ypos = temp1144break145146case MOVINGPLATFORM_STOPPED147foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)148BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)149next150break151152end switch153end event154155156event ObjectDraw157if object.state > MOVINGPLATFORM_HIDDEN158DrawSprite(0)159end if160end event161162163event ObjectStartup164LoadSpriteSheet("LZ/Objects.gif")165SpriteFrame(-16, -8, 32, 16, 1, 1)166167foreach (TypeName[Moving Block], arrayPos0, ALL_ENTITIES)168object[arrayPos0].priority = PRIORITY_XBOUNDS169next170171SetTableValue(TypeName[Moving Block], DebugMode_ObjCount, DebugMode_TypesTable)172SetTableValue(MovingBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)173SetTableValue(MovingBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)174DebugMode_ObjCount++175end event176177178// ========================179// Editor Events180// ========================181182event RSDKDraw183DrawSprite(0)184end event185186187event RSDKLoad188LoadSpriteSheet("LZ/Objects.gif")189SpriteFrame(-16, -8, 32, 16, 1, 1)190191SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")192end event193194195