function gunImage::onFire(%db,%pl,%slot)
{
%up = %pl.getUpVector();
%muzVec = %pl.getMuzzleVector(%slot);
%forward = %pl.getForwardVector();
%muzPoint = %pl.getMuzzlePoint(%slot);
%rightVec = vectorCross(%forward,%up);
%upHack = %pl.getUpVectorHack();
%proj_or[0] = 0.2 SPC %rightVec;
%proj_or[1] = -0.2 SPC %rightVec;
%proj_or[2] = 0.2 SPC %upHack;
%proj_or[3] = -0.2 SPC %upHack;
for(%i=0;%i<4;%i++)
{
%ang = getWord(%proj_or[%i],0);
%axis = getWords(%proj_or[%i],1,3);
%vec = vectorAngleRotate(%muzVec,%axis,%ang);
%p = new (%db.projectileType)()
{
dataBlock = %db.projectile;
initialVelocity = vectorScale(%vec,60);
initialPosition = %muzPoint;
sourceObject = %pl;
sourceSlot = %slot;
client = %pl.client;
};
MissionCleanup.add(%p);
}
}
function vectorAngleRotate(%vec,%axis,%ang)
{
%x = getWord(%vec,0);
%y = getWord(%vec,1);
%z = getWord(%vec,2);
%u = getWord(%axis,0);
%v = getWord(%axis,1);
%w = getWord(%axis,2);
%cos = mCos(%ang);
%sin = mSin(%ang);
return %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%x*%cos+(%v*%z-%w*%y)*%sin SPC %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%y*%cos+(%w*%x-%u*%z)*%sin SPC %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%z*%cos+(%u*%y-%v*%x)*%sin;
}
function player::getUpVectorHack(%pl)
{
%muz = %pl.getMuzzleVector(0);
%forward = %pl.getForwardVector();
%up = %pl.getUpVector();
return vectorAngleRotate(%muz,vectorCross(%forward,%up),$PI/2);
}
heres a vector rotate function which amade did all the work for
input the base vector, the upwards orientation, and the angle
getUpVectorHack is a vector that actually represents the players eye point rotated 90 degrees upwards
the code for the gun fires 4 projectiles all rotated 0.2 radians to the left/right and up/down