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

// ========================
// Events
// ========================

event ObjectUpdate
	object.xpos += object.xvel

	object.frame = object.animationTimer
	object.frame >>= 2
	object.animationTimer++
	if object.animationTimer >= 32
		object.animationTimer = 0
	end if

	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_TOUCH, object.entityPos, -4, -4, 4, 4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
		if checkResult == true
			CallFunction(Player_ProjectileHit)
		end if
	next

	if object.outOfBounds == true
		object.type = TypeName[Blank Object]
	end if
end event


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


event ObjectStartup
	CheckCurrentStageFolder("Zone11")
	if checkResult == true
		LoadSpriteSheet("SCZ/Objects.gif")
		
		SpriteFrame(-3, -4, 6, 8, 50, 214)
		SpriteFrame(-4, -4, 7, 7, 57, 215)
		SpriteFrame(-4, -3, 8, 6, 65, 216)
		SpriteFrame(-4, -3, 7, 7, 74, 215)
		SpriteFrame(-3, -4, 6, 8, 82, 214)
		SpriteFrame(-3, -3, 7, 7, 89, 215)
		SpriteFrame(-4, -3, 8, 6, 97, 216)
		SpriteFrame(-3, -4, 7, 7, 106, 215)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		
		SpriteFrame(-3, -4, 6, 8, 660, 289)
		SpriteFrame(-4, -4, 7, 7, 659, 298)
		SpriteFrame(-4, -3, 8, 6, 658, 306)
		SpriteFrame(-4, -3, 7, 7, 659, 313)
		SpriteFrame(-3, -4, 6, 8, 660, 321)
		SpriteFrame(-3, -3, 7, 7, 659, 330)
		SpriteFrame(-4, -3, 8, 6, 658, 338)
		SpriteFrame(-3, -4, 7, 7, 659, 345)
	end if
end event


// ========================
// Editor Events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone11")
	if checkResult == true
		LoadSpriteSheet("SCZ/Objects.gif")
		SpriteFrame(-3, -4, 6, 8, 50, 214)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-3, -4, 6, 8, 660, 289)
	end if
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
