Jump to content

Recommended Posts

Hey guys,

 

I wanted to release a short script I've been working on.   This code allows the player to activate the throw-able and then throw it on separate key presses.

So now you can activate any grenade and carry it, then toss it later!   Great for if you want to carry a smoke grenade for cover, hang on to a chemlight or even blow yourself up by hanging on to a live grenade.

 

Known issues

  • Currently the below looks for the "Throw" action key (default of G) and will fire at every press.  To make it possible to switch what your throwing, it was hard coded not to fire if you are pressing "Ctrl".
    • This means if your throw grenade key is "G" and switch grenade is "Ctrl + G", you wont have an issue.  If your switch grenade is "Shift + G", "2xG" or any combination involving the "throw" key and something other than "Ctrl" you will not be able to change what grenade you are throwing.

 

How player's use it

  • Push the throw button once to activate the grenade.
  • Push the throw button again to throw it.

 

How to implement

  1. Add "fn_throw.sqf" to your functions library.
  2. Add the following code to your initPlayerLocal.sqf
    • [] spawn {
      	waituntil {!isnull (finddisplay 46)};
      	(findDisplay 46) displayAddEventHandler ["KeyDown",{
      		if (((_this select 1) in (actionkeys "Throw")) && (_this select 3 isequalto false)) then {
      			call my_fnc_throw; 
      			true;
      		};	
      	}];
      };

      Replace "my_fnc_throw" with the proper name you gave it in your functions library.  If you already have a dedicated keydown handler file, you could migrate/modify the above into it instead.

 

Here is a sample PBO for your enjoyment!

 

Here is fn_throw.sqf.

 

Thank you!

Edited by wyattwic
Updated to V1.1, Removed items from known issues.

Share this post


Link to post
Share on other sites
10 hours ago, foxhound said:

An Armaholic mirror is now available:

news_download_a3_3.png
Wyatt's grenade script v1.0

 

Thanks fox, but I dont consider this release ready for 1.0 status.  Got to knock out those known issues before I call it V1.0 :)

Share this post


Link to post
Share on other sites
Guest

I will fix the versioning with your next update if that is ok with you. I do not want to cause any further confusion now by changing version to those who already downloaded it. With the next update it is easier to change.

Share this post


Link to post
Share on other sites
6 hours ago, foxhound said:

I will fix the versioning with your next update if that is ok with you. I do not want to cause any further confusion now by changing version to those who already downloaded it. With the next update it is easier to change.

It was a joke mate but thanks :)  Good night!

Share this post


Link to post
Share on other sites

Hey guys!  I am working to clean this code up a bit better since I've had more than a few people on my community show interest in it.  

 

I've figured out what was causing it to throw slightly off, but now I am trying to find out how to set the grenade's owner.   Would anyone have any idea on how to set who threw the grenade, so that they could get score for their kills?  I am lost.

Share this post


Link to post
Share on other sites
32 minutes ago, wyattwic said:

Would anyone have any idea on how to set who threw the grenade, so that they could get score for their kills?

setShotParents? needs to be set from the server though.

  • Like 3

Share this post


Link to post
Share on other sites
6 hours ago, Larrow said:

setShotParents? needs to be set from the server though.

 

That worked!!!  No clue how I didn't find that since its description is exactly what I searched. 

 

I'm working on coding a custom key handler for it to eliminate that last known issue, but that may have to wait till Sunday.  Thank you!

Share this post


Link to post
Share on other sites
7 hours ago, Larrow said:

setShotParents? needs to be set from the server though.

Don't mind me, while I'll incorporate this command into a few scripts of mine...

 

Cheers

Share this post


Link to post
Share on other sites

AHA! I see, this is what you posted on the other day huh? Pretty neat. 

Share this post


Link to post
Share on other sites

I've updated it to V1.1,

Changes made -

  • Players now get credit for the kills made with frag grenades.  Thanks to @Larrow!
    • We are now using remoteexec in this script.  If your description.ext has blocking, please allow the "setShotParents" command from client to server.
  • Grenade trajectories have been improved and now more closely match vanilla throws.
    • This also fixed the random "off to the left" throws.

I have not had a chance to make a custom key handler.  My air conditioning messed up this morning and there goes the rest of my weekend.

 

Have fun!  Don't blow yourselves up!

Share this post


Link to post
Share on other sites

i'm sorry, i cant make it work.
i put the code into initPlayerLocal.sqf and the file fn_throw.sqf into mission folder.....dunno what i did wrong!
plz help :)

Share this post


Link to post
Share on other sites
8 hours ago, dlegion said:

i'm sorry, i cant make it work.
i put the code into initPlayerLocal.sqf and the file fn_throw.sqf into mission folder.....dunno what i did wrong!
plz help :)

 

Okay, so this is made to be used in a function library.  See the below article on how to set one up.  

https://community.bistudio.com/wiki/Functions_Library_(Arma_3)#Adding_a_Function

 

The code that goes into initPlayerLocal.sqf should point at the name you give it in the function library.

 

Edit:  This code wasn't made to be ready-make easy bake cake.  Minor assembly is required, but it works great in the end. :)

Share this post


Link to post
Share on other sites

ahh ok !
thanks for the suggestion, i made it work !
its a very nice script !
may i suggest a couple of features that would made of this script the ultimate grenade script ?

right now throw force its not adjustable. i've a found a script from Serena that do exactly this. its very useful to actually place the grenade where you want !
and another veeery nice feature would be grenades re-throw (throw-back) i found this from Zorylias 3D explosives.

really nice work! thanks !
 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×