Path: blob/master/Sonic 1/Scripts/Enemies/BuzzBomber.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Buzz Bomber Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value1 : object.startPos.x13private alias object.value2 : object.hasShot14private alias object.value3 : object.hideOnOffScreen // Set from the editor1516// Player Aliases17private alias object.value40 : player.hitboxLeft18private alias object.value38 : player.hitboxTop19private alias object.value41 : player.hitboxRight20private alias object.value39 : player.hitboxBottom2122private alias 0 : BUZZBOMBER_BUZZAROUND23private alias 1 : BUZZBOMBER_IDLEDELAY24private alias 2 : BUZZBOMBER_FOUNDPLAYER25private alias 3 : BUZZBOMBER_SHOOTING26private alias 4 : BUZZBOMBER_HIDDEN2728private alias 0 : BUZZBOMBER_ANI_FLY29private alias 1 : BUZZBOMBER_ANI_FLY_IDLE30private alias 2 : BUZZBOMBER_ANI_SHOOT31private alias 3 : BUZZBOMBER_ANI_NONE323334// ========================35// Function Declarations36// ========================3738reserve function BuzzBomber_DebugDraw39reserve function BuzzBomber_DebugSpawn404142// ========================43// Function Definitions44// ========================4546private function BuzzBomber_DebugDraw47DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)48DrawSpriteFX(2, FX_FLIP, object.xpos, object.ypos)49end function505152private function BuzzBomber_DebugSpawn53CreateTempObject(TypeName[Buzz Bomber], 0, object.xpos, object.ypos)54GetBit(temp0, object.direction, 0)55if temp0 == FLIP_NONE56// Facing left57object[tempObjectPos].direction = FLIP_NONE58object[tempObjectPos].xvel = -0x4000059else60// Facing right61object[tempObjectPos].direction = FLIP_X62object[tempObjectPos].xvel = 0x4000063end if6465end function666768// ========================69// Events70// ========================7172event ObjectUpdate73switch object.state74case BUZZBOMBER_BUZZAROUND75object.priority = PRIORITY_ACTIVE76if object.timer < 12777object.timer++78object.xpos += object.xvel79else80object.timer = 081object.state = BUZZBOMBER_IDLEDELAY82object.animation = BUZZBOMBER_ANI_FLY_IDLE83object.direction ^= FLIP_X84FlipSign(object.xvel)85end if86break8788case BUZZBOMBER_IDLEDELAY89if object.timer < 5990object.timer++91else92object.timer = 093object.state = BUZZBOMBER_BUZZAROUND94object.animation = BUZZBOMBER_ANI_FLY95object.hasShot = false96end if97break9899case BUZZBOMBER_FOUNDPLAYER100if object.timer < 29101object.timer++102else103object.timer = 0104object.state++105object.animation = BUZZBOMBER_ANI_SHOOT106end if107break108109case BUZZBOMBER_SHOOTING110if object.timer < 59111object.timer++112if object.timer == 15113CreateTempObject(TypeName[Buzz Bomber Shot], 0, object.xpos, object.ypos)114object[tempObjectPos].direction = object.direction115if object.direction == FLIP_NONE116object[tempObjectPos].xpos -= 0x180000117object[tempObjectPos].xvel = -0x20000118else119object[tempObjectPos].xpos += 0x180000120object[tempObjectPos].xvel = 0x20000121end if122object[tempObjectPos].ypos += 0x1C0000123object[tempObjectPos].yvel = 0x20000124end if125else126object.timer = 0127object.state = BUZZBOMBER_BUZZAROUND128object.animation = BUZZBOMBER_ANI_FLY129object.hasShot = true130end if131break132133case BUZZBOMBER_HIDDEN134object.animation = BUZZBOMBER_ANI_NONE135break136137end switch138139if object.outOfBounds == true140temp0 = object.xpos141object.xpos = object.startPos.x142if object.hideOnOffScreen == true143object.state = BUZZBOMBER_HIDDEN144end if145146if object.outOfBounds == true147object.xpos = object.startPos.x148149GetBit(temp0, object.propertyValue, 0)150if temp0 == false151object.direction = FLIP_NONE152object.xvel = -0x40000153else154object.direction = FLIP_X155object.xvel = 0x40000156end if157object.timer = 0158object.animation = BUZZBOMBER_ANI_FLY159object.priority = PRIORITY_BOUNDS160object.state = BUZZBOMBER_BUZZAROUND161else162object.xpos = temp0163end if164end if165166// Player Collisons167foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)168if object.state == BUZZBOMBER_BUZZAROUND169if object.hasShot == false170if object.propertyValue < 2171BoxCollisionTest(C_TOUCH, object.entityPos, -96, -256, 96, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)172else173BoxCollisionTest(C_TOUCH, object.entityPos, -48, -256, 48, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)174end if175176if checkResult == true177object.state = BUZZBOMBER_FOUNDPLAYER178object.timer = 0179object.animation = BUZZBOMBER_ANI_FLY_IDLE180end if181end if182end if183184if object.state < BUZZBOMBER_HIDDEN185BoxCollisionTest(C_TOUCH, object.entityPos, -24, -12, 24, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)186if checkResult == true187CallFunction(Player_BadnikBreak)188end if189end if190next191192object.frame = object.animationTimer193object.frame >>= 1194object.frame += 2195object.animationTimer++196object.animationTimer &= 3197end event198199200event ObjectDraw201if object.state < BUZZBOMBER_HIDDEN202if object.direction == FLIP_NONE203DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)204else205object.frame += 2206DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)207object.frame -= 2208end if209end if210211switch object.animation212case BUZZBOMBER_ANI_FLY213DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)214object.frame += 4215DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)216object.frame -= 4217break218219case BUZZBOMBER_ANI_FLY_IDLE220DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)221break222223case BUZZBOMBER_ANI_SHOOT224DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)225break226227default228break229230end switch231end event232233234event ObjectStartup235CheckCurrentStageFolder("Zone01")236if checkResult == true237LoadSpriteSheet("GHZ/Objects.gif")238SpriteFrame(-23, -9, 45, 19, 98, 74)239SpriteFrame(-23, -9, 36, 29, 149, 49)240SpriteFrame(-17, -15, 35, 8, 144, 79)241SpriteFrame(-18, -10, 37, 5, 144, 88)242SpriteFrame(-18, -15, 35, 8, 145, 220)243SpriteFrame(-19, -10, 37, 5, 143, 229)244SpriteFrame(13, 4, 6, 5, 98, 68)245SpriteFrame(13, 4, 10, 5, 104, 68)246end if247248CheckCurrentStageFolder("Zone02")249if checkResult == true250LoadSpriteSheet("MZ/Objects.gif")251SpriteFrame(-23, -9, 45, 19, 1, 127)252SpriteFrame(-23, -9, 36, 29, 1, 147)253SpriteFrame(-17, -15, 35, 8, 38, 147)254SpriteFrame(-18, -10, 37, 5, 38, 156)255SpriteFrame(-18, -15, 35, 8, 38, 162)256SpriteFrame(-19, -10, 37, 5, 38, 171)257SpriteFrame(13, 4, 6, 5, 76, 153)258SpriteFrame(13, 4, 10, 5, 74, 147)259end if260261CheckCurrentStageFolder("Zone03")262if checkResult == true263LoadSpriteSheet("SYZ/Objects.gif")264SpriteFrame(-23, -9, 45, 19, 1, 81)265SpriteFrame(-23, -9, 36, 29, 1, 101)266SpriteFrame(-17, -15, 35, 8, 38, 101)267SpriteFrame(-18, -10, 37, 5, 38, 110)268SpriteFrame(-18, -15, 35, 8, 38, 116)269SpriteFrame(-19, -10, 37, 5, 38, 125)270SpriteFrame(13, 4, 6, 5, 76, 123)271SpriteFrame(13, 4, 10, 5, 83, 123)272end if273274CheckCurrentStageFolder("Zone07")275if checkResult == true276LoadSpriteSheet("MBZ/Objects.gif")277SpriteFrame(-23, -9, 45, 19, 1, 1)278SpriteFrame(-23, -9, 36, 29, 1, 21)279SpriteFrame(-17, -15, 35, 8, 38, 21)280SpriteFrame(-18, -10, 37, 5, 38, 30)281SpriteFrame(-18, -15, 35, 8, 38, 36)282SpriteFrame(-19, -10, 37, 5, 38, 45)283SpriteFrame(13, 4, 6, 5, 47, 15)284SpriteFrame(13, 4, 10, 5, 54, 15)285end if286287// propertyValue info:288// bit 0 = direction289// bit 1 = range type (large/small)290291foreach (TypeName[Buzz Bomber], arrayPos0, ALL_ENTITIES)292object[arrayPos0].startPos.x = object[arrayPos0].xpos293object[arrayPos0].inkEffect = 2294object[arrayPos0].alpha = 0xC0295GetBit(temp0, object[arrayPos0].propertyValue, 0)296if temp0 == 0297object[arrayPos0].direction = FLIP_NONE298object[arrayPos0].xvel = -0x40000299else300object[arrayPos0].direction = FLIP_X301object[arrayPos0].xvel = 0x40000302end if303next304305SetTableValue(TypeName[Buzz Bomber], DebugMode_ObjCount, DebugMode_TypesTable)306SetTableValue(BuzzBomber_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)307SetTableValue(BuzzBomber_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)308DebugMode_ObjCount++309end event310311312// ========================313// Editor Events314// ========================315316event RSDKEdit317if editor.returnVariable == true318switch editor.variableID319case EDIT_VAR_PROPVAL // property value320checkResult = object.propertyValue321break322323case 0 // direction324GetBit(checkResult, object.propertyValue, 0)325break326327case 1 // rangeSize328GetBit(checkResult, object.propertyValue, 1)329break330331case 2 // hideOnOffScreen332CheckEqual(object.hideOnOffScreen, true)333break334335end switch336else337switch editor.variableID338case EDIT_VAR_PROPVAL // property value339object.propertyValue = editor.variableValue340break341342case 0 // direction343CheckNotEqual(editor.variableValue, false)344SetBit(object.propertyValue, 0, checkResult)345break346347case 1 // rangeSize348CheckNotEqual(editor.variableValue, false)349SetBit(object.propertyValue, 1, checkResult)350break351352case 2 // hideOnOffScreen353object.hideOnOffScreen = editor.variableValue354break355356end switch357end if358end event359360361event RSDKDraw362GetBit(object.direction, object.propertyValue, 0)363DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)364DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)365end event366367368event RSDKLoad369// Make sure we have a fall-back, in case the current folder isn't actually a valid one370temp0 = false371372CheckCurrentStageFolder("Zone02")373temp0 |= checkResult374if checkResult == true375LoadSpriteSheet("MZ/Objects.gif")376SpriteFrame(-23, -9, 45, 19, 1, 127)377SpriteFrame(-17, -15, 35, 8, 38, 147)378end if379380CheckCurrentStageFolder("Zone03")381temp0 |= checkResult382if checkResult == true383LoadSpriteSheet("SYZ/Objects.gif")384SpriteFrame(-23, -9, 45, 19, 1, 81)385SpriteFrame(-17, -15, 35, 8, 38, 101)386end if387388CheckCurrentStageFolder("Zone07")389temp0 |= checkResult390if checkResult == true391LoadSpriteSheet("MBZ/Objects.gif")392SpriteFrame(-23, -9, 45, 19, 1, 1)393SpriteFrame(-17, -15, 35, 8, 38, 21)394end if395396if temp0 == false397// We use GHZ's sprites as the fallback, "Zone01" (GHZ's folder) will come here too398LoadSpriteSheet("GHZ/Objects.gif")399SpriteFrame(-23, -9, 45, 19, 98, 74)400SpriteFrame(-17, -15, 35, 8, 144, 79)401end if402403AddEditorVariable("direction")404SetActiveVariable("direction")405AddEnumVariable("Left", 0)406AddEnumVariable("Right", 1)407408AddEditorVariable("rangeSize")409SetActiveVariable("rangeSize")410AddEnumVariable("Large", 0)411AddEnumVariable("Small", 1)412413AddEditorVariable("hideOnOffScreen")414SetActiveVariable("hideOnOffScreen")415AddEnumVariable("False", false)416AddEnumVariable("True", true)417end event418419420