Path: blob/main/Scripts/R8/Dango.txt
1319 views
//-------------------Sonic CD Dango 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.XOriginPos7#alias Object.Value2 : Object.YOriginPos8#alias Object.Value3 : Object.XVelocity9#alias Object.Value4 : Object.ChaseChain1011#alias Object.PropertyValue : Object.Quality1213// States14#alias 0 : DANGO_WALK15#alias 1 : DANGO_CURL116#alias 2 : DANGO_CURL217#alias 3 : DANGO_CHARGEROLL18#alias 4 : DANGO_ROLLING19#alias 5 : DANGO_UNCURL120#alias 6 : DANGO_UNCURL221#alias 7 : DANGO_UNCURLED22#alias 8 : DANGO_OFFSCREEN // Unused2324// Gravity25#alias 1 : GRAVITY_AIR2627// Collision Sides28#alias 0 : CSIDE_FLOOR29#alias 1 : CSIDE_LWALL30#alias 2 : CSIDE_RWALL3132// Priority33#alias 0 : PRIORITY_BOUNDS34#alias 1 : PRIORITY_ACTIVE3536// Badnik Quality / Property Values37#alias 0 : GOOD_QUALITY38#alias 1 : BAD_QUALITY394041sub ObjectMain42if Object.Quality == GOOD_QUALITY43switch Object.State44case DANGO_WALK45Object.Priority = PRIORITY_ACTIVE46Object.Frame = Object.Timer47Object.Frame /= 1048Object.Timer++49Object.Timer %= 2050Object.XPos += Object.XVelocity5152if Object.Direction == FACING_RIGHT53ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)54else55ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)56end if5758if CheckResult == false59FlipSign(Object.XVelocity)60Object.Direction++61Object.Direction &= FACING_LEFT62Object.ChaseChain = 063else64if Object.XVelocity > 065ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)66if CheckResult == true67FlipSign(Object.XVelocity)68Object.Direction++69Object.Direction &= FACING_LEFT70Object.ChaseChain = 071end if72else73ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)74if CheckResult == true75FlipSign(Object.XVelocity)76Object.Direction++77Object.Direction &= FACING_LEFT78Object.ChaseChain = 079end if80end if81end if82break83case DANGO_CURL184Object.Frame = 485if Object.Timer < 886Object.Timer++87else88Object.Timer = 089Object.State++90end if91break9293case DANGO_CURL294Object.Frame = 595if Object.Timer < 696Object.Timer++97else98Object.Timer = 099Object.State++100end if101break102103case DANGO_CHARGEROLL104Object.Frame = Object.AnimationTimer105Object.Frame /= 5106Object.Frame += 6107Object.AnimationTimer++108Object.AnimationTimer %= 10109if Object.Timer < 34110Object.Timer++111else112Object.Timer = 0113Object.State++114if Object.Direction == FACING_RIGHT115Object.XVelocity = -0x40000116else117Object.XVelocity = 0x40000118end if119end if120break121122case DANGO_ROLLING123Object.Frame = Object.AnimationTimer124Object.Frame /= 5125Object.Frame += 6126Object.AnimationTimer++127Object.AnimationTimer %= 10128Object.XPos += Object.XVelocity129130if Object.Direction == FACING_RIGHT131ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)132else133ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)134end if135136if CheckResult == false137Object.State++138Object.ChaseChain++139else140if Object.XVelocity > 0141ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)142if CheckResult == true143Object.State++144Object.ChaseChain++145end if146else147ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)148if CheckResult == true149Object.State++150Object.ChaseChain++151end if152end if153end if154break155156case DANGO_UNCURL1157Object.Frame = 5158if Object.Timer < 6159Object.Timer++160else161Object.Timer = 0162Object.State++163end if164break165166case DANGO_UNCURL2167Object.Frame = 4168if Object.Timer < 8169Object.Timer++170else171Object.Timer = 0172Object.State++173end if174break175176177case DANGO_UNCURLED178Object.Frame = 0179if Object.Timer < 16180Object.Timer++181else182Object.Timer = 0183Object.State = DANGO_WALK184if Object.ChaseChain > 7185// Tried going in the same direction 8 times now...186// Even if the player's the other way, go ahead and change directions187Object.Direction++188Object.Direction &= FACING_LEFT189Object.ChaseChain = 0190end if191192if Object.Direction == FACING_RIGHT193Object.XVelocity = -0x6000194else195Object.XVelocity = 0x6000196end if197end if198break199200case DANGO_OFFSCREEN201// This state is unused, but it serves just about the same buffer purpose as it does with other badniks202if Object.OutOfBounds == true203Object.State = DANGO_WALK204Object.Priority = PRIORITY_BOUNDS205end if206break207end switch208else209switch Object.State210case DANGO_WALK211Object.Priority = PRIORITY_ACTIVE212Object.Frame = Object.Timer213Object.Frame /= 30214Object.Frame += 2215216Object.Timer++217Object.Timer %= 60218219Object.XPos += Object.XVelocity220221if Object.Direction == FACING_RIGHT222ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)223else224ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)225end if226227if CheckResult == false228FlipSign(Object.XVelocity)229Object.Direction++230Object.Direction &= FACING_LEFT231Object.ChaseChain = 0232else233if Object.XVelocity > 0234ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)235if CheckResult == true236FlipSign(Object.XVelocity)237Object.Direction++238Object.Direction &= FACING_LEFT239Object.ChaseChain = 0240end if241else242ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)243if CheckResult == true244FlipSign(Object.XVelocity)245Object.Direction++246Object.Direction &= FACING_LEFT247Object.ChaseChain = 0248end if249end if250end if251break252253case DANGO_CURL1254Object.Frame = 4255if Object.Timer < 20256Object.Timer++257else258Object.Timer = 0259Object.State++260end if261break262263case DANGO_CURL2264Object.Frame = 5265if Object.Timer < 12266Object.Timer++267else268Object.Timer = 0269Object.State++270end if271break272273case DANGO_CHARGEROLL274Object.Frame = Object.AnimationTimer275Object.Frame /= 10276Object.Frame += 8277Object.AnimationTimer++278Object.AnimationTimer %= 20279if Object.Timer < 96280Object.Timer++281else282Object.Timer = 0283Object.State++284if Object.Direction == FACING_RIGHT285Object.XVelocity = -0x10000286else287Object.XVelocity = 0x10000288end if289end if290break291292293case DANGO_ROLLING294Object.Frame = Object.AnimationTimer295Object.Frame /= 10296Object.Frame += 8297Object.AnimationTimer++298Object.AnimationTimer %= 20299Object.XPos += Object.XVelocity300301if Object.Direction == FACING_RIGHT302ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)303else304ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)305end if306307if CheckResult == false308Object.State++309Object.ChaseChain++310else311if Object.XVelocity > 0312ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)313if CheckResult == true314Object.State++315Object.ChaseChain++316end if317else318ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)319if CheckResult == true320Object.State++321Object.ChaseChain++322end if323end if324end if325break326327case DANGO_UNCURL1328Object.Frame = 5329if Object.Timer < 12330Object.Timer++331else332Object.Timer = 0333Object.State++334end if335break336337case DANGO_UNCURL2338Object.Frame = 4339if Object.Timer < 20340Object.Timer++341else342Object.Timer = 0343Object.State++344end if345break346347case DANGO_UNCURLED348Object.Frame = 2349if Object.Timer < 64350Object.Timer++351else352Object.Timer = 0353Object.State = DANGO_WALK354if Object.ChaseChain > 7355// Been going in the same direction for 8 cycles now...356// Even if it may be opposite of the player, go ahead and change direction because much isn't happening now anyway357Object.Direction++358Object.Direction &= FACING_LEFT359Object.ChaseChain = 0360end if361362if Object.Direction == FACING_RIGHT363Object.XVelocity = -0x1000364else365Object.XVelocity = 0x1000366end if367end if368break369370case DANGO_OFFSCREEN371// This state is unused as Dango uses a simpler OOB process instead372if Object.OutOfBounds == true373Object.State = DANGO_WALK374Object.Priority = PRIORITY_BOUNDS375end if376break377end switch378end if379380CallFunction(StageSetup_CheckGoodFuture)381382// See if the Dango is out of bounds383if Object.OutOfBounds == true384TempValue0 = Object.XPos385TempValue1 = Object.YPos386Object.XPos = Object.XOriginPos387Object.YPos = Object.YOriginPos388if Object.OutOfBounds == true389// It is, so in that case it's clear to restore the Dango to its original spot390Object.Priority = PRIORITY_BOUNDS391Object.State = DANGO_WALK392Object.Timer = 0393Object.Direction = FACING_RIGHT394Object.ChaseChain = 0395396if Object.Quality == GOOD_QUALITY397Object.XVelocity = -0x6000398else399Object.XVelocity = -0x1000400end if401else402Object.XPos = TempValue0403Object.YPos = TempValue1404end if405end if406end sub407408409sub ObjectPlayerInteraction410if Object.State == DANGO_WALK411// If the Dango's just wandering, then check to see if the player's stepped within activation range412413if Object.Direction == FACING_RIGHT414PlayerObjectCollision(C_TOUCH, -112, -128, 0, 128)415else416PlayerObjectCollision(C_TOUCH, 0, -128, 112, 128)417end if418419if CheckResult == true420// On the attack!421Object.State = DANGO_CURL1422end if423end if424425switch Object.State426case DANGO_WALK427case DANGO_CURL1428case DANGO_CURL2429case DANGO_UNCURL1430case DANGO_UNCURL2431case DANGO_UNCURLED432#platform: Use_Standalone433PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)434#endplatform435#platform: Use_Origins436PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)437#endplatform438if CheckResult == true439CallFunction(Player_BadnikBreak)440end if441break442443case DANGO_CHARGEROLL444#platform: Use_Standalone445PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)446#endplatform447#platform: Use_Origins448PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)449#endplatform450if CheckResult == true451CheckEqual(Player.Animation, ANI_JUMPING)452TempValue0 = CheckResult453CheckEqual(Player.Animation, ANI_SPINDASH)454TempValue0 |= CheckResult455if TempValue0 == true456// The player's rolled towards the Dango, so bounce the player back457Player.Speed = Player.XPos458Player.Speed -= Object.XPos459Player.Speed >>= 2460Player.XVelocity = Player.Speed461462// Account for aerial bouncing too if needed463if Player.Gravity == GRAVITY_AIR464Player.YVelocity = Player.YPos465Player.YVelocity -= Object.YPos466Player.YVelocity >>= 2467end if468else469// Hurt the player470// (Note that there are edge cases with Tails where he may end up breaking the Dango with his tails, instead)471CallFunction(Player_BadnikBreak)472end if473end if474break475476case DANGO_ROLLING477#platform: Use_Standalone478PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)479#endplatform480#platform: Use_Origins481PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)482#endplatform483if CheckResult == true484CheckEqual(Player.Animation, ANI_JUMPING)485TempValue0 = CheckResult486CheckEqual(Player.Animation, ANI_SPINDASH)487TempValue0 |= CheckResult488if TempValue0 == true489// The player's rolled towards the Dango, so recoil the both of them490Object.XVelocity = Player.XVelocity491Player.Speed = Player.XPos492Player.Speed -= Object.XPos493Player.Speed >>= 2494Player.XVelocity = Player.Speed495496if Player.Gravity == GRAVITY_AIR497// Account for Y recoil, too498Player.YVelocity = Player.YPos499Player.YVelocity -= Object.YPos500Player.YVelocity >>= 2501else502// The player is on the ground, make them bounce back rolling503Player.State = Player_State_Roll504Player.Animation = ANI_JUMPING505end if506else507// Hurt the player508// (See above note about Tails's fluffy but dangerous parts)509CallFunction(Player_BadnikBreak)510end if511end if512break513514end switch515end sub516517518sub ObjectDraw519if Object.State < 8520DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)521end if522end sub523524525sub ObjectStartup526LoadSpriteSheet("R8/Objects2.gif")527528// Dango Frames529530// 0-1 - Idle Animation, "Good" variant531SpriteFrame(-16, -7, 32, 24, 1, 84)532SpriteFrame(-16, -7, 32, 24, 1, 109)533534// 2-3 - Idle Animation, "Bad" variant (version with the cracked shell frames)535SpriteFrame(-16, -7, 32, 24, 34, 84)536SpriteFrame(-16, -7, 32, 24, 34, 109)537538// 4-5 - Curl539SpriteFrame(-16, -16, 32, 32, 34, 134)540SpriteFrame(-16, -16, 32, 32, 1, 167)541542// 6-9 - Rolling Frames543SpriteFrame(-16, -15, 32, 32, 34, 167)544SpriteFrame(-16, -15, 32, 32, 124, 223)545SpriteFrame(-16, -16, 32, 32, 1, 134)546SpriteFrame(-16, -15, 32, 32, 34, 167)547548// Cycle through the level and find all Dango objects549ArrayPos0 = 32550while ArrayPos0 < 1056551if Object[ArrayPos0].Type == TypeName[Dango]552Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos553Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos554if Object[ArrayPos0].Quality == GOOD_QUALITY555Object[ArrayPos0].XVelocity = -0x6000556else557Object[ArrayPos0].XVelocity = -0x1000558end if559end if560ArrayPos0++561loop562end sub563564565// ========================566// Editor Subs567// ========================568569sub RSDKEdit570if Editor.ReturnVariable == true571switch Editor.VariableID572case EDIT_VAR_PROPVAL // Property Value573CheckResult = Object.PropertyValue574CheckResult &= 1575break576case 0 // condition577CheckResult = Object.PropertyValue578CheckResult &= 1579break580end switch581else582switch Editor.VariableID583case EDIT_VAR_PROPVAL // Property Value584Object.PropertyValue = Editor.VariableValue585Object.PropertyValue &= 1586break587case 0 // condition588Object.PropertyValue = Editor.VariableValue589Object.PropertyValue &= 1590break591end switch592end if593end sub594595sub RSDKDraw596DrawSprite(Object.PropertyValue)597end sub598599600sub RSDKLoad601LoadSpriteSheet("R8/Objects2.gif")602// Dango Frames603604// 0-1 - Idle Animation, "Good" variant605SpriteFrame(-16, -7, 32, 24, 1, 84)606607// 2-3 - Idle Animation, "Bad" variant (version with the cracked shell frames)608SpriteFrame(-16, -7, 32, 24, 34, 84)609610AddEditorVariable("condition")611SetActiveVariable("condition")612AddEnumVariable("Good Quality", GOOD_QUALITY)613AddEnumVariable("Bad Quality", BAD_QUALITY)614end sub615616617