Game Development Community

Whats up with this crazy rifle script?

by Dr. John Nobody · in Torque Game Engine · 06/19/2003 (12:55 am) · 7 replies

Hey, nothing to serious, just have a few questions about the rifle script... first off, you know that smoke that comes out of the weapon when its fired? ya, I hate that, how do you turn it off? I've tried commenting out every reference to smokeParticle in the script and IT WONT DIE! Same thing with that smoke trail that follows the projectile, thats cool sometimes, but I'd really like to turn it off for some weapons, any idea how I'd go about doing all that? I've also tried commenting out the

explosion = RifleExplosion;
particleEmitter = RifleSmokeEmitter;

in the projectile datablock, getting no results, could someone shed some light on what exactly controls this stuff?

Next I have some issues with the projectiles explosion. As a default its set to use particles, and thats cool and everything, but for some of my rifle mods I'd really like to use an animated model as an explosion (so I can have cool shockwave effects and beams of light and stuff), however when I uncomment the references to explosion.dts and add a .dts shape of that name to the rifle folder, it doestn seem to use it, anyone know how you enable this and turn off the particle explosion?

Also, I'm having a little trouble finding the variable which controls a projectiles reload time, I thought it was this

stateTimeoutValue[4] = 0.1;

but that doestn seem to do anything

one last thing, which actualy has nothing to do with the rifle script, does anyone know how to make a cool lense flair looking image? I have a bilboard for a projectile, I'd like to have a cool lense flair energy thing (like a photon torpedo or something) any idea how you'd make the lense flair on a transparent background?


I'd appriciate it if you could answer any or all of these questions (heck, i'd appriciate it if you just read through my post), so thanks :)

#1
06/19/2003 (3:06 am)
Here's a couple sections of the rifle.cs script that will do what you're asking. Notice firerate is really controlled in two areas. Remember to delete the rifle.cs.dso file.

datablock ProjectileData(RifleProjectile)
{
projectileShapeName = "~/data/shapes/rifle/projectile.dts";
explosion = RifleExplosion;
//particleEmitter = RifleSmokeEmitter; // no proj trail


// Fire the weapon. Calls the fire script which does
// the actual work.
stateName[3] = "Fire";
stateTimeoutValue[3] = 0.01; // small=faster
//stateEmitter[3] = RifleFireEmitter;


// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTimeoutValue[4] = 0.01; // small=faster


explosions (need animated dts with "amibient" sequence):

datablock ExplosionData(RifleExplosion)
{
explosionShape= "~/data/shapes/explosions/explosion.dts;
faceViewer = true;
delayMS = 100;
offset = 5.0;
playSpeed = 1.5;
sizes[0] = "0.5 0.5 0.5";
sizes[1] = "0.5 0.5 0.5";
times[0] = 0.0;
times[1] = 1.0;

emitter[0] = RifleExplosionSmokeEmitter;
emitter[1] = RifleExplosionSparkEmitter;
};

I'm actually using multiple subexplosions. I don't think you need to tho.
#2
06/19/2003 (3:14 am)
Thanks Sabrecyd.

My group is now on the process of exporting weapons to DTS and I am already expecting to hit these same problems. Thanks for the info ... it saved me alot of hair pulling. :)

Alex
#3
06/19/2003 (4:31 am)
Thanks Sabrecyd, thats most of what I needed, a couple of quick questions though,

just to be sure, your saying that in order for a .dts model to work as an explosion it needs to have an animation named "ambient"?

also, I still need to turn off the smoke that comes out of the weapon when its fired, anyone know how to do that?

man, I could have sworn I tried that "//particleEmitter = RifleSmokeEmitter; // no proj trail" already, oh well, I'm losing my mind :)

thanks again
#4
06/19/2003 (4:44 am)
Arggggg, thats twice tonight that my post has been resubmitted on its own several minutes after I submitted it... could this have something to do with that forum update last night?
#5
06/19/2003 (1:19 pm)
No problem guys,

yes, animated explosions need an "ambient" animation sequence. It could be changed in explosion.cc to something else if you prefer.

Hmm..I'm not sure why you'd have smoke. The unmodified rifle.cs file doesn't have both a SmokeEmitter and RifleFireEmitter. Just commenting out:

stateEmitter[3] = RifleFireEmitter;

should do the trick. I added a seperate emitter to add smoke (WeaponMuzzleSmokeEmitter). Then I had one emitter for smoke and one for muzzle flash. If you get really frustrated I'd take a look at your rifle.cs file for you if you want.
#6
06/19/2003 (4:38 pm)
Thanks again Sabrecyd

I know this is a little off topic, but I dont really want to start a new thread just for this... does anyone know if you can animate opacity? I'd like to have shockwaves that fade out as they expand
#7
06/19/2003 (4:44 pm)
Thanks again Sabrecyd

I know this is a little off topic, but I dont really want to start a new thread just for this... does anyone know if you can animate opacity? I'd like to have shockwaves that fade out as they expand