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

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

private alias object.value0 : object.timer

// Player Aliases
private alias object.state : player.state
private alias object.xpos : player.xpos
private alias object.ypos : player.ypos

private alias -1 : DRAWORDER_PLAYER

// Super States
private alias 1 : SUPERSTATE_SUPER


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

event ObjectUpdate
	object.drawOrder = DRAWORDER_PLAYER

	// Dead players shouldn't have any shields
	if player[-playerCount].state == Player_State_Death
		object.type = TypeName[Blank Object]
	end if

	// No shields here, either
	if player[-playerCount].state == Player_State_Drown
		object.type = TypeName[Blank Object]
	end if

	// Update the object's animation
	object.frame = object.timer
	object.frame >>= 1
	
	object.timer++
	object.timer %= 10
end event


event ObjectDraw
	// Super characters shouldn't have shields
	if Player_superState != SUPERSTATE_SUPER
		DrawSpriteFX(object.frame, FX_INK, player[-playerCount].xpos, player[-playerCount].ypos)
		DrawSpriteFX(5,            FX_INK, player[-playerCount].xpos, player[-playerCount].ypos)
	end if
end event


event ObjectStartup
	LoadSpriteSheet("Global/Items.gif")

	// Shield frames
	SpriteFrame(-16, -16, 32, 32, 18, 34)  // 0
	SpriteFrame(-16, -16, 32, 32, 18, 67)  // 1
	SpriteFrame(-16, -16, 32, 32, 85, 27)  // 2
	SpriteFrame(-16, -16, 32, 32, 85, 60)  // 3
	SpriteFrame(-16, -16, 32, 32, 85, 93)  // 4
	SpriteFrame(-24, -24, 48, 48, 35, 117) // Center circle thing that always gets drawn
end event


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

event RSDKDraw
	DrawSprite(0)
	DrawSprite(1)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Items.gif")
	SpriteFrame(-16, -16, 32, 32, 18, 34)
	SpriteFrame(-24, -24, 48, 48, 35, 117)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
