Path: blob/main/Scripts/R8/Buzzsaw.txt
1319 views
//------------------Sonic CD Buzzsaw 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.XVelocity7#alias Object.Value2 : Object.YVelocity8#alias Object.Value3 : Object.FrameTimer9#alias Object.Value4 : Object.SfxTimer1011// States12#alias 0 : BUZZSAW_STOPPED13#alias 1 : BUZZSAW_DROP14#alias 2 : BUZZSAW_LOW_STOPPED15#alias 3 : BUZZSAW_LIFT1617// Stage SFX18#alias 1 : SFX_S_BUZZSAW1920// Property Values21// tecnically direction is used, but it's set according to the property value so22#alias 0 : DIR_FACING_RIGHT23#alias 1 : DIR_FACING_LEFT24#alias 2 : DIR_FACING_UPEND_RIGHT25#alias 3 : DIR_FACING_UPEND_LEFT2627// These prop vals are going to switch the first state to 228// then behave the same as the ones above it29#alias 128 : LOW_FACING_RIGHT30#alias 129 : LOW_FACING_LEFT31#alias 130 : LOW_FACING_UPEND_RIGHT32#alias 131 : LOW_FACING_UPEND_LEFT333435sub ObjectMain36switch Object.State37case BUZZSAW_STOPPED38if Object.Timer < 6039Object.Timer++40else41Object.Timer = 042Object.State++43end if44break4546case BUZZSAW_DROP47if Object.Timer < 7448Object.Timer++49Object.FrameTimer++50Object.XPos += Object.XVelocity51Object.YPos += Object.YVelocity52else53Object.Timer = 054Object.State++55end if56break5758case BUZZSAW_LOW_STOPPED59if Object.Timer < 6060Object.Timer++61else62Object.Timer = 063Object.State++64end if65break6667case BUZZSAW_LIFT68if Object.Timer < 7469Object.Timer++70Object.FrameTimer--71Object.XPos -= Object.XVelocity72Object.YPos -= Object.YVelocity73else74Object.Timer = 075Object.State = BUZZSAW_STOPPED76end if77break78end switch7980if Object.SfxTimer > 081Object.SfxTimer--82else83PlayStageSfx(SFX_S_BUZZSAW, false)84Object.SfxTimer += 4885end if86end sub878889sub ObjectPlayerInteraction90PlayerObjectCollision(C_TOUCH, -24, -24, 24, 24)91if CheckResult == true92CallFunction(Player_Hit)93end if94end sub959697sub ObjectDraw98TempValue0 = Object.Frame99TempValue0 >>= 1100DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)101Object.Frame++102Object.Frame &= 3103104TempValue0 = Object.FrameTimer105TempValue0 /= 20106switch TempValue0107case 0108DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)109break110case 1111DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)112DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)113break114case 2115DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)116DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)117DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)118break119case 3120DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)121DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)122DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)123DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)124break125end switch126end sub127128129sub ObjectStartup130LoadSpriteSheet("R8/Objects2.gif")131132SpriteFrame(-33, -36, 66, 68, 67, 127) // #0 - Buzzsaw frame 0133SpriteFrame(-33, -36, 66, 68, 190, 154) // #1 - Buzzsaw frame 1134135SpriteFrame(-53, -53, 26, 26, 158, 43) // #2 - Buzzsaw Extension frame 0136SpriteFrame(-73, -73, 26, 26, 158, 43) // #3 - Buzzsaw Extension frame 1137SpriteFrame(-93, -93, 26, 26, 158, 43) // #4 - Buzzsaw Extension frame 2138SpriteFrame(-113, -113, 26, 26, 158, 43) // #5 - Buzzsaw Extension frame 3139140ArrayPos0 = 32141while ArrayPos0 < 1056142if Object[ArrayPos0].Type == TypeName[Buzzsaw]143if Object[ArrayPos0].PropertyValue > 127144Object[ArrayPos0].PropertyValue -= 128145Object[ArrayPos0].Direction = Object[ArrayPos0].PropertyValue146Object[ArrayPos0].FrameTimer = 74147Object[ArrayPos0].State = BUZZSAW_LOW_STOPPED148else149Object[ArrayPos0].Direction = Object[ArrayPos0].PropertyValue150end if151152switch Object[ArrayPos0].Direction153case 0154Object[ArrayPos0].XVelocity = 0x10000155Object[ArrayPos0].YVelocity = 0x10000156break157case 1158Object[ArrayPos0].XVelocity = -0x10000159Object[ArrayPos0].YVelocity = 0x10000160break161case 2162Object[ArrayPos0].XVelocity = 0x10000163Object[ArrayPos0].YVelocity = -0x10000164break165case 3166Object[ArrayPos0].XVelocity = -0x10000167Object[ArrayPos0].YVelocity = -0x10000168break169end switch170end if171ArrayPos0++172loop173end sub174175176// ========================177// Editor Subs178// ========================179180sub RSDKEdit181if Editor.ReturnVariable == true182switch Editor.VariableID183case EDIT_VAR_PROPVAL // Property Value184CheckResult = Object.PropertyValue185break186case 0 // startStreched187GetBit(CheckResult, Object.PropertyValue, 7)188break189case 1 // direction190CheckResult = Object.PropertyValue191CheckResult &= 3192break193end switch194else195switch Editor.VariableID196case EDIT_VAR_PROPVAL // Property Value197Object.PropertyValue = Editor.VariableValue198break199case 0 // startStreched200Object.PropertyValue &= 127201SetBit(Object.PropertyValue, 7, Editor.VariableValue)202break203204case 1 // direction205Object.PropertyValue &= 128206Object.PropertyValue |= Editor.VariableValue207break208end switch209end if210end sub211212sub RSDKDraw213Object.Direction = Object.PropertyValue214Object.Direction &= 3215if Object.PropertyValue > 127216TempValue1 = 74217else218TempValue1 = 0219end if220TempValue0 = TempValue1221TempValue0 /= 20222DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)223switch TempValue0224case 0225DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)226break227case 1228DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)229DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)230break231case 2232DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)233DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)234DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)235break236case 3237DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)238DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)239DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)240DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)241break242end switch243244if Editor.ShowGizmos == true245Editor.DrawingOverlay = true246TempValue0 = Object.XPos247TempValue1 = Object.YPos248TempValue2 = 0x10000249TempValue2 *= 74250if Object.PropertyValue < 127251switch Object.Direction252case 0253TempValue0 += TempValue2254TempValue1 += TempValue2255break256case 1257TempValue0 -= TempValue2258TempValue1 += TempValue2259break260case 2261TempValue0 += TempValue2262TempValue1 -= TempValue2263break264case 3265TempValue0 -= TempValue2266TempValue1 -= TempValue2267break268end switch269else270switch Object.Direction271case 0272TempValue0 -= TempValue2273TempValue1 -= TempValue2274break275case 1276TempValue0 += TempValue2277TempValue1 -= TempValue2278break279case 2280TempValue0 -= TempValue2281TempValue1 += TempValue2282break283case 3284TempValue0 += TempValue2285TempValue1 += TempValue2286break287end switch288289end if290DrawArrow(Object.XPos, Object.YPos, TempValue0, TempValue1, 255, 255, 0)291Editor.DrawingOverlay = false292end if293end sub294295296sub RSDKLoad297LoadSpriteSheet("R8/Objects2.gif")298299SpriteFrame(-33, -36, 66, 68, 67, 127) // #0 - Buzzsaw frame 0300SpriteFrame(-33, -36, 66, 68, 190, 154) // #1 - Buzzsaw frame 1301302SpriteFrame(-53, -53, 26, 26, 158, 43) // #2 - Buzzsaw Extension frame 0303SpriteFrame(-73, -73, 26, 26, 158, 43) // #3 - Buzzsaw Extension frame 1304SpriteFrame(-93, -93, 26, 26, 158, 43) // #4 - Buzzsaw Extension frame 2305SpriteFrame(-113, -113, 26, 26, 158, 43) // #5 - Buzzsaw Extension frame 3306307AddEditorVariable("startStreched")308SetActiveVariable("startStreched")309AddEnumVariable("false", 0)310AddEnumVariable("true", 1)311312AddEditorVariable("direction")313SetActiveVariable("direction")314AddEnumVariable("Right", 0)315AddEnumVariable("Left", 1)316AddEnumVariable("Upside-Down Right", 2)317AddEnumVariable("Upside-Down Left", 3)318end sub319320321