Path: blob/master/Sonic 2/Scripts/Mission/Buzzer2.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Buzzer2 Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// This Object is used in Mission "Stinger Swarm!" - M030 - Mission_Zone0189// ========================10// Aliases11// ========================1213// This object has values set from the Editor, but these values are used for different purposes in-game1415// These pair of values, as they are set from the editor initially16private alias object.value0 : object.initialCooldown17private alias object.value1 : object.initialXVel1819// And then these are the same pair of values, but labelled as to what they do in-game20private alias object.value0 : object.timer21private alias object.value1 : object.startPos.x2223private alias object.value2 : object.hasShot24private alias object.value3 : object.shootTimer25private alias object.value4 : object.cooldownTime26private alias object.value5 : object.setXVel2728// States29private alias 0 : BUZZER2_FLYING30private alias 1 : BUZZER2_STOPPED31private alias 2 : BUZZER2_SHOOTING32private alias 3 : BUZZER2_INVISIBLE3334// Animations35private alias 0 : BUZZER2_ANI_FLYING36private alias 1 : BUZZER2_ANI_STOPPED37private alias 2 : BUZZER2_ANI_SHOOTING38private alias 3 : BUZZER2_ANI_INVISBLE3940// Player Aliases41private alias object.value40 : player.hitboxLeft42private alias object.value38 : player.hitboxTop43private alias object.value41 : player.hitboxRight44private alias object.value39 : player.hitboxBottom454647// ========================48// Function Declarations49// ========================5051reserve function Buzzer2_DebugDraw52reserve function Buzzer2_DebugSpawn535455// ========================56// Function Definitions57// ========================5859private function Buzzer2_DebugDraw60DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)61end function626364private function Buzzer2_DebugSpawn65CreateTempObject(TypeName[Buzzer2], 0, object.xpos, object.ypos)66GetBit(temp0, object.direction, 0)67if temp0 == FACING_RIGHT68object[tempObjectPos].direction = FLIP_NONE69object[tempObjectPos].xvel = -0x1000070else71object[tempObjectPos].direction = FLIP_X72object[tempObjectPos].xvel = 0x1000073end if74end function757677// ========================78// Events79// ========================8081event ObjectUpdate82switch object.state83case BUZZER2_FLYING84object.priority = PRIORITY_ACTIVE85if object.timer < object.cooldownTime86object.timer++87object.xpos += object.xvel88else89object.timer = 090object.state = BUZZER2_STOPPED91object.animation = BUZZER2_ANI_STOPPED92object.direction ^= FLIP_X93FlipSign(object.xvel)94end if95break9697case BUZZER2_STOPPED98if object.shootTimer < 3099object.shootTimer++100else101object.shootTimer = 0102object.state = BUZZER2_FLYING103object.animation = BUZZER2_ANI_FLYING104object.hasShot = false105end if106break107108case BUZZER2_SHOOTING109if object.shootTimer < 50110object.shootTimer++111if object.shootTimer == 30112CreateTempObject(TypeName[Buzzer Shot], 0, object.xpos, object.ypos)113object[tempObjectPos].direction = object.direction114if object.direction == FLIP_NONE115object[tempObjectPos].xpos += 0xD0000116object[tempObjectPos].xvel = -0x18000117else118object[tempObjectPos].xpos -= 0xD0000119object[tempObjectPos].xvel = 0x18000120end if121object[tempObjectPos].ypos += 0x180000122object[tempObjectPos].yvel = 0x18000123end if124else125object.shootTimer = 0126object.state = BUZZER2_FLYING127object.animation = BUZZER2_ANI_FLYING128object.hasShot = true129end if130break131132case BUZZER2_INVISIBLE133object.animation = BUZZER2_ANI_INVISBLE134break135136end switch137138if object.outOfBounds == true139temp0 = object.xpos140object.xpos = object.startPos.x141if object.shootTimer == 1142object.state = BUZZER2_INVISIBLE143end if144145if object.outOfBounds == true146object.xpos = object.startPos.x147object.xvel = object.setXVel148GetBit(temp0, object.propertyValue, 0)149if temp0 == false150object.direction = FLIP_NONE151FlipSign(object.xvel)152else153object.direction = FLIP_X154end if155156object.timer = 0157object.animation = BUZZER2_ANI_FLYING158object.priority = PRIORITY_BOUNDS159object.state = BUZZER2_FLYING160else161object.xpos = temp0162end if163end if164165foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)166if object.state == BUZZER2_FLYING167if object.hasShot == false168if object.direction == FLIP_NONE169BoxCollisionTest(C_TOUCH, object.entityPos, -28, -256, -30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)170else171BoxCollisionTest(C_TOUCH, object.entityPos, 28, -256, 30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)172end if173174if checkResult == true175object.state = BUZZER2_SHOOTING176object.animation = BUZZER2_ANI_SHOOTING177end if178end if179end if180181if object.state < BUZZER2_INVISIBLE182BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)183if checkResult == true184CallFunction(Player_BadnikBreak)185end if186end if187next188189object.frame = object.animationTimer190object.frame /= 3191object.frame += 3192object.animationTimer++193if object.animationTimer >= 6194object.animationTimer = 0195end if196end event197198199event ObjectDraw200switch object.animation201case BUZZER2_ANI_FLYING202DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)203DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)204break205206case BUZZER2_ANI_STOPPED207DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)208break209210case BUZZER2_ANI_SHOOTING211DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)212break213214case BUZZER2_ANI_INVISBLE215break216217end switch218end event219220221event ObjectStartup222CheckCurrentStageFolder("Zone01")223if checkResult == true224LoadSpriteSheet("EHZ/Objects.gif")225SpriteFrame(-24, -8, 48, 16, 1, 1)226SpriteFrame(-24, -8, 42, 31, 1, 18)227SpriteFrame(1, 6, 17, 17, 50, 1)228SpriteFrame(5, -8, 6, 5, 19, 50)229SpriteFrame(5, -8, 7, 5, 19, 56)230else231LoadSpriteSheet("MBZ/Objects.gif")232SpriteFrame(-24, -8, 48, 16, 1, 256)233SpriteFrame(-24, -8, 42, 31, 1, 273)234SpriteFrame(1, 6, 17, 17, 268, 501)235SpriteFrame(5, -8, 6, 5, 137, 331)236SpriteFrame(5, -8, 7, 5, 137, 337)237end if238239// They updated the use of TypeName here to be Buzzer2, but then...240foreach (TypeName[Buzzer2], arrayPos0, ALL_ENTITIES)241if object[arrayPos0].initialCooldown <= 0242object[arrayPos0].initialCooldown = 256243end if244245object[arrayPos0].cooldownTime = object[arrayPos0].initialCooldown246object[arrayPos0].timer = 0 // same object value as initialCooldown247248if object[arrayPos0].initialXVel <= 0249object[arrayPos0].initialXVel = 100250end if251object[arrayPos0].initialXVel *= 0x10000252object[arrayPos0].initialXVel /= 100253object[arrayPos0].setXVel = object[arrayPos0].initialXVel254255object[arrayPos0].startPos.x = object[arrayPos0].xpos256object[arrayPos0].xvel = object[arrayPos0].setXVel257258GetBit(temp0, object[arrayPos0].propertyValue, 0)259if temp0 == false260object[arrayPos0].direction = FLIP_NONE261FlipSign(object[arrayPos0].xvel)262else263object[arrayPos0].direction = FLIP_X264end if265next266267// ... this TypeName is still referencing a normal Buzzer, but with the Buzzer2 functions? sure ig268// It doesn't matter much since both Buzzers and Buzzer2's have the same SpriteFrames, but it's worth noting ig269SetTableValue(TypeName[Buzzer], DebugMode_ObjCount, DebugMode_TypesTable)270SetTableValue(Buzzer2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)271SetTableValue(Buzzer2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)272DebugMode_ObjCount++273end event274275276// ========================277// Editor Events278// ========================279280event RSDKEdit281if editor.returnVariable == true282switch editor.variableID283case EDIT_VAR_PROPVAL // property value284checkResult = object.propertyValue285break286287case 0 // direction288checkResult = object.propertyValue289break290291end switch292else293switch editor.variableID294case EDIT_VAR_PROPVAL // property value295object.propertyValue = editor.variableValue296break297298case 0 // direction299object.propertyValue = editor.variableValue300break301302end switch303end if304end event305306307event RSDKDraw308GetBit(object.direction, object.propertyValue, 0)309DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)310DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)311end event312313314event RSDKLoad315CheckCurrentStageFolder("Zone01")316if checkResult == true317LoadSpriteSheet("EHZ/Objects.gif")318SpriteFrame(-24, -8, 48, 16, 1, 1)319SpriteFrame(5, -8, 6, 5, 19, 50)320else321LoadSpriteSheet("MBZ/Objects.gif")322SpriteFrame(-24, -8, 48, 16, 1, 256)323SpriteFrame(5, -8, 6, 5, 137, 331)324end if325326AddEditorVariable("direction")327SetActiveVariable("direction")328AddEnumVariable("Left", 0)329AddEnumVariable("Right", 1)330331SetVariableAlias(ALIAS_VAR_VAL0, "cooldownTime")332SetVariableAlias(ALIAS_VAR_VAL1, "setXVel")333end event334335336