Force spawned AI to use flashlights with ALiVE / holding fire

  1. 8 years ago
    Edited 8 years ago by incontinenetia

    Hi all,

    I've Googled and tested and frustrated my nuts off on this. Basically, I'd like BLUFOR to use their lasers and GUER to add flashlights and use them at night. I've tried using the scripting in this thread but I'm not having much luck.

    This is my description.ext:

    class Extended_Init_EventHandlers { 
    	class Man {
    		init = "_this call (compile preprocessFileLineNumbers 'lights.sqf')";
    	 };
    };

    And this is my lights.sqf:

    params ["_unit"];
    
    if (side _unit == GUER) then {
     _unit addItem "Item_acc_flashlight";
     _unit enableGunLights "forceon";
    };
    
    if (side _unit == WEST) then {
     _unit enableIRLasers "true";
    };

    It's on vanilla units so they should be XEH compatible. Anybody able to lend a hand?

    Thanks in advance! And again, amazing work devs - the new features are incredible.

  2. side _unit == GUER

    Welcome to the fun..

    side _unit will never be GUER, it will be INDEPENDANT. However, str side _unit would be "GUER"..

    Essentially I would change your script to appear like so

    params ["_unit"];
    
    switch (str side _unit) do {
        case "WEST": {
            _unit enableIRLasers "true";
        };
        case "GUER": {
            _unit addItem "Item_acc_flashlight";
            _unit enableGunLights "forceon";
        };
    };
  3. side _unit will never be GUER, it will be INDEPENDANT. However, str side _unit would be "GUER"..

    Obviously!

    Thank you Spyder (again!). Just tested it however and still no luck. Anything else I could try?

  4. It looks like you are just adding the item to their inventory, you'll want to add it to their weapon. Might not work on all weapons.

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

  5. Thank you Spyder. It seems to work in some instances (I can reliably add a suppressor). No luck on getting them to use lasers when they switch to combat though and still not having much success adding flashlights to those with weapons that support them. Shame it's so difficult to control!

  6. Wish I could help more :\ , haven't messed with this type of stuff much

  7. Maybe this script can help you in some way?

    https://forums.bistudio.com/topic/190880-release-jboy-patrol-chatter-and-lights-onoff-scripts/

  8. Thanks dude! Managed to get roughly what I wanted with the following:

    params ["_unit"];
    
    switch (str side _unit) do {
        case "WEST": {
            removeHeadgear _unit;
    	removeGoggles _unit;
    	_unit addPrimaryWeaponItem "muzzle_snds_M";
            _unit enableIRLasers true;
            _unit enableGunLights "forceOn";
            _unit addHeadgear "H_Booniehat_oli";
        };
        case "GUER": {
            _unit removePrimaryWeaponItem "acc_pointer_IR";
            _unit addPrimaryWeaponItem "Item_acc_flashlight";
            _unit enableGunLights "auto";
        };
        case "EAST": {
            removeHeadgear _unit;
            removegoggles _unit; 
            _unit unlinkItem "O_NVGoggles_ghex_F"; 
            _unit removeitem "O_NVGoggles_ghex_F"; 
            _unit removePrimaryWeaponItem "acc_pointer_IR";
            _unit addPrimaryWeaponItem "acc_flashlight";        
            _unit enableGunLights "forceOn";
            _unit addHeadgear "H_Booniehat_dgtl";
        };
    
    };

    Getting rid of the NVGs makes AI use flashlights. "ForceOn" doesn't really do what it should, but it kind of works.

    Not such a fan of the fancy hats either... can't imagine how anybody would survive wearing that kind of stuff in the jungle.

    Thanks for the help guys! Much appreciated.

  9. Nice job!

  10. Edited 8 years ago by incontinenetia

    Thanks Spyder! Another quick question, is it possible to make spawned AI have a certain rules of engagement? I've tried using setCombatMode in the above script, no luck so far unfortunately. This is how it looks at the moment.

    params ["_unit","_group"];
    
    switch (str side _unit) do {
        case "WEST": {
    		_unit addPrimaryWeaponItem "muzzle_snds_M";
            _unit enableIRLasers true;
            _unit enableGunLights "forceOn";
    		_group setCombatMode "WHITE";
    
        };
        case "GUER": {
            _unit removePrimaryWeaponItem "acc_pointer_IR";
    		_unit unlinkItem "ItemRadio";
            _unit addPrimaryWeaponItem "Item_acc_flashlight";
            _unit enableGunLights "auto";
        };
        case "EAST": {
            removeHeadgear _unit;
            removegoggles _unit; 
            _unit unlinkItem "O_NVGoggles_ghex_F"; 
            _unit removeitem "O_NVGoggles_ghex_F"; 
            _unit removePrimaryWeaponItem "acc_pointer_IR";
            _unit addPrimaryWeaponItem "acc_flashlight";        
            _unit enableGunLights "forceOn";
            _unit addHeadgear "H_Booniehat_dgtl";
    		_group setCombatMode "BLUE";
        };
    
    };

    Edit: Add this to the script:

    {if (side _x == east) then {_x setCombatMode "WHITE"};} foreach allunits;
  11. is _group defined? try using (group _unit)

  12. Thanks Spyder! Got it working. Getting close to releasing my first mission. Exciting times.

  13. Good luck :)

  14. I can't wait!

  15. Thanks guys!! Finally starting to learn actual coding in Arma to get some finishing touches done. May take a while...

  16. Hit me up when it's done. I want to play it.

 

or Sign Up to reply!