Jump to content
Sign in to follow this  
Streblo88

addAction and Backpacks

Recommended Posts

Hello, I rarely post in forums asking for help but my latest project in the editor has me completely stumped. I have searched the forums before posting, but have not found a working solution to my problem so I have started a new thread, I hope this is OK. Basically I have an air support script that I have used many times before, but this time I only want it to work if my unit is wearing one of ACE's PRC-119 radio packs (or any pack for that matter, I just like the way this one looks).

I would normally start the script either in a units init or the mission init like so -

player addAction ["Request AC-130","LDL_ac130\Actions\ac130_action_map_AI.sqf"];

Are there any geniuses out there who could help me add a condition to this addAction to check that the player is wearing an ACE PRC-119 pack? (classname ACE_PRC119 if it helps)

I have been googling this for days and have found some info, but unfortunately nothing has worked. I have had some success by placing a UAV pack in the editor and adding the addAction strait into the UAV pack's init. This is not ideal though as you have to drop the bag on the floor in order to access the actions, as well as this you cannot pack additional items into the UAV bag, so its just too inconvenient.

If anyone has a solution to this please share it as this is driving me mental. Thanks in advance!

Share this post


Link to post
Share on other sites

This is from the top of my head, dunno if this will work:

player addAction ["Request AC-130","LDL_ac130\Actions\ac130_action_map_AI.sqf"];
   [], 6, true, true, "", {typeOf (unitBackPack _this) == "ACE_PRC119"}
];

Might want to try that.

Share this post


Link to post
Share on other sites

If ("ACE_PRC119_MAR" in weapons player || "ACE_PRC119_ACU" in weapons player || "ACE_PRC119" in weapons player) then

{

player addAction ["Request AC-130","LDL_ac130\Actions\ac130_action_map_AI.sqf"];

};

Something along those lines... The backpacks in ACE are considered weapons if I remember correctly.

This will only give the addAction if the player has one of the "backpacks". You can remove the other two if not needed.

You can implement this into what Alwarren suggested as the condition, then a player can start with a normal "backpack" and pick up an ACE_PRC119 pack.

Tested in editor, this works for soldier initialization field:

this addAction ["Request AC-130","LDL_ac130\Actions\ac130_action_map_AI.sqf", [], 6, true, true, "", """ACE_PRC119"" in weapons _this"];

Edited by panther42

Share this post


Link to post
Share on other sites

I would definitely put the condition in the addAction, otherwise you will keep the action even if you drop/loose the backpack. Plus, you can give the action to all players and it will always show for the guy that is carrying it.

Share this post


Link to post
Share on other sites

Thanks for the quick replies, i'm just testing these suggestions now. Alwarren, I have just tried your idea. It keeps telling me that i'm missing ; and i'm having a hard time seeing why. I’m just gonna test panther42's idea now.

---------- Post added at 15:31 ---------- Previous post was at 15:23 ----------

Nice panther! You've got further in 5 mins than i have in 2 days! Although Al is right, even if I drop the pack i still have the option to call air support. I realise im pushing my luck now, but do you know of any way i can stop this? Thanks again.

---------- Post added at 15:34 ---------- Previous post was at 15:31 ----------

Hmmm.. and it also seems that you have to spawn with the pack for it to work. If you start without a pack and pick one out of a box for example, you get no new actions.

Share this post


Link to post
Share on other sites
Hmmm.. and it also seems that you have to spawn with the pack for it to work. If you start without a pack and pick one out of a box for example, you get no new actions.

That's because of what I said, conditionally adding the action will not work as expected, you have to put it in the addAction condition. See panther42's edit.

Init code is only executed once, at the very start of the mission.

Also, I would add the same action to everyone that may pick up the radio, since it will "tie-in" the possibility with the backpack.

Share this post


Link to post
Share on other sites
Hmmm.. and it also seems that you have to spawn with the pack for it to work. If you start without a pack and pick one out of a box for example, you get no new actions.

Just for the heck of it, here's a way you can add to all players via script which should work correctly.

In your init.sqf file, add the following:

["Request AC-130", {"ACE_PRC119" in weapons player}] execVM "scripts\giveme_support.sqf";

giveme_support.sqf:

private["_acidx1", "_veh", "_condition_extra", "_text"];
_text = _this select 0;
_condition_extra = _this select 1;

_acidx1 = -1;

while {true} do
{
  while {!alive player || !call (_condition_extra)} do
  {
     Sleep 1;      
  };

  _veh = vehicle player;
  _acidx1 = _veh addAction ["<t color=""#ffffff"">"+_text, "LDL_ac130\Actions\ac130_action_map_AI.sqf"];
  while {(vehicle player == _veh) && call (_condition_extra)} do
  {
     Sleep 1;
  };
  _veh removeAction _acidx1;
}; 

This is code I use from MMA which is very usefull.

Edited by panther42

Share this post


Link to post
Share on other sites

Panther thank you! You have helped me out big time there. Thank you too Al for your replies. Quick question panther, say if my unit was killed, would a squad member be able to pick up my pack and continue in my role as radio op? I would prefer not go give my whole squad the ability to call in air support at once otherwise things might get a bit erm... crazy. I will check out your script though, thanks again.

Share this post


Link to post
Share on other sites

Script above only works if you have the radio. Yes, you can kill the guy with the radio, pick it up, and you will have the addAction

Don't know if it matters, but I found if using the init field of a soldier with the code I posted in #3, I can't get into a vehicle! Even after dropping the ruck...

Script version works fine though. You'll have the action in or out of the vehicle.

Disregard the above comment about not being able to get into a vehicle. I had two soldiers on the map(grouped) while testing, and even though the second one placed was set to player, it would not let me enter vehicle since the first placed soldier was the squad leader. Hello...

Edited by panther42

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  

×