Jump to content
Sertica

AI Hide Weapon In Backpack

Recommended Posts

Because the virtual arsenal does not allow seeing everything on the list, the arsenal can't be used to make the kit I want.  I can execute "soldier addItemToBackpack "weapon"" in debug console in play mode, but it does not work in edit mode.  Surely there is an easier way to fill backpacks than scrounging for weight and capacity info in config viewer for every single item, then using Windows Calculator to determine how to fit, then editing the mission text file.  Eventually I need a way to make the AI hide weapon in backpack.  Even if it can be forced in, how to make the AI want to keep it there in safe mode is likely the challenge.

Share this post


Link to post
Share on other sites

The problem is you can't add a weapon to a backpack.  Currently it seems the closest hack is creating every character entirely in the arsenal outside of the editor, then loading them in the editor.

Share this post


Link to post
Share on other sites

To be honest, I did just skim through. It is late here so pretty tired. Besides, it doesn't matter if you can't do that in the Arsenal. What is exactly 'edit mode'? I assume you mean the editor? I am aware you can't add stuff in the backpack via Arsenal. You can use the init field to accomplish this. There is no need to use a Calculator when you can check if it fits using canAddItemToBackpack command. As for the AI hiding the weapon. I assume the AI has the weapon in backpack to start with? Then if I've understood correctly you want to make them get it out when not in SAFE behaviour mode? Yes? Sadly there is no EH for behaviour mode change so you'll have to use some loop for that. You can probably use one of the Anim EHs and put the code in there.

if !(behaviour _unit isEqualTo "SAFE") then
{
	// code...	
};

You'll want to cycle through backpack items and check out which are actual weapons. Then remove the weapon, add it in the AI's hand. You can repeat the process but invert it to accomplish it again but for SAFE behaviour mode.

https://community.bistudio.com/wiki/hasWeapon

https://community.bistudio.com/wiki/backpackItems

https://community.bistudio.com/wiki/BIS_fnc_itemType

I suggest AnimChanged since AI will change stance or will be moving so the code will continue to check and if true, run.

  • Like 1

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

×