Path: blob/master/Sonic 1/Scripts/GHZ/CLedgeLeft.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: C Ledge Left 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.delay1314private alias 0 : CLEDGEL_ACTIVE15private alias 1 : CLEDGEL_COLLAPSE16private alias 2 : CLEDGEL_COLLAPSED17private alias 3 : CLEDGEL_NONE18private alias 4 : CLEDGEL_TILEDELAY19private alias 5 : CLEDGEL_TILEFALL2021// Player Aliases22private alias object.xpos : player.xpos23private alias object.ypos : player.ypos24private alias object.yvel : player.yvel252627// ========================28// Function Declarations29// ========================3031reserve function CLedgeLeft_DebugDraw32reserve function CLedgeLeft_DebugSpawn333435// ========================36// Tables37// ========================3839// This table is used by CLedgeRight as well, which is why it's public40// (Neat note - in earlier versions of S1 this was a raw file, but after tables were introduced it was made to be like this instead)41public table CLedgeLeft_heightArray4232, 32, 32, 32, 32, 324332, 32, 33, 33, 34, 344435, 35, 36, 36, 37, 374538, 38, 39, 39, 40, 404641, 41, 42, 42, 43, 434744, 44, 45, 45, 46, 464847, 47, 48, 48, 48, 484948, 48, 48, 48, 48, 4850end table515253// ========================54// Function Definitions55// ========================5657private function CLedgeLeft_DebugDraw58DrawSprite(0)59end function606162private function CLedgeLeft_DebugSpawn63CreateTempObject(TypeName[C Ledge Left], 0, object.xpos, object.ypos)64end function656667// ========================68// Events69// ========================7071event ObjectUpdate72switch object.state73case CLEDGEL_NONE74break7576case CLEDGEL_COLLAPSE77if object.timer < 1078object.timer++79else80object.frame = 181temp0 = 082temp3 = object.ypos83temp3 -= 0x38000084temp4 = 1085while temp0 < 686temp1 = 087temp2 = object.xpos88temp2 -= 0x28000089while temp1 < 690CreateTempObject(TypeName[C Ledge Left], object.frame, temp2, temp3)91object[tempObjectPos].state = CLEDGEL_TILEDELAY92object[tempObjectPos].delay = temp493object.frame++94temp1++95temp2 += 0x10000096temp4 += 497loop98temp4 -= 2699temp0++100temp3 += 0x100000101loop102103// In initial versions this just played Sfx[Ledge Break], but a later update changed it104// and made it play a sound across both ears105106PlaySfx(SfxName[Ledge Break L], false)107SetSfxAttributes(SfxName[Ledge Break L], -1, -100)108PlaySfx(SfxName[Ledge Break R], false)109SetSfxAttributes(SfxName[Ledge Break R], -1, 100)110111object.timer = 0112113object.state++114end if115break116117case CLEDGEL_COLLAPSED118if object.timer < 20119object.timer++120else121object.timer = 0122object.state++123ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, object.xpos, object.ypos)124end if125break126127case CLEDGEL_NONE128break129130case CLEDGEL_TILEDELAY131if object.timer < object.delay132object.timer++133else134object.timer = 0135object.state++136end if137break138139case CLEDGEL_TILEFALL140object.ypos += object.yvel141object.yvel += 0x4000142if object.outOfBounds == true143object.type = TypeName[Blank Object]144end if145break146147end switch148149if object.state < CLEDGEL_NONE150foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)151if player[currentPlayer].yvel >= 0152temp0 = player[currentPlayer].xpos153temp0 -= object.xpos154temp0 >>= 17155temp0 += 24156if temp0 < 0157temp0 = 0158end if159if temp0 > 47160temp0 = 47161end if162temp2 = 47163temp2 -= temp0164GetTableValue(temp1, temp2, CLedgeLeft_heightArray)165temp1 -= 84166temp0 = temp1167temp0 += 32168BoxCollisionTest(C_PLATFORM, object.entityPos, -48, temp1, 48, temp0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)169if checkResult == true170player[currentPlayer].ypos += 0x40000171if object.state == CLEDGEL_ACTIVE172object.state = CLEDGEL_COLLAPSE173end if174end if175end if176next177end if178end event179180181event ObjectDraw182switch object.state183case CLEDGEL_ACTIVE184case CLEDGEL_COLLAPSE185DrawSprite(0)186break187188case CLEDGEL_TILEDELAY189case CLEDGEL_TILEFALL190DrawSprite(object.propertyValue)191break192193case CLEDGEL_COLLAPSED194case CLEDGEL_NONE195default196break197198end switch199end event200201202event ObjectStartup203LoadSpriteSheet("GHZ/Objects.gif")204205// 0 - Full Platform Frame206SpriteFrame(-48, -64, 96, 96, 1, 51)207208// All the Platform "Tile" Frames are done in a loop209temp0 = 51210while temp0 < 147 // sprY + height (51 + 96 = 147)211temp1 = 1212while temp1 < 97 // sprX + width (1 + 96 = 97)213SpriteFrame(-8, -8, 16, 16, temp1, temp0)214temp1 += 16215loop216217temp0 += 16218loop219220// This was hangin' out in the earliest S1 builds221// It's safe to assume that this is how it was done pre-tables, given that this object was done while the RSDKv4 spec was still being developed222// (Also separate other note - LoadTextFile had 3 paramters back then but in current versions in only has 2, that's another neat little change)223// LoadTextFile(MENU_2, "Data/Game/Misc/CLedgeMask.bin", false)224225SetTableValue(TypeName[C Ledge Left], DebugMode_ObjCount, DebugMode_TypesTable)226SetTableValue(CLedgeLeft_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)227SetTableValue(CLedgeLeft_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)228DebugMode_ObjCount++229end event230231232// ========================233// Editor Events234// ========================235236event RSDKDraw237DrawSprite(0)238239if editor.showGizmos == true240editor.drawingOverlay = true241242temp0 = 48; temp1 = 48; temp2 = 48; temp3 = 48;243CallFunction(EditorHelpers_DrawHitbox)244245editor.drawingOverlay = false246end if247end event248249250event RSDKLoad251LoadSpriteSheet("GHZ/Objects.gif")252SpriteFrame(-48, -64, 96, 96, 1, 51)253254// Although used by the object, it shouldn't be set by the editor255SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")256end event257258259