Path: blob/master/Sonic 2/Scripts/CPZ/BreakBlock.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Break Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias 0 : BREAKBLOCK_SOLID12private alias 1 : BREAKBLOCK_DEBRIS113private alias 2 : BREAKBLOCK_DEBRIS214private alias 3 : BREAKBLOCK_DEBRIS315private alias 4 : BREAKBLOCK_DEBRIS41617// Player Aliases18private alias object.yvel : player.yvel19private alias object.gravity : player.gravity20private alias object.animation : player.animation21private alias object.value16 : player.isSidekick22private alias object.value19 : player.badnikBonus23private alias object.value40 : player.hitboxLeft24private alias object.value38 : player.hitboxTop25private alias object.value41 : player.hitboxRight26private alias object.value39 : player.hitboxBottom2728// Global Variable ID Aliases29private alias 22 : GLOBAL_PLAYERSCORE303132// ========================33// Function Declarations34// ========================3536reserve function BreakBlock_DebugDraw37reserve function BreakBlock_DebugSpawn383940// ========================41// Function Definitions42// ========================4344private function BreakBlock_DebugDraw45DrawSprite(0)46end function474849private function BreakBlock_DebugSpawn50CreateTempObject(TypeName[Break Block], 0, object.xpos, object.ypos)51end function525354// ========================55// Events56// ========================5758event ObjectUpdate59switch object.state60case BREAKBLOCK_SOLID61foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)62#platform: USE_STANDALONE63if player[currentPlayer].animation == ANI_JUMPING64BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)65#endplatform66#platform: USE_ORIGINS67checkResult = false6869if player[currentPlayer].animation == ANI_JUMPING70checkResult = true71end if7273if player[currentPlayer].animation == ANI_HAMMER_JUMP74checkResult = 275end if7677if checkResult != false78switch checkResult79case 180BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)81break8283case 284BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)85break86end switch87#endplatform88if checkResult == COL_TOP89player[currentPlayer].yvel = -0x3000090player[currentPlayer].gravity = GRAVITY_AIR9192CreateTempObject(TypeName[Object Score], player[currentPlayer].badnikBonus, object.xpos, object.ypos)93object[tempObjectPos].drawOrder = 49495// Create block fragments96CreateTempObject(TypeName[Break Block], 0, object.xpos, object.ypos)97object[tempObjectPos].ixpos -= 898object[tempObjectPos].iypos -= 899object[tempObjectPos].xvel = -0x20000100object[tempObjectPos].yvel = -0x20000101object[tempObjectPos].state = BREAKBLOCK_DEBRIS1102object[tempObjectPos].drawOrder = 5103104CreateTempObject(TypeName[Break Block], 0, object.xpos, object.ypos)105object[tempObjectPos].ixpos += 8106object[tempObjectPos].iypos -= 8107object[tempObjectPos].xvel = 0x20000108object[tempObjectPos].yvel = -0x20000109object[tempObjectPos].state = BREAKBLOCK_DEBRIS2110object[tempObjectPos].drawOrder = 5111112CreateTempObject(TypeName[Break Block], 0, object.xpos, object.ypos)113object[tempObjectPos].ixpos -= 8114object[tempObjectPos].iypos += 8115object[tempObjectPos].xvel = -0x10000116object[tempObjectPos].yvel = -0x10000117object[tempObjectPos].state = BREAKBLOCK_DEBRIS3118object[tempObjectPos].drawOrder = 5119120CreateTempObject(TypeName[Break Block], 0, object.xpos, object.ypos)121object[tempObjectPos].ixpos += 8122object[tempObjectPos].iypos += 8123object[tempObjectPos].xvel = 0x10000124object[tempObjectPos].yvel = -0x10000125object[tempObjectPos].state = BREAKBLOCK_DEBRIS4126object[tempObjectPos].drawOrder = 5127128object.type = TypeName[Blank Object]129130// Award some score to the player, uses the global variable "array" (yes, this is actually how its done)131arrayPos0 = GLOBAL_PLAYERSCORE132#platform: USE_DECOMP133arrayPos0 = VarName[player.score]134#endplatform135if player[currentPlayer].isSidekick == false136arrayPos0 += currentPlayer137end if138139switch player[currentPlayer].badnikBonus140case 0141global[arrayPos0] += 100142break143144case 1145global[arrayPos0] += 200146break147148case 2149global[arrayPos0] += 500150break151152case 3153case 4154case 5155case 6156case 7157case 8158case 9159case 10160case 11161case 12162case 13163case 14164global[arrayPos0] += 1000165break166167case 15168global[arrayPos0] += 10000169break170end switch171172if player[currentPlayer].gravity == 1173if player[currentPlayer].badnikBonus < 15174player[currentPlayer].badnikBonus++175end if176end if177178PlaySfx(SfxName[Block Break], false)179end if180else181BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)182end if183next184break185186case BREAKBLOCK_DEBRIS1187case BREAKBLOCK_DEBRIS2188case BREAKBLOCK_DEBRIS3189case BREAKBLOCK_DEBRIS4190// Block fragment - just update movement and unload when no longer needed191object.xpos += object.xvel192object.ypos += object.yvel193object.yvel += 0x3800194if object.outOfBounds == true195object.type = TypeName[Blank Object]196end if197break198199end switch200end event201202203event ObjectDraw204DrawSprite(object.state)205end event206207208event ObjectStartup209LoadSpriteSheet("CPZ/Objects.gif")210211// Main Block Frame212SpriteFrame(-16, -16, 32, 32, 165, 223)213214// Top-Left Frame215SpriteFrame(-8, -8, 16, 16, 165, 223)216217// Top-Right Frame218SpriteFrame(-8, -8, 16, 16, 181, 223)219220// Bottom-Left Frame221SpriteFrame(-8, -8, 16, 16, 165, 239)222223// Bottom-Right Frame224SpriteFrame(-8, -8, 16, 16, 181, 239)225226SetTableValue(TypeName[Break Block], DebugMode_ObjCount, DebugMode_TypesTable)227SetTableValue(BreakBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)228SetTableValue(BreakBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)229DebugMode_ObjCount++230end event231232233// ========================234// Editor Events235// ========================236237event RSDKDraw238DrawSprite(0)239end event240241242event RSDKLoad243LoadSpriteSheet("CPZ/Objects.gif")244SpriteFrame(-16, -16, 32, 32, 165, 223)245246SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")247end event248249250