Path: blob/master/Sonic 2/Scripts/Enemies/Octus.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Octus 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.y1314// States15private alias 0 : OCTUS_SETUP16private alias 1 : OCTUS_JUMPDELAY17private alias 2 : OCTUS_JUMP18private alias 3 : OCTUS_SHOOT19private alias 4 : OCTUS_FALL2021// Player Aliases22private alias object.value40 : player.hitboxLeft23private alias object.value38 : player.hitboxTop24private alias object.value41 : player.hitboxRight25private alias object.value39 : player.hitboxBottom2627// Path ID Aliases28private alias 0 : PATH_A293031// ========================32// Function Declarations33// ========================3435reserve function Octus_DebugDraw36reserve function Octus_DebugSpawn37reserve function Octus_TryPlayShotSfx383940// ========================41// Function Definitions42// ========================4344private function Octus_DebugDraw45DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)46end function474849private function Octus_DebugSpawn50CreateTempObject(TypeName[Octus], 0, object.xpos, object.ypos)51object[tempObjectPos].direction = object.direction52end function535455private function Octus_TryPlayShotSfx56temp0 = screen.xcenter57temp0 += 3258CheckCameraProximity(object.ixpos, object.iypos, temp0, 140)59if checkResult == true60// Fun fact, this sound effect isn't named correctly for Mission Mode Sky Chase in Origins LOL61// because of that it just plays the jump sfx (id 0)62PlaySfx(SfxName[Octus Shot], false)63end if64end function656667// ========================68// Events69// ========================7071event ObjectUpdate72switch object.state73case OCTUS_SETUP74if object.priority != PRIORITY_XBOUNDS_DESTROY75object.priority = PRIORITY_ACTIVE76end if7778ObjectTileGrip(CSIDE_FLOOR, 0, 13, PATH_A)7980foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)81BoxCollisionTest(C_TOUCH, object.entityPos, -128, -512, 128, 512, currentPlayer, 0, 0, 0, 0)82if checkResult == true83object.state = OCTUS_JUMPDELAY84end if85next8687object.frame = object.animationTimer88object.frame >>= 489object.animationTimer++90object.animationTimer &= 3191break9293case OCTUS_JUMPDELAY94object.frame = 29596object.timer++97if object.timer == 3298object.timer = 099object.yvel = -0x20000100object.animationTimer = 0101object.state = OCTUS_JUMP102end if103break104105case OCTUS_JUMP106if object.timer < 8107object.timer++108object.frame = 1109else110object.frame = object.animationTimer111object.frame >>= 2112object.frame += 3113object.animationTimer++114object.animationTimer %= 12115end if116117object.yvel += 0x1000118if object.yvel >= 0119object.timer = 0120object.drawOrder = 4121object.state = OCTUS_SHOOT122end if123124object.ypos += object.yvel125break126127case OCTUS_SHOOT128if object.timer == 0129CreateTempObject(TypeName[Octus Shot], 0, object.xpos, object.ypos)130if object.direction == FLIP_NONE131object[tempObjectPos].xpos -= 0xE0000132object[tempObjectPos].xvel = -0x20000133else134object[tempObjectPos].xpos += 0xE0000135object[tempObjectPos].xvel = 0x20000136end if137138CallFunction(Octus_TryPlayShotSfx)139end if140141if object.timer == 15142object.drawOrder = 3143end if144145object.frame = object.animationTimer146object.frame >>= 2147object.frame += 3148object.animationTimer++149object.animationTimer %= 12150object.timer++151if object.timer == 60152object.timer = 0153object.state = OCTUS_FALL154end if155break156157case OCTUS_FALL158object.frame = object.animationTimer159object.frame >>= 2160object.frame += 3161object.animationTimer++162object.animationTimer %= 12163object.yvel += 0x1000164object.ypos += object.yvel165ObjectTileCollision(CSIDE_FLOOR, 0, 13, PATH_A)166if checkResult == true167object.yvel = 0168object.animationTimer = 0169object.state = OCTUS_SETUP170end if171break172173end switch174175if object.outOfBounds == true176#platform: USE_ORIGINS177if game.playMode == BOOT_PLAYMODE_MISSION178object.yvel = 0179end if180#endplatform181temp0 = object.ypos182object.ypos = object.startPos.y183if object.outOfBounds == true184if object.priority != PRIORITY_XBOUNDS_DESTROY185object.priority = PRIORITY_BOUNDS186object.timer = 0187object.animationTimer = 0188object.state = OCTUS_SETUP189end if190else191object.ypos = temp0192end if193end if194195foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)196BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)197if checkResult == true198CallFunction(Player_BadnikBreak)199end if200next201end event202203204event ObjectDraw205DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)206end event207208209event ObjectStartup210CheckCurrentStageFolder("Zone07")211if checkResult == true212LoadSpriteSheet("OOZ/Objects.gif")213SpriteFrame(-21, -12, 42, 25, 1, 49)214SpriteFrame(-16, -19, 32, 32, 149, 52)215SpriteFrame(-21, -12, 42, 25, 1, 75)216SpriteFrame(-21, -12, 42, 25, 1, 49)217SpriteFrame(-20, -12, 40, 25, 44, 49)218SpriteFrame(-21, -12, 42, 25, 85, 49)219else220// This does mean the entire MBZ sheet is loaded in Origins's WFZ mission221222LoadSpriteSheet("MBZ/Objects.gif")223SpriteFrame(-21, -12, 42, 25, 667, 256)224SpriteFrame(-16, -19, 32, 32, 634, 256)225SpriteFrame(-21, -12, 42, 25, 794, 256)226SpriteFrame(-21, -12, 42, 25, 667, 256)227SpriteFrame(-20, -12, 40, 25, 710, 256)228SpriteFrame(-21, -12, 42, 25, 751, 256)229end if230231foreach (TypeName[Octus], arrayPos0, ALL_ENTITIES)232object[arrayPos0].direction = object[arrayPos0].propertyValue233object[arrayPos0].direction &= FLIP_X234object[arrayPos0].startPos.y = object[arrayPos0].ypos235next236237SetTableValue(TypeName[Octus], DebugMode_ObjCount, DebugMode_TypesTable)238SetTableValue(Octus_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)239SetTableValue(Octus_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)240DebugMode_ObjCount++241end event242243244// ========================245// Editor Events246// ========================247248event RSDKEdit249if editor.returnVariable == true250switch editor.variableID251case EDIT_VAR_PROPVAL // property value252checkResult = object.propertyValue253break254255case 0 // direction256checkResult = object.propertyValue257break258259end switch260else261switch editor.variableID262case EDIT_VAR_PROPVAL // property value263object.propertyValue = editor.variableValue264break265266case 0 // direction267object.propertyValue = editor.variableValue268break269270end switch271end if272end event273274275event RSDKDraw276GetBit(object.direction, object.propertyValue, 0)277DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)278279if editor.showGizmos == true280editor.drawingOverlay = true281282temp0 = object.ypos283temp0 -= 0x200000284285// we might have to flip so no ink effects for us, sorry..286DrawSpriteFX(0, FX_FLIP, object.xpos, temp0)287288DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0x00, 0xFF, 0x00)289290editor.drawingOverlay = false291end if292end event293294295event RSDKLoad296CheckCurrentStageFolder("Zone07")297if checkResult == true298LoadSpriteSheet("OOZ/Objects.gif")299SpriteFrame(-21, -12, 42, 25, 1, 49)300else301LoadSpriteSheet("MBZ/Objects.gif")302SpriteFrame(-21, -12, 42, 25, 667, 256)303end if304305AddEditorVariable("direction")306SetActiveVariable("direction")307AddEnumVariable("Left", 0)308AddEnumVariable("Right", 1)309end event310311312