Path: blob/main/Scripts/R1/BreakWall.txt
1319 views
//---------------Sonic CD Breakable Wall Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.XVelocity6#alias Object.Value1 : Object.YVelocity78// Global SFX9#alias 22 : SFX_G_EXPLOSION1011// Property Values12#alias 0 : VARIANT_1_SMALL13#alias 1 : VARIANT_1_BIG_LEFT14#alias 2 : VARIANT_1_BIG_MIDDLE15#alias 3 : VARIANT_1_BIG_RIGHT1617#alias 4 : VARIANT_2_SMALL18#alias 5 : VARIANT_2_BIG_LEFT19#alias 6 : VARIANT_2_BIG_MIDDLE20#alias 7 : VARIANT_2_BIG_RIGHT2122// from 8 onwards it will be considered debris232425sub ObjectMain26if Object.PropertyValue > 727Object.XPos += Object.XVelocity28Object.YPos += Object.YVelocity29Object.YVelocity += 0x400030if Object.OutOfBounds == true31Object.Type = TypeName[Blank Object]32end if33end if34end sub353637sub ObjectPlayerInteraction38// Checks:39// That the object is not debris40// The Player is rolling/jumping, if this one doesn't happen then it will act like a normal wall41// The Player collided42if Object.PropertyValue < 843// if Player.Animation == ANI_JUMPING // Standalone/Preplus check44CheckResult = false45if Player.Animation == ANI_JUMPING46CheckResult = true47end if48#platform: Use_Origins49if Stage.PlayerListPos == PLAYER_KNUCKLES50CheckResult = true51end if52if Stage.PlayerListPos == PLAYER_AMY53if Player.Animation == ANI_HAMMER_JUMP54CheckResult = true55end if56if Player.Animation == ANI_HAMMER_DASH57CheckResult = true58end if59end if60#endplatform61if CheckResult == true62#platform: Use_Origins63PlayerObjectCollision(C_ENEMY, -17, -24, 17, 24)64#endplatform65#platform: Use_Standalone66PlayerObjectCollision(C_TOUCH, -17, -24, 17, 24)67#endplatform68if CheckResult == true6970Object.Type = TypeName[Blank Object]71PlaySfx(SFX_G_EXPLOSION, false)72TempValue0 = Object.PropertyValue73TempValue0 *= 674TempValue0 += 87576TempValue1 = Object.XPos77TempValue1 -= 0x800007879TempValue2 = Object.XPos80TempValue2 += 0x800008182TempValue3 = Object.YPos83TempValue3 -= 0x1000008485if Player.XPos < Object.XPos86CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)87Object[TempObjectPos].XVelocity = -0x3000088Object[TempObjectPos].YVelocity = -0x2000089Object[TempObjectPos].DrawOrder = 490TempValue0++9192CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)93Object[TempObjectPos].XVelocity = -0x2000094Object[TempObjectPos].YVelocity = -0x2000095Object[TempObjectPos].DrawOrder = 496TempValue0++9798TempValue3 += 0x10000099CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)100Object[TempObjectPos].XVelocity = -0x40000101Object[TempObjectPos].YVelocity = -0x10000102Object[TempObjectPos].DrawOrder = 4103TempValue0++104105CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)106Object[TempObjectPos].XVelocity = -0x30000107Object[TempObjectPos].YVelocity = -0x10000108Object[TempObjectPos].DrawOrder = 4109TempValue0++110111TempValue3 += 0x100000112CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)113Object[TempObjectPos].XVelocity = -0x30000114Object[TempObjectPos].YVelocity = 0x10000115Object[TempObjectPos].DrawOrder = 4116TempValue0++117118CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)119Object[TempObjectPos].XVelocity = -0x20000120Object[TempObjectPos].YVelocity = 0x10000121Object[TempObjectPos].DrawOrder = 4122TempValue0++123124TempValue3 += 0x100000125else126CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)127Object[TempObjectPos].XVelocity = 0x20000128Object[TempObjectPos].YVelocity = -0x20000129Object[TempObjectPos].DrawOrder = 4130TempValue0++131132CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)133Object[TempObjectPos].XVelocity = 0x30000134Object[TempObjectPos].YVelocity = -0x20000135Object[TempObjectPos].DrawOrder = 4136TempValue0++137138TempValue3 += 0x100000139CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)140Object[TempObjectPos].XVelocity = 0x30000141Object[TempObjectPos].YVelocity = -0x10000142Object[TempObjectPos].DrawOrder = 4143TempValue0++144145CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)146Object[TempObjectPos].XVelocity = 0x40000147Object[TempObjectPos].YVelocity = -0x10000148Object[TempObjectPos].DrawOrder = 4149TempValue0++150151TempValue3 += 0x100000152CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)153Object[TempObjectPos].XVelocity = 0x20000154Object[TempObjectPos].YVelocity = 0x10000155Object[TempObjectPos].DrawOrder = 4156TempValue0++157158CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)159Object[TempObjectPos].XVelocity = 0x30000160Object[TempObjectPos].YVelocity = 0x10000161Object[TempObjectPos].DrawOrder = 4162TempValue0++163TempValue3 += 0x100000164end if165end if166else167// "Fake" Wall Collision168PlayerObjectCollision(C_TOUCH, -17, -24, 16, 24)169if CheckResult == true170if Player.XPos < Object.XPos171Player.XPos = Player.CollisionLeft172Player.XPos <<= 16173Player.XPos += Object.XPos174Player.XPos -= 0x100000175Player.Speed = 0176Player.XVelocity = 0177if Player.Right == true178if Player.Direction == FACING_RIGHT179Player.Pushing = 2180end if181end if182else183Player.XPos = Player.CollisionRight184Player.XPos <<= 16185Player.XPos += Object.XPos186Player.XPos += 0x100000187Player.Speed = 0188Player.XVelocity = 0189if Player.Direction == FACING_LEFT190Player.Pushing = 2191end if192end if193end if194end if195end if196end sub197198199sub ObjectDraw200DrawSprite(Object.PropertyValue)201end sub202203204sub ObjectStartup205LoadSpriteSheet("R1/Objects2.gif")206207// Variant 1208SpriteFrame(-16, -24, 32, 48, 190, 1) // #0 - BreakWall singular piece209SpriteFrame(-16, -24, 32, 48, 223, 1) // #1 - BreakWall left piece210SpriteFrame(-16, -24, 32, 48, 190, 50) // #2 - BreakWall middle piece211SpriteFrame(-16, -24, 32, 48, 223, 50) // #3 - BreakWall right piece212// Variant 2213SpriteFrame(-16, -24, 32, 48, 190, 99) // #4 - BreakWall singular piece214SpriteFrame(-16, -24, 32, 48, 223, 99) // #5 - BreakWall left piece215SpriteFrame(-16, -24, 32, 48, 190, 148) // #6 - BreakWall middle piece216SpriteFrame(-16, -24, 32, 48, 223, 148) // #7 - BreakWall right piece217218// Variant 1 debris chunks219220// Debris chunks BreakWall singular piece221TempValue0 = 0222TempValue3 = 1223while TempValue0 < 3224TempValue1 = 0225TempValue2 = 190226while TempValue1 < 2227SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)228TempValue1++229TempValue2 += 16230loop231TempValue0++232TempValue3 += 16233loop234235// Debris chunks BreakWall left piece236TempValue0 = 0237TempValue3 = 1238while TempValue0 < 3239TempValue1 = 0240TempValue2 = 223241while TempValue1 < 2242SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)243TempValue1++244TempValue2 += 16245loop246TempValue0++247TempValue3 += 16248loop249250// Debris chunks BreakWall middle piece251TempValue0 = 0252TempValue3 = 50253while TempValue0 < 3254TempValue1 = 0255TempValue2 = 190256while TempValue1 < 2257SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)258TempValue1++259TempValue2 += 16260loop261TempValue0++262TempValue3 += 16263loop264265// Debris chunks BreakWall right piece266TempValue0 = 0267TempValue3 = 50268while TempValue0 < 3269TempValue1 = 0270TempValue2 = 223271while TempValue1 < 2272SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)273TempValue1++274TempValue2 += 16275loop276TempValue0++277TempValue3 += 16278loop279280// Variant 2 debris chunks281282// Debris chunks BreakWall singular piece283TempValue0 = 0284TempValue3 = 99285while TempValue0 < 3286TempValue1 = 0287TempValue2 = 190288while TempValue1 < 2289SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)290TempValue1++291TempValue2 += 16292loop293TempValue0++294TempValue3 += 16295loop296297// Debris chunks BreakWall left piece298TempValue0 = 0299TempValue3 = 99300while TempValue0 < 3301TempValue1 = 0302TempValue2 = 223303while TempValue1 < 2304SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)305TempValue1++306TempValue2 += 16307loop308TempValue0++309TempValue3 += 16310loop311312// Debris chunks BreakWall middle piece313TempValue0 = 0314TempValue3 = 148315while TempValue0 < 3316TempValue1 = 0317TempValue2 = 190318while TempValue1 < 2319SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)320TempValue1++321TempValue2 += 16322loop323TempValue0++324TempValue3 += 16325loop326327// Debris chunks BreakWall right piece328TempValue0 = 0329TempValue3 = 148330while TempValue0 < 3331TempValue1 = 0332TempValue2 = 223333while TempValue1 < 2334SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)335TempValue1++336TempValue2 += 16337loop338TempValue0++339TempValue3 += 16340loop341342// original code have this below LoadSpriteSheet, moved for consistency with the rest343ArrayPos0 = 32344while ArrayPos0 < 1056345if Object[ArrayPos0].Type == TypeName[Breakable Wall]346Object[ArrayPos0].DrawOrder = 4347end if348ArrayPos0++349loop350end sub351352353// ========================354// Editor Subs355// ========================356357sub RSDKEdit358if Editor.ReturnVariable == true359switch Editor.VariableID360case EDIT_VAR_PROPVAL // Property Value361CheckResult = Object.PropertyValue362CheckResult &= 7363break364case 0 // type365CheckResult = Object.PropertyValue366CheckResult &= 7367break368end switch369else370switch Editor.VariableID371case EDIT_VAR_PROPVAL // Property Value372Object.PropertyValue = Editor.VariableValue373Object.PropertyValue &= 7374break375case 0 // type376Object.PropertyValue = Editor.VariableValue377Object.PropertyValue &= 7378break379end switch380end if381end sub382383384sub RSDKDraw385DrawSprite(Object.PropertyValue)386end sub387388389sub RSDKLoad390LoadSpriteSheet("R1/Objects2.gif")391392// Variant 1393SpriteFrame(-16, -24, 32, 48, 190, 1) // #0 - BreakWall singular piece394SpriteFrame(-16, -24, 32, 48, 223, 1) // #1 - BreakWall left piece395SpriteFrame(-16, -24, 32, 48, 190, 50) // #2 - BreakWall middle piece396SpriteFrame(-16, -24, 32, 48, 223, 50) // #3 - BreakWall right piece397// Variant 2398SpriteFrame(-16, -24, 32, 48, 190, 99) // #4 - BreakWall singular piece399SpriteFrame(-16, -24, 32, 48, 223, 99) // #5 - BreakWall left piece400SpriteFrame(-16, -24, 32, 48, 190, 148) // #6 - BreakWall middle piece401SpriteFrame(-16, -24, 32, 48, 223, 148) // #7 - BreakWall right piece402403404AddEditorVariable("type")405SetActiveVariable("type")406AddEnumVariable("Variant 1 (Single)", 0)407AddEnumVariable("Variant 1 (Left)", 1)408AddEnumVariable("Variant 1 (Middle)", 2)409AddEnumVariable("Variant 1 (Right)", 3)410AddEnumVariable("Variant 2 (Single)", 4)411AddEnumVariable("Variant 2 (Left)", 5)412AddEnumVariable("Variant 2 (Middle)", 6)413AddEnumVariable("Variant 2 (Right)", 7)414end sub415416417