Path: blob/main/Scripts/R7/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// Badnik Quality / Property Values33#alias 0 : GOOD_QUALITY34#alias 1 : BAD_QUALITY3536// Priority37#alias 0 : PRIORITY_BOUNDS38#alias 1 : PRIORITY_ACTIVE394041sub ObjectMain42if Object.Quality == GOOD_QUALITY43switch Object.State44case DANGO_WALK45Object.Priority = PRIORITY_ACTIVE4647Object.Frame = Object.Timer48Object.Frame /= 104950Object.Timer++51Object.Timer %= 205253Object.XPos += Object.XVelocity5455if Object.Direction == FACING_RIGHT56ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)57else58ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)59end if6061if CheckResult == false62FlipSign(Object.XVelocity)63Object.Direction++64Object.Direction &= FACING_LEFT6566Object.ChaseChain = 067else68if Object.XVelocity > 069ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)70if CheckResult == true71FlipSign(Object.XVelocity)72Object.Direction++73Object.Direction &= FACING_LEFT7475Object.ChaseChain = 076end if77else78ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)79if CheckResult == true80FlipSign(Object.XVelocity)81Object.Direction++82Object.Direction &= FACING_LEFT8384Object.ChaseChain = 085end if86end if87end if88break8990case DANGO_CURL191Object.Frame = 492if Object.Timer < 893Object.Timer++94else95Object.Timer = 096Object.State++97end if98break99100case DANGO_CURL2101Object.Frame = 5102if Object.Timer < 6103Object.Timer++104else105Object.Timer = 0106Object.State++107end if108break109110case DANGO_CHARGEROLL111Object.Frame = Object.AnimationTimer112Object.Frame /= 5113Object.Frame += 6114115Object.AnimationTimer++116Object.AnimationTimer %= 10117118if Object.Timer < 34119Object.Timer++120else121Object.Timer = 0122Object.State++123if Object.Direction == FACING_RIGHT124Object.XVelocity = -0x40000125else126Object.XVelocity = 0x40000127end if128end if129break130131case DANGO_ROLLING132Object.Frame = Object.AnimationTimer133Object.Frame /= 5134Object.Frame += 6135136Object.AnimationTimer++137Object.AnimationTimer %= 10138139Object.XPos += Object.XVelocity140141if Object.Direction == FACING_RIGHT142ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)143else144ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)145end if146147if CheckResult == false148Object.State++149Object.ChaseChain++150else151if Object.XVelocity > 0152ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)153if CheckResult == true154Object.State++155Object.ChaseChain++156end if157else158ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)159if CheckResult == true160Object.State++161Object.ChaseChain++162end if163end if164end if165break166167case DANGO_UNCURL1168Object.Frame = 5169if Object.Timer < 6170Object.Timer++171else172Object.Timer = 0173Object.State++174end if175break176177case DANGO_UNCURL2178Object.Frame = 4179if Object.Timer < 8180Object.Timer++181else182Object.Timer = 0183Object.State++184end if185break186187case DANGO_UNCURLED188Object.Frame = 0189if Object.Timer < 16190Object.Timer++191else192Object.Timer = 0193Object.State = DANGO_WALK194if Object.ChaseChain > 7195// Tried going in the same direction 8 times now...196// Even if the player's the other way, go ahead and change directions197198Object.Direction++199Object.Direction &= FACING_LEFT200Object.ChaseChain = 0201end if202203if Object.Direction == FACING_RIGHT204Object.XVelocity = -0x6000205else206Object.XVelocity = 0x6000207end if208end if209break210211case DANGO_OFFSCREEN212// This state is unused, but it serves just about the same buffer purpose as it does with other badniks213if Object.OutOfBounds == true214Object.State = DANGO_WALK215Object.Priority = PRIORITY_BOUNDS216end if217break218219end switch220else221switch Object.State222case DANGO_WALK223Object.Priority = PRIORITY_ACTIVE224225Object.Frame = Object.Timer226Object.Frame /= 30227Object.Frame += 2228229Object.Timer++230Object.Timer %= 60231232Object.XPos += Object.XVelocity233234if Object.Direction == FACING_RIGHT235ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)236else237ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)238end if239240if CheckResult == false241FlipSign(Object.XVelocity)242Object.Direction++243Object.Direction &= FACING_LEFT244245Object.ChaseChain = 0246else247if Object.XVelocity > 0248ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)249if CheckResult == true250FlipSign(Object.XVelocity)251Object.Direction++252Object.Direction &= FACING_LEFT253254Object.ChaseChain = 0255end if256else257ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)258if CheckResult == true259FlipSign(Object.XVelocity)260Object.Direction++261Object.Direction &= FACING_LEFT262263Object.ChaseChain = 0264end if265end if266end if267break268269case DANGO_CURL1270Object.Frame = 4271if Object.Timer < 20272Object.Timer++273else274Object.Timer = 0275Object.State++276end if277break278279case DANGO_CURL2280Object.Frame = 5281if Object.Timer < 12282Object.Timer++283else284Object.Timer = 0285Object.State++286end if287break288289case DANGO_CHARGEROLL290Object.Frame = Object.AnimationTimer291Object.Frame /= 10292Object.Frame += 8293294Object.AnimationTimer++295Object.AnimationTimer %= 20296297if Object.Timer < 96298Object.Timer++299else300Object.Timer = 0301Object.State++302if Object.Direction == FACING_RIGHT303Object.XVelocity = -0x10000304else305Object.XVelocity = 0x10000306end if307end if308break309310case DANGO_ROLLING311Object.Frame = Object.AnimationTimer312Object.Frame /= 10313Object.Frame += 8314315Object.AnimationTimer++316Object.AnimationTimer %= 20317318Object.XPos += Object.XVelocity319320if Object.Direction == FACING_RIGHT321ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)322else323ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)324end if325326if CheckResult == false327Object.State++328Object.ChaseChain++329else330if Object.XVelocity > 0331ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)332if CheckResult == true333Object.State++334Object.ChaseChain++335end if336else337ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)338if CheckResult == true339Object.State++340Object.ChaseChain++341end if342end if343end if344break345346case DANGO_UNCURL1347Object.Frame = 5348if Object.Timer < 12349Object.Timer++350else351Object.Timer = 0352Object.State++353end if354break355356case DANGO_UNCURL2357Object.Frame = 4358if Object.Timer < 20359Object.Timer++360else361Object.Timer = 0362Object.State++363end if364break365366case DANGO_UNCURLED367Object.Frame = 2368if Object.Timer < 64369Object.Timer++370else371Object.Timer = 0372Object.State = DANGO_WALK373if Object.ChaseChain > 7374// Been going in the same direction for 8 cycles now...375// Even if it may be opposite of the player, go ahead and change directions because much isn't happening now anyway376377Object.Direction++378Object.Direction &= FACING_LEFT379380Object.ChaseChain = 0381end if382383if Object.Direction == FACING_RIGHT384Object.XVelocity = -0x1000385else386Object.XVelocity = 0x1000387end if388end if389break390391case DANGO_OFFSCREEN392// This state is unused as Dango uses a simpler OOB process instead393if Object.OutOfBounds == true394Object.State = DANGO_WALK395Object.Priority = PRIORITY_BOUNDS396end if397break398399end switch400end if401402// Standard Badnik stuff, make sure it shouldn't become a Flower automatically or anything403CallFunction(StageSetup_CheckGoodFuture)404405// See if the Dango is out of bounds406if Object.OutOfBounds == true407408// If it is, then see if its starting position is out of bounds too409TempValue0 = Object.XPos410TempValue1 = Object.YPos411412Object.XPos = Object.XOriginPos413Object.YPos = Object.YOriginPos414415if Object.OutOfBounds == true416// It is too, so in that case it's clear to restore the Dango to its original spot417Object.Priority = PRIORITY_BOUNDS418Object.State = DANGO_WALK419Object.Timer = 0420Object.Direction = FACING_RIGHT421422Object.ChaseChain = 0423424if Object.Quality == GOOD_QUALITY425Object.XVelocity = -0x6000426else427Object.XVelocity = -0x1000428end if429else430// Nope not ready yet, move back431432Object.XPos = TempValue0433Object.YPos = TempValue1434end if435end if436437end sub438439440sub ObjectPlayerInteraction441if Object.State == DANGO_WALK442// If the Dango's just wandering, then check to see if the player's stepped within activation range443if Object.Direction == FACING_RIGHT444PlayerObjectCollision(C_TOUCH, -112, -128, 0, 128)445else446PlayerObjectCollision(C_TOUCH, 0, -128, 112, 128)447end if448449if CheckResult == true450// On the attack!451Object.State = DANGO_CURL1452end if453end if454455switch Object.State456case DANGO_WALK457case DANGO_CURL1458case DANGO_CURL2459case DANGO_UNCURL1460case DANGO_UNCURL2461case DANGO_UNCURLED462// The Dango is in a breakable form, so just check for simple badnik breaking463#platform: Use_Standalone464PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)465#endplatform466#platform: Use_Origins467PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)468#endplatform469if CheckResult == true470CallFunction(Player_BadnikBreak)471end if472break473474case DANGO_CHARGEROLL475#platform: Use_Standalone476PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)477#endplatform478#platform: Use_Origins479PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)480#endplatform481if CheckResult == true482CheckEqual(Player.Animation, ANI_JUMPING)483TempValue0 = CheckResult484CheckEqual(Player.Animation, ANI_SPINDASH)485TempValue0 |= CheckResult486if TempValue0 == true487// The player's rolled towards the Dango, so bounce the player back488Player.Speed = Player.XPos489Player.Speed -= Object.XPos490Player.Speed >>= 2491492Player.XVelocity = Player.Speed493494// Account for aerial bouncing too if needed495if Player.Gravity == GRAVITY_AIR496Player.YVelocity = Player.YPos497Player.YVelocity -= Object.YPos498Player.YVelocity >>= 2499end if500else501// Hurt the player502// (Note that there are edge cases with Tails where he may end up breaking the Dango with his tails, instead)503CallFunction(Player_BadnikBreak)504end if505end if506break507508case DANGO_ROLLING509#platform: Use_Standalone510PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)511#endplatform512#platform: Use_Origins513PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)514#endplatform515if CheckResult == true516CheckEqual(Player.Animation, ANI_JUMPING)517TempValue0 = CheckResult518CheckEqual(Player.Animation, ANI_SPINDASH)519TempValue0 |= CheckResult520if TempValue0 == true521// The player's rolled towards the Dango, so recoil the both of them522523Object.XVelocity = Player.XVelocity524Player.Speed = Player.XPos525Player.Speed -= Object.XPos526Player.Speed >>= 2527Player.XVelocity = Player.Speed528529if Player.Gravity == GRAVITY_AIR530// Account for Y recoil, too531Player.YVelocity = Player.YPos532Player.YVelocity -= Object.YPos533Player.YVelocity >>= 2534else535// The player is on the ground, make them bounce back rolling536Player.State = Player_State_Roll537Player.Animation = ANI_JUMPING538end if539else540// Hurt the player541// (See above note about Tails's fluffy but dangerous parts)542CallFunction(Player_BadnikBreak)543end if544end if545break546547end switch548549end sub550551552sub ObjectDraw553if Object.State < DANGO_OFFSCREEN554DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)555end if556end sub557558559sub ObjectStartup560LoadSpriteSheet("R7/Objects.gif")561562// Dango Frames563564// 0-1 - Idle Animation, "Good" variant565SpriteFrame(-16, -7, 32, 24, 116, 121)566SpriteFrame(-16, -7, 32, 24, 149, 121)567568// 2-3 - Idle Animation, "Bad" variant (version with the cracked shell frames)569SpriteFrame(-16, -7, 32, 24, 116, 146)570SpriteFrame(-16, -7, 32, 24, 149, 146)571572// 4-5 - Curl573SpriteFrame(-16, -16, 32, 32, 51, 219)574SpriteFrame(-16, -16, 32, 32, 84, 219)575576// 6-9 - Rolling Frames577SpriteFrame(-16, -15, 32, 32, 51, 186)578SpriteFrame(-16, -15, 32, 32, 117, 186)579SpriteFrame(-16, -16, 32, 32, 84, 186)580SpriteFrame(-16, -15, 32, 32, 51, 186)581582// Cycle through the level and find all Dango objects583ArrayPos0 = 32584while ArrayPos0 < 1056585if Object[ArrayPos0].Type == TypeName[Dango]586587// Set the Dango's initial positions588Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos589Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos590591// Set its starting velocity too, "Bad" Dangos go slower than "Good" ones since they're, y'know, "Bad"592if Object[ArrayPos0].Quality == GOOD_QUALITY593// Speed of 0.375 pixels per frame594Object[ArrayPos0].XVelocity = -0x6000595else596// 0.0625 pixels per frame... that's hardly anything!597Object[ArrayPos0].XVelocity = -0x1000598end if599end if600601ArrayPos0++602loop603604end sub605606607// ========================608// Editor Subs609// ========================610611sub RSDKEdit612if Editor.ReturnVariable == true613switch Editor.VariableID614case EDIT_VAR_PROPVAL // Property Value615case 0 // Condition616CheckResult = Object.PropertyValue617break618end switch619else620switch Editor.VariableID621case EDIT_VAR_PROPVAL // Property Value622case 0 // Condition623Object.PropertyValue = Editor.VariableValue624break625end switch626end if627end sub628629630sub RSDKDraw631DrawSprite(Object.Quality)632end sub633634635sub RSDKLoad636LoadSpriteSheet("R7/Objects.gif")637SpriteFrame(-16, -7, 32, 24, 116, 121) // Normal "Good" version638SpriteFrame(-16, -7, 32, 24, 116, 146) // Cracked "Bad" version639640AddEditorVariable("Condition")641SetActiveVariable("Condition")642AddEnumVariable("Good", GOOD_QUALITY)643AddEnumVariable("Bad", BAD_QUALITY)644end sub645646647