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

//-------Aliases-------//
private alias 59 : TYPE_EGGMANDRILL


// Static Values

// Tables

event ObjectMain
	if object.state == 0
		if object.interaction == 1
			temp0 = object.xpos
			temp1 = object.ypos
			Sin(object.xpos, object.angle)
			if object.direction == FLIP_NONE
				object.xpos *= -0xC00
			else
				object.xpos *= 0xC00
			end if
			Cos(object.ypos, object.angle)
			object.ypos *= -0xC00
			object.xpos += temp0
			object.ypos += temp1
			foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
				BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
				if checkResult == 1
					CallFunction(PlayerObject_Hit)
				end if
			next
			Sin(object.xpos, object.angle)
			if object.direction == FLIP_NONE
				object.xpos *= -0x1300
			else
				object.xpos *= 0x1300
			end if
			Cos(object.ypos, object.angle)
			object.ypos *= -0x1300
			object.xpos += temp0
			object.ypos += temp1
			foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
				BoxCollisionTest(C_TOUCH, object.entityPos, -4, -4, 4, 4, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
				if checkResult == 1
					CallFunction(PlayerObject_Hit)
				end if
			next
			object.xpos = temp0
			object.ypos = temp1
		end if
	else
		object.xpos += object.xvel
		object.ypos += object.yvel
		object.yvel += 0x3800
		if object.outOfBounds == 1
			object.type = TypeName[Blank Object]
		end if
	end if
end event


event ObjectDraw
	DrawSpriteFX(object.frame, FX_ROTATE, object.xpos, object.ypos)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone06")
	if checkResult == 1
		LoadSpriteSheet("MCZ/Objects.gif")
		SpriteFrame(-12, -48, 24, 64, 1, 132)
		SpriteFrame(-12, -48, 24, 64, 26, 132)
		SpriteFrame(-12, -48, 24, 64, 51, 132)
		SpriteFrame(-48, -12, 64, 24, 150, 182)
		SpriteFrame(-48, -12, 64, 24, 150, 207)
		SpriteFrame(-48, -12, 64, 24, 150, 232)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-12, -48, 24, 64, 42, 191)
		SpriteFrame(-12, -48, 24, 64, 67, 191)
		SpriteFrame(-12, -48, 24, 64, 92, 191)
		SpriteFrame(-48, -12, 64, 24, 117, 181)
		SpriteFrame(-48, -12, 64, 24, 117, 206)
		SpriteFrame(-48, -12, 64, 24, 117, 231)
	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
