#include scener
#include input
#include kdsqueststate
#include kds3

export ON_CREATE;
export ON_LBUTTONDOWN;
export ON_COMMAND;
export ON_SETFOCUS;
export ON_KILLFOCUS;

KDS3_WPINFO info;
vec3_t dist;

void ON_CREATE()
{
	 vec3_t v;
	 v.Assign(0, 70.0, 0);
	 info.at(100.0, 0,	-1, 500.0, v);
	 dist.Assign(0.0, -100.0, 0.0);
}

void ON_SETFOCUS()
{
	if (!isItemPicked("SHVABRA"))
	{
		SetKdsCursor(CURSOR_TAKE);
		SetFocusObject(self, "SHVABRA");
	}
}

void ON_KILLFOCUS()
{
	SetKdsCursor(CURSOR_NORMAL);
	SetFocusObject(NULL, "");
}

void ON_LBUTTONDOWN()
{
	 ObjectClick(0, dist, self);
}

void ON_COMMAND(int lparam, int rparam)
{
	 vec3_t v;
	 v.Assign(0, 0, 0);

	if (lparam == EMC_WOODY_QUERY)
	{
		WriteLog("Query action for woody!");

		int* woodyAnimation = (int*)lparam;
		LINK* woody = scene.FindObjectByName("01Hero");

		vec3_t lookForward;
        lookForward.Assign(0.0, 1.0, 0.0);

		PersJob* woodyJob = AddAnimationStackJob(woody);
		AddFreeAnimation(woodyJob, 8, lookForward); // Aha!
		AddFreeAnimation(woodyJob, 6, lookForward); // Берем предмет

		AddEvent(woodyJob, self, 2, 1);
	}

	if (lparam == EMC_EVENT)
	{
		if (rparam == 1)
		{
			if (!isItemPicked("SHVABRA"))
			{
				AddItem("SHVABRA");
				scene.DeleteObject(scene.FindObjectByName("r11_shvabra"));
			}
		}

	}


}




