Path: blob/master/Sonic 1/Scripts/LZ/PushButton.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Push Button Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.stood1213// Player Aliases14private alias object.ypos : player.ypos15private alias object.yvel : player.yvel16private alias object.gravity : player.gravity17private alias object.collisionBottom : player.collisionBottom181920// ========================21// Function Declarations22// ========================2324reserve function PushButton_DebugDraw25reserve function PushButton_DebugSpawn262728// ========================29// Function Definitions30// ========================3132private function PushButton_DebugDraw33DrawSprite(0)34end function353637private function PushButton_DebugSpawn38CreateTempObject(TypeName[Push Button], 0, object.xpos, object.ypos)39end function404142// ========================43// Events44// ========================4546event ObjectUpdate47object.stood = false48foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)49if object.frame == 050BoxCollisionTest(C_SOLID, object.entityPos, -14, -4, 14, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)51if checkResult == COL_TOP52object.stood = true53player[currentPlayer].ypos += 40000054PlaySfx(SfxName[Button Press], false)5556switch object.propertyValue57default58case 0 // Generic, up to the other [+1] object to change59break6061case 1 // Open LZ3 Path62// Uses hardcoded tile positions :(63GetTileLayerEntry(temp0, 0, 12, 5)64if temp0 == 30265PlaySfx(SfxName[Large Wall], false)66SetTileLayerEntry(30, 0, 12, 5)67SetTileLayerEntry(31, 0, 13, 5)68end if69break7071case 2 // Unused72break7374case 3 // Set Belt Dir75LZSetup_beltdirection = FACING_LEFT76break7778end switch79end if80else81if player[currentPlayer].yvel >= 082BoxCollisionTest(C_PLATFORM, object.entityPos, -14, -4, 14, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)83if checkResult == true84object.stood = true85player[currentPlayer].ypos += 0x2000086else87BoxCollisionTest(C_TOUCH, object.entityPos, -20, -12, 20, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)88if checkResult == true89player[currentPlayer].ypos = player[currentPlayer].collisionBottom90FlipSign(player[currentPlayer].ypos)91player[currentPlayer].ypos <<= 1692player[currentPlayer].ypos += object.ypos93player[currentPlayer].ypos -= 0x2000094player[currentPlayer].gravity = GRAVITY_AIR95end if96end if97end if98end if99next100101foreach (TypeName[Push Block], arrayPos0, ACTIVE_ENTITIES)102BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 8, arrayPos0, -16, -16, 16, 16)103if checkResult == true104// I think this is a leftover from MZ/SYZ, this should probably set object.stood instead of object.propertyValue (which was object.stood in MZ/SYZ)105object.propertyValue = 1106if object.frame == 0107PlaySfx(SfxName[Button Press], false)108end if109end if110next111end event112113114event ObjectDraw115object.frame = object.stood116DrawSprite(object.frame)117end event118119120event ObjectStartup121LoadSpriteSheet("LZ/Objects.gif")122SpriteFrame(-16, -8, 32, 16, 1, 84)123SpriteFrame(-16, -4, 32, 12, 85, 160)124125SetTableValue(TypeName[Push Button], DebugMode_ObjCount, DebugMode_TypesTable)126SetTableValue(PushButton_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)127SetTableValue(PushButton_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)128DebugMode_ObjCount++129end event130131132// ========================133// Editor Events134// ========================135136event RSDKEdit137if editor.returnVariable == true138switch editor.variableID139case EDIT_VAR_PROPVAL // property value140checkResult = object.propertyValue141checkResult &= 3142break143144case 0 // type145checkResult = object.propertyValue146checkResult &= 3147break148149end switch150else151switch editor.variableID152case EDIT_VAR_PROPVAL // property value153object.propertyValue = editor.variableValue154object.propertyValue &= 3155break156157case 0 // type158object.propertyValue = editor.variableValue159object.propertyValue &= 3160break161162end switch163end if164end event165166167event RSDKDraw168DrawSprite(0)169end event170171172event RSDKLoad173LoadSpriteSheet("LZ/Objects.gif")174SpriteFrame(-16, -8, 32, 16, 1, 84)175176AddEditorVariable("type")177SetActiveVariable("type")178AddEnumVariable("Generic", 0)179AddEnumVariable("Open LZ3 Path", 1)180// AddEnumVariable("unused?", 2) // as far as I know this does nothing special so... (it's placed in LZ3 once but it acts the same as prop val 0)181AddEnumVariable("Swap Belt Platform Dir", 3)182end event183184185