I'm sure there's a better way than this, but it works:
datablock ShapeBaseImageData(IM_hatHead)
{
shapeFile = "./hat.dts";
emap = true;
mountPoint = $HeadSlot;
offset = "0 0 0";
eyeOffset = "0 0 10 1";
rotation = eulerToMatrix("0 0 0");
scale = "1 1 1";
doColorShift = true;
colorShiftColor = "1 1 0.949 1"; //Color of the hat when worn.
};
datablock ShapeBaseImageData(IM_hatItem)
{
shapeFile = "./hat.dts";
Item = "IT_hatItem";
firstPersonParticles = true;
armReady = true;
mountPoint = 0;
offset = "0 0 0";
rotation = eulerToMatrix("0 0 0");
eyeOffset = "0 0 0 0";
eyeRotation = "0 0 0 0";
doColorShift = true;
colorShiftColor = IM_hatHead.colorShiftColor; //Color of the hat on hand.
stateName[0] = "Active";
stateWaitForTimeout[0] = true;
stateTimeoutValue[0] = 0.03;
stateTransitionOnTriggerDown[0] = "Ready";
stateName[1] = "Ready";
stateAllowImageChange[1] = false;
stateWaitForTimeout[1] = true;
stateTimeoutValue[1] = 0.03;
stateTransitionOnTriggerUp[1] = "Equip";
stateName[2] = "Equip";
stateAllowImageChange[2] = true;
stateScript[2] = "onFire";
stateWaitForTimeout[2] = true;
stateTimeoutValue[2] = 0.03;
stateTransitionOnTimeout[2] = "Ready";
};
datablock ItemData(IT_hatItem)
{
shapeFile = "./hat.dts"; //Hat model, when spawned.
image = "IM_hatItem";
rotate = false;
hatItem = true;
uiName = "Hat Item"; //Hat name.
iconName = "Add-Ons/Weapon_Gun/icon_gun"; //Hat inventory icon.
canDrop = true;
mass = 1;
drag = 0.5;
density = 0.2;
friction = 0.6;
elasticity = 0.2;
gravityMod = 1;
doColorShift = true;
colorShiftColor = IM_hatHead.colorShiftColor; //Color of the hat icon and item when spawned.
};
function IM_hatItem::onFire(%this, %obj, %slot)
{
%client=%obj.client;
if(!%obj.Wear)
{
%obj.Wear = 1;
for(%i = 0;$hat[%i] !$= "";%i++)
{
%obj.hideNode($hat[%i]);
//%obj.hideNode("headskin"); //Hides player's head.
}
%obj.unMountImage(1);
%obj.mountimage(IM_hatHead, 1);
%obj.unMountImage(0);
%obj.mountimage(IM_hatEmpty,0);
%obj.schedule(0,"playThread",2,shiftAway);
%obj.schedule(190,"playThread",1,root);
}
}
datablock ShapeBaseImageData(IM_hatEmpty : IM_HatItem)
{
shapeFile = "base/data/shapes/empty.dts";
};
function IM_hatEmpty::onFire(%this, %obj, %slot)
{
%client=%obj.client;
if(%obj.Wear)
{
%obj.Wear = 0;
%obj.unMountImage(1);
//%obj.unHideNode("headskin"); //Unhides player's head.
%obj.unMountImage(0);
%obj.mountimage(IM_hatItem,0);
%obj.playThread(2, shiftAway);
%obj.playThread(1, armReadyRight);
%client.applyBodyParts();
%client.applyBodyColors();
}
}
function IM_hatItem::onMount(%this, %obj, %slot)
{
if(%obj.Wear)
{
%obj.unMountImage(0);
%obj.mountimage(IM_hatEmpty,0);
}
}
package hatitempackage
{
function serverCmdDropTool(%client,%slot)
{
if(nameToID(%client.player.tool[%slot]).hatItem)
{
if(%client.player.Wear)
{
%client.player.Wear = 0;
%client.player.unMountImage(0);
%client.player.unMountImage(1);
%client.applyBodyParts();
%client.applyBodyColors();
}
}
parent::serverCmdDropTool(%client,%slot);
}
};
activatePackage(hatitempackage);
Packaged serverCmdDropTool to check if the player is wearing the hat (and is dropping the hat item), if so it'll unMount. I also cleaned up a bit, and the colorShiftColor for the spawn item and the item in hand will be the same as the actual hat images colorShiftColor now.
edit: oops had to fix something, sorry