// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Lava Bubble Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 64 : TYPE_LAVABUBBLE

// Function declarations
reserve function LavaBubble_DebugDraw
reserve function LavaBubble_DebugSpawn

// Static Values

// Tables

function LavaBubble_DebugDraw
	DrawSprite(0)
end function


function LavaBubble_DebugSpawn
	CreateTempObject(TypeName[Lava Bubble], 0, object.xpos, object.ypos)
end function


event ObjectMain
	if object.state == 0
		object.animationTimer++
		if object.animationTimer >= 13
			object.animationTimer = 0
			object.frame++
			if object.frame == 3
				object.frame = 0
				object.state = 1
			end if
		end if
		if object.frame == 2
			if object.animationTimer == 8
				PlaySfx(SfxName[Small Fireball], 0)
				CreateTempObject(TypeName[Lava Jump], 0, object.xpos, object.ypos)
				object[tempObjectPos].xvel = -0x1C000
				object[tempObjectPos].yvel = -0x60000
				CreateTempObject(TypeName[Lava Jump], 0, object.xpos, object.ypos)
				object[tempObjectPos].xvel = 0x1C000
				object[tempObjectPos].yvel = -0x60000
				object[tempObjectPos].direction = FLIP_X
			end if
		end if
	else
		object.animationTimer++
		if object.animationTimer >= 60
			object.animationTimer = 0
			object.state = 0
		end if
	end if
end event


event ObjectDraw
	if object.state == 0
		DrawSprite(object.frame)
	end if
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone05")
	if checkResult == 1
		LoadSpriteSheet("HTZ/Objects.gif")
		SpriteFrame(-8, -2, 16, 11, 124, 110)
		SpriteFrame(-8, -5, 16, 11, 141, 110)
		SpriteFrame(-8, -7, 16, 13, 158, 108)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-8, -2, 16, 11, 125, 110)
		SpriteFrame(-8, -5, 16, 11, 141, 110)
		SpriteFrame(-8, -7, 16, 13, 158, 108)
	end if
	SetTableValue(TypeName[Lava Bubble], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(LavaBubble_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(LavaBubble_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
