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

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

private alias 1 : BODYPART_DESTROYED


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

event ObjectUpdate
	if object.state == BODYPART_DESTROYED
		object.xpos += object.xvel
		object.ypos += object.yvel
		object.yvel += 0x3800

		if object.outOfBounds == true
			object.type = TypeName[Blank Object]
		end if
	else
		// Follow the main Death Egg Robot object
		object.xpos = object[-5].xpos
		if object.direction == FLIP_NONE
			object.xpos += 0xC0000
		else
			object.xpos -= 0xC0000
		end if

		object.ypos = object[-5].ypos
		object.ypos -= 0x140000
	end if
end event


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


event ObjectStartup
	CheckCurrentStageFolder("Zone12")
	if checkResult == true
		LoadSpriteSheet("DEZ/Objects.gif")
		SpriteFrame(-16, -16, 32, 30, 356, 123)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-16, -16, 32, 30, 868, 123)
	end if
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone12")
	if checkResult == true
		LoadSpriteSheet("DEZ/Objects.gif")
		SpriteFrame(-16, -16, 32, 30, 356, 123)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-16, -16, 32, 30, 868, 123)
	end if

	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
