Jump to content

Inq

Member
  • Posts

    9
  • Joined

  • Last visited

Posts posted by Inq

  1. Could you repost this with the "code" tag so it's formatted properly?

    if(isServer) then {
    
    	private ["_player_near","_map_marker","_node","_max_ai","_timeout_time","_currenttime","_starttime","_msglose","_msgwin","_msgstart","_objectives","_crate","_marker","_in_range","_objectivetarget","_position","_type","_complete","_timeout","_mission","_killpercent","_delete_mines","_cleanunits","_clearmission","_baseclean","_playernear"];
    
    	_mission	= (_this select 0) select 0;
    	_crate		= (_this select 0) select 1;
    	_type		= (_this select 1) select 0;
    	_baseclean	= _this select 2;
    	_msgstart	= _this select 3;
    	_msgwin		= _this select 4;
    	_msglose	= _this select 5;
    
    	_position		= position _crate;
    	_timeout 		= false;
    	_player_near	= false;
    	_complete		= false;
    	_starttime 		= time;
    	_start 			= false;
    	_timeout_time	= ((wai_mission_timeout select 0) + random((wai_mission_timeout select 1) - (wai_mission_timeout select 0)));
    	_max_ai			= (wai_mission_data select _mission) select 0;
    	_killpercent 	= _max_ai - (_max_ai * (wai_kill_percent / 100));
    	_mission_units	= [];
    
    	if((_type == "patrol")) then {
    		_start = true;
    	};
    	
    	if(_type == "bomb") then {
    		_start = true;
    		_timeout_time = wai_timeout_bomb;
    		
    		// Debug 
    		if(debug_mode) then {_timeout_time = 300;};
    	};
    
    	{
    		if (_x getVariable ["mission", nil] == _mission) then {
    			_mission_units set [count _mission_units, _x];
    		};
    
    	} count allUnits;
    	if(debug_mode) then { diag_log("WAI: _mission_units " + str(_mission_units)); };
    	
    	RemoteMessage = [wai_announce,_msgstart];
    	publicVariable "RemoteMessage";
    	
    	markerReady = true;
    
    	while {!_start && !_timeout} do {
    
    		sleep 1;
    		_currenttime = time;
    
    		{
    			if((isPlayer _x) && (_x distance _position <= 1500)) then {
    				_start = true
    			};
    
    		} count playableUnits;
    
    		if (_currenttime - _starttime >= _timeout_time) then {
    			_timeout = true;
    		};
    
    	};
    
    	{	
    		_x enableAI "TARGET";
    		_x enableAI "AUTOTARGET";
    		_x enableAI "MOVE";
    		_x enableAI "ANIM";
    		_x enableAI "FSM";
    		_x setRank  "Private";
    	} count _mission_units;
    
    	while {!_timeout && !_complete} do {
    
    		sleep 1;
    		_currenttime = time;
    		{
    			if((isPlayer _x) && (_x distance _position <= wai_timeout_distance) && (_type != "bomb") ) then {
    				_player_near = true;
    			};
    			
    		} count playableUnits;
    
    		if (_currenttime - _starttime >= _timeout_time && !_player_near) then {
    			_timeout = true;
    		};
    		
    		call {
    
    			if (_type == "crate") exitWith {
    
    				if(wai_kill_percent == 0) then {
    
    					{
    						if((isPlayer _x) && (_x distance _position <= 30)) then {
    							_complete = true;
    						};
    					} count playableUnits;
    
    				} else {
    
    					if(((wai_mission_data select _mission) select 0) <= _killpercent) then {
    						{
    							if((isPlayer _x) && (_x distance _position <= 30)) then {
    								_complete = true;
    							};
    						} count playableUnits;
    					};
    
    				};
    
    			};
    
    			if (_type == "kill") exitWith {
    				if(((wai_mission_data select _mission) select 0) == 0) then {
    					_complete = true;
    				};
    			};
    
    			if (_type == "patrol") exitWith {
    				if(((wai_mission_data select _mission) select 0) == 0) then {
    					_complete = true;
    				};
    			};
    			
    			if (_type == "assassinate") exitWith {
    				_objectivetarget = (_this select 1) select 1;
    				{
    					_complete = true;
    					if (alive _x) exitWith {_complete = false;};
    				} count units _objectivetarget;
    			};
    			
    			if (_type == "bomb") exitWith {
    				{
    					if((isPlayer _x) && (_x distance _position <= 2.5)) then {
    						_complete = true;
    					};
    				} count playableUnits;
    			};
    
    			if (_type == "resource") exitWith {
    					{
    						if((isPlayer _x) && (_x distance _position <= 30)) then {
    							_complete = true;
    						};
    					} count playableUnits;
    
    			};
    		};
    	};
    
    	if (_complete) then {
    
    		if (typeOf(_crate) in (crates_large + crates_medium + crates_small)) then {
    
    			if(wai_crates_smoke && sunOrMoon == 1) then {
    				_marker = "SmokeShellPurple" createVehicle getPosATL _crate;
    				_marker setPosATL (getPosATL _crate);
    				_marker attachTo [_crate,[0,0,0]];
    			};
    
    			if (wai_crates_flares && sunOrMoon != 1) then {
    				_marker = "B_IR_Grenade" createVehicle getPosATL _crate;
    				_marker setPosATL (getPosATL _crate);
    				_marker attachTo [_crate, [0,0,0]];
    			};
    
    		};
    		
    
    		
    
    		_delete_mines = ((wai_mission_data select _mission) select 2);
    
    		if(count _delete_mines > 0) then {
    		
    			{
    				if(typeName _x == "ARRAY") then {
    					{
    						deleteVehicle _x;
    					} count _x;
    				} else {
    					deleteVehicle _x;	
    				};
    				
    			} forEach _delete_mines;
    			
    		};
    		
    		// WINNING
    		RemoteMessage = [wai_announce,_msgwin];
    		publicVariable "RemoteMessage";
    		
    		if (wai_clean_mission) then {
    
    			[_position,_baseclean,_mission] spawn {
    				private ["_pos","_clean","_finish_time","_cleaned","_playernear","_currenttime","_miss"];
    				_pos = _this select 0;
    				_clean = _this select 1;
    				_miss = _this select 2;
    				_finish_time = time;
    				_playernear = false;
    				
    				while {true} do {
    					_currenttime = time;
    					
    
    					{
    						if ((isPlayer _x) && (_x distance _pos < 1000)) then { _playernear = true } else { _playernear = false}
    					} count playableUnits;	
    					
    					if ((!_playernear) && (_currenttime - _finish_time >= wai_clean_mission_time))  exitWith {};
    					sleep 1;
    				};
    
    
    					//if ((_currenttime - _finish_time >= wai_clean_mission_time) && !_playernear) then {
    					if (!_playernear) then {
    
    						{
    							if(typeName _x == "ARRAY") then {
    			
    							{
    							deleteVehicle _x;
    							//if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };
    							} count _x;
    			
    							} else {
    			
    								deleteVehicle _x;
    								//if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };
    							};
    							
    						} forEach _clean;
    
    
    					// Delete AI
    						{
    		
    						if (_x getVariable ["mission", nil] == _miss) then {
    			
    						if (alive _x) then {
    
    						_cleanunits = _x getVariable ["missionClean",nil];
    		
    						if (!isNil "_cleanunits") then {
    				
    							call {
    								if(_cleanunits == "ground") 	exitWith { ai_ground_units = (ai_ground_units -1); };
    								if(_cleanunits == "air") 		exitWith { ai_air_units = (ai_air_units -1); };
    								if(_cleanunits == "vehicle") 	exitWith { ai_vehicle_units = (ai_vehicle_units -1); };
    								if(_cleanunits == "static") 	exitWith { ai_emplacement_units = (ai_emplacement_units -1); };
    									};
    								};
    							};
    				
    						deleteVehicle _x;
    						if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };
    						};
    
    						} count allUnits + vehicles + allDead;
    		
    					};
    					
    
    			};
    		};
    	};
    	
    	if (_timeout) then {
    		
    		//BOMB STUFF 
    		if(_type == "bomb") then {
    			private["_bomb"];
    			{
    				// only send to players with in view distance
    				if((isPlayer _x) && (_x distance _position <= 2500)) then {
    					// Magic happens
    					WAIclient = ["nuke",_position];
    					publicVariable "WAIclient";
    				};
    			} count playableUnits;
    			
    			// Wait for countdown
    			sleep 20;
    			{
    				_bomb = "Bo_GBU12_LGB_MI10" createVehicle (getPos _x);
    				_bomb setVectorDirAndUp [[0,0,1],[0,-1,0]];
    				_bomb setVelocity [0,0,-1000];
    				_x setDamage 1;
    			} forEach (_position nearObjects (wai_blacklist_range - 50));// Player base protection
    		};
    		
    		// Delete AI
    		{
    		
    			if (_x getVariable ["mission", nil] == _mission) then {
    			
    				if (alive _x) then {
    
    					_cleanunits = _x getVariable ["missionClean",nil];
    		
    					if (!isNil "_cleanunits") then {
    				
    						call {
    							if(_cleanunits == "ground") 	exitWith { ai_ground_units = (ai_ground_units -1); };
    							if(_cleanunits == "air") 		exitWith { ai_air_units = (ai_air_units -1); };
    							if(_cleanunits == "vehicle") 	exitWith { ai_vehicle_units = (ai_vehicle_units -1); };
    							if(_cleanunits == "static") 	exitWith { ai_emplacement_units = (ai_emplacement_units -1); };
    						};
    					};
    				};
    				
    				deleteVehicle _x;
    				if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };
    			};
    
    		} count allUnits + vehicles + allDead;
    		
    		// Delete scenery
    		{
    			if(typeName _x == "ARRAY") then {
    			
    				{
    					deleteVehicle _x;
    					//if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };
    				} count _x;
    			
    			} else {
    			
    				deleteVehicle _x;
    				//if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };
    			};
    			
    		} forEach _baseclean + ((wai_mission_data select _mission) select 2) + [_crate];
    
    		// Loosing
    		RemoteMessage = [wai_announce,_msglose];
    		publicVariable "RemoteMessage";
    	};
    	
    	_map_marker = (wai_mission_data select _mission) select 1;
    	wai_mission_markers = wai_mission_markers - [(_map_marker + str(_mission))];
    	wai_mission_data set [_mission, -1];
    	_complete
    
    };
    
  2. Hey guys has any one had issues with the mission rebel base not despawning when completed(all ai killed) if so is there a fix, also the mission seems to always spawn in Novy and was wondering if anyone has a way to fix this as the base seems to spawn inside buildings. I can email anyone that wants to help the current .sqf file for said mission or the whole pbo if they would like to take a look at it.

     

    I got a custom version of WAI with new missions etc. This fixes the cleanup after completing a mission. Deletes all the mission objects (except the crate) and straggler ai if the mission has been completed after the time set in the config.sqf under: wai_clean_mission_time.

     

    Change mission_winorfail.sqf to this:

     

    if(isServer) then {

    private ["_player_near","_map_marker","_node","_max_ai","_timeout_time","_currenttime","_starttime","_msglose","_msgwin","_msgstart","_objectives","_crate","_marker","_in_range","_objectivetarget","_position","_type","_complete","_timeout","_mission","_killpercent","_delete_mines","_cleanunits","_clearmission","_baseclean","_playernear"];

    _mission = (_this select 0) select 0;

    _crate = (_this select 0) select 1;

    _type = (_this select 1) select 0;

    _baseclean = _this select 2;

    _msgstart = _this select 3;

    _msgwin = _this select 4;

    _msglose = _this select 5;

    _position = position _crate;

    _timeout = false;

    _player_near = false;

    _complete = false;

    _starttime = time;

    _start = false;

    _timeout_time = ((wai_mission_timeout select 0) + random((wai_mission_timeout select 1) - (wai_mission_timeout select 0)));

    _max_ai = (wai_mission_data select _mission) select 0;

    _killpercent = _max_ai - (_max_ai * (wai_kill_percent / 100));

    _mission_units = [];

    if((_type == "patrol")) then {

    _start = true;

    };

    if(_type == "bomb") then {

    _start = true;

    _timeout_time = wai_timeout_bomb;

    // Debug

    if(debug_mode) then {_timeout_time = 300;};

    };

    {

    if (_x getVariable ["mission", nil] == _mission) then {

    _mission_units set [count _mission_units, _x];

    };

    } count allUnits;

    if(debug_mode) then { diag_log("WAI: _mission_units " + str(_mission_units)); };

    RemoteMessage = [wai_announce,_msgstart];

    publicVariable "RemoteMessage";

    markerReady = true;

    while {!_start && !_timeout} do {

    sleep 1;

    _currenttime = time;

    {

    if((isPlayer _x) && (_x distance _position <= 1500)) then {

    _start = true

    };

    } count playableUnits;

    if (_currenttime - _starttime >= _timeout_time) then {

    _timeout = true;

    };

    };

    {

    _x enableAI "TARGET";

    _x enableAI "AUTOTARGET";

    _x enableAI "MOVE";

    _x enableAI "ANIM";

    _x enableAI "FSM";

    _x setRank "Private";

    } count _mission_units;

    while {!_timeout && !_complete} do {

    sleep 1;

    _currenttime = time;

    {

    if((isPlayer _x) && (_x distance _position <= wai_timeout_distance) && (_type != "bomb") ) then {

    _player_near = true;

    };

    } count playableUnits;

    if (_currenttime - _starttime >= _timeout_time && !_player_near) then {

    _timeout = true;

    };

    call {

    if (_type == "crate") exitWith {

    if(wai_kill_percent == 0) then {

    {

    if((isPlayer _x) && (_x distance _position <= 30)) then {

    _complete = true;

    };

    } count playableUnits;

    } else {

    if(((wai_mission_data select _mission) select 0) <= _killpercent) then {

    {

    if((isPlayer _x) && (_x distance _position <= 30)) then {

    _complete = true;

    };

    } count playableUnits;

    };

    };

    };

    if (_type == "kill") exitWith {

    if(((wai_mission_data select _mission) select 0) == 0) then {

    _complete = true;

    };

    };

    if (_type == "patrol") exitWith {

    if(((wai_mission_data select _mission) select 0) == 0) then {

    _complete = true;

    };

    };

    if (_type == "assassinate") exitWith {

    _objectivetarget = (_this select 1) select 1;

    {

    _complete = true;

    if (alive _x) exitWith {_complete = false;};

    } count units _objectivetarget;

    };

    if (_type == "bomb") exitWith {

    {

    if((isPlayer _x) && (_x distance _position <= 2.5)) then {

    _complete = true;

    };

    } count playableUnits;

    };

    if (_type == "resource") exitWith {

    {

    if((isPlayer _x) && (_x distance _position <= 30)) then {

    _complete = true;

    };

    } count playableUnits;

    };

    };

    };

    if (_complete) then {

    if (typeOf(_crate) in (crates_large + crates_medium + crates_small)) then {

    if(wai_crates_smoke && sunOrMoon == 1) then {

    _marker = "SmokeShellPurple" createVehicle getPosATL _crate;

    _marker setPosATL (getPosATL _crate);

    _marker attachTo [_crate,[0,0,0]];

    };

    if (wai_crates_flares && sunOrMoon != 1) then {

    _marker = "B_IR_Grenade" createVehicle getPosATL _crate;

    _marker setPosATL (getPosATL _crate);

    _marker attachTo [_crate, [0,0,0]];

    };

    };

    _delete_mines = ((wai_mission_data select _mission) select 2);

    if(count _delete_mines > 0) then {

    {

    if(typeName _x == "ARRAY") then {

    {

    deleteVehicle _x;

    } count _x;

    } else {

    deleteVehicle _x;

    };

    } forEach _delete_mines;

    };

    // WINNING

    RemoteMessage = [wai_announce,_msgwin];

    publicVariable "RemoteMessage";

    if (wai_clean_mission) then {

    [_position,_baseclean,_mission] spawn {

    private ["_pos","_clean","_finish_time","_cleaned","_playernear","_currenttime","_miss"];

    _pos = _this select 0;

    _clean = _this select 1;

    _miss = _this select 2;

    _finish_time = time;

    _playernear = false;

    while {true} do {

    _currenttime = time;

    {

    if ((isPlayer _x) && (_x distance _pos < 1000)) then { _playernear = true } else { _playernear = false}

    } count playableUnits;

    if ((!_playernear) && (_currenttime - _finish_time >= wai_clean_mission_time)) exitWith {};

    sleep 1;

    };

    //if ((_currenttime - _finish_time >= wai_clean_mission_time) && !_playernear) then {

    if (!_playernear) then {

    {

    if(typeName _x == "ARRAY") then {

    {

    deleteVehicle _x;

    //if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };

    } count _x;

    } else {

    deleteVehicle _x;

    //if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };

    };

    } forEach _clean;

    // Delete AI

    {

    if (_x getVariable ["mission", nil] == _miss) then {

    if (alive _x) then {

    _cleanunits = _x getVariable ["missionClean",nil];

    if (!isNil "_cleanunits") then {

    call {

    if(_cleanunits == "ground") exitWith { ai_ground_units = (ai_ground_units -1); };

    if(_cleanunits == "air") exitWith { ai_air_units = (ai_air_units -1); };

    if(_cleanunits == "vehicle") exitWith { ai_vehicle_units = (ai_vehicle_units -1); };

    if(_cleanunits == "static") exitWith { ai_emplacement_units = (ai_emplacement_units -1); };

    };

    };

    };

    deleteVehicle _x;

    if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };

    };

    } count allUnits + vehicles + allDead;

    };

    };

    };

    };

    if (_timeout) then {

    //BOMB STUFF

    if(_type == "bomb") then {

    private["_bomb"];

    {

    // only send to players with in view distance

    if((isPlayer _x) && (_x distance _position <= 2500)) then {

    // Magic happens

    WAIclient = ["nuke",_position];

    publicVariable "WAIclient";

    };

    } count playableUnits;

    // Wait for countdown

    sleep 20;

    {

    _bomb = "Bo_GBU12_LGB_MI10" createVehicle (getPos _x);

    _bomb setVectorDirAndUp [[0,0,1],[0,-1,0]];

    _bomb setVelocity [0,0,-1000];

    _x setDamage 1;

    } forEach (_position nearObjects (wai_blacklist_range - 50));// Player base protection

    };

    // Delete AI

    {

    if (_x getVariable ["mission", nil] == _mission) then {

    if (alive _x) then {

    _cleanunits = _x getVariable ["missionClean",nil];

    if (!isNil "_cleanunits") then {

    call {

    if(_cleanunits == "ground") exitWith { ai_ground_units = (ai_ground_units -1); };

    if(_cleanunits == "air") exitWith { ai_air_units = (ai_air_units -1); };

    if(_cleanunits == "vehicle") exitWith { ai_vehicle_units = (ai_vehicle_units -1); };

    if(_cleanunits == "static") exitWith { ai_emplacement_units = (ai_emplacement_units -1); };

    };

    };

    };

    deleteVehicle _x;

    if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };

    };

    } count allUnits + vehicles + allDead;

    // Delete scenery

    {

    if(typeName _x == "ARRAY") then {

    {

    deleteVehicle _x;

    //if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };

    } count _x;

    } else {

    deleteVehicle _x;

    //if(debug_mode) then { diag_log("WAI: DELETE " + str(_x)); };

    };

    } forEach _baseclean + ((wai_mission_data select _mission) select 2) + [_crate];

    // Loosing

    RemoteMessage = [wai_announce,_msglose];

    publicVariable "RemoteMessage";

    };

    _map_marker = (wai_mission_data select _mission) select 1;

    wai_mission_markers = wai_mission_markers - [(_map_marker + str(_mission))];

    wai_mission_data set [_mission, -1];

    _complete

    };

  3. I have a question for you. If I want to switch out the quad bike on the moving mission (the boys and gals are not the best drives on bornholms bumpy roads), from what file are they getting the vehicle list?

    SupplyConvoy.sqf, line 33

     

    _convoyVeh1 =    ["C_Quadbike_01_EPOCH",_startPos,1,0,_dir] call SEM_fnc_spawnVehicle;

     

    Alternatively, if its the bad Ai driving thats the problem, change Fn_Aiconvoy.sqf to this:

     

    /* KiloSwiss */

    private["_group","_endPos","_missionID","_mainVehicle","_convoyVehicles","_enterableVehicles","_convoyGrps","_ranks","_side","_vehiclePos","_vehFrontPos","_veh1","_veh2","_veh3","_start"];

    _group = _this select 0;

    _endPos = _this select 1;

    _missionID = _this select 2;

    _mainVehicle = _this select 3;

    _convoyVehicles = _this select 4;

    _enterableVehicles = _this select 5;

    /* Marker position update */

    _this spawn { private["_endPos","_missionID","_mainVehicle","_oldPos","_newPos"];

    _endPos = _this select 1;

    _missionID = _this select 2;

    _mainVehicle = _this select 3;

    _oldPos = position _mainVehicle;

    while{alive _mainVehicle && _mainVehicle distance _endPos > 50}do{

    UIsleep 10;

    _newPos = position _mainVehicle;

    if(_oldPos distance _newPos > 10)then{

    _oldPos = _newPos;

    SEM_updateMissionMarkerPos = [_missionID, _newPos];

    publicVariable "SEM_updateMissionMarkerPos";

    if(!isDedicated)then{SEM_updateMissionMarkerPos call SEM_client_updateMissionMarkerPos};

    };

    };

    };

    _units = (units _group);

    _side = side (_units select 0);

    _startPos = getPos _mainVehicle;

    _vehFront = (if(count _convoyVehicles == 1)then[{_mainVehicle},{{if(_x != _mainVehicle)exitWith{_x}; (_convoyVehicles select 0)}count _convoyVehicles}]);

    {_x setVariable ["AIskill",(skill _x)]}count _units;

    _ranks = ["COLONEL","MAJOR","CAPTAIN","LIEUTENANT","SERGEANT","CORPORAL","PRIVATE"];

    {

    _x setFuel 1;

    _x setDamage 0;

    _group addVehicle _x;

    if(_x in _enterableVehicles)then[{_x lock 0},{_x lock 3}];

    _x setVariable ["AIrank", (_ranks select (_forEachIndex min (count _ranks -1)))];

    _x addEventHandler ["getIn",{

    (_this select 2) setUnitRank ((_this select 0) getVariable ["AIrank","PRIVATE"]);

    if(((_this select 1) == "driver") && (driver (_this select 2) != player))then{

    (_this select 2) setSkill 1;

    (_this select 0) addEventhandler ["EpeContactStart",{(_this select 0) setdamage 0}];

    };

    }];

    _x addEventHandler ["getOut",{

    (_this select 2) setSkill ((_this select 2) getVariable ["AIskill",0.7]);

    if((_this select 1) == "driver")then{

    (_this select 0) removeeventHandler ["EpeContactStart",0];

    };

    }];

    _x addeventHandler ["handleDamage",{

    if(isNull (_this select 3))then{false};

    }];

    _x addEventhandler ["EpeContactStart",{if (driver (_this select 0) != player) then {(_this select 0) setdamage 0}}];

    // Fill driver seats first

    (_units select _forEachIndex) assignAsDriver _x;

    //(_units select _forEachIndex) moveInDriver _x;

    //(_units select _forEachIndex) setSkill 1;

    //(_units select _forEachIndex) setUnitRank (_x getVariable ["AIrank","PRIVATE"]);

    if(_x emptyPositions "GUNNER" > 0)then{ // Assign a gunner

    _x allowCrewInImmobile true; //allow gunner to stay in immobilized vehicle

    (_units select (_forEachIndex + (count _convoyVehicles))) assignAsGunner _x;

    //(_units select (_forEachIndex + (count _convoyVehicles))) moveInGunner _x;

    //(_units select (_forEachIndex + (count _convoyVehicles))) setUnitRank (_x getVariable ["AIrank","PRIVATE"]);

    };

    }forEach _convoyVehicles;

    //Order all Units to get in

    _units allowGetIn true;

    _units orderGetIn true;

    //Wait until every unit has boarded a vehicle

    _start = time;

    waitUntil{sleep 1;{(alive _x && vehicle _x == _x)}count _units == 0 || time - _start >= 30};

    if({alive _x && vehicle _x == _x}count _units > 0)then{

    { /* Move stuck AI into vehicles */

    if(vehicle _x == _x)then{

    _y = _x;

    { /* Fill driver/gunner seats first */

    if(_x emptyPositions "DRIVER" > 0)exitWith{_y moveInDriver _x; _y setSkill 1};

    if(_x emptyPositions "GUNNER" > 0)exitWith{_y moveInGunner _x};

    }forEach _convoyVehicles;

    { /* Fill cargo seats */

    if(_x emptyPositions "CARGO" > 0)exitWith{_y moveInCargo _x};

    }forEach (_convoyVehicles - [_mainVehicle]);

    };

    _x setUnitRank ((vehicle _x) getVariable ["AIrank","PRIVATE"]);

    }forEach _units;

    };

    //-- Get lowest TopSpeed from all vehicles

    _topSpeeds = [];

    {

    _maxSpd = getNumber (configFile >> "cfgVehicles" >> typeOf _x >> "maxSpeed");

    if(!isNil "_maxSpd")then{_topSpeeds pushBack _maxSpd};

    }forEach _convoyVehicles;

    _select = 0;

    _maxSpd = _topSpeeds select _select;

    while{{_maxSpd > _x}count _topSpeeds != 0}do{

    _select = _select + 1;

    _maxSpd = _topSpeeds select _select;

    };

    {_x forceSpeed (_maxSpd*0.8)*0.2777778}forEach _convoyVehicles; // m/s

    //DEBUG

    if(SEM_debug in ["log","full"])then{diag_log format["SEM DEBUG: Convoy Vehicles TopSpeeds: %1 - Selected lowest: %2", _topSpeeds, _maxSpd]};

    hint "convoy start";

    //_group move _endPos;

    {driver _x move _endPos}count _convoyVehicles;

    _group setSpeedMode "FULL";//"FULL";

    _group setBehaviour "SAFE"; //"CARELESS";

    _group setCombatMode "GREEN";

    _group setFormation "COLUMN";

    sleep 30;

    /* temporary definition of 3 vehicles */

    _veh1 = _convoyVehicles select 0;

    _veh2 = _convoyVehicles select 1;

    _veh3 = _convoyVehicles select 2;

    _lastMoveCheck = time;

    _oldPos = getPos _mainVehicle;

    /* Convoy loop */

    _stayToDefend = true;

    while{{_x distance _endPos < 20}count _convoyVehicles < 1}do{ //CONVOY LOOP

    _vehiclePos = getPos _mainVehicle;

    _vehFrontPos = getPos _vehFront;

    if({!canMove _x}count _convoyVehicles > 0 && _stayToDefend)then{

    {if(canMove _x)then{(driver _x) doMove _vehiclePos}}forEach _convoyVehicles;

    sleep 5;

    {

    if(_x distance _vehiclePos < 50)then[{

    if(_x != gunner (vehicle _x))then{

    _x action ["GetOut", (vehicle _x)];

    sleep 0.5;

    [_x] orderGetIn false;

    [_x] allowGetIn false;

    _x doMove _vehiclePos;

    };

    },{

    _x doMove _vehiclePos;

    }];

    }forEach units _group;

    _group move _vehiclePos;

    _group setSpeedMode "FULL";

    if({_x distance _veh2 < 50}count units _group == count units _group)then{

    _endPos = _vehiclePos;

    };

    }else{

    //-- Work In Progress!

    if({alive _x && !(vehicle _x in _convoyVehicles)}count units _group > 0)then{ //AI has left the vehicle

    hint "AI has left the vehicle";

    _group setBehaviour "CARELESS";

    _group setCombatMode "GREEN";

    {

    if(!(vehicle _x in _convoyVehicles))then{

    [_x] allowGetIn true;

    [_x] orderGetIn true;

    };

    }forEach units _group;

    sleep 10; //Brake the loop for 10 seconds

    _group move _endPos;

    //_group setSpeedMode "NORMAL";

    }else{ //Do vehicle speed management and continue travel to destination

    //_group move _endPos;

    //{driver _x move _endPos}count _convoyVehicles;

    _group setBehaviour "SAFE";

    _group setCombatMode "GREEN";

    //_group setFormation "COLUMN";//"FILE";

    _group setSpeedMode "FULL";

    if(time - _lastMoveCheck > 60)then{

    _group move _endPos;

    _lastMoveCheck = time;

    if(_vehiclePos distance _oldPos < 30)then[{

    hint "Convoy is stuck";

    //FAILSAFE IF CONVOY IS STUCK

    {driver _x doMove _endPos}count _convoyVehicles;

    //_group setSpeedMode "FULL";

    sleep 20; //Brake the loop for 20 seconds

    if(_vehiclePos distance _oldPos < 10)then{

    _endPos = _vehiclePos;

    };

    },{_group move _endPos}];

    _oldPos = getPos _mainVehicle;

    _group move _endPos;

    };

    //-- Distance Checks

    // forceSpeed = m/s

    // limitSpeed = km/h

    // 1 km/h == ~0.2777778 m/s

    /*

    //Check Formation

    _distanceA = _veh1 distance _veh2;

    _distanceB = _veh1 distance _veh3;

    if(_distanceA > _distanceB)then{

    _3inFrontOf2 = [_veh2, _veh3, 0] call BIS_fnc_isInFrontOf;

    if(_3inFrontOf2 || abs(_distanceA - _distanceB) > 10)then{//Swap Vehicles position in convoy (2 <-> 3)

    //diag_log format["A: Distance 1-2: %1 - Distance 1-3: %2", round (_veh1 distance _veh2), round (_veh1 distance _veh3)];

    _vehinMiddle = _veh3;

    _veh3 = _veh2;

    _veh2 = _vehinMiddle;

    //diag_log format["B: Distance 1-2: %1 - Distance 1-3: %2", round (_veh1 distance _veh2), round (_veh1 distance _veh3)];

    };

    };

    */

    //Speed Management for Vehicle 1

    if(_veh1 distance _veh2 > 80 || _veh1 distance _veh3 > 120)then{

    if(_veh1 distance _veh2 > 90 || _veh1 distance _veh3 > 130)then{

    //_veh1 forceSpeed (_maxSpd*0.1)*0.2777778;

    _veh1 limitSpeed 0;

    }else{

    if(speed _veh3 < 10)then{

    //_veh1 forceSpeed (1 max (speed _veh3)*0.2777778);

    _veh1 limitSpeed (1 max (speed _veh3));

    }else{

    //_veh1 forceSpeed (_maxSpd*0.4)*0.2777778;

    _veh1 limitSpeed (_maxSpd*0.4);

    };

    };

    }else{

    if(speed _veh3 < 10)then{

    //_veh1 forceSpeed (_maxSpd*0.1)*0.2777778;

    _veh1 limitSpeed (_maxSpd*0.1);

    }else{

    //_veh1 forceSpeed (_maxSpd*0.8)*0.2777778; //-- m/s

    _veh1 limitSpeed (_maxSpd*0.8);

    };

    };

    //Speed Management for Vehicle 2

    if(_veh2 distance _veh1 > 80)then{

    if(_veh2 distance _veh3 < _veh2 distance _veh1)then{

    //_veh2 forceSpeed (_maxSpd*0.8)*0.2777778;

    _veh2 limitSpeed (_maxSpd*0.8);

    }else{

    //Move faster to catch up with Vehicle1

    //_veh2 forceSpeed _maxSpd*0.2777778;

    _veh2 limitSpeed _maxSpd;

    };

    }else{

    if(_veh2 distance _veh1 < 50)then{

    //_veh2 forceSpeed (1 max (speed _veh1)*0.2777778);

    _veh2 limitSpeed (1 max (speed _veh1));

    }else{

    if(_veh2 distance _veh3 > _veh2 distance _veh1)then{ //let Vehicle3 catch up

    //_veh2 forceSpeed (_maxSpd*0.5)*0.2777778;

    _veh2 limitSpeed (_maxSpd*0.5);

    }else{

    //_veh2 forceSpeed (_maxSpd*0.8)*0.2777778;

    _veh2 limitSpeed (_maxSpd*0.8);

    };

    };

    };

    //Speed Management for Vehicle 3

    if(_veh3 distance _veh2 > 80 || _veh3 distance _veh1 > 150)then{ //catch up

    if(_veh3 distance _veh2 < 40)then{

    //_veh3 forceSpeed (1 max (speed _veh2)*0.2777778);

    _veh3 limitSpeed (1 max (speed _veh2));

    }else{

    //_veh3 forceSpeed _maxSpd*0.2777778;

    _veh3 limitSpeed _maxSpd;

    };

    }else{

    if(_veh3 distance _veh2 < 40)then{

    //_veh3 forceSpeed (1 max (speed _veh2)*0.2777778);

    _veh3 limitSpeed (1 max (speed _veh2));

    }else{

    //if(speed _veh1 < 10)then{ //FAILSAFE IF CONVOY IS STUCK

    // (driver _veh3) doMove (getPos _veh1);

    //_veh3 forceSpeed (_maxSpd*0.8)*0.2777778;

    // _veh3 limitSpeed (_maxSpd*0.8);

    //}else{

    //_veh3 forceSpeed (_maxSpd*0.8)*0.2777778;

    _veh3 limitSpeed (_maxSpd*0.8);

    //};

    };

    };

    };

    };

    //code to end the while

    _unitsAlive = ({alive _x}count units _group);

    if(_unitsAlive < 1) then {

    _endPos = _vehiclePos;

    };

    if (damage _mainVehicle == 1) then {

    _endPos = _vehiclePos;

    };

    if({isPlayer _x && alive _x}count crew _mainVehicle > 0)then{

    doStop (units _group);

    {

    _x spawn{

    _this action ["engineOff", (vehicle _this)];

    sleep 0.5;

    deleteVehicle _this;

    };

    }foreach units _group;

    _endPos = _vehiclePos;

    };

    UIsleep 1;

    }; //END OF LOOP

    hint "Dynamic Mission Status: Convoy Ended";

    if({alive _x}count units _group > 0 && damage _mainVehicle < 1)then{

    _group move _vehiclePos;

    sleep 10;

    {

    if(_x != gunner (vehicle _x))then{

    [_x,_vehiclePos] spawn{ private "_unit";

    _unit = _this select 0;

    doStop _unit;

    sleep 1;

    _unit action ["engineOff", (vehicle _unit)];

    _unit action ["GetOut", (vehicle _unit)];

    unassignVehicle _unit;

    sleep 0.1;

    [_unit] orderGetIn false;

    [_unit] allowGetIn false;

    };

    };

    }forEach (units _group);

    _group move _vehiclePos;

    _group setBehaviour "AWARE";

    _group setFormation "FILE";

    _group setCombatMode "YELLOW";

    [_group, _vehiclePos] call SEM_fnc_AImove;

    };

     

    It makes the cars immune to crash damage while the ai is driving, if a player is driving it does nothing.

  4. Using stock epochAH, players get kicked and an admin ban if they run over mission AI.  Redis log is showing ": Crypto: -150".

     

    I 'think" it's when the semclient SEM_Krypto_AIroadkill publiceventhandler triggers.  Why players aren't being kicked for gaining crypto on killing AI is beyond me.

     

    Players get put on the bans.txt and can't get back on until the entry is removed and the server is restarted.  I'm in favour of punishing roadkilling mission AI, but that's a tad drastic!

     

    Any ideas on how to fix this?  (Without disabling the stock AH)

     

    SEM_Krypto_AIroadkill = 0;    // How much Krypto will be removed by punishing players for AI roadkills. make sure this is 0 and it won't happen.

  5. gorgon, BTR any armoured vehicle that uses a 30mm cannon

     

    Till BIS fix their game or Halv can think of a better way - heres a inefficient way of adding cannon ammo :P In Service_point.sqf change the bit that starts_fnc_getammo = {... to this :

    _fnc_getAmmo = {

    private ["_vehicle","_role","_weapons","_cannon"];

    _vehicle = _this select 0;

    _weapon = _this select 1;

    _cannon = weapons _vehicle;

    _allammo = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines");

    if ("autocannon_40mm_CTWS" in _cannon) then {_allammo = _allammo + ["40Rnd_40mm_APFSDS_shells","60Rnd_40mm_GPR_shells"]};

    if (("autocannon_30mm" in _cannon) || ("autocannon_30mm_CTWS" in _cannon)) then {_allammo = _allammo + ["140Rnd_30mm_MP_shells","60Rnd_30mm_APFSDS_shells"]};

    _ammoreturn = [];

    {

    _curammo = _x;

    if !(_curammo in _NoGoAmmoCName) then{

    _ammoname = getText (configFile >> "Cfgmagazines" >> _curammo >> "displayName");

    _ammoreturn set [count _ammoreturn, [_curammo, _ammoname]];

    };

    }forEach _allammo;

    _ammoreturn

    };

  6. For anyone trying to add a AI Hellcat without rockets, change A3EAI_removeMissiles.sqf  to this.

     

    if ((typeName _this) != "OBJECT") exitWith {};



    private ["_vehicleWeapons","_turretWeapons","_turretMags","_cursorAim","_missileMags","_vehicleMags","_missileTurMags"];

    _vehicleWeapons = +(weapons _this);
    _vehicleMags = +(magazines _this);
    _turretWeapons = +(_this weaponsTurret [-1]);
    _turretMags = +(_this magazinesTurret [-1]);

    {
    _cursorAim = [configFile >> "CfgWeapons" >> _x,"cursorAim",""] call BIS_fnc_returnConfigEntry;
    if ((toLower _cursorAim) in ["missile","rocket"]) then {
    _missileMags = [configFile >> "CfgWeapons" >> _x,"magazines",[]] call BIS_fnc_returnConfigEntry;
    { if (_x in _vehicleMags) then { _this removeMagazines _x; }; } count _missileMags;
    _this removeWeapon _x;
    if (A3EAI_debugLevel > 1) then {diag_log format ["A3EAI Extended Debug: Removed missile/rocket weapon %1 from vehicle %2.",_x,(typeOf _this)];};
    };
    } forEach _vehicleWeapons;

    {
    _cursorAim = [configFile >> "CfgWeapons" >> _x,"cursorAim",""] call BIS_fnc_returnConfigEntry;
    if ((toLower _cursorAim) in ["missile","rocket"]) then {
    _missileTurMags = [configFile >> "CfgWeapons" >> _x,"magazines",[]] call BIS_fnc_returnConfigEntry;
    { if (_x in _turretMags) then { _this removeMagazinesTurret [_x,[-1]]; }; } count _missileTurMags;
    _this removeWeaponTurret [_x,[-1]];
    if (A3EAI_debugLevel > 1) then {diag_log format ["A3EAI Extended Debug: Removed turret missile/rocket weapon %1 from vehicle %2.",_x,(typeOf _this)];};
    };
    } forEach _turretWeapons;

    true

  7. Got this to work for the Pawnee and Orca, still doesn't work for the Hellcat, something to do with the weapons actually being mounted on a gunners position or something, because of the camera.

     

     

    https://community.bistudio.com/wiki/removeWeaponGlobal- second example worked, how I didn't find and try this earlier I have no freaking idea.

     

    { if (typeOf _x == "B_Heli_Light_01_armed_F") then { _x removeWeaponGlobal "missiles_DAR"; }; } forEach vehicles;

    { if (typeOf _x == "O_Heli_Light_02_F") then { _x removeWeaponGlobal "missiles_DAGR"; }; } forEach vehicles;

     

     

    For Hellcat it is:

     

    { if (typeOf _x == "I_Heli_light_03_F") then { _x removeWeaponTurret ["missiles_DAR",[-1]]; }; } forEach vehicles;

     

    This format also works for Pawnee and Orca. Eg:

     

    { if (typeOf _x == "B_Heli_Light_01_armed_F") then { _x removeWeaponTurret ["missiles_DAR",[-1]]; }; } forEach vehicles;

×
×
  • Create New...