Path: blob/master/Sonic 2/Scripts/HTZ/FPlatform.txt
1478 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.stoodAngle1617private alias 0 : FPLATFORM_IDLE18private alias 1 : FPLATFORM_FALLING_SOLID19private alias 2 : FPLATFORM_FALLING20private alias 3 : FPLATFORM_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_DebugSpawn343536private function FallPlatform_DebugDraw37DrawSprite(0)38end function394041private function FallPlatform_DebugSpawn42CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)43object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos44end function454647// ========================48// Events49// ========================5051event ObjectUpdate52if object.stood == true53if object.timer == 054object.priority = PRIORITY_ACTIVE55object.timer = 3056end if57if object.stoodAngle < 6458object.stoodAngle += 459end if60else61if object.stoodAngle > 062object.stoodAngle -= 463end if64end if6566temp0 = object.ypos67temp0 &= 0xFFFF000068switch object.state69case FPLATFORM_IDLE70temp1 = object.stoodAngle71temp1 <<= 172Sin(temp2, temp1)73temp2 <<= 974object.ypos = object.centerPos.y75object.ypos += temp276if object.propertyValue == 0 // Falling variant?77if object.timer != 078object.timer--79if object.timer == 080object.state++81object.timer = 3282end if83end if84end if85break8687case FPLATFORM_FALLING_SOLID88object.timer--89if object.timer == 090object.state++91foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)92BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)93if checkResult == true94player[currentPlayer].ypos += object.yvel95player[currentPlayer].yvel = object.yvel96player[currentPlayer].yvel -= 0x380097player[currentPlayer].gravity = GRAVITY_AIR98end if99next100end if101// [Fallthrough]102case FPLATFORM_FALLING103object.ypos += object.yvel104object.yvel += 0x3800105if object.outOfBounds == true106object.ypos = object.centerPos.y107object.yvel = 0108object.timer = 0109object.state++110end if111break112113case FPLATFORM_OFFSCREEN114if object.outOfBounds == true115object.state = 0116object.priority = PRIORITY_BOUNDS117end if118break119120end switch121122object.collisionOffset.y = object.ypos123object.collisionOffset.y &= 0xFFFF0000124object.collisionOffset.y -= temp0125object.stood = false126127if object.state < 2128temp1 = object.ypos129object.ypos = temp0130foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)131BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)132133if checkResult == true134object.stood = true135player[currentPlayer].ypos += object.collisionOffset.y136end if137next138object.ypos = temp1139end if140end event141142143event ObjectDraw144if object.state < 3145DrawSprite(0)146end if147end event148149150event ObjectStartup151LoadSpriteSheet("HTZ/Objects.gif")152SpriteFrame(-32, -12, 64, 32, 191, 223)153154foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)155object[arrayPos0].centerPos.y = object[arrayPos0].ypos156next157158SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)159SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)160SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)161DebugMode_ObjCount++162end event163164165// ========================166// Editor Events167// ========================168169event RSDKEdit170if editor.returnVariable == true171switch editor.variableID172case EDIT_VAR_PROPVAL // property value173checkResult = object.propertyValue174break175176case 0 // type177checkResult = object.propertyValue178break179180end switch181else182switch editor.variableID183case EDIT_VAR_PROPVAL // property value184object.propertyValue = editor.variableValue185break186187case 0 // type188object.propertyValue = editor.variableValue189break190191end switch192end if193end event194195196event RSDKDraw197DrawSprite(0)198end event199200201event RSDKLoad202LoadSpriteSheet("HTZ/Objects.gif")203SpriteFrame(-32, -12, 64, 32, 191, 223)204205AddEditorVariable("type")206SetActiveVariable("type")207AddEnumVariable("Falling Platform", 0)208AddEnumVariable("Static Platform", 1)209end event210211212