Path: blob/master/Sonic 1/Scripts/MZ/RideBlock.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Ride Block 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.drawPos.x13private alias object.value2 : object.startPos.x14private alias object.value3 : object.startPos.y1516private alias 0 : RIDEBLOCK_AWAITPLAYER17private alias 1 : RIDEBLOCK_MOVING18private alias 2 : RIDEBLOCK_SINKING19private alias 3 : RIDEBLOCK_STOPPED2021// Player Aliases22private alias object.xpos: player.xpos23private alias object.ypos: player.ypos2425// Tile Flag Aliases26private alias 1 : TILE_LAVA2728// Tile Info ID Aliases29private alias 8 : TILEINFO_ANGLEB3031// Path ID Aliases32private alias 0 : PATH_A333435// ========================36// Function Declarations37// ========================3839reserve function RideBlock_DebugDraw40reserve function RideBlock_DebugSpawn414243// ========================44// Tables45// ========================4647private function RideBlock_DebugDraw48DrawSprite(0)49end function505152private function RideBlock_DebugSpawn53CreateTempObject(TypeName[Ride Block], 0, object.xpos, object.ypos)54object[tempObjectPos].direction = object.direction55object[tempObjectPos].startPos.x = object[arrayPos0].xpos56object[tempObjectPos].startPos.y = object[arrayPos0].ypos57end function585960// ========================61// Events62// ========================6364event ObjectUpdate65switch object.state66case RIDEBLOCK_AWAITPLAYER67object.priority = PRIORITY_ACTIVE68foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)69BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, 16, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)70if checkResult == true71object.state++72if object.direction == FLIP_NONE73object.xvel = 0x1000074else75object.xvel = -0x1000076end if77end if78next79break8081case RIDEBLOCK_MOVING82temp0 = object.xpos83temp0 -= object.drawPos.x84temp0 += object.xvel85temp0 &= 0xFFFF00008687foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)88BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, 16, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)89if checkResult == true90player[currentPlayer].xpos += temp091end if92next9394object.xpos += object.xvel95if object.xvel > 096ObjectTileCollision(CSIDE_LWALL, 16, 12, PATH_A)97if checkResult == true98object.xvel = 099object.timer = 0100temp1 = object.iypos101temp1 += 12102Get16x16TileInfo(temp0, object.ixpos, temp1, TILEINFO_ANGLEB)103if temp0 == TILE_LAVA104object.state = RIDEBLOCK_SINKING105else106object.state = RIDEBLOCK_STOPPED107end if108end if109else110ObjectTileCollision(CSIDE_RWALL, -16, 12, PATH_A)111if checkResult == true112object.xvel = 0113object.timer = 0114temp1 = object.iypos115temp1 += 12116Get16x16TileInfo(temp0, object.ixpos, temp1, TILEINFO_ANGLEB)117if temp0 == TILE_LAVA118object.state = RIDEBLOCK_SINKING119else120object.state = RIDEBLOCK_STOPPED121end if122end if123end if124break125126case RIDEBLOCK_SINKING127if object.timer < 320128object.timer++129temp0 = object.timer130temp0 &= 7131if temp0 == 0132temp0 = 0x10000133else134temp0 = 0135end if136137foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)138BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, 16, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)139if checkResult == true140player[currentPlayer].ypos += temp0141end if142next143object.ypos += temp0144end if145break146147case RIDEBLOCK_STOPPED148foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)149BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, 16, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)150next151break152153end switch154155object.drawPos.x = object.xpos156object.drawPos.x &= 0xFFFF0000157if object.outOfBounds == true158temp0 = object.xpos159temp1 = object.ypos160object.xpos = object.startPos.x161object.ypos = object.startPos.y162if object.outOfBounds == true163object.yvel = 0164object.state = 0165else166object.xpos = temp0167object.ypos = temp1168end if169end if170end event171172173event ObjectDraw174DrawSpriteXY(0, object.drawPos.x, object.ypos)175end event176177178event ObjectStartup179LoadSpriteSheet("MZ/Objects.gif")180SpriteFrame(-16, -16, 32, 32, 159, 322)181182foreach (TypeName[Ride Block], arrayPos0, ALL_ENTITIES)183object[arrayPos0].direction = object[arrayPos0].propertyValue184object[arrayPos0].direction &= FLIP_X185object[arrayPos0].startPos.x = object[arrayPos0].xpos186object[arrayPos0].startPos.y = object[arrayPos0].ypos187next188189SetTableValue(TypeName[Ride Block], DebugMode_ObjCount, DebugMode_TypesTable)190SetTableValue(RideBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)191SetTableValue(RideBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)192DebugMode_ObjCount++193end event194195196// ========================197// Editor Events198// ========================199200event RSDKEdit201if editor.returnVariable == true202switch editor.variableID203case EDIT_VAR_PROPVAL // property value204checkResult = object.propertyValue205checkResult &= 1206break207208case 0 // direction209checkResult = object.propertyValue210checkResult &= 1211break212213end switch214else215switch editor.variableID216case EDIT_VAR_PROPVAL // property value217object.propertyValue = editor.variableValue218object.propertyValue &= 1219break220221case 0 // direction222object.propertyValue = editor.variableValue223object.propertyValue &= 1224break225226end switch227end if228end event229230231event RSDKDraw232DrawSprite(0)233end event234235236event RSDKLoad237LoadSpriteSheet("MZ/Objects.gif")238SpriteFrame(-16, -16, 32, 32, 159, 322)239240AddEditorVariable("direction")241SetActiveVariable("direction")242AddEnumVariable("Right", 0)243AddEnumVariable("Left", 1)244end event245246247