Path: blob/main/Scripts/R4/Dragonfly.txt
1319 views
//----------------Sonic CD Dragonfly Script-------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Angle6#alias Object.Value1 : Object.YVelocity78#alias Object.PropertyValue : Object.Quality910// States11#alias 0 : DRAGONFLY_MOVE_LEFT12#alias 1 : DRAGONFLY_MOVE_RIGHT1314// Badnik Quality / Property Values15#alias 0 : GOOD_QUALITY16#alias 1 : BAD_QUALITY171819sub ObjectMain20if Object.Quality == GOOD_QUALITY21switch Object.State22case DRAGONFLY_MOVE_LEFT23Sin(Object.YPos, Object.Angle)24Object.YPos <<= 1125Object.YPos += Object.YVelocity2627Object.XPos -= 0x100002829Object.Angle -= 830if Object.Angle == 031Object.State = DRAGONFLY_MOVE_RIGHT32Object.Direction = FACING_LEFT33end if34break3536case DRAGONFLY_MOVE_RIGHT37Sin(Object.YPos, Object.Angle)38FlipSign(Object.YPos)39Object.YPos <<= 1140Object.YPos += Object.YVelocity4142Object.XPos += 0x100004344Object.Angle += 845if Object.Angle == 204846Object.State = DRAGONFLY_MOVE_LEFT47Object.Direction = FACING_RIGHT48end if49break5051end switch5253else54switch Object.State55case DRAGONFLY_MOVE_LEFT56Sin(Object.YPos, Object.Angle)57Object.YPos <<= 1158Object.YPos += Object.YVelocity5960Object.XPos -= 0x80006162Object.Angle -= 263if Object.Angle == 064Object.State = DRAGONFLY_MOVE_RIGHT65Object.Direction = FACING_LEFT66end if67break6869case DRAGONFLY_MOVE_RIGHT70Sin(Object.YPos, Object.Angle)71FlipSign(Object.YPos)72Object.YPos <<= 1173Object.YPos += Object.YVelocity7475Object.XPos += 0x80007677Object.Angle += 278if Object.Angle == 102479Object.State = DRAGONFLY_MOVE_LEFT80Object.Direction = FACING_RIGHT81end if82break8384end switch85end if8687CallFunction(StageSetup_CheckGoodFuture) // Check if it should be a flower88end sub899091sub ObjectPlayerInteraction92#platform: Use_Standalone93PlayerObjectCollision(C_TOUCH, -20, -10, 20, 10)94#endplatform95#platform: Use_Origins96PlayerObjectCollision(C_ENEMY, -20, -10, 20, 10)97#endplatform98if CheckResult == true99CallFunction(Player_BadnikBreak)100end if101end sub102103104sub ObjectDraw105TempValue0 = Object.Frame106TempValue0 /= 3107108if Object.Quality == GOOD_QUALITY109DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)110else111TempValue0 += 2112DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)113end if114115Object.Frame++116Object.Frame %= 6117end sub118119120sub ObjectStartup121LoadSpriteSheet("R4/Objects.gif")122123SpriteFrame(-29, -20, 64, 32, 18, 119) // #0 - Dragon Fly frame 0124SpriteFrame(-29, -16, 64, 28, 83, 152) // #1 - Dragon Fly frame 1125SpriteFrame(-29, -20, 64, 32, 18, 86) // #2 - Dragon Fly frame 2126SpriteFrame(-29, -16, 64, 28, 18, 152) // #3 - Dragon Fly frame 3127128// Used to be below LoadSpriteSheet, moved here for consistency129ArrayPos0 = 32130while ArrayPos0 < 1056131if Object[ArrayPos0].Type == TypeName[Dragonfly]132Object[ArrayPos0].YVelocity = Object[ArrayPos0].YPos133Object[ArrayPos0].Angle = 1024134Object[ArrayPos0].Angle >>= Object[ArrayPos0].Quality135end if136ArrayPos0++137loop138end sub139140141// ========================142// Editor Subs143// ========================144145sub RSDKEdit146if Editor.ReturnVariable == true147switch Editor.VariableID148case EDIT_VAR_PROPVAL // Property Value149CheckResult = Object.PropertyValue150CheckResult &= 1151break152case 0 // condition153CheckResult = Object.PropertyValue154CheckResult &= 1155break156end switch157else158switch Editor.VariableID159case EDIT_VAR_PROPVAL // Property Value160Object.PropertyValue = Editor.VariableValue161Object.PropertyValue &= 1162break163case 0 // condition164Object.PropertyValue = Editor.VariableValue165Object.PropertyValue &= 1166break167end switch168end if169end sub170171172sub RSDKDraw173DrawSprite(Object.PropertyValue)174end sub175176177sub RSDKLoad178LoadSpriteSheet("R4/Objects.gif")179180// Good Dragonfly181SpriteFrame(-29, -20, 64, 32, 18, 119) // #0 - Dragon Fly182// Bad Dragonfly183SpriteFrame(-29, -20, 64, 32, 18, 86) // #1 - Dragon Fly184185AddEditorVariable("condition")186SetActiveVariable("condition")187AddEnumVariable("Good Quality", GOOD_QUALITY)188AddEnumVariable("Bad Quality", BAD_QUALITY)189end sub190191192