Path: blob/main/Scripts/R7/BreakSpikes.txt
1319 views
//----------------Sonic CD Break Spikes Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value1 : Object.XVelocity6#alias Object.Value2 : Object.YVelocity7#alias Object.Value3 : Object.YAcceleration89// Player Aliases10#alias Player.Value4 : Player.InvincibleTimer1112// Property Values13// All non-zero property values are for individual spike pieces14#alias 0 : BREAKSPIKES_MAIN15#alias 1 : BREAKSPIKES_DEBRIS_116#alias 2 : BREAKSPIKES_DEBRIS_217#alias 3 : BREAKSPIKES_DEBRIS_318#alias 4 : BREAKSPIKES_DEBRIS_41920// Ink Effects21#alias 2 : INK_ALPHA2223// Stage SFX24#alias 7 : SFX_S_CRUMBLE252627sub ObjectMain28if Object.PropertyValue == BREAKSPIKES_MAIN2930// Compare Metal Sonic's position with that of the spikes' to see if they should be broken3132// Take the spike's position and subtract 20 pixels from it33TempValue0 = Object.XPos34TempValue0 -= 0x1400003536ArrayPos0 = MetalSonic_EntityNo3738if Object[ArrayPos0].XPos > TempValue03940// Metal Sonic has passed these spikes, destroy them4142// Play the Crumble SFX43PlayStageSfx(SFX_S_CRUMBLE, false)4445#platform: Use_Haptics46// Do a strong shake47HapticEffect(96, 0, 0, 0)48#endplatform4950// Create a bunch of spike fragments51// Their property value is what frame they should use5253CreateTempObject(TypeName[Break Spikes], BREAKSPIKES_DEBRIS_1, Object.XPos, Object.YPos)54Object[TempObjectPos].XVelocity = 0x800055Object[TempObjectPos].YVelocity = -0x2000056Object[TempObjectPos].YAcceleration = 0x300057Object[TempObjectPos].InkEffect = INK_ALPHA58Object[TempObjectPos].Alpha = 2545960CreateTempObject(TypeName[Break Spikes], BREAKSPIKES_DEBRIS_2, Object.XPos, Object.YPos)61Object[TempObjectPos].XVelocity = 0x1000062Object[TempObjectPos].YVelocity = -0x4000063Object[TempObjectPos].YAcceleration = 0x300064Object[TempObjectPos].InkEffect = INK_ALPHA65Object[TempObjectPos].Alpha = 2546667CreateTempObject(TypeName[Break Spikes], BREAKSPIKES_DEBRIS_3, Object.XPos, Object.YPos)68Object[TempObjectPos].XVelocity = 0x1800069Object[TempObjectPos].YVelocity = -0x2000070Object[TempObjectPos].YAcceleration = 0x200071Object[TempObjectPos].InkEffect = INK_ALPHA72Object[TempObjectPos].Alpha = 2547374CreateTempObject(TypeName[Break Spikes], BREAKSPIKES_DEBRIS_4, Object.XPos, Object.YPos)75Object[TempObjectPos].XVelocity = 0x2000076Object[TempObjectPos].YVelocity = -0x4000077Object[TempObjectPos].YAcceleration = 0x400078Object[TempObjectPos].InkEffect = INK_ALPHA79Object[TempObjectPos].Alpha = 2548081// Clear the main spikes object82ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)83end if8485ArrayPos0 = 086else87// Spike fragment8889// Fade out90if Object.Alpha > 091Object.Alpha -= 292end if9394// Update movement95Object.XPos += Object.XVelocity96Object.YPos += Object.YVelocity9798// The top and bottom spikes get different gravities, which is why gravity is just stored as an Object Value in this case99Object.YVelocity += Object.YAcceleration100101if Object.OutOfBounds == true102// Unload as soon as out of view, as at that point the Object's no longer needed103104Object.Type = TypeName[Blank Object]105end if106end if107end sub108109110sub ObjectPlayerInteraction111// If the Spikes are all still together, then they can still damage Sonic112if Object.PropertyValue == BREAKSPIKES_MAIN113// Act as a box for the player114PlayerObjectCollision(C_BOX, -16, -15, 16, 16)115116// And now check for actual touching of the sharp spikes117if Player.YVelocity > -1118if Player.InvincibleTimer == 0119PlayerObjectCollision(C_TOUCH, -15, -16, 15, -12)120121if CheckResult == true122123// Damage the player124Player.State = Player_State_GotHit125126// Since the Player's been hit, they can no longer get the Heavy Metal Achievement127// (For refrence, the Heavy Metal Achievement has you get through the entire Metal Sonic race without getting hit)128Player.HeavyMetalFlag = false129130// Decide knockback direction based on if the player's behind or in front of this object131// The X Positions used are based on the centers of both entities132if Player.XPos > Object.XPos133Player.Speed = 0x20000134else135Player.Speed = -0x20000136end if137138end if139end if140end if141end if142143// Spike fragments don't really do anything, so there's nothing for them here144end sub145146147sub ObjectDraw148DrawSpriteFX(Object.PropertyValue, FX_INK, Object.XPos, Object.YPos)149end sub150151152sub ObjectStartup153154LoadSpriteSheet("Global/Items3.gif")155156// Spike Frames157158// 0 - Main Spikes frame159SpriteFrame(-16, -16, 32, 32, 50, 1)160161// 1-3 - Individual Spike Frames162SpriteFrame(-16, -16, 8, 32, 50, 1)163SpriteFrame(-8, -16, 8, 32, 50, 1)164SpriteFrame(0, -16, 8, 32, 50, 1)165SpriteFrame(8, -16, 8, 32, 50, 1)166167end sub168169170// ========================171// Editor Subs172// ========================173174sub RSDKDraw175DrawSprite(0)176end sub177178179sub RSDKLoad180LoadSpriteSheet("Global/Items3.gif")181SpriteFrame(-16, -16, 32, 32, 50, 1)182183// Although used by the object for its broken variants, it shouldn't be set by the editor184SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")185end sub186187188