Path: blob/main/Scripts/R3/KamaKama.txt
1319 views
//-----------------Sonic CD Kama Kama 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.FrameTimer7#alias Object.Value2 : Object.XVelocity8#alias Object.Value3 : Object.XOriginPos9#alias Object.Value4 : Object.YOriginPos1011#alias Object.PropertyValue : Object.Quality1213// Blade Aliases14#alias Object.Value2 : Object.KamaKamaEntityNo1516// States17#alias 0 : KAMAKAMA_GUARD18#alias 1 : KAMAKAMA_LAUNCH_BLADE19#alias 2 : KAMAKAMA_PREPARE_CHARGE20#alias 3 : KAMAKAMA_CHARGE21#alias 4 : KAMAKAMA_SWITCH_DIRECTION2223// Collision Sides24#alias 0 : CSIDE_FLOOR2526// Badnik Quality / Property Values27#alias 0 : GOOD_QUALITY28#alias 1 : BAD_QUALITY2930// Priority31#alias 0 : PRIORITY_BOUNDS32#alias 1 : PRIORITY_ACTIVE333435sub ObjectMain36Object.FrameTimer++37Object.FrameTimer &= 1538switch Object.State39case KAMAKAMA_GUARD40ObjectTileGrip(CSIDE_FLOOR, 0, 19, 0)41if Object.XPos > Player.XPos42Object.Direction = FACING_RIGHT43else44Object.Direction = FACING_LEFT45end if4647PlayerObjectCollision(C_TOUCH, -96, -48, 96, 48)48if CheckResult == true49Object.State = KAMAKAMA_LAUNCH_BLADE50Object.Priority = PRIORITY_ACTIVE51if Object.Quality == GOOD_QUALITY // Only badniks in a good state still have blades to throw52CreateTempObject(TypeName[Kama Kama Blade], 24, Object.XPos, Object.YPos)53Object[TempObjectPos].Direction = Object.Direction54Object[TempObjectPos].iYPos -= 655Object[TempObjectPos].KamaKamaEntityNo = Object.EntityNo5657if Object.Direction == FACING_RIGHT58Object[TempObjectPos].iXPos -= 859else60Object[TempObjectPos].iXPos += 861end if62CreateTempObject(TypeName[Kama Kama Blade], 56, Object.XPos, Object.YPos)63Object[TempObjectPos].Direction = Object.Direction64Object[TempObjectPos].iYPos -= 465Object[TempObjectPos].KamaKamaEntityNo = Object.EntityNo6667if Object.Direction == FACING_RIGHT68Object[TempObjectPos].iXPos -= 1669else70Object[TempObjectPos].iXPos += 1671end if7273end if7475end if76break7778case KAMAKAMA_LAUNCH_BLADE79if Object.Timer < 11080Object.Timer++81else82Object.State = KAMAKAMA_PREPARE_CHARGE83Object.Timer = 084end if85break8687case KAMAKAMA_PREPARE_CHARGE88if Object.Timer < 4889Object.Timer++90else91Object.State = KAMAKAMA_CHARGE92Object.Timer = 093Object.Frame = 094if Object.Direction == FACING_RIGHT95Object.XVelocity = -0x1000096else97Object.XVelocity = 0x1000098end if99if Object.Quality > 0100Object.XVelocity >>= 1101end if102end if103break104105case KAMAKAMA_CHARGE106Object.Frame++107Object.Frame &= 31108109Object.XPos += Object.XVelocity110ObjectTileGrip(CSIDE_FLOOR, 0, 19, 0) // Check if it's reaching a ledge111if CheckResult == false112Object.State = KAMAKAMA_SWITCH_DIRECTION113Object.Timer = 60114end if115break116117case KAMAKAMA_SWITCH_DIRECTION118Object.Frame++119Object.Frame &= 31120if Object.Timer > 0121Object.Timer--122else123Object.State = KAMAKAMA_CHARGE124FlipSign(Object.XVelocity)125if Object.Direction == FACING_RIGHT126Object.Direction = FACING_LEFT127else128Object.Direction = FACING_RIGHT129end if130131end if132break133134end switch135136// Reset object when out of bounds137if Object.OutOfBounds == true138Object.Priority = PRIORITY_BOUNDS139140Object.State = KAMAKAMA_GUARD141142Object.Timer = 0143Object.FrameTimer = 0144Object.Frame = 0145146Object.XPos = Object.XOriginPos147Object.YPos = Object.YOriginPos148end if149150CallFunction(StageSetup_CheckGoodFuture) // Check if it should be a flower151end sub152153154sub ObjectPlayerInteraction155#platform: Use_Standalone156PlayerObjectCollision(C_TOUCH, -16, -16, 16, 20)157#endplatform158#platform: Use_Origins159PlayerObjectCollision(C_ENEMY, -16, -16, 16, 20)160#endplatform161if CheckResult == true162CallFunction(Player_BadnikBreak)163end if164end sub165166167sub ObjectDraw168switch Object.State169case KAMAKAMA_GUARD170TempValue0 = Object.FrameTimer171TempValue0 >>= 3172DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)173174if Object.Quality == GOOD_QUALITY175TempValue1 = TempValue0176TempValue1 += 4177DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)178179TempValue1 += 12180DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)181182TempValue1 -= 10183DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)184else185TempValue1 = TempValue0186TempValue1 += 10187DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)188189TempValue1 += 2190DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)191end if192break193194case KAMAKAMA_LAUNCH_BLADE195TempValue0 = Object.FrameTimer196TempValue0 >>= 3197DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)198199if Object.Quality == GOOD_QUALITY200TempValue1 = TempValue0201TempValue1 += 4202DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)203204TempValue1 += 2205DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)206else207TempValue1 = TempValue0208TempValue1 += 10209DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)210211TempValue1 += 2212DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)213end if214break215216case KAMAKAMA_PREPARE_CHARGE217TempValue0 = Object.FrameTimer218TempValue0 >>= 3219DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)220221if Object.Quality == GOOD_QUALITY222TempValue1 = TempValue0223TempValue1 += 4224DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)225226TempValue1 += 4227DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)228else229TempValue1 = TempValue0230TempValue1 += 10231DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)232233TempValue1 += 4234DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)235end if236break237238case KAMAKAMA_CHARGE239case KAMAKAMA_SWITCH_DIRECTION240TempValue0 = Object.Frame241TempValue0 >>= 3242DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)243244TempValue0 = Object.FrameTimer245TempValue0 >>= 3246247if Object.Quality == GOOD_QUALITY248TempValue1 = TempValue0249TempValue1 += 4250DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)251252TempValue1 += 2253DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)254else255TempValue1 = TempValue0256TempValue1 += 10257DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)258259TempValue1 += 2260DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)261end if262break263264end switch265end sub266267268sub ObjectStartup269LoadSpriteSheet("R3/Objects.gif")270271SpriteFrame(0, 4, 16, 16, 198, 119) // #0 - Wheel Frame 0272SpriteFrame(0, 4, 16, 16, 215, 119) // #1 - Wheel Frame 1273SpriteFrame(0, 4, 16, 16, 232, 119) // #2 - Wheel Frame 2274SpriteFrame(0, 4, 16, 16, 215, 119) // #3 - Wheel Frame 3275276// Good Kama Kama277SpriteFrame(-10, -4, 24, 16, 215, 102) // #4 - Body Frame 0278SpriteFrame(-10, -3, 24, 16, 215, 102) // #5 - Body Frame 1279280SpriteFrame(-16, -20, 16, 16, 198, 102) // #6 - Head Frame 0281SpriteFrame(-16, -19, 16, 16, 198, 102) // #7 - Head Frame 1282SpriteFrame(-16, -20, 16, 16, 198, 136) // #8 - Head Frame 2283SpriteFrame(-16, -19, 16, 16, 198, 102) // #9 - Head Frame 3284285// Bad Kama Kama286SpriteFrame(-10, -4, 24, 16, 232, 136) // #10 - Body Frame 0287SpriteFrame(-10, -3, 24, 16, 198, 153) // #11 - Body Frame 1288289SpriteFrame(-16, -20, 16, 16, 215, 136) // #12 - Head Frame 0290SpriteFrame(-16, -19, 16, 16, 240, 102) // #13 - Head Frame 0291SpriteFrame(-16, -20, 16, 16, 198, 136) // #14 - Head Frame 0292SpriteFrame(-16, -19, 16, 16, 240, 102) // #15 - Head Frame 0293294SpriteFrame(-22, -14, 24, 20, 173, 101) // #16 - Claws Frame 0295SpriteFrame(-22, -14, 24, 20, 173, 122) // #17 - Claws Frame 1296297// Used to be below LoadSpriteSheet, moved here for consistency298ArrayPos0 = 32299while ArrayPos0 < 1056300if Object[ArrayPos0].Type == TypeName[Kama Kama]301Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos302Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos303end if304ArrayPos0++305loop306end sub307308309// ========================310// Editor Subs311// ========================312313314sub RSDKEdit315if Editor.ReturnVariable == true316switch Editor.VariableID317case EDIT_VAR_PROPVAL // Property Value318CheckResult = Object.PropertyValue319CheckResult &= 1320break321case 0 // condition322CheckResult = Object.PropertyValue323CheckResult &= 1324break325end switch326else327switch Editor.VariableID328case EDIT_VAR_PROPVAL // Property Value329Object.PropertyValue = Editor.VariableValue330Object.PropertyValue &= 1331break332case 0 // condition333Object.PropertyValue = Editor.VariableValue334Object.PropertyValue &= 1335break336end switch337end if338end sub339340341sub RSDKDraw342DrawSprite(0)343344switch Object.Quality345case GOOD_QUALITY346DrawSprite(1)347DrawSprite(2)348DrawSprite(3)349break350case BAD_QUALITY351DrawSprite(4)352DrawSprite(5)353break354end switch355end sub356357358sub RSDKLoad359LoadSpriteSheet("R3/Objects.gif")360361SpriteFrame(0, 4, 16, 16, 198, 119) // #0 - Wheel362363// Good Kama Kama364SpriteFrame(-10, -4, 24, 16, 215, 102) // #1 - Body365SpriteFrame(-16, -20, 16, 16, 198, 102) // #2 - Head366SpriteFrame(-22, -14, 24, 20, 173, 101) // #3 - Claws367368// Bad Kama Kama369SpriteFrame(-10, -4, 24, 16, 232, 136) // #4 - Body370SpriteFrame(-16, -20, 16, 16, 215, 136) // #5 - Head371372AddEditorVariable("condition")373SetActiveVariable("condition")374AddEnumVariable("Good Quality", GOOD_QUALITY)375AddEnumVariable("Bad Quality", BAD_QUALITY)376end sub377378379