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

//-------Aliases-------//
private alias 79 : TYPE_EGGMAN


// Static Values
public value WFZEggman_value51 = 0;

// Tables

event ObjectMain
	CheckEqual(options.vsMode, 1)
	temp0 = checkResult
	CheckEqual(options.gameMode, 2)
	temp0 |= checkResult
	if temp0 == 1		
		object.type = TypeName[Blank Object]
		temp0 = tileLayer[0].ysize
		temp0 <<= 7
		stage.newYBoundary2 = temp0
		temp0 <<= 16
		stage.deathBoundary = temp0
	else		
		switch object.state
		case 0
			temp0 = object.xpos
			temp0 -= 0x200000
			if object[0].xpos > temp0
				temp0 = stage.newYBoundary2
				temp0 -= screen.ysize
				stage.newYBoundary1 = temp0
				if object.propertyValue == 1
					temp0 = object.ixpos
					temp0 -= 212
					stage.newXBoundary1 = temp0
				end if
				object.xpos += 0xE00000
				object[+1].type = TypeName[Eggman Barrier]
				object[+1].inkEffect = INK_ADD
				object[+2].type = TypeName[Eggman Barrier]
				object[+2].propertyValue = 1
				object[+2].inkEffect = INK_ADD
				object[+4].type = WFZEggman_value51
				ResetObjectEntity(26, TypeName[Music Event], 0, 0, 0)
				object[26].priority = PRIORITY_ACTIVE
				object.priority = PRIORITY_ACTIVE
				object.state = 1
			end if
			break
		case 1
			break
		case 2
			object.ypos += 0x10000
			object.value0++
			if object.value0 == 240
				stage.newYBoundary1 = 0
				object.type = TypeName[Blank Object]
				ResetObjectEntity(26, TypeName[Music Event], 1, 0, 0)
				object[26].priority = PRIORITY_ACTIVE
			end if
			break
		end switch
		object.animationTimer++
		if object.animationTimer >= 6
			object.animationTimer = 0
			object.frame ^= 1
		end if
	end if
end event


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


event ObjectStartup
	CheckCurrentStageFolder("Zone11")
	if checkResult == 1
		if stage.playerListPos == 2
			if saveRAM[284] == 1
				LoadSpriteSheet("SCZ/ObjectsRobo.gif")
			else
				LoadSpriteSheet("SCZ/Objects.gif")
			end if
		else
			LoadSpriteSheet("SCZ/Objects.gif")
		end if
		SpriteFrame(-22, -28, 38, 52, 1, 256)
		SpriteFrame(-22, -27, 38, 51, 41, 257)
		SpriteFrame(-32, 24, 64, 24, 1, 146)
		WFZEggman_value51 = TypeName[Eggman Laser]
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-16, -28, 32, 52, 737, 58)
		SpriteFrame(-16, -27, 32, 51, 770, 58)
		SpriteFrame(-32, 24, 64, 24, 464, 999)
		WFZEggman_value51 = TypeName[Eggman Laser 3]
	end if
end event

event RSDKDraw
	DrawSprite(0)
end event

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