Path: blob/master/Sonic 1/Scripts/GHZ/CLedgeRight.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: C Ledge Right 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 : CLEDGER_ACTIVE15private alias 1 : CLEDGER_COLLAPSE16private alias 2 : CLEDGER_COLLAPSED17private alias 3 : CLEDGER_NONE18private alias 4 : CLEDGER_TILEDELAY19private alias 5 : CLEDGER_TILEFALL2021// Player Aliases22private alias object.xpos : player.xpos23private alias object.ypos : player.ypos24private alias object.yvel : player.yvel252627// ========================28// Function Declarations29// ========================3031reserve function CLedgeRight_DebugDraw32reserve function CLedgeRight_DebugSpawn333435// ========================36// Function Definitions37// ========================3839private function CLedgeRight_DebugDraw40DrawSprite(0)41end function424344private function CLedgeRight_DebugSpawn45CreateTempObject(TypeName[C Ledge Right], 0, object.xpos, object.ypos)46end function474849// ========================50// Events51// ========================5253event ObjectUpdate54switch object.state55case CLEDGER_ACTIVE56break5758case CLEDGER_COLLAPSE59if object.timer < 1060object.timer++61else62object.frame = 163temp0 = 064temp3 = object.ypos65temp3 -= 0x38000066temp4 = 3067while temp0 < 668temp1 = 069temp2 = object.xpos70temp2 -= 0x28000071while temp1 < 672CreateTempObject(TypeName[C Ledge Right], object.frame, temp2, temp3)73object[tempObjectPos].state = CLEDGER_TILEDELAY74object[tempObjectPos].delay = temp475object.frame++76temp1++77temp2 += 0x10000078temp4 -= 479loop80temp4 += 2281temp0++82temp3 += 0x10000083loop84PlaySfx(SfxName[Ledge Break L], false)85SetSfxAttributes(SfxName[Ledge Break L], -1, -100)86PlaySfx(SfxName[Ledge Break R], false)87SetSfxAttributes(SfxName[Ledge Break R], -1, 100)88object.timer = 089object.state++90end if91break9293case CLEDGER_COLLAPSED94if object.timer < 2095object.timer++96else97object.timer = 098object.state++99ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, object.xpos, object.ypos)100end if101break102103case CLEDGER_NONE104break105106case CLEDGER_TILEDELAY107if object.timer < object.delay108object.timer++109else110object.timer = 0111object.state++112end if113break114115case CLEDGER_TILEFALL116object.ypos += object.yvel117object.yvel += 0x4000118if object.outOfBounds == true119object.type = TypeName[Blank Object]120end if121break122123end switch124125if object.state < CLEDGER_NONE126foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)127if player[currentPlayer].yvel >= 0128temp0 = player[currentPlayer].xpos129temp0 -= object.xpos130temp0 >>= 17131temp0 += 24132if temp0 < 0133temp0 = 0134end if135if temp0 > 47136temp0 = 47137end if138GetTableValue(temp1, temp0, CLedgeLeft_heightArray)139temp1 -= 84140temp0 = temp1141temp0 += 32142BoxCollisionTest(C_PLATFORM, object.entityPos, -48, temp1, 48, temp0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)143if checkResult == true144player[currentPlayer].ypos += 0x40000145if object.state == CLEDGER_ACTIVE146object.state = CLEDGER_COLLAPSE147end if148end if149end if150next151end if152end event153154155event ObjectDraw156switch object.state157case CLEDGER_ACTIVE158case CLEDGER_COLLAPSE159DrawSprite(0)160break161162case CLEDGER_TILEDELAY163case CLEDGER_TILEFALL164DrawSprite(object.propertyValue)165break166167case CLEDGER_COLLAPSED168case CLEDGER_NONE169default170break171172end switch173end event174175176event ObjectStartup177LoadSpriteSheet("GHZ/Objects.gif")178179// 0 - Full Platform Frame180SpriteFrame(-48, -64, 96, 96, 1, 148)181182// All the Platform "Tile" Frames are done in a loop183temp0 = 148184while temp0 < 244 // sprY + height (148 + 96 = 244)185temp1 = 1186while temp1 < 97 // sprX + width (1 + 96 = 97)187SpriteFrame(-8, -8, 16, 16, temp1, temp0)188temp1 += 16189loop190temp0 += 16191loop192193SetTableValue(TypeName[C Ledge Right], DebugMode_ObjCount, DebugMode_TypesTable)194SetTableValue(CLedgeRight_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)195SetTableValue(CLedgeRight_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)196DebugMode_ObjCount++197end event198199200// ========================201// Editor Events202// ========================203204event RSDKDraw205DrawSprite(0)206207if editor.showGizmos == true208editor.drawingOverlay = true209210temp0 = 48; temp1 = 48; temp2 = 48; temp3 = 48;211CallFunction(EditorHelpers_DrawHitbox)212213editor.drawingOverlay = false214end if215end event216217218event RSDKLoad219LoadSpriteSheet("GHZ/Objects.gif")220SpriteFrame(-48, -64, 96, 96, 1, 148)221222// Although used by the object, it shouldn't be set by the editor223SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")224end event225226227