Path: blob/master/Sonic 1/Scripts/GHZ/FPlatform.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.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.gravity313233// ========================34// Function Declarations35// ========================3637reserve function FallPlatform_DebugDraw38reserve function FallPlatform_DebugSpawn394041// ========================42// Function Definitions43// ========================4445private function FallPlatform_DebugDraw46DrawSprite(0)47end function484950private function FallPlatform_DebugSpawn51CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)52object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos53end function545556// ========================57// Events58// ========================5960event ObjectUpdate61if object.stood == true62if object.timer == 063object.priority = PRIORITY_ACTIVE64object.timer = 3065end if6667if object.stoodAngle < 6468object.stoodAngle += 469end if70else71if object.stoodAngle > 072object.stoodAngle -= 473end if74end if7576temp0 = object.ypos77temp0 &= 0xFFFF00007879switch object.state80case FPLATFORM_IDLE81temp1 = object.stoodAngle82temp1 <<= 183Sin(temp2, temp1)84temp2 <<= 985object.ypos = object.centerPos.y86object.ypos += temp287if object.propertyValue == FPLATFORM_FALL88if object.timer != 089object.timer--90if object.timer == 091object.state++92object.timer = 3293end if94end if95end if96break9798case FPLATFORM_FALLING_SOLID99object.timer--100if object.timer == 0101object.state++102foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)103BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)104if checkResult == true105player[currentPlayer].ypos += object.yvel106player[currentPlayer].yvel = object.yvel107player[currentPlayer].yvel -= 0x3800108player[currentPlayer].gravity = GRAVITY_AIR109end if110next111end if112// [FallThrough]113case FPLATFORM_FALLING114object.ypos += object.yvel115object.yvel += 0x3800116if object.outOfBounds == true117object.ypos = object.centerPos.y118object.yvel = 0119object.timer = 0120object.state++121end if122break123124case FPLATFORM_OFFSCREEN125if object.outOfBounds == true126object.state = FPLATFORM_IDLE127object.priority = PRIORITY_BOUNDS128end if129break130131end switch132133object.collisionOffset.y = object.ypos134object.collisionOffset.y &= 0xFFFF0000135object.collisionOffset.y -= temp0136object.stood = false137138if object.state < FPLATFORM_FALLING139temp1 = object.ypos140141object.ypos = temp0142foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)143BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)144if checkResult == true145object.stood = true146player[currentPlayer].ypos += object.collisionOffset.y147end if148next149150object.ypos = temp1151end if152end event153154155event ObjectDraw156if object.state < FPLATFORM_OFFSCREEN157DrawSprite(0)158end if159end event160161162event ObjectStartup163LoadSpriteSheet("GHZ/Objects.gif")164SpriteFrame(-32, -14, 64, 32, 50, 18)165166foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)167object[arrayPos0].centerPos.y = object[arrayPos0].ypos168next169170SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)171SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)172SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)173DebugMode_ObjCount++174end event175176177// ========================178// Editor Events179// ========================180181event RSDKEdit182if editor.returnVariable == true183switch editor.variableID184case EDIT_VAR_PROPVAL // property value185checkResult = object.propertyValue186break187188case 0 // type189checkResult = object.propertyValue190break191192end switch193else194switch editor.variableID195case EDIT_VAR_PROPVAL // property value196object.propertyValue = editor.variableValue197break198199case 0 // type200object.propertyValue = editor.variableValue201break202203end switch204end if205end event206207208event RSDKDraw209DrawSprite(0)210211CheckEqual(editor.showGizmos, true)212temp0 = checkResult213CheckEqual(object.propertyValue, FPLATFORM_FALL)214temp0 &= checkResult215if temp0 == true216// Draw a dashed line to indicate that this platform is of the falling variety217// (Otherwise it's just the generic platform sprite, which is shared between two other objects)218219editor.drawingOverlay = true220221temp0 = object.ypos222223temp1 = object.ypos224temp1 += 0x60000225226temp2 = object.ypos227temp2 += 0x3E0000228229while temp0 < temp2230DrawLine(object.xpos, temp0, object.xpos, temp1, 255, 255, 255)231232temp0 += 0xC0000233temp1 += 0xC0000234loop235236editor.drawingOverlay = false237end if238end event239240241event RSDKLoad242LoadSpriteSheet("GHZ/Objects.gif")243SpriteFrame(-32, -14, 64, 32, 50, 18)244245AddEditorVariable("type")246SetActiveVariable("type")247AddEnumVariable("Falling Platform", FPLATFORM_FALL)248AddEnumVariable("Static Platform", FPLATFORM_STATIC)249end event250251252