Random gear script won't equip Goggles

  1. 7 years ago
    Edited 7 years ago by Easy

    Hello!

    I'm fiddling with a random gear script to use on a Project Opfor faction (LOP_US). So far everything works great, the ALiVE spawned units get random uniform, vest and headgear. However, the facewear (goggles) won't equip.

    What is weird is that the script equips randomized eyewear/facewear for editor placed units, just not ALiVE spawned units. This is where I'm stuck.

    Any insight on this would be much appreciated.

    Script:

    params ["_unit"];

    if ((side _unit == EAST) && (vehicle _unit == _unit)) then {
    _magazines = magazines _unit;
    _items = items _unit;
    _aItems = assignedItems _unit;

    removeAllItems _unit;

    removeVest _unit;
    _vests = ["","LOP_V_6Sh92_WDL","LOP_V_6Sh92_Radio_WDL","LOP_V_6Sh92_Radio_OLV","rhs_6sh92_digi_radio","rhs_6sh92_digi","rhs_6sh92","rhs_6sh92_radio","LOP_V_6Sh92_OLV","LOP_V_Chestrig_Kamysh","LOP_V_Chestrig_VSR","rhs_vydra_3m"];
    _count = count _vests;
    _unit addVest (_vests select floor random _count);

    removeUniform _unit;
    _uniforms = ["LOP_U_US_Fatigue_09","LOP_U_US_Fatigue_06","LOP_U_US_Fatigue_07","LOP_U_US_Fatigue_14","LOP_U_US_Fatigue_12","LOP_U_US_Fatigue_03","LOP_U_US_Fatigue_11","LOP_U_US_Fatigue_10"];
    _count = count _uniforms;
    _unit addUniform (_uniforms select floor random _count);

    removeHeadgear _unit;
    _headgear = ["","H_Cap_oli","H_Cap_grn","H_Cap_blk","rhs_beanie","rhs_beanie_green","H_Shemag_olive","H_ShemagOpen_tan","H_ShemagOpen_khk","H_Bandanna_gry","H_Bandanna_blu","H_Bandanna_cbr","H_Bandanna_khk"];
    _count = count _headgear;
    _unit addHeadGear (_headgear select floor random _count);

    removeGoggles _unit;
    _goggles = ["","G_Shades_Green","G_Shades_Black","G_Bandanna_sport","G_Bandanna_beast","G_Bandanna_aviator","G_Aviator"];
    _count = count _goggles;
    _unit addGoggles (_goggles select floor random _count);

    {_unit addItem _x} forEach _items;
    {_unit addMagazine _x} forEach _magazines;
    {_unit addItem _x} forEach _items;
    {_unit assignItem _x} forEach _aItems;

    };

  2. "My eyes!!!! The googles do nothing!!"

    Sorry I'm not much help otherwise. Have you tried just equipping the googles and nothing else? Any errors in your RPT file?

  3. Also a good idea to use hints if you haven't already. Hint the goggles before the script runs, the unit's goggles after the script runs, and then maybe sleep 2 seconds and hint the goggles again. Maybe it's getting overriden by vanilla randomization.

  4. I don't really know what I'm doing tbh, still learning. Please tell me more about these hints you speak of :)

  5. Edited 7 years ago by HeroesandvillainsOS

    Not sure if it's related but there's a game engine bug that makes units not equip certain selected (even vanilla) facewear. I reported this to BIS ages ago but apparently it's not anyway near the tops of their list to fix.

    Perhaps it's caused by this?

    It's easily reproducible. Go into the editor and put a vanilla shemag on a vanilla unit and watch how he spawns without it.

  6. Edited 7 years ago by SavageCDN

    edit: see Sypder's much better solution below

  7. @HeroesandvillainsOS  Not sure if it's related but there's a game engine bug that makes units not equip certain selected (even vanilla) facewear. I reported this to BIS ages ago but apparently it's not anyway near the tops of their list to fix.

    Perhaps it's caused by this?

    It's easily reproducible. Go into the editor and put a vanilla shemag on a vanilla unit and watch how he spawns without it.

    I dunno, your guess is probably better than mine. But if this was the case the script shouldn't work for editor placed units, but it do.

    SavageCDN, cheers!

  8. Edited 7 years ago by SpyderBlack723
    params ["_unit"];
    
    if ((side _unit == EAST) && (vehicle _unit == _unit)) then {
    
        _magazines = magazines _unit;
        _items = items _unit;
        _aItems = assignedItems _unit;
    
        removeAllItems _unit;
    
        removeVest _unit;
        _vests = ["","LOP_V_6Sh92_WDL","LOP_V_6Sh92_Radio_WDL","LOP_V_6Sh92_Radio_OLV","rhs_6sh92_digi_radio","rhs_6sh92_digi","rhs_6sh92","rhs_6sh92_radio","LOP_V_6Sh92_OLV","LOP_V_Chestrig_Kamysh","LOP_V_Chestrig_VSR","rhs_vydra_3m"];
        _count = count _vests;
        _unit addVest (_vests select floor random _count);
    
        removeUniform _unit;
        _uniforms = ["LOP_U_US_Fatigue_09","LOP_U_US_Fatigue_06","LOP_U_US_Fatigue_07","LOP_U_US_Fatigue_14","LOP_U_US_Fatigue_12","LOP_U_US_Fatigue_03","LOP_U_US_Fatigue_11","LOP_U_US_Fatigue_10"];
        _count = count _uniforms;
        _unit addUniform (_uniforms select floor random _count);
    
        removeHeadgear _unit;
        _headgear = ["","H_Cap_oli","H_Cap_grn","H_Cap_blk","rhs_beanie","rhs_beanie_green","H_Shemag_olive","H_ShemagOpen_tan","H_ShemagOpen_khk","H_Bandanna_gry","H_Bandanna_blu","H_Bandanna_cbr","H_Bandanna_khk"];
        _count = count _headgear;
        _unit addHeadGear (_headgear select floor random _count);
        
        systemchat format ["[%1] Current Goggles: %2", _unit, goggles _unit]; // debug
    
        removeGoggles _unit;
        _goggles = ["","G_Shades_Green","G_Shades_Black","G_Bandanna_sport","G_Bandanna_beast","G_Bandanna_aviator","G_Aviator"];
        _count = count _goggles;
        _unit addGoggles (_goggles select floor random _count);
    
        {_unit addItem _x} forEach _items;
        {_unit addMagazine _x} forEach _magazines;
        {_unit addItem _x} forEach _items;
        {_unit assignItem _x} forEach _aItems;
        
        // debug
        
        [_unit] spawn {
            params ["_unit"];
            sleep 2;
            systemchat format ["[%1] New Goggles - %2", _unit, goggles _unit];
        };
        
        // debug
    
    };
  9. https://community.bistudio.com/wiki/systemChat
    https://community.bistudio.com/wiki/hint

 

or Sign Up to reply!