I have no clue either. The whole armor on trigger thing is really annoying, calling it when it is released, holding it down, not holding it down, it's really stupid that you have to go to great lengths to perform simple tasks. I ripped code out of shootonclick, which I dislike using due to it not mounting emitters and not shooting accurately. But at least shoot on click can actually loop.
$TP::Version=1.1; //Version number, do NOT change this unless you know what you are doing.
if($Support::ShootonclickB<$Prop::Version) {return;} //Newer version already loaded.
$Support::ShootonclickB=$TP::Version;
package ShootonclickB_Pack
{
function armor::onTrigger(%db,%obj,%slot,%val)
{
if(%obj.getClassName()$="Player")
{
if(%slot $= 0)
{
if(%val)
{
if($Sim::Time<%obj.client.SOCB_LastFireTime)
{
return;
}
}
%obj.SOCB_Shoot(%slot,%val);
}
}
return Parent::onTrigger(%db,%obj,%slot,%val);
}
};
ActivatePackage(ShootonclickB_Pack);
function repeatedVectorAddwithScale(%vecs)
{
%vec="0 0 0";
%cnt=getFieldCount(%vecs);
for(%i=0;%i<%cnt;%i++)
{
%fld=getField(%vecs,%i);
%tvec=getWords(%fld,0,3);
%scale=getWord(%fld,3);
%svec=vectorScale(%tvec,%scale);
%vec=vectorAdd(%vec,%svec);
}
return %vec;
}
function SimObject::getLeftVector(%obj)
{
return vectorCross(%obj.getEyeVector(),%obj.getUpVector());
}
function SimObject::getRightVector(%obj)
{
return vectorScale(%obj.getLeftVector(%obj),-1);
}
function Player::SOCB_Shoot(%obj,%slot,%val)
{
if(!%val) {cancel(%obj.SOCB_reshoot);return;}
%mnt= %obj.getObjectMount();
if(!isObject(%mnt))
{
return;
}
%data= %mnt.getDatablock();
%mountObj= %mnt.getMountNodeObject(%data.ShootonclickB_RequiredSlot);
if(%mountObj!$=%Obj) {return;}
if(%data.ShootonclickB)
{
//Checks OK, shoot it all.
%cnt=%data.ShootonclickB_ProjectileCount;
for(%i=0;%i<%cnt;%i++)
{
%pos= %mnt.getPosition();
%PVec= %data.ShootonclickB_Position[%i];
%VVec= %data.ShootonclickB_Velocity[%i];
%iPos= repeatedVectorAddwithScale(
%mnt.getEyeVector() SPC getWord(%PVec,0) TAB
%mnt.getLeftVector() SPC getWord(%PVec,1) TAB
%mnt.getUpVector() SPC getWord(%PVec,2)
);
%iVel= repeatedVectorAddwithScale(
%mnt.getEyeVector() SPC getWord(%VVec,0) TAB
%mnt.getLeftVector() SPC getWord(%VVec,1) TAB
%mnt.getUpVector() SPC getWord(%VVec,2)
);
%scale=%data.ShootonclickB_Scale[%i];
if(%scale$="") {%scale="1 1 1";}
%p= new Projectile()
{
dataBlock= %data.ShootonclickB_Projectile[%i];
initialPosition= vectorAdd(%pos,%iPos);
initialVelocity= %iVel;
sourceObject= %obj;
client= %obj.client;
sourceSlot= %slot;
scale= %scale;
};missionCleanup.add(%p);
}
serverPlay3d(%data.ShootonclickB_Sound,%pos);
//If hold, schedule.
if(%data.ShootonclickB_Hold)
{
//Delay according to datablocks.
%obj.SOCB_reshoot= %obj.schedule(%data.ShootonclickB_ReshootDelay,SOCB_Shoot,%slot,%val);
}
%obj.client.SOCB_LastFireTime=$Sim::Time+%data.ShootonclickB_ShootDelay/1000;
}
}