Path: blob/master/Sonic 2/Scripts/ARZ/FPlatform.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Fall Platform 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 : FPLATFORM_FALL19private alias 1 : FPLATFORM_STATIC2021// States22private alias 0 : FPLATFORM_IDLE23private alias 1 : FPLATFORM_FALLING_SOLID24private alias 2 : FPLATFORM_FALLING25private alias 3 : FPLATFORM_OFFSCREEN2627// Player Aliases28private alias object.ypos : player.ypos29private alias object.yvel : player.yvel30private alias object.gravity : player.gravity3132private alias object.value17 : debugMode.currentSelection333435// ========================36// Function Declarations37// ========================3839reserve function FallPlatform_DebugDraw40reserve function FallPlatform_DebugSpawn414243// ========================44// Static Values45// ========================4647private value FallPlatform_startDebugID = 0484950// ========================51// Function Definitions52// ========================5354private function FallPlatform_DebugDraw55DrawSprite(0)56end function575859private function FallPlatform_DebugSpawn60temp0 = debugMode[0].currentSelection61temp0 -= FallPlatform_startDebugID62CreateTempObject(TypeName[Fall Platform], temp0, object.xpos, object.ypos)63object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos64end function656667// ========================68// Events69// ========================7071event ObjectUpdate72if object.stood == true73if object.timer == 074object.priority = PRIORITY_ACTIVE75object.timer = 3076end if7778if object.stoodAngle < 6479object.stoodAngle += 480end if81else82if object.stoodAngle > 083object.stoodAngle -= 484end if85end if8687temp0 = object.ypos88temp0 &= 0xFFFF000089switch object.state90case FPLATFORM_IDLE91temp1 = object.stoodAngle92temp1 <<= 193Sin(temp2, temp1)94temp2 <<= 995object.ypos = object.centerPos.y96object.ypos += temp297if object.propertyValue == FPLATFORM_FALL98if object.timer != 099object.timer--100if object.timer == 0101object.state++102object.timer = 32103end if104end if105end if106break107108case FPLATFORM_FALLING_SOLID109object.timer--110if object.timer == 0111object.state++112foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)113BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 13, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)114if checkResult == true115player[currentPlayer].ypos += object.yvel116player[currentPlayer].yvel = object.yvel117player[currentPlayer].yvel -= 0x3800118player[currentPlayer].gravity = GRAVITY_AIR119end if120next121end if122// Fall-through123124case FPLATFORM_FALLING125object.ypos += object.yvel126object.yvel += 0x3800127if object.outOfBounds == true128object.ypos = object.centerPos.y129object.yvel = 0130object.timer = 0131object.state++132end if133break134135case FPLATFORM_OFFSCREEN136if object.outOfBounds == true137object.state = 0138object.priority = PRIORITY_BOUNDS139end if140break141end switch142143object.collisionOffset.y = object.ypos144object.collisionOffset.y &= 0xFFFF0000145object.collisionOffset.y -= temp0146object.stood = false147148if object.state < FPLATFORM_FALLING149temp1 = object.ypos150151object.ypos = temp0152foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)153BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)154if checkResult == true155object.stood = true156player[currentPlayer].ypos += object.collisionOffset.y157end if158next159160object.ypos = temp1161end if162end event163164165event ObjectDraw166if object.state < FPLATFORM_OFFSCREEN167DrawSprite(0)168end if169end event170171172event ObjectStartup173LoadSpriteSheet("ARZ/Objects.gif")174SpriteFrame(-32, -13, 64, 45, 126, 145)175176foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)177object[arrayPos0].centerPos.y = object[arrayPos0].ypos178next179180temp0 = 0181FallPlatform_startDebugID = DebugMode_ObjCount182while temp0 < 2183SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)184SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)185SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)186DebugMode_ObjCount++187temp0++188loop189end event190191192// ========================193// Editor Events194// ========================195196event RSDKEdit197if editor.returnVariable == true198switch editor.variableID199case EDIT_VAR_PROPVAL // property value200checkResult = object.propertyValue201break202203case 0 // type204checkResult = object.propertyValue205break206end switch207else208switch editor.variableID209case EDIT_VAR_PROPVAL // property value210object.propertyValue = editor.variableValue211break212213case 0 // type214object.propertyValue = editor.variableValue215break216end switch217end if218end event219220221event RSDKDraw222DrawSprite(0)223end event224225226event RSDKLoad227LoadSpriteSheet("ARZ/Objects.gif")228SpriteFrame(-32, -13, 64, 45, 126, 145)229230AddEditorVariable("type")231SetActiveVariable("type")232AddEnumVariable("Falling Platform", FPLATFORM_FALL)233AddEnumVariable("Static Platform", FPLATFORM_STATIC)234end event235236237