Path: blob/main/Scripts/R7/VerticalDoor.txt
1319 views
//---------------Sonic CD Vertical Door Script----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.DrawPosY67// HUD Alias8#alias Object[24].PropertyValue : HUD.CurrentTimePeriod910// States11#alias 0 : VERTICALDOOR_CLOSED12#alias 1 : VERTICALDOOR_START_OPENING13#alias 2 : VERTICALDOOR_END_CLOSING14#alias 3 : VERTICALDOOR_END_OPENED15#alias 4 : VERTICALDOOR_END_CLOSING_METAL16#alias 5 : VERTICALDOOR_START_OPENED17#alias 6 : VERTICALDOOR_END_CLOSED_SONIC1819// Time Periods20#alias 2 : TIME_GOOD_FUTURE2122// Stage SFX23#alias 3 : SFX_S_DOORCLOSE242526sub ObjectMain27switch Object.State28case VERTICALDOOR_START_OPENING29if Object.DrawPosY < 0x40000030Object.DrawPosY += 0x2000031Object.YPos -= 0x2000032else33Object.State = VERTICALDOOR_START_OPENED34end if35break3637case VERTICALDOOR_END_CLOSING38if Object.DrawPosY > 0x0000039Object.DrawPosY -= 0x2000040Object.YPos += 0x2000041else42Object.State = VERTICALDOOR_END_CLOSED_SONIC43end if44break4546case VERTICALDOOR_END_OPENED47TempValue0 = Player.CollisionRight48TempValue0 += 1649TempValue0 <<= 1650TempValue0 += Object.XPos51if Player.XPos > TempValue052// The Player is past the door, meaning Sonic's won5354#platform: Use_Origins55// There can only be one, let the game know we've killed Metal Sonic56// -> This doesn't really seem to do much, the NOTIFY_BOSS_END is what triggers all the fancy screens and such57EngineCallback(NOTIFY_KILL_BOSS)58#endplatform5960// From here, do the standard closing routine61Object.State = VERTICALDOOR_END_CLOSING62PlayStageSfx(SFX_S_DOORCLOSE, false)63else64if Object[+2].XPos > Object.XPos65// If Metal Sonic is past the door66Object.State = VERTICALDOOR_END_CLOSING_METAL67PlayStageSfx(SFX_S_DOORCLOSE, false)68end if69end if70break7172case VERTICALDOOR_END_CLOSING_METAL73if Object.DrawPosY > 0x0000074Object.DrawPosY -= 0x2000075Object.YPos += 0x2000076end if77break7879end switch8081end sub828384sub ObjectPlayerInteraction8586switch Object.State87case VERTICALDOOR_CLOSED88// Act as a tall vertical wall89PlayerObjectCollision(C_BOX, -16, -32, 16, 64)90break9192case VERTICALDOOR_START_OPENING93case VERTICALDOOR_START_OPENED94// Acting as a comparatively shorter wall (it's still pretty tall though!)95PlayerObjectCollision(C_BOX, -16, -32, 16, 32)96break9798case VERTICALDOOR_END_CLOSING99case VERTICALDOOR_END_CLOSED_SONIC100// Acting as a *really* tall vertical wall101PlayerObjectCollision(C_BOX, -16, -32, 16, 128)102103// Enforce right bounds, make sure the player doesn't leave where they should be104TempValue0 = Player.CollisionRight105TempValue0 <<= 16106TempValue0 += Player.XPos107TempValue1 = Stage.XBoundary2108TempValue1 <<= 16109if TempValue0 > TempValue1110Player.XVelocity = 0111Player.Speed = 0112Player.XPos = TempValue1113TempValue0 = Player.CollisionRight114TempValue0 <<= 16115Player.XPos -= TempValue0116end if117break118119case VERTICALDOOR_END_OPENED120// Somewhat tall vertical wall121PlayerObjectCollision(C_BOX, -16, -32, 16, 32)122123// And enforce right bounds here too124TempValue0 = Player.CollisionRight125TempValue0 <<= 16126TempValue0 += Player.XPos127TempValue1 = Stage.XBoundary2128TempValue1 <<= 16129if TempValue0 > TempValue1130Player.XVelocity = 0131Player.Speed = 0132Player.XPos = TempValue1133TempValue0 = Player.CollisionRight134TempValue0 <<= 16135Player.XPos -= TempValue0136end if137break138139case VERTICALDOOR_END_CLOSING_METAL140// Only enforcing right bounds, no need for collision checks anymore141TempValue0 = Player.CollisionRight142TempValue0 <<= 16143TempValue0 += Player.XPos144TempValue1 = Object.XPos145TempValue1 -= 0x100000146if TempValue0 > TempValue1147Player.XVelocity = 0148Player.Speed = 0149Player.XPos = TempValue1150TempValue0 = Player.CollisionRight151TempValue0 <<= 16152Player.XPos -= TempValue0153end if154break155156end switch157158end sub159160161sub ObjectDraw162163// Draw the extension sprite164TempValue0 = Object.DrawPosY165TempValue0 >>= 1166TempValue0 += Object.YPos167DrawSpriteXY(0, Object.XPos, TempValue0)168169// Draw the base sprite170DrawSprite(1)171172end sub173174175sub ObjectStartup176177LoadSpriteSheet("R7/Objects.gif")178179// Good future gets different sprites from other time periods180if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE181SpriteFrame(-16, -32, 32, 32, 117, 219)182SpriteFrame(-16, 0, 32, 32, 117, 219)183else184SpriteFrame(-16, -32, 32, 32, 1, 1)185SpriteFrame(-16, 0, 32, 32, 1, 1)186end if187188end sub189190191// ========================192// Editor Subs193// ========================194195sub RSDKDraw196DrawSprite(0)197DrawSprite(1)198end sub199200201sub RSDKLoad202LoadSpriteSheet("R7/Objects.gif")203SpriteFrame(-16, 0, 32, 32, 1, 1) // Sticking with the normal variant here...204SpriteFrame(-16, -32, 32, 32, 1, 1)205206SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")207end sub208209210