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

// ========================
// Aliases
// ========================

private alias 0 : BOSSROCK_TYPE_PEBBLE
private alias 1 : BOSSROCK_TYPE_STALACTITE


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

event ObjectUpdate
	if object.propertyValue == BOSSROCK_TYPE_STALACTITE
		// Object is one of the sharp stalactites, so check for collision with players
		foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
			BoxCollisionTest(C_TOUCH, object.entityPos, -4, -12, 4, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)

			if checkResult == true
				CallFunction(Player_ProjectileHit)
			end if
		next
	end if

	object.ypos += object.yvel
	object.yvel += 0x1800

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


event ObjectDraw
	DrawSprite(object.propertyValue)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone06") // In Mystic Cave Zone?
	if checkResult == true
		// Load the Mystic Cave sprites
		LoadSpriteSheet("MCZ/Objects.gif")
		SpriteFrame(-8, -8,  16, 16, 184, 115) // 0 - Pebble Frame
		SpriteFrame(-4, -16,  8, 32, 131, 164) // 1 - Stalactite Frame
	else
		// In Egg Gauntlet Zone, load the EGZ/"MBZ" sprites
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-8, -8,  16, 16, 100, 174)
		SpriteFrame(-4, -16,  8, 32,  34, 191)
	end if
end event


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

event RSDKDraw
	DrawSprite(object.propertyValue)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone06") // In Mystic Cave Zone?
	if checkResult == true
		// Load the Mystic Cave sprites
		LoadSpriteSheet("MCZ/Objects.gif")
		SpriteFrame(-8, -8,  16, 16, 184, 115) // 0 - Pebble Frame
		SpriteFrame(-4, -16,  8, 32, 131, 164) // 1 - Stalactite Frame
	else
		// In Egg Gauntlet Zone, load the EGZ sprites
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-8, -8,  16, 16, 100, 174)
		SpriteFrame(-4, -16,  8, 32,  34, 191)
	end if 				            				  		 
	
	// although used by the object, this object shouldn't be placed in a scene at all
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
