Author Topic: Converted the Citi MK2 to FWD, doesn't work, what's wrong?  (Read 2370 times)

I've attempted to FWD-ize the Citi MK2 which is (very unrealistically) AWD by default by adding this into the .cs file (stuff in bold was what I added)
What's wrong here?

Quote from: CitiMK2.cs
datablock WheeledVehicleData(CitiMk2Vehicle)
{
   isCustom=1;
   type="CitiMk2";
   uiName = "Citi Mk2";
   
   shapeFile = "./CitiMk2.dts";
   category = "Vehicles";
   displayName = " ";
   emap = true;
   minMountDist = 3;
   
   numMountPoints = 4;
   mountThread[0] = "sit";
   mountThread[1] = "sit";
   mountThread[2] = "sit";
   mountThread[3] = "sit";

   maxDamage = 200.00;
   destroyedLevel = 200.00;
   energyPerDamagePoint = 160;
   speedDamageScale = 1.04;
   collDamageThresholdVel = 20.0;
   collDamageMultiplier   = 0.02;

   massCenter = "0 0 0.6";
   //massBox = "2 5 1";

   maxSteeringAngle = 0.7;  // Maximum steering

angle, should match animation
   integration = 4;           // Force integration

time: TickSec/Rate
   //tireEmitter = VehicleTireEmitter; // All the

tires use the same dust emitter

   // 3rd person camera settings
   cameraRoll = false;         // Roll the camera

with the vehicle
   cameraMaxDist = 8.5;         // Far distance from

vehicle
   cameraOffset = 3.4;        // Vertical offset from

camera mount point
   cameraLag = 0.0;           // Velocity lag of

camera
   cameraDecay = 0.75;        // Decay per sec. rate

of velocity lag
   cameraTilt = 0.2;
   collisionTol = 0.1;        // Collision distance

tolerance
   contactTol = 0.1;

   useEyePoint = false;   

   defaultTire   = CitiMk2Tire;
   defaultSpring   = CitiMk2Spring;
   flatTire   = jeepFlatTire;
   flatSpring   = jeepFlatSpring;

   numWheels = 4;

   // Rigid Body
   mass = 200;
   density = 5.0;
   drag = 4.5;
   bodyFriction = 0.6;
   bodyRestitution = 0.6;
   minImpactSpeed = 10;        // Impacts over this

invoke the script callback
   softImpactSpeed = 10;       // Play SoftImpact

Sound
   hardImpactSpeed = 15;      // Play HardImpact

Sound
   groundImpactMinSpeed    = 10.0;


   // Engine
   engineTorque = 2400;   //teneksi   3000;

//4000;       // Engine power
   engineBrake = 600;   //teneksi   700;       

  // Braking when throttle is 0
   brakeTorque = 2000;   //teneksi   3200;     

  // When brakes are applied
   maxWheelSpeed = 37;   //teneksi   42;       

// Engine scale by current speed / max speed

   rollForce      = 900;
   yawForce      = 600;
   pitchForce      = 1000;
   rotationalDrag      = 0;

   // Advanced Steering
     steeringAutoReturn = true;
     steeringAutoReturnRate = 1;
     steeringAutoReturnMaxSpeed = 10;
    steeringUseStrafeSteering = true;
    steeringStrafeSteeringRate = 0.08;
   
   // Energy
   maxEnergy = 100;
   jetForce = 3000;
   minJetEnergy = 30;
   jetEnergyDrain = 2;

   splash = jeepSplash;
   splashVelocity = 4.0;
   splashAngle = 67.0;
   splashFreqMod = 300.0;
   splashVelEpsilon = 0.60;
   bubbleEmitTime = 1.4;
   splashEmitter[0] = VehicleFoamDropletsEmitter;
   splashEmitter[1] = VehicleFoamEmitter;
   splashEmitter[2] = VehicleBubbleEmitter;
   mediumSplashSoundVelocity = 10.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 5.0;
      
   //mediumSplashSound = "";
   //hardSplashSound = "";
   //exitSplashSound = "";
   
   // Sounds
   //   jetSound = ScoutThrustSound;
   //engineSound = idleSound;
   //squealSound = skidSound;
   softImpactSound = SlowImpactSound;
   hardImpactSound = FastImpactSound;
   //wheelImpactSound = slowImpactSound;

   //   explosion = VehicleExplosion;
   justcollided = 0;
   rideable = true;
      lookUpLimit = 0.50;
      lookDownLimit = 0.50;

   paintable = true;
   
   damageEmitter[0] = VehicleBurnEmitter;
   damageEmitterOffset[0] = "0.0 0.0 0.0 ";
   damageLevelTolerance[0] = 0.99;

   damageEmitter[1] = VehicleBurnEmitter;
   damageEmitterOffset[1] = "0.0 0.0 0.0 ";
   damageLevelTolerance[1] = 1.0;

   handsOnVehicle = 1;

   numDmgEmitterAreas = 1;


   initialExplosionProjectile =

CitiMk2ExplosionProjectile;
   initialExplosionOffset = 0;         //offset only uses

a z value for now

   burnTime = 4000;

   finalExplosionProjectile =

CitiMk2FinalExplosionProjecti le;
   finalExplosionOffset = 0.5;          //offset only uses

a z value for now


   minRunOverSpeed    = 2;   //how fast you need to be

going to run someone over (do damage)
   runOverDamageScale = 5;   //when you run over someone,

speed * runoverdamagescale = damage amt
   runOverPushScale   = 1.2; //how hard a person you're

running over gets pushed
};
Garage_AddParts("add-ons/Vehicle_CitiMk2/CitiMk2.txt");

function CitiMk2Vehicle::onAdd(%this,%obj)
{
   Parent::onAdd(%this,%obj);
   %obj.playthread(0,"propslow");
 %obj.hideNode(lhand);
 %obj.hideNode(rhand);
 %obj.hideNode(lhook);
 %obj.hideNode(rhook);
 %obj.setWheelPowered(0, true );
 %obj.setWheelPowered(1, true );
 %obj.setWheelPowered(2, false );   
 %obj.setWheelPowered(3, false );

 %obj.schedule(0,garageDefault);
}

Why doesn't this work? Is there anything missing?

Remove the spaces surrounding the words true and false, like this.
%obj.setWheelPowered(0,true);
 %obj.setWheelPowered(1,true);
 %obj.setWheelPowered(2,false);   
 %obj.setWheelPowered(3,false);

Remove the spaces surrounding the words true and false, like this.
%obj.setWheelPowered(0,true);
 %obj.setWheelPowered(1,true);
 %obj.setWheelPowered(2,false);   
 %obj.setWheelPowered(3,false);
this isnt necessary afaik

how is it not working? can you clarify what isnt working? can the vehicle drive at all?

this isnt necessary afaik
it isnt, and it actually makes it less readable

this isnt necessary afaik

how is it not working? can you clarify what isnt working? can the vehicle drive at all?

The car is still AWD. Everything else works fine.
EDIT: Also, no syntax errors according to console.
EDIT 2: Also also, this worked on the Club along with some other vehicles.
« Last Edit: November 12, 2017, 12:25:29 AM by Sideswipe »

Shouldn't you switch %obj to %this?

Shouldn't you switch %obj to %this?
No, it's because %this is the datablock object while %object is the actual physical object.

make sure that function is in a package

if that isn't relevant, try
%obj.setWheelPowered(0, 1);
and so on

also get rid of forgetin' %obj.playthread(0,"propslow"); what is that still doing there? that's for a plane. I'm betting the car has no such sequence.

make sure that function is in a package

if that isn't relevant, try
%obj.setWheelPowered(0, 1);
and so on

also get rid of forgetin' %obj.playthread(0,"propslow"); what is that still doing there? that's for a plane. I'm betting the car has no such sequence.
I'll try this tomorrow

Find anything out?

Not trying to be pushy, just curious what the changes did.

Sorry I was procrastinating. I tried what Teneksi suggested and...

Code: [Select]
function CitiMk2Vehicle::onAdd(%this,%obj)
{
   Parent::onAdd(%this,%obj);
   %obj.setWheelPowered(2, 0);
   %obj.setWheelPowered(3, 0);
 %obj.hideNode(lhand);
 %obj.hideNode(rhand);
 %obj.hideNode(lhook);
 %obj.hideNode(rhook);
 %obj.schedule(0,garageDefault);
}

There is a syntax error somewhere in there (apparently in "%obj.setWheelPowered(3, 0);") - but where?
« Last Edit: November 18, 2017, 10:19:25 PM by Sideswipe »

do you completely restart BL when you make these changes? you need to if you do changes to a .zip file

do you completely restart BL when you make these changes? you need to if you do changes to a .zip file

Code: [Select]
setModPaths(getModPaths());

Code: [Select]
setModPaths(getModPaths());
true, i guess i should have just said that. i feel like completely restarting bl is a better habit to instill to new developers until they figure out how the scripting engine works a little better.

I don't understand how you're having so much trouble with this.  here

https://www.dropbox.com/s/y9nfm23pez8bicf/Vehicle_CitiMk2.zip?dl=1