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

//-------Aliases-------//
private alias 57 : TYPE_BEESHOT


// Static Values

// Tables

event ObjectMain
	object.xpos += object.xvel
	object.ypos += object.yvel
	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, object[currentPlayer].value38, object[currentPlayer].value40, object[currentPlayer].value39, object[currentPlayer].value41)
		if checkResult == 1
			CallFunction(PlayerObject_ProjectileHit)
		end if
	next
	foreach (TypeName[Bridge], arrayPos0, ACTIVE_ENTITIES)
		if object.xpos > object[arrayPos0].value6
			if object.xpos < object[arrayPos0].value7
				temp0 = object[arrayPos0].ypos
				temp0 -= 0x80000
				if object.ypos >= temp0
					temp0 += 0x100000
					if object.ypos <= temp0
						temp7 = object.xpos
						temp7 -= object[arrayPos0].value6
						temp7 >>= 20
						temp7 *= 15
						temp7 -= 15
						temp6 = -15
						temp0 = 0
						temp1 = object[arrayPos0].value6
						temp1 += 0x80000
						temp4 = 0x80000
						temp5 = object[arrayPos0].value2
						temp5 >>= 20
						while temp0 < temp5
							temp3 = temp4
							temp3 <<= 7
							temp3 /= object[arrayPos0].value2
							Sin(temp2, temp3)
							temp2 *= object[arrayPos0].value4
							temp2 >>= 9
							temp2 += object[arrayPos0].ypos
							CreateTempObject(TypeName[Burning Log], 0, temp1, temp2)
							object[tempObjectPos].value0 = temp7
							temp7 += temp6
							if temp7 == 15
								FlipSign(temp6)
							end if
							temp1 += 0x100000
							temp4 += 0x100000
							temp0++
						loop
						temp2 = object[arrayPos0].value4
						temp2 += object[arrayPos0].ypos
						CreateTempObject(TypeName[Burning Log], 0, temp1, temp2)
						object[tempObjectPos].value0 = temp7
						temp7 += temp6
						if temp7 == 15
							FlipSign(temp6)
						end if
						temp1 += 0x100000
						temp0++
						temp5 = object[arrayPos0].value7
						temp5 -= object[arrayPos0].value6
						temp5 -= object[arrayPos0].value2
						temp1 = object[arrayPos0].value7
						temp1 -= 0x80000
						temp4 = 0x80000
						temp7 = object[arrayPos0].propertyValue
						temp7 -= temp0
						temp7 *= 15
						temp6 = -15
						while temp0 < object[arrayPos0].propertyValue
							temp3 = temp4
							temp3 <<= 7
							temp3 /= temp5
							Sin(temp2, temp3)
							temp2 *= object[arrayPos0].value4
							temp2 >>= 9
							temp2 += object[arrayPos0].ypos
							CreateTempObject(TypeName[Burning Log], 0, temp1, temp2)
							object[tempObjectPos].value0 = temp7
							temp7 += temp6
							if temp7 == 15
								FlipSign(temp6)
							end if
							temp1 -= 0x100000
							temp4 += 0x100000
							temp0++
						loop
						object[arrayPos0].type = TypeName[Blank Object]
					end if
				end if
			end if
		end if
	next
end event


event ObjectDraw
	DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone01")
	if checkResult == 1
		LoadSpriteSheet("EHZ/Objects.gif")
		SpriteFrame(-12, -3, 8, 10, 1, 50)
		SpriteFrame(-12, -3, 8, 10, 10, 50)
		SpriteFrame(-8, -8, 16, 24, 110, 19)
	end if
	CheckCurrentStageFolder("ZoneM")
	if checkResult == 1
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-12, -3, 8, 10, 1, 50)
		SpriteFrame(-12, -3, 8, 10, 10, 50)
		SpriteFrame(-8, -8, 16, 24, 110, 19)
	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
