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

//-------Aliases-------//
private alias 62 : TYPE_EGGMANFIREBALL2


// Static Values

// Tables

event ObjectMain
	object.xpos += object.xvel
	object.ypos += object.yvel
	object.yvel += 0x3800
	ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
	if checkResult == 1
		PlaySfx(SfxName[Flame Thrower], 0)
		CreateTempObject(TypeName[Ground Flame], 0, object.xpos, object.ypos)
		object[tempObjectPos].value0 = 3
		if object.xvel < 0
			object[tempObjectPos].direction = FLIP_NONE
			object[tempObjectPos].xpos -= 0x20000
		else
			object[tempObjectPos].direction = FLIP_X
			object[tempObjectPos].xpos += 0x20000
		end if
		object.type = TypeName[Blank Object]
	end if
	object.frame = object.animationTimer
	object.frame >>= 2
	object.animationTimer++
	object.animationTimer &= 7
	if object.outOfBounds == 1
		object.type = TypeName[Blank Object]
	end if
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		if checkResult == 1
			CallFunction(PlayerObject_FireHit)
		end if
	next
end event


event ObjectDraw
	DrawSprite(object.frame)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone05")
	if checkResult == 1
		LoadSpriteSheet("HTZ/Objects.gif")
		SpriteFrame(-8, -8, 16, 16, 191, 94)
		SpriteFrame(-8, -8, 16, 16, 191, 110)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-8, -8, 16, 16, 1008, 1)
		SpriteFrame(-8, -8, 16, 16, 1008, 17)
	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
