Path: blob/master/Sonic 2/Scripts/ARZ/BreakablePillar.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Breakable Pillar Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.height12private alias object.value1 : object.delay1314// States15private alias 0 : BREAKABLEPILLAR_AWAITPLAYER16private alias 1 : BREAKABLEPILLAR_RISE17private alias 2 : BREAKABLEPILLAR_RISEN18private alias 3 : BREAKABLEPILLAR_NONE19private alias 4 : BREAKABLEPILLAR_TILEDELAY20private alias 5 : BREAKABLEPILLAR_FALL2122// Player Aliases23private alias object.state : player.state24private alias object.xvel : player.xvel25private alias object.speed : player.speed26private alias object.gravity : player.gravity27private alias object.animation : player.animation2829private alias object.value17 : debugMode.currentSelection303132// ========================33// Function Declarations34// ========================3536reserve function BreakablePillar_DebugDraw37reserve function BreakablePillar_DebugSpawn383940// ========================41// Static Values42// ========================4344private value BreakablePillar_startDebugID = 0454647// ========================48// Tables49// ========================5051private table BreakablePillar_tileVelTable52-0x20000, -0x20000, -0x1C000, -0x1C000, 0x1C000, -0x1C000, 0x20000, -0x20000, -0x18000, -0x18000, 0x18000, -0x18000, -0x14000, -0x14000, 0x14000, -0x1400053-0x10000, -0x10000, 0x10000, -0x10000, -0xC000, -0xC000, 0xC000, -0xC000, -0x8000, -0x8000, 0x8000, -0x800054end table555657// ========================58// Function Definitions59// ========================6061private function BreakablePillar_DebugDraw62EditFrame(0, -28, -24, 56, 32, 59, 42)63DrawSprite(0)6465temp0 = debugMode[0].currentSelection66temp0 -= BreakablePillar_startDebugID67temp0++68DrawSprite(temp0)69end function707172private function BreakablePillar_DebugSpawn73temp0 = debugMode[0].currentSelection74temp0 -= BreakablePillar_startDebugID75temp0++76CreateTempObject(TypeName[Breakable Pillar], temp0, object.xpos, object.ypos)77object[tempObjectPos].height = 3278end function798081// ========================82// Events83// ========================8485event ObjectUpdate86switch object.state87case BREAKABLEPILLAR_AWAITPLAYER88foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)89BoxCollisionTest(C_TOUCH, object.entityPos, -40, -256, 40, 256, currentPlayer, -1, -1, 1, 1)90if checkResult == true91object.priority = PRIORITY_ACTIVE92object.state++93end if94next95break9697case BREAKABLEPILLAR_RISE98object.height += 299if object.height == 80100object.state = 2101end if102break103104case BREAKABLEPILLAR_RISEN105break106107case BREAKABLEPILLAR_NONE108break109110case BREAKABLEPILLAR_TILEDELAY111object.delay--112if object.delay < 0113object.state++114end if115break116117case BREAKABLEPILLAR_FALL118object.xpos += object.xvel119object.ypos += object.yvel120object.yvel += 0x1800121122if object.outOfBounds == true123object.type = TypeName[Blank Object]124end if125break126127end switch128129if object.state < BREAKABLEPILLAR_TILEDELAY130temp0 = object.height131temp0 -= 8132FlipSign(temp0)133foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)134if object.state < BREAKABLEPILLAR_NONE135BoxCollisionTest(C_SOLID, object.entityPos, -16, temp0, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)136if checkResult == COL_TOP137player[currentPlayer].animation = ANI_JUMPING138if player[currentPlayer].state == Player_State_GlideLeft139FlipSign(player[currentPlayer].xvel)140player[currentPlayer].speed = player[currentPlayer].xvel141end if142143player[currentPlayer].state = Player_State_Roll144player[currentPlayer].gravity = GRAVITY_AIR145PlaySfx(SfxName[Ledge Break], false)146147temp5 = 0148temp0 = object.height149temp0 >>= 5150temp1 = object.height151temp1 &= 31152if temp1 != 0153temp0++154end if155temp3 = object.height156FlipSign(temp3)157temp3 += 16158temp3 <<= 16159temp3 += object.ypos160temp2 = object.xpos161temp2 -= 0x180000162temp1 = 3163while temp1 < 7164CreateTempObject(TypeName[Breakable Pillar], temp1, temp2, temp3)165GetTableValue(object[tempObjectPos].xvel, temp5, BreakablePillar_tileVelTable)166temp5++167GetTableValue(object[tempObjectPos].yvel, temp5, BreakablePillar_tileVelTable)168temp5++169object[tempObjectPos].state = BREAKABLEPILLAR_TILEDELAY170temp2 += 0x100000171temp1++172loop173174temp3 += 0x100000175temp4 = 4176while temp0 >= 0177temp1 = 7178temp2 = object.xpos179temp2 -= 0x80000180while temp1 < 9181CreateTempObject(TypeName[Breakable Pillar], temp1, temp2, temp3)182GetTableValue(object[tempObjectPos].xvel, temp5, BreakablePillar_tileVelTable)183temp5++184GetTableValue(object[tempObjectPos].yvel, temp5, BreakablePillar_tileVelTable)185temp5++186object[tempObjectPos].delay = temp4187object[tempObjectPos].state = BREAKABLEPILLAR_TILEDELAY188temp2 += 0x100000189temp1++190loop191temp3 += 0x100000192temp4 += 4193temp0--194loop195196temp3 = object.ypos197temp3 += 0x100000198if object.propertyValue == 1199temp6 = 0200else201temp6 = 2202end if203temp6 += 9204205temp1 = 0206temp2 = object.xpos207temp2 -= 0x80000208while temp1 < 2209CreateTempObject(TypeName[Breakable Pillar], temp6, temp2, temp3)210GetTableValue(object[tempObjectPos].xvel, temp5, BreakablePillar_tileVelTable)211temp5++212GetTableValue(object[tempObjectPos].yvel, temp5, BreakablePillar_tileVelTable)213temp5++214object[tempObjectPos].delay = temp4215object[tempObjectPos].state = BREAKABLEPILLAR_TILEDELAY216temp2 += 0x100000217temp6++218temp1++219loop220object.state = BREAKABLEPILLAR_NONE221end if222end if223next224225temp0 = screen.xcenter226temp0 += 184227CheckCameraProximity(object.ixpos, 0, temp0, -1)228if checkResult == false229object.height = 32230object.delay = 0231object.state = BREAKABLEPILLAR_AWAITPLAYER232object.priority = PRIORITY_BOUNDS233end if234end if235end event236237238event ObjectDraw239if object.state != BREAKABLEPILLAR_NONE240temp0 = object.height241temp0 -= 8242FlipSign(temp0)243EditFrame(0, -28, temp0, 56, object.height, 59, 42)244245DrawSprite(0)246DrawSprite(object.propertyValue)247end if248end event249250251event ObjectStartup252LoadSpriteSheet("ARZ/Objects.gif")253SpriteFrame(-28, -24, 56, 32, 59, 42)254SpriteFrame(-16, 8, 32, 24, 223, 137)255SpriteFrame(-16, 8, 32, 16, 71, 130)256SpriteFrame(-4, -8, 12, 16, 59, 42)257SpriteFrame(-8, -8, 16, 16, 71, 42)258SpriteFrame(-8, -8, 16, 16, 87, 42)259SpriteFrame(-8, -8, 12, 16, 103, 42)260SpriteFrame(-8, -8, 16, 16, 71, 58)261SpriteFrame(-8, -8, 16, 16, 87, 58)262SpriteFrame(-8, -8, 16, 24, 223, 137)263SpriteFrame(-8, -8, 16, 24, 239, 137)264SpriteFrame(-8, -8, 16, 16, 71, 130)265SpriteFrame(-8, -8, 16, 16, 87, 130)266267temp0 = 0268BreakablePillar_startDebugID = DebugMode_ObjCount269while temp0 < 2270SetTableValue(TypeName[Breakable Pillar], DebugMode_ObjCount, DebugMode_TypesTable)271SetTableValue(BreakablePillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)272SetTableValue(BreakablePillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)273DebugMode_ObjCount++274temp0++275loop276277foreach (TypeName[Breakable Pillar], arrayPos0, ALL_ENTITIES)278object[arrayPos0].height = 32279object[arrayPos0].propertyValue++280next281end event282283284// ========================285// Editor Events286// ========================287288event RSDKEdit289if editor.returnVariable == true290switch editor.variableID291case EDIT_VAR_PROPVAL // property value292checkResult = object.propertyValue293checkResult &= 1294break295296case 0 // noGrass297checkResult = object.propertyValue298checkResult &= 1299break300301end switch302else303switch editor.variableID304case EDIT_VAR_PROPVAL // property value305object.propertyValue = editor.variableValue306object.propertyValue &= 1307break308309case 0 // noGrass310object.propertyValue = editor.variableValue311object.propertyValue &= 1312break313314end switch315end if316end event317318319event RSDKDraw320object.height = 80321object.frame = object.propertyValue322object.frame++323324temp0 = object.height325temp0 -= 8326FlipSign(temp0)327EditFrame(0, -28, temp0, 56, object.height, 59, 42)328329DrawSprite(0)330DrawSprite(object.frame)331end event332333334event RSDKLoad335LoadSpriteSheet("ARZ/Objects.gif")336SpriteFrame(-28, -24, 56, 32, 59, 42)337SpriteFrame(-16, 8, 32, 24, 223, 137)338SpriteFrame(-16, 8, 32, 16, 71, 130)339SpriteFrame(-4, -8, 12, 16, 59, 42)340SpriteFrame(-8, -8, 16, 16, 71, 42)341SpriteFrame(-8, -8, 16, 16, 87, 42)342SpriteFrame(-8, -8, 12, 16, 103, 42)343SpriteFrame(-8, -8, 16, 16, 71, 58)344SpriteFrame(-8, -8, 16, 16, 87, 58)345SpriteFrame(-8, -8, 16, 24, 223, 137)346SpriteFrame(-8, -8, 16, 24, 239, 137)347SpriteFrame(-8, -8, 16, 16, 71, 130)348SpriteFrame(-8, -8, 16, 16, 87, 130)349350AddEditorVariable("noGrass")351SetActiveVariable("noGrass")352AddEnumVariable("false", false)353AddEnumVariable("true", true)354end event355356357