Path: blob/master/Sonic 1/Scripts/SLZ/FallingPlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// 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.stoodAngle1617private alias 0 : FALLPLATFORM_IDLE18private alias 1 : FALLPLATFORM_FALLING_SOLID19private alias 2 : FALLPLATFORM_FALLING20private alias 3 : FALLPLATFORM_OFFSCREEN2122// Player Aliases23private alias object.ypos : player.ypos24private alias object.yvel : player.yvel25private alias object.gravity : player.gravity262728// ========================29// Function Declarations30// ========================3132reserve function FallPlatform_DebugDraw33reserve function FallPlatform_DebugSpawn343536// ========================37// Function Definitions38// ========================3940private function FallPlatform_DebugDraw41DrawSprite(0)42end function434445private function FallPlatform_DebugSpawn46CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)47object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos48end function495051// ========================52// Events53// ========================5455event ObjectUpdate56if object.stood == true57if object.timer == 058object.priority = PRIORITY_ACTIVE59object.timer = 3060end if6162if object.stoodAngle < 6463object.stoodAngle += 464end if65else66if object.stoodAngle > 067object.stoodAngle -= 468end if69end if7071temp0 = object.ypos72temp0 &= 0xFFFF00007374switch object.state75case FALLPLATFORM_IDLE76temp1 = object.stoodAngle77temp1 <<= 178Sin(temp2, temp1)79temp2 <<= 980object.ypos = object.centerPos.y81object.ypos += temp282if object.timer != 083object.timer--84if object.timer == 085object.state++86object.timer = 3287end if88end if89break9091case FALLPLATFORM_FALLING_SOLID92object.timer--93if object.timer == 094object.state++95foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)96BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)97if checkResult == true98player[currentPlayer].ypos += object.yvel99player[currentPlayer].yvel = object.yvel100player[currentPlayer].yvel -= 0x3800101player[currentPlayer].gravity = GRAVITY_AIR102end if103next104end if105// [Fallthrough]106case FALLPLATFORM_FALLING107object.ypos += object.yvel108object.yvel += 0x3800109110if object.outOfBounds == true111object.ypos = object.centerPos.y112object.yvel = 0113object.timer = 0114object.state++115end if116break117118case FALLPLATFORM_OFFSCREEN119if object.outOfBounds == true120object.state = FALLPLATFORM_IDLE121object.priority = PRIORITY_BOUNDS122end if123break124125end switch126127object.collisionOffset.y = object.ypos128object.collisionOffset.y &= 0xFFFF0000129object.collisionOffset.y -= temp0130object.stood = false131132if object.state < FALLPLATFORM_FALLING133temp1 = object.ypos134object.ypos = temp0135foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)136BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)137if checkResult == true138object.stood = true139player[currentPlayer].ypos += object.collisionOffset.y140end if141next142object.ypos = temp1143end if144end event145146147event ObjectDraw148if object.state < FALLPLATFORM_OFFSCREEN149DrawSprite(0)150end if151end event152153154event ObjectStartup155LoadSpriteSheet("SLZ/Objects.gif")156SpriteFrame(-32, -8, 64, 32, 67, 26)157158foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)159object[arrayPos0].centerPos.y = object[arrayPos0].ypos160next161162SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)163SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)164SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)165DebugMode_ObjCount++166end event167168169// ========================170// Editor Events171// ========================172173event RSDKDraw174DrawSprite(0)175end event176177178event RSDKLoad179LoadSpriteSheet("SLZ/Objects.gif")180SpriteFrame(-32, -8, 64, 32, 67, 26)181182SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")183end event184185186