Author Topic: Tank edit: Spread on Tank shot  (Read 2343 times)

Code: [Select]
%theVector = %mount.getEyeVector();
Yes, you leave that alone. After the final setting of %theVector, enter this line:
Code: [Select]
%theVector = vectorAdd(%theVector, getRandom(-15, 15) SPC getRandom(-15, 15) SPC getRandom(-15, 15));That should create a spread.

Yes, you leave that alone. After the final setting of %theVector, enter this line:
Code: [Select]
%theVector = vectorAdd(%theVector, getRandom(-15, 15) SPC getRandom(-15, 15) SPC getRandom(-15, 15));That should create a spread.
K,
Also, how would I loop this to make it so when you hold down, it keeps shooting.
Code: [Select]
function armor::onTrigger(%this, %obj, %triggerNum, %val)
   {
      %mount = %obj.getObjectMount();
      if(isObject(%mount))
      {
         if(%mount.getDataBlock() == CrocodileTurretPlayer.getId() && %triggerNum == 0 && %val)
         {
            %client = %obj.client;
            if(isObject(%client))
               ServerCmdUnUseTool(%client);

            if(getSimTime() - %obj.lastShotTime < 30)
               return;
           
            %scaleFactor = getWord(%mount.getScale(), 2);
            %p = new Projectile()
            {
               dataBlock = CrocodileProjectile;
               initialPosition = vectorAdd(%mount.getEyeTransform(),vectorScale(%mount.getEyeVector(),3));
               initialVelocity = vectorScale(%mount.getEyeVector(),140 * %scaleFactor);
               sourceObject = %obj;
               client = %obj.client;
               sourceSlot = 0;
               originPoint = vectorAdd(%mount.getEyeTransform(),vectorScale(%mount.getEyeVector(),3));
            };
            MissionCleanup.add(%p);
            %p.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);


           

            %theVector = %mount.getEyeVector();
            %theVector = vectorAdd(%theVector,"0 0 1");
            %theVector = vectorScale(%theVector,%mount.getObjectMount().dataBlock.mass*5);
            %theVector = vectorSub(%theVector,vectorScale(%thevector,2));
            %mount.getObjectMount().applyImpulse(getWords(%mount.getEyeTransform(),0,2),%theVector);
           
            %obj.playThread(0,activate);
            %obj.lastShotTime = getSimTime();

            return;
         }
      }
     
      Parent::onTrigger(%this,%obj,%triggerNum,%val);
   }

Edit: What about firing from the mount1 instead of from the eye point?


also, it doesn't spread.
Code: [Select]
function armor::onTrigger(%this, %obj, %triggerNum, %val)
   {
      %mount = %obj.getObjectMount();
      if(isObject(%mount))
      {
         if(%mount.getDataBlock() == CrocodileTurretPlayer.getId() && %triggerNum == 0 && %val)
         {
            %client = %obj.client;
            if(isObject(%client))
               ServerCmdUnUseTool(%client);

            if(getSimTime() - %obj.lastShotTime < 30)
               return;
           
            %scaleFactor = getWord(%mount.getScale(), 2);
            %p = new Projectile()
            {
               dataBlock = CrocodileProjectile;
               initialPosition = vectorAdd(%mount.getEyeTransform(),vectorScale(%mount.getEyeVector(),3));
               initialVelocity = vectorScale(%mount.getEyeVector(),140 * %scaleFactor);
               sourceObject = %obj;
               client = %obj.client;
               sourceSlot = 0;
               originPoint = vectorAdd(%mount.getEyeTransform(),vectorScale(%mount.getEyeVector(),3));
            };
            MissionCleanup.add(%p);
            %p.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);


           

            %theVector = %mount.getEyeVector();
            %theVector = vectorAdd(%theVector,"0 0 1");
            %theVector = vectorScale(%theVector,%mount.getObjectMount().dataBlock.mass*5);
            %theVector = vectorSub(%theVector,vectorScale(%thevector,2));
            %theVector = vectorAdd(%theVector, getRandom(-15, 15) SPC getRandom(-15, 15) SPC getRandom(-15, 15));
            %mount.getObjectMount().applyImpulse(getWords(%mount.getEyeTransform(),0,2),%theVector);
           
            %obj.playThread(0,activate);
            %obj.lastShotTime = getSimTime();

            return;
         }
      }
     
      Parent::onTrigger(%this,%obj,%triggerNum,%val);
   }

You're adding random spread to the recoil on the vehicle, not the shell.

You're adding random spread to the recoil on the vehicle, not the shell.
Where would I put it 0_o


Well, what have you tried? People spoon-feeding you all the answers will not teach you at all.

Well, what have you tried? People spoon-feeding you all the answers will not teach you at all.
I know you have to put it under
Code: [Select]
%p = new Projectile()
{
//goes here somewhere
}
but I do not know how to format it.
You would probably have to edit
Code: [Select]
initialVelocity = vectorScale(%mount.getEyeVector(),140 * %scaleFactor);since that is the velocity of it shooting, but this is vectors, not shooting.

A vector is a direction and a magnitude.
The velocity is a direction and a magnitude.

I know what I have to do I just can't figure out how I would convert it.