Author Topic: Set look limits breaking turret  (Read 747 times)

Code: [Select]
   function armor::onMount(%this,%obj,%col,%slot)
   {
      Parent::onMount(%this,%obj,%col,%slot);
      if(%col.getDataBlock() == HumveeGVehicle.getId())
      {
         if(%slot $= 4)
         {
    echo("Placeholder");
            //%obj.setLookLimits(1,0);
         }



      }
      else if(%col.getDataBlock() == HumveeGTurretPlayer.getId())
      {
         %client = %obj.client;
         if(isObject(%client))
            ServerCmdUnUseTool(%client);
      }
   }

Code: [Select]
function HumveeFire(%this, %obj, %triggerNum, %val,%mount)
{
   %mount = %obj.getObjectMount();
   %client = %obj.client;
   if(isObject(%client))
      ServerCmdUnUseTool(%client);

   if(getSimTime() - %obj.lastShotTime < 2500)
      return;

   %scaleFactor = getWord(%mount.getScale(), 2);
   %p = new Projectile()
   {
      dataBlock       = HumveeGrenadeProjectile;
      initialPosition = %mount.getEyeTransform();
      initialVelocity = vectorScale(%mount.getMuzzleVector(0), %mount.shotpower * 5.5 * %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);


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

   %obj.lastShotTime = getSimTime();
}

function HumveeStrengthLoop(%obj)
{
cancel(%obj.stsched);

%obj.ShotPower += 1;
   
   %client = %obj.getControllingClient();
   if(isObject(%client))
      bottomprintHumveeStrength(%client, %obj.shotpower);

if(%obj.ShotPower >= 10)
return;

%obj.stsched = schedule(200, %obj, Humveestrengthloop, %obj);


}

function bottomprintHumveeStrength(%client, %amount)
{
   %per = %amount * 2;
   %maxcounters = 20;
   %foo = %maxcounters - %per;
   %char = "|";for(%a =0; %a<%per; %a++){%fchar = %char @ %fchar;}
   %char2 = "|";for(%b =0; %b<%foo; %b++){%ftchar = %char2 @ %ftchar;}
   bottomprint(%client, "<just:center><color:FF0000>Power <color:FFFFFF>:<color:FFFF00>" @ %fchar @ "<color:000000>" @%ftchar, 1, 1);
}
The problem is that the turret looks up and down fine, but fires from the same point.

If I look up, the turret will still fire straight out.
When the look limits are commented, the turret moves up and down barely, a little less than the pirate cannon's aim, but shoots good.

When I uncomment the setlooklimits, it moves up and down, but fires like it can only move a tiny bit up and down. Sort of like invisible paramters are blocking it from firing higher.

This may sound weird, so I provided a terrible diagram to help explain.

The following may help as well:
Code: [Select]
datablock TSShapeConstructor(HumveeGTurretDts)
{
baseShape  = "./HumveeGTurret.dts";
sequence0  = "./t_root.dsq root";

sequence1  = "./t_root.dsq run";
sequence2  = "./t_root.dsq walk";
sequence3  = "./t_root.dsq back";
sequence4  = "./t_root.dsq side";

sequence5  = "./t_root.dsq crouch";
sequence6  = "./t_root.dsq crouchRun";
sequence7  = "./t_root.dsq crouchBack";
sequence8  = "./t_root.dsq crouchSide";

sequence9  = "./t_look.dsq look";
sequence10 = "./t_root.dsq headside";
sequence11 = "./t_root.dsq headUp";

sequence12 = "./t_root.dsq jump";
sequence13 = "./t_root.dsq standjump";
sequence14 = "./t_root.dsq fall";
sequence15 = "./t_root.dsq land";

sequence16 = "./t_root.dsq armAttack";
sequence17 = "./t_root.dsq armReadyLeft";
sequence18 = "./t_root.dsq armReadyRight";
sequence19 = "./t_root.dsq armReadyBoth";
sequence20 = "./t_root.dsq spearready"; 
sequence21 = "./t_root.dsq spearThrow";

sequence22 = "./t_root.dsq talk"; 

sequence23 = "./t_root.dsq death1";

sequence24 = "./t_root.dsq shiftUp";
sequence25 = "./t_root.dsq shiftDown";
sequence26 = "./t_root.dsq shiftAway";
sequence27 = "./t_root.dsq shiftTo";
sequence28 = "./t_root.dsq shiftLeft";
sequence29 = "./t_root.dsq shiftRight";
sequence30 = "./t_root.dsq rotCW";
sequence31 = "./t_root.dsq rotCCW";

sequence32 = "./t_root.dsq undo";
sequence33 = "./t_root.dsq plant";

sequence34 = "./t_root.dsq sit";

sequence35 = "./t_root.dsq wrench";
};   







datablock PlayerData(HumveeGTurretPlayer)
{

   renderFirstPerson = true;
   emap = false;
   
   className = Armor;
   shapeFile = "./HumveeGTurret.dts";
   cameraMaxDist = 15;
   cameraTilt = 0.261;
   cameraVerticalOffset = 5.3;
   computeCRC = false;
 
   canObserve = true;
   cmdCategory = "Clients";

   cameraDefaultFov = 90.0;
   cameraMinFov = 5.0;
   cameraMaxFov = 120.0;
   
   //debrisShapeName = "~/data/player/debris_player.dts";
   //debris = horseDebris;

   aiAvoidThis = true;

   minLookAngle = -1.5708;
   maxLookAngle = 0;
   maxFreelookAngle = 3.0;

   mass = 200;
   drag = 10;
   maxdrag = 0.52;
   density = 0.7;
   maxDamage = 250;
   maxEnergy =  10;
   repairRate = 0.33;
   energyPerDamagePoint = 75.0;

   rechargeRate = 0.4;

   runForce = 0 * 0;
   runEnergyDrain = 0;
   minRunEnergy = 0;
   maxForwardSpeed = 0;
   maxBackwardSpeed = 0;
   maxSideSpeed = 0;

   maxForwardCrouchSpeed = 0;
   maxBackwardCrouchSpeed = 0;
   maxSideCrouchSpeed = 0;

   maxForwardProneSpeed = 0;
   maxBackwardProneSpeed = 0;
   maxSideProneSpeed = 0;

   maxForwardWalkSpeed = 0;
   maxBackwardWalkSpeed = 0;
   maxSideWalkSpeed = 0;

   maxUnderwaterForwardSpeed = 0;
   maxUnderwaterBackwardSpeed = 0;
   maxUnderwaterSideSpeed = 0;

   jumpForce = 0 * 0; //8.3 * 90;
   jumpEnergyDrain = 0;
   minJumpEnergy = 0;
   jumpDelay = 0;

   minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;

   recoverDelay = 0;
   recoverRunForceScale = 1.2;

   minImpactSpeed = 250;
   speedDamageScale = 3.8;

   boundingBox = vectorScale("2.5 2.5 1.7", 4);
   crouchBoundingBox = vectorScale("2.5 2.5 1.7", 4);
   proneBoundingBox = vectorScale("2.5 2.5 1.7", 4);

   pickupRadius = 0.75;
   
   // Damage location details
   boxNormalHeadPercentage       = 0.83;
   boxNormalTorsoPercentage      = 0.49;
   boxHeadLeftPercentage         = 0;
   boxHeadRightPercentage        = 1;
   boxHeadBackPercentage         = 0;
   boxHeadFrontPercentage        = 1;

   // Foot Prints
   //decalData   = HorseFootprint;
   //decalOffset = 0.25;


   jetEmitter = playerJetEmitter;
   jetGroundEmitter = playerJetGroundEmitter;
   jetGroundDistance = 4;
 
   //footPuffEmitter = LightPuffEmitter;
   footPuffNumParts = 10;
   footPuffRadius = 0.25;

   //dustEmitter = LiftoffDustEmitter;

   splash = PlayerSplash;
   splashVelocity = 4.0;
   splashAngle = 67.0;
   splashFreqMod = 300.0;
   splashVelEpsilon = 0.60;
   bubbleEmitTime = 0.1;
   splashEmitter[0] = PlayerFoamDropletsEmitter;
   splashEmitter[1] = PlayerFoamEmitter;
   splashEmitter[2] = PlayerBubbleEmitter;
   mediumSplashSoundVelocity = 10.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 5.0;

   // Controls over slope of runnable/jumpable surfaces
   runSurfaceAngle  = 85;
   jumpSurfaceAngle = 86;

   minJumpSpeed = 20;
   maxJumpSpeed = 30;

   horizMaxSpeed = 68;
   horizResistSpeed = 33;
   horizResistFactor = 0.35;

   upMaxSpeed = 80;
   upResistSpeed = 25;
   upResistFactor = 0.3;
   
   footstepSplashHeight = 0.35;

   //NOTE:  some sounds commented out until wav's are available

   JumpSound = HorseJumpSound;

   // Footstep Sounds
   //FootSoftSound        = HorseFootFallSound;
   //FootHardSound        = HorseFootFallSound;
   //FootMetalSound       = HorseFootFallSound;
   //FootSnowSound        = HorseFootFallSound;
   //FootShallowSound     = HorseFootFallSound;
   //FootWadingSound      = HorseFootFallSound;
   //FootUnderwaterSound  = HorseFootFallSound;
   //FootBubblesSound     = FootLightBubblesSound;
   //movingBubblesSound   = ArmorMoveBubblesSound;
   //waterBreathSound     = WaterBreathMaleSound;

   //impactSoftSound      = ImpactLightSoftSound;
   //impactHardSound      = ImpactLightHardSound;
   //impactMetalSound     = ImpactLightMetalSound;
   //impactSnowSound      = ImpactLightSnowSound;
   
   //impactWaterEasy      = ImpactLightWaterEasySound;
   //impactWaterMedium    = ImpactLightWaterMediumSound;
   //impactWaterHard      = ImpactLightWaterHardSound;
   
   groundImpactMinSpeed    = 10.0;
   groundImpactShakeFreq   = "4.0 4.0 4.0";
   groundImpactShakeAmp    = "1.0 1.0 1.0";
   groundImpactShakeDuration = 0.8;
   groundImpactShakeFalloff = 10.0;
   
   //exitingWater         = ExitingWaterLightSound;
   
   observeParameters = "0.5 4.5 4.5";

   // Inventory Items
maxItems   = 10; //total number of bricks you can carry
maxWeapons = 5; //this will be controlled by mini-game code
maxTools = 5;

uiName = "Grenade Turret";
rideable = true;
   lookUpLimit = 0.6;
   lookDownLimit = 0.1;

canRide = false;
showEnergyBar = false;
paintable = true;

brickImage = horseBrickImage; //the imageData to use for brick deployment

   numMountPoints = 1;
   mountThread[0] = "sit";

   //protection for passengers
   protectPassengersBurn   = true;  //protect passengers from the burning effect of explosions?
   protectPassengersRadius = false;  //protect passengers from radius damage (explosions) ?
   protectPassengersDirect = false; //protect passengers from direct damage (bullets) ?
};

I fixed it, the problem was this:
Code: [Select]
initialVelocity = vectorScale(%mount.getMuzzleVector(0), %mount.shotpower * 5.5 * %scaleFactor);

I changed that to this
Code: [Select]
%mount.Newpower = %mount.shotpower * 2;
Code: [Select]
initialVelocity = vectorScale(%mount.getMuzzleVector(1), %mount.Newpower * %scaleFactor);And I made the initial position
Code: [Select]
      initialPosition = %mount.getSlotTransform(1);