Path: blob/master/Sonic 1/Scripts/GHZ/BreakWall.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Breakable Wall Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011// Player Aliases12private alias object.state : player.state13private alias object.xpos : player.xpos14private alias object.speed : player.speed15private alias object.direction : player.direction16private alias object.animation : player.animation17private alias object.value40 : player.hitboxLeft18private alias object.value38 : player.hitboxTop19private alias object.value41 : player.hitboxRight20private alias object.value39 : player.hitboxBottom21private alias object.value16 : player.isSidekick2223private alias object.value17 : debugMode.currentSelection2425private alias 1 : SUPERSTATE_SUPER262728// ========================29// Function Declarations30// ========================3132reserve function EditorHelpers_DrawHitboxOutline33reserve function BreakableWall_DebugDraw34reserve function BreakableWall_DebugSpawn353637// ========================38// Static Values39// ========================4041private value BreakableWall_startDebugID = 0424344// ========================45// Function Definitions46// ========================4748private function BreakableWall_DebugDraw49temp0 = debugMode[0].currentSelection50temp0 -= BreakableWall_startDebugID51DrawSprite(temp0)52end function535455private function BreakableWall_DebugSpawn56temp0 = debugMode[0].currentSelection57temp0 -= BreakableWall_startDebugID58CreateTempObject(TypeName[Breakable Wall], temp0, object.xpos, object.ypos)59object[tempObjectPos].drawOrder = 460end function616263// ========================64// Events65// ========================6667event ObjectUpdate68if object.propertyValue > 269// Wall fragment, just fly through the air and unload when possible7071object.xpos += object.xvel72object.ypos += object.yvel73object.yvel += 0x70007475if object.outOfBounds == true76object.type = TypeName[Blank Object]77end if78else79foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)80checkResult = false8182if player[currentPlayer].state == Player_State_Roll83if player[currentPlayer].speed >= 0x4800084checkResult = true85end if8687if player[currentPlayer].speed <= -0x4800088checkResult = true89end if90end if9192if stage.playerListPos == PLAYER_KNUCKLES_A93// Knuckles can break all walls, regardless if he's rolling or not94// (Though, this implementation results in P2 Tails also being able to break all walls if Knux is P1...)95checkResult = true96end if9798if Player_superState == SUPERSTATE_SUPER99// Similarly, this also means P2 Tails can break any walls he pleases too...100checkResult = true101end if102103#platform: USE_STANDALONE104if checkResult == true105BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)106#endplatform107108#platform: USE_ORIGINS109if stage.playerListPos == PLAYER_AMY110if player[currentPlayer].isSidekick == false111if player[currentPlayer].animation == ANI_HAMMER_JUMP112checkResult = 2113end if114if player[currentPlayer].animation == ANI_HAMMER_DASH115checkResult = 2116end if117end if118end if119if checkResult != 0120switch checkResult121case 1122BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)123break124case 2125BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)126break127end switch128#endplatform129if checkResult == true130object.type = TypeName[Blank Object]131PlaySfx(SfxName[Block Break], false)132133temp0 = object.propertyValue134temp0 <<= 1135temp0 += 3136temp1 = temp0137temp1++138139temp2 = object.xpos140temp2 -= 0x80000141temp3 = object.xpos142temp3 += 0x80000143temp4 = object.ypos144temp4 -= 0x180000145146if player[currentPlayer].xpos < object.xpos147CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)148object[tempObjectPos].xvel = -0x60000149object[tempObjectPos].yvel = -0x60000150object[tempObjectPos].drawOrder = 4151152CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)153object[tempObjectPos].xvel = -0x40000154object[tempObjectPos].yvel = -0x50000155object[tempObjectPos].drawOrder = 4156temp4 += 0x100000157158CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)159object[tempObjectPos].xvel = -0x80000160object[tempObjectPos].yvel = -0x20000161object[tempObjectPos].drawOrder = 4162163CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)164object[tempObjectPos].xvel = -0x60000165object[tempObjectPos].yvel = -0x10000166object[tempObjectPos].drawOrder = 4167temp4 += 0x100000168169CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)170object[tempObjectPos].xvel = -0x80000171object[tempObjectPos].yvel = 0x20000172object[tempObjectPos].drawOrder = 4173174CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)175object[tempObjectPos].xvel = -0x60000176object[tempObjectPos].yvel = 0x10000177object[tempObjectPos].drawOrder = 4178temp4 += 0x100000179180CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)181object[tempObjectPos].xvel = -0x60000182object[tempObjectPos].yvel = 0x60000183object[tempObjectPos].drawOrder = 4184185CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)186object[tempObjectPos].xvel = -0x40000187object[tempObjectPos].yvel = 0x50000188object[tempObjectPos].drawOrder = 4189else190CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)191object[tempObjectPos].xvel = 0x40000192object[tempObjectPos].yvel = -0x50000193object[tempObjectPos].drawOrder = 4194195CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)196object[tempObjectPos].xvel = 0x60000197object[tempObjectPos].yvel = -0x60000198object[tempObjectPos].drawOrder = 4199temp4 += 0x100000200201CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)202object[tempObjectPos].xvel = 0x60000203object[tempObjectPos].yvel = -0x10000204object[tempObjectPos].drawOrder = 4205206CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)207object[tempObjectPos].xvel = 0x80000208object[tempObjectPos].yvel = -0x20000209object[tempObjectPos].drawOrder = 4210temp4 += 0x100000211212CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)213object[tempObjectPos].xvel = 0x60000214object[tempObjectPos].yvel = 0x10000215object[tempObjectPos].drawOrder = 4216217CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)218object[tempObjectPos].xvel = 0x80000219object[tempObjectPos].yvel = 0x20000220object[tempObjectPos].drawOrder = 4221temp4 += 0x100000222223CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)224object[tempObjectPos].xvel = 0x40000225object[tempObjectPos].yvel = 0x50000226object[tempObjectPos].drawOrder = 4227228CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)229object[tempObjectPos].xvel = 0x60000230object[tempObjectPos].yvel = 0x60000231object[tempObjectPos].drawOrder = 4232end if233234if player[currentPlayer].animation == ANI_GLIDING235// Make Knuckles drop, since he's collided into an unclimbable wall236player[currentPlayer].animation = ANI_GLIDING_DROP237player[currentPlayer].state = Player_State_GlideDrop238if player[currentPlayer].direction == FACING_LEFT239FlipSign(player[currentPlayer].speed)240end if241end if242end if243else244BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)245end if246next247end if248end event249250251event ObjectDraw252DrawSprite(object.propertyValue)253end event254255256event ObjectStartup257LoadSpriteSheet("GHZ/Objects.gif")258259foreach (TypeName[Breakable Wall], arrayPos0, ALL_ENTITIES)260object[arrayPos0].drawOrder = 4261next262263// 0 - Left Wall Frame264SpriteFrame(-16, -32, 32, 64, 191, 146)265266// 1 - Middle Wall Frame267SpriteFrame(-16, -32, 32, 64, 207, 146)268269// 2 - Right Wall Frame270SpriteFrame(-16, -32, 32, 64, 223, 146)271272// 3-8 - Wall Fragment Frames273SpriteFrame(-8, -8, 16, 16, 191, 146)274SpriteFrame(-8, -8, 16, 16, 207, 146)275SpriteFrame(-8, -8, 16, 16, 207, 146)276SpriteFrame(-8, -8, 16, 16, 223, 146)277SpriteFrame(-8, -8, 16, 16, 223, 146)278SpriteFrame(-8, -8, 16, 16, 239, 146)279280// Add the object to the Debug Object List thrice, for every type281temp0 = 0282BreakableWall_startDebugID = DebugMode_ObjCount283while temp0 < 3284SetTableValue(TypeName[Breakable Wall], DebugMode_ObjCount, DebugMode_TypesTable)285SetTableValue(BreakableWall_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)286SetTableValue(BreakableWall_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)287DebugMode_ObjCount++288temp0++289loop290end event291292293// ========================294// Editor Events295// ========================296297event RSDKEdit298if editor.returnVariable == true299switch editor.variableID300case EDIT_VAR_PROPVAL // property value301checkResult = object.propertyValue302break303304case 0 // type305checkResult = object.propertyValue306break307308end switch309else310switch editor.variableID311case EDIT_VAR_PROPVAL // property value312object.propertyValue = editor.variableValue313break314315case 0 // type316object.propertyValue = editor.variableValue317break318319end switch320end if321end event322323324event RSDKDraw325DrawSprite(object.propertyValue)326327if editor.showGizmos == true328editor.drawingOverlay = true329330// These objects are made to blend in with the terrain, give them a little outline to make them more distinct331332temp0 = 16; temp1 = 32; temp2 = 16; temp3 = 32;333CallFunction(EditorHelpers_DrawHitbox)334335editor.drawingOverlay = false336end if337end event338339340event RSDKLoad341LoadSpriteSheet("GHZ/Objects.gif")342SpriteFrame(-16, -32, 32, 64, 191, 146)343SpriteFrame(-16, -32, 32, 64, 207, 146)344SpriteFrame(-16, -32, 32, 64, 223, 146)345346AddEditorVariable("type")347SetActiveVariable("type")348AddEnumVariable("Left", 0)349AddEnumVariable("Middle", 1)350AddEnumVariable("Right", 2)351end event352353354