Path: blob/main/Scripts/R5/Kemusi.txt
1319 views
//-------------------Sonic CD Kemusi Script-------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer67#alias Object.Value1 : Object.BodyPosition1X8#alias Object.Value4 : Object.BodyPosition1Y910#alias Object.Value2 : Object.BodyPosition2X11#alias Object.Value5 : Object.BodyPosition2Y1213#alias Object.Value3 : Object.BodyPosition3X14#alias Object.Value6 : Object.BodyPosition3Y1516// (The head's position is base XPos and YPos)1718// Bitfield for all the directions of the individual pieces19#alias Object.Value7 : Object.PieceDirection2021// The range the Kemusi will go, stored in rather unconventional values...22#alias Object.Scale : Object.BoundsL23#alias Object.Rotation : Object.BoundsR2425#alias Object.PropertyValue : Object.Quality2627// States28#alias 0 : KEMUSI_INIT29#alias 1 : KEMUSI_FINDGROUND30#alias 2 : KEMUSI_SPIKED_ADVANCE31#alias 3 : KEMUSI_SPIKED_RETRACT32#alias 4 : KEMUSI_NORMAL_ADVANCE33#alias 5 : KEMUSI_NORMAL_RETRACT3435// Collision Sides36#alias 0 : CSIDE_FLOOR3738// Badnik Quality / Property Values39#alias 0 : GOOD_QUALITY40#alias 1 : BAD_QUALITY414243sub ObjectMain4445switch Object.State46case KEMUSI_INIT47// Set initial body part positions4849// Setup the first body fragment to be 12 pixels to the right from the head50Object.BodyPosition1X = Object.XPos51Object.BodyPosition1X += 0xC00005253// Set the second body fragment to be 24 pixels away from the head54Object.BodyPosition2X = Object.XPos55Object.BodyPosition2X += 0x1800005657// And then make the third, and last, body fragment 36 pixels away from the head58Object.BodyPosition3X = Object.XPos59Object.BodyPosition3X += 0x2400006061// All the body fragments start on the same Y Position as the head62Object.BodyPosition1Y = Object.YPos63Object.BodyPosition2Y = Object.YPos64Object.BodyPosition3Y = Object.YPos6566// And setup initial bounds too6768// Left bounds is 64 pixels away69Object.BoundsL = Object.XPos70Object.BoundsL -= 0x4000007172// And right bounds is 64 pixels away too, adding up to a total of 128 pixels range73Object.BoundsR = Object.XPos74Object.BoundsR += 0x4000007576Object.State = KEMUSI_FINDGROUND77break7879case KEMUSI_FINDGROUND80// Get the directions of every piece (incl. head)81GetBit(TempValue0, Object.PieceDirection, 0)82GetBit(TempValue1, Object.PieceDirection, 1)83GetBit(TempValue2, Object.PieceDirection, 2)84GetBit(TempValue3, Object.PieceDirection, 3)8586// First, update make the head track the ground if needed87if TempValue0 == false88ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)89if CheckResult == false90// If there was no collision, move the head down by a pixel91Object.YPos += 0x1000092else93TempValue0 = CheckResult94end if95end if9697// ObjectTileCollision can only pull from Object.XPos and Object.YPos, no custom values, so it's rapidly98// changing throughout this section99// With that, back it up now so it can be properly set again later100TempValue4 = Object.XPos101TempValue5 = Object.YPos102103// Then, update following piece 1104if TempValue1 == false105Object.XPos = Object.BodyPosition1X106Object.YPos = Object.BodyPosition1Y107108ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)109if CheckResult == false110Object.BodyPosition1Y += 0x10000111else112TempValue1 = CheckResult113Object.BodyPosition1Y = Object.YPos114end if115end if116117// Now, update piece 2's grip to the ground118if TempValue2 == false119Object.XPos = Object.BodyPosition2X120Object.YPos = Object.BodyPosition2Y121122ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)123if CheckResult == false124Object.BodyPosition2Y += 0x10000125else126TempValue2 = CheckResult127Object.BodyPosition2Y = Object.YPos128end if129end if130131// And finally, piece 3132if TempValue3 == false133Object.XPos = Object.BodyPosition3X134Object.YPos = Object.BodyPosition3Y135136ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)137if CheckResult == false138Object.BodyPosition3Y += 0x10000139else140TempValue3 = CheckResult141Object.BodyPosition3Y = Object.YPos142end if143end if144145// Restore the Object's position, now that all the Object Tile Collision checks have been done146Object.XPos = TempValue4147Object.YPos = TempValue5148149// Add the collision results of all individual pieces150// (0 if in the air, 1 if on the ground)151TempValue4 = TempValue0152TempValue4 += TempValue1153TempValue4 += TempValue2154TempValue4 += TempValue3155156// 4 means, are all pieces are touching the ground?157if TempValue4 == 4158if Object.Quality == GOOD_QUALITY159Object.State = KEMUSI_SPIKED_RETRACT160else161Object.State = KEMUSI_NORMAL_RETRACT162end if163164Object.PieceDirection = 0165else166// Store the current collision states for use next frame167SetBit(Object.PieceDirection, 0, TempValue0)168SetBit(Object.PieceDirection, 1, TempValue1)169SetBit(Object.PieceDirection, 2, TempValue2)170SetBit(Object.PieceDirection, 3, TempValue3)171end if172break173174case KEMUSI_SPIKED_ADVANCE175if Object.Timer < 36176Object.Timer++177178// See which way the Head's facing179GetBit(TempValue0, Object.PieceDirection, 0)180181if TempValue0 == 0182// The Head's facing left183184// Move it half a pixel to the left185Object.XPos -= 0x8000186187// See if it's still the ground188ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)189190if CheckResult == true191// The Head's still on the ground, that's good192193if Object.XPos < Object.BoundsL194// However, if the Head's now past the Object's Left bounds, then turn around195SetBit(Object.PieceDirection, 0, 1)196end if197else198// The Head's now in the air, turn it around199SetBit(Object.PieceDirection, 0, 1)200end if201else202// The Head's facing right203204// Move it a half pixel to the right205Object.XPos += 0x8000206207// See if the Head's still on the ground208ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)209210if CheckResult == true211// Yup the Head's still grounded, that's good212213if Object.XPos > Object.BoundsR214// However, the Head's beyond the Right bounds, so turn around215SetBit(Object.PieceDirection, 0, 0)216end if217else218// Head's now in the air, turn around219SetBit(Object.PieceDirection, 0, 0)220end if221end if222223// Now, onto the Body segments!224225// First, backup the Object's base Position226TempValue1 = Object.XPos227TempValue2 = Object.YPos228229// Get Body Piece 1's Direction230GetBit(TempValue0, Object.PieceDirection, 1)231232if TempValue0 == 0233// Facing left234235// Move it left by about 0.333 pixels236Object.BodyPosition1X -= 0x5555237238// Move the entire Object to this Body Piece's Position239Object.XPos = Object.BodyPosition1X240Object.YPos = Object.BodyPosition1Y241242// Check to see if it can Grip to a tile243ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)244245if CheckResult == true246// Move this Body Piece to be on the floor247Object.BodyPosition1Y = Object.YPos248249if Object.BodyPosition1X < Object.BoundsL250// Left bounds reached, turn around251SetBit(Object.PieceDirection, 1, 1)252end if253else254// It's in the air, so turn around255SetBit(Object.PieceDirection, 1, 1)256end if257else258// Facing right259260// Move abut a third of a pixel right261Object.BodyPosition1X += 0x5555262263// Move the entire Object to the current Body Piece's Position264Object.XPos = Object.BodyPosition1X265Object.YPos = Object.BodyPosition1Y266267// Check Grip to the Tile, this is why the Object needed to be moved268ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)269270if CheckResult == true271// Move the Body Piece to where the ground grip is272Object.BodyPosition1Y = Object.YPos273274if Object.BodyPosition1X > Object.BoundsR275// The Piece is past its right Bounds, turn it around276SetBit(Object.PieceDirection, 1, 0)277end if278else279// The Object's in the air, turn around280SetBit(Object.PieceDirection, 1, 0)281end if282end if283284// Get the direction of Body Fragment 2285GetBit(TempValue0, Object.PieceDirection, 2)286287if TempValue0 == 0288// Piece is facing left289290// Move the Piece about 0.1666 pixels left291Object.BodyPosition2X -= 0x2AAA292293// And now move the entire Object to this Piece's Position294Object.XPos = Object.BodyPosition2X295Object.YPos = Object.BodyPosition2Y296297// Grip this Piece to the tile298ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)299300if CheckResult == true301Object.BodyPosition2Y = Object.YPos302if Object.BodyPosition2X < Object.BoundsL303SetBit(Object.PieceDirection, 2, 1)304end if305else306SetBit(Object.PieceDirection, 2, 1)307end if308else309Object.BodyPosition2X += 0x2AAA310311Object.XPos = Object.BodyPosition2X312Object.YPos = Object.BodyPosition2Y313314ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)315if CheckResult == true316Object.BodyPosition2Y = Object.YPos317318if Object.BodyPosition2X > Object.BoundsR319SetBit(Object.PieceDirection, 2, 0)320end if321else322SetBit(Object.PieceDirection, 2, 0)323end if324end if325326Object.XPos = TempValue1327Object.YPos = TempValue2328else329330// Are all Pieces facing left?331if Object.PieceDirection == 0332Object.BodyPosition1X = Object.XPos333Object.BodyPosition1X += 0xC0000334335Object.BodyPosition2X = Object.XPos336Object.BodyPosition2X += 0x180000337338Object.BodyPosition3X = Object.XPos339Object.BodyPosition3X += 0x240000340end if341342// Are all Pieces facing right?343if Object.PieceDirection == 15344Object.BodyPosition1X = Object.XPos345Object.BodyPosition1X -= 0xC0000346347Object.BodyPosition2X = Object.XPos348Object.BodyPosition2X -= 0x180000349350Object.BodyPosition3X = Object.XPos351Object.BodyPosition3X -= 0x240000352end if353354Object.Timer = 0355Object.State = KEMUSI_SPIKED_RETRACT356end if357break358359case KEMUSI_SPIKED_RETRACT360if Object.Timer < 36361Object.Timer++362363TempValue1 = Object.XPos364TempValue2 = Object.YPos365366GetBit(TempValue0, Object.PieceDirection, 1)367if TempValue0 == 0368Object.BodyPosition1X -= 0x2AAA369370Object.XPos = Object.BodyPosition1X371Object.YPos = Object.BodyPosition1Y372373ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)374if CheckResult == true375Object.BodyPosition1Y = Object.YPos376377if Object.BodyPosition1X < Object.BoundsL378SetBit(Object.PieceDirection, 1, 1)379end if380else381SetBit(Object.PieceDirection, 1, 1)382end if383else384Object.BodyPosition1X += 0x2AAA385386Object.XPos = Object.BodyPosition1X387Object.YPos = Object.BodyPosition1Y388389ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)390if CheckResult == true391Object.BodyPosition1Y = Object.YPos392393if Object.BodyPosition1X > Object.BoundsR394SetBit(Object.PieceDirection, 1, 0)395end if396else397SetBit(Object.PieceDirection, 1, 0)398end if399end if400401GetBit(TempValue0, Object.PieceDirection, 2)402if TempValue0 == 0403Object.BodyPosition2X -= 0x5555404405Object.XPos = Object.BodyPosition2X406Object.YPos = Object.BodyPosition2Y407408ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)409if CheckResult == true410Object.BodyPosition2Y = Object.YPos411412if Object.BodyPosition2X < Object.BoundsL413SetBit(Object.PieceDirection, 2, 1)414end if415else416SetBit(Object.PieceDirection, 2, 1)417end if418else419Object.BodyPosition2X += 0x5555420421Object.XPos = Object.BodyPosition2X422Object.YPos = Object.BodyPosition2Y423424ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)425if CheckResult == true426Object.BodyPosition2Y = Object.YPos427428if Object.BodyPosition2X > Object.BoundsR429SetBit(Object.PieceDirection, 2, 0)430end if431else432SetBit(Object.PieceDirection, 2, 0)433end if434end if435436GetBit(TempValue0, Object.PieceDirection, 3)437if TempValue0 == 0438Object.BodyPosition3X -= 0x8000439440Object.XPos = Object.BodyPosition3X441Object.YPos = Object.BodyPosition3Y442443ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)444if CheckResult == true445Object.BodyPosition3Y = Object.YPos446447if Object.BodyPosition3X < Object.BoundsL448SetBit(Object.PieceDirection, 3, 1)449end if450else451SetBit(Object.PieceDirection, 3, 1)452end if453else454Object.BodyPosition3X += 0x8000455456Object.XPos = Object.BodyPosition3X457Object.YPos = Object.BodyPosition3Y458459ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)460461if CheckResult == true462Object.BodyPosition3Y = Object.YPos463464if Object.BodyPosition3X > Object.BoundsR465SetBit(Object.PieceDirection, 3, 0)466end if467else468SetBit(Object.PieceDirection, 3, 0)469end if470end if471472Object.XPos = TempValue1473Object.YPos = TempValue2474else475Object.Timer = 0476Object.State = KEMUSI_SPIKED_ADVANCE477end if478break479480case KEMUSI_NORMAL_ADVANCE481if Object.Timer < 36482Object.Timer++483484GetBit(TempValue0, Object.PieceDirection, 0)485if TempValue0 == 0486Object.XPos -= 0x4000487488ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)489490if CheckResult == true491if Object.XPos < Object.BoundsL492SetBit(Object.PieceDirection, 0, 1)493end if494else495SetBit(Object.PieceDirection, 0, 1)496end if497else498Object.XPos += 0x4000499500ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)501502if CheckResult == true503if Object.XPos > Object.BoundsR504SetBit(Object.PieceDirection, 0, 0)505end if506else507SetBit(Object.PieceDirection, 0, 0)508end if509end if510511TempValue1 = Object.XPos512TempValue2 = Object.YPos513514GetBit(TempValue0, Object.PieceDirection, 1)515if TempValue0 == 0516Object.BodyPosition1X -= 0x2AAA517518Object.XPos = Object.BodyPosition1X519Object.YPos = Object.BodyPosition1Y520521ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)522523if CheckResult == true524Object.BodyPosition1Y = Object.YPos525526if Object.BodyPosition1X < Object.BoundsL527SetBit(Object.PieceDirection, 1, 1)528end if529else530SetBit(Object.PieceDirection, 1, 1)531end if532else533Object.BodyPosition1X += 0x2AAA534535Object.XPos = Object.BodyPosition1X536Object.YPos = Object.BodyPosition1Y537538ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)539540if CheckResult == true541Object.BodyPosition1Y = Object.YPos542543if Object.BodyPosition1X > Object.BoundsR544SetBit(Object.PieceDirection, 1, 0)545end if546else547SetBit(Object.PieceDirection, 1, 0)548end if549end if550551GetBit(TempValue0, Object.PieceDirection, 2)552if TempValue0 == 0553Object.BodyPosition2X -= 0x1555554555Object.XPos = Object.BodyPosition2X556Object.YPos = Object.BodyPosition2Y557558ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)559560if CheckResult == true561Object.BodyPosition2Y = Object.YPos562563if Object.BodyPosition2X < Object.BoundsL564SetBit(Object.PieceDirection, 2, 1)565end if566else567SetBit(Object.PieceDirection, 2, 1)568end if569else570Object.BodyPosition2X += 0x1555571572Object.XPos = Object.BodyPosition2X573Object.YPos = Object.BodyPosition2Y574575ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)576577if CheckResult == true578Object.BodyPosition2Y = Object.YPos579580if Object.BodyPosition2X > Object.BoundsR581SetBit(Object.PieceDirection, 2, 0)582end if583else584SetBit(Object.PieceDirection, 2, 0)585end if586end if587588Object.XPos = TempValue1589Object.YPos = TempValue2590else591if Object.PieceDirection == 0592Object.BodyPosition1X = Object.XPos593Object.BodyPosition1X += 0xC0000594595Object.BodyPosition2X = Object.XPos596Object.BodyPosition2X += 0x180000597598Object.BodyPosition3X = Object.XPos599Object.BodyPosition3X += 0x240000600end if601602if Object.PieceDirection == 15603Object.BodyPosition1X = Object.XPos604Object.BodyPosition1X -= 0xC0000605606Object.BodyPosition2X = Object.XPos607Object.BodyPosition2X -= 0x180000608609Object.BodyPosition3X = Object.XPos610Object.BodyPosition3X -= 0x240000611end if612613Object.Timer = 0614Object.State = KEMUSI_NORMAL_RETRACT615end if616break617618case KEMUSI_NORMAL_RETRACT619if Object.Timer < 36620Object.Timer++621622TempValue1 = Object.XPos623TempValue2 = Object.YPos624625GetBit(TempValue0, Object.PieceDirection, 1)626if TempValue0 == 0627Object.BodyPosition1X -= 0x1555628629Object.XPos = Object.BodyPosition1X630Object.YPos = Object.BodyPosition1Y631632ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)633if CheckResult == true634Object.BodyPosition1Y = Object.YPos635636if Object.BodyPosition1X < Object.BoundsL637SetBit(Object.PieceDirection, 1, 1)638end if639else640SetBit(Object.PieceDirection, 1, 1)641end if642else643Object.BodyPosition1X += 0x1555644645Object.XPos = Object.BodyPosition1X646Object.YPos = Object.BodyPosition1Y647648ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)649650if CheckResult == true651Object.BodyPosition1Y = Object.YPos652653if Object.BodyPosition1X > Object.BoundsR654SetBit(Object.PieceDirection, 1, 0)655end if656else657SetBit(Object.PieceDirection, 1, 0)658end if659end if660661GetBit(TempValue0, Object.PieceDirection, 2)662if TempValue0 == 0663Object.BodyPosition2X -= 0x2AAA664665Object.XPos = Object.BodyPosition2X666Object.YPos = Object.BodyPosition2Y667668ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)669670if CheckResult == true671Object.BodyPosition2Y = Object.YPos672673if Object.BodyPosition2X < Object.BoundsL674SetBit(Object.PieceDirection, 2, 1)675end if676else677SetBit(Object.PieceDirection, 2, 1)678end if679else680Object.BodyPosition2X += 0x2AAA681682Object.XPos = Object.BodyPosition2X683Object.YPos = Object.BodyPosition2Y684685ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)686687if CheckResult == true688Object.BodyPosition2Y = Object.YPos689690if Object.BodyPosition2X > Object.BoundsR691SetBit(Object.PieceDirection, 2, 0)692end if693else694SetBit(Object.PieceDirection, 2, 0)695end if696end if697698GetBit(TempValue0, Object.PieceDirection, 3)699if TempValue0 == 0700Object.BodyPosition3X -= 0x4000701702Object.XPos = Object.BodyPosition3X703Object.YPos = Object.BodyPosition3Y704705ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)706707if CheckResult == true708Object.BodyPosition3Y = Object.YPos709710if Object.BodyPosition3X < Object.BoundsL711SetBit(Object.PieceDirection, 3, 1)712end if713else714SetBit(Object.PieceDirection, 3, 1)715end if716else717Object.BodyPosition3X += 0x4000718719Object.XPos = Object.BodyPosition3X720Object.YPos = Object.BodyPosition3Y721722ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)723724if CheckResult == true725Object.BodyPosition3Y = Object.YPos726727if Object.BodyPosition3X > Object.BoundsR728SetBit(Object.PieceDirection, 3, 0)729end if730else731SetBit(Object.PieceDirection, 3, 0)732end if733end if734735Object.XPos = TempValue1736Object.YPos = TempValue2737738else739Object.Timer = 0740Object.State = KEMUSI_NORMAL_ADVANCE741end if742break743744end switch745746CallFunction(StageSetup_CheckGoodFuture)747748end sub749750751sub ObjectPlayerInteraction752753// First, check for the head754#platform: Use_Standalone755PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)756#endplatform757758#platform: Use_Origins759PlayerObjectCollision(C_ENEMY, -8, -10, 8, 8)760#endplatform761762if CheckResult == true763CallFunction(Player_BadnikBreak)764else765// The head wasn't hit, so now check against every body fragment766767// First, backup the Object's base Position768TempValue1 = Object.XPos769TempValue2 = Object.YPos770771if Object.Quality == GOOD_QUALITY772Object.XPos = Object.BodyPosition1X773Object.YPos = Object.BodyPosition1Y774775PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)776777if CheckResult == true778CallFunction(Player_Hit)779else780Object.XPos = Object.BodyPosition2X781Object.YPos = Object.BodyPosition2Y782783PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)784785if CheckResult == true786CallFunction(Player_Hit)787else788Object.XPos = Object.BodyPosition3X789Object.YPos = Object.BodyPosition3Y790791PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)792793if CheckResult == true794CallFunction(Player_Hit)795end if796end if797end if798else799Object.XPos = Object.BodyPosition1X800Object.YPos = Object.BodyPosition1Y801#platform: Use_Standalone802PlayerObjectCollision(C_TOUCH, -8, -8, 8, 8)803#endplatform804805#platform: Use_Origins806PlayerObjectCollision(C_ENEMY, -8, -8, 8, 8)807#endplatform808if CheckResult == true809CallFunction(Player_BadnikBreak)810else811Object.XPos = Object.BodyPosition2X812Object.YPos = Object.BodyPosition2Y813#platform: Use_Standalone814PlayerObjectCollision(C_TOUCH, -8, -8, 8, 8)815#endplatform816817#platform: Use_Origins818PlayerObjectCollision(C_ENEMY, -8, -8, 8, 8)819#endplatform820if CheckResult == true821CallFunction(Player_BadnikBreak)822else823Object.XPos = Object.BodyPosition3X824Object.YPos = Object.BodyPosition3Y825#platform: Use_Standalone826PlayerObjectCollision(C_TOUCH, -8, -8, 8, 8)827#endplatform828829#platform: Use_Origins830PlayerObjectCollision(C_ENEMY, -8, -8, 8, 8)831#endplatform832if CheckResult == true833CallFunction(Player_BadnikBreak)834end if835end if836end if837end if838839// It's safe to restore the Object's base Position now840Object.XPos = TempValue1841Object.YPos = TempValue2842843end if844end sub845846847sub ObjectDraw848849if Object.Quality == GOOD_QUALITY850GetBit(Object.Direction, Object.PieceDirection, 3)851DrawSpriteFX(2, FX_FLIP, Object.BodyPosition3X, Object.BodyPosition3Y)852853GetBit(Object.Direction, Object.PieceDirection, 2)854DrawSpriteFX(2, FX_FLIP, Object.BodyPosition2X, Object.BodyPosition2Y)855856GetBit(Object.Direction, Object.PieceDirection, 1)857DrawSpriteFX(2, FX_FLIP, Object.BodyPosition1X, Object.BodyPosition1Y)858else859GetBit(Object.Direction, Object.PieceDirection, 3)860DrawSpriteFX(3, FX_FLIP, Object.BodyPosition3X, Object.BodyPosition3Y)861862GetBit(Object.Direction, Object.PieceDirection, 2)863DrawSpriteFX(3, FX_FLIP, Object.BodyPosition2X, Object.BodyPosition2Y)864865GetBit(Object.Direction, Object.PieceDirection, 1)866DrawSpriteFX(3, FX_FLIP, Object.BodyPosition1X, Object.BodyPosition1Y)867end if868869// Get the direction of the head870GetBit(Object.Direction, Object.PieceDirection, 0)871872switch Object.State873case KEMUSI_INIT874case KEMUSI_FINDGROUND875case KEMUSI_SPIKED_RETRACT876case KEMUSI_NORMAL_RETRACT877// Closed mouth Frame878DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)879break880881case KEMUSI_SPIKED_ADVANCE882case KEMUSI_NORMAL_ADVANCE883// Mouth Open Frame884DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)885break886887end switch888889end sub890891892sub ObjectStartup893LoadSpriteSheet("R5/Objects.gif")894895// 0 - Kemusi Closed Mouth Frame896SpriteFrame(-8, -16, 16, 24, 125, 75)897898// 1 - Kemusi Smiling Frame899SpriteFrame(-8, -16, 16, 24, 125, 50)900901// 2- Kemusi Spiked Fragment Frame902SpriteFrame(-8, -16, 16, 24, 67, 150)903904// 2- Kemusi Normal Fragment Frame905SpriteFrame(-8, -8, 16, 16, 52, 1)906907end sub908909910// ========================911// Editor Subs912// ========================913914sub RSDKEdit915if Editor.ReturnVariable == true916switch Editor.VariableID917case EDIT_VAR_PROPVAL // Property Value918CheckResult = Object.PropertyValue919break920case 0 // Type921CheckResult = Object.PropertyValue922break923end switch924else925switch Editor.VariableID926case EDIT_VAR_PROPVAL // Property Value927Object.PropertyValue = Editor.VariableValue928break929case 0 // Type930Object.PropertyValue = Editor.VariableValue931break932end switch933end if934end sub935936937sub RSDKDraw938TempValue0 = Object.XPos939TempValue0 += 0x240000940941DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)942943TempValue0 -= 0xC0000944DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)945946TempValue0 -= 0xC0000947DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)948949TempValue0 -= 0xC0000950DrawSpriteXY(2, TempValue0, Object.YPos) // smile :)951end sub952953954sub RSDKLoad955LoadSpriteSheet("R5/Objects.gif")956SpriteFrame(-8, -16, 16, 24, 67, 150)957SpriteFrame(-8, -8, 16, 16, 52, 1)958SpriteFrame(-8, -16, 16, 24, 125, 50)959960AddEditorVariable("condition")961SetActiveVariable("condition")962AddEnumVariable("Good Quality", GOOD_QUALITY)963AddEnumVariable("Bad Quality", BAD_QUALITY)964end sub965966967