ArmorPiercing Projectiles + (Update: BUGFIX)
by CSMP · 08/21/2009 (1:03 pm) · 13 comments
This has been created and tested with TGE 1.5.2 with the intent of having all the features Multiplay Compatible and ease of installation with Stock or Modded TGE.
Download AP Projectile + Source Files Here:
[url]http://torque.abigholeintheweb.com/public_system/useruploads/AP Projectiles Plus.zip[/url]
(Thanks to eb for the Unofficial Torque Public File System!)
This Resource includes:
Armor Piercing Rounds (w/ Decals)
Projectile Spread (Optionally Speed Based w/ Pre-Installed Multi Postion Resource)
Explode On Water (Surface)
Player Explosion (ex. Blood)
Vehicle Explosion (ex. Metal)
Credits go out to:
Armor Piercing was taken out of Ron Nelson's "Enhanced Projectiles" resource (Enhanced Projectiles resource not Multiplay compatible)
Water Explosions have been taken from Josh Moore's "Projectiles Explode on Water Impact" resource,
Projectile Spread was taken from Daniel Neilsen's "Projectile Spread and Shotguns" resource.
Vehicle/Player Explosions were taken from Thomas Tong's "Player Damage Explosion" resource.
Bullet Decals were taken from Tim Heldna's "Bullet Hole Decals" resource.
After you have installed the Projectile.cc and .h into your /engine/game/ folder and added it into your C++ Project, Compile and continue to the Script changes below:
Inside your "datablock ProjectileData(YourBullet)"
After "datablock ShapeBaseImageData(YourWeaponImage)"
Create a Decals.cs file and add:
inside your game.cs file add: (Make sure this is exec'd BEFORE your weapons scripts!!!)
Note: To keep this working for long-distance or slow-moving projectiles apply this fix:
http://www.garagegames.com/community/forums/viewthread/17909
Note: To keep this working for long-distance or slow-moving projectiles apply the fix!
I hope this helps!
If anyone has any problems let me know and I'll try to help you as much as I can. :)
Download AP Projectile + Source Files Here:
[url]http://torque.abigholeintheweb.com/public_system/useruploads/AP Projectiles Plus.zip[/url]
(Thanks to eb for the Unofficial Torque Public File System!)
This Resource includes:
Armor Piercing Rounds (w/ Decals)
Projectile Spread (Optionally Speed Based w/ Pre-Installed Multi Postion Resource)
Explode On Water (Surface)
Player Explosion (ex. Blood)
Vehicle Explosion (ex. Metal)
Credits go out to:
Armor Piercing was taken out of Ron Nelson's "Enhanced Projectiles" resource (Enhanced Projectiles resource not Multiplay compatible)
Water Explosions have been taken from Josh Moore's "Projectiles Explode on Water Impact" resource,
Projectile Spread was taken from Daniel Neilsen's "Projectile Spread and Shotguns" resource.
Vehicle/Player Explosions were taken from Thomas Tong's "Player Damage Explosion" resource.
Bullet Decals were taken from Tim Heldna's "Bullet Hole Decals" resource.
After you have installed the Projectile.cc and .h into your /engine/game/ folder and added it into your C++ Project, Compile and continue to the Script changes below:
Inside your "datablock ProjectileData(YourBullet)"
// / / AP + Projectiles / / playerExplosion = BulletBloodExplosion; //need your own blood explosion here vehicleExplosion = BulletMetalExplosion; //need your own vehicle explosion here decals[0] = medGenericDecal1; //these are defined in a decals.cs file you create later decals[1] = medGenericDecal2; decals[2] = medGenericDecal3; decals[3] = medGenericDecal4; decals[4] = medGenericDecal3; decals[5] = medGenericDecal2; pierceOffset = "1 1 1"; explodeOnWater = true; // / / AP + Projectiles / /
After "datablock ShapeBaseImageData(YourWeaponImage)"
//-----------------------------------------------------------------------------
// Functions
function YourWeaponImage::onFire(%this, %obj, %slot) //replace "YourWeapon" with yourweapon
{
// Decrease the weapons ammo on fire
%obj.decInventory(%this.ammo,1);
// Get the type of projectile we are gonna fire
%projectile = %this.projectile;
// if you are using the MultiPos resource then adjust these Velocity values accordingly...
// its assumed that with the MultiPos resource you have differant speeds for each Pos...
if( VectorLen(%obj.getVelocity()) > 3 )
%SpeedSpread = (14.0 / 1000);
else if ( VectorLen(%obj.getVelocity()) > 0.9 )
%SpeedSpread = (10.0 / 1000);
else if ( VectorLen(%obj.getVelocity()) > 0.1 )
%SpeedSpread = (7.0 / 1000);
else // if not using the MultiPosition resource then delete the entire if statement above...
%SpeedSpread = (2.0 / 1000);
// Get the weapons projectile spread and ensure it is never 0
// (we need some spread direction even if it is extremely tiny)
%spread = %SpeedSpread;
%spread = %spread $= "" ? 0.001 : %spread;
%spread = %spread <= 0 ? 0.001 : %spread;
// Determine if we are using a shotgun class weapon or not
// If we are using a shotgun, set the number of projectiles we are going to fire to 12
%shellcount = 1;
if(%this.isShotGun)
%shellcount = 12;
// Create each projectile and send it on its way
for(%shell=0; %shell<%shellcount; %shell++)
{
// Get the muzzle vector. This is the dead straight aiming point of the gun
%vector = %obj.getMuzzleVector(%slot);
// Get our players velocity. We must ensure that the players velocity is added
// onto the projectile
%objectVelocity = %obj.getVelocity();
// Determine scaled projectile vector. This is still in a straight line as
// per the default example
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
// Determine our random x, y and z points in our spread circle and create
// a spread matrix.
%x = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
// Alter our projectile vector with our spread matrix
%velocity = MatrixMulVector(%mat, %velocity);
// Create our projectile
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
isArmorPiercing = true; //this is the original bullet
};
MissionCleanup.add(%p);
}
return %p;
}
function YourBullet::onPierce(%this,%obj,%startPos,%startVel)//replace "YourBullet" with yourbullet
{
//Put together a dummy projectile
//%this = projectile's datablock
//%obj = the projectile instance
// Create the projectile object;
%weaponImage = %obj.sourceObject.getMountedImage($WeaponSlot);
%p = new (%weaponImage.projectileType)() {
dataBlock = %this;
initialVelocity = %startVel;
initialPosition = %startPos;
sourceObject = %obj.sourceObject;
sourceSlot = %obj.sourceSlot;
client = %obj.client;
isArmorPiercing = false; //this is the second bullet...
};
MissionCleanup.add(%p);
return %p;
}Create a Decals.cs file and add:
// Medium Bullet Decal
datablock DecalData(medGenericDecal1)
{
sizeX = 0.07;
sizeY = 0.07;
textureName = "~/data/textures/particles/bullethole";
};
datablock DecalData(medGenericDecal2 : medGenericDecal1)
{
sizeX = 0.09;
sizeY = 0.09;
//textureName = "~/data/textures/particles/bullethole"; //uncomment these to have multi decals...
};
datablock DecalData(medGenericDecal3 : medGenericDecal1)
{
sizeX = 0.08;
sizeY = 0.08;
//textureName = "~/data/textures/particles/bullethole";
};
datablock DecalData(medGenericDecal4 : medGenericDecal1)
{
sizeX = 0.05;
sizeY = 0.05;
//textureName = "~/data/textures/particles/bullethole";
};inside your game.cs file add: (Make sure this is exec'd BEFORE your weapons scripts!!!)
exec("./decals.cs");Note: To keep this working for long-distance or slow-moving projectiles apply this fix:
http://www.garagegames.com/community/forums/viewthread/17909
Note: To keep this working for long-distance or slow-moving projectiles apply the fix!
I hope this helps!
If anyone has any problems let me know and I'll try to help you as much as I can. :)
About the author
Alpha Project Website: http://csmp.angelfire.com
#2
08/21/2009 (8:45 pm)
Hmm, dumping this in TGEA 1.8.1 almost worked, except it keeps bugging me for particleEngine.h - which as far as i can figure out was replaced by particleEmitter.h ? (probably wrong...) does anyone know what the right file to include is?
#3
08/21/2009 (10:12 pm)
Nice resource! I get tired of hearing this, but I must say it's good to see people still using TGE! ;)
#4
08/22/2009 (5:21 am)
mmm, got this into T3D without too many tears. sweet
#5
making this work in T3D, what would you think should be done to do it in TGEA 1.8.1??
like my previous post stated i cant seem to find the replacement for particleEngine...
08/22/2009 (9:54 am)
@deepscratch;making this work in T3D, what would you think should be done to do it in TGEA 1.8.1??
like my previous post stated i cant seem to find the replacement for particleEngine...
#6
08/22/2009 (11:42 am)
particleEmitter
#7
08/22/2009 (12:18 pm)
I'm glad you all found this useful!
#8
Also, the armor piercing rounds code I did in that version was way to difficult to use for anyone less than an experienced programmer. The newer version has your pierce depths seperated for player characters and walls and are adjustable within the datablocks. That way you can adjust according to your own needs.
I will have my new enhanced projectiles resource out by next week at the latest. It has a ton more than the old version and the networking is fixed.
08/25/2009 (6:55 pm)
Well I can only say I usually like to be asked for permission before releasing another resource based upon my work. Also, the armor piercing rounds code I did in that version was way to difficult to use for anyone less than an experienced programmer. The newer version has your pierce depths seperated for player characters and walls and are adjustable within the datablocks. That way you can adjust according to your own needs.
I will have my new enhanced projectiles resource out by next week at the latest. It has a ton more than the old version and the networking is fixed.
#9
Since you said that the new resource would not be backwards compatible from TGEA, I decided a working TGE resource would be in order.
I am really sorry if you feel I have somehow cheated you for credit...
I specifically and clearly credited the original resource and author for each feature I used and given the nature I did not feel I had to notify every author of every resource used for permission.
I hope this doesnt create any unneeded animosity between us as I have looked up to you many times in your works, and you have provided help in many other areas aswell in either the form of direct help or already created threads that have helped me based on your findings.
It is noted that if the situation happens again, I will ask for permission first. :)
08/25/2009 (10:36 pm)
@Ron: Sorry, but it really seemed like you were ignoring me when I had problems with your resource, considering I was getting no response from you about anything and it was my second time installing your resource and running into problems, it really pissed me off that I couldnt get it working given all the changes I had already made... again.Since you said that the new resource would not be backwards compatible from TGEA, I decided a working TGE resource would be in order.
I am really sorry if you feel I have somehow cheated you for credit...
I specifically and clearly credited the original resource and author for each feature I used and given the nature I did not feel I had to notify every author of every resource used for permission.
I hope this doesnt create any unneeded animosity between us as I have looked up to you many times in your works, and you have provided help in many other areas aswell in either the form of direct help or already created threads that have helped me based on your findings.
It is noted that if the situation happens again, I will ask for permission first. :)
#10
even though this probably aint the right place to ask but will the new and updated resource be compatible with TGEA 1.8.1?
08/26/2009 (6:17 am)
@Ron:even though this probably aint the right place to ask but will the new and updated resource be compatible with TGEA 1.8.1?
#11
Details: projectile impact before 7ticks the projectile's %weaponImage variable returns the SourceID correctly, afterward it returns world coords and shows 2 errors...
Bug Fix:
In Projectile.cc search for this code block around line #830
and comment out the mSourceObjectId to look like this:
08/27/2009 (6:17 pm)
Bug Report:Details: projectile impact before 7ticks the projectile's %weaponImage variable returns the SourceID correctly, afterward it returns world coords and shows 2 errors...
common/scripts/server/weapons/rpd.cs (584): Unable to find object: '0' attempting to call function 'getMountedImage' common/scripts/server/weapons/rpd.cs (598): Unable to instantiate non-conobject class . Set::add: Object "0" doesn't exist
Bug Fix:
In Projectile.cc search for this code block around line #830
if(mSourceObject && mCurrTick > SourceIdTimeoutTicks)
{
mSourceObject = 0;
mSourceObjectId = 0;
}and comment out the mSourceObjectId to look like this:
if(mSourceObject && mCurrTick > SourceIdTimeoutTicks)
{
mSourceObject = 0;
//mSourceObjectId = 0;
}
#12
Sebastian H - Yes is will be for both TGEA 1.81 and TGE. I do not own T3D so I will not be doing an update for that version. However, I have already given deepscratch permission to release a T3D version when I release it. I will probably give it to him first so it won't take so long.
09/11/2009 (7:24 pm)
CSMP - Thats fine. Oh and my new resource WILL be TGE compatible.Sebastian H - Yes is will be for both TGEA 1.81 and TGE. I do not own T3D so I will not be doing an update for that version. However, I have already given deepscratch permission to release a T3D version when I release it. I will probably give it to him first so it won't take so long.
#13
P.S. glad your working on a TGE compatible version.(even if it doesnt have all the cool TGEA stuff included!)
09/11/2009 (8:58 pm)
Awesome, whenever its released I'll check it out!P.S. glad your working on a TGE compatible version.(even if it doesnt have all the cool TGEA stuff included!)
Torque 3D Owner Hans Cremers