This is the way I did it:
datablock ItemData(IT_SkullHead)
{
category = "Item";
className = "Item";
shapeFile = "./skull.dts";
image = "IM_SkullHead";
rotate = false;
emap = true;
uiName = "Skull Head";
iconName = "Add-Ons/Weapon_Gun/icon_gun";
canDrop = true;
mass = 1;
drag = 0.1;
density = 0.1;
friction = 0.5;
elasticity = 0.1;
sticky = 0;
gravityMod = 1;
maxVelocity = -1;
dynamicType = 0;
doColorShift = false;
colorShiftColor = "0 0 0 0";
};
datablock ShapeBaseImageData(IM_SkullHead)
{
className = "ItemImage";
shapeFile = "./skull.dts";
item = "IT_SkullHead";
emap = true;
firstPersonParticles = true;
armReady = false;
melee = false;
mountPoint = 0;
offset = "0 -0.05 0.1";
rotation = eulerToMatrix("0 0 0");
eyeOffset = "0 0 10 1";
eyeRotation = "0 0 0 0";
correctMuzzleVector = false;
doColorShift = false;
colorShiftColor = "0 0 0 0";
stateName[0] = "Activate";
stateWaitForTimeout[0] = false;
stateTimeoutValue[0] = 0.1;
stateTransitionOnTimeout[0] = "Ready";
stateName[1] = "Ready";
stateAllowImageChange[1] = true;
stateTransitionOnTriggerDown[1] = "Equip";
stateName[2] = "Equip";
stateScript[2] = "onFire";
stateTransitionOnTriggerUp[2] = "Ready";
};
datablock ShapeBaseImageData(IM_SkullHeadEmpty)
{
className = "ItemImage";
shapeFile = "./skull.dts";
item = "IT_SkullHead";
emap = true;
firstPersonParticles = true;
armReady = false;
melee = false;
mountPoint = 0;
offset = "0 -0.05 0.1";
rotation = eulerToMatrix("0 0 0");
eyeOffset = "0 0 10 1";
eyeRotation = "0 0 0 0";
correctMuzzleVector = false;
doColorShift = false;
colorShiftColor = "0 0 0 0";
stateName[0] = "Activate";
stateWaitForTimeout[0] = false;
stateTimeoutValue[0] = 0.1;
stateTransitionOnTimeout[0] = "Ready";
stateName[1] = "Ready";
stateAllowImageChange[1] = true;
stateTransitionOnTriggerDown[1] = "Equip";
stateName[2] = "Equip";
stateScript[2] = "onFire";
stateTransitionOnTriggerUp[2] = "Ready";
};
function IM_SkullHead::onFire(%this, %obj, %slot)
{
%client=%obj.client;
if(!%obj.HatWear)
{
%obj.HatWear = 1;
%client.centerPrint("\c6You put on the hat.",3);
for(%i = 0;$hat[%i] !$= "";%i++)
{
%obj.hideNode($hat[%i]);
}
%obj.unmountimage(1);
%obj.mountimage(SkullHat, 1);
%obj.mountimage(IM_SkullHeadEmpty,0);
}
}
function IM_SkullHeadEmpty::onFire(%this, %obj, %slot)
{
%client=%obj.client;
if(%obj.HatWear)
{
%obj.HatWear = 0;
%client.centerPrint("\c6You took off the hat.",3);
%obj.unmountimage(1);
%obj.mountImage(IM_SkullHead,0);
%client.applyBodyParts();
%client.applyBodyColors();
}
}
function IM_SkullHead::onMount(%this,%obj,%slot)
{
if(%obj.HatWear)
{
%obj.unMountImage(0);
%obj.mountImage(IM_SkullHeadEmpty,0);
}
}
datablock ShapeBaseImageData(SkullHat)
{
shapeFile = "./skull.dts";
emap = true;
mountPoint = $HeadSlot;
offset = "0 -0.05 0.1";
eyeOffset = "0 0 10 1";
rotation = eulerToMatrix("0 0 0");
scale = "1 1 1";
doColorShift = false;
colorShiftColor = "0.392 0.196 0.0 1.000";
};
The only problem is holding down your mouse button will constantly change your hat. I'm sure this is because of how the states are set up, but I have a hard time understanding those.
edit: oops, forgot to change one of the shapefiles back since I was testing it on another model.