Author Topic: Rapid fire? Semi Auto?  (Read 5525 times)

Okay.. Sorry about bothering again, But I need to sort things out cause I don't know how to make a weapon semi-auto or auto.. Or at least I don't find a switch in the cs file.

If I'm right it's gonna be here somewhere right?

Quote
// Initial start up state

   stateName[0]                        = "Activate";
   stateTimeoutValue[0]                = 0.32;
   stateTransitionOnTimeout[0]          = "Equip";
   StateSequence[0]         = "Ready";
   StateSound[0]            = "P250E";
   stateName[1]                        = "Ready";
   stateTransitionOnNoAmmo[1]          = "Reload";
   stateTransitionOnTriggerDown[1]     = "Fire";
   stateAllowImageChange[1]            = true;

    stateName[2]                        = "Equip";
   stateTimeoutValue[2]                = 0.20;
   stateTransitionOnTimeout[2]          = "LoadCheckA";
   StateSequence[2]         = "Equip";
   StateSound[2]            = "P250E";
   
   stateName[3]                       = "Fire";
   stateTransitionOnTimeout[3]        = "Delay";
   stateTimeoutValue[3]               = 0.00;
   stateFire[3]                       = true;
   stateAllowImageChange[3]           = false;
   stateSequence[3]                   = "Fire";
   stateScript[3]                     = "onFire";
   stateEjectShell[3]               = true;
   stateEmitter[3]            = gunFlashEmitter;
   stateEmitterTime[3]         = 0.05;
   stateEmitterNode[3]         = "muzzleNode";
   stateWaitForTimeout[3]         = true;
   StateSequence[3]         = "Fire";
   stateSound[3]            = P250Fire;

   stateName[4]            = "Delay";
   stateTransitionOnTimeout[4]        = "FireLoadCheckA";
   stateTimeoutValue[4]               = 0.1;
   stateEmitter[4]            = gunSmokeEmitter;
   stateEmitterTime[4]         = 0.5;
   stateEmitterNode[4]         = "muzzleNode";

Things go slow here don't they?

yes especially in this board



I don't see a "FireLoadCheckA" state in there anywhere, but Delay calls for it on timeout. Is that the whole states part of the script?

to make a weapon full auto basically what you need to do is check if the player is still holding the trigger down and then split the image states from there, so after your fire state you want to check if the gun should fire again...

Code: [Select]
stateTransitionOnTriggerDown[#] = "Fire";
but what if the player is not holding the trigger down? you want to switch to a state that can put the gun back into a "neutral state" so we do this...
Code: [Select]
stateTimeoutValue[#] = 0.2; //some short amount of time
stateTransitionOnTimeout[#] = "Ready";
basically what this does is, if the trigger is not being held down it sends the gun back to the neutral state between shots, your code block should look something like this...

Code: [Select]
stateName[#] = "TriggerCheck";
stateTimeoutValue[#] = 0.2;
stateTransitionOnTimeout[#] = "Ready";
stateTransitionOnTriggerDown[#] = "Fire";

your going to want to trigger this code sometime after the weapon fires, in your case, based off of what code you gave us, you excluded or deleted some blocks of code, give us the whole fire secuence of the gun and i might be able to show you exactly where to put the code i just gave you...

to make it semi auto just simply remove the
Code: [Select]
stateTransitionOnTriggerDown[#] = "Fire";
and the gun should just timeout back to a ready state.
« Last Edit: September 19, 2014, 07:05:18 PM by zombekillz »

Quote
stateName[0]                        = "Activate";
   stateTimeoutValue[0]                = 0;
   stateTransitionOnTimeout[0]          = "Equip";
   StateSequence[0]         = "Ready";
   StateSound[0]            = "P250E";
   stateName[1]                        = "Ready";
   stateTransitionOnNoAmmo[1]          = "Reload";
   stateTransitionOnTriggerDown[1]     = "Fire";
   stateAllowImageChange[1]            = true;

    stateName[2]                        = "Equip";
   stateTimeoutValue[2]                = 0.70;
   stateTransitionOnTimeout[2]          = "LoadCheckA";
   StateSequence[2]         = "Equip";
   StateSound[2]            = "P250Equip";
   
   stateName[3]                       = "Fire";
   stateTransitionOnTimeout[3]        = "Ready";
   stateTimeoutValue[3]               = 0.14;
   stateFire[3]                       = true;
   stateAllowImageChange[3]           = false;
   stateSequence[3]                   = "Fire";
   stateScript[3]                     = "onFire";
   stateEjectShell[3]               = true;
   stateEmitter[3]            = gunFlashEmitter;
   stateEmitterTime[3]         = 0.05;
   stateEmitterNode[3]         = "muzzleNode";
   stateWaitForTimeout[3]         = true;
   StateSequence[3]         = "Fire";
   stateSound[3]            = P250Fire;

   stateName[4]            = "Delay";
   stateTransitionOnTimeout[4]        = "FireLoadCheckA";
   stateTimeoutValue[4]               = 0.1;
   stateEmitter[4]            = gunSmokeEmitter;
   stateEmitterTime[4]         = 0.5;
   stateEmitterNode[4]         = "muzzleNode";
   
   //Torque switches states instantly if there is an ammo/noammo state, regardless of stateWaitForTimeout

   stateName[5]            = "LoadCheckA";
   stateScript[5]            = "onLoadCheck";
   stateTimeoutValue[5]         = 0.01;
   stateTransitionOnTimeout[5]      = "LoadCheckB";
   
   stateName[6]            = "LoadCheckB";
   stateTransitionOnAmmo[6]      = "Ready";
   stateTransitionOnNoAmmo[6]      = "ReloadWait";
   
   stateName[7]            = "ReloadWait";
   stateTimeoutValue[7]         = 0.3;
   stateTransitionOnTimeout[7]      = "Reload";
   stateWaitForTimeout[7]         = true;
   
   stateName[8]            = "Reload";
   stateTimeoutValue[8]         = 1.3;
   stateScript[8]            = "onReloadStart";
   stateTransitionOnTimeout[8]      = "ReloadB";
   stateWaitForTimeout[8]         = false;
   StateSequence[8]         = "Reload";
   stateSound[8]            = P250R;

   stateName[9]            = "ReloadB";
   stateTimeoutValue[9]         = 0;
   stateTransitionOnTimeout[9]      = "Reloaded";
   stateWaitForTimeout[9]         = false;
   StateSequence[9]         = "Reload2";
   stateSound[9]            = P250CI;
   
   stateName[10]            = "Reloaded";
   stateTimeoutValue[10]         = 0.05;
   stateScript[10]            = "onReloaded";
   stateTransitionOnTimeout[10]      = "Ready";
   stateSound[10]            = P250ClipOut;

   stateName[11]             = "Smoke";
   stateEmitter[11]         = gunSmokeEmitter;
   stateEmitterTime[11]         = 0.3;
   stateEmitterNode[11]         = "muzzleNode";
   stateTimeoutValue[11]         = 0.2;
   stateTransitionOnTimeout[11]      = "Ready";
   stateTransitionOnTriggerDown[11]   = "Fire";
   
   stateName[12]             = "ReloadSmoke";
   stateEmitter[12]         = gunSmokeEmitter;
   stateEmitterTime[12]         = 0.3;
   stateEmitterNode[12]         = "muzzleNode";
   stateTimeoutValue[12]         = 0.2;
   stateTransitionOnTimeout[12]      = "Reload";

   stateName[13]            = "FireLoadCheckA";
   stateScript[13]            = "onLoadCheck";
   stateTimeoutValue[13]         = 0.01;
   stateTransitionOnTimeout[13]      = "FireLoadCheckB";
   
   stateName[14]            = "FireLoadCheckB";
   stateTransitionOnAmmo[14]      = "Smoke";
   stateTransitionOnNoAmmo[14]      = "ReloadSmoke";

Here's all the code for you. I also experienced that the reload sound comes after the reload.. Not during it.

this weapon appears to be semi automatic, so add this:
Code: [Select]
stateName[15] = "TriggerCheck";
stateTimeoutValue[15] = 0.2;
stateTransitionOnTimeout[15] = "Ready";
stateTransitionOnTriggerDown[15] = "Fire";

at the end of your code

and in blocks 10 and 11 replace the

Code: [Select]
stateTransitionOnTimeout[##] = "Ready";
with

Code: [Select]
stateTransitionOnTimeout[##] = "TriggerCheck";
and obviously replace the ## signs with the proper sequence number for that block, when your done your code should be full auto, but i did a really quick job of that so it might not work as well as advertised, just try it...

and also remember to think about why you are taking these steps and the logic behind them, its the best way to learn for yourself!

oh yea, and as to why your reload sounds are messed up, im not sure, try opening the sounds in audacity and look for a long silent delay in the audio... that's probably whats happening, nothing script related.

oh yea, and as to why your reload sounds are messed up, im not sure, try opening the sounds in audacity and look for a long silent delay in the audio... that's probably whats happening, nothing script related.

Not really the problem. I use FL Studio and when I open the file it goes fine. I adjusted the reload too and it always came when the reload stopped. Right in that exact point.

this weapon appears to be semi automatic, so add this:
Code: [Select]
stateName[15] = "TriggerCheck";
stateTimeoutValue[15] = 0.2;
stateTransitionOnTimeout[15] = "Ready";
stateTransitionOnTriggerDown[15] = "Fire";

at the end of your code

and in blocks 10 and 11 replace the

Code: [Select]
stateTransitionOnTimeout[##] = "Ready";
with

Code: [Select]
stateTransitionOnTimeout[##] = "TriggerCheck";
and obviously replace the ## signs with the proper sequence number for that block, when your done your code should be full auto, but i did a really quick job of that so it might not work as well as advertised, just try it...

and also remember to think about why you are taking these steps and the logic behind them, its the best way to learn for yourself!

Also we're talking about a pistol, And it's not semi-automatic.

oops, i guess i forgot about ontriggerUp

add this instead of what i said earlier...

Code: [Select]
stateName[15] = "TriggerCheck";
stateTransitionOnTriggerUp[15] = "Ready";

i kinda overlooked that possibility...

oops, i guess i forgot about ontriggerUp

add this instead of what i said earlier...

Code: [Select]
stateName[15] = "TriggerCheck";
stateTransitionOnTriggerUp[15] = "Ready";

i kinda overlooked that possibility...

I actually took the code from a Thompson SMG, And thanks for the help so. One more question. The code is there, Yet it doesn't run out of ammo but reloads when I press R, Why is that?

Code: [Select]
stateName[15] = "TriggerCheck";
stateTransitionOnTriggerUp[15] = "Ready";

And is still Automatic.