Damage Oddities with projectiles
by Jeff Trier · in Torque Game Engine · 07/23/2003 (8:05 am) · 7 replies
I am having some problems with my projectile damage and I can't seem to figure out the cause.
First, I should mention that damage is set up a little differently for my weapons. The player actually carries the weapons damage value(it's user defined), and it's passed in the projectiles onCollision function.
If I fire my weapon and hit a target at long rage, no damage is done. And strangly enough, the projectiles "sourceObject" becomes invalid as well(which is bad). But at close range, everything is fine and the sourceObject stays valid. You would think this might be due to the projectile fading before it hit it's target, but it isn't. It even makes it's collision effect.
There is a fix I found, but it doesn't yield the result I am looking for. Basically I just increase the ProjectileData's muzzleVelocity and it works great at any distance. Well, aside from the fact that my flame throwers and gas sprayers now shoot at the speed of a bullet. So this indicates that it is either a range or a time issue.
If I can figure out how to keep sourceObject valid, I am sure I could fix my overall problem.
Here is the solid based projectile:
I have been racking my brain on this for a while. Any help would be great!
Thanks,
-Jeff
First, I should mention that damage is set up a little differently for my weapons. The player actually carries the weapons damage value(it's user defined), and it's passed in the projectiles onCollision function.
If I fire my weapon and hit a target at long rage, no damage is done. And strangly enough, the projectiles "sourceObject" becomes invalid as well(which is bad). But at close range, everything is fine and the sourceObject stays valid. You would think this might be due to the projectile fading before it hit it's target, but it isn't. It even makes it's collision effect.
There is a fix I found, but it doesn't yield the result I am looking for. Basically I just increase the ProjectileData's muzzleVelocity and it works great at any distance. Well, aside from the fact that my flame throwers and gas sprayers now shoot at the speed of a bullet. So this indicates that it is either a range or a time issue.
If I can figure out how to keep sourceObject valid, I am sure I could fix my overall problem.
Here is the solid based projectile:
datablock ProjectileData(SolidProjectile){
projectileShapeName = "~/data/shapes/Gun/SolidProj.dts";
directDamage = 0;
radiusDamage = 0; //10;
damageRadius = 0; //0.5;
//explosion = DefaultExplosion;
//particleEmitter = DefaultTrailEmitter;
muzzleVelocity = 1000; // RANGE???
velInheritFactor = 1;
armingDelay = 0;
lifetime = 10000;
fadeDelay = 10000;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = true;
gravityMod = 0.10;
hasLight = false;
lightRadius = 1.0;
lightColor = "0 0 0.0";
};
datablock ProjectileData(SolidBallistic : SolidProjectile){
explosion = SolidRicochet;
};
function SolidBallistic::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Apply damage to the object all shape base objects
%damage = %obj.sourceObject.DamageValue; // becomes invalid at longer ranges
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%damage,"BallisticBase");
// Radius damage is a support scripts defined in radiusDamage.cs
//radiusDamage(%obj,%pos,%this.damageRadius,%damage,"BallisticBase",0);
}I have been racking my brain on this for a while. Any help would be great!
Thanks,
-Jeff
About the author
Originally a Classical/Metal musician, I've always been attracted to anything involving computers, including: Networking, PC Building and Repair, software design and coding. I've been involved with game design and development for over 10 years.
#2
Hope this helps...
John.
07/23/2003 (8:36 am)
Scratch that, it looks like sourceObject is being used by something else. I stopped using it and started using my own variable (like mySourceObject) to house the player.Hope this helps...
John.
#3
07/23/2003 (9:22 am)
The sourceObject variable is used to prevent projectile collisions with the source for a short period (231 ms). When that period expires, sourceObject is set to 0. This happens in Projectile::processTick in projectile.cc.
#5
So I just need to store the reference to the player a different way.
EDIT: Bob, did you make that variable in source or script?
EDIT2: Nevermind, I will just change the damage of the projectile in the projectiles creation. Something like:
%p = new ProjectileType(){
...
damage = %player.damageModifier;
}
Thanks guys!
-Jeff
07/23/2003 (10:16 am)
Ahh, thanks.So I just need to store the reference to the player a different way.
EDIT: Bob, did you make that variable in source or script?
EDIT2: Nevermind, I will just change the damage of the projectile in the projectiles creation. Something like:
%p = new ProjectileType(){
...
damage = %player.damageModifier;
}
Thanks guys!
-Jeff
#6
I added a player reference to the projectile through the script. The reference to the player comes in handy for multiplayer / team play.
John.
07/23/2003 (1:18 pm)
Jeff,I added a player reference to the projectile through the script. The reference to the player comes in handy for multiplayer / team play.
John.
Torque Owner John Kabus (BobTheCBuilder)
I've noticed the same thing. It looks like the projectiles are recreated after a period of time. Though I'm not sure why.
John.