Path: blob/master/Sonic 2/Scripts/ARZ/BreakoffPillar.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Breakoff Pillar Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.offset.y12private alias object.value1 : object.shakePos.x13private alias object.value2 : object.timer1415// States16private alias 0 : BREAKOFFPILLAR_AWAITPLAYER17private alias 1 : BREAKOFFPILLAR_SHAKING18private alias 2 : BREAKOFFPILLAR_FALLING19private alias 3 : BREAKOFFPILLAR_FALLEN2021// Player Aliases22private alias object.gravity : player.gravity2324// Path ID Aliases25private alias 0 : PATH_A262728// ========================29// Function Declarations30// ========================3132reserve function BreakoffPillar_DebugDraw33reserve function BreakoffPillar_DebugSpawn343536// ========================37// Tables38// ========================3940private table BreakoffPillar_shakePosTable410, 0x10000, -0x10000, 0x10000, 0, -0x10000, 0, 0x1000042end table434445// ========================46// Function Definitions47// ========================4849private function BreakoffPillar_DebugDraw50DrawSprite(0)51DrawSprite(1)52DrawSprite(2)53end function545556private function BreakoffPillar_DebugSpawn57CreateTempObject(TypeName[Breakoff Pillar], 0, object.xpos, object.ypos)58object[tempObjectPos].frame = 259end function606162// ========================63// Events64// ========================6566event ObjectUpdate67switch object.state68case BREAKOFFPILLAR_AWAITPLAYER69foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)70BoxCollisionTest(C_TOUCH, object.entityPos, -128, -256, 128, 256, currentPlayer, -1, -1, 1, 1)71if checkResult == true72object.priority = PRIORITY_ACTIVE73object.timer = 874object.state = BREAKOFFPILLAR_SHAKING75end if76next77break7879case BREAKOFFPILLAR_SHAKING80object.timer--81if object.timer >= 082GetTableValue(object.shakePos.x, object.timer, BreakoffPillar_shakePosTable)83else84object.state = BREAKOFFPILLAR_FALLING85end if86break8788case BREAKOFFPILLAR_FALLING89object.offset.y += object.yvel90object.yvel += 0x38009192temp0 = object.ypos93object.ypos += object.offset.y94temp1 = object.ypos95ObjectTileCollision(CSIDE_FLOOR, 0, 65, PATH_A)96if checkResult == true97object.state = BREAKOFFPILLAR_FALLEN98object.frame++99end if100temp1 -= object.ypos101object.ypos = temp0102103object.offset.y -= temp1104break105106case BREAKOFFPILLAR_FALLEN107break108109end switch110111foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)112BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)113114temp0 = object.ypos115object.ypos += object.offset.y116BoxCollisionTest(C_SOLID, object.entityPos, -16, 32, 16, 65, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)117if checkResult == COL_BOTTOM118if player[currentPlayer].gravity == GRAVITY_GROUND119CallFunction(Player_Kill)120end if121end if122object.ypos = temp0123next124125temp0 = screen.xcenter126temp0 += 184127CheckCameraProximity(object.ixpos, 0, temp0, -1)128if checkResult == false129object.offset.y = 0130object.shakePos.x = 0131object.yvel = 0132object.timer = 0133object.frame = 2134object.state = BREAKOFFPILLAR_AWAITPLAYER135object.priority = PRIORITY_BOUNDS136end if137end event138139140event ObjectDraw141DrawSprite(0)142DrawSprite(1)143temp0 = object.xpos144temp0 += object.shakePos.x145temp1 = object.ypos146temp1 += object.offset.y147DrawSpriteXY(object.frame, temp0, temp1)148end event149150151event ObjectStartup152LoadSpriteSheet("ARZ/Objects.gif")153SpriteFrame(-28, -32, 56, 56, 59, 42)154SpriteFrame(-16, 24, 32, 8, 140, 80)155SpriteFrame(-16, 32, 32, 37, 173, 38)156SpriteFrame(-16, 32, 32, 41, 140, 38)157158SetTableValue(TypeName[Breakoff Pillar], DebugMode_ObjCount, DebugMode_TypesTable)159SetTableValue(BreakoffPillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)160SetTableValue(BreakoffPillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)161DebugMode_ObjCount++162163foreach (TypeName[Breakoff Pillar], arrayPos0, ALL_ENTITIES)164object[arrayPos0].frame = 2165next166end event167168169// ========================170// Editor Events171// ========================172173event RSDKDraw174DrawSprite(0)175DrawSprite(1)176DrawSprite(2)177end event178179180event RSDKLoad181LoadSpriteSheet("ARZ/Objects.gif")182SpriteFrame(-28, -32, 56, 56, 59, 42)183SpriteFrame(-16, 24, 32, 8, 140, 80)184SpriteFrame(-16, 32, 32, 37, 173, 38)185186SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")187end event188189190