Where to put this script?

  1. 8 years ago

    Hey guys, I'm cobbling together a bunch of crap with ALiVE as the glue, but patrols including AA/AT soldiers are making it nearly impossible for a player to cover any in a vehicle without being taken down. I wrote a little script that I think will address the issue, but I am not sure where to put it to make sure it applies to all ALiVE units AFTER they have been spawned so that I don't need to have the script run every 30 seconds or something.

    {  if (side _x == Guer) then 
    	{  
    	_x removeWeaponGlobal "launch_I_Titan_F";
    	_x removeWeaponGlobal "launch_I_Titan_short_F";
    	_x removeWeaponGlobal "launch_RPG32_F";
    	_x removeWeaponGlobal "launch_NLAW_F";
    	}  
    } ForEach allUnits;
  2. after a little tinkering I think a better way to put this question would be: is there a way to have this script apply to placed units and virtualized units together, or should I just have it run every 10 seconds or so to update virtualized units that have been spawned?

  3. You can run code on newly spawn units using CBA's XEH system. There is an example located here
    http://alivemod.com/wiki/index.php/Script_Snippets#Adding_Custom_Inits_to_Spawned_Units

    You can also blacklist specific units/groups if you wish to try that route
    http://alivemod.com/wiki/index.php/Custom_Blacklists

  4. highhead

    16 Apr 2016 Administrator
    Edited 8 years ago by highhead

    i am not sure how your script manages to do this, because it would need to be side _x == RESISTANCE or str(side _x) == "GUER". XEH would definitly be better for performance

  5. Edited 8 years ago by DaVidoSS

    Even better performance would be use just AT/AA units classnames in XEH, and run such function on each such unit.

    description.ext

    class Extended_Init_EventHandlers	{
    	 
    	class O_MTI_AA_F {
    	
    		init = "_this call INS_fnc_rmrpg";
    
    	};
    	
    	class O_MTI_LAT_F {
    	
    		init = "_this call INS_fnc_rmrpg";
    	};
    	
    	class O_MTI_AT_F {
    	
    		init = "_this call INS_fnc_rmrpg";
    	};
    };
    

    INS_fnc_rmrpg

    params ["_unit", "_launchers"];
    
    _launchers = ["launch_I_Titan_F", "launch_I_Titan_short_F", "launch_RPG32_F", "launch_NLAW_F"];
    
    {
    
    	if (_x in _launchers) then {
    
    	_unit removeWeaponGlobal _x;
    	};
    
    }forEach (weapons _unit);
  6. "side _x == independent" was what it needed to work as is, however these answers were exactly why I asked. Thank you everyone for your input.

 

or Sign Up to reply!