Path: blob/master/Sonic 2/Scripts/Enemies/Bee.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Bee 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.shootTimer1516// States17private alias 0 : BEE_FLYING18private alias 1 : BEE_STOPPED19private alias 2 : BEE_SHOOTING20private alias 3 : BEE_INVISIBLE2122// Animations23private alias 0 : BEE_ANI_FLYING24private alias 1 : BEE_ANI_STOPPED25private alias 2 : BEE_ANI_SHOOTING26private alias 3 : BEE_ANI_INVISIBLE2728// Player Aliases29private alias object.value40 : player.hitboxLeft30private alias object.value38 : player.hitboxTop31private alias object.value41 : player.hitboxRight32private alias object.value39 : player.hitboxBottom333435// ========================36// Function Declarations37// ========================3839reserve function Bee_DebugDraw40reserve function Bee_DebugSpawn414243// ========================44// Function Definitions45// ========================4647private function Bee_DebugDraw48DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)49end function505152private function Bee_DebugSpawn53CreateTempObject(TypeName[Bee], 0, object.xpos, object.ypos)54GetBit(temp0, object.direction, 0)55if temp0 == FACING_RIGHT56object[tempObjectPos].direction = FLIP_NONE57object[tempObjectPos].xvel = -0x1000058else59object[tempObjectPos].direction = FLIP_X60object[tempObjectPos].xvel = 0x1000061end if62end function636465// ========================66// Events67// ========================6869event ObjectUpdate70switch object.state71case BEE_FLYING72object.priority = PRIORITY_ACTIVE73if object.timer < 25674object.timer++75object.xpos += object.xvel76else77object.timer = 078object.state = BEE_STOPPED79object.animation = BEE_ANI_STOPPED80object.direction ^= FLIP_X81FlipSign(object.xvel)82end if83break8485case BEE_STOPPED86if object.shootTimer < 3087object.shootTimer++88else89object.shootTimer = 090object.state = BEE_FLYING91object.animation = BEE_ANI_FLYING92object.hasShot = false93end if94break9596case BEE_SHOOTING97if object.shootTimer < 5098object.shootTimer++99if object.shootTimer == 30100CreateTempObject(TypeName[Bee Shot], 0, object.xpos, object.ypos)101object[tempObjectPos].direction = object.direction102if object.direction == FLIP_NONE103object[tempObjectPos].xpos += 0xD0000104object[tempObjectPos].xvel = -0x18000105else106object[tempObjectPos].xpos -= 0xD0000107object[tempObjectPos].xvel = 0x18000108end if109object[tempObjectPos].ypos += 0x180000110object[tempObjectPos].yvel = 0x18000111end if112else113object.shootTimer = 0114object.state = BEE_FLYING115object.animation = BEE_ANI_FLYING116object.hasShot = true117end if118break119120case BEE_INVISIBLE121object.animation = BEE_ANI_INVISIBLE122break123124end switch125126if object.outOfBounds == true127temp0 = object.xpos128object.xpos = object.startPos.x129if object.shootTimer == 1130object.state = BEE_INVISIBLE131end if132133if object.outOfBounds == true134object.xpos = object.startPos.x135136GetBit(temp0, object.propertyValue, 0)137if temp0 == 0138object.direction = FLIP_NONE139object.xvel = -0x10000140else141object.direction = FLIP_X142object.xvel = 0x10000143end if144145object.timer = 0146object.animation = BEE_ANI_FLYING147object.priority = PRIORITY_BOUNDS148object.state = BEE_FLYING149else150object.xpos = temp0151end if152end if153154foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)155if object.state == BEE_FLYING156if object.hasShot == false157if object.direction == FLIP_NONE158BoxCollisionTest(C_TOUCH, object.entityPos, -28, -256, -30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)159else160BoxCollisionTest(C_TOUCH, object.entityPos, 28, -256, 30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)161end if162163if checkResult == true164object.state = BEE_SHOOTING165object.animation = BEE_ANI_SHOOTING166end if167end if168end if169170if object.state < BEE_INVISIBLE171BoxCollisionTest(C_TOUCH, object.entityPos, -24, -12, 24, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)172if checkResult == true173CallFunction(Player_BadnikBreak)174end if175end if176next177178object.frame = object.animationTimer179object.frame /= 3180object.frame += 3181object.animationTimer++182if object.animationTimer >= 6183object.animationTimer = 0184end if185end event186187188event ObjectDraw189switch object.animation190case BEE_ANI_FLYING191DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)192DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)193break194195case BEE_ANI_STOPPED196DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)197break198199case BEE_ANI_SHOOTING200DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)201202if object.shootTimer > 20203if object.shootTimer < 30204DrawSpriteFX(2, FX_FLIP, object.xpos, object.ypos)205end if206end if207break208209case BEE_ANI_INVISIBLE210break211212end switch213end event214215216event ObjectStartup217CheckCurrentStageFolder("Zone01")218if checkResult == true219LoadSpriteSheet("EHZ/Objects.gif")220SpriteFrame(-24, -8, 48, 18, 78, 1)221SpriteFrame(-24, -8, 42, 31, 146, 224)222SpriteFrame(1, 6, 17, 17, 50, 1)223SpriteFrame(5, -8, 6, 5, 19, 50)224SpriteFrame(5, -8, 7, 5, 19, 56)225else226LoadSpriteSheet("MBZ/Objects.gif")227228// This is strange - they *partially* adjusted some of the frames for MBZ?229// The ones shared with the Buzzer (which is used in MBZ) got updated, while the ones unique to the Bee were neglected230// How strange...231232SpriteFrame(-24, -8, 48, 18, 78, 1)233SpriteFrame(-24, -8, 42, 31, 146, 224)234SpriteFrame(1, 6, 17, 17, 50, 1)235SpriteFrame(5, -8, 6, 5, 137, 331)236SpriteFrame(5, -8, 7, 5, 137, 337)237end if238239foreach (TypeName[Bee], arrayPos0, ALL_ENTITIES)240object[arrayPos0].startPos.x = object[arrayPos0].xpos241242GetBit(temp0, object[arrayPos0].propertyValue, 0)243if temp0 == 0244object[arrayPos0].direction = FLIP_NONE245object[arrayPos0].xvel = -0x10000246else247object[arrayPos0].direction = FLIP_X248object[arrayPos0].xvel = 0x10000249end if250next251252SetTableValue(TypeName[Bee], DebugMode_ObjCount, DebugMode_TypesTable)253SetTableValue(Bee_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)254SetTableValue(Bee_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)255DebugMode_ObjCount++256end event257258259// ========================260// Editor Events261// ========================262263event RSDKEdit264if editor.returnVariable == true265switch editor.variableID266case EDIT_VAR_PROPVAL // property value267checkResult = object.propertyValue268break269270case 0 // direction271checkResult = object.propertyValue272break273274end switch275else276switch editor.variableID277case EDIT_VAR_PROPVAL // property value278object.propertyValue = editor.variableValue279break280281case 0 // direction282object.propertyValue = editor.variableValue283break284285end switch286end if287end event288289290event RSDKDraw291GetBit(object.direction, object.propertyValue, 0)292DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)293DrawSpriteFX(3, FX_FLIP, object.xpos, object.ypos)294end event295296297event RSDKLoad298CheckCurrentStageFolder("Zone01")299if checkResult == true300LoadSpriteSheet("EHZ/Objects.gif")301SpriteFrame(-24, -8, 48, 18, 78, 1)302SpriteFrame(-24, -8, 42, 31, 146, 224)303SpriteFrame(1, 6, 17, 17, 50, 1)304SpriteFrame(5, -8, 6, 5, 19, 50)305SpriteFrame(5, -8, 7, 5, 19, 56)306else307LoadSpriteSheet("MBZ/Objects.gif")308SpriteFrame(-24, -8, 48, 18, 78, 1)309SpriteFrame(-24, -8, 42, 31, 146, 224)310SpriteFrame(1, 6, 17, 17, 50, 1)311SpriteFrame(5, -8, 6, 5, 137, 331)312SpriteFrame(5, -8, 7, 5, 137, 337)313end if314315AddEditorVariable("direction")316SetActiveVariable("direction")317AddEnumVariable("Left", 0)318AddEnumVariable("Right", 1)319end event320321322