Jump to content
Ali walter

help for respawn Ai with custom loadouts

Recommended Posts

hello guys. i need save my custom loadouts after respawn on Ai but cant and i dont know how every one can help me pls have any script and more about this ? TNX

Share this post


Link to post
Share on other sites

place this code in init.sqf


 

addMissionEventHandler ["entityKilled", {
  _victim = _this select 0;
  if (local _victim) then {
    [_victim, [missionNamespace, name _victim]] call BIS_fnc_saveInventory; 
    _victim setVariable ["MGI_ammo1",_victim ammo (primaryWeapon _victim)];
    _victim setVariable ["MGI_ammo2",_victim ammo (handgunWeapon _victim)];
    _victim setVariable ["MGI_ammo3",_victim ammo (secondaryWeapon _victim)];
    _victim setVariable ["MGI_mags",magazinesAmmoFull _victim];
    _victim setVariable ["MGI_weapon",currentWeapon _victim];
  };
}];

addMissionEventHandler ["entityRespawned", {
  _unit = _this select 0;
  _corpse = _this select 1;
  if (local _unit) then {
    [_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
    {_unit removeMagazine _x} forEach magazines _unit;
    _unit setAmmo [primaryWeapon _unit, 0];
    _unit setAmmo [handGunWeapon _unit, 0];
    _unit setAmmo [secondaryWeapon _unit, 0];
    {
      if (((_unit getVariable "MGI_mags") select _foreachindex select 3) <= 0) then {
        _unit addMagazine [_x select 0,_x select 1]
      }
    } forEach (_unit getVariable "MGI_mags");
    _unit setAmmo [primaryWeapon _unit,_unit getVariable "MGI_ammo1"];
    _unit setAmmo [handGunWeapon _unit,_unit getVariable  "MGI_ammo2"];
    _unit setAmmo [secondaryWeapon _unit,_unit getVariable "MGI_ammo3"];
    _unit selectWeapon (_unit getVariable "MGI_weapon");
    removeAllWeapons _corpse;
    removeBackpackGlobal _corpse;
    removeVest _corpse;
    removeAllAssignedItems _corpse;
    removeAllItems _corpse;
    removeGoggles _corpse;
    removeHeadgear _corpse;
    {deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
  };
}];

 

Question: Why do you use get/setUnitLoadout?

  _victim setVariable ["MGIinvent", getUnitLoadout _victim]; // in EH entityKilled

  _unit setUnitLoadout (_corpse getVariable "MGIinvent");  // in EH entityRespawned

 

Answer: because these commands are OK for own inventory but you loose the possibility to open the backpack of a respawned fellow.

The "old" functions are fine at all level.

 

  • Like 1

Share this post


Link to post
Share on other sites

This should work even though you are playing coop and respawning on AI and this a multiplayer thing I'm quoting.

 

Quote

You need a description.ext file in the missions/scenario folder and it needs to say this (as always do not include the quote marks) " respawnTemplates[] = {"MenuInventory","MenuPosition"}; "

 

The next file you need to make with a text editor is initplayerlocal.sqf and inside it needs to say this exactly, do not put the name of the mission, it knows this, " [player, [missionnamespace, "virtualinventory"]] call Bis_fnc_saveinventory; "

 

last file you need to make is onplayerrespawn.sqf and inside it needs to say " [player, [missionnamespace, "virtualinventory"]] call Bis_fnc_loadinventory; "

 

 You go into the editor and make guys to fight with in your mission or multiplayer scenario, you place them down, got to arsenal to edit the loadouts of the soldiers, save the mission and it should save the loadouts. YOU may have to click "save loadout" in the editor by clicking on attributes and picking multiplayer from the drop down menu and save loadout.

 

Those guys you make and save have a role description when you double click them in the editor, I use this to basically tell the loadout to the person joining a server, they all say rifleman or pilot or something else in the lobby but under that I have this under rifleman on one of the slots in the lobby " Lite Rifleman Garand 2 nades mucho ammo ". As you can read its a WWII scenario cause its got the Garand. He has nothing but a bunch of ammo and 2 nades, they all have 2 bandages so I don't bother with that. They can see what they are going to get when they pick that slot. I do this because it stops people from using arsenal to bring modern weapons into a WWII battle. There have been several so called fixes to this but I've seen people get around them. 

 

All this will throw and error at the bottom of the screen, it is meaningless. It is because you haven't specified different inventories to pick for each one but you don't have or need to, you've already made the loadouts you wanted.

I posted this elsewhere and just picked the parts out that I thought would help you. It is the simplest way I've seen to make custom loadouts and save them without a bunch of files having to be created. You can quickly make 200 or custom loadouts in the editor, in arsenal, not even saving them in arsenal and and as long as you do what is written above, like saving the scenario and clicking save loadouts in the multiplayer drop down in the editor they will be there. I do think you should save them in the arsenal so they can easily reused in the next scenario.  I know all of this because of SayUnkl. I don't know if he is still doing ARMA3 or not.

 

 

Share this post


Link to post
Share on other sites
On 20/10/2017 at 01:58, Alleged Accomplice said:

Isso deve funcionar mesmo que você esteja jogando coop e renascendo na IA, e estou citando uma coisa para vários jogadores.

 

Postei isso em outro lugar e apenas escolhi as partes que pensei que poderiam ajudá-lo. É a maneira mais simples que vi de fazer carregamentos personalizados e salvá-los sem que um monte de arquivos tenha que ser criado. Você pode rapidamente fazer 200 ou loadouts customizados no editor, no arsenal, nem mesmo salvá-los no arsenal e e contanto que você faça o que está escrito acima, como salvar o cenário e clicar em salvar loadouts no menu multiplayer do editor eles estarei lá. Acho que você deve salvá-los no arsenal para que possam ser facilmente reutilizados no próximo cenário. Eu sei de tudo isso por causa do SayUnkl. Não sei se ele ainda está usando ARMA3 ou não.

 

 

 

Hello, how do I save AI's custom equipment? I command a group of 6 iA and they all respawn with the standard equipment after they die.

Share this post


Link to post
Share on other sites
On 21/09/2017 at 21:52, pierremgi said:

coloque este código em init.sqf


 



 

Pergunta: Por que você usa get / setUnitLoadout?

  _victim setVariable ["MGIinvent", getUnitLoadout _victim]; // em EH entityKilled

  _unit setUnitLoadout (_corpse getVariable "MGIinvent"); // em EH entityRespawned

 

Resposta: porque esses comandos são adequados para o próprio inventário, mas você perde a possibilidade de abrir a mochila de um sujeito renascido.

As funções "antigas" funcionam em todos os níveis.

 

 

Hello, how do I save AI's custom equipment? I command a group of 6 iA and they all respawn with the standard equipment after they die.

Share this post


Link to post
Share on other sites

It's an old thread...

 

in init.sqf


 

RESPAWNASSTART = FALSE;  // true if you want the same loadout at start
FULLMAGS = FALSE;    // true if you want full mags in inventory (no matter the current one)

{_x setVariable ["Invent", getUnitLoadOut _x]} forEach theUnitsAbleToRespawn;

addMissionEventHandler ["entityKilled",{
  params ["_victim"];
  if (_victim in theUnitsAbleToRespawn && !RESPAWNASSTART) then {
    _victim setVariable ["Invent",getUnitLoadout _victim];
  };
}];

addMissionEventHandler ["entityRespawned",{
  params ["_unit","_corpse"];
  if (local _corpse) then {
    _unit setUnitLoadout [_corpse getVariable ["invent",getUnitLoadout _unit],FULLMAGS];
  };
}];

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 12/7/2020 at 10:50 AM, LLM777 said:

 

Hello, how do I save AI's custom equipment? I command a group of 6 iA and they all respawn with the standard equipment after they die.

I quit ARMA after buying Hell Let Loose. I won't be editing or doing anything else with it.

  • Confused 1

Share this post


Link to post
Share on other sites
On 12/11/2020 at 1:15 AM, Alleged Accomplice said:

I quit ARMA after buying Hell Let Loose. I won't be editing or doing anything else with it.

A very bad choice. 🙂

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

×