Accessing Parent data in datablock function
by Jacob Gostylo · in Torque Game Engine · 11/16/2005 (6:22 am) · 2 replies
I may have a fundamental misunderstaning of this but this is the best way I can explain it for what I know.
I am trying to add radial damage to my weapons. I have a tank that fires numerous types of ammo and each do differing damage at differing radii. I have been modifying examples and tutorials to get what I want so I am left here missing some part without a complete understanding of the code I am using.
The datablock looks like this:
The ammo object contructor looks like this:
The function that is giving me trouble is:
Is my assumption correct that the function onCollision is based on the TankPrimaryProjectile datablock "namespace" (I know that there really is no classic namespace in Torque script)? If so then I know why %this.damageRadius,%this.radiusDamage,%this.radiusType,%this.impulse have no value because those are defined in the Projectile object that I create.
If this is the case, is there a way to retrieve these values in TankPrimaryProjectile::onCollision?
I am hoping to not have to set up a new datablock and possibly a new onCollision function for every one of my ammo types.
I am trying to add radial damage to my weapons. I have a tank that fires numerous types of ammo and each do differing damage at differing radii. I have been modifying examples and tutorials to get what I want so I am left here missing some part without a complete understanding of the code I am using.
The datablock looks like this:
datablock ProjectileData(TankPrimaryProjectile)
{
explosion = TankPrimaryExplosion;
waterExplosion = TankPrimaryWaterExplosion;
splash = TankPrimarySplash;
velInheritFactor = 0.3;
armingDelay = 0;
lifetime = 5000;
fadeDelay = 5000;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = true;
gravityMod = 0.80;
hasLight = true;
lightRadius = 4;
lightColor = "0.5 0.5 0.25";
hasWaterLight = true;
waterLightColor = "0 0.5 0.5";The ammo object contructor looks like this:
%p = new (Projectile)() {
dataBlock = TankPrimaryProjectile;
initialVelocity = %muzzleVelocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
...snip...
directDamage = %damage;
damageRadius = %radius;
radiusDamage = %radiusDamage;
radiusType = %radiusType;
damageType = %damageType;
impulse = %impulse;The function that is giving me trouble is:
function TankPrimaryProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Apply damage to the object all shape base objects
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%this.directDamage,"TankPrimaryProjectile");
// Radius damage is a support scripts defined in radiusDamage.cs
// Push the contact point away from the contact surface slightly
// along the contact normal to derive the explosion center. -dbs
radiusDamage
(%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
%this.damageRadius,%this.radiusDamage,%this.radiusType,%this.impulse);
}Is my assumption correct that the function onCollision is based on the TankPrimaryProjectile datablock "namespace" (I know that there really is no classic namespace in Torque script)? If so then I know why %this.damageRadius,%this.radiusDamage,%this.radiusType,%this.impulse have no value because those are defined in the Projectile object that I create.
If this is the case, is there a way to retrieve these values in TankPrimaryProjectile::onCollision?
I am hoping to not have to set up a new datablock and possibly a new onCollision function for every one of my ammo types.
About the author
Torque 3D Owner Billy L