Path: blob/master/Sonic 2/Scripts/OOZ/BreakBlock.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Gas Break Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011// States12private alias 0 : GASBREAKBLOCK_BLOCKS13private alias 1 : GASBREAKBLOCK_LAUNCHER14private alias 2 : GASBREAKBLOCK_DEBRIS1516// Player Aliases17private alias object.state : player.state18private alias object.xpos : player.xpos19private alias object.ypos : player.ypos20private alias object.xvel : player.xvel21private alias object.yvel : player.yvel22private alias object.gravity : player.gravity23private alias object.animationSpeed : player.animationSpeed24private alias object.animation : player.animation2526private alias object.value5 : player.rollAnimationSpeed27private alias object.value17 : debugMode.currentSelection28private alias object.value40 : player.hitboxLeft29private alias object.value38 : player.hitboxTop30private alias object.value41 : player.hitboxRight31private alias object.value39 : player.hitboxBottom323334// ========================35// Function Declarations36// ========================3738reserve function GasBreakBlock_DebugDraw39reserve function GasBreakBlock_DebugSpawn404142// ========================43// Static Values44// ========================4546private value GasBreakBlock_startDebugID = 0474849// ========================50// Tables51// ========================5253// btw these tables are public cuz Checkered Ball uses 'em too5455// Holds position offsets for blocks56public table GasBreakBlock_blockOffsets57-0xC0000, -0xC000058-0x40000, -0xC0000590x40000, -0xC0000600xC0000, -0xC000061-0xC0000, -0x4000062-0x40000, -0x40000630x40000, -0x40000640xC0000, -0x4000065-0xC0000, 0x4000066-0x40000, 0x40000670x40000, 0x40000680xC0000, 0x4000069-0xC0000, 0xC000070-0x40000, 0xC0000710x40000, 0xC0000720xC0000, 0xC000073end table7475// Holds starting velocity for blocks76public table GasBreakBlock_blockVelocities77-0x40000, -0x4000078-0x20000, -0x40000790x20000, -0x40000800x40000, -0x4000081-0x3C000, -0x2000082-0x1C000, -0x20000830x1C000, -0x20000840x3C000, -0x2000085-0x38000, 0x2000086-0x18000, 0x20000870x18000, 0x20000880x38000, 0x2000089-0x34000, 0x4000090-0x14000, 0x40000910x14000, 0x40000920x34000, 0x4000093end table9495// Holds frame IDs for block fragments to display96public table GasBreakBlock_blockFrames972, 3, 4, 5982, 3, 4, 5992, 3, 4, 51002, 3, 4, 5101end table102103// Holds frame IDs for block fragments to display, but now for a horizontal block104// Even though there are (otherwise unused) SpriteFrames for it, this goes unused anyways..105private table GasBreakBlock_unusedTable1066, 6, 6, 61077, 7, 7, 71088, 8, 8, 81099, 9, 9, 9110end table111112113// ========================114// Function Definitions115// ========================116117private function GasBreakBlock_DebugDraw118temp0 = debugMode[0].currentSelection119temp0 -= GasBreakBlock_startDebugID120DrawSprite(temp0)121end function122123124private function GasBreakBlock_DebugSpawn125temp0 = debugMode[0].currentSelection126temp0 -= GasBreakBlock_startDebugID127CreateTempObject(TypeName[Gas Break Block], temp0, object.xpos, object.ypos)128object[tempObjectPos].frame = temp0129object[tempObjectPos].drawOrder = 4130end function131132133// ========================134// Events135// ========================136137event ObjectUpdate138switch object.state139case GASBREAKBLOCK_BLOCKS140foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)141#platform: USE_STANDALONE142if player[currentPlayer].animation == ANI_JUMPING143#endplatform144#platform: USE_ORIGINS145checkResult = false146147if player[currentPlayer].animation == ANI_JUMPING148checkResult = true149end if150151if player[currentPlayer].animation == ANI_HAMMER_JUMP152checkResult = 2153end if154155if checkResult != false156#endplatform157if object.state == GASBREAKBLOCK_BLOCKS158temp0 = player[currentPlayer].yvel159#platform: USE_STANDALONE160BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)161#endplatform162#platform: USE_ORIGINS163switch checkResult164case 1165BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)166break167168case 2169BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)170break171end switch172#endplatform173player[currentPlayer].yvel = temp0174if checkResult == COL_TOP175player[currentPlayer].gravity = GRAVITY_AIR176temp0 = 0177temp1 = 0178while temp0 < 16179CreateTempObject(TypeName[Gas Break Block], 0, object.xpos, object.ypos)180GetTableValue(object[tempObjectPos].frame, temp0, GasBreakBlock_blockFrames) // these blocks compose a Vertical block, there's no extra version of the table for Horizontal blocks181GetTableValue(temp2, temp1, GasBreakBlock_blockOffsets)182GetTableValue(object[tempObjectPos].xvel, temp1, GasBreakBlock_blockVelocities)183temp1++184185GetTableValue(temp3, temp1, GasBreakBlock_blockOffsets)186GetTableValue(object[tempObjectPos].yvel, temp1, GasBreakBlock_blockVelocities)187temp1++188189object[tempObjectPos].xpos += temp2190object[tempObjectPos].ypos += temp3191object[tempObjectPos].state = GASBREAKBLOCK_DEBRIS192object[tempObjectPos].drawOrder = 5193temp0++194loop195object.state++196197if object.priority != PRIORITY_XBOUNDS_DESTROY198object.priority = PRIORITY_ACTIVE199end if200PlaySfx(SfxName[Block Break], false)201end if202end if203else204BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)205end if206next207break208209case GASBREAKBLOCK_LAUNCHER210foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)211if player[currentPlayer].state != Player_State_Static212BoxCollisionTest(C_TOUCH, object.entityPos, -8, -4, 8, 4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)213if checkResult == true214player[currentPlayer].state = Player_State_Static215player[currentPlayer].animation = ANI_JUMPING216player[currentPlayer].animationSpeed = 0xF0217player[currentPlayer].rollAnimationSpeed = 0xF0218player[currentPlayer].xpos = object.xpos219player[currentPlayer].ypos = object.ypos220#platform: USE_ORIGINS221player[currentPlayer].gravity = GRAVITY_AIR222#endplatform223if object.propertyValue == 0224// Vertical Block225player[currentPlayer].xvel = 0226player[currentPlayer].yvel = -0x80000227else228// Horizontal Block229player[currentPlayer].xvel = 0x80000230player[currentPlayer].yvel = 0231end if232PlaySfx(SfxName[Rolling], false)233end if234end if235next236237if object.outOfBounds == true238if object.priority != PRIORITY_XBOUNDS_DESTROY239object.priority = PRIORITY_BOUNDS240object.state = GASBREAKBLOCK_BLOCKS241end if242end if243break244245case GASBREAKBLOCK_DEBRIS246object.xpos += object.xvel247object.ypos += object.yvel248object.yvel += 0x1800249250if object.outOfBounds == true251object.type = TypeName[Blank Object]252end if253break254255end switch256end event257258259event ObjectDraw260if object.state != GASBREAKBLOCK_LAUNCHER261DrawSprite(object.frame)262end if263end event264265266event ObjectStartup267CheckCurrentStageFolder("Zone07")268if checkResult == true269LoadSpriteSheet("OOZ/Objects.gif")270SpriteFrame(-16, -16, 32, 32, 69, 141) // Vertical Frame - #0271SpriteFrame(-16, -16, 32, 32, 69, 174) // Horizontal Frame - #1272SpriteFrame(-4, -4, 8, 8, 69, 141) // V Block Debris Frame 0 - #2273SpriteFrame(-4, -4, 8, 8, 77, 141) // V Block Debris Frame 1 - #3274SpriteFrame(-4, -4, 8, 8, 85, 141) // V Block Debris Frame 2 - #4275SpriteFrame(-4, -4, 8, 8, 93, 141) // V Block Debris Frame 3 - #5276SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 4 (Unused) - #6277SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 5 (Unused) - #7278SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 6 (Unused) - #8279SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 7 (Unused) - #9280else281LoadSpriteSheet("MBZ/Objects.gif")282SpriteFrame(-16, -16, 32, 32, 991, 843) // Vertical Frame - #0283SpriteFrame(-16, -16, 32, 32, 991, 876) // Horizontal Frame - #1284SpriteFrame(-4, -4, 8, 8, 991, 843) // V Block Debris Frame 0 - #2285SpriteFrame(-4, -4, 8, 8, 999, 843) // V Block Debris Frame 1 - #3286SpriteFrame(-4, -4, 8, 8, 1007, 843) // V Block Debris Frame 2 - #4287SpriteFrame(-4, -4, 8, 8, 1015, 843) // V Block Debris Frame 3 - #5288SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 4 (Unused) - #6289SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 5 (Unused) - #7290SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 6 (Unused) - #8291SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 7 (Unused) - #9292end if293294foreach (TypeName[Gas Break Block], arrayPos0, ALL_ENTITIES)295object[arrayPos0].propertyValue &= 1296object[arrayPos0].frame = object[arrayPos0].propertyValue297object[arrayPos0].drawOrder = 4298next299300temp0 = 0301GasBreakBlock_startDebugID = DebugMode_ObjCount302while temp0 < 2303SetTableValue(TypeName[Gas Break Block], DebugMode_ObjCount, DebugMode_TypesTable)304SetTableValue(GasBreakBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)305SetTableValue(GasBreakBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)306DebugMode_ObjCount++307temp0++308loop309end event310311312// ========================313// Editor Events314// ========================315316event RSDKEdit317if editor.returnVariable == true318switch editor.variableID319case EDIT_VAR_PROPVAL // property value320checkResult = object.propertyValue321break322323case 0 // frameID324checkResult = object.propertyValue325checkResult &= 1326break327328end switch329else330switch editor.variableID331case EDIT_VAR_PROPVAL // property value332object.propertyValue = editor.variableValue333break334335case 0 // frameID336editor.variableValue &= 1337338object.propertyValue = editor.variableValue339break340341end switch342end if343end event344345346event RSDKDraw347object.frame = object.propertyValue348object.frame &= 1349DrawSprite(object.frame)350351if editor.showGizmos == true352editor.drawingOverlay = true353354object.inkEffect = INK_NONE355GetBit(temp0, object.propertyValue, 0)356if temp0 == 0357// Vertical (upwards) block358temp0 = object.ypos359temp0 -= 0x480000360DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0xFF, 0x00, 0x00)361else362// Horizontal (right) block363temp0 = object.xpos364temp0 += 0x480000365DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 0xFF, 0x00, 0x00)366end if367368editor.drawingOverlay = false369end if370end event371372373event RSDKLoad374CheckCurrentStageFolder("Zone07")375if checkResult == true376LoadSpriteSheet("OOZ/Objects.gif")377SpriteFrame(-16, -16, 32, 32, 69, 141) // Vertical Frame378SpriteFrame(-16, -16, 32, 32, 69, 174) // Horizontal Frame379else380LoadSpriteSheet("MBZ/Objects.gif")381SpriteFrame(-16, -16, 32, 32, 991, 843) // Vertical Frame382SpriteFrame(-16, -16, 32, 32, 991, 876) // Horizontal Frame383end if384385AddEditorVariable("orientation")386SetActiveVariable("orientation")387AddEnumVariable("Vertical", 0)388AddEnumVariable("Horizontal", 1)389end event390391392