Path: blob/master/Sonic 2/Scripts/OOZ/CollapsingFloor.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: C 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.delay13private alias object.value2 : object.collapseTable1415private alias 0 : CFLOOR_ACTIVE16private alias 1 : CFLOOR_COLLAPSE17private alias 2 : CFLOOR_COLLAPSED18private alias 3 : CFLOOR_NONE19private alias 4 : CFLOOR_TILEDELAY20private alias 5 : CFLOOR_TILEFALL2122// Player Aliases23private alias object.yvel : player.yvel2425private alias object.value17 : debugMode.currentSelection262728// ========================29// Function Declarations30// ========================3132reserve function CFloor_DebugDraw33reserve function CFloor_DebugSpawn343536// ========================37// Tables38// ========================3940private table CFloor_tileFramesFlipX411, 2, 3, 4425, 6, 7, 843end table4445// Unused, same table as the one in ARZ though...46private table CFloor_tileFramesNoFlip474, 3, 2, 1488, 7, 6, 549end table5051private table CFloor_collapseTableL5230, 22, 14, 65326, 18, 10, 254end table555657// ========================58// Function Definitions59// ========================6061private function CFloor_DebugDraw62DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)63end function646566private function CFloor_DebugSpawn67CreateTempObject(TypeName[C Floor], 0, object.xpos, object.ypos)68object[tempObjectPos].collapseTable = CFloor_collapseTableL69object[tempObjectPos].direction = object.direction70end function717273// ========================74// Events75// ========================7677event ObjectUpdate78switch object.state79default80case CFLOOR_ACTIVE81break8283case CFLOOR_COLLAPSE84if object.timer < 1085object.timer++86else87temp5 = 088temp0 = 089temp3 = object.ypos90temp3 -= 0x8000091temp4 = 1092while temp0 < 293temp1 = 094temp2 = object.xpos95if object.direction == FLIP_NONE96temp2 -= 0x30000097else98temp2 += 0x30000099end if100101while temp1 < 4102GetTableValue(temp6, temp5, CFloor_tileFramesFlipX)103104CreateTempObject(TypeName[C Floor], temp6, temp2, temp3)105object[tempObjectPos].direction = object.direction106object[tempObjectPos].state = CFLOOR_TILEDELAY107GetTableValue(object[tempObjectPos].delay, temp5, object.collapseTable)108temp5++109temp6++110temp1++111if object.direction == FLIP_NONE112temp2 += 0x200000113else114temp2 -= 0x200000115end if116temp4 += 4117loop118temp4 -= 26119object.frame += 2120temp0++121temp3 += 0x180000122loop123PlaySfx(SfxName[Ledge Break], false)124object.timer = 0125object.state++126end if127break128129case CFLOOR_COLLAPSED130if object.timer < 20131object.timer++132else133object.timer = 0134object.state++135end if136break137138case CFLOOR_NONE139break140141case CFLOOR_TILEDELAY142if object.timer < object.delay143object.timer++144else145object.timer = 0146object.state++147end if148break149150case CFLOOR_TILEFALL151object.ypos += object.yvel152object.yvel += 0x4000153if object.outOfBounds == true154object.type = TypeName[Blank Object]155end if156break157158end switch159160if object.state < CFLOOR_TILEDELAY161if object.outOfBounds == true162object.state = CFLOOR_ACTIVE163object.timer = 0164object.priority = PRIORITY_BOUNDS165end if166end if167168if object.state < CFLOOR_NONE169foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)170if object.propertyValue < 2171if player[currentPlayer].yvel >= 0172BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -24, 64, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)173else174checkResult = COL_NONE175end if176else177BoxCollisionTest(C_SOLID, object.entityPos, -64, -16, 64, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)178end if179180if checkResult == COL_TOP181if object.state == CFLOOR_ACTIVE182object.state = CFLOOR_COLLAPSE183object.priority = PRIORITY_ACTIVE184end if185end if186next187end if188end event189190191event ObjectDraw192switch object.state193case CFLOOR_ACTIVE194case CFLOOR_COLLAPSE195DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)196break197198case CFLOOR_COLLAPSED199case CFLOOR_NONE200break201202case CFLOOR_TILEDELAY203case CFLOOR_TILEFALL204DrawSpriteFX(object.propertyValue, FX_FLIP, object.xpos, object.ypos)205break206207end switch208end event209210211event ObjectStartup212LoadSpriteSheet("OOZ/Objects.gif")213SpriteFrame(-64, -24, 128, 48, 1, 207)214SpriteFrame(-16, -16, 32, 32, 1, 207)215SpriteFrame(-16, -16, 32, 32, 33, 207)216SpriteFrame(-16, -16, 32, 32, 65, 207)217SpriteFrame(-16, -16, 32, 32, 97, 207)218SpriteFrame(-16, -8, 32, 16, 1, 239)219SpriteFrame(-16, -8, 32, 16, 33, 239)220SpriteFrame(-16, -8, 32, 16, 65, 239)221SpriteFrame(-16, -8, 32, 16, 97, 239)222223foreach (TypeName[C Floor], arrayPos0, ALL_ENTITIES)224object[arrayPos0].collapseTable = CFloor_collapseTableL225next226227SetTableValue(TypeName[C Floor], DebugMode_ObjCount, DebugMode_TypesTable)228SetTableValue(CFloor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)229SetTableValue(CFloor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)230DebugMode_ObjCount++231end event232233234// ========================235// Editor Events236// ========================237238event RSDKDraw239DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)240end event241242243event RSDKLoad244LoadSpriteSheet("OOZ/Objects.gif")245SpriteFrame(-64, -24, 128, 48, 1, 207)246247// even if flipped platforms have it set, dir attr is used in favour instead248SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")249end event250251252