Game Development Community

Bullet Holes ???

by Michael Schaumburg · in Torque Game Engine · 02/18/2005 (8:43 am) · 34 replies

I know there is an example code from May 2002 how to integrate Bullet Holes.
I think there is no engine modification necassary to integrate this in version 1.3
because it is already in.
I added in the script for my weapon :

datablock DecalData(BulletHoleData)
{
   sizeX       = 0.125;
   sizeY       = 0.125;
   textureName = "~/data/shapes/particles/smoke";
};

and in the datablock ProjectileData() I added

DecalData = BulletHoleData;

but I can not see any bullet holes. Does anyone has an idea or I am wrong ......
Page «Previous 1 2
#1
02/18/2005 (8:52 am)
@ Michael - try -

decals[0] = BulletHoleData;

in the ProjectileData block

Here is a free bullethole :)

www.vhp.co.uk/bullethole.png

setup like this for a nice sized effect (obviously, change the texturename path to where ever you save the bullethole image)-

datablock DecalData(BulletHoleData)
{
   sizeX       = 0.08;
   sizeY       = 0.08;
   textureName = "~/data/special/weapons/bullethole";
};

:)
www.vhp.co.uk/screenshot.jpg
#2
02/19/2005 (1:38 am)
Hi David,
thanks a lot, its working perfect. I was not so far away from the solution, but how to find.
I dont remember exactly but there was a way to get all the methods from a given object
to the console. Your given link is broken 'server not found'.
Thanks again.....
#3
02/19/2005 (8:19 am)
Bullet holes dont appear on dts objects like a box, crate, barrel etc. Any reason they wouldn't?
#4
02/19/2005 (9:11 am)
David, I am running into a new problem. How do you make your bullethole.png file ???
I tried a lot but always I got only a white square as a decal !! The interesting thing is,
if I load the same png file into a GuiBitmapCtrl, the transparency is there, oops !!!
Any idea ????
#5
02/19/2005 (10:05 am)
I'm not sure if this still works but it's worth a try.
#6
02/19/2005 (10:11 am)
I ran into this problem a while back let me check out what the problem was
oh yeah here... Timothy Aste "If your getting solid white blocks, then the path is incorrect to your texture. Check your paths. This isn't caused by not being a png file, as you would only see white where the transparency would usually be.
" try that sometimes torque sets the path like fps/etc... when it should be starter.fps/etc...
#7
02/19/2005 (10:25 am)
@Master, thanks that fixed it, objectType mask needs set for statics
#8
02/19/2005 (10:57 am)
Yes this was also my first thought to have the wrong path, but it isn't. I do not get
a message in the console 'Could not locate texture: .......' . If I put the the footprint.png
file into my directory and use it for the decals, it is working. Only my bullethole.png doesn't
work, but as I said in a GuiBitmapCtrl there is the transparency. I have no idea.....
#9
02/19/2005 (11:29 am)
@ Michael - that problem had me puzzled for a while until I remembered that the decals (and textures in general) have to be sized in powers of 2 so 16x16 will work but 15x15 wont and you just get a white square. If you rightclick on the link I gave for free bullethole and click save target as it should let you save it to disk.
#10
02/19/2005 (11:40 am)
Hey David, thanks a lot you are my teacher I think, huhh, the hol day I was thinking where
is my fault, I tried all the grafik programms I have ( and more ) to see what's happend.
Now it works, again thanks a lot.......


Greatings from Berlin
#11
02/21/2005 (4:12 am)
I am running into a problem with the decal not showing up, I have done everything you said to do and still no such luck. The only things I can think of is ether I have put bullethole data in the wrong area or the second posiblity is I am using the crossbow!

anyone know what the problem could be?
#12
02/21/2005 (6:53 am)
Hi Jeff I will give you my code from the crossbow. In crossbow.cs I have :


datablock DecalData(CrossbowHoleData)
{
   sizeX       = 0.125;
   sizeY       = 0.125;
   textureName = "~/data/particles/bullethole2";
};


//-----------------------------------------------------------------------------
// Projectile Object

datablock ProjectileData(CrossbowProjectile)
{
   projectileShapeName = "~/data/shapes/crossbow/projectile.dts";
   directDamage        = 20;
   radiusDamage        = 20;
   damageRadius        = 1.5;
   explosion           = CrossbowExplosion;
   waterExplosion      = CrossbowWaterExplosion;

   particleEmitter     = CrossbowBoltEmitter;
   particleWaterEmitter= CrossbowBoltBubbleEmitter;

   splash              = CrossbowSplash;

   muzzleVelocity      = 100;
   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";
   decals[0] = CrossbowHoleData;
};


change the texturename path to where ever you save the bullethole image. Hope that helps.
#13
02/21/2005 (8:33 am)
Thank you !
#14
01/17/2007 (1:30 am)
Sorry Alot for bumping this old thread but. I have 1 question i tried this bullethole code in crossbow.cs it worked but with my own gun.cs it doesnt work. Is this because i need the explosion data? And when i try put the explosion data IN the explosion data doesnt come Please HELP! code:

exec("~data/shapes/awp/w_awp.cs");

datablock DecalData(AwpBulletHoleData)
{
sizeX = 0.125;
sizeY = 0.125;
textureName = "~/data/bullethole";
};
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Crossbow weapon. This file contains all the items related to this weapon
// including explosions, ammo, the item and the weapon item image.
// These objects rely on the item & inventory support system defined
// in item.cs and inventory.cs
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Sounds profiles

datablock AudioProfile(AwpReloadSound)
{
filename = "~/data/sound/crossbow_reload.ogg";
description = AudioClose3d;
preload = true;
};

datablock AudioProfile(AwpFireSound)
{
filename = "~/data/sound/crossbow_firing.ogg";
description = AudioClose3d;
preload = true;
};

datablock AudioProfile(AwpFireEmptySound)
{
filename = "~/data/sound/crossbow_firing_empty.ogg";
description = AudioClose3d;
preload = true;
};

datablock AudioProfile(AwpExplosionSound)
{
filename = "~/data/sound/crossbow_explosion.ogg";
description = AudioDefault3d;
preload = true;
};

//-----------------------------------------------------------------------------
// M16 ammo projectile splash

datablock ParticleData(AwpSplashMist)
{
dragCoefficient = 2.0;
gravityCoefficient = -0.05;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 400;
lifetimeVarianceMS = 100;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 500.0;
textureName = "~/data/shapes/soldier/splash";

colors[0] = "0.7 0.8 1.0 1.0";
colors[1] = "0.7 0.8 1.0 0.5";
colors[2] = "0.7 0.8 1.0 0.0";

sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.8;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};

datablock ParticleEmitterData(AwpSplashMistEmitter)
{
ejectionPeriodMS = 5;
periodVarianceMS = 0;
ejectionVelocity = 3.0;
velocityVariance = 2.0;
ejectionOffset = 0.0;
thetaMin = 85;
thetaMax = 85;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
lifetimeMS = 250;
particles = "AwpSplashMist";
};
#15
01/17/2007 (1:30 am)
Datablock ParticleData( AwpSplashParticle )
{
dragCoefficient = 1;
gravityCoefficient = 0.2;
inheritedVelFactor = 0.2;
constantAcceleration = -0.0;
lifetimeMS = 600;
lifetimeVarianceMS = 0;
colors[0] = "0.7 0.8 1.0 1.0";
colors[1] = "0.7 0.8 1.0 0.5";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};

datablock ParticleEmitterData( AwpSplashEmitter )
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 3;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 60;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
orientParticles = true;
lifetimeMS = 100;
particles = "AwpSplashParticle";
};

datablock SplashData(AwpSplash)
{
numSegments = 15;
ejectionFreq = 15;
ejectionAngle = 40;
ringLifetime = 0.5;
lifetimeMS = 300;
velocity = 4.0;
startRadius = 0.0;
acceleration = -3.0;
texWrap = 5.0;

texture = "~/data/shapes/soldier/splash";

emitter[0] = AwpSplashEmitter;
emitter[1] = AwpSplashMistEmitter;

colors[0] = "0.7 0.8 1.0 0.0";
colors[1] = "0.7 0.8 1.0 0.3";
colors[2] = "0.7 0.8 1.0 0.7";
colors[3] = "0.7 0.8 1.0 0.0";
times[0] = 0.0;
times[1] = 0.4;
times[2] = 0.8;
times[3] = 1.0;
};

datablock ParticleData(AwpExplosionSparks)
{
textureName = "~/data/shapes/soldier/spark";
dragCoefficient = 1;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 250;
lifetimeVarianceMS = 50;

sizes[0] = 0.6;
sizes[1] = 0.5;
sizes[2] = 0.3;

times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};

datablock ParticleEmitterData(AwpExplosionSparkEmitter)
{
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 5;
velocityVariance = 1;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 0;
phiReferenceVel = 0;
phiVariance = 0;
overrideAdvances = false;
orientParticles = true;
lifetimeMS = 100;
particles = "AwpExplosionSparks";

useEmitterSizes = false;
};

datablock ParticleData(AwpExplosionWaterSparks)
{
textureName = "~/data/shapes/particles/bubble";
dragCoefficient = 0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 350;

colors[0] = "0.4 0.4 1.0 1.0";
colors[1] = "0.4 0.4 1.0 1.0";
colors[2] = "0.4 0.4 1.0 0.0";

sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.5;

times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};

datablock ParticleEmitterData(AwpExplosionWaterSparkEmitter)
{
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 4;
velocityVariance = 4;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 60;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = true;
lifetimeMS = 200;
particles = "AwpExplosionWaterSparks";
};

datablock ExplosionData(AwpExplosion)
{
soundProfile = AwpExplosionSound;
lifeTimeMS = 1200;

// Volume particles
particleEmitter = AwpExplosionSparkEmitter;
particleDensity = 15;
particleRadius = 1;

// Camera Shaking
shakeCamera = false;

// Impulse
impulseRadius = 0.5;
impulseForce = 15;

// Dynamic light
lightStartRadius = 2;
lightEndRadius = 3;
lightStartColor = "0.9 1 0.5";
lightEndColor = "0 0 0";
};

datablock ExplosionData(AwpWaterExplosion)
{
soundProfile = AwpExplosionSound;

// Volume particles
particleEmitter = AwpExplosionBubbleEmitter;
particleDensity = 375;
particleRadius = 2;


// Point emission
emitter[0] = AwpExplosionBubbleEmitter;
emitter[1] = AwpExplosionWaterSparkEmitter;
#16
01/17/2007 (1:31 am)
// Camera Shaking
shakeCamera = false;

// Impulse
impulseRadius = 0.5;
impulseForce = 15;

// Dynamic light
lightStartRadius = 2;
lightEndRadius = 3;
lightStartColor = "0 0.5 0.5";
lightEndColor = "0 0 0";
};

//-----------------------------------------------------------------------------
// Projectile Object

datablock ProjectileData(AwpProjectile)
{
projectileShapeName = "~/data/shapes/soldier/tracer.dts";
directDamage = 20;

explosion = AwpExplosion;

waterExplosion = AwpWaterExplosion;

particleWaterEmitter= AwpAmmoBubbleEmitter;

splash = AwpSplash;

muzzleVelocity = 3000; // default 150
velInheritFactor = 0.3;

armingDelay = 0;
lifetime = 5000;
fadeDelay = 5000;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = true;
gravityMod = 0;

hasLight = true; // default true
lightRadius = 4;
lightColor = "0.5 0.5 0.25";

hasWaterLight = true;
waterLightColor = "0 0.5 0.5";

decals[0] = AwpBulletHoleData;
};

function AwpProjectile::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,"AwpAmmo");

// 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,"Radius",40);
}


//-----------------------------------------------------------------------------
// Ammo Item

datablock ItemData(AwpAmmo)
{
// Mission editor category
category = "Ammo";

// Add the Ammo namespace as a parent. The ammo namespace provides
// common ammo related functions and hooks into the inventory system.
className = "Ammo";

// Basic Item properties
shapeFile = "~/data/shapes/crossbow/ammo.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;

// Dynamic properties defined by the scripts
pickUpName = "Awp bullets";
maxInventory = 20;
};


//--------------------------------------------------------------------------
// Weapon Item. This is the item that exists in the world, i.e. when it's
// been dropped, thrown or is acting as re-spawnable item. When the weapon
// is mounted onto a shape, the AwpImage is used.

datablock ItemData(Awp)
{
// Mission editor category
category = "Weapon";

// Hook into Item Weapon class hierarchy. The weapon namespace
// provides common weapon handling functions in addition to hooks
// into the inventory system.
className = "Weapon";

// Basic Item properties
shapeFile = "~/data/shapes/awp/w_awp.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
emap = true;

// Dynamic properties defined by the scripts
pickUpName = "a Awp";
image = AwpImage;

};
#17
01/17/2007 (1:31 am)
//--------------------------------------------------------------------------
// Awp image which does all the work. Images do not normally exist in
// the world, they can only be mounted on ShapeBase objects.


datablock ShapeBaseImageData(AwpImage)
{
// Basic Item properties
shapeFile = "~/data/shapes/awp/w_awp.dts";
emap = true;

// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
eyeOffset = "0.5 0.7 -0.2"; // default is 0.5 0.4 -0.4

// When firing from a point offset from the eye, muzzle correction
// will adjust the muzzle vector to point to the eye LOS point.
// Since this weapon doesn't actually fire from the muzzle point,
// we need to turn this off.
correctMuzzleVector = false;

// Add the WeaponImage namespace as a parent, WeaponImage namespace
// provides some hooks into the inventory system.
className = "WeaponImage";

// Projectile && Ammo.
item = Awp;
ammo = AwpAmmo;
projectile = AwpProjectile;
projectileType = Projectile;

// 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
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";

// Activating the gun. Called when the weapon is first
// mounted and there is ammo.
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.6;
stateSequence[1] = "Activate";

// Ready to fire, just waiting for the trigger
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "Shoot"; // DEFAULT Fire

// Fire the weapon. Calls the fire script which does
// the actual work.
stateName[3] = "Shoot";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 2.0; // DEFAULT is 0.1
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Shoot";
stateScript[3] = "onShoot"; // MIGHT NOT WORK CHANGE TO onFire
stateSound[3] = AwpFireSound;

// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.05; // DEFAULT IS 0.05
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateSound[4] = AwpReloadSound;

// No ammo in the weapon, just idle until something
// shows up. Play the dry fire sound if the trigger is
// pulled.
stateName[5] = "NoAmmo";
stateTransitionOnAmmo[5] = "Reload";
stateSequence[5] = "NoAmmo";
stateTransitionOnTriggerDown[5] = "DryShoot"; // Fire

// No ammo dry fire
stateName[6] = "DryShoot"; // Fire
stateTimeoutValue[6] = 1.0;
stateTransitionOnTimeout[6] = "NoAmmo";
stateSound[6] = AwpFireEmptySound;
};




//-----------------------------------------------------------------------------

function AwpImage::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;

// Decrement inventory ammo. The image's ammo state is update
// automatically by the ammo inventory hooks.
%obj.decInventory(%this.ammo,1);

// Determin 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));

// Create the projectile object
%p = new (%this.projectileType)() {
dataBlock = %projectile;
initialVelocity = %muzzleVelocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
return %p;
}
#18
01/17/2007 (5:30 am)
Saska, help would come easier and quicker if you didn't post your entire script file. Especially when it's not in code form. If you are just using the AWP weapon, post on the datablocks and functions related to it.

Are you getting any console or syntax errors in console.log?
#19
01/17/2007 (5:51 am)
XD really sorry i forgot all about that i was only suppost to include the particle files and the parameter thing :D and i was in a hurry so sorrry nope no errors in console.log
#20
01/17/2007 (6:32 am)
Yes, after looking through the engine, decals are tied into explosions.

If you go to engine/game/projectile.cc and find the function void Projectile::explode(const Point3F& p, const Point3F& n, const U32 collideType), you'll see what I mean.

Decals are placed during the explosion routine.

I too successfully added decals to the crossbow, but when I took out the explosions, the decals stopped working. When you say the explosions don't come, do they not occur at all? Any console output when you the projectile collides?

Double check your file path for AwpExplosionSparks.textureName

If you can, put break points in Projectile::Explode and in around this chunk of code (do a search):

// It is possible that during the processTick the server may have decided that a hit
         // has occured while the client prediction has decided that a hit has not occured.
         // In this particular scenario the client will have failed to call onCollision and
         // explode during the processTick. However, the explode function will be called
         // during the next packet update, due to the ExplosionMask network bit being set.
         // onCollision will remain uncalled on the client however, therefore no client
         // specific code should be placed inside the function!
         onCollision(rInfo.point, rInfo.normal, rInfo.object);
         explode(rInfo.point, rInfo.normal, objectType );

That last part is in Projectile::processTick()
Page «Previous 1 2