datablock ShapeBaseImageData(MedicineImage) {
	shapeFile = $SMM::Path @ "res/shapes/suitcase.dts";

	item = MedicineItem;
	armReady = true;
	armReadyBoth = true;

	stateName[0]					= "Activate";
	stateTimeoutValue[0]			= 0.01;
	stateTransitionOnTimeout[0]		= "Ready";

	stateName[1] = "Ready";
	stateAllowImageChange[1] = true;
	stateTransitionOnTriggerDown[1] = "Use";

	stateName[2] = "Use";
	stateScript[2] = "onUse";
	stateAllowImageChange[2] = false;
	stateTransitionOnTriggerUp[2] = "Ready";
};

datablock ItemData(MedicineItem) {
	image = MedicineImage;
	shapeFile = $SMM::Path @ "res/shapes/suitcase.dts";

	uiName = "Medicine";
	canDrop = true;

	mass = 1;
	density = 0.2;
	elasticity = 0.2;
	friction = 0.6;
	emap = true;
};

function MedicineImage::onMount(%this, %obj, %slot) {
	%obj.playThread(1, "armReadyBoth");
}

function MedicineImage::onUnMount(%this, %obj, %slot) {
	%obj.schedule(0, animCheck, %slot);
}

function MedicineImage::onUse(%this, %obj, %slot) {
	if (!isObject(%obj.client)) {
		return;
	}

	%eyePoint = %obj.getEyePoint();
	%eyeVector = %obj.getEyeVector();

	%ray = containerRayCast(%eyePoint,
		vectorAdd(%eyePoint, vectorScale(%eyeVector, 6)),
		$TypeMasks::PlayerObjectType | $TypeMasks::FxBrickObjectType,
		%obj
	);

	%col = getWord(%ray, 0);

	if (!isObject(%col) || !%col.isCorpse || !isObject(%col.originalClient)) {
		%obj.client.centerPrint("\c6Click on an unconscious player with Medicine to revive them.", 2);
		return;
	}

	if (!%col.isUnconscious) {
		%obj.client.centerPrint("\c6They're dead; there is no hope.", 2);
		return;
	}

	%corpseClient = %col.originalClient;
	%col.reviveCorpse();

	%obj.client.centerPrint("\c6You have revived \c3" @ %corpseClient.getSMMName() @ "\c6.", 3);
	%corpseClient.centerPrint("\c6You have been revived by \c3" @ %obj.client.getSMMName() @ "\c6.", 3);
}