Path: blob/master/Sonic 2/Scripts/ARZ/FallingPillar.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Falling Pillar Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.stood12private alias object.value1 : object.collisionOffset.y13private alias object.value2 : object.timer14private alias object.value3 : object.centerPos.y15private alias object.value4 : object.stoodAngle1617// Types18private alias 0 : FPILLAR_FALL19private alias 1 : FPILLAR_STATIC2021// States22private alias 0 : FPILLAR_IDLE23private alias 1 : FPILLAR_FALLING_SOLID24private alias 2 : FPILLAR_FALLING25private alias 3 : FPILLAR_OFFSCREEN26private alias 4 : FPILLAR_NOFALL2728// Player Aliases29private alias object.ypos : player.ypos30private alias object.gravity : player.gravity3132private alias object.value17 : debugMode.currentSelection3334// Path ID Aliases35private alias 0 : PATH_A363738// ========================39// Function Declarations40// ========================4142reserve function FallingPillar_DebugDraw43reserve function FallingPillar_DebugSpawn444546// ========================47// Static Values48// ========================4950private value FallingPillar_startDebugID = 0515253// ========================54// Function Definitions55// ========================5657private function FallingPillar_DebugDraw58DrawSprite(0)59DrawSprite(1)60DrawSprite(2)61end function626364private function FallingPillar_DebugSpawn65temp0 = debugMode[0].currentSelection66temp0 -= FallingPillar_startDebugID67CreateTempObject(TypeName[Falling Pillar], temp0, object.xpos, object.ypos)68object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos69object[tempObjectPos].state = temp070object[tempObjectPos].state <<= 271end function727374// ========================75// Events76// ========================7778event ObjectUpdate79if object.stood == true80if object.timer == 081object.timer = 3082end if8384if object.stoodAngle < 6485object.stoodAngle += 486end if87else88if object.stoodAngle > 089object.stoodAngle -= 490end if91end if92temp0 = object.ypos93temp0 &= 0xFFFF00009495switch object.state96case FPILLAR_IDLE97temp1 = object.stoodAngle98temp1 <<= 199Sin(temp2, temp1)100temp2 <<= 9101object.ypos = object.centerPos.y102object.ypos += temp2103if object.timer != 0104object.timer--105if object.timer == 0106object.state++107object.priority = PRIORITY_ACTIVE108end if109end if110break111112case FPILLAR_FALLING_SOLID113object.ypos += object.yvel114object.yvel += 0x800115116ObjectTileCollision(CSIDE_FLOOR, 0, 65, PATH_A)117if checkResult == true118object.state++119end if120121if object.outOfBounds == true122object.ypos = object.centerPos.y123object.yvel = 0124object.timer = 0125object.state = 3126end if127break128// [Fallthrough]129case FPILLAR_FALLING130if object.outOfBounds == true131object.ypos = object.centerPos.y132object.yvel = 0133object.timer = 0134object.state++135end if136break137138case FPILLAR_OFFSCREEN139if object.outOfBounds == true140object.state = FPILLAR_IDLE141object.priority = PRIORITY_BOUNDS142end if143break144145case FPILLAR_NOFALL146break147148end switch149150object.collisionOffset.y = object.ypos151object.collisionOffset.y &= 0xFFFF0000152object.collisionOffset.y -= temp0153154object.stood = false155if object.state != FPILLAR_OFFSCREEN156temp1 = object.ypos157object.ypos = temp0158foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)159BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 65, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)160if checkResult == COL_TOP161object.stood = true162player[currentPlayer].ypos += object.collisionOffset.y163end if164165if checkResult == COL_BOTTOM166if player[currentPlayer].gravity == GRAVITY_GROUND167CallFunction(Player_Kill)168end if169end if170next171object.ypos = temp1172end if173end event174175176event ObjectDraw177DrawSprite(0)178DrawSprite(1)179DrawSprite(2)180end event181182183event ObjectStartup184LoadSpriteSheet("ARZ/Objects.gif")185186// Pillar frames187SpriteFrame(-28, -32, 56, 56, 59, 42)188SpriteFrame(-16, 24, 32, 8, 140, 80)189SpriteFrame(-16, 32, 32, 37, 173, 38)190191// Add the Falling Pillars to the debug mode object list192temp0 = 0193FallingPillar_startDebugID = DebugMode_ObjCount194while temp0 < 2195SetTableValue(TypeName[Falling Pillar], DebugMode_ObjCount, DebugMode_TypesTable)196SetTableValue(FallingPillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)197SetTableValue(FallingPillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)198DebugMode_ObjCount++199temp0++200loop201202foreach (TypeName[Falling Pillar], arrayPos0, ALL_ENTITIES)203object[arrayPos0].centerPos.y = object[arrayPos0].ypos204if object[arrayPos0].propertyValue == FPILLAR_STATIC205object[arrayPos0].state = FPILLAR_NOFALL206end if207next208end event209210211// ========================212// Editor Events213// ========================214215event RSDKEdit216if editor.returnVariable == true217switch editor.variableID218case EDIT_VAR_PROPVAL // property value219checkResult = object.propertyValue220break221222case 0 // type223checkResult = object.propertyValue224break225226end switch227else228switch editor.variableID229case EDIT_VAR_PROPVAL // property value230object.propertyValue = editor.variableValue231break232233case 0 // type234object.propertyValue = editor.variableValue235break236237end switch238end if239end event240241242event RSDKDraw243DrawSprite(0)244DrawSprite(1)245DrawSprite(2)246end event247248249event RSDKLoad250LoadSpriteSheet("ARZ/Objects.gif")251SpriteFrame(-28, -32, 56, 56, 59, 42)252SpriteFrame(-16, 24, 32, 8, 140, 80)253SpriteFrame(-16, 32, 32, 37, 173, 38)254255AddEditorVariable("type")256SetActiveVariable("type")257AddEnumVariable("Falling", FPILLAR_FALL)258AddEnumVariable("Static", FPILLAR_STATIC)259end event260261262