Author Topic: Skateboard help?  (Read 584 times)

Alright someone helped me by modifying a script, however he doesn't know a whole lot about scripting so can someone modify this to not let the player ride through walls and not flip over (or at least when they do, flip back)?
Code: [Select]
//script made by Bas BT 4-1-2010.

datablock WheeledVehicleTire(SkateboardwheelTire)
{
shapeFile = "./Skateboardwheel.dts";
staticFriction = 4;
kineticFriction = 7;

// Spring that generates lateral tire forces
lateralForce = 18000;
lateralDamping = 4000;
lateralRelaxation = 1;

// Spring that generates longitudinal tire forces
longitudinalForce = 18000;
longitudinalDamping = 4000;
longitudinalRelaxation = 1;
};

datablock WheeledVehicleSpring(SkateboardwheelSpring)
{
// Wheel suspension properties
length = 0.3;                // Suspension travel
force = 3500;              // Spring force
damping = 800;             // Spring damping
antiSwayForce = 6;        // Lateral anti-sway force
};

datablock WheeledVehicleData(SkateboardwheelVehicle)
{
category = "Vehicles";
displayName = "skate Board";
shapeFile = "./Skateboard.dts";
emap = true;
minMountDist = 3;
   
numMountPoints = 1;
mountThread[0] = "root";


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

maxSteeringAngle = 0.85;
integration = 4;           



cameraRoll = false;         // Roll the camera with the vehicle
cameraMaxDist = 13;         // Far distance from vehicle
cameraOffset = 7.5;        // Vertical offset from camera mount point
cameraLag = 001;           // Velocity lag of camera
cameraDecay = 0.75;        // Decay per sec. rate of velocity lag
cameraTilt = 0.4;
collisionTol = 0.1;        // Collision distance tolerance
contactTol = 0.1;

useEyePoint = false;

defaultTire = SkateboardwheelTire;
defaultSpring = SkateboardwheelSpring;
flatTire = SkateboardwheelTire;
flatSpring = SkateboardwheelFlatSpring;

numWheels = 4;


mass = 400;
density = 5.0;
drag = 1.6;
bodyFriction = 0.6;
bodyRestitution = 0.6;
minImpactSpeed = 5;        // Impacts over this invoke the script callback
softImpactSpeed = 5;       // Play SoftImpact Sound
hardImpactSpeed = 15;      // Play HardImpact Sound
groundImpactMinSpeed    = 10.0;


engineTorque = 4000; //4000;       // Engine power
engineBrake = 600;         // Braking when throttle is 0
brakeTorque = 8000;        // When brakes are applied
maxWheelSpeed = 40;        // Engine scale by current speed / max speed

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


justcollided = 0;

uiName = "Skateboardwheeler Board ";
rideable = true;
lookUpLimit = 1.6;
lookDownLimit = 1.6;

paintable = true;


minRunOverSpeed    = 1;   //Skateboardwheel fast you need to be going to run someone over (do damage)
runOverDamageScale = 10;   //when you run over someone, speed * runoverdamagescale = damage amt
runOverPushScale   = 10; //Skateboardwheel hard a person you're running over gets pushed

steeringUseStrafeSteering = false; //this vehicle has pitch control, so we can't use strafe steering
};


function Skateboardwheel::onCollision(%this,%obj,%col,%vec,%speed)
{
   // Collision with other objects, including items
    Parent::onDamage(%this, %obj);
}

function Skateboardwheel::onAdd(%this,%obj)
{
         %obj.playThread(0,"Action");
}

function StaticShapeData::create(%block)
{
 %obj = new StaticShape()
 {
      dataBlock = %block;
 };
 return(%obj);
}

function ServerCmdOllie(%client)
{
%pmount = %client.player.getObjectMount();
%vec2 = %pmount.getForwardVector();
%vec2 = VectorNormalize(%vec2);
%vec2 = VectorScale(%vec2, 15);
Checkheight(%client, %pmount);
if($Pref::Server::Midollie){
%client.ollie = 1;
}
if(%pmount.getDataBlock().getname() $= "SkateboardwheelVehicle"){
if(!%client.ollie) return;
%vec3 = %pmount.getposition();
%client.ollie = 0;
%vec = VectorAdd(%pmount.getposition(), "0 0" SPC 10);
%vec = VectorAdd(%vec, %vec2);
%vec = VectorSub(%vec, %vec3);
%vec = VectorNormalize(%vec);
%vec = VectorScale(%vec, 30);
%pmount.setVelocity(%vec);
}else{
messageclient(%client,"","You are not on a Skateboard.");
}
}

function CheckHeight(%client, %obj)
{
%Zspeed = getWord(%obj.getvelocity(), 2);
if(%Zspeed < 0.35 && %Zspeed > -1.5)
{
%client.ollie = 1;
}else{
%client.ollie = 0;
}
}

function ServerCmdNitro(%client)
{
%pmount = %client.player.getObjectMount();
if(%pmount.getDataBlock().GetName() $= "SkateboardwheelVehicle"){
if(%client.nitro){
messageclient(%client,"","You do not have Nitro charged.");
return;
}
%vec = %pmount.getForwardVector();
%vec = VectorAdd(%vec, "0 0" SPC 0.3);
%vec = VectorNormalize(%vec);
%vec = VectorScale(%vec, 65);
%pmount.setVelocity(%vec);
%client.nitro = 1;
schedule(3500,0,"Nitroit",%client);
}else{
messageclient(%client,"","You are not on a Skateboard.");
}
}

function Nitroit(%client)
{
%client.Nitro = 0;
}

function SkateboardwheelVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val){
      if(%triggerNum == 2){
      ServerCmdollie(%obj.spawnbrick.client);
  }
   }
}

function ServerCmdToggleMidollie(%client)
{
if(%client.issuperadmin || %client.isadmin)
{
 if($pref::server::Midollie){
  $pref::server::Midollie = 0;
  messageAll('','Midollie is now disabled!');
  }else{
  $pref::server::Midollie = 1;
  messageall('','Midollie now enabled!');
 }
}
}

Alright someone helped me by modifying a script, however he doesn't know a whole lot about scripting so can someone modify this to not let the player ride through walls and not flip over (or at least when they do, flip back)?
Code: [Select]
-Snip-
People won't do the work for you But, the snowmobile some how keeps balance, i would check the script on snowmobile.

People won't do the work for you But, the snowmobile some how keeps balance, i would check the script on snowmobile.
Just fields of the vehicle datablock, the GSF Sea-Copter does it too.

Well pah I WOULD do it myself but I have NO idea once so ever about scripting for torque..I know SOME lua from roblox but that's about it.


EDIT: This is the snowmobile script, can someone at least tell me which part is the part that is stopping it from flipping?

Code: [Select]
// support stuff for the SnowMobile vehicle
exec("./SnowMobile_Tire.cs");
exec("./SnowMobile_Explosion.cs");
exec("./SnowMobile_FinalExplosion.cs");
exec("./SnowMobile_Spring.cs");

datablock WheeledVehicleData(snowmobileVehicle)
{
category = "Vehicles";
displayName = " ";
shapeFile = "./snowmobile.dts"; //"~/data/shapes/skivehicle.dts"; //
emap = true;
minMountDist = 3;
   
   numMountPoints = 1;
   mountThread[0] = "sit";

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

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

maxSteeringAngle = 0.9785;  // 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;         // Far distance from vehicle
cameraOffset = 5;        // 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.3;
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.1;

useEyePoint = false;

defaultTire = snowmobileTire;
defaultSpring = snowmobileSpring;
//flatTire = snowmobileFlatTire;
//flatSpring = snowmobileFlatSpring;

   numWheels = 4;

// Rigid Body
mass = 800;
density = 5.0;
drag = 1.6;
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 = 85000; //4000;       // Engine power
engineBrake = 2000;         // Braking when throttle is 0
brakeTorque = 50000;        // When brakes are applied
maxWheelSpeed = 30;        // Engine scale by current speed / max speed

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

   // Advanced Steering
   steeringAutoReturn = true;
   steeringAutoReturnRate = 0.9;
   steeringAutoReturnMaxSpeed = 10;
   steeringUseStrafeSteering = true;
   steeringStrafeSteeringRate = 0.1;

// Energy
maxEnergy = 100;
jetForce = 3000;
minJetEnergy = 30;
jetEnergyDrain = 2;

splash = vehicleSplash;
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;

   uiName = "Snowmobile";
rideable = true;
lookUpLimit = 0.72;
lookDownLimit = 0.72;

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;

   numDmgEmitterAreas = 1;

   initialExplosionProjectile = snowmobileExplosionProjectile;
   initialExplosionOffset = 0;         //offset only uses a z value for now

   burnTime = 4000;

   finalExplosionProjectile = snowmobileFinalExplosionProjectile;
   finalExplosionOffset = 0.5;          //offset only uses a z value for now

   minRunOverSpeed    = 4;   //how fast you need to be going to run someone over (do damage)
   runOverDamageScale = 8;   //when you run over someone, speed * runoverdamagescale = damage amt
   runOverPushScale   = 1.2; //how hard a person you're running over gets pushed

   //protection for passengers
   protectPassengersBurn   = false;  //protect passengers from the burning effect of explosions?
   protectPassengersRadius = true;  //protect passengers from radius damage (explosions) ?
   protectPassengersDirect = false; //protect passengers from direct damage (bullets) ?
};
« Last Edit: January 08, 2010, 05:04:35 PM by naturemon »