2 problems with the racing mod
by Kirby Webber · in Torque Game Engine · 12/28/2002 (9:46 pm) · 10 replies
I will understand this engine. Even if it kills me. ;)
My first problem is that I can't seem to get the vehicle (a hover vehicle) to apply the turboFactor.
I have mapped the right mouse button to a function mousejet(%val) as suggested in a tutorial, but I cannot seem to link this to anything relevant!
Second... does anyone have a working example of a vehicle::damag() or vehicle::opnDamage() function? I cannot seem to get my pesky player to die!
My first problem is that I can't seem to get the vehicle (a hover vehicle) to apply the turboFactor.
I have mapped the right mouse button to a function mousejet(%val) as suggested in a tutorial, but I cannot seem to link this to anything relevant!
Second... does anyone have a working example of a vehicle::damag() or vehicle::opnDamage() function? I cannot seem to get my pesky player to die!
#2
I tried your script in my onAdd() method, and got no results, I had included similar instructions from a previous tutorial.
Let me just post my datablocks, and see if anyone has any clues... incidentally, this DOES work to instantiate hovervehicles, so if anyone wants to use portions of the script, feel free. ;)
As you can see, I have been experimenting with both damage() and onDamage() methods in script. I could find no references to onDamage() in code.
Also, in order to implement turbo/ jetting ability, I added the following to my default.bind.cs script:
Any help is greatly appreciated!
12/30/2002 (9:45 am)
Hi Sam. Thanks for your response... I was beginning to feel like something of a leper! LOL ;)I tried your script in my onAdd() method, and got no results, I had included similar instructions from a previous tutorial.
Let me just post my datablocks, and see if anyone has any clues... incidentally, this DOES work to instantiate hovervehicles, so if anyone wants to use portions of the script, feel free. ;)
//**************************************************************
//HOVER CYCLE
//**************************************************************
//**************************************************************
//DUST EMMITER AND TEXTURE DATA
//**************************************************************
datablock ParticleData(DustParticle)
{
textureName = "~/data/shapes/buggy/dustParticle";
dragCoefficient = 2.0;
gravityCoefficient = -0.1;
inheritedVelFactor = 0.1;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 0;
colors[0] = "0.46 0.36 0.26 1.0";
colors[1] = "0.46 0.46 0.36 0.0";
sizes[0] = 1.0;
sizes[1] = 1.5;
};
datablock ParticleEmitterData(LifterDustEmitter)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 1;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 5;
thetaMax = 20;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
particles = "DustParticle";
};
//**************************************************************
// VEHICLE CHARACTERISTICS
//**************************************************************
datablock HoverVehicleData(HoverCycle)
{
spawnOffset = "0 0 1";
renderFirstPerson = false;
floatingGravMag = 2.25; //Original value = 2.5
//load model/ information
catagory = "Vehicles";
shapeFile = "~/data/shapes/buggy/banshee.dts";
emap = true; //enables alpha channel reflections
computeCRC = true;
//damage information
debrisShapeName = "fps/data/shapes/player/debris_player.dts";
debris = playerDebris; //temporary
renderWhenDestroyed = false;
drag = 0.0;
density = 0.9;
//camera variables
cameraMaxDist = 5.5;
cameraOffset = 0.8;
//damage variables
maxDamage = 3.00;
destroyedLevel = 3.0;
//energy variables
jetForce = 20;
maxEnergy = 100;
minJetEnergy = 15;
jetEnergyDrain = 1.3;
// Rigid Body
mass = 1.0;
bodyFriction = 0.1;
bodyRestitution = 0.75;
minImpactSpeed = 20;
softImpactSpeed = 10; // Play SoftImpact Sound
hardImpactSpeed = 25; // Play HardImpact Sound
speedDamageScale = 0.008;
// Object Impact Damage
collDamageThresholdVel = 23;
collDamageMultiplier = 0.030;
//Handling Info**********************
dragForce = 25 / 45.0; //*
vertFactor = 0.0; //*
floatingThrustFactor = 0.37; //*
//baseline = 0.35 //*
//*
mainThrustForce = 37.50; //(35)//*
reverseThrustForce = 10; //*
strafeThrustForce = 15; //*
turboFactor = 2.0; //*
rechargeRate = 0.25; //*
//*
brakingForce = 25; //*
brakingActivationSpeed = 4; //*
//*
stabLenMin = 2.25; //*
stabLenMax = 3.25; //*
stabSpringConstant = 30; //*
stabDampingConstant = 12; //*
//*
gyroDrag = 16; //*
normalForce = 30; //*
restorativeForce = 20; //*
steeringForce = 27.50; //(25) //*
rollForce = 15; //*
pitchForce = 7; //*
//Handling Info**********************
//splash emitter
//splash = PlayerSplash;
//splashVelocity = 4.0;
//splashAngle = 67.0;
//splashFreqMod = 300.0;
//splashVelEpsilon = 0.60;
//bubbleEmitTime = 0.4;
//splashEmitter[0] = PlayerFoamDropletsEmitter;
//splashEmitter[1] = PlayerFoamEmitter;
//splashEmitter[2] = PlayerBubbleEmitter;
//dust emitter
dustEmitter = LifterDustEmitter;
triggerDustHeight = 3.5; //was 2.5
dustHeight = 0.2;
};
//*****************************************************************************
//METHOD DATABLOCKS
//*****************************************************************************
//-----------------------------------------------------------------------------
function HoverVehicleData::onAdd(%this,%obj)
{
// Setup defualt energy values
%obj.setEnergyLevel(%this.MaxEnergy);
%obj.setRechargeRate(%this.rechargeRate);
}
//-----------------------------------------------------------------------------
function HoverCycle::onRemove(%this, %obj)
{
if (%obj.client.player == %obj)
%obj.client.player = 0;
}
//-----------------------------------------------------------------------------
function HoverCycle::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
if (%obj.getDamageState() $= "Dead")
return;
%obj.applyDamage(%damage);
//%location = "Body";
// Deal with client callbacks here because we don't have this
// information in the onDamage or onDisable methods
%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0;
if (%obj.getDamageState() $= "Dead")
%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
}
//-----------------------------------------------------------------------------
function HoverCycle::onDamage(%this, %obj, %delta)
{
Parent::onDamage(%this, %obj);
%currentDamage = %obj.getDamageLevel();
if(%currentDamage > %obj.destroyedLevel)
{
if(%obj.getDamageState() !$= "Dead")
{
//if(%obj.respawnTime !$= "")
//%obj.marker.schedule = %obj.marker.data.schedule(%obj.respawnTime, "respawn", %obj.marker);
%obj.setDamageState(Destroyed);
}
}
else
{
if(%obj.getDamageState() !$= "Enabled")
%obj.setDamageState(Enabled);
}
// if (%obj.getDamageState() $= "Destroyed")
// %client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
}As you can see, I have been experimenting with both damage() and onDamage() methods in script. I could find no references to onDamage() in code.
Also, in order to implement turbo/ jetting ability, I added the following to my default.bind.cs script:
function mouseJet(%val)
{
$mvTriggerCount1++;
}
moveMap.bind( mouse, button1, mouseJet );Any help is greatly appreciated!
#3
12/30/2002 (9:52 am)
Yeah thanks for the datablock man. I needed another hover datablock as reference.
#4
12/30/2002 (10:01 am)
No problem... maybe you could return the favor and tell me what is wrong with it! ;-)
#5
Test and see if the vehicle has energy too.
%obj.getEnergyLevel();
You can call this in the console as well. Just go to the mission editor and use the number it is assigned.
example in console: "echo(1488.getEnergylevel());"
It will either come back 0 or the correct amount.
12/31/2002 (10:49 am)
The "jetForce" may need to be larger "200" instead of "20". And in your mouse bind is that "buttonl" or "button1" It looks like a small "L" to me..Test and see if the vehicle has energy too.
%obj.getEnergyLevel();
You can call this in the console as well. Just go to the mission editor and use the number it is assigned.
example in console: "echo(1488.getEnergylevel());"
It will either come back 0 or the correct amount.
#6
At this point, I have to assume that I screwed something up while monkeying around in the engine. ;-)
What I am trying to do now (to better understand the vehicles) is to simply get damage working in the racing mod using the buggy - on a clean install none-the-less.
Ironically, I am having a harder time getting damage to recognize with the wheeled vehicle! Before I at least had the damage meter decrementing, this simply doesn't register AT ALL! =/
Does someone have a damage function (script) that works with the stock buggy model? It would be SUCH a help.
Incidentally I am using the guiVehicleHealthBar available in the resources, if that is of any consequence.
*Man this is a humbling experience!*
01/01/2003 (8:21 pm)
Okay Sam... I checked it all out, and everything looks spiffy. I have no idea why it's not working.At this point, I have to assume that I screwed something up while monkeying around in the engine. ;-)
What I am trying to do now (to better understand the vehicles) is to simply get damage working in the racing mod using the buggy - on a clean install none-the-less.
Ironically, I am having a harder time getting damage to recognize with the wheeled vehicle! Before I at least had the damage meter decrementing, this simply doesn't register AT ALL! =/
Does someone have a damage function (script) that works with the stock buggy model? It would be SUCH a help.
Incidentally I am using the guiVehicleHealthBar available in the resources, if that is of any consequence.
*Man this is a humbling experience!*
#7
they didnt tell me either and I had to track it down last night try this:
Edit:
have you gotten damage working yet?
01/02/2003 (12:51 pm)
heh yea, this is cause someone changed the trigger used for jetting to 3 .. grr... :)they didnt tell me either and I had to track it down last night try this:
function mouseJet(%val)
{
$mvTriggerCount3++;
}Edit:
have you gotten damage working yet?
#8
I can't seem to get this. I researched models and added (I think) all of the necessary nodes for collision, but nothin' doing so far!
I have been testing my variables in the console. Damage is being calculated, and the damage level of the player stops at it's maximum value, but no matter what I do the player "state" is always enabled.
I am starting to get the feeling that my script is being ignored, at least with regards to the onDamage() method.
Even after abandoning the hovervehicle for a while, I can't get the car to even take damage!
There has to be something I am missing. I'm sure it's a small detail that will make me feel oh so stupid when I realize what it is... but d@mn this is frustrating! =/
I appreciate everyones patience and help though! :-D
01/02/2003 (6:13 pm)
No... no damage yet. No mouse jetting either. At this point I have 3 installations on my box at various levels for experimenting.I can't seem to get this. I researched models and added (I think) all of the necessary nodes for collision, but nothin' doing so far!
I have been testing my variables in the console. Damage is being calculated, and the damage level of the player stops at it's maximum value, but no matter what I do the player "state" is always enabled.
I am starting to get the feeling that my script is being ignored, at least with regards to the onDamage() method.
Even after abandoning the hovervehicle for a while, I can't get the car to even take damage!
There has to be something I am missing. I'm sure it's a small detail that will make me feel oh so stupid when I realize what it is... but d@mn this is frustrating! =/
I appreciate everyones patience and help though! :-D
#9
The schedule code makes a call to this:
now this isn't stock, but compare it to what you have - ignore the salvageflag and the stuff about destroyer scoring.
The point is to check against the destroyed level, and then set the state to destroyed.
01/02/2003 (7:41 pm)
in vehicle.csfunction WheeledVehicleData::onDamage(%this, %obj, %delta)
{
%currentDamage = %obj.getDamageLevel();
if(%currentDamage >= %obj.getDataBlock().destroyedLevel)
{
if(%obj.getDamageState() !$= "Destroyed")
{
%this.schedule(%obj.destroyDelay, "Destroy",%obj);
%obj.setDamageState(Destroyed);
}
}
}The schedule code makes a call to this:
function LandRover::Destroy(%this, %obj)
{
%this.salvageFlag = 0;
%period = getRandom(10);
schedule(20000+(%period*1000),0,SalvageVehicle,%this.getName(),%obj.index);
%obj.schedule(10000+%period, "startFade", 3000, 0, true);
%obj.schedule(13000+%period, "delete");
if (%this.destroyer)
{
%this.destroyer.incTargets(1);
}
%this.destroyer = 0;
}now this isn't stock, but compare it to what you have - ignore the salvageflag and the stuff about destroyer scoring.
The point is to check against the destroyed level, and then set the state to destroyed.
#10
I am quite sure though, that something is amiss with my installation. I plan to wipe them (all) out this weekend after making some backup files and getting a fresh download through CVS.
I will post when I know one way or the other. Either I have screwed something up in the code, or I am just an idiot. Well, I am an idiot, but I still think I screwed up the code! ;-) LOL
Thank you guys for all of your help, you have been very accommodating so far, and I really appreciate your patience with me as I wrestle to get my head around this engine. :-)
01/03/2003 (7:52 am)
I'm really not sure why, but I noticed that when I run my demo, it says version 1.1.1, though I am quite sure I d/l'd version 1.1.2! I wonder if I got the wrong version and maybe this is part of the problem?I am quite sure though, that something is amiss with my installation. I plan to wipe them (all) out this weekend after making some backup files and getting a fresh download through CVS.
I will post when I know one way or the other. Either I have screwed something up in the code, or I am just an idiot. Well, I am an idiot, but I still think I screwed up the code! ;-) LOL
Thank you guys for all of your help, you have been very accommodating so far, and I really appreciate your patience with me as I wrestle to get my head around this engine. :-)
Torque Owner Sam Guffey
%energy = %data.maxEnergy; // %data may be %this instead.
%obj.setEnergy(%energy);
That should set ya up there. For number 2 I cant help ya since I dont have access to my code atm.
Sam