Path: blob/main/Scripts/R5/Sasuri.txt
1319 views
//-------------------Sonic CD Sasuri Script-------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.MoveTimer6#alias Object.Value1 : Object.CannonTimer78#alias Object.PropertyValue : Object.Quality910// Sasuri Bullet (SBullet) Aliases11#alias Object.Value1 : Object.XVelocity1213// States14#alias 0 : SASURI_FINDGROUND15#alias 1 : SASURI_CRAWLLEFT16#alias 2 : SASURI_CRAWLRIGHT17#alias 3 : SASURI_SPOTPLAYER18#alias 4 : SASURI_SHOOT19#alias 5 : SASURI_RETRACTCANNON2021// Badnik Quality / Property Values22#alias 0 : GOOD_QUALITY23#alias 1 : BAD_QUALITY2425// Collision Sides26#alias 0 : CSIDE_FLOOR2728// Stage SFX29#alias 2 : SFX_S_SHOT3031sub ObjectMain3233// Animate the Sasuri34Object.Frame++35Object.Frame %= 603637if Object.Quality == GOOD_QUALITY38switch Object.State39case SASURI_FINDGROUND40// See if there's any ground for the Sasuri to stand on41// Note - is this an error? Should it be ObjectTileGrip instead? That's what all the other stuff around here uses...42ObjectTileCollision(CSIDE_FLOOR, 0, 13, 0)4344if CheckResult == true45// If there is, then start crawling46Object.State = SASURI_CRAWLLEFT47else48// If there isn't, then move a pixel down and try again next frame49Object.YPos += 0x1000050end if51break5253case SASURI_CRAWLLEFT5455// Move the Sasuri left by one pixel56Object.XPos -= 0x100005758// Increment its movement timer, and see if it's time to turn around now59Object.MoveTimer--60if Object.MoveTimer <= -8061Object.State = SASURI_CRAWLRIGHT62Object.Direction = FACING_LEFT63end if6465// Also, see if the Sasuri is still on ground66// -> If it isn't, then turn around67ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)68if CheckResult == false69Object.State = SASURI_CRAWLRIGHT70Object.MoveTimer = 071Object.Direction = FACING_LEFT72end if73break7475case SASURI_CRAWLRIGHT7677// Move the Sasuri one pixel right78Object.XPos += 0x100007980// As with above, do timer stuff and see if the Sasuri should turn around now81Object.MoveTimer++82if Object.MoveTimer >= 8083Object.State = SASURI_CRAWLLEFT84Object.Direction = FACING_RIGHT85end if8687// Also like above, see if the Sasuri's still on ground and if it isn't, then turn around88ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)89if CheckResult == false90Object.State = SASURI_CRAWLLEFT91Object.MoveTimer = 092Object.Direction = FACING_RIGHT93end if94break9596case SASURI_SPOTPLAYER97// This state's set in ObjectPlayerInteraction if the Player is within shooting range9899if Object.CannonTimer < 30100Object.CannonTimer++101else102Object.State = SASURI_SHOOT103Object.CannonTimer = 0104end if105break106107case SASURI_SHOOT108if Object.CannonTimer < 40109if Object.CannonTimer == 10110PlayStageSfx(SFX_S_SHOT, false)111112// Create the Bullet that the Sasuri shot113CreateTempObject(TypeName[Sasuri Bullet], 0, Object.XPos, Object.YPos)114115// Move the Bullet 24 pixels up, to match where the Sasuri's cannon is drawn116Object[TempObjectPos].YPos -= 0x180000117118// Move it 24 pixels in the Sasuri's direction, as well as giving it a velocity of 3px per frame in that very same direction too119if Object.Direction == FACING_RIGHT120Object[TempObjectPos].XPos -= 0x70000121Object[TempObjectPos].XVelocity = -0x30000122else123Object[TempObjectPos].XPos += 0x70000124Object[TempObjectPos].XVelocity = 0x30000125end if126127// Move the Sasuri up a Draw Order in order to make it drawn on top of the shot Bullet128Object.DrawOrder = 4129end if130131Object.CannonTimer++132else133// Pull the cannon back in134Object.State = SASURI_RETRACTCANNON135Object.CannonTimer = 0136137// Move the Sasuri back to its original Draw Order as well, as at this point,138// the Bullet's definitely beyond the Sasuri now139Object.DrawOrder = 3140end if141break142143case SASURI_RETRACTCANNON144if Object.CannonTimer < 30145Object.CannonTimer++146else147148// ...what?149// Why make it shoot again? The State's set proper in a couple of lines after anyway...150Object.State = SASURI_SHOOT151152if Object.Direction == FACING_RIGHT153Object.State = SASURI_CRAWLLEFT154else155Object.State = SASURI_CRAWLRIGHT156end if157end if158break159160end switch161else162switch Object.State163case SASURI_FINDGROUND164// See if there's any ground for the Sasuri to stand on165// (Interestingly, the Good version of this state uses ObjectTileCollision instead,166// but I believe the error lies in the Good version rather than here)167ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)168169if CheckResult == true170// If the Sasuri foung ground collision, then start prowling around171Object.State = SASURI_CRAWLLEFT172else173// If collision wasn't found, however, then move a pixel down and wait 'till next frame174Object.YPos += 0x10000175end if176break177178case SASURI_CRAWLLEFT179180// Move at a rate of half a pixel left per frame181Object.XPos -= 0x8000182183// Allow the Sasuri to advance for 2 and two-thirds seconds before turning around184Object.MoveTimer--185if Object.MoveTimer <= -160186Object.State = SASURI_CRAWLRIGHT187Object.Direction = FACING_LEFT188end if189190// In addition to the timer condition, the Sasuri can also run out of ground as another condition for turning around191ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)192if CheckResult == false193Object.State = SASURI_CRAWLRIGHT194Object.MoveTimer = 0195Object.Direction = FACING_LEFT196end if197break198199case SASURI_CRAWLRIGHT200201// Just like before, move the Sasuri at a 0.5px rate, but this time to the right202Object.XPos += 0x8000203204// Same timing of 2 and two-thirds seconds, though do note that the Move Timer will likely be -160 when entering this state205// so the time is doubled206Object.MoveTimer++207if Object.MoveTimer >= 160208Object.State = SASURI_CRAWLLEFT209Object.Direction = FACING_RIGHT210end if211212// And like before, another condition for turning around is reached at the end of the ground213ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)214if CheckResult == false215Object.State = SASURI_CRAWLLEFT216Object.MoveTimer = 0217Object.Direction = FACING_RIGHT218end if219break220221case SASURI_SPOTPLAYER222if Object.CannonTimer < 30223Object.CannonTimer++224else225Object.State = SASURI_SHOOT226Object.CannonTimer = 0227end if228break229230case SASURI_SHOOT231// Poor Bad Sasuri... it can't even shoot, yet it tries anyway...232233if Object.CannonTimer < 40234Object.CannonTimer++235else236Object.State = SASURI_RETRACTCANNON237Object.CannonTimer = 0238end if239break240241case SASURI_RETRACTCANNON242if Object.CannonTimer < 30243Object.CannonTimer++244else245// huh? why is this here?246// it gets changed again a line later anyway...247Object.State = SASURI_SHOOT248249if Object.Direction == FACING_RIGHT250Object.State = SASURI_CRAWLLEFT251else252Object.State = SASURI_CRAWLRIGHT253end if254end if255break256257end switch258end if259260// See if the Sasuri should become a Flower instead261CallFunction(StageSetup_CheckGoodFuture)262263end sub264265266sub ObjectPlayerInteraction267#platform: Use_Standalone268PlayerObjectCollision(C_TOUCH, -22, -14, 22, 14)269#endplatform270#platform: Use_Origins271PlayerObjectCollision(C_ENEMY, -22, -14, 22, 14)272#endplatform273if CheckResult == true274CallFunction(Player_BadnikBreak)275end if276277switch Object.State278case SASURI_CRAWLLEFT279case SASURI_CRAWLRIGHT280// If in a movement state, then see if the Sasuri281if Object.CannonTimer == 0282PlayerObjectCollision(C_TOUCH, -64, -24, 64, 24)283if CheckResult == true284Object.State = SASURI_SPOTPLAYER285286if Player.XPos < Object.XPos287Object.Direction = FACING_RIGHT288else289Object.Direction = FACING_LEFT290end if291end if292else293Object.CannonTimer = 0294end if295break296297end switch298299end sub300301302sub ObjectDraw303304if Object.Quality == GOOD_QUALITY305if Object.Frame < 30306// In this order, draw the:307// - back paw308// - main body309// - front paw310311DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)312DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)313DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)314else315// These are the same order as detailed above, just with different frames for the paws316317DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)318DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)319DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)320end if321322switch Object.State323case SASURI_CRAWLLEFT324case SASURI_CRAWLRIGHT325case SASURI_SPOTPLAYER326case SASURI_RETRACTCANNON327// Draw the pulled back cannon frame328DrawSpriteFX(10, FX_FLIP, Object.XPos, Object.YPos)329break330331case SASURI_SHOOT332// The Sasuri's shooting, so draw the extended cannon frame333DrawSpriteFX(11, FX_FLIP, Object.XPos, Object.YPos)334break335336end switch337else338// Bad Sasuri version, use the broken versions of the Sasuri's sprites339340if Object.Frame < 30341DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)342DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)343DrawSpriteFX(7, FX_FLIP, Object.XPos, Object.YPos)344else345DrawSpriteFX(8, FX_FLIP, Object.XPos, Object.YPos)346DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)347DrawSpriteFX(9, FX_FLIP, Object.XPos, Object.YPos)348end if349350switch Object.State351case SASURI_CRAWLLEFT352case SASURI_CRAWLRIGHT353case SASURI_SPOTPLAYER354case SASURI_RETRACTCANNON355// Draw the Sasuri's broken retracted cannon frame356DrawSpriteFX(12, FX_FLIP, Object.XPos, Object.YPos)357break358359case SASURI_SHOOT360// The cannon's broken but the Sasuri's gonna try and use it anyway,361// draw the extended cannon frame362DrawSpriteFX(13, FX_FLIP, Object.XPos, Object.YPos)363break364365end switch366end if367368end sub369370371sub ObjectStartup372LoadSpriteSheet("R5/Objects.gif")373374// Sasuri Frames375376// Good Main Sasuri Frame377SpriteFrame(-24, -16, 48, 32, 174, 141)378379// Bad Main Sasuri Frame380SpriteFrame(-24, -16, 48, 32, 174, 174)381382// Good Sasuri Paw Frames383SpriteFrame(-32, -4, 32, 16, 100, 110)384SpriteFrame(-21, -3, 32, 16, 100, 110)385SpriteFrame(-28, -4, 32, 16, 100, 110)386SpriteFrame(-25, -3, 32, 16, 100, 110)387388// Bad Sasuri Paw Frames389SpriteFrame(-32, -4, 32, 16, 100, 127)390SpriteFrame(-21, -3, 32, 16, 100, 127)391SpriteFrame(-28, -4, 32, 16, 100, 127)392SpriteFrame(-25, -3, 32, 16, 100, 127)393394// Good Sasuri Cannon Frames395SpriteFrame(-9, -24, 24, 16, 100, 93)396SpriteFrame(-5, -29, 24, 16, 100, 93)397398// Bad Sasuri Cannon Frames399SpriteFrame(-1, -24, 16, 16, 133, 110)400SpriteFrame(3, -29, 16, 16, 133, 110)401402end sub403404405// ========================406// Editor Subs407// ========================408409sub RSDKEdit410if Editor.ReturnVariable == true411switch Editor.VariableID412case EDIT_VAR_PROPVAL // Property Value413CheckResult = Object.PropertyValue414break415case 0 // Condition416CheckResult = Object.PropertyValue417break418end switch419else420switch Editor.VariableID421case EDIT_VAR_PROPVAL // Property Value422Object.PropertyValue = Editor.VariableValue423break424case 0 // Condition425Object.PropertyValue = Editor.VariableValue426break427end switch428end if429end sub430431432sub RSDKDraw433if Object.PropertyValue == GOOD_QUALITY434DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)435DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)436DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)437DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)438else439DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)440DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)441DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)442DrawSpriteFX(7, FX_FLIP, Object.XPos, Object.YPos)443end if444end sub445446447sub RSDKLoad448LoadSpriteSheet("R5/Objects.gif")449450SpriteFrame(-24, -16, 48, 32, 174, 141)451SpriteFrame(-24, -16, 48, 32, 174, 174)452453SpriteFrame(-32, -4, 32, 16, 100, 110)454SpriteFrame(-21, -3, 32, 16, 100, 110)455456SpriteFrame(-32, -4, 32, 16, 100, 127)457SpriteFrame(-21, -3, 32, 16, 100, 127)458459SpriteFrame(-9, -24, 24, 16, 100, 93)460SpriteFrame(-1, -24, 16, 16, 133, 110)461462AddEditorVariable("Condition")463SetActiveVariable("Condition")464AddEnumVariable("Good", GOOD_QUALITY)465AddEnumVariable("Bad", BAD_QUALITY)466end sub467468469