lordician, you could base your sapper on this if you want.
(copied from Weapon_ElectroSapper.cs from the Gamemode_BlockBastion project)
datablock itemData(tf2_sapperItem)
{
category = "item";
equipment = true;
uiName = "Electro Sapper";
iconName = "base/client/ui/avatarIcons/accent/visor";
doColorShift = true;
colorShiftColor = "0.3 0.3 0.3 1";
shapeFile = "base/data/shapes/brickWeapon.dts";
emap = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
image = tf2_sapperImage;
canDrop = true;
};
datablock shapeBaseImageData(tf2_sapperImage)
{
className = "weaponImage";
item = tf2_sapperItem;
shapeFile = tf2_sapperItem.shapeFile;
emap = tf2_sapperItem.emap;
doColorShift = tf2_sapperItem.doColorShift;
colorShiftColor = tf2_sapperItem.colorShiftColor;
mountPoint = 0;
offset = "0 -0.05 0";
rotation = "0 1 0 180";
eyeOffset = "0.7 1.2 -0.8";
eyeRotation = "0 1 0 180";
correctMuzzleVector = false;
melee = true;
armReady = true;
stateName[0] = "activate";
stateTimeoutValue[0] = 0.5;
stateTransitionOnTimeout[0] = "ready";
stateName[1] = "ready";
stateTransitionOnTriggerDown[1] = "fire";
stateAllowImageChange[1] = true;
stateName[2] = "fire";
stateTransitionOnTriggerUp[2] = "ready";
stateScript[2] = "onFire";
};
function tf2_sapperImage::onFire(%this,%obj,%slot)
{
if(!isObject(%cl = %obj.client))
return;
if(!isObject(%pl = %cl.player))
return;
%l=VectorAdd(%pl.getEyePoint(), VectorScale(%pl.getEyeVector(),10));
%raycast=containerRaycast(%pl.getEyePoint(), %l, $TypeMasks::PlayerObjectType, %pl);
if(!isObject(%build = firstWord(%raycast)))
return;
if(!isObject(%build.sentryOwner))
return;
if(%build.beingSapped)
return;
if(%build.bb_team !$= %cl.bb_team)
%build.startSap(%cl);
}
function SimObject::startSap(%this,%cl)
{
if(strLen(%this.dataBlock) && %this.dataBlock $= "playerSentryBottom")
%obj = %this.sentryTop;
else
%obj = %this;
if(%obj.beingSapped)
return;
%obj.beingSapped = true;
%obj.spySapping = %cl;
%obj.sapperHealth = 2;
if(%obj.dataBlock $= "playerSentryTop")
serverCmdMessageSent(%obj.sentryOwner @ "VOICE","\c6Spy sappin' my sentry!");
else
serverCmdMessageSent(%obj.owner @ "VOICE","\c6Spy sappin' my "@strLwr(%obj.bb_type)@"!");
%obj.schedule(500,sapTick);
}
function SimObject::stopSap(%this)
{
cancel(%this.sapTick);
%this.beingSapped = false;
%this.sapperHealth = 0;
}
function SimObject::sapTick(%this)
{
cancel(%this.sapTick);
if(!%this.beingSapped)
return;
%this.addHealth(-25);
%this.sapTick = %this.schedule(1000,sapTick);
}