Path: blob/master/Sonic 1/Scripts/MZ/ButtonPillar.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Button Pillar 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.startPos.y13private alias object.value2 : object.shinePos.y1415private alias 0 : BUTTONPILLAR_AWAITBUTTON16private alias 1 : BUTTONPILLAR_MOVING17private alias 2 : BUTTONPILLAR_MOVED1819// Player Aliases20private alias object.ypos : player.ypos2122// PushButton aliases23private alias object.propertyValue : pushButton.stood2425// ========================26// Function Declarations27// ========================2829reserve function ButtonPillar_DebugDraw30reserve function ButtonPillar_DebugSpawn313233private function ButtonPillar_DebugDraw34DrawSprite(0)35end function363738private function ButtonPillar_DebugSpawn39CreateTempObject(TypeName[Button Pillar], 0, object.xpos, object.ypos)40object[tempObjectPos].startPos.y = object.ypos41end function424344// ========================45// Events46// ========================4748event ObjectUpdate49switch object.state50case BUTTONPILLAR_AWAITBUTTON51if pushButton[-1].stood == true52object.state = BUTTONPILLAR_MOVING53object.priority = PRIORITY_ACTIVE54end if55foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)56BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)57next58break5960case BUTTONPILLAR_MOVING61if object.timer < 14462object.timer += 263foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)64BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)65if checkResult == COL_TOP66player[currentPlayer].ypos += 0x2000067end if68next69object.ypos += 0x2000070else71foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)72BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)73next74object.state++75end if76break7778case BUTTONPILLAR_MOVED79foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)80BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)81next82break8384end switch8586object.angle = oscillation87object.angle <<= 188Sin(object.shinePos.y, object.angle)89object.shinePos.y <<= 1290object.shinePos.y += object.ypos91object.shinePos.y &= 0xFFFF00009293if object.outOfBounds == true94temp0 = object.ypos95object.ypos = object.startPos.y96if object.outOfBounds == true97object.priority = PRIORITY_BOUNDS98object.state = BUTTONPILLAR_AWAITBUTTON99object.timer = 0100else101object.ypos = temp0102end if103end if104end event105106107event ObjectDraw108DrawSprite(0)109DrawSpriteXY(1, object.xpos, object.shinePos.y)110end event111112113event ObjectStartup114LoadSpriteSheet("MZ/Objects.gif")115SpriteFrame(-32, -56, 64, 112, 126, 1)116SpriteFrame(-16, -16, 31, 32, 159, 114)117118foreach (TypeName[Button Pillar], arrayPos0, ALL_ENTITIES)119object[arrayPos0].startPos.y = object[arrayPos0].ypos120next121122SetTableValue(TypeName[Button Pillar], DebugMode_ObjCount, DebugMode_TypesTable)123SetTableValue(ButtonPillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)124SetTableValue(ButtonPillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)125DebugMode_ObjCount++126end event127128129// ========================130// Editor Events131// ========================132133event RSDKDraw134DrawSprite(0)135DrawSprite(1)136137if editor.showGizmos == true138editor.drawingOverlay = true139140// Draw an arrow to link it to its activator button141DrawArrow(object.xpos, object.ypos, object[-1].xpos, object[-1].ypos, 255, 255, 255)142143// Draw a preview of where the pillar will end up144temp0 = object.ixpos145temp0 -= 32146temp1 = 2147temp1 *= 144148temp1 += object.iypos149temp1 -= 56150DrawRectOutline(temp0, temp1, 64, 112, 255, 255, 255, 255)151// object.inkEffect = INK_BLEND152// DrawSpriteFX(0, FX_INK, object.xpos, temp1)153// DrawSpriteFX(1, FX_INK, object.xpos, temp1)154155editor.drawingOverlay = false156end if157end event158159160event RSDKLoad161LoadSpriteSheet("MZ/Objects.gif")162SpriteFrame(-32, -56, 64, 112, 126, 1)163SpriteFrame(-16, -16, 31, 32, 159, 114)164165SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")166end event167168169