// ----------------------------------
// RSDK Project: Sonic 1
// Script Description: Blue Shield 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 player shouldn't have any shield
	if player[-playerCount].state == Player_State_Death
		object.type = TypeName[Blank Object]
	end if

	// Drowned player shouldn't have any shield, either
	if player[-playerCount].state == Player_State_Drown
		object.type = TypeName[Blank Object]
	end if

	// Update the object's animation
	object.timer++
	if object.timer == 2
		object.timer = 0
		object.frame++
		if object.frame > 5
			object.frame = 0
		end if
	end if
end event


event ObjectDraw
	// Super characters shouldn't have shields
	// Object isn't just erased in case the player untransforms
	if Player_superState != SUPERSTATE_SUPER
		DrawSpriteFX(object.frame, FX_INK, player[-playerCount].xpos, player[-playerCount].ypos)
	end if
end event


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

	// Shield frames
	SpriteFrame(-24, -24, 48, 48, 109, 196)
	SpriteFrame(0, 0, 0, 0, 109, 196)
	SpriteFrame(-24, -24, 48, 48, 158, 196)
	SpriteFrame(0, 0, 0, 0, 109, 196)
	SpriteFrame(-24, -24, 48, 48, 207, 196)
	SpriteFrame(0, 0, 0, 0, 109, 196)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Items2.gif")
	SpriteFrame(-24, -24, 48, 48, 109, 196)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
