Path: blob/main/Scripts/R5/Stalactite.txt
1319 views
//-----------------Sonic CD Stalactite Script-----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.YVelocity6#alias Object.Value1 : Object.YOriginPos78// HUD Alias9#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1011// States12#alias 0 : STALACTITE_IDLE13#alias 1 : STALACTITE_FALLING14#alias 2 : STALACTITE_OFFSCREEN1516// Time Periods17#alias 0 : TIME_PRESENT18#alias 1 : TIME_PAST19#alias 2 : TIME_GOOD_FUTURE20#alias 3 : TIME_BAD_FUTURE2122// Priority23#alias 0 : PRIORITY_BOUNDS24#alias 1 : PRIORITY_ACTIVE252627sub ObjectMain2829switch Object.State3031// State STALACTITE_IDLE doesn't really do anything...32// Instead, falling is triggered over in ObjectPlayerInteraction3334case STALACTITE_FALLING35// Update Gravity, maximum velocity of 8 pixels36if Object.YVelocity < 0x8000037// Gravity rate of 0.25 pixels per frame38Object.YVelocity += 0x400039end if4041Object.YPos += Object.YVelocity4243if Object.OutOfBounds == true44// If this object goes offscreen, then put it back at its starting position and into the temp buffer state45Object.State = STALACTITE_OFFSCREEN46Object.YPos = Object.YOriginPos47end if48break4950case STALACTITE_OFFSCREEN51// This state is here just in case the Stalactite fell off screen, but the Player is still near it too52// In this case, we need the Object to stay away just a bit longer so that it doesn't suddenly snap back to position5354if Object.OutOfBounds == true55// It's safe to go back now, restore56Object.Priority = PRIORITY_BOUNDS57Object.State = STALACTITE_IDLE58end if59break6061end switch6263end sub646566sub ObjectPlayerInteraction6768switch Object.State69case STALACTITE_IDLE70// First check if the player's within falling trigger range71PlayerObjectCollision(C_TOUCH, -4, 0, 4, 96)72if CheckResult == true73// Make the Stalactite start falling7475// Make it always active, since it'll end up falling out of bounds76Object.Priority = PRIORITY_ACTIVE7778// Reset its falling properties79Object.YVelocity = 080Object.State = STALACTITE_FALLING81end if8283// [Fallthrough]8485case STALACTITE_FALLING8687// Just act as a plain 'ol hitbox too, in case the player jumps at it for whatever reason88PlayerObjectCollision(C_TOUCH, -8, -24, 8, 20)8990if CheckResult == true91CallFunction(Player_Hit)92end if93break9495end switch9697end sub9899100sub ObjectDraw101102switch Object.State103case STALACTITE_IDLE104case STALACTITE_FALLING105DrawSprite(0)106break107108end switch109110end sub111112113sub ObjectStartup114LoadSpriteSheet("R5/Objects.gif")115116// Use different frames for the different time period117switch HUD.CurrentTimePeriod118case TIME_PRESENT119SpriteFrame(-8, -24, 16, 48, 172, 207)120break121122case TIME_PAST123SpriteFrame(-8, -24, 16, 48, 189, 207)124break125126case TIME_GOOD_FUTURE127SpriteFrame(-8, -24, 16, 48, 172, 207) // Same as Present, is this supposed to be the frame next to the Flowers instead?128break129130case TIME_BAD_FUTURE131SpriteFrame(-8, -24, 16, 48, 155, 207)132break133134end switch135136// Cycle through all Stalactite Objects in the level137ArrayPos0 = 32138while ArrayPos0 < 1056139if Object[ArrayPos0].Type == TypeName[Stalactite]140141// Store its Starting Position, this will be needed for restoration after the Object falls142Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos143144end if145146ArrayPos0++147loop148149end sub150151152// ========================153// Editor Subs154// ========================155156sub RSDKDraw157DrawSprite(0)158end sub159160161sub RSDKLoad162LoadSpriteSheet("R5/Objects.gif")163164// TODO: support other time periods165// Surely there's a better way to do it than 10 separate checkCurrentStageFolder checks?166SpriteFrame(-8, -24, 16, 48, 172, 207)167168SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")169end sub170171172