Jump to content
Sign in to follow this  
twisted

switch weapon automatically

Recommended Posts

Hi

i was hoping that some experienced modder could please help me.

basically i want to swap out one weapon held by a player for another - and to have this activated by selection of a menu command (that side menu that gives options like eject, get out, etc)

the reason i want to do this is to implement bipods that actually affect accuracy. my idea is this. using the rpk74 for example. have 2 models - one with bipod up and one with bipod deployed. define bipod up's prone recoil as a lowish number and then define bipod deployed number as an even lower recoil.

player is given weapon with bipod up as default - but when the option to deploy bipod is made then the weapon is swapped out for the deployed bipod version with it's lower recoil value. to prevent people just walking around with bipod extended i'll raise the dexterity value of the weapon to make it more sluggish to move with standing/crouching.

the trick is making this instant and not noticed by player. Also carrying the weapons current ammo count across and vice versa.

eventually i would want a bipod down animation but at the moment i'd like a way to incorpoarate the functionality.

I'd also like to know if there's a way to constrain movement of a player when prone from maybe -30 to +30 degrees.

this would mean prone player with the weapon would not be able to spin around on his stomach like currently when bipod is deployed.

eventually i'd like to apply this for all machineguns with bipods as well as rifles with deployable bipods.

Share this post


Link to post
Share on other sites

some guy made a script to carry two primary weapons and

switch weapons. that should be more or less what you need.

try searching on armaholic

Share this post


Link to post
Share on other sites

thanks mate. i just needed a point in the direction and this is good. cheers. smile_o.gif

Share this post


Link to post
Share on other sites

You can make a script that checks if a unit carries a particular weapon, f.ex rpk74, and check the what anim the unit uses. If the unit have a rpk74 and is prone you remove the weapon with the bipod up and addweapon a weapon with the bipod down.

It will take some research for you to find all the anims and to write a script, but it should be possible. There might be some potential problems with magasines. How many bullets did the unit have before the weaponswitch...

Share this post


Link to post
Share on other sites

why not do it through an action?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

player addAction ["Bipod Down", "\Your Weapon\bipod.sqf", [0]];

of course if you want it in your addon, you would have to define a Class UserActions in your config.

bipod.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_case = ((_this select 3) select 0);

_user = _this select 1;

switch (_case) do

{

case 0:

{

if (!("Weapon_Bipod_Up" in weapons _user)) exitWith {};

_user removeWeapon "Weapon_Bipod_Up";

_user AddWeapon "Weapon_Bipod_down";

_user removeAction (_this select 2);

_user addAction ["Bipod Up", "\Your Weapon\bipod.sqf", [1]];

};

case 1:

{

if (!("Weapon_Bipod_down" in weapons _user)) exitWith {};

_user removeWeapon "Weapon_Bipod_Down";

_user AddWeapon "Weapon_Bipod_Up";

_user removeAction (_this select 2);

_user addAction ["Bipod Down", "\Your Weapon\bipod.sqf", [0]];

};

};

------

Of course replacing the Weapon_Bipod_Up wit the classname of the weapon with the bipod up, and vise versa hehe

Share this post


Link to post
Share on other sites

The way to limit the character's movement could only be achieved by making a separate RPK with bipod static MG. This way you can switch the player out when prone, remove his RPK and throw him in the machinegun. This method also lets you give a custom recoil to the weapon.

The main issue here is getting out of the "MG" and moving on - it might look dodgy, will most likely require a custom addaction, and will definitely break stock AI.

However my scripting is extremely rusty from long non-use, so perhaps you have some tools up your sleeve!

Share this post


Link to post
Share on other sites
carrying the weapons current ammo count across and vice versa.

I think this will be hard. As it is hot-swapping weapons in

game causes the weapon to automatically be reloaded with

the next magazine in the inventory. Despite searching and

hacking about at it I myself have not found any way to set a

particular ammo count onto a weapon. I wonder if anyone

else has been able to do it. As it is, having a bipod lowered

by swapping models on a menu command is trivially easy to do

(I can post some example code if required). It's this annoying

"automatic reload" that really detracts from it.

Share this post


Link to post
Share on other sites
why not do it through an action?

thank you. what was easy for you was not easy for me. your help is appreciated.

Thank you to all who have responded to this post - almost every single reply has helped.

and it seems the weaponswitching addon referenced by Q helps with the carry over of the ammo counts. it seems like it does this for its own weapons but i am pretty slow at picking this kind of thing up.

Share this post


Link to post
Share on other sites

no problem.

Yes, basically, what happens with the ammo is that, when you have a weapon, and its magazines, and you drop/remove that weapon, whilst keeping the magazines for it. Any time you pick a new weapon up, ArmA sees those mags and no weapon to match it too, so it automatically drops them.

Where as, if you remove/add the same type of weapon, the magazines will not move.

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
Sign in to follow this  

×