Jump to content

Donnovan

Member
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by Donnovan

  1. If you like my work, please consider a donation:

     

    btn_donate_LG.gif $USD

     

    btn_donate_LG.gif $EURO

     

    Please just donate after the script works to you.

    Here is the new Version! You will love it!

     

    To stop the convoy you need to shot the convoy vehicles or any of the AI.

    IMPORTANT: If your sleep around line 371 is not "sleep 2.5;" you is using an old version, please get the file again, bellow. Thankyou!

    //===========================================
    //THIS VERSION IS FOR ARMA 2: ANDRE CONVOYS
    //===========================================
    
    if (isServer) then {
    	//=======================
    	//BASIC KONFIGURATION 1!
    	//=======================
    
    	//Vehicles: Its ok to repeate the same car with different configuration.
    	donn_carsConvy = [
    		//(0) Vehicle Unarmored Armed low Capacity
    		["Offroad_DSHKM_Gue",0,["150Rnd_127x107_DSHKM"]],
    		//(1) Vehicle Unarmored Unarmed Mediun Capacity
    		["BAF_Offroad_D",2,[]],
    		//(2) Vehicle Unarmed Armored High Capacity
    		["BTR40_TK_GUE_EP1",4,[]],
    		//(3) Vehicle Unarmed Armored High Capacity
    		["GAZ_Vodnik_MedEvac",4,[]],
    		//(4) Vehicle Trash High Capacity
    		["S1203_TK_CIV_EP1",4,[]],
    		//(5) Civil Truck Ultra High Capacity
    		["Ural_TK_CIV_EP1",7,[]]
    	];
    
    	//Soldier of the Convoys (all the soldiers are the same)
    	donn_soldierSkin = "TK_INS_Bonesetter_EP1";
    
    	//=======================
    	//BASIC KONFIGURATION 2!
    	//=======================
    
    	//CONVOY CONFIGURATION
    	
    	//Time between each consecutive spawn
    	_timeBetweenSpawns = 200;
    
    	//Cars in each convoy (refere to donn_carsConvy)
    	_convoyFormation = [
    		[0,1],	// convoy 1		
    		[0,2],	// convoy 2
    		[0,3],	// convoy 3
    		[4],		// convoy 4
    		[5],		// convoy 5		
    		[0,1,0]	// convoy 6
    	];
    	
    	//Crew Skill (driver, cargors and turreters)
    	_driverManSkill = 0.6; 	//Skill of the driver, from 0 to 1
    	_cargoMansSkill = 0.5;	//Skill of the cargo ocupants, from 0 to 1
    	_turretMansSkill = 0.4;	//Skill ot the turret operators, from 0 to 1
    	_bomberManPerc = 0.1;	//Percentage of bomberman AI: 0 is 0% and 1 is 100%
    	
    	//====================
    	//MAP CONFIGURATION
    	//====================
    
    	//VEHICLES SPAWN: [[vehicle spawn position],[nothing],spawn angle,spawn radius]
    	
    	//CHERNARUS SPAWNS
    	_spawns = [
    		[[2000,10907,0.2],[],100,15],
    		[[7730,4798,0.2],[],22,15],
    		[[7195,9700,0.2],[],0,15]
    	];
    
    	//====================
    	//EXTRA KONFIGURATION!
    	//====================
    
    	//LOOT IN VEHICLE
    	_loot1 = [
    		[["addWeaponCargoGlobal","Mk_48_DZ",[1,1,2]],["addMagazineCargoGlobal","100Rnd_762x51_M240",[1,2,3]]],	//Maried Loot
    		[["addWeaponCargoGlobal","M249_DZ",[1,1,2]],["addMagazineCargoGlobal","200Rnd_556x45_M249",[1,2,3]]],	//Maried Loot
    		[["addWeaponCargoGlobal","G36C",[1,1,2]],["addMagazineCargoGlobal","30Rnd_556x45_Stanag",[2,3,4]]],		//Maried Loot
    		[["addWeaponCargoGlobal","DMR_DZ",[1,1,2]],["addMagazineCargoGlobal","20Rnd_762x51_DMR",[3,4,5]]],		//Maried Loot
    		[["addWeaponCargoGlobal","AK_47_M",[1,1,2]],["addMagazineCargoGlobal","30Rnd_762x39_AK47",[2,3,4]]],		//Maried Loot
    		[["addWeaponCargoGlobal","NVGoggles",[3,4,5]]],
    		[["addWeaponCargoGlobal","ItemEtool",[3,4,5]]],
    		[["addWeaponCargoGlobal","Binocular_Vector",[2,3,4]]],
    		[["addMagazineCargoGlobal","ItemBloodBag",[8,12,16]]],
    		[["addMagazineCargoGlobal","PartEngine",[5,7,9]]],
    		[["addMagazineCargoGlobal","ItemBandage",[20,25,30]]],
    		[["addMagazineCargoGlobal","HandGrenade_West",[6,10,14]]],
    		[["addMagazineCargoGlobal","ItemBriefcase100oz",[1,1,1]]],
    		[["addMagazineCargoGlobal","ItemBriefcase100oz",[1,2,2]]]
    	];
    	
    	//=========================
    	//END OF KONFIGURATION
    	//=========================
    	
    	//==============================================================================================================
    	//==============================================================================================================
    	//==============================================================================================================
    	//==============================================================================================================
    	
    	//Avoid Vehicles to Explode when Entering it
    	waitUntil {sleep 2;!isNil "DZE_safeVehicle"};
    	_cascaVehicles = [];
    	{
    		_car = _x select 0;
    		if !(_car in _cascaVehicles) then {
    			_cascaVehicles = _cascaVehicles + [_car];
    		};
    	} forEach donn_carsConvy;
    	DZE_safeVehicle = DZE_safeVehicle + _cascaVehicles;	
    	
    	//AI handle damage Event Handler
    	donn_casca_unit_HD = {
    		_damage = _this select 2;
    		if (_damage > 0.1) then { 
    			_hurtedOne = _this select 0;
    			_partDamage = _this select 1;
    			_ofender = _this select 3;
    			//diag_log (_partDamage + " / " + str _damage + " / " + str diag_tickTime);
    			if (isPlayer _ofender) then {
    				_unit = _this select 0;
    				_dist = (_this select 3) distance _unit;
    				_groupShoted = group _unit;
    				_groupShoted setVariable ["donn_pshot",true,false]; //MANY
    				if (_dist < 100) then {_groupShoted reveal [_this select 3,4];}; //MANY
    				if (_partDamage == "body" && _damage > 1) then {
    					if (_hurtedOne getVariable ["donn_bomb",false]) then {
    						//diag_log "[DONN DONN DONN] BOOOOM!";
    						_hurtedOne setVariable ["donn_bomb",false,false];
    						_uPos = position _hurtedOne;
    						"HelicopterExploSmall" createVehicle _uPos;
    						"G_Camel_HE" createVehicle _uPos;
    						_hurtedOne setDamage 1;					
    					};
    				};
    			} else {
    				if (_hurtedOne != _ofender) then {_damage = 0;};
    			};
    		};
    		_damage
    	};
    	
    	//Vehicle Handle Damage
    	donn_casca_veh_HD = {
    		_motor = _this select 0;
    		_dist = (_this select 3) distance _motor;
    		_groupShoted = _motor getVariable ["car_group",GrpNull];
    		_inWar = _groupShoted getVariable ["donn_inWar",false];
    		if (!_inWar) then {
    			_crew = crew _motor;
    			if (count _crew > 0) then {
    				_groupShoted setVariable ["donn_pshot",true,false];
    				if (_dist < 120) then {_groupShoted reveal [_this select 3,4];};
    			};
    		};
    		if (_inWar) then {_groupShoted setVariable ["donn_pshot",true,false];	if (_dist < 120) then {_groupShoted reveal [_this select 3,4];};};
    	};
    	
    	//Show Spawn Icons on Map
    	_spawns spawn {
    		_spawns = _this;
    		_donn_casca_icons = [];
    		{
    			_donn_casca_icons = _donn_casca_icons + [[_x select 0,"Convoy Spawn " + str (_forEachIndex + 1)]];
    		} forEach _spawns;
    		while {true} do {
    			{
    				_mark = createMarker ["Donn_Spawn_" + str _forEachIndex, _x select 0];
    				_mark setMarkerShape "Icon";
    				_mark setMarkerText (_x select 1);
    				_mark setMarkerType "mil_dot";
    				_mark setMarkerColor "ColorPink";
    			} forEach _donn_casca_icons;
    			sleep 15;
    			{
    				deleteMarker ("Donn_Spawn_" + str _forEachIndex);
    			} forEach _donn_casca_icons;
    		};
    	};
    	
    	//Loot Selection Function
    	_donn_selectLoot = {
    		_lootsOriginal = _this select 0;
    		_qtd = _this select 1;
    		_loots = +_lootsOriginal;
    		_qtd = _qtd min 8;
    		_return = [];
    		for "_x" from 0 to (_qtd - 1) do {
    			_rnd = (ceil (random (count _loots))) - 1;
    			_rnd = _rnd max 0;
    			_return = _return + [_loots select _rnd];
    			_loots set [_rnd,"delme"];
    			_loots = _loots - ["delme"];
    			if (count _loots == 0) then {_loots = +_lootsOriginal;};
    		};
    		_return
    	};
    	
    	//Add or Remove Turret Ammo - Function
    	donn_cascar_tuAmmo = {
    		_ammos = _this select 0;
    		_motor = _this select 1;
    		_action = _this select 2;
    		if (_action == "add") then {
    			{
    				_ammo = _x;
    				for "_a" from 1 to 2 do {
    					_motor addMagazineTurret [_ammo,[_forEachIndex]];
    				};
    			} forEach _ammos;
    		};
    		if (_action == "remove") then {
    			{
    				_motor removeMagazinesTurret [_x,[_forEachIndex]];
    			} forEach _ammos;
    		};
    	};
    	
    	//Clean AI on death and re-assign a new driver
    	donn_cleanUnit = {
    		_unit = _this select 0;
    		_motor = assignedVehicle _unit;
    		_role = assignedVehicleRole _unit;
    		_unit removeAllEventHandlers "handleDamage";
    		if (_role select 0 == "Driver") then {
    			_assignedVehDrv = assignedVehicle _unit;
    			_unitsGrp = units group _unit;
    			_newDriver = ObjNull;
    			{
    				if (alive _x) then {
    					if (assignedVehicle _x == _assignedVehDrv) then {
    						if (isNull _newDriver) then {
    							_newDriver = _x;
    						} else {
    							if ((assignedVehicleRole _newDriver) select 0 == "Turret") then {
    								_newDriver = _x;
    							};
    						};
    					};
    				};
    			} forEach _unitsGrp;
    			if (!isNull _newDriver) then {_newDriver assignAsDriver _motor;};
    		};
    		removeBackpack _unit;
    		{_unit removeMagazine _x;} forEach magazines _unit;
    		if (random 100 > 70) then {
    			{_unit removeWeapon _x;} forEach weapons _unit;
    		};
    		donn_units_motor = donn_units_motor - [_unit];
    	};
    	
    	//Find Waypoints: Automatic find street waypoints
    	_donn_wps = [];
    	_roads = [0,0,0] nearRoads 50000;
    	{
    		_road = _x;
    		if (count roadsConnectedTo _x > 2) then {
    			_alone = true;
    			{
    				if (_road distance _x < 1200) exitWith {
    					_alone = false;
    				};
    			} forEach _donn_wps;
    			if (_alone) then {
    				_donn_wps = _donn_wps + [position _x];
    			};
    		};
    	} forEach _roads;
    	_roads = nil;
    	
    	//Bot Weapons
    	_donn_weapons = [
    		["Mk_48_DZ","100Rnd_762x51_M240"],
    		["M249_DZ","200Rnd_556x45_M249"],
    		["G36C","30Rnd_556x45_Stanag"],
    		["G36C_camo","30Rnd_556x45_Stanag"],
    		["G36A_camo","30Rnd_556x45_Stanag"],
    		["G36K_camo","30Rnd_556x45_Stanag"],
    		["AK_47_M","30Rnd_762x39_AK47"],
    		["AKS_74_U","30Rnd_545x39_AK"],
    		["bizon_silenced","64Rnd_9x19_SD_Bizon"],
    		["DMR_DZ","20Rnd_762x51_DMR"],
    		["RPK_74","75Rnd_545x39_RPK"]
    	];
    	
    	//Refual Vehicles
    	donn_motor = [];
    	[] spawn {
    		while {true} do {
    			{if (fuel _x > 0) then {_x setFuel 1;};} forEach donn_motor;
    			uiSleep 120;
    		};
    	};	
    	
    	//Casca Units Icons on Map
    	donn_units_motor = [];
    	[] spawn {
    		//Add Icon Function
    		_addIcon = {
    			_iName = _this select 0;
    			_iPos = _this select 1;
    			_iColor = _this select 2;
    			_iText = _this select 3;
    			_mark = createMarker [_iName, _iPos];
    			_mark setMarkerColor _iColor;
    			_mark setMarkerShape "Icon";
    			_mark setMarkerType "mil_dot";
    			_mark setMarkerText _iText;
    		};
    		_add = [];
    		_remove = [];
    		_update = [];
    		_donn_units_motor_icon_old = [];
    		_count = 0;
    		while {true} do {
    			{
    				deleteMarker vehicleVarName _x;
    			} forEach _remove;
    			{
    				_color = "";
    				_txt = "";
    				if (_x isKindOf "LandVehicle") then {
    					_txt = str ({alive _x} count crew _x);
    					if (_x getVariable ["donn_tu",false]) then {
    						_color = "ColorRed";
    					} else {
    						_color = "ColorBlue";
    					};
    				} else {
    					_txt = "";
    					_color = "ColorYellow";
    				};
    				_array = [vehicleVarName _x,position _x,_color,_txt];
    				_array call _addIcon;
    			} forEach _add;
    			{
    				_posXY = position _x;
    				_marker = vehicleVarName _x;
    				_marker setMarkerPos (getPosATL _x);
    				if (_x isKindOf "LandVehicle") then {
    					_marker setMarkerText str ({alive _x} count crew _x);
    				};
    
    			} forEach _update;
    			_donn_units_motor_icon = [];
    			_vehIcon = [];
    			{
    				_veh = vehicle _x;
    				_assigned = assignedVehicle _x;
    				if (_veh != _x) then {
    					if !(_veh in _vehIcon) then {
    						_vehIcon = _vehIcon + [_veh];
    						_donn_units_motor_icon = _donn_units_motor_icon + [_veh];
    					};
    				} else {
    					_donn_units_motor_icon = _donn_units_motor_icon + [_x];
    				};
    				if !(_assigned in _vehIcon) then {
    					_vehIcon = _vehIcon + [_assigned];
    					_donn_units_motor_icon = _donn_units_motor_icon + [_assigned];
    				};
    			} forEach donn_units_motor;
    			if (_count >= 10) then {
    				_add = _donn_units_motor_icon;
    				_remove = _donn_units_motor_icon_old;
    				_donn_units_motor_icon_old = _donn_units_motor_icon;
    				_count = 0;
    			} else {
    				_add = _donn_units_motor_icon - _donn_units_motor_icon_old;
    				_remove = _donn_units_motor_icon_old - _donn_units_motor_icon;
    				_update = _donn_units_motor_icon - _add;
    				_donn_units_motor_icon_old = _donn_units_motor_icon;
    			};
    			sleep 2.5;
    			_count = _count + 1;
    		};
    	};
    	
    	//Safe Sleep
    	sleep 10;
    	
    	//Spawn Casca Units/Cars
    	_totalUnitCount = 0;
    	for "_cs" from 1 to (count _convoyFormation) do {
    		diag_log ("[CASCA CONVOY] Initialized Spawn! " + str _cs);
    		//Inicialization
    		_spawn = _spawns select ((_cs + ((count _spawns)-1)) mod (count _spawns));
    		_origin = _spawn select 0;
    		_rad = _spawn select 3;
    		_rosa_group = createGroup EAST;
    		_convoy = _convoyFormation select (_cs-1);
    		_behaviorSafe = "CARELESS";
    		_speed = "FULL";
    		_qtd = count _convoy;
    		_cars = [];
    		{
    			_cars = _cars + [donn_carsConvy select _x];
    		} forEach _convoy;
    		_donn_motor = [];
    		for "_n" from 1 to _qtd do {
    			private ["_firstDriver"];
    			//Spawn Car
    			_car = _cars select (_n - 1);
    			_motor = createVehicle [_car select 0,_origin,[],_rad,"NONE"];
    			_motor allowDamage false;
    			_motor setVehicleVarName ("CASCA_CAR_" + str _cs + "_" + str _n);
    			_motor setVariable ["ObjectID","1",true];
    			_motor setVariable ["ObjectUID","1",true];
    			_motor setVariable ["car_group",_rosa_group,false];
    			_motor removeAllEventHandlers "HandleDamage";
    			_motor addEventHandler ["HandleDamage",{_this call donn_casca_veh_HD}];
    			_motor setDir (_spawn select 2);
    			_motor setFuel 1;
    			_donn_motor = _donn_motor + [_motor];
    			donn_motor = donn_motor + [_motor];
    			_motor addEventHandler ["GetIn",{
    				_motor = _this select 0;
    				_unit = _this select 2;
    				if (isPlayer _unit) then {
    					_unit action ['getOut', _motor];
    				};
    			}];
    			//Add Vehicle Ammo
    			_ammos = _car select 2;
    			if (count _ammos > 0) then {
    				[_ammos,_motor,"add"] call donn_cascar_tuAmmo;
    				_motor setVariable ["donn_tu",true,true];
    			};
    			//count Crew
    			_driverCount = 1;
    			_turreterCount = count _ammos;
    			_cargorsCount = _car select 1;
    			_crewCount = _driverCount + _turreterCount + _cargorsCount;
    			//Put Loot in the Car
    			clearWeaponCargoGlobal _motor;
    			clearMagazineCargoGlobal _motor;
    			{
    				{call compile format ["_motor %1 ['%2',%3];",_x select 0,_x select 1,_x select 2 select ((_qtd - 1) min 2)];} forEach _x;
    			} forEach ([_loot1,_crewCount] call _donn_selectLoot);
    			//Spawn Soldiers
    			_gunnerPos = 0;
    			for "_y" from 1 to _crewCount do {
    				//Create Soldier
    				_totalUnitCount = _totalUnitCount + 1;
    				_unit = _rosa_group createUnit [donn_soldierSkin,[50,50,50],[],50,"PRIVATE"];
    				_unit setVehicleVarName ("CASCA_AI_" + str _cs + "_" + str _n + "_" + str _y);				
    				[_unit] joinSilent _rosa_group;
    				_unit addEventHandler ["Killed",{_this call donn_cleanUnit;}];
    				_unit addEventHandler ["HandleDamage",{_this call donn_casca_unit_HD}];
    				_isBomber = false;
    				if (_totalUnitCount mod floor (1/_bomberManPerc) == 0) then {_isBomber = true;};
    				_unit setVariable ["donn_bomb",_isBomber,false];
    				donn_units_motor = donn_units_motor + [_unit];
    				_unit disableAi "TARGET";
    				_unit disableAi "AUTOTARGET";
    				//Give Soldier Weapon and Ammo
    				removeAllWeapons _unit;
    				{_unit removeMagazine _x} forEach magazines _unit;
    				_weap_mag = _donn_weapons call BIS_fnc_selectRandom;
    				_weapon = _weap_mag select 0;
    				_magazine = _weap_mag select 1;
    				_unit addBackPack "B_Carryall_ocamo";
    				_unit addWeapon _weapon;
    				_unit selectWeapon _weapon;
    				for "_pa" from 1 to 8 do {
    					_unit addMagazine _magazine;
    				};
    				//Put AI in the car
    				if (_y == 1) then {
    					//Driver
    					_unit assignAsDriver _motor;
    					_unit moveInDriver _motor;
    					_unit setSkill _driverManSkill;
    				};
    				if (_y > 1 && _y <= 1 + _turreterCount) then {
    					//Turreters
    					_unit assignAsGunner _motor;
    					_unit moveInTurret [_motor,[_gunnerPos]];
    					_unit setSkill _turretMansSkill;
    					_gunnerPos = _gunnerPos + 1;
     				};
    				if (_y > 1 + _turreterCount) then {
    					//Cargors
    					_unit assignAsCargo _motor;
    					_unit moveInCargo _motor;
    					_unit setSkill _cargoMansSkill;
    				};
    			};
    			_rosa_group setCombatMode "RED";
    			_rosa_group setBehaviour _behaviorSafe;
    			_rosa_group setVariable ["donn_pshot",false,false];
    			_rosa_group setVariable ["donn_inWar",false,false];
    			_rosa_group allowFleeing 0;
    			//Unstuck Car
    			_motor spawn {
    				_motor = _this;
    				_excludeGeneral = [];
    				_count = 0;
    				while {true} do {
    					_fix = false;
    					sleep 5;
    					while {!isNull driver _motor && isEngineOn _motor} do {
    						_lastPos = position _motor;
    						sleep 5;						
    						_newPos = position _motor;
    						if (_newPos distance _lastPos < 0.5) then {
    							_count = _count + 1;
    						} else {
    							_count = 0;
    							_excludeGeneral = [];
    						};
    						if (_count >= 15) exitWith {_fix = true;};
    					};
    					if (_fix) then {
    						_lastPos = position _motor;
    						_noPlayerNear = true;
    						_near = (position _motor) nearEntities ["CAManBase",350];
    						{
    							if (isPlayer _x) exitWith {
    								_noPlayerNear = false;
    							};
    						} forEach _near;
    						if (_noPlayerNear) then {
    							_roads = [];
    							_grow = 1;
    							_roadsNegative = (position _motor) nearRoads 20;
    							while {count _roads < 5} do {
    								_roads = (position _motor) nearRoads (50*_grow + 20);
    								_roads = _roads - _roadsNegative;								
    								_grow = _grow + 1;
    							};
    							_notOk = true;
    							_exclude = [];
    							_theRoadSafe = _roads call BIS_fnc_selectRandom;
    							while {_notOk} do {
    								_minDist = 200;
    								_theRoad = _theRoadSafe;
    								{
    									_dist = _motor distance _x;
    									if (_dist < _minDist && !(_x in _exclude) && !(_x in _excludeGeneral)) then {
    										_minDist = _dist;
    										_theRoad = _x;
    									};
    								} forEach _roads;
    								_occuping = ((position _theRoad) nearEntities ["CAManBase",15]) - [_motor];
    								_newPos = position _motor;
    								if (_newPos distance _lastPos >= 0.5) then {
    									_notOk = false;
    									_count = 0;
    								} else {
    									if (count _occuping == 0) then {
    										_notOk = false;
    										_count = 0;
    										if (_theRoad != _theRoadSafe) then {_excludeGeneral = _excludeGeneral + [_theRoad]};
    										_motor setPos (position _theRoad);
    									} else {
    										if (_theRoad != _theRoadSafe) then {_exclude = _exclude + [_theRoad];};
    										sleep 7.5;
    									};
    								};
    							};
    						};
    					};
    				};
    			};
    		};
    		//Make Units leave or Embark car
    		[_rosa_group,_behaviorSafe,_donn_motor] spawn {
    			_rosa_group = _this select 0;
    			_behaviorSafe = _this select 1;
    			_donn_motor = _this select 2;
    			_KA_playersLast = false;
    			_followeds = [];	
    			_noHurtTime = 0;
    			_tm = 0;
    			_tmSup = 0;
    			_targetOff = true;
    			_reTravel = 0;
    			while {!isNil "_rosa_group"} do {
    				_KA_players = false;
    				_shotNearPlayers = _rosa_group getVariable ["donn_pshot",false];
    				if (isNil "_shotNearPlayers") then {_shotNearPlayers = false;};
    				if (_shotNearPlayers) then {
    					_rosa_group setVariable ["donn_pshot",false,false];
    					_KA_players = true;
    				};
    				if (str _KA_players != str _KA_playersLast && _KA_players) then {
    					_rosa_group setVariable ["donn_inWar",true,false];
    					{_x enableAi "AUTOTARGET";} forEach units _rosa_group;
    					_reTravel = 0;
    					_vehGrp = [];
    					_inCar = [];
    					_onFoot = [];
    					{
    						_veh = vehicle _x;
    						if (_x != _veh) then {
    							if (!(_veh in _vehGrp) && !isNull driver _veh) then {_vehGrp = _vehGrp + [_veh];};
    							_inCar = _inCar + [_x];
    						} else {
    							_onFoot = _onFoot + [_x];
    						};
    					} forEach units _rosa_group;
    					{_x enableAi "TARGET";} forEach _onFoot;
    					_start = time;
    					_timePassed = 0;
    					_danger = true;
    					while {_danger && _timePassed < 2} do {
    						_danger = false;
    						{if ({isPlayer _x} count (_x nearEntities ["CAManBase",50]) > 0) then {_danger = true;};} forEach _vehGrp;
    						sleep 1;
    						_timePassed = time - _start;
    					};
    					_targetOff = false;
    					{_x enableAi "TARGET";} forEach _inCar;
    					_turreters = [];
    					{if ((assignedVehicleRole _x) select 0 == "Turret") then {_turreters = _turreters + [_x];};} forEach units _rosa_group;
    					_leaveToFight = (units _rosa_group) - _turreters;
    					{sleep 0.001;[_x] allowGetIn false;} forEach _leaveToFight;
    					{_x setFuel 0;} forEach _donn_motor;
    					sleep 2.5;
    					_rosa_group setBehaviour "COMBAT";
    					_rosa_group setCombatMode "RED";
    					_tmSup = 15;
    				};
    				if (!_KA_players) then {_noHurtTime = _noHurtTime + _tm;};
    				if (!_KA_players && _noHurtTime > 180 && !_targetOff) then {
    					_targetOff = true;
    					{_x disableAi "TARGET";} forEach units _rosa_group;
    					{_x disableAi "AUTOTARGET";} forEach units _rosa_group;
    					sleep 1;
    					_rosa_group setBehaviour _behaviorSafe;
    					_rosa_group setCombatMode "RED";
    					{[_x] allowGetIn true;sleep 0.001;[_x] orderGetIn true;} forEach units _rosa_group;
    					_tmSup = 0;
    					_reTravel = 1;
    				};
    				_KA_playersLast = _KA_players;
    				_tm = 1 max _tmSup;
    				if (_KA_players) then {_noHurtTime = -_tm;};
    				sleep _tm;
    				if (_reTravel > 0) then {
    					_embNOk = [];
    					{if (_x == vehicle _x && alive _x) then {_embNOk = _embNOk + [_x];};} forEach units _rosa_group;
    					if (count _embNOk == 0) then {
    						{_x setFuel 1;} forEach _donn_motor;_rosa_group setVariable ["donn_inWar",false,false];_reTravel = 0;
    					} else {
    						if (_reTravel > 60) then {{_x doMove (position (assignedVehicle _x));} forEach _embNOk;_reTravel = 1;};
    						{[_x] allowGetIn true;sleep 0.01;[_x] orderGetIn true;} forEach _embNOk;
    						_reTravel = _reTravel + 1;
    					};
    				};
    			};
    		};
    		//Make the Route
    		_origin = _spawn select 0;
    		_posBefore = _origin;
    		_posNow = _origin;
    		_wp = _rosa_group addWaypoint [_posNow,0,0];
    		_wp setWaypointCompletionRadius 15;
    		_wp setWaypointType "MOVE";
    		_wp setWaypointSpeed _speed;
    		_posNext = [0,0,0];
    		for "_c" from 1 to 5 do {
    			_distToBefore = 0;
    			_distToNext = 0;
    			_found = false;
    			for "_x" from 1 to 200 do {
    				_posNext = _donn_wps call BIS_fnc_selectRandom;
    				_distToNext = _posNow distance _posNext;
    				_distToBefore = _posNext distance _posBefore;
    				_otherIsland = false;
    				if (_distToNext > 2500 && _distToNext < 5000 && _distToBefore > 2000) then {
    					_found = true;
    					_distUnits = _distToNext/20;
    					_dltX = ((_posNext select 0) - (_posNow select 0))/_distUnits;
    					_dltY = ((_posNext select 1) - (_posNow select 1))/_distUnits;
    					for "_i" from 1 to _distUnits do {
    						_travelPos = [(_posNow select 0)+_i*_dltX,(_posNow select 1)+_i*_dltX]; 
    						if (surfaceIsWater _travelPos) exitWith {_found = false;};
    					};
    				};
    				if (_found) exitWith {};
    				sleep 0.001;
    			};
    			if (!_found) then {_posNext = _donn_wps call BIS_fnc_selectRandom;};
    			_wp = _rosa_group addWaypoint [_posNext,0,_c];
    			_wp setWaypointCompletionRadius 15;
    			_wp setWaypointType "MOVE";
    			_wp setWaypointSpeed _speed;
    			_posNow = _posNext;
    		};
    		_wp = _rosa_group addWaypoint [_origin,0,6];
    		_wp setWaypointCompletionRadius 15;
    		_wp setWaypointType "CYCLE";
    		_wp setWaypointSpeed _speed;
    		//Sleep Before Next Spawn
    		sleep _timeBetweenSpawns;
    	};
    };
    
  2. Dawg,

     

    This error "Can't find andre_convoy.sqf" is because you is calling a file that is not there. The other errors are not related to Andre convoy i believe.

     

    Have you put andre_convoy.sqf in your mission file?

     

    If you want, send me your init.sqf by pm.

  3. Next release will be for Arma 2, and right after it will be ported to Arma 3:

     

    Changes:

     

    - Many New Default Vehicle types (Arma 2):

    ---- Off Road Unarmed

    ---- Off Road Armed

    ---- Civ Truck High Crew Capacity

    ---- Civ Van High Crew Capacity

    ---- Armored Unarmed High Crew Capacity (BRDM)

    ---- Armored Unarmed High Crew Capacity (Med Evak Vodinik)

    - Loot quantity in vehicle based on the crew number of the vehicle. So a trucks full of AI will have lots of loot.

    - Bomb Mans (they explode when you shot their chest)

    - No AI friendlly fire. Good for truck and high capacity vehicles disembark.

    - No client side. Full on server or Headless Client.

    ---- To stop the convoy you need to shot the vehicle or any of its crew.

    - A considerable number of spawn loops removed and converted to event handlers.

    - Some multiple spawn loop checks joined in one spawn loop check.

    - Some refinement and simplification of the code.

  4. Next release will be for Arma 2, and right after it will be ported to Arma 3:

     

    Changes:

     

    - Many New Default Vehicle types (Arma 2):

    ---- Off Road Unarmed

    ---- Off Road Armed

    ---- Civ Truck High Crew Capacity

    ---- Civ Van High Crew Capacity

    ---- Armored Unarmed High Crew Capacity (BRDM)

    ---- Armored Unarmed High Crew Capacity (Med Evak Vodinik)

    - Loot quantity in vehicle based on the crew number of the vehicle. So a trucks full of AI will have lots of loot.

    - Bomb Mans (they explode when you shot their chest)

    - No AI friendlly fire. Good for truck and high capacity vehicles disembark.

    - No client side. Full on server or Headless Client.

    ---- To stop the convoy you need to shot the vehicle or any of its crew.

    - A considerable number of spawn loops removed and converted to event handlers.

    - Some multiple spawn loop checks joined in one spawn loop check.

    - Some refinement and simplification of the code.

  5. outlander, casca convoy is not ready for armed vehicles. I do not recomend using armed vehicle for it.

     

    The only problem left in Andre Convoy for Arma 2 is that the vehicle enter in combat mode when a player is near, and this make then go out of the street. While in Arma 3 the deviation is small, in arma 2 its very big, the vehicle go deep in the forest/wild and this is not really what i intend, my desire is to make then run over the player.

     

    I have TARGET and AUTOTARGET off but they still enters in combat mode and exit the street.

     

    Working in a solution.

  6. I updated the focus of the script:
     
    For who? For vehicles drived by bots.
    When? When they get stuck.
    How often they get stuck? Not rarely.
    Why they get stuck? Because they ar bad drivers when they are not in a very simple driver situation.
     
    Not really intended to run it on all vehicles or on player vehicles. Just on scripted AI vehicles that have a task and could never acomplish the task due to car stuck.
     
    The code is not that important, but a big picture on how to implement it.
     
    I though in one individual spawn for each vehicle. People gave other ideas:
     
    1 ) With one spawn for all stuck checks, i believe the script will be less responsive, since the script execution will be lengther and it will run only one time in each schedule execution cycle. But not really a big problem for that script.
     
    a ) If i have 10 cars protected with Unstuckos XS (10 separated spawns) i will have all cars checked in x ms.
    b ) if i have 10 cars protected with Unstuckos 1S (1 spawn only) i will have all cars checked in 10*x ms.
     
    The list of scheduled executions will be smaller in b ), 9 executions smaller, what can make rise overall performance and make it execute in less than 10*x ms, but never faster than x ms.

     

    In other fonts, one spawn, among other things, will decrease code priority, leaving more free power to the unscheduled code to run.

     
    2 ) I'm examining other solutions.
     
    Thanks a lot!

  7. My idea is to spawn a code for each car you want to use unstuck monitorement.

     

    For who? For vehicles drived by bots.

    When? When they get stuck.

    How often? Not rarely they get stuck.

    Why they get stuck? Because they ar bad drivers when they are not in a very simple situation.

    //_car is the AI vehicle
    
    _car spawn {
    	_car = _this;
    	while {true} do {
    		_count = 0;
    		_needFix = false;
    		while {isEngineOn _car} do {
    			_carLaterPos = position _car;
    			sleep 5;
    			if (_car distance _carLaterPos < 1) then {
    				_count = _count + 1;
    			} else {
    				_count = 0;
    			};
    			if (_count == 10) exitWith {_needFix = true;};
    		};
    		if {_needFix} then {
    			_nearRoads = [];
    			_radMult = 1;
    			while {count _nearRoads < 5} do {
    				_nearRoads = (position _car) nearRoads (_radMult * 30);
    				_radMult = _radMult + 1;
    			};
    			_roadToMove = _nearRoads call BIS_fnc_selectRandom;
    			_car setPos (position _roadToMove);
    			_car setDir getDir _roadtoMove;
    		};
    		sleep 5;
    	};
    };
    

    When the car dont move for more than 50 seconds with the engine on, the code will find near roads and teleport the car to that road.

     
    Any other way to do that without a spawn for each car?
     
    Its just open for any idea. Thankyou in advance.

  8. maca134,

     

    I'm trying to find any advice about spawn clean problems, or any other explicity problem, but can't find only obivious tips like "don't jump from 25 meters, or you will die".

     

    I'm indeed searching for something like "don't jump from 10 cm, or you will die".

     

    Know any documentation about it?

×
×
  • Create New...