Path: blob/main/Scripts/R8/Bumper.txt
1319 views
//-----------------Sonic CD Bumper Script---------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.FrameTimer6#alias Object.Value1 : Object.BonusScore7#alias Object.Value2 : Object.Oscillation8#alias Object.Value3 : Object.TurnDirection9#alias Object.Value4 : Object.XOriginPos10#alias Object.Value5 : Object.YOriginPos1112// States13#alias 0 : BUMPER_IDLE14#alias 1 : BUMPER_ACTIVE1516// Gravity17#alias 0 : GRAVITY_GROUND18#alias 1 : GRAVITY_AIR1920// Stage SFX21#alias 3 : SFX_S_BUMPER2223// Priority24#alias 0 : PRIORITY_BOUNDS25#alias 1 : PRIORITY_ACTIVE2627// Property Values28#alias 1 : BUMPER_RIGHT_TO_LEFT29#alias 2 : BUMPER_LEFT_TO_RIGHT30#alias 3 : BUMPER_TOP_TO_BOTTOM31#alias 4 : BUMPER_BOTTOM_TO_TOP323334sub ObjectMain35switch Object.PropertyValue36case BUMPER_RIGHT_TO_LEFT37if Object.TurnDirection == false38if Object.Oscillation < 0x30000039Object.Oscillation += 0x1000040else41Object.TurnDirection = true42end if43else44if Object.Oscillation > -0x30000045Object.Oscillation -= 0x1000046else47Object.TurnDirection = false48end if49end if50Object.XPos = Object.XOriginPos51Object.XPos += Object.Oscillation52break5354case BUMPER_LEFT_TO_RIGHT55if Object.TurnDirection == false56if Object.Oscillation < 0x30000057Object.Oscillation += 0x1000058else59Object.TurnDirection = true60end if61else62if Object.Oscillation > -0x30000063Object.Oscillation -= 0x1000064else65Object.TurnDirection = false66end if67end if68Object.XPos = Object.XOriginPos69Object.XPos += Object.Oscillation70break7172case BUMPER_TOP_TO_BOTTOM73if Object.TurnDirection == false74if Object.Oscillation < 0x30000075Object.Oscillation += 0x1000076else77Object.TurnDirection = true78end if79else80if Object.Oscillation > -0x30000081Object.Oscillation -= 0x1000082else83Object.TurnDirection = false84end if85end if86Object.YPos = Object.YOriginPos87Object.YPos += Object.Oscillation88break8990case BUMPER_BOTTOM_TO_TOP91if Object.TurnDirection == false92if Object.Oscillation < 0x30000093Object.Oscillation += 0x1000094else95Object.TurnDirection = true96end if97else98if Object.Oscillation > -0x30000099Object.Oscillation -= 0x10000100else101Object.TurnDirection = false102end if103end if104Object.YPos = Object.YOriginPos105Object.YPos -= Object.Oscillation106break107end switch108109if Object.State > BUMPER_IDLE // Check that is being used110Object.Frame = Object.FrameTimer111Object.Frame /= 5112Object.Frame++113114Object.FrameTimer++115if Object.FrameTimer > 22116Object.FrameTimer = 0117Object.State = BUMPER_IDLE118Object.Frame = 0119end if120end if121122if Object.OutOfBounds == true123Object.BonusScore = 0124Object.Priority = PRIORITY_BOUNDS125end if126end sub127128129sub ObjectPlayerInteraction130if Player.Animation != ANI_HURT131132PlayerObjectCollision(C_TOUCH, -14, -14, 14, 14)133if CheckResult == true134135#platform: Use_Origins136if Player.Animation == ANI_CLIMBING137// Before bouncing him away, let's make sure Knuckles is in his normal air state, first138CallFunction(Player_CancelClimb)139end if140#endplatform141142if Object.State == BUMPER_IDLE143PlayStageSfx(SFX_S_BUMPER, false)144if Object.BonusScore < 5145CreateTempObject(TypeName[Object Score], 0, Object.XPos, Object.YPos)146Player.Score += 100147Object.BonusScore++148end if149end if150if Object.FrameTimer > 5151PlayStageSfx(SFX_S_BUMPER, false)152153#platform: Use_Haptics154HapticEffect(9, 0, 0, 0)155#endplatform156157end if158Object.State = BUMPER_ACTIVE159160Object.Priority = PRIORITY_ACTIVE161162TempValue0 = Player.XPos163TempValue0 -= Object.XPos164TempValue1 = Player.YPos165TempValue1 -= Object.YPos166ATan2(TempValue2, TempValue0, TempValue1)167Cos256(TempValue0, TempValue2)168Sin256(TempValue1, TempValue2)169170if Player.State == Player_State_Fly171TempValue0 <<= 10172TempValue1 <<= 10173else174TempValue0 *= 0x700175TempValue1 *= 0x700176Player.Timer = 0177end if178Player.XVelocity = TempValue0179Player.YVelocity = TempValue1180Player.Speed = Player.XVelocity181182Player.Gravity = GRAVITY_AIR183end if184end if185end sub186187188sub ObjectDraw189DrawSprite(Object.Frame)190end sub191192193sub ObjectStartup194LoadSpriteSheet("R8/Objects3.gif")195196SpriteFrame(-16, -16, 32, 32, 100, 100) // #0 - Bumper197SpriteFrame(-12, -12, 24, 24, 1, 228) // #1 - Bumper Hit Frame 0198SpriteFrame(-20, -20, 40, 40, 1, 187) // #2 - Bumper Hit Frame 1199SpriteFrame(-12, -12, 24, 24, 1, 228) // #3 - Bumper Hit Frame 2200SpriteFrame(-20, -20, 40, 40, 1, 187) // #4 - Bumper Hit Frame 3201SpriteFrame(-20, -20, 40, 40, 1, 187) // #5 - Bumper Hit Frame 4202203// Used to be below LoadSpriteSheet, moved here for consistency with the rest204ArrayPos0 = 32205while ArrayPos0 < 1056206if Object[ArrayPos0].Type == TypeName[Bumper]207Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos208Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos209end if210ArrayPos0++211loop212end sub213214215// ========================216// Editor Subs217// ========================218219sub RSDKDraw220DrawSprite(0)221end sub222223224sub RSDKLoad225LoadSpriteSheet("R8/Objects3.gif")226227SpriteFrame(-16, -16, 32, 32, 100, 100) // #0 - Bumper228229SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")230end sub231232233