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

//-------Aliases-------//
private alias 61 : TYPE_WATERGEYSER


// Static Values

// Tables

event ObjectMain
	switch object.state
	case 0
		object.value1 = object.ypos
		object.value2 = object.ypos
		object.value2 -= 0x1000000
		object.value3 = object.ypos
		object.value3 -= 0x900000
		if object.propertyValue == 0
			object.state++
		else
			object.value4 = 0xFFFFFF
			object.state = 3
		end if
		object.yvel = -0x100000
		break
	case 1
		object.yvel += 0x3800
		object.ypos += object.yvel
		if object.ypos <= object.value2
			object.ypos = object.value2
			object.state++
		end if
		break
	case 2
		object.yvel += 0x3800
		if object.yvel > 0
			object.ypos += object.yvel
		end if
		if object.ypos >= object.value1
			object.type = TypeName[Blank Object]
		end if
		break
	case 3
		object.yvel += 0x3800
		object.ypos += object.yvel
		foreach (TypeName[B08 Eggman], arrayPos0, ACTIVE_ENTITIES)
			BoxCollisionTest(C_TOUCH, object.entityPos, -14, -18, 14, 18, arrayPos0, -12, -24, 12, 24)
			if checkResult == 1
				object.value2 = object.value3
				object.value4 = arrayPos0
				if object[arrayPos0].state != 13
					object[arrayPos0].state = 10
				end if
			end if
		next
		if object.ypos <= object.value2
			object.ypos = object.value2
			object.state++
		end if
		break
	case 4
		object.yvel += 0x3800
		if object.yvel > 0
			object.ypos += object.yvel
			if object.value4 != 0xFFFFFF
				arrayPos0 = object.value4
				if object[arrayPos0].state != 13
					object[arrayPos0].state = 11
				end if
				object[arrayPos0].yvel = 0
				object[arrayPos0].value13 = 0
				object.value4 = 0xFFFFFF
			end if
		else
			if object.value4 != 0xFFFFFF
				foreach (TypeName[B08 Eggman], arrayPos0, ACTIVE_ENTITIES)
					BoxCollisionTest(C_TOUCH, object.entityPos, -14, -18, 14, 18, arrayPos0, -12, -24, 12, 24)
					if checkResult == 1
						object.value2 = object.value3
						object.value4 = arrayPos0
						if object[arrayPos0].state != 13
							object[arrayPos0].state = 10
						end if
					end if
				next
			end if
		end if
		if object.ypos >= object.value1
			object.type = TypeName[Blank Object]
		end if
		break
	end switch
end event


event ObjectDraw
	temp0 = object.value1
	temp0 -= object.ypos
	temp0 >>= 16
	EditFrame(0, -14, 0, 28, temp0, 484, 0)
	DrawSprite(0)
	DrawSprite(1)
end event


event ObjectStartup
	LoadSpriteSheet("HPZ/Objects.gif")
	SpriteFrame(-14, 0, 28, 256, 484, 256)
	SpriteFrame(-24, -20, 48, 24, 174, 231)
end event

event RSDKDraw
	DrawSprite(0)
end event

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