Jump to content
Sign in to follow this  
AnimalMother92

Use actions added to a backpack while wearing it

Recommended Posts

Ok so what I'm trying to do is have actions added to a unit's backpack, as opposed to the unit itself, but I want to be able to access the actions while the backpack is being worn.

I have my unit "SF1"

removeBackpack this; this addBackpack "US_UAV_Pack_EP1";

And my init.sqf

(unitBackpack SF1) addAction["Request Missile (Hellfire)","launchMissile.sqf",[sF1, missilestart,"M_Hellfire_AT",200]];
(unitBackpack SF1) addAction["Request Bomb (GBU)","launchMissile.sqf",[sF1, missilestart,"Bo_GBU12_LGB",200]];

So what happens right now is that if I take off the backpack I can access the actions by looking at the bag on the ground (no good). But there are no actions while the bag is on my back.

I know it works fine if I do the addAction directly to SF1, but then if SF1 is killed I want other units to be able to take the bag from him and access the actions (which is why I want to addAction to the bag itself). Possible?

Thanks

Share this post


Link to post
Share on other sites

One way would be to store the backpack in a variable.

Do this for all players you want able to use the backpack special ability(ies). This assumes SF1 start with the backpack:

SpecialBackpack = (unitBackpack SF1);

Then addAction all the player however the last parameter (optional parameters) of the addAction you check whether they have the backpack on:

player addAction["Request Missile (Hellfire)","launchMissile.sqf",[player, missilestart,"M_Hellfire_AT",200], 1, false, true, "", "unitBackpack _target == SpecialBackpack"];

Then the action will only be available if the unit has that backpack. This is written from memory, and it may not work, however I can't see any apparent reason it should not. Besides syntax error maybe.

Share this post


Link to post
Share on other sites

Hmm well it added the actions for SF1 (the 1st player) just fine but not for other units that picked up the pack. Perhaps I'm just misunderstanding.

If it makes it any easier, there is an array of the units that I want to be able to use the special pack

_units = [sF1,SF2,SF3,SF4,SF5,SF6,SF7,SF8];

In the group, there are two special packs: carried by SF1 and SF8 from the start.

Could you expand on how I would go about this?

Thx

Share this post


Link to post
Share on other sites
SpecialBackpacks = [];
if (!isnil "SF1") then { SpecialBackpacks set [count SpecialBackpacks, unitBackpack SF1] };
if (!isnil "SF8") then { SpecialBackpacks set [count SpecialBackpacks, unitBackpack SF8] };

waituntil {!isnull player};
player addAction ["Request Missile (Hellfire)","launchMissile.sqf",[player, missilestart,"M_Hellfire_AT",200], 1, false, true, "", "unitbackpack _target in SpecialBackpacks"];


/* editor testing
{
 _x addAction ["Request Missile (Hellfire)","launchMissile.sqf",[player, missilestart,"M_Hellfire_AT",200], 1, false, true, "", "unitbackpack _target in SpecialBackpacks"];
} foreach (if ismultiplayer then {playableunits} else {switchableunits});
*/

Share this post


Link to post
Share on other sites

SpecialBackpacks = [];
if (!isnil "SF1") then { SpecialBackpacks set [count SpecialBackpacks, unitBackpack SF1] };
if (!isnil "SF8") then { SpecialBackpacks set [count SpecialBackpacks, unitBackpack SF8] };

waituntil {!isnull player};
player addAction ["Request Missile (Hellfire)","launchMissile.sqf",[player, missilestart,"M_Hellfire_AT",200], 1, false, true, "", "unitbackpack _target in SpecialBackpacks"];
player addAction["Request Bomb (GBU)","launchMissile.sqf",[player, missilestart,"Bo_GBU12_LGB",200]], 1, false, true, "", "unitbackpack _target in SpecialBackpacks"];


/* editor testing
{
 _x addAction ["Request Missile (Hellfire)","launchMissile.sqf",[player, missilestart,"M_Hellfire_AT",200], 1, false, true, "", "unitbackpack _target in SpecialBackpacks"];
 _x addAction["Request Bomb (GBU)","launchMissile.sqf",[player, missilestart,"Bo_GBU12_LGB",200]], 1, false, true, "", "unitbackpack _target in SpecialBackpacks"];
} foreach (if ismultiplayer then {playableunits} else {switchableunits});
*/

Thanks shk, but there are still some issues. So, SF1 gets the actions just fine but there are no actions when team-switching to SF8 (only if you start as him in MP). And still, any unit that takes the bag doesn't get the actions given to them. :(

Share this post


Link to post
Share on other sites

That's why I actually left the commented part there.

You need to add the action to every unit if you are planning on team switching.

Share this post


Link to post
Share on other sites

Oh alright, sorry for my noobness :o

So I would just replace the _x and player with SF2, SF3 etc etc? And this is all ok to run from the init.sqf right?

Thanks for your help :)

Share this post


Link to post
Share on other sites

Im doing something similar but cannot figure out where I am going wrong.

I have two of tier 1 operators named OP_1 and OP_2 on the map. OP_2 has the UAV backpack. In case OP_2 goes down I need to be able to grab the UAV bag which simulates the radio, so the UAV bag should have the action.

Also I do not want to have the option to add the action at the start of the mission only when an objective has been met.

Here is my addaction script:

private ["_caller","_id"];

_caller = _this select 1;
_id = _this select 2;

if (unitBackpack _caller isKindof "US_UAV_Pack_EP1") then 
{
_caller sidechat "Lets go, were getting out of here!";
[["transport"], OP_1] call BIS_SOM_addSupportRequestFunc

} else {_caller removeaction _id; hint "Unit does not have the UAV backpack"};


_caller removeaction _id;

Here is the init.sqf

SpecialBackpacks = [];
if (!isnil "OP_2") then { SpecialBackpacks set [count SpecialBackpacks, unitBackpack OP_2] };

waituntil {!isnull player};
{_x addAction ["Call for Extraction","addextract.sqf"], 1, false, true, "", "unitbackpack _target in SpecialBackpacks"} foreach (if ismultiplayer then {playableunits} else {switchableunits});

It continues to throw up errors and is not working, any suggestions?

Found out I was missing a ] above which is why it wasnt working.

Edited by cobra4v320

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  

×