Author Topic: Questions about weapon states presented to you by Paradon.  (Read 3730 times)

I've looked trough the whole server.cs and found nothing mentioning the mouse or firing the projectile.
I'll ask more questions once I've got help with this.
« Last Edit: August 13, 2013, 06:33:35 PM by Paradon »

you will need to take the weaponimage::onFire() function and instead make the code inside get called from armor::ontrigger()

bad stuff
No.

The easiest way to work out how this sort of thing works is to open up Weapon_AkimboGun.cs and see how it does the akimbo firing for the secondary gun. In short, for a given state at index x you want to fire from,
Code: [Select]
stateTransitionOnTriggerUp[x] = "Fire"Then assuming your "Fire" state has a stateScript[] = "OnFire", you're done.

If that explanation was a little over your head, the short-short answer: Find
Code: [Select]
stateTransitionOnTriggerDown[1] = "Fire"; Note that [1] may be a different number. Change the word "Down" to "Up".

No.

The easiest way to work out how this sort of thing works is to open up Weapon_AkimboGun.cs and see how it does the akimbo firing for the secondary gun. In short, for a given state at index x you want to fire from,
Code: [Select]
stateTransitionOnTriggerUp[x] = "Fire"Then assuming your "Fire" state has a stateScript[] = "OnFire", you're done.

If that explanation was a little over your head, the short-short answer: Find
Code: [Select]
stateTransitionOnTriggerDown[1] = "Fire"; Note that [1] may be a different number. Change the word "Down" to "Up".
Thanks.

Now, how do I make it so that the player has to hold the mouse button down for 2 sec before releasing it for the gun to fire? I'm not aware of any weapon that does this, so looking at other peoples code isn't something I can do.

I had a feeling that was coming. I'm going to use plain english so just look at weapon scripts for specific examples of the exact things you need to type into the file.

You'll need "Charging" and "Charged" states (or whatever you wanna call them).

Transition from "Ready" on mouse down to "Charging", and from "Charging" on mouse up to "Ready".
Now clicking will set it to "Charging" and releasing will set it back to "Ready".

Set the timeout value of "Charging" to 2 and the transition on timeout to "Charged". (Do not set wait for timeout to true on "Charging".)
Now holding the mouse for two seconds will set it to "Charged".

Set the on mouse up of "Charged" to "Fire", so that once it's in "Charged", the gun fires when the mouse is released.

This is what I've got, I've been looking at the tf2 sniper script because it does kinda what I want.

Code: [Select]
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "charging";
stateAllowImageChange[1]         = true;
stateSequence[1] = "Ready";

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = chargeGunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = chargeGunShot1Sound;
stateEjectShell[2]       = true;

stateName[3] = "Smoke";
stateEmitter[3] = chargeGunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0.5;
stateSequence[3] = "Reload";
StateTransitionOnTimeout[3] = "ready";

stateName[4] = "Reload";
stateSequence[4]                = "Reload";
stateTransitionOnTriggerUp[4]   = "Ready";

stateName[5] = "Charging";
stateTransitionOnTimeout[5] = "Charged";
stateTimeoutValue[5] = 2;
stateSequence[5] = "Charging";
stateWaitForTimeout[5] = false;

stateName[6]                    = "Charged";
  stateTransitionOnTriggerUp[6]   = "Fire";
stateAllowImageChange[6]        = false;
stateSequence[6]                = "Charged";
stateWaitForTimeout[6] = true;

The problem now is that even if I just press the fire button quick, the gun will fire after 2 sec, though if I hold it down it won't fire until I release it.

you need to add an stateTransitionOnTriggerUp[5] = "Ready"; under the charging state so that if they release the trigger it will reset

you need to add an stateTransitionOnTriggerUp[5] = "Ready"; under the charging state so that if they release the trigger it will reset
Well that was pretty simple.

Next step would be    making it play sounds when it's ready to shoot and when you release the button too early.
I've tried placing
Code: [Select]
stateSound[6] = clickPlantSound;all around the charged state but it didn't do anything. Same for the charging state to see if I could make it play a fail sound but of course it didn't do anything.

This is starting to get out my area of expertise, but just so you know, the order of these things make no difference. If you wanted you could have all the stateName[] fields at the very top, or you could completely randomize all of their ordering so it was a complete mess. You can organize it any way you want that makes sense to you, and you never have to worry about where in state 6 something like the sound needs to go.

Basically blockland loads all of this information from start to finish before it actually tries to do anything with the weapon. So it doesn't matter if the sound name got loaded earlier or later, as long as it's there when the game sees if there's a sound it should be playing.
« Last Edit: August 08, 2013, 02:24:46 PM by Mr. Wallet »

No.

The easiest way to work out how this sort of thing works is to open up Weapon_AkimboGun.cs and see how it does the akimbo firing for the secondary gun. In short, for a given state at index x you want to fire from,
Code: [Select]
stateTransitionOnTriggerUp[x] = "Fire"Then assuming your "Fire" state has a stateScript[] = "OnFire", you're done.

If that explanation was a little over your head, the short-short answer: Find
Code: [Select]
stateTransitionOnTriggerDown[1] = "Fire"; Note that [1] may be a different number. Change the word "Down" to "Up".

Er, yeah.

I've never worked with states and completely forgot those existed.

Would it be possible to do something like stateTransitionOnTimeoutSound = whatever; ?

Code: [Select]
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.15;
stateTransitionOnTimeout[0]     = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1] = "Ready"
stateTransitionOnTriggerDown[1] = "Charging";

stateName[2] = "Charging";
stateTimeoutValue[2] = 2;
stateTransitionOnTriggerUp[2] = "DeCharge";
stateTransitionOnTimeout[2] = "Charged";

stateName[3] = "Charged";
stateTransitionOnTriggerUp[3] = "Fire";

stateName[4] = "DeCharge";
stateTimeoutValue[4] = 0.3;
stateTransitionOnTimeout[4]     = "Ready";

stateName[5] = "Fire";
stateTransitionOnTimeout[5]     = "Smoke";
stateTimeoutValue[5]            = 0.14;
stateFire[5]                    = true;

stateName[6] = "Smoke";
stateTimeoutValue[6]            = 0.5;
StateTransitionOnTimeout[6] = "Ready";
this is the bare structure, add all the emitter and sound crap, if you need more help post or add me on steam or something

Holy stuff I just now realized how the whole state system works.
The only thing stateTransition____ does is set your weapon to another specified state, god damn, things are getting a lot clearer for me.

forget do I feel stupid.

Holy stuff I just now realized how the whole state system works.
The only thing stateTransition____ does is set your weapon to another specified state, god damn, things are getting a lot clearer for me.

forget do I feel stupid.
don't put yourself down, everyone must learn something to become good at it

I changed (copy/pasted) to the code you posted, but the weapon won't show up in the item list when spawning items. It works again if I change back to my old code.