Multiple emmiters...
by Max Thomas · in Torque Game Engine · 11/12/2004 (11:16 am) · 11 replies
Hello all,
I think I have a fairly simple question this time... Well here I go. I Can't figue out how to have multiple emmiters. For example "I have 5 or 6 nodes down the barrel of my weapon and I want to have them all emmit smoke when I fire the weapon... I couldn't find anything of much help in rifle.cs or from Ken's book tommygun.cs or from crossbow.cs. Any help would be greatly appreciated.
Thanks, Max
I think I have a fairly simple question this time... Well here I go. I Can't figue out how to have multiple emmiters. For example "I have 5 or 6 nodes down the barrel of my weapon and I want to have them all emmit smoke when I fire the weapon... I couldn't find anything of much help in rifle.cs or from Ken's book tommygun.cs or from crossbow.cs. Any help would be greatly appreciated.
Thanks, Max
#2
11/15/2004 (10:20 am)
It sounds like something that would take a c++ change. It's almost certainly not a trivial script change.
#3
11/15/2004 (11:27 am)
Think so? Yeah I guess it must be because there is no instance of the node names in the *.cs files. Any idea how I would go about this?
#4
11/15/2004 (2:26 pm)
You'd probably have to edit the shapebaseimage implementation... If you're not a programmer, it's probably not going to be very easy for you. I'd love to give you a walk through but I simply haven't the time. :-/ Someone else in the community might be able to help you, though.
#5
11/15/2004 (5:12 pm)
Yeah as you prolly can tell I'm not a wiz at programing. I can't even decide what .cc file to use to change this... If you could just give me a pointer that would be great.
#6
function CrossbowImage::onMount(%pos,%obj,%slot)
{
%obj.setImageAmmo(%slot,true);
%p = new ParticleEmitterNode() {
position = %pos;
emitter = "CrossbowFlameEmitter";
dataBlock = ChimneySmokeEmitterNode;
};
MissionCleanup.add(%p);
%obj.mountobject(%p,%slot);
}
Then the weapon propertys then...
datablock ParticleData(CrossbowFlameParticle)
{
dragCoefficient = 1.0;
gravityCoefficient = -2.0;
inheritedVelFactor = 0;
constantAcceleration = 0.0;
lifetimeMS = 300;
lifetimeVarianceMS = 50;
textureName = "~/data/shapes/particles/smoke";
times[0]=0.0;
times[1]=1.0;
colors[0] = "1.5 0.45 0.0 1.0";
colors[1] = "1.5 0.3 0.0 1.0";
sizes[0] = 0.1;
sizes[1] = 0.1;
};
datablock ParticleEmitterData(CrossbowFlameEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 6.0;
velocityVariance = 2.0;
ejectionOffset = 0.5;
thetaMin = 0;
thetaMax = 0;
phiReferenceVel = 0;
phiVariance = 0;
overrideAdvances = false;
particles = CrossbowFlameParticle;
};
Granted I would have a node on my weapon called "CrossbowFlameEmitter" would that work? Please correct me if I'm wrong... I know that I would have to still implament a way a making them go on when I fire but I'll save that for lata.
11/15/2004 (7:39 pm)
Ben, Could I use a datablock like this in *.cs format? I looked around for a little bit and found some examples...function CrossbowImage::onMount(%pos,%obj,%slot)
{
%obj.setImageAmmo(%slot,true);
%p = new ParticleEmitterNode() {
position = %pos;
emitter = "CrossbowFlameEmitter";
dataBlock = ChimneySmokeEmitterNode;
};
MissionCleanup.add(%p);
%obj.mountobject(%p,%slot);
}
Then the weapon propertys then...
datablock ParticleData(CrossbowFlameParticle)
{
dragCoefficient = 1.0;
gravityCoefficient = -2.0;
inheritedVelFactor = 0;
constantAcceleration = 0.0;
lifetimeMS = 300;
lifetimeVarianceMS = 50;
textureName = "~/data/shapes/particles/smoke";
times[0]=0.0;
times[1]=1.0;
colors[0] = "1.5 0.45 0.0 1.0";
colors[1] = "1.5 0.3 0.0 1.0";
sizes[0] = 0.1;
sizes[1] = 0.1;
};
datablock ParticleEmitterData(CrossbowFlameEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 6.0;
velocityVariance = 2.0;
ejectionOffset = 0.5;
thetaMin = 0;
thetaMax = 0;
phiReferenceVel = 0;
phiVariance = 0;
overrideAdvances = false;
particles = CrossbowFlameParticle;
};
Granted I would have a node on my weapon called "CrossbowFlameEmitter" would that work? Please correct me if I'm wrong... I know that I would have to still implament a way a making them go on when I fire but I'll save that for lata.
#7
Take note of how every state (1-6) has a "stateName[n]". notice some use "stateTimeoutValue[n]" and some don't. Some use "stateSound[n]" and some don't. Which states you use depends on your need and the mode of weapon operation you desire. Now, as for your emitters, you can add them to every state as well if you wish, or just the states where you want emissions. How do you do that? Simple, you add in the appropriate settings based on these possibilities.....(note: I dropped state ZERO because of the character limit in posts)
As you can see, you have options for stateEmitter, stateEmitterTime, and stateEmitterNode as well. That should get you all you need to shoot smoke from your barrel when you fire.
11/15/2004 (7:51 pm)
You don't need to modify the engine to get what you want, you just need to script it correctly. Every state has the same conditions possible and how you use them is up to you. Lets look at a the crossbow for example......// Activating the gun. Called when the weapon is first // mounted and there is ammo. stateName[1] = "Activate"; stateTransitionOnTimeout[1] = "Ready"; stateTimeoutValue[1] = 0.1; stateSequence[1] = "Activate"; // Ready to fire, just waiting for the trigger stateName[2] = "Ready"; stateTransitionOnNoAmmo[2] = "NoAmmo"; stateTransitionOnTriggerDown[2] = "Fire"; // Fire the weapon. Calls the fire script which does // the actual work. stateName[3] = "Fire"; stateTransitionOnTimeout[3] = "Reload"; stateTimeoutValue[3] = 0.1; stateFire[3] = true; stateRecoil[3] = LightRecoil; stateAllowImageChange[3] = false; stateSequence[3] = "Fire"; stateScript[3] = "onFire"; stateSound[3] = CrossbowFireSound; // Play the relead animation, and transition into stateName[4] = "Reload"; stateTransitionOnNoAmmo[4] = "NoAmmo"; stateTransitionOnTimeout[4] = "Ready"; stateTimeoutValue[4] = 0.1; stateAllowImageChange[4] = false; stateSequence[4] = "Reload"; stateEjectShell[4] = true; stateSound[4] = CrossbowReloadSound; // 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] = "DryFire"; // No ammo dry fire stateName[6] = "DryFire"; stateTimeoutValue[6] = 1.0; stateTransitionOnTimeout[6] = "NoAmmo"; stateSound[6] = CrossbowFireEmptySound;
Take note of how every state (1-6) has a "stateName[n]". notice some use "stateTimeoutValue[n]" and some don't. Some use "stateSound[n]" and some don't. Which states you use depends on your need and the mode of weapon operation you desire. Now, as for your emitters, you can add them to every state as well if you wish, or just the states where you want emissions. How do you do that? Simple, you add in the appropriate settings based on these possibilities.....(note: I dropped state ZERO because of the character limit in posts)
stateName[i]
stateTransitionLoaded[i]
stateTransitionNotLoaded[i]
stateTransitionAmmo[i]
stateTransitionNoAmmo[i]
stateTransitionTarget[i]
stateTransitionNoTarget[i]
stateTransitionWet[i]
stateTransitionNotWet[i]
stateTransitionTriggerUp[i]
stateTransitionTriggerDown[i]
stateTransitionTimeout[i]
stateWaitForTimeout[i]
stateTimeoutValue[i]
stateFire[i]
stateEjectShell[i]
stateEnergyDrain[i]
stateAllowImageChange[i]
stateScaleAnimation[i]
stateDirection[i]
stateLoaded[i] = StateData::IgnoreLoaded;
stateSpin[i] = StateData::IgnoreSpin;
stateRecoil[i] = StateData::NoRecoil;
stateSequence[i]
stateSequenceRandomFlash[i]
stateSound[i]
stateScript[i]
stateEmitter[i]
stateEmitterTime[i]
stateEmitterNode[i]
stateIgnoreLoadedForReady[i]As you can see, you have options for stateEmitter, stateEmitterTime, and stateEmitterNode as well. That should get you all you need to shoot smoke from your barrel when you fire.
#8
11/16/2004 (1:43 am)
I've tried that before myself but never seemed to work right.. If ya do have it workin right, post what ya did for it! ;)
#9
11/16/2004 (5:44 am)
Thanks very much guys. Gonzo helpful as usual ;). Thanks, I'll go and try that code out for a bit see if I can get it to work.
#10
11/16/2004 (7:04 am)
Oopsy double post
#11
Thanks, Max
11/16/2004 (7:07 am)
Yay, Thanks Gonzo it kinda works... One prob though It is beein kinda tempremental and only wants to eject the particles from the "muzzlePoint" I can't get it to eject from other nodes... And can you please tell me how to set it up to eject it from a few nodes at the same time?Thanks, Max
Torque Owner Max Thomas