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


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

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


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

event ObjectUpdate
	object.xpos += object.xvel
	object.ypos += object.yvel
	
	// Check collision with players
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		if player[currentPlayer].state != Player_State_Static
			BoxCollisionTest(C_TOUCH, object.entityPos, -4, -4, 4, 4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)

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

	// Animate the object
	object.frame = object.animationTimer
	object.frame /= 3
	object.animationTimer++
	if object.animationTimer >= 6
		object.animationTimer = 0
	end if

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


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


event ObjectStartup
	CheckCurrentStageFolder("Zone07")
	if checkResult == true
		LoadSpriteSheet("OOZ/Objects.gif")
		SpriteFrame(-3, -3, 6, 6, 92, 32)
		SpriteFrame(-4, -4, 8, 8, 92, 39)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-3, -3, 6, 6, 910, 332)
		SpriteFrame(-4, -4, 8, 8, 910, 323)
	end if
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone07")
	if checkResult == true
		LoadSpriteSheet("OOZ/Objects.gif")
		SpriteFrame(-3, -3, 6, 6, 92, 32)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-3, -3, 6, 6, 910, 332)
	end if

	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
