Path: blob/master/Sonic 1/Scripts/SBZ/SlidingFloor.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Sliding Floor 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.x1314private alias 0 : SLIDINGFLOOR_WAITFORPLAYER15private alias 1 : SLIDINGFLOOR_SLIDEAWAY16private alias 2 : SLIDINGFLOOR_FINISHEDSLIDING17private alias 3 : SLIDINGFLOOR_RETURNTOSTART1819// Player Aliases20private alias object.xpos : player.xpos212223// ========================24// Function Declarations25// ========================2627reserve function SlidingFloor_DebugDraw28reserve function SlidingFloor_DebugSpawn293031// ========================32// Function Definitions33// ========================3435private function SlidingFloor_DebugDraw36DrawSprite(0)37end function383940private function SlidingFloor_DebugSpawn41CreateTempObject(TypeName[Sliding Floor], 0, object.xpos, object.ypos)42if object.direction == FLIP_NONE43object[tempObjectPos].xvel = 0x8000044else45object[tempObjectPos].xvel = -0x8000046end if47object[tempObjectPos].startPos.x = object.xpos48end function495051// ========================52// Events53// ========================5455event ObjectUpdate56switch object.state57case SLIDINGFLOOR_WAITFORPLAYER58foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)59BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)60if checkResult == true61object.priority = PRIORITY_ACTIVE62object.state++63end if64next65break6667case SLIDINGFLOOR_SLIDEAWAY68object.timer++69if object.timer == 1670object.timer = 071object.state++72end if7374foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)75BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)76if checkResult == true77player[currentPlayer].xpos += object.xvel78end if79next80object.xpos += object.xvel81break8283case SLIDINGFLOOR_FINISHEDSLIDING84object.timer++85if object.timer == 36086object.timer = 087object.state++88end if8990if object.timer < 391foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)92BoxCollisionTest(C_PLATFORM, object.entityPos, -72, -12, 72, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)93next94else95foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)96BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)97next98end if99break100101case SLIDINGFLOOR_RETURNTOSTART102object.timer++103if object.timer == 16104object.timer = 0105object.state = SLIDINGFLOOR_WAITFORPLAYER106end if107108foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)109BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)110if checkResult == true111player[currentPlayer].xpos -= object.xvel112end if113next114object.xpos -= object.xvel115break116117end switch118119if object.outOfBounds == true120temp0 = object.xpos121object.xpos = object.startPos.x122123if object.outOfBounds == true124object.timer = 0125object.priority = PRIORITY_BOUNDS126object.state = SLIDINGFLOOR_WAITFORPLAYER127else128object.xpos = temp0129end if130end if131end event132133134event ObjectDraw135DrawSprite(0)136end event137138139event ObjectStartup140LoadSpriteSheet("SBZ/Objects.gif")141SpriteFrame(-64, -12, 128, 24, 383, 115)142143foreach (TypeName[Sliding Floor], arrayPos0, ALL_ENTITIES)144object[arrayPos0].propertyValue &= 1145if object[arrayPos0].propertyValue == 0146object[arrayPos0].xvel = 0x80000147else148object[arrayPos0].xvel = -0x80000149end if150object[arrayPos0].startPos.x = object[arrayPos0].xpos151next152153SetTableValue(TypeName[Sliding Floor], DebugMode_ObjCount, DebugMode_TypesTable)154SetTableValue(SlidingFloor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)155SetTableValue(SlidingFloor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)156DebugMode_ObjCount++157end event158159160// ========================161// Editor Events162// ========================163164event RSDKEdit165if editor.returnVariable == true166switch editor.variableID167case EDIT_VAR_PROPVAL // property value168checkResult = object.propertyValue169checkResult &= 1170break171172case 0 // direction173checkResult = object.propertyValue174break175176end switch177else178switch editor.variableID179case EDIT_VAR_PROPVAL // property value180object.propertyValue = editor.variableValue181object.propertyValue &= 1182break183184case 0 // direction185object.propertyValue = editor.variableValue186break187188end switch189end if190end event191192193event RSDKDraw194DrawSprite(0)195end event196197198event RSDKLoad199LoadSpriteSheet("SBZ/Objects.gif")200SpriteFrame(-64, -12, 128, 24, 383, 115)201202AddEditorVariable("direction")203SetActiveVariable("direction")204AddEnumVariable("Right", 0)205AddEnumVariable("Left", 1)206end event207208209