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

Doesn't spread. Someone help?


Look at Ephialtes' Shotgun.

Look at Ephialtes' Shotgun.
That is where I got the spread code.

Look at lines 729-821 and make sure that you're changing the names of the variables in your coding, not just copying and pasting.

Look at lines 729-821 and make sure that you're changing the names of the variables in your coding, not just copying and pasting.
I think the problem is that there is no muzzlevector on the tank, what would I fix?

I think the problem is that there is no muzzlevector on the tank, what would I fix?
The turret is a bot, it does have a muzzlevector.

The turret is a bot, it does have a muzzlevector.
Still don't see what is wrong. The image is called when the armortrigger is set, then I call in another projectile for now. So it fires two projectiles.

Still don't see what is wrong. The image is called when the armortrigger is set, then I call in another projectile for now. So it fires two projectiles.
Get a clean copy of the tank script and edit lines 729-821.

I cannot view lines in notepad D:

Is it this?
Code: [Select]
   function armor::onTrigger(%this, %obj, %triggerNum, %val)
   {
      %mount = %obj.getObjectMount();
      if(isObject(%mount))
      {
         if(%mount.getDataBlock() == TankTurretPlayer.getId() && %triggerNum == 0 && %val)
         {
            %client = %obj.client;
            if(isObject(%client))
               ServerCmdUnUseTool(%client);

            if(getSimTime() - %obj.lastShotTime < 2500)
               return;
           
            %scaleFactor = getWord(%mount.getScale(), 2);
            %p = new Projectile()
            {
               dataBlock = tankShellProjectile;
               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);

            %mount.mountImage(TankSmokeImage,1);

            serverPlay3D(TankshotSound,%obj.getPosition());

            %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);
   }

I cannot view lines in notepad D:

Ctrl+G is the go to option in notepad, just enter the line number.

I know it is the armor ontrigger line but I have no clue how to change it since it uses get eye points and spread uses muzzle vectors.

I know it is the armor ontrigger line but I have no clue how to change it since it uses get eye points and spread uses muzzle vectors.
Change muzzle vectors to eye vectors. Although, you wouldn't need to, as the muzzle and eye vectors are identical in slots without weapons.

Change muzzle vectors to eye vectors. Although, you wouldn't need to, as the muzzle and eye vectors are identical in slots without weapons.
You mean change the eye vectors to muzzle ones.?

Edit: I am still completely lost. They are not the same looking to me. I would change
Code: [Select]
%theVector = %mount.getEyeVector();to what? In the spread code there are 3 vectors, none which look like this at all.
« Last Edit: November 05, 2009, 08:53:55 AM by heedicalking »

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?