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

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

private alias object.value0 : object.timer

private alias -1 : DRAWORDER_PLAYER

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

// Super States
private alias 1 : SUPERSTATE_SUPER


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

event ObjectUpdate
	object.drawOrder = DRAWORDER_PLAYER

	// Dead player 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, 190, 50)  // 0
	SpriteFrame(-16, -16, 32, 32, 223, 50)  // 1
	SpriteFrame(-16, -16, 32, 32, 190, 83)  // 2
	SpriteFrame(-16, -16, 32, 32, 223, 83)  // 3
	SpriteFrame(-16, -16, 32, 32, 190, 116) // 4
	SpriteFrame(-24, -24, 48, 48, 151, 1) 	// Center circle
end event


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

event RSDKDraw
	DrawSprite(0)
end event


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