Path: blob/master/Sonic 2/Scripts/MPZ/FPlatform.txt
1480 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.timer12private alias object.value1 : object.centerPos.y13private alias object.value2 : object.stoodPlayers14private alias object.value31 : object.wrapOffset.y1516// Types17private alias 0 : FPLATFORM_FALL18private alias 1 : FPLATFORM_STATIC1920// States21private alias 0 : FPLATFORM_IDLE22private alias 1 : FPLATFORM_FALLING_SOLID23private alias 2 : FPLATFORM_FALLING24private alias 3 : FPLATFORM_OFFSCREEN2526// Player Aliases27private alias object.ypos : player.ypos28private alias object.yvel : player.yvel29private alias object.gravity : player.gravity303132// ========================33// Function Declarations34// ========================3536reserve function FallPlatform_DebugDraw37reserve function FallPlatform_DebugSpawn383940// ========================41// Function Definitions42// ========================4344private function FallPlatform_DebugDraw45DrawSprite(0)46end function474849private function FallPlatform_DebugSpawn50CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)51object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos52end function535455// ========================56// Events57// ========================5859event ObjectUpdate60temp0 = object.ypos61temp0 &= 0xFFFF00006263switch object.state64case FPLATFORM_IDLE65if object.propertyValue == 066if object.timer != 067object.timer--68if object.timer == 069object.state++70object.timer = 3271end if72end if73end if74break7576case FPLATFORM_FALLING_SOLID77object.timer--78if object.timer == 079object.state++80foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)81BoxCollisionTest(C_SOLID, object.entityPos, -32, -12, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)82if checkResult == COL_TOP83player[currentPlayer].ypos += object.yvel84player[currentPlayer].yvel = object.yvel85player[currentPlayer].yvel -= 0x380086player[currentPlayer].gravity = GRAVITY_AIR87end if88next89end if90// [Fallthrough]91case FPLATFORM_FALLING92object.ypos += object.yvel93object.yvel += 0x38009495if object.outOfBounds == true96object.ypos = object.centerPos.y97object.ypos += object.wrapOffset.y98object.yvel = 099object.timer = 0100object.state++101end if102break103104case FPLATFORM_OFFSCREEN105if object.outOfBounds == true106object.state = FPLATFORM_IDLE107object.priority = PRIORITY_BOUNDS108end if109break110111end switch112113temp7 = object.ypos114temp7 &= 0xFFFF0000115temp7 -= temp0116if object.state < FPLATFORM_FALLING117temp2 = 0118119foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)120GetBit(temp0, object.stoodPlayers, temp2)121if temp0 == true122player[currentPlayer].ypos += temp7123end if124125SetBit(object.stoodPlayers, temp2, false)126BoxCollisionTest(C_SOLID, object.entityPos, -32, -12, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)127switch checkResult128case COL_TOP129SetBit(object.stoodPlayers, temp2, true)130if object.timer == 0131if object.state == FPLATFORM_IDLE132object.priority = PRIORITY_ACTIVE133object.timer = 30134end if135end if136break137138case COL_BOTTOM139if player[currentPlayer].gravity == GRAVITY_GROUND140CallFunction(Player_Kill)141end if142break143end switch144145temp2++146next147end if148end event149150151event ObjectDraw152if object.state < FPLATFORM_OFFSCREEN153DrawSprite(0)154end if155end event156157158event ObjectStartup159LoadSpriteSheet("MPZ/Objects.gif")160SpriteFrame(-32, -12, 64, 24, 383, 207)161162foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)163object[arrayPos0].centerPos.y = object[arrayPos0].ypos164next165166SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)167SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)168SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)169DebugMode_ObjCount++170end event171172173// ========================174// Editor Events175// ========================176177event RSDKEdit178if editor.returnVariable == true179switch editor.variableID180case EDIT_VAR_PROPVAL // property value181checkResult = object.propertyValue182break183184case 0 // type185checkResult = object.propertyValue186break187188end switch189else190switch editor.variableID191case EDIT_VAR_PROPVAL // property value192object.propertyValue = editor.variableValue193break194195case 0 // type196object.propertyValue = editor.variableValue197break198199end switch200end if201end event202203204event RSDKDraw205DrawSprite(0)206end event207208209event RSDKLoad210LoadSpriteSheet("MPZ/Objects.gif")211SpriteFrame(-32, -12, 64, 24, 383, 207)212213AddEditorVariable("type")214SetActiveVariable("type")215AddEnumVariable("Falling Platform", FPLATFORM_FALL)216AddEnumVariable("Static Platform", FPLATFORM_STATIC)217end event218219220