Path: blob/main/Scripts/R4/Eggman1.txt
1319 views
//----------Sonic CD R4 Eggman Chase Sequence Script----------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Unused6#alias Object.Value1 : Object.Speed7#alias Object.Value2 : Object.Angle8#alias Object.Value3 : Object.YOffset9#alias Object.Value4 : Object.FlameAnimation10#alias Object.Value5 : Object.Hits11#alias Object.Value6 : Object.FrameTimer12#alias Object.Value7 : Object.ExplosionTimer13#alias Object.PropertyValue : SolidBarrier.PropertyValue1415// Player Alias16#alias Player.Value4 : Player.InvincibleTimer1718// States19#alias 0 : R4_EGG_CHASE_PLAYER_APPROACH20#alias 1 : R4_EGG_CHASE_MOVE_DOWN_121#alias 2 : R4_EGG_CHASE_SHIFT_RIGHT_122#alias 3 : R4_EGG_CHASE_SHIFT_DOWN_123#alias 4 : R4_EGG_CHASE_MOVE_RIGHT_124#alias 5 : R4_EGG_CHASE_MOVE_DOWN_225#alias 6 : R4_EGG_CHASE_MOVE_LEFT_126#alias 7 : R4_EGG_CHASE_MOVE_DOWN_327#alias 8 : R4_EGG_CHASE_MOVE_DR_128#alias 9 : R4_EGG_CHASE_VERTICAL_LOOP29#alias 10 : R4_EGG_CHASE_MOVE_DOWN_430#alias 11 : R4_EGG_CHASE_MOVE_DR_231#alias 12 : R4_EGG_CHASE_MOVE_RIGHT_232#alias 13 : R4_EGG_CHASE_MOVE_DR_333#alias 14 : R4_EGG_CHASE_MOVE_DOWN_534#alias 15 : R4_EGG_CHASE_MOVE_DR_435#alias 16 : R4_EGG_CHASE_MOVE_DOWN_636#alias 17 : R4_EGG_CHASE_MOVE_DL_137#alias 18 : R4_EGG_CHASE_MOVE_LEFT_238#alias 19 : R4_EGG_FLEE_TOP_DOOR39#alias 20 : R4_EGG_FLEE_MOVE_DR40#alias 21 : R4_EGG_FLEE_MOVE_RIGHT_141#alias 22 : R4_EGG_FLEE_MOVE_DOWN_142#alias 23 : R4_EGG_FLEE_BOTTOM_DOOR43#alias 24 : R4_EGG_FLEE_MOVE_RIGHT_244#alias 25 : R4_EGG_FLEE_MOVE_UR4546// Global SFX47#alias 22 : SFX_G_EXPLOSION4849// Stage SFX50#alias 5 : SFX_S_BOSSHIT5152// Priority53#alias 1 : PRIORITY_ACTIVE5455// Solid Barrier Property Values56#alias 3 : OPEN_EGGMAN5758// Function declarations59#function ChaseEggman_Oscillation6061function ChaseEggman_Oscillation62Sin(Object.YPos, Object.Angle)63Object.YPos <<= 1064Object.Angle += 465Object.Angle &= 51166end function676869sub ObjectMain70switch Object.State71case R4_EGG_CHASE_PLAYER_APPROACH72PlayerObjectCollision(C_TOUCH, -64, -256, 64, 256)73if CheckResult == true74Object.State = R4_EGG_CHASE_MOVE_DOWN_175Object.Priority = PRIORITY_ACTIVE76Object.Speed = 0x1C00077end if78break7980case R4_EGG_CHASE_MOVE_DOWN_181Object.YPos += Object.Speed82// Y - 1054 in map coords83if Object.YPos > 0x41E000084Object.State++85Object.Direction = FACING_RIGHT86Object.FlameAnimation = 287end if88break8990case R4_EGG_CHASE_SHIFT_RIGHT_191Object.XPos += Object.Speed92Object.YPos += Object.Speed93// X - 1248 in map coords94if Object.XPos > 0x4E0000095Object.XPos = 0x4E0000096Object.State++97Object.FlameAnimation = 098end if99break100101case R4_EGG_CHASE_SHIFT_DOWN_1102Object.YPos += Object.Speed103// Y - 1120 in map coords104if Object.YPos > 0x4600000105Object.YPos = 0x4600000106Object.State++107Object.Angle = 0108Object.YOffset = Object.YPos109Object.FlameAnimation = 1110end if111break112113case R4_EGG_CHASE_MOVE_RIGHT_1114Object.XPos += Object.Speed115CallFunction(ChaseEggman_Oscillation)116Object.YPos += Object.YOffset117// X - 1596 in map coords118if Object.XPos > 0x63C0000119Object.XPos = 0x63C0000120Object.FlameAnimation = 0121if Object.Hits < 4122Object.State++123else124Object.State = R4_EGG_FLEE_BOTTOM_DOOR125SolidBarrier[+2].PropertyValue = OPEN_EGGMAN126end if127end if128break129130case R4_EGG_CHASE_MOVE_DOWN_2131Object.YPos += Object.Speed132// Y - 1312 in map coords133if Object.YPos > 0x5200000134Object.YPos = 0x5200000135Object.State++136Object.Direction = FACING_LEFT137Object.Angle = 0138Object.YOffset = Object.YPos139Object.FlameAnimation = 1140end if141break142143case R4_EGG_CHASE_MOVE_LEFT_1144Object.XPos -= Object.Speed145CallFunction(ChaseEggman_Oscillation)146FlipSign(Object.YPos)147Object.YPos += Object.YOffset148// Y - 1376 in map coords149if Object.XPos < 0x5600000150Object.XPos = 0x5600000151Object.State++152Object.FlameAnimation = 0153end if154break155156case R4_EGG_CHASE_MOVE_DOWN_3157Object.YPos += Object.Speed158// Y - 1498 in map coords159if Object.YPos > 0x5DA0000160Object.State++161Object.Direction = FACING_RIGHT162Object.FlameAnimation = 2163end if164break165166case R4_EGG_CHASE_MOVE_DR_1167Object.XPos += Object.Speed168Object.YPos += Object.Speed169// X - 1396 in map coords170if Object.XPos > 0x5740000171Object.XPos = 0x5740000172Object.State++173Object.FlameAnimation = 0174end if175break176177case R4_EGG_CHASE_VERTICAL_LOOP178Object.YPos += Object.Speed179// Y - 2272 in map coords180if Object.YPos > 0x8E00000181Object.YPos -= 0x8000000 // Y - -2048 in map coords182Object.State++183else184// Y - 320 in map coords185if Player.YPos < 0x1400000186Object.YPos -= 0x8000000 // Y - -2048 in map coords187Object.State++188end if189end if190break191192case R4_EGG_CHASE_MOVE_DOWN_4193Object.YPos += Object.Speed194// Y - 300 in map coords195if Object.YPos > 0x12C0000196Object.YPos = 0x12C0000197Object.State++198Object.FlameAnimation = 2199end if200break201202case R4_EGG_CHASE_MOVE_DR_2203Object.XPos += Object.Speed204Object.YPos += Object.Speed205// X - 1532 in map coords206if Object.XPos > 0x5FC0000207Object.XPos = 0x5FC0000208Object.State++209Object.Angle = 0210Object.YOffset = Object.YPos211Object.FlameAnimation = 1212end if213break214215case R4_EGG_CHASE_MOVE_RIGHT_2216Object.XPos += Object.Speed217CallFunction(ChaseEggman_Oscillation)218Object.YPos += Object.YOffset219// X - 1654 in map coords220if Object.XPos > 0x6760000221Object.State++222Object.FlameAnimation = 2223end if224break225226case R4_EGG_CHASE_MOVE_DR_3227Object.XPos += Object.Speed228Object.YPos += Object.Speed229// X - 1732 in map coords230if Object.XPos > 0x6C40000231Object.XPos = 0x6C40000232Object.State++233Object.FlameAnimation = 0234end if235break236237case R4_EGG_CHASE_MOVE_DOWN_5238Object.YPos += Object.Speed239// Y - 626 in map coords240if Object.YPos > 0x2720000241Object.State++242Object.FlameAnimation = 2243end if244break245246case R4_EGG_CHASE_MOVE_DR_4247Object.XPos += Object.Speed248Object.YPos += Object.Speed249// X - 1764 in map coords250if Object.XPos > 0x6E40000251Object.XPos = 0x6E40000252Object.State++253Object.FlameAnimation = 0254end if255break256257case R4_EGG_CHASE_MOVE_DOWN_6258Object.YPos += Object.Speed259if Object.Hits < 4260// Y - 626 in map coords261if Object.YPos > 0x2EC0000262Object.State++263Object.Direction = FACING_LEFT264Object.FlameAnimation = 2265end if266else267// Y - 688 in map coords268if Object.YPos > 0x2B00000269Object.State = R4_EGG_FLEE_TOP_DOOR270Object.FlameAnimation = 1271Object.Angle = 0272Object.YOffset = Object.YPos273SolidBarrier[+1].PropertyValue = OPEN_EGGMAN274end if275end if276break277278case R4_EGG_CHASE_MOVE_DL_1279Object.XPos -= Object.Speed280Object.YPos += Object.Speed281// Y - 816 in map coords282if Object.YPos > 0x3300000283Object.YPos = 0x3300000284Object.State++285Object.Angle = 0286Object.YOffset = Object.YPos287Object.FlameAnimation = 1288end if289break290291case R4_EGG_CHASE_MOVE_LEFT_2292Object.XPos -= Object.Speed293CallFunction(ChaseEggman_Oscillation)294FlipSign(Object.YPos)295Object.YPos += Object.YOffset296// X - 1232 in map coords297if Object.XPos < 0x4D00000298Object.XPos = 0x4D00000299Object.State = R4_EGG_CHASE_MOVE_DOWN_1300Object.FlameAnimation = 0301end if302break303304case R4_EGG_FLEE_TOP_DOOR305Object.XPos += Object.Speed306CallFunction(ChaseEggman_Oscillation)307Object.YPos += Object.YOffset308// X - 1956 in map coords309if Object.XPos > 0x7A40000310Object.State++311Object.FlameAnimation = 2312end if313break314315case R4_EGG_FLEE_MOVE_DR316Object.XPos += Object.Speed317Object.YPos += Object.Speed318// Y - 736 in map coords319if Object.YPos > 0x2E00000320Object.YPos = 0x2E00000321Object.State++322Object.FlameAnimation = 1323Object.Angle = 0324Object.YOffset = Object.YPos325end if326break327328case R4_EGG_FLEE_MOVE_RIGHT_1329Object.XPos += Object.Speed330CallFunction(ChaseEggman_Oscillation)331Object.YPos += Object.YOffset332// X - 2168 in map coords333if Object.XPos > 0x8780000334Object.XPos = 0x8780000335Object.State++336Object.FlameAnimation = 0337end if338break339340case R4_EGG_FLEE_MOVE_DOWN_1341if Object.Speed < 0x40000342Object.YPos += 0x40000343else344Object.YPos += Object.Speed345end if346347TempValue0 = Screen.YOffset348TempValue0 += 288349TempValue0 <<= 16350351if Object.YPos > TempValue0352ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)353end if354break355356case R4_EGG_FLEE_BOTTOM_DOOR357Object.YPos -= Object.Speed358// Y - 1088 in map coords359if Object.YPos < 0x4400000360Object.YPos = 0x4400000361Object.State++362Object.FlameAnimation = 1363Object.Angle = 0364Object.YOffset = Object.YPos365end if366break367368case R4_EGG_FLEE_MOVE_RIGHT_2369Object.XPos += Object.Speed370CallFunction(ChaseEggman_Oscillation)371Object.YPos += Object.YOffset372// X - 1856 in map coords373if Object.XPos > 0x7400000374Object.State++375Object.FlameAnimation = 2376end if377break378379case R4_EGG_FLEE_MOVE_UR380Object.XPos += Object.Speed381Object.YPos -= Object.Speed382// Y - 988 in map coords383if Object.YPos < 0x3DC0000384Object.YPos = 0x3DC0000385Object.State = R4_EGG_FLEE_MOVE_RIGHT_1386Object.FlameAnimation = 1387Object.Angle = 0388Object.YOffset = Object.YPos389end if390break391392end switch393394if Object.ExplosionTimer == 1395CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)396if Object.Direction == FACING_RIGHT397Object[TempObjectPos].XPos -= 0x80000398else399Object[TempObjectPos].XPos += 0x80000400end if401PlaySfx(SFX_G_EXPLOSION, false)402Object.ExplosionTimer = 34403else404if Object.ExplosionTimer > 0405Object.ExplosionTimer--406end if407end if408end sub409410411sub ObjectPlayerInteraction412if Object.FrameTimer == 0413#platform: Use_Standalone414PlayerObjectCollision(C_TOUCH, -32, -24, 32, 24)415#endplatform416#platform: Use_Origins417PlayerObjectCollision(C_ENEMY, -32, -24, 32, 24)418#endplatform419if CheckResult == true420CheckEqual(Player.Animation, ANI_JUMPING)421TempValue0 = CheckResult422CheckEqual(Player.Animation, ANI_SPINDASH)423TempValue0 |= CheckResult424#platform: Use_Origins425// making really sure you're the one character that can glide or the one character that has a hammer426if Stage.PlayerListPos == PLAYER_KNUCKLES427CheckEqual(Player.Animation, ANI_GLIDING)428TempValue0 |= CheckResult429CheckEqual(Player.Animation, ANI_GLIDING_STOP)430TempValue0 |= CheckResult431end if432if Stage.PlayerListPos == PLAYER_AMY433CheckEqual(Player.Animation, ANI_HAMMER_JUMP)434TempValue0 |= CheckResult435CheckEqual(Player.Animation, ANI_HAMMER_DASH)436TempValue0 |= CheckResult437end if438#endplatform439if Player.Animation == ANI_FLYING440CheckGreater(Player.YPos, Object.YPos)441TempValue0 |= CheckResult442end if443444ArrayPos0 = Player.EntityNo445ArrayPos0 += 2446if Object[ArrayPos0].Type == TypeName[Invincibility]447TempValue0 = true448end if449450if TempValue0 == true451FlipSign(Player.XVelocity)452FlipSign(Player.Speed)453Player.XVelocity >>= 1454Player.Speed >>= 1455456Player.YVelocity = Player.YPos457Player.YVelocity -= Object.YPos458Player.YVelocity >>= 3459460#platform: Use_Origins461if Stage.PlayerListPos == PLAYER_KNUCKLES462if Player.Animation == ANI_GLIDING463Player.Animation = ANI_GLIDING_DROP464Player.State = Player_State_GlideDrop465end if466end if467#endplatform468469Object.Hits++470if Object.Hits == 4471Object.FrameTimer = 16472Object.ExplosionTimer = 1473else474Object.FrameTimer = 1475PlayStageSfx(SFX_S_BOSSHIT, false)476Object.Speed = 0x48000477end if478else479if Player.InvincibleTimer == 0480Player.State = Player_State_GotHit481if Player.XPos > Object.XPos482Player.Speed = 0x20000483else484Player.Speed = -0x20000485end if486end if487end if488end if489else490if Object.Hits == 4491PlayerObjectCollision(C_TOUCH, -64, -80, 64, 80)492if CheckResult == true493switch Object.FlameAnimation494case 0495Object.Speed += 0x8000496break497498case 1499Object.Speed += 0x8000500if Object.Speed > 0x60000501Object.Speed = 0x60000502end if503break504505case 2506Object.Speed -= 0x2000507if Object.Speed > 0x60000508Object.Speed = 0x60000509end if510if Object.Speed < 0x20000511Object.Speed = 0x20000512end if513break514515end switch516else517Object.Speed -= 0x2000518if Object.Speed < 0x1C000519Object.Speed = 0x1C000520end if521end if522523PlayerObjectCollision(C_TOUCH, -320, -240, 320, 240)524if CheckResult == false525Object.Speed = 0526end if527end if528end if529end sub530531532sub ObjectDraw533if Object.FrameTimer == 0534DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)535DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)536else537if Object.FrameTimer < 16538TempValue0 = Object.FrameTimer539TempValue0 &= 1540DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)541542if TempValue0 == 0543DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)544end if545546TempValue0 = Object.FrameTimer547TempValue0 &= 15548TempValue0 >>= 2549TempValue0 += 8550DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)551else552if Object.Unused < 32553DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)554DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos) // Nervous face555else556DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)557DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos) // Normal face558end if559TempValue0 = Object.FrameTimer560TempValue0 &= 15561TempValue0 >>= 2562TempValue0 += 8563DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)564end if565566Object.FrameTimer++567if Object.Hits < 4568if Object.FrameTimer == 80569Object.FrameTimer = 0570Object.Speed = 0x1C000571end if572else573if Object.FrameTimer == 32574Object.FrameTimer = 16575end if576end if577end if578579TempValue0 = Object.Frame580TempValue0 >>= 2581switch Object.FlameAnimation582case 0583TempValue0 += 4584DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)585break586587case 1588TempValue0 += 6589DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)590break591592case 2593TempValue0 += 4594DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)595TempValue0 += 2596DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)597break598end switch599600Object.Frame++601Object.Frame &= 7602end sub603604605sub ObjectStartup606LoadSpriteSheet("R4/Objects2.gif")607608// Egg Mobile609SpriteFrame(-36, -28, 72, 56, 61, 1) // #0 - Egg Bubble Chase610SpriteFrame(-36, -28, 72, 56, 134, 1) // #1 - Egg Bubble Chase damage611612// Eggman613SpriteFrame(-12, -28, 32, 16, 207, 1) // #2 - Eggman face614SpriteFrame(-12, -28, 32, 16, 207, 18) // #3 - Eggman nervous face615616// Thruster617SpriteFrame(-36, 28, 72, 16, 116, 58) // #4 - Thruster vertical big flame618SpriteFrame(-36, 28, 72, 16, 116, 75) // #5 - Thruster vertical small flame619SpriteFrame(-36, 20, 72, 16, 116, 92) // #6 - Thruster angle big flame620SpriteFrame(-36, 20, 72, 16, 116, 109) // #7 - Thruster angle small flame621622// Sweat623SpriteFrame(-12, -44, 16, 16, 1, 135) // #8 - Sweat drop frame 0624SpriteFrame(-12, -44, 1, 1, 1, 135) // #9 - Sweat drop frame 1625SpriteFrame(-12, -44, 16, 16, 18, 135) // #10 - Sweat drop frame 2626SpriteFrame(-12, -44, 1, 1, 1, 135) // #11 - Sweat drop frame 3627628// Used to be below LoadSpriteSheet, moved here for consistency629ArrayPos0 = 32630while ArrayPos0 < 1056631if Object[ArrayPos0].Type == TypeName[Eggman Part 1]632Object[ArrayPos0].Direction = FACING_LEFT633end if634ArrayPos0++635loop636end sub637638639// ========================640// Editor Subs641// ========================642643sub RSDKDraw644DrawSprite(0)645DrawSprite(1)646end sub647648649sub RSDKLoad650LoadSpriteSheet("R4/Objects2.gif")651652// Egg Mobile653SpriteFrame(-36, -28, 72, 56, 61, 1) // #0 - Egg Bubble Chase654// Eggman655SpriteFrame(-12, -28, 32, 16, 207, 1) // #2 - Eggman face656657SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")658end sub659660661