Path: blob/master/Sonic 2/Scripts/OOZ/EggmanCannon.txt
1487 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Eggman Cannon 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.originPos.x13private alias object.value2 : object.originPos.y14private alias object.value3 : object.startPos.y15private alias object.value4 : object.cannonHeight16private alias object.value5 : object.shotCount17private alias object.value6 : object.lastAttackHeight1819// States20private alias 0 : OOZEGGMANCANNON_SETUP21private alias 1 : OOZEGGMANCANNON_RISE22private alias 2 : OOZEGGMANCANNON_PREPARE23private alias 3 : OOZEGGMANCANNON_ATTACK24private alias 4 : OOZEGGMANCANNON_LOWER2526// Player Aliases27private alias object.xpos : player.xpos282930// ========================31// Tables32// ========================3334private table OOZEggmanCannon_cannonHeights35-0x780000, -0x800000, -0x700000, -0x51000036end table373839// ========================40// Events41// ========================4243event ObjectUpdate44object.angle += 445object.angle &= 0x1FF46if player[0].xpos < object.xpos47object.direction = FLIP_NONE48else49object.direction = FLIP_X50end if5152switch object.state53case OOZEGGMANCANNON_SETUP54object.originPos.x = object.xpos55object.originPos.y = object.ypos56object.cannonHeight = object.ypos57object.cannonHeight -= 0x70000058object.startPos.y = object.ypos59object.yvel = -0x800060object.state = OOZEGGMANCANNON_RISE61break6263case OOZEGGMANCANNON_RISE64object.originPos.y += object.yvel65if object.originPos.y <= object.cannonHeight66object.originPos.y = object.cannonHeight67object.shotCount = 368object.timer = 12869object.lastAttackHeight = 070object.state++71end if72break7374case OOZEGGMANCANNON_PREPARE75if object.animationTimer > 076object.animationTimer--77else78object.frame = 079end if8081object.timer--82if object.timer == 083if object.shotCount > 084Rand(temp0, 4)85while temp0 == object.lastAttackHeight86if stage.milliSeconds > 5087temp0++88else89temp0--90end if91temp0 &= 392loop93object.lastAttackHeight = temp09495GetTableValue(object.cannonHeight, temp0, OOZEggmanCannon_cannonHeights)96object.cannonHeight += object.startPos.y97if object.cannonHeight < object.originPos.y98object.yvel = -0x800099else100object.yvel = 0x8000101end if102object.state = OOZEGGMANCANNON_ATTACK103else104object.yvel = 0x8000105object.state = OOZEGGMANCANNON_LOWER106end if107end if108break109110case OOZEGGMANCANNON_ATTACK111object.originPos.y += object.yvel112checkResult = false113if object.yvel < 0114if object.originPos.y <= object.cannonHeight115object.originPos.y = object.cannonHeight116checkResult = true117end if118else119if object.originPos.y >= object.cannonHeight120object.originPos.y = object.cannonHeight121checkResult = true122end if123end if124125if checkResult == true126object.animationTimer = 7127object.frame = 1128object.shotCount--129object.timer = 40130object.state = OOZEGGMANCANNON_PREPARE131132Cos(object.xpos, object.angle)133object.xpos <<= 11134object.xpos += object.originPos.x135136Sin(object.ypos, object.angle)137object.ypos <<= 9138object.ypos += object.originPos.y139140CreateTempObject(TypeName[Eggman Laser], 0, object.xpos, object.ypos)141object[tempObjectPos].drawOrder = 2142object[tempObjectPos].direction = object.direction143if object.direction == FLIP_NONE144object[tempObjectPos].xvel = -0x40000145else146object[tempObjectPos].xvel = 0x40000147end if148PlaySfx(SfxName[Small Laser], false)149end if150break151152case OOZEGGMANCANNON_LOWER153object.originPos.y += object.yvel154if object.originPos.y > object.startPos.y155object.type = TypeName[Blank Object]156end if157break158159end switch160end event161162163event ObjectDraw164temp1 = object.angle165temp1 -= 288166temp1 &= 0x1FF167temp0 = 0168temp2 = object.originPos.y169temp2 += 0x780000170while temp0 < 8171Cos(object.xpos, temp1)172object.xpos <<= 11173object.xpos += object.originPos.x174175Sin(object.ypos, temp1)176object.ypos <<= 9177object.ypos += temp2178179DrawSprite(2)180181temp0++182temp1 += 32183temp1 &= 0x1FF184temp2 -= 0xF0000185loop186187Cos(object.xpos, temp1)188object.xpos <<= 11189object.xpos += object.originPos.x190191Sin(object.ypos, temp1)192object.ypos <<= 9193object.ypos += temp2194195DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)196197// Why is there collision in the draw event?????198#platform: USE_ORIGINS199foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)200#endplatform201BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)202if checkResult == true203CallFunction(Player_Hit)204end if205#platform: USE_ORIGINS206next207#endplatform208end event209210211event ObjectStartup212CheckCurrentStageFolder("Zone07")213if checkResult == true214LoadSpriteSheet("OOZ/Objects.gif")215SpriteFrame(-32, -8, 40, 16, 141, 207)216SpriteFrame(-32, -8, 40, 16, 141, 224)217SpriteFrame(-8, -8, 16, 16, 379, 196)218else219LoadSpriteSheet("MBZ/Objects.gif")220SpriteFrame(-32, -8, 40, 16, 512, 180)221SpriteFrame(-32, -8, 40, 16, 553, 180)222SpriteFrame(-8, -8, 16, 16, 355, 214)223end if224end event225226227// ========================228// Editor Events229// ========================230231event RSDKDraw232DrawSprite(0)233end event234235236event RSDKLoad237CheckCurrentStageFolder("Zone07")238if checkResult == true239LoadSpriteSheet("OOZ/Objects.gif")240SpriteFrame(-32, -8, 40, 16, 141, 224)241else242LoadSpriteSheet("MBZ/Objects.gif")243SpriteFrame(-32, -8, 40, 16, 553, 180)244end if245246SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")247end event248249250