Path: blob/master/Sonic 1/Scripts/SBZ/GirderDoor.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Girder Door 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.x13private alias object.value2 : object.buttonPressed1415// States16private alias 0 : GIRDERDOOR_IDLE17private alias 1 : GIRDERDOOR_WAITFORACTIVE18private alias 2 : GIRDERDOOR_MOVE19private alias 3 : GIRDERDOOR_DELAY20private alias 4 : GIRDERDOOR_RETURNTOSTART2122// Player Aliases23private alias object.xpos : player.xpos2425// Button Aliases26private alias object.value0 : pushButton.stood272829// ========================30// Function Declarations31// ========================3233reserve function GirderDoor_DebugDraw34reserve function GirderDoor_DebugSpawn353637// ========================38// Tables39// ========================4041private function GirderDoor_DebugDraw42DrawSprite(0)43end function444546private function GirderDoor_DebugSpawn47CreateTempObject(TypeName[Girder Door], 0, object.xpos, object.ypos)48end function495051// ========================52// Events53// ========================5455event ObjectUpdate56switch object.state57case GIRDERDOOR_IDLE58foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)59BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)60next61break6263case GIRDERDOOR_WAITFORACTIVE64object.priority = PRIORITY_BOUNDS65if pushButton[-1].stood == true66if object.buttonPressed == false67object.buttonPressed = true68object.state++69end if70else71object.buttonPressed = false72end if7374foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)75BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)76next77break7879case GIRDERDOOR_MOVE80object.xpos += object.xvel81object.timer++82if object.timer == 6483object.timer = 084object.state++85end if8687foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)88BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)89if checkResult == COL_TOP90player[currentPlayer].xpos += object.xvel91end if92next93break9495case GIRDERDOOR_DELAY96object.timer++97if object.timer == 18098object.timer = 099object.state++100end if101102foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)103BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)104next105break106107case GIRDERDOOR_RETURNTOSTART108object.xpos -= object.xvel109object.timer++110if object.timer == 64111object.timer = 0112object.state = GIRDERDOOR_WAITFORACTIVE113end if114115foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)116BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)117if checkResult == COL_TOP118player[currentPlayer].xpos -= object.xvel119end if120next121break122123end switch124end event125126127event ObjectDraw128DrawSprite(0)129end event130131132event ObjectStartup133LoadSpriteSheet("SBZ/Objects.gif")134SpriteFrame(-64, -12, 128, 24, 383, 140)135136foreach (TypeName[Girder Door], arrayPos0, ALL_ENTITIES)137switch object[arrayPos0].propertyValue138default139case 0140break141142case 1143object[arrayPos0].state = GIRDERDOOR_WAITFORACTIVE144object[arrayPos0].xvel = 0x20000145break146147case 2148object[arrayPos0].state = GIRDERDOOR_WAITFORACTIVE149object[arrayPos0].xvel = -0x20000150break151152end switch153154object[arrayPos0].startPos.x = object[arrayPos0].xpos155next156157SetTableValue(TypeName[Girder Door], DebugMode_ObjCount, DebugMode_TypesTable)158SetTableValue(GirderDoor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)159SetTableValue(GirderDoor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)160DebugMode_ObjCount++161end event162163164// ========================165// Editor Events166// ========================167168event RSDKEdit169if editor.returnVariable == true170switch editor.variableID171case EDIT_VAR_PROPVAL // property value172checkResult = object.propertyValue173checkResult &= 3174break175176case 0 // type177checkResult = object.propertyValue178checkResult &= 3179break180181end switch182else183switch editor.variableID184case EDIT_VAR_PROPVAL // property value185object.propertyValue = editor.variableValue186object.propertyValue &= 3187break188189case 0 // type190object.propertyValue = editor.variableValue191object.propertyValue &= 3192break193194end switch195end if196end event197198199event RSDKDraw200DrawSprite(0)201end event202203204event RSDKLoad205LoadSpriteSheet("SBZ/Objects.gif")206SpriteFrame(-64, -12, 128, 24, 383, 140)207208AddEditorVariable("type")209SetActiveVariable("type")210AddEnumVariable("No movement", 0)211AddEnumVariable("Move Right", 1)212AddEnumVariable("Move Left", 2)213end event214215216