Path: blob/master/Sonic 2/Scripts/Enemies/BubblersMother.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Bubblers Mother 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.spawnTimer13private alias object.value2 : object.startPos.x14private alias object.value3 : object.startPos.y1516// States17private alias 0 : BUBBLERSMOTHER_PATROL18private alias 1 : BUBBLERSMOTHER_FOUNDPLAYER19private alias 2 : BUBBLERSMOTHER_ATTACKING2021// Player Aliases22private alias object.value40 : player.hitboxLeft23private alias object.value38 : player.hitboxTop24private alias object.value41 : player.hitboxRight25private alias object.value39 : player.hitboxBottom2627// ========================28// Function Declarations29// ========================3031reserve function BubblersMother_Setup32reserve function BubblersMother_DebugDraw33reserve function BubblersMother_DebugSpawn343536// ========================37// Function Definitions38// ========================3940private function BubblersMother_Setup41object[arrayPos0].direction = object[arrayPos0].propertyValue42if object[arrayPos0].direction == FLIP_NONE43object[arrayPos0].xvel = -0x400044else45object[arrayPos0].xvel = 0x400046end if47object[arrayPos0].yvel = 048object[arrayPos0].timer = 51249object[arrayPos0].spawnTimer = 050object[arrayPos0].frame = 151object[arrayPos0].animationTimer = 052object[arrayPos0].priority = PRIORITY_BOUNDS53object[arrayPos0].state = BUBBLERSMOTHER_PATROL54end function555657private function BubblersMother_DebugDraw58DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)59end function606162private function BubblersMother_DebugSpawn63CreateTempObject(TypeName[Bubblers Mother], object.direction, object.xpos, object.ypos)64object[tempObjectPos].startPos.x = object.xpos65object[tempObjectPos].startPos.y = object.ypos66arrayPos0 = object[tempObjectPos].entityPos67CallFunction(BubblersMother_Setup)68end function697071// ========================72// Events73// ========================7475event ObjectUpdate76switch object.state77case BUBBLERSMOTHER_PATROL78object.priority = PRIORITY_ACTIVE79object.xpos += object.xvel80object.animationTimer++81object.animationTimer &= 382object.frame = object.animationTimer83object.frame >>= 184object.frame++8586object.timer--87if object.timer == 088object.direction ^= FLIP_X89FlipSign(object.xvel)90object.timer = 51291end if9293foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)94if object.state == BUBBLERSMOTHER_PATROL95if object.direction == FLIP_NONE96BoxCollisionTest(C_TOUCH, object.entityPos, -160, 12, 16, 96, currentPlayer, -1, -1, 1, 1)97else98BoxCollisionTest(C_TOUCH, object.entityPos, 16, 12, 160, 96, currentPlayer, -1, -1, 1, 1)99end if100101if checkResult == true102object.state = BUBBLERSMOTHER_FOUNDPLAYER103object.frame = 2104object.timer = 16105if object.direction == FLIP_NONE106object.xvel = -0x28000107else108object.xvel = 0x28000109end if110end if111end if112next113break114115case BUBBLERSMOTHER_FOUNDPLAYER116object.timer--117if object.timer < 0118object.state = BUBBLERSMOTHER_ATTACKING119end if120121object.animationTimer++122object.animationTimer &= 3123object.frame = object.animationTimer124object.frame >>= 1125object.frame++126break127128case BUBBLERSMOTHER_ATTACKING129object.xpos += object.xvel130object.ypos += object.yvel131132object.spawnTimer++133if object.spawnTimer >= 20134object.spawnTimer = 0135temp0 = object.xpos136if object.direction == FLIP_NONE137temp0 += 0x60000138else139temp0 -= 0x60000140end if141temp1 = object.ypos142temp1 += 0xA0000143CreateTempObject(TypeName[Bubbler], 0, temp0, temp1)144end if145146object.animationTimer++147if object.animationTimer >= 3148object.animationTimer = 0149end if150151object.frame = object.animationTimer152object.frame++153break154155end switch156157if object.outOfBounds == true158temp0 = object.xpos159temp1 = object.ypos160object.xpos = object.startPos.x161object.ypos = object.startPos.y162if object.outOfBounds == true163arrayPos0 = object.entityPos164CallFunction(BubblersMother_Setup)165else166object.xpos = temp0167object.ypos = temp1168end if169end if170171foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)172BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)173if checkResult == true174CallFunction(Player_BadnikBreak)175end if176next177end event178179180event ObjectDraw181DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)182DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)183end event184185186event ObjectStartup187CheckCurrentStageFolder("Zone02")188if checkResult == true189LoadSpriteSheet("CPZ/Objects.gif")190SpriteFrame(-16, -12, 32, 28, 117, 102)191SpriteFrame(0, 0, 1, 1, 117, 102)192SpriteFrame(15, -3, 7, 13, 150, 111)193SpriteFrame(15, -3, 8, 13, 158, 111)194else195LoadSpriteSheet("MBZ/Objects.gif")196SpriteFrame(-16, -12, 32, 28, 117, 102)197198// they uhhhh.... kinda forgot all the other frames199end if200201foreach (TypeName[Bubblers Mother], arrayPos0, ALL_ENTITIES)202object[arrayPos0].startPos.x = object[arrayPos0].xpos203CallFunction(BubblersMother_Setup)204next205206SetTableValue(TypeName[Bubblers Mother], DebugMode_ObjCount, DebugMode_TypesTable)207SetTableValue(BubblersMother_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)208SetTableValue(BubblersMother_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)209DebugMode_ObjCount++210end event211212213// ========================214// Editor Events215// ========================216217event RSDKEdit218if editor.returnVariable == true219switch editor.variableID220case EDIT_VAR_PROPVAL // property value221checkResult = object.propertyValue222break223224case 0 // direction225GetBit(checkResult, object.propertyValue, 0)226break227228end switch229else230switch editor.variableID231case EDIT_VAR_PROPVAL // property value232object.propertyValue = editor.variableValue233break234235case 0 // direction236CheckNotEqual(editor.variableValue, 0)237SetBit(object.propertyValue, 0, checkResult)238break239240end switch241end if242end event243244245event RSDKDraw246GetBit(object.direction, object.propertyValue, 0)247DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)248end event249250251event RSDKLoad252CheckCurrentStageFolder("Zone02")253if checkResult == true254LoadSpriteSheet("CPZ/Objects.gif")255SpriteFrame(-16, -12, 32, 28, 117, 102)256else257LoadSpriteSheet("MBZ/Objects.gif")258SpriteFrame(-16, -12, 32, 28, 117, 102)259end if260261AddEditorVariable("direction")262SetActiveVariable("direction")263AddEnumVariable("Left", 0)264AddEnumVariable("Right", 1)265end event266267268