Jump to content

scottb613

Member
  • Content Count

    731
  • Joined

  • Last visited

  • Medals

Posts posted by scottb613


  1. 17 minutes ago, Ibragim A said:

    You also need to fix the block that counts the magazines suitable for the primary weapon. Your block counts the same magazine several times.
    Do it like this:

    
    	// Count Primary Weapon Magazines
    
    		{
    			if (_x in _compMagArr) then {_cntMag = _cntMag + 1};	
    		} foreach _unitMagArr;

     

     

    Hi Folks,

     

    Thanks so much as well. I'm a novice - so corrections and critical feedback is ALWAYS most welcome. It's how I learn. Let me go over your posts in detail. I'll see if I can figure out my mistake. I'll have to correct it elsewhere - as I've used that block before.

    😉

     

    Regards,
    Scott  

    • Like 1

  2. Hi Folks,

     

    Working on a routine to display a unit's health and ammo status for the player group - so potentially a 20-line report of text for the largest player groups. I've tested [hint] and it works with 20 lines of text and does support carriage returns - [format] doesn't seem to. So - I've got a loop running to gather all the required information for each unit and I was thinking of putting each line into an array - then outputting in some yet undefined manner.

     

    Question: I need to make a 20-line formatted text report with carriage returns for a [hint] - based on the gathered information. Any thoughts on how I can do this?

     

    I tried the [sideChat] but that only displays half a dozen lines or so max.

     

    Where I'm at:

    private _unitArr = units player;
    _unitArr deleteAt 0;
    private _hintArr = [];
    
    if (isnil "kiaCnt") then 
    {
    	kiaCnt = 0;
    };
    
    {
    	private _unit = _x;
    	private _health = round ((1 - damage _unit) * 100); // health in % from 0 to 100
    	
    	private _kiaCnt = kiaCnt;
    	
    	//If Dead - Remove From Group - Increment Kill Counter
    	if (_health == 0) then 
    	{
    		kiaCnt = _kiaCnt + 1;
    		private _grpDOA = createGroup [west, true];
    		[_unit] join _grpDOA;	
    	};
    	
    	//Unit Info
    	private _priWeap = primaryWeapon _unit;
    	private _unitMagArr = magazines _unit;
    	private _compMagArr = compatibleMagazines _priWeap;
    	private _cntMag = 0;
    	
    	// Count Primary Weapon Magazines
    	{
    		private _compMag = _x;
    		{
    			private _unitMag = _x;
    			if (_compMag == _unitMag) then {_cntMag = _cntMag + 1};	
    		} foreach _unitMagArr;
    	} foreach _compMagArr;
    	private _logger = format ["%1 || %2 || %3 || Mags: %4", _unit, _health, _priWeap, _cntMag];
    	_hintArr pushback _logger;
    	_unit groupChat _logger;
    	
    } foreach _unitArr;
    _logger = format ["KIA: %1", kiaCnt];
    player groupChat _logger;

     

    Thanks.

     

    Regards,
    Scott


  3. Hi Folks,

     

    Consolidated a couple threads into this one - I'll keep post #1 up to date - scripts are updated with progress and functional.

     

    I see from how @thy_ did it - I need to delete all magazines - from unit and ammo box - then replace with what I want after I update the quantities - respectively. I think I have it. I'll be working on implementing same.

     

    I posted my remaining active questions in post #1.

     

    Regards,
    Scott


  4. 11 hours ago, ThomasRW said:

    For me the script works fine. I don't really think this is what causes your problem, but magazines <unit> does not return the current loaded mag of a AI unit. So, if the AI just have the loaded mag and nothing else, you get "U2 || ", "U3 || ", ... 

     

    Hi Thomas,

     

    Thanks so much.

     

    Bingo.

     

    Bad test units. I had units where I used the ACE Arsenal to empty all containers via the "trashcan" icon for my testing - - - however - - - I knew they didn't have magazines - so I went back into ACE Arsenal and added magazines. Apparently - this doesn't work and these units appear broken. After your feedback - I added a fresh unit to my test - untouched by the ACE Arsenal - works like a champ. Spent hours on this issue. A fresh set of eyes is always helpful - much appreciated.

     

    Regards,
    Scott


  5. Hi Folks,

     

    Spinning my wheels on this one - [magazines] works fine on the player - however - [magazines] doesn't work on the Players AI Group Members? I've tried everything I can think of. I gave the AI Units Variable Names - I also tried the default names returned from a [units player] command - nothing seems to provide me with the magazines of the AI units - it returns null. The [magazines player] works absolutely fine. What am I missing?

     

    //U2-U6 Variable Names assigned to AI Player Group Members.
    
    private _units = [U2,U3,U4,U5,U6];
    //private _units = units player;
    
    private _mags = magazines player;
    
    _logger = format ["PLAYER || %1", _mags];
    hint _logger;
    sleep 5;
    
    {
    	private _mags = magazines _x;
    	
    	_logger = format ["%1 || %2", _x, _mags];
    	hint _logger;
    	sleep 5;
    } foreach _units;
    hint "";

     

    Thanks.

     

    Regards,
    Scott


  6. Hi @thy_

     

    Thanks - it always helps to see how others do it. Let me go over this and see if I can figure it out.

     

    I've seen the following done before - but - I'm not exactly sure what it's doing. I assume it's reading some master config file for Arma. I'll look deeper into this as well.

     

    Quote

    _magazines = getArray(configFile >> "CfgVehicles" >> _type >> "magazines");

     

    Thank You!

    😉

     

    Regards,
    Scott


  7. Hi Folks,

     

    I'm on a coding spurt - LOL. Doing some simple quality of life scripts. Learning as I go.

     

    I made a self-destruct script to destroy any ammo pallets left over after I rearm my units. I learned how to add actions to objects now - new to me - very cool.

     

    The script "works" as is.

     

    Question: When I [attachTo] - the relative positioning doesn't seem to work. I can never see the charge - no matter the values (assumed buried in object). Shouldn't I be able to move the explosive around on the object (ammo pallet) using the position array?

     

    Question: If I use the "scripted charges" this works - however - I originally wanted to place a SOG incendiary grenade on the pallet (better effect) - but that doesn't work using the classname - ideas?

     

    //SCOdestruct.sqf
    private _target = _this;
    private _posit = getpos (_this select 0);
    // create and attach charge
    private _charge = "DemoCharge_Remote_Ammo_Scripted" createVehicle _posit;
    _charge attachTo [_target, [1.0, 1.0, 1,0]];
    // now detonate charge
    sleep 2;
    hint "----RUN---RUN---RUN----";
    sleep 3;
    hint "---------10";
    sleep 1;
    hint "--------9";
    sleep 1;
    hint "-------8";
    sleep 1;
    hint "------7";
    sleep 1;
    hint "-----6";
    sleep 1;
    hint "----5";
    sleep 1;
    hint "---4";
    sleep 1;
    hint "--3";
    sleep 1;
    hint "-2";
    sleep 1;
    hint "1";
    sleep 2;
    hint "";
    _charge setDamage 1;

    Thanks.

     

    Regards,
    Scott


  8. Hi Folks,

     

    Working on a simple "Rearm" script using the vanilla "Rearm Action" - as it's obvious the default menu "Rearm" actions are really unusable. The "Rearm" action is intended to be initiated from an Ammo Crate Action Menu. You can select "Rearm" by Player Squad or Team. There is a self-destruct mechanism included to destroy any ammo not taken - to prevent it falling into enemy hands.

     

    Question [SCOammo.sqf]:  I get the yellow "out of ammo" indications on the HUD for the unit - it doesn't clear after they rearm - is there a way to force the HUD Indicator back to normal?

     

    Question [SCOammo.sqf]:  Is there a way to detect the end of a reload animation of a unit - like [waitUntil]? The reload times vary greatly between weapon/unit.

     

    Question [SCOdestruct.sqf]:  When I [attachTo] the charge to the pallet - the relative positioning doesn't seem to work. I can never see the charge - no matter the values (assumed buried in object). Shouldn't I be able to move the charge around on the object (ammo pallet) using the position array?

     

    Question [SCOdestruct.sqf]:  If I use the "scripted charges" this works - however - I originally wanted to place a SOG incendiary grenade on the pallet (better effect) - but that doesn't work using the classname - ideas?

     

     

    //SCOinitAmmoCrate.sqf
    //Insert into Init Field of Desired Ammo Crate.
    
    this addAction ["Rearm Squad","SCOammo.sqf","ALL",1.5,true,true,"","true",5];
    this addAction ["Rearm Team_W","SCOammo.sqf","MAIN",1.5,true,true,"","true",5];
    this addAction ["Rearm Team_R","SCOammo.sqf","RED",1.5,true,true,"","true",5];
    this addAction ["Rearm Team_G","SCOammo.sqf","GREEN",1.5,true,true,"","true",5];
    this addAction ["Rearm Team_Y","SCOammo.sqf","YELLOW",1.5,true,true,"","true",5];
    this addAction ["Rearm Team_B","SCOammo.sqf","BLUE",1.5,true,true,"","true",5];
    this addAction ["<t color='#FF0000'>Destruct</t>","SCOdestruct.sqf","nil",1.5,true,true,"","true",5];

     

    //SCOammo.sqf
    //Need Classname of desired Ammo Crate on line 4.
    private _choseTeam = _this select 3;
    private _logger = format ["Rearm %1", _choseTeam];
    hint _logger;
    sleep 3;
    
    //Check Ammo Box Range
    private _ammoBox = nearestObject [player, "vn_b_ammobox_supply_01"];
    private _ammoRun = 1;
    if (isNull _ammoBox) then
    {
    	hint "No Ammo in Range";
    	sleep 5;
    	hint "";
    	_ammoRun = 0;
    };
    
    while { _ammoRun == 1 } do
    {
    	private _ammoPos = getpos _ammoBox;
    	private _unitArr = units player;
    	_unitArr deleteAt 0;
    	
    	{
    		// Unit Info and Team Membership
    		private _unit = _x;
    		if (!alive _unit) then {continue};
    		private _priWeap = primaryWeapon _unit;
    		private _unitMagArr = magazines _unit;
    		private _compMagArr = compatibleMagazines _priWeap;
    		private _totCnt = 0;
    		private _assTeam = assignedTeam _unit;
    		if (_choseTeam == "ALL") then {_assTeam = "ALL"};
    		if (_choseTeam != _assTeam) then {continue};	
    		
    		// Count Primary Weapon Magazines
    		{
    			private _compMag = _x;
    			{
    				private _unitMag = _x;
    				if (_compMag == _unitMag) then {_totCnt = _totCnt + 1};	
    			} foreach _unitMagArr;
    		} foreach _compMagArr;
    		
    		// If Unit Above Threshold - Continue
    		if (_totCnt > 4) then 
    		{
    			_logger = format ["%1 - I'm good.", _unit];
    			hint _logger;
    			sleep 1;
    			continue;
    		};
    		
    		// Get Ammo
    		_unitPos = getpos _unit;
    		_logger = format ["Rearm %1",_unit];
    		hint _logger;
    		_unit doMove _ammoPos;
    		waitUntil {sleep 1; (_unit distance _ammoBox) < 5};
    		_unit action ["rearm", _ammoBox];
    		_unit doMove _unitPos;
    		
    	} foreach _unitArr;
    	
    	_ammoRun = 0;
    };
    hint "";

     

    //SCOdestruct.sqf
    //Destroy Ammo Crate
    private _target = _this;
    private _posit = getposATL (_this select 0);
    // create and attach charge
    private _charge = "DemoCharge_Remote_Ammo_Scripted" createVehicle _posit;
    _charge attachTo [_target, [1.0, 1.0, 1,0]];
    // now detonate charge
    sleep 2;
    hint "----RUN---RUN---RUN----";
    sleep 3;
    hint "---------10";
    sleep 1;
    hint "--------9";
    sleep 1;
    hint "-------8";
    sleep 1;
    hint "------7";
    sleep 1;
    hint "-----6";
    sleep 1;
    hint "----5";
    sleep 1;
    hint "---4";
    sleep 1;
    hint "--3";
    sleep 1;
    hint "-2";
    sleep 1;
    hint "1";
    sleep 2;
    hint "";
    _charge setDamage 1;

     

    Thanks.

     

    Regards,
    Scott


  9. 34 minutes ago, sarogahtyp said:

    in your code you cycle through the array of strings _magsArr using a forEach loop which gives you the current string in _x.

    But you are comparing _x wich is a string with the array of strings _priMag. 

    Thats the problem, primaryWeaponMagazine returns an array of strings but not a single string.

     

    Edit:

    you could use:

    
    _x in _priMag

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

     

    Thanks for the explanation - let me give that a try. It's amazing how much time you can spend attempting to overcome a simple hurdle.

     

    Regards,
    Scott


  10. Hi Folks,

     

    Working on a simple script where I want to redistribute remaining mags among team members - after a firefight - as I would expect would happen in real life. I plan to count all the primary weapon magazines and distribute the remaining evenly among respective weapon users. I haven't figured out how to handle a unit that may have different types of magazines for their primary weapon - yet. 

     

    It's been a while since I've done any heavy Arma scripts.

     

    What am I doing wrong? I simply want to count the remaining mags of the primary weapon. The string comparison never increments the counter. I tried making both a STR. I looked at each value and the array element includes brackets and quotes which is probably the cause.

     

    _priWeap = primaryWeapon player;
    _priMag = primaryWeaponMagazine player;
    
    _magsArr = magazines player;
    			
    _cntMags = count _magsArr;
    _logger = format ["%1 Mags",_cntMags];
    //hint _logger;
    
    _cnt1 = 0;
    {
    	if (_x == _priMag) then
    	{
    		_cnt1 = _cnt1 + 1;
    	};	
    } forEach _magsArr;
    _logger = format ["%1 Mags",_cnt1];
    hint _logger;

     

    Thanks.

     

    Regards,
    Scott


  11. Hi Folks,

     

    By default - most AI driven vehicles seem to be racing around at cartoon like speeds. Has anyone made a mod to limit the speed on all AI driven vehicles for a given scenario? If not - how would I find all the ground vehicles in any scenario to impart said speed restrictions? I guess I would need to leave the script running for the duration to control newly spawned vehicles as well. This is really for missions ran by ALiVE or Drongo's Map Population... 

     

    Thanks.

     

    Regards,

    Scott


  12. Hi JB,

     

    Thanks for all the SP consideration - I always felt we took a back seat to MP stuff.

     

    I was last active back when Mad Cheese was working on C2 - had a bunch of conversations with him - and I enjoyed his mod a great deal. Then when I resurfaced with SOG - I wanted - simpler - instead of micromanaging and spinning mouse wheels in the heat of combat - I just wanted "smarter" more effective AI teammates. You're definitely on the right track.

     

    I'm getting that screen artifact more often now - could it be ACE? Bardosy - perhaps if we share mod lists we can isolate it? I've been trying to pare down my list of mods. I think ACE is the only thing I have that messes with GUI stuff. It's the "No Medical" version for me.

     

    Regards,

    Scott


  13. 3 hours ago, Ibragim A said:

    If you need a script for AI groups, I can recommend this script, which you can add to the activation of the waypoint from which the escape will begin.
    This is code from the GoGoGo mod, but for AI groups.

    Go Go Go! combat mode is terminated by changing the combat mode or behaviour.

     

    Hi Folks,

     

    Absolutely BRILLIANT - sir.

     

    You've made it so easy for me a caveman could do it. 

     

    Thank You!

     

    Here's the updated test mission - if anyone is interested in a working example:

    https://mega.nz/file/JswWWBpA#qNgNiV7BB6KM_MtOniFiCbtJFEUx_fosnY6DHor_BlU

     

    Combat or No Combat - ALL - the troops pack up and try to get the heck out of there.

     

    Nice and easy to restore everyone after the running is done.

     

    This is a keeper.

     

    Regards,

    Scott


  14. 1 hour ago, Ibragim A said:

    If you need a script for AI groups, I can recommend this script, which you can add to the activation of the waypoint from which the escape will begin.
    This is code from the GoGoGo mod, but for AI groups.

    Go Go Go! combat mode is terminated by changing the combat mode or behaviour.

     

     

    Hi Folks,

     

    Hah - now that's a good share - I'll have to give that a try.

     

    Appreciate the help.

     

    My work is still less than satisfactory.

     

    Regards,
    Scott


  15. 43 minutes ago, Harzach said:

     

    You are telling your infantry units to run at 100 meters per second/360KMH.

     

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

     

     

    You might also want to take a look at setBehaviourStrong.

     

    Hah - oops - LOL - they don't really run at 100 (I would have noticed) - I'll fix it.

    😁

     

    I'll look at "setBehaviourStrong" as well.

     

     

     

    It's so odd that it works fine on all but one unit - most of the time - then occasionally works for everyone. I can't identify what's different - on my test runs - or - the one remaining unit always left behind. It's not even Combat Mode causing this - as sometimes I just issue the "withdraw" command and I still have the remaining unit - frozen.

     

     

     

    Regards,

    Scott

×