Author: wyattwic
Author Website:

Requirements: No addons required

Version: 1.1

Short description: 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!

Date: 2017-05-01 09:44


Comments: (0)
Rating:



 



Wyatt's grenade script

by
wyattwic


Description:
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! Warning: this script will not trigger a fired event handler of any kind.



Installation / Usage:
For usage instructions and information of how to use the Wyatt's grenade script please refer to the included documentation and/or example mission.

How to implement
Add "fn_throw.sqf" to your functions library.
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.

To use it, tap your grenade key once to activate the grenade. Tap it again to throw.
Double tapping it should immediately throw it.

You are able to throw another grenade as soon as the selected throwable appears in the HUD again. You dont have to wait for it to stop being red.


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", or any combination involving the "throw" key and something other than "Ctrl" you will not be able to change what grenade you are throwing.
I would love feedback on how to fix this!
Occasionally it will throw slightly to the left. Not enough to effect game play, but enough to be noticeable.
If anyone could provide suggestions I would love feedback. I am not sure what causes it to be intermittently accurate, but it seems to only happen when stationary.
Untested - I am fairly sure the player who threw it may not get credit for its kill. Our server doesn't track score or show who-killed-who, so I didn't get a chance to work on that much.
If this is the case, I would love suggestions on how to make it possible.


Changelog:
v1.1
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.

v1.0


Forum topic:
- BI forums




Enable javascript to be able to download from Armaholic please!



Tags: Action,   Animation,   Enhace,   Grenade,   Script,   Throw,   Throw-Able