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

//-------Aliases-------//
private alias 19 : TYPE_DUSTPUFF

private alias object.value0 : object.timer2
private alias object.value1 : object.timer1
private alias object.value2 : object.xposAssist

public value DustMove = 0;

// Static Values

// Tables

event ObjectMain
	if object.propertyvalue == 5
		object.value1++
		if object.value1 > 2
			object.value0++ 
			object.value1 = 0
		end if
			
		if object.value0 == 8
			object.type = TypeName[Blank Object]
		end if
		
		//object.xpos += object.value2
		ObjectTileGrip(0, 0, 0, object[currentPlayer].CollisionPlane)
		if CheckResult == 0
			ObjectTileGrip(0, 0, 8, object[currentPlayer].CollisionPlane)
			if CheckResult != 0
				object.ypos += 524288
			end if
		end if
	else
		object.xpos += object.xvel
		object.ypos += object.yvel
		switch object.frame
		case 0
		case 1
		case 2
			object.animationTimer++
			if object.animationTimer > 3
				object.frame++
				object.animationTimer = 0
			end if
			break
		case 3
			object.animationTimer++
			if object.animationTimer > 3
				object.type = TypeName[Blank Object]
			end if
			break
		case 4
		case 5
		case 6
		case 7
		case 8
		case 9
			object.animationTimer++
			if object.animationTimer > 1
				object.frame++
				object.animationTimer = 0
			end if
			break
		case 10
			object.animationTimer++
			if object.animationTimer > 1
				object.frame = 4
				object.animationTimer = 0
			end if
			break
		case 11
		case 12
		case 13
		case 14
		case 15
		case 16
		case 17
			object.animationTimer++
			if object.animationTimer > 3
				object.frame++
				object.animationTimer = 0
			end if
			break
		case 18
			object.animationTimer++
			if object.animationTimer > 3
				object.type = TypeName[Blank Object]
			end if
		end switch
	end if
end event


event ObjectDraw
	if object.propertyvalue == 5
		if object.value0 != 10
			temp0 = object.value0
			temp0 += 0
			temp0 /= 2			
			object.value3 += 0x10000			
			DrawSpriteFX(temp0, FX_FLIP, object.value3, object.ypos)
	
			object.value4 += 0x18000			
			DrawSpriteFX(temp0, FX_FLIP, object.value4, object.ypos)
		
			object.value5 += 0x20000			
			DrawSpriteFX(temp0, FX_FLIP, object.value5, object.ypos)
			
			object.value6 -= 0x10000			
			DrawSpriteFX(temp0, FX_FLIP, object.value6, object.ypos)
	
			object.value7 -= 0x18000			
			DrawSpriteFX(temp0, FX_FLIP, object.value7, object.ypos)
		
			object.value8 -= 0x20000			
			DrawSpriteFX(temp0, FX_FLIP, object.value8, object.ypos)
			
		end if
	else
		switch object.frame
		case 4
		case 5
		case 6
		case 7
		case 8
		case 9
		case 10
			currentPlayer = object.propertyValue
			object.direction = object[currentPlayer].direction
			object.xpos = object[currentPlayer].xpos
			object.iypos = object[currentPlayer].collisionBottom
			object.ypos += object[currentPlayer].ypos
			if object[currentPlayer].animation != ANI_SPINDASH
				object.type = TypeName[Blank Object]
			else
				DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
			end if
			break
		default
			DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
			break
		end switch
	end if
end event


event ObjectStartup
	LoadSpriteSheet("Global/KnuxGreyShield.gif")
	SpriteFrame(-7, -11, 13, 14, 138, 1)
	SpriteFrame(-7, -11, 13, 14, 152, 1)
	SpriteFrame(-6, -11, 13, 14, 166, 1)
	SpriteFrame(-7, -11, 13, 14, 180, 1)
	
	SpriteFrame(-32, -10, 32, 10, 138, 16)
	SpriteFrame(-32, -12, 32, 12, 171, 16)
	SpriteFrame(-32, -16, 32, 16, 171, 29)
	SpriteFrame(-32, -18, 32, 18, 138, 27)
	SpriteFrame(-32, -20, 32, 20, 118, 46)
	SpriteFrame(-32, -21, 32, 21, 151, 46)
	SpriteFrame(-32, -23, 32, 23, 184, 46)
	
	SpriteFrame(-19, -9, 19, 9, 1, 1)
	SpriteFrame(-23, -16, 20, 16, 21, 1)
	SpriteFrame(-25, -19, 21, 19, 42, 1)
	SpriteFrame(-24, -20, 22, 20, 64, 1)
	SpriteFrame(-25, -21, 24, 21, 87, 1)
	SpriteFrame(-24, -26, 24, 26, 112, 1) 
	SpriteFrame(-22, -24, 25, 21, 59, 22)
	SpriteFrame(-18, -20, 22, 18, 62, 44)
end event

event RSDKDraw
	DrawSprite(0)
end event

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