Path: blob/main/Scripts/R8/Hotaru.txt
1319 views
//------------------Sonic CD Hotaru Script--------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.XVelocity7#alias Object.Value2 : Object.YVelocity8#alias Object.Value3 : Object.XOriginPos9#alias Object.Value4 : Object.YOriginPos10#alias Object.Value5 : Object.LeftBound11#alias Object.Value6 : Object.RightBound12#alias Object.Value7 : Object.CheckBounds1314// Hotaru Laser alias15#alias Object.Value2 : Object.HotaruEntity1617// HUD Alias18#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1920// One Way Door Alias21#alias Object[+5].State : OneWayDoor.State2223// Hotaru Spawner States24#alias 0 : HOTARU_SPAWNER_CHECK_BOUNDS25#alias 1 : HOTARU_SPAWNER_SPAWN_CHILD_126#alias 2 : HOTARU_SPAWNER_CHECK_CHILD_127#alias 3 : HOTARU_SPAWNER_SPAWN_CHILD_228#alias 4 : HOTARU_SPAWNER_CHECK_CHILD_229#alias 5 : HOTARU_SPAWNER_OPEN_DOORS3031// Hotaru States32#alias 0 : HOTARU_FADE_IN33#alias 1 : HOTARU_MOVE34#alias 2 : HOTARU_CHARGE_LASER35#alias 3 : HOTARU_SHOT_LASER36#alias 4 : HOTARU_SET_NEW_DESTINATION3738// One Way Door States39#alias 1 : ONEWAYDOOR_OPEN4041// Stage SFX42#alias 4 : SFX_S_HLASER4344// Ink Effects45#alias 2 : INK_ALPHA4647// Priority48#alias 1 : PRIORITY_ACTIVE4950// Property Values51#alias 0 : PARENT_OBJECT52#alias 1 : CHILD_OBJECT5354// Time Periods55#alias 0 : TIME_PRESENT56#alias 1 : TIME_PAST57#alias 2 : TIME_GOOD_FUTURE58#alias 3 : TIME_BAD_FUTURE596061// Function declarations62#function Hotaru_Set_Destination6364function Hotaru_Set_Destination65if Object.CheckBounds == false66TempValue0 = true67else68TempValue1 = Player.XPos69TempValue1 >>= 1670TempValue1 &= 0x7FF87172CheckLower(TempValue1, Object.LeftBound)73TempValue0 = CheckResult7475CheckGreater(TempValue1, Object.RightBound)76TempValue0 |= CheckResult77end if7879if TempValue0 == true80TempValue2 = Oscillation81TempValue2 &= 12782TempValue2 += Object.XOriginPos83TempValue2 -= 648485TempValue3 = Player.XPos86TempValue3 >>= 1687TempValue3 *= 588TempValue3 &= 3189TempValue3 += Object.YOriginPos90else91TempValue2 = TempValue19293TempValue3 = Object.YOriginPos94TempValue3 -= 895end if96Object.XVelocity = TempValue297Object.XVelocity -= Object.iXPos98Object.XVelocity <<= 1199100Object.YVelocity = TempValue3101Object.YVelocity -= Object.iYPos102Object.YVelocity <<= 11103104Object.CheckBounds++105Object.CheckBounds &= 1106end function107108109sub ObjectMain110#platform: Use_Origins111if game.playMode == BOOT_PLAYMODE_BOSSRUSH112Object.Type = TypeName[Blank Object]113else114#endplatform115if Object.PropertyValue == PARENT_OBJECT116switch Object.State117case HOTARU_SPAWNER_CHECK_BOUNDS118TempValue0 = Object.XPos119TempValue0 -= 0x300000120121if Player.XPos > TempValue0122Object.State++123end if124break125126case HOTARU_SPAWNER_SPAWN_CHILD_1127if Object.Timer < 60128Object.Timer++129else130Object.Timer = 0131132Object[+1].Type = TypeName[Hotaru]133Object[+1].XPos = Object.XPos134Object[+1].XPos -= 0x500000135Object[+1].YPos = Object.YPos136Object[+1].YPos += 0x300000137Object.State++138end if139break140141case HOTARU_SPAWNER_CHECK_CHILD_1142// Check if the first Hotaru got destroyed143if Object[+1].Type != TypeName[Hotaru]144Object.State++145else146if Object[+1].State < HOTARU_CHARGE_LASER147TempValue0 = 176148else149TempValue0 = 0150end if151TempValue0 -= Object.Alpha152TempValue0 >>= 3153Object.Alpha += TempValue0154end if155break156157case HOTARU_SPAWNER_SPAWN_CHILD_2158if Object.Timer < 60159Object.Timer++160else161Object.Timer = 0162Object[+2].Type = TypeName[Hotaru]163Object[+2].CheckBounds = true164165Object[+2].XPos = Object.XPos166Object[+2].XPos -= 0x500000167168Object[+2].YPos = Object.YPos169Object[+2].YPos += 0x280000170171Object[+3].Type = TypeName[Hotaru]172Object[+3].CheckBounds = false173174Object[+3].XPos = Object.XPos175Object[+3].XPos += 0x500000176177Object[+3].YPos = Object.YPos178Object[+3].YPos += 0x280000179Object.State++180end if181break182183case HOTARU_SPAWNER_CHECK_CHILD_2184if Object[+2].Type != TypeName[Hotaru]185if Object[+3].Type != TypeName[Hotaru]186TempValue0 = 3840187TempValue0 -= Screen.CenterX188Stage.NewXBoundary1 = TempValue0189TempValue0 += Screen.XSize190Stage.NewXBoundary2 = TempValue0191Object.Priority = PRIORITY_ACTIVE192Object.State++193else194if Object[+3].State < HOTARU_CHARGE_LASER195TempValue0 = 176196else197TempValue0 = 0198end if199TempValue0 -= Object.Alpha200TempValue0 >>= 3201Object.Alpha += TempValue0202end if203else204if Object[+2].State < HOTARU_CHARGE_LASER205TempValue0 = 176206else207TempValue0 = 0208end if209TempValue0 -= Object.Alpha210TempValue0 >>= 3211Object.Alpha += TempValue0212end if213break214215case HOTARU_SPAWNER_OPEN_DOORS216if Object[+2].State > HOTARU_MOVE217if Object[+3].State > HOTARU_MOVE218OneWayDoor.State = ONEWAYDOOR_OPEN219end if220end if221222if HUD.CurrentTimePeriod == TIME_BAD_FUTURE223if Object.Alpha < 176224Object.Alpha++225end if226else227if Object.Alpha > 0228Object.Alpha--229end if230end if231232PlayerObjectCollision(C_TOUCH, -192, -256, 420, 256)233if CheckResult == false234ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)235end if236break237end switch238else239switch Object.State240case HOTARU_FADE_IN241if Object.Timer < 60242Object.Timer++243else244Object.Timer = 32245CallFunction(Hotaru_Set_Destination)246Object.State++247end if248Object.Alpha = Object.Timer249Object.Alpha <<= 2250break251252case HOTARU_MOVE253Object.XPos += Object.XVelocity254Object.YPos += Object.YVelocity255256TempValue0 = Object.Timer257TempValue0 &= 3258if TempValue0 == 0259CreateTempObject(TypeName[Hotaru Trail], 0, Object.XPos, Object.YPos)260Object[TempObjectPos].InkEffect = INK_ALPHA261Object[TempObjectPos].Alpha = 248262end if263264Object.Timer--265if Object.Timer == 0266Object.State++267end if268break269270case HOTARU_CHARGE_LASER271Object.Timer++272if Object.Timer == 32273Object.Timer = 0274Object.State++275PlayStageSfx(SFX_S_HLASER, false)276end if277break278279case HOTARU_SHOT_LASER280TempValue0 = Object.Timer281TempValue0 &= 1282if TempValue0 == 0283CreateTempObject(TypeName[Hotaru Laser], 0, Object.XPos, Object.YPos)284Object[TempObjectPos].HotaruEntity = Object.EntityNo285end if286Object.Timer++287if Object.Timer == 20288Object.Timer = 0289Object.State++290end if291break292293case HOTARU_SET_NEW_DESTINATION294Object.Timer++295if Object.Timer == 16296Object.Timer = 32297CallFunction(Hotaru_Set_Destination)298Object.State = HOTARU_MOVE299end if300break301end switch302end if303#platform: Use_Origins304end if305#endplatform306end sub307308309sub ObjectPlayerInteraction310if Object.PropertyValue == CHILD_OBJECT311if Object.State == HOTARU_SHOT_LASER312if Object.Timer > 1313#platform: Use_Standalone314PlayerObjectCollision(C_TOUCH, -5, -5, 5, 5)315#endplatform316#platform: Use_Origins317PlayerObjectCollision(C_ENEMY, -5, -5, 5, 5)318#endplatform319if CheckResult == true320CallFunction(Player_BadnikBreak)321end if322end if323end if324end if325end sub326327328sub ObjectDraw329if Object.PropertyValue == CHILD_OBJECT330switch Object.State331case HOTARU_FADE_IN332DrawSpriteFX(2, FX_INK, Object.XPos, Object.YPos)333break334335case HOTARU_MOVE336DrawSprite(2)337break338339case HOTARU_CHARGE_LASER340TempValue0 = Object.Timer341TempValue0 &= 3342TempValue0 >>= 1343if TempValue0 == 0344DrawSprite(3)345else346DrawSprite(0)347end if348break349350case HOTARU_SHOT_LASER351TempValue0 = Object.Timer352TempValue0 &= 7353TempValue0 >>= 2354DrawSprite(TempValue0)355DrawSprite(3)356break357358case HOTARU_SET_NEW_DESTINATION359TempValue0 = Object.Timer360TempValue0 &= 3361TempValue0 >>= 1362if TempValue0 == 0363DrawSprite(3)364else365DrawSprite(0)366end if367break368end switch369else370DrawRect(0, 0, Screen.XSize, Screen.YSize, 0, 0, 0, Object.Alpha)371end if372end sub373374375sub ObjectStartup376LoadSpriteSheet("R8/Objects3.gif")377378SpriteFrame(-12, -24, 24, 40, 96, 133) // #0 - Hotaru Idle frame 0379SpriteFrame(-12, -24, 24, 40, 121, 133) // #1 - Hotaru Idle frame 1380381SpriteFrame(-12, -10, 24, 24, 146, 133) // #2 - Hotaru Bulb frame 0382SpriteFrame(-12, -10, 24, 24, 171, 133) // #3 - Hotaru Bulb frame 1383384ArrayPos0 = 32385while ArrayPos0 < 1056386if Object[ArrayPos0].Type == TypeName[Hotaru]387Object[ArrayPos0].Alpha = 0388Object[ArrayPos0].InkEffect = INK_ALPHA389390if HUD.CurrentTimePeriod == TIME_BAD_FUTURE391Object[ArrayPos0].DrawOrder = 2392end if393394ArrayPos1 = ArrayPos0395ArrayPos1++396TempValue0 = 0397while TempValue0 < 3398// Setups the next 3 blank objects399Object[ArrayPos1].PropertyValue = CHILD_OBJECT400Object[ArrayPos1].DrawOrder = 4401Object[ArrayPos1].InkEffect = INK_ALPHA402403Object[ArrayPos1].XOriginPos = Object[ArrayPos0].iXPos404Object[ArrayPos1].YOriginPos = Object[ArrayPos0].iYPos405406Object[ArrayPos1].LeftBound = Object[ArrayPos0].iXPos407Object[ArrayPos1].LeftBound -= 112408409Object[ArrayPos1].RightBound = Object[ArrayPos0].iXPos410Object[ArrayPos1].RightBound += 112411TempValue0++412ArrayPos1++413loop414ArrayPos0 += 3415end if416ArrayPos0++417loop418end sub419420421// ========================422// Editor Subs423// ========================424425sub RSDKDraw426DrawSprite(0)427if Editor.ShowGizmos == true428Editor.DrawingOverlay = true429DrawLine(Object.XPos, Object.YPos, Object[+1].XPos, Object[+1].YPos, 255, 255, 0)430DrawLine(Object.XPos, Object.YPos, Object[+2].XPos, Object[+2].YPos, 255, 255, 0)431DrawLine(Object.XPos, Object.YPos, Object[+3].XPos, Object[+3].YPos, 255, 255, 0)432Editor.DrawingOverlay = false433end if434end sub435436437sub RSDKLoad438LoadSpriteSheet("R8/Objects3.gif")439440SpriteFrame(-12, -24, 24, 40, 96, 133) // #0 - Hotaru Idle frame 0441442SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")443end sub444445446