Game Development Community

Error trying to add a player object

by Jorge Luis Gandulfo · in Torque Game Engine · 06/26/2008 (10:21 pm) · 8 replies

I get this error when i try to add a FlyingVehicle player:

Quote:
Object 'Holder' is not a member of the 'GameBaseData' data block class
game/server/game.cs (104): Register object failed for object (null) of class FlyingVehicle.

this is the code i used:
// Create the player object
   //%player = new Player() {
   //   dataBlock = PlayerBody;
   //   client = %this;
   //};
   //MissionCleanup.add(%player);
   %player = new FlyingVehicle() {
      datablock = Holder;
      client = %this;
   };
   MissionCleanup.add(%player);

And Holder is the name of the Flyingvehicle datablock wich is defined already.

Got the same error trying to add a Turret player.
The Dummy DTS i made for the tests i have to do dont have a valid shape or colision, but all the rest nodes required for either a Turret or a Flying vehicle in both cases.

I'm still trying to make a Turret object my player object, and got no luck so far, always end in this error.

For a Arcade like game, all i need is a static object that rotates and allow me to fire, thats a turret, wish i could get this to work.

Thanks a lot in advance for any tips you could give me.

Note: For what i readed in the forum i'm almost sure something in the DTS files might be missing, but maybe somebody knows what going on here.

#1
06/27/2008 (12:47 pm)
It looks like the problem is in your FlyingVehicleData class. How is it defined?
#2
07/01/2008 (10:19 am)
I made a copy of the Flying Vehicle resource of BraveTree.

datablock FlyingVehicleData(Holder)
{

  spawnOffset = "0 0 1";
  category = "Vehicles";
  shapeFile = "~/data/shapes/turret/holder.dts";

  ultipassenger = false;
  renderWhenDestroyed = false;
  mountPose[0] = sitting;
  drag = 0.10;
  density = 1.0;

  cameraMaxDist = 5;
  cameraOffset = 1.0;
  cameraRoll = true;// Roll the camera with the vehicle
  cameraDecay = 0.80;// Decay per sec. rate of velocity lag
  cameraLag = 0.05;

  minMountDist = 6;

  //explosion = WarSparrowExplosion;
  //explosionDamage = 0.5;
  //explosionRadius = 5.0;

  maxDamage = 90.00;
  DestroyedLevel = 90.00;
  isShielded = true;
  EnergyPerDamagePoint = 160;

  MaxEnergy = 280;    // Afterburner and any energy weapon pool
  MinDrag = 88;       // Linear Drag (eventually slows you down when not thrusting...constant drag)
  RotationalDrag = 10;// Anguler Drag (dampens the drift after you stop moving the mouse...also tumble drag)
  RechargeRate = 0.0;

  maxAutoSpeed = 4;      // Autostabilizer kicks in when less than this speed. (meters/second)
  autoAngularForce = 100;  // Angular stabilizer force (this force levels you out when autostabilizer kicks in)
  autoLinearForce = 300;   // Linear stabilzer force (this slows you down when autostabilizer kicks in)
  autoInputDamping = 0.85;// Dampen control input so you don't whack out at very slow speeds

  // Maneuvering Information
  MaxSteeringAngle = 4.2;      // Max radians you can rotate the wheel. Smaller number is more maneuverable.
  HorizontalSurfaceForce = 350;// Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning)
  VerticalSurfaceForce = 100;  // Vertical center "wing" (controls side slip. lower numbers make MORE slide.)
  ManeuveringForce = 4500;     // Horizontal jets (W,S,D,A key thrust)
  SteeringForce = 1500;        // Steering jets (force applied when you move the mouse)
  SteeringRollForce = 1280;     // Steering jets (how much you heel over when you turn)
  RollForce = 820;             // Auto-roll (self-correction to right you after you roll/invert)
  HoverHeight = 1.0;           // Height off the ground at rest
  CreateHoverHeight = 1.0;     // Height off the ground when created

  // Rigid body
  Mass = 500;           // Mass of the vehicle
  BodyFriction = 0;     // Don't mess with this.
  BodyRestitution = 0.8;// When you hit the ground, how much you rebound. (between 0 and 1)
  MinRollSpeed = 0;     // Don't mess with this.
  MinImpactSpeed = 0;   // If hit ground at speed above this then it's an impact. Meters/second
  SoftImpactSpeed = 10; // Sound hooks. This is the soft hit.
  HardImpactSpeed = 25; // Sound hooks. This is the hard hit.
  SpeedDamageScale = 0.04;

  collDamageThresholdVel = 20.0;
  collDamageMultiplier = 0.02;

  minTrailSpeed = 0; // The speed your contrail shows up at.


//------------------------------------------------------------
// Sound Velocities
// Velocities at which Water Impact sounds will be triggered

  SoftSplashSound = 15.0;
  MediumSplashSoundVelocity = 30.0;
  HardSplashSoundVelocity = 60.0;
  ExitSplashSoundVelocity = 20.0;
};

I had the same error if i tried to make the Turret Object a player, i really don't know what to check for next.
#3
07/01/2008 (3:34 pm)
Just glancing over it real quick, you have 'ultipassenger' when it should be 'multipassenger'.
#4
07/02/2008 (11:21 pm)
Thanks a lot for helping, still i got the same error after fixing that up, anyway its weird after copying pasting something like this i could find a Missing M..
#5
07/03/2008 (11:26 am)
Seems the error is made when i try to run this code, which adds a PDANA turret.

function Holder::onAdd(%this,%obj)
{
   // Called when the PlayerData datablock is first 'read' by the engine (executable)

   // mount turret
   %turret = new Turret()
    {
       dataBlock = GenericTurret;
    };
    // mount turret at whatever mount point
    %obj.mountObject(%turret,1);
   //}
   %obj.mountedTurret = %turret;
}

I was checking all the Turret Blocks and i can't find why it crashes when trying to add a turret to the Holder Object.

Just in case anybody came up with any idea


Weapon.cs

//-----------------------------------------------------------------------------
// Projectile Object
datablock ProjectileData(SmallTurretGunProjectile)
{
  projectileShapeName = "~/data/shapes/weapon/projectile.dts";
  directDamage        = 10;
  radiusDamage        = 10;
  damageRadius        = 0.5;
  //explosion           = FlyerMachineGunExplosion;
  //particleEmitter     = FlyerMachineGunSmokeEmitter;
  muzzleVelocity      = 60;
  velInheritFactor    = 1;
  armingDelay         = 0.3;
  lifetime            = 8000;
  fadeDelay           = 1500;
  bounceElasticity    = 0;
  bounceFriction      = 0;
  isBallistic         = true;
  gravityMod = 0.10;
  hasLight    = true;
  lightRadius = 1.5;
  lightColor  = "0.56 0.36 0.26 1.0";
};

datablock ShapeBaseImageData(SmallTurretGun)
{
   // Basic Item properties
   shapeFile = "~/data/shapes/turret/barrel.dts";
   mass = 15;
   //category					= "Turrets";  // you dont want to place these

   mountPoint = 0;
   offset = "0 0 0";

   projectile = SmallTurretGunProjectile;
   projectileType = Projectile;
   correctMuzzleVector = false;   // not sure how this is used

   // I dont implement use of these in script
   // but old turret stuff had this...
   usesEnergy = true;
   fireEnergy = 10;
   minEnergy = 4;

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
      // State transitions
   stateName[0]                     = "Activate";
   stateTimeoutValue[0]             = 0.01;
   stateTransitionOnTimeout[0]      = "Ready";
   //stateSound[0]                    = TurretSwitchSound;

   stateName[1]                     = "Ready";
   stateTransitionOnTriggerDown[1]  = "Fire";
   stateTransitionOnNoAmmo[1]       = "NoAmmo";

   stateName[2]                     = "Fire";
   stateTransitionOnTimeout[2]      = "Reload";
   stateTimeoutValue[2]             = 0.13;
   stateFire[2]                     = true;
   stateRecoil[2]                   = LightRecoil;
   stateAllowImageChange[2]         = false;
   stateSequence[2]                 = "Fire";
   //stateSound[2]                    = TurretGunFireSound;
   stateScript[2]                   = "onFire";

   stateName[3]                     = "Reload";
   stateTimeoutValue[3]             = 0.40;
   stateAllowImageChange[3]         = false;
   stateTransitionOnTimeout[3]      = "Ready";
   stateTransitionOnNoAmmo[3]       = "NoAmmo";

   stateName[4]                     = "NoAmmo";
   stateTransitionOnAmmo[4]         = "Reload";
   stateSequence[4]                 = "NoAmmo";
};

function GenericTurret::onAdd(%this,%obj)
{
   // we specified a barrel so the parent class does all the work
   // in fact we could remove this GenericTurret::onAdd() method completely
   Parent::onAdd(%this,%obj);

   // if you do not specify a barrel then you
   // need to do this...
   //%turretSlot = 0;
   //%obj.setEnergyLevel(%this.MaxEnergy);
   //%obj.getMountedImage(%turretSlot);
   //echo("Created Generic Turret By hand");
   //%obj.mountImage(SmallTurretGun,%turretSlot);
}


function GenericTurret::onFire(%data, %obj, %slot)
{
    %projectile = %data.projectile;
    // Determine initial projectile velocity based on the
    // gun's muzzle point and the object's current velocity
    %muzzleVector = %obj.getMuzzleVector(%slot);
    %objectVelocity = %obj.getVelocity();
    %muzzleVelocity = VectorAdd(
    	VectorScale(%muzzleVector, %projectile.muzzleVelocity),
    	VectorScale(%objectVelocity, %projectile.velInheritFactor));
    %vehicle = 0;
    // Create the projectile object
    %p = new (%data.projectileType)()
    {
      dataBlock        = %data.projectile;
      initialVelocity  = %muzzleVelocity;
      initialDirection = %obj.getMuzzleVector(%slot);
      initialPosition  = %obj.getMuzzlePoint(%slot);
      sourceObject     = %obj;
      sourceSlot       = %slot;
      vehicleObject    = %vehicle;
    };
    if (isObject(%obj.lastProjectile) && %obj.deleteLastProjectile)
       %obj.lastProjectile.delete();
       %obj.lastProjectile = %p;
   %obj.deleteLastProjectile = %data.deleteLastProjectile;
   MissionCleanup.add(%p);
   return %p;
}


genericturret.cs
// phdana turrets ->

datablock DebrisData(TurretDebris)
{
	explodeOnMaxBounce = false;

	elasticity = 0.15;
	friction = 0.5;

	lifetime = 2.0;
	lifetimeVariance = 0.0;

	minSpinSpeed = 40;
	maxSpinSpeed = 200;

	numBounces = 5;
	bounceVariance = 0;

	staticOnMaxBounce = true;
	gravModifier = 1.0;

	useRadiusMass = true;
	baseRadius = 1;

	velocity = 30.0;
	velocityVariance = 12.0;
};

datablock TurretData(GenericTurret)
{
	category						= "Turrets";
    numPoints                       = 100;
    
	shapeFile						= "~/data/shapes/turret/turret.dts";
    maxDamage                       = 110;
    //explosion                       = RifleExplosion;
    destroyedLevel                  = 110;
    disabledLevel                   = 0.84;
	debrisShapeName		   	        = "~/data/shapes/turret/turret.dts";
    debris                          = TurretDebris;
    renderWhenDestroyed             = false;
  	mountPose[0]					= sitting;
	numMountPoints					= 2;
	isProtectedMountPoint[0]		= true;
	cameraMaxDist					= 10;
	cameraOffset					= 2.5;
	maxEnergy						= 280;
	rechargeRate					= 0.8;
 	heat                            = 1.0;
  
    // turret specific stuff
    //minYaw = -90.0;
    //maxYaw = 90;
  
    // mounted by default in TurretData if specified
    barrelSlot                      = 0;
    barrel                          = SmallTurretGun;
};
// <- phdana turrets
#6
07/03/2008 (5:50 pm)
What error is it?
#7
07/06/2008 (12:20 pm)
It crashes somewhere inside the Turret Scripts, after the player tries to mount the turret, no error is given.
For example the program crashes after this line in console.log : TurretData::onNewDataBlock, but the only thing that is done there is writing this line..

If i remove this lines everything work, but got no turret of course..

// mount turret
   %turret = new Turret()
    {
       dataBlock = GenericTurret;
    };
    // mount turret at whatever mount point
    %obj.mountObject(%turret,1);
   //}
   %obj.mountedTurret = %turret;

The error i got before was becouse the Pdana script mounts a turret in mount 3 for default, when i changed it, it started to crash.

I cleaned most of the turret functions where the barrel is added etc, to see if the error had something to do with it, but still nothing, i also checked the C++ Code of the additions i made for turrets, but i couldn't find anything either, im almost sure the error is in the script side of the code.
#8
07/12/2008 (11:29 am)
The problem seems to be that the code is not finding the codeWeapon and codeTurret nodes, they are case sensitive so i used the correct name, and also modified the CFG of the max exporter to have the nodes exported, and still no luck.

Any Ideas?

This is the line where nodes are accesed, they always return -1 for some reason

bool TurretData::preload(bool server, char errorBuffer[256])
{

...

   // get nodes from shape
   turretNode = shapeResource->findNode("codeTurret");
   weaponNode = shapeResource->findNode("codeWeapon");

...