Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!isServer)exitWith{};
- private ["_vehpos","_aitype","_aicsskill","_ainum","_skillarray","_position","_skill","_wpRadius","_xpos","_ypos","_unitGroup","_aiskin","_weapon","_magazine","_wppos1","_wppos2","_wppos3","_wppos4","_wp1","_wp2","_wp3","_wp4","_wpfin","_unitArrayName","_unitMissionCount","_patrol","_pilot","_gunner"];
- _position = _this select 0;
- _wpRadius = _this select 1;
- _skill = _this select 2;
- _aitype = _this select 3;
- _xpos = _position select 0;
- _ypos = _position select 1;
- //diag_log text format ["[DZMS_Patrol]: AI Pos:%1 / AI SkillLev:%2",_position,_skill];
- if (count _this > 4) then {
- _mission = _this select 4;
- } else {
- _mission = nil;
- };
- _skillarray = ["aimingAccuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","commanding","general"];
- //Lets set the skills
- call {
- if(_skill == "easy") exitWith { _aicsskill = ai_skill_easy; };
- if(_skill == "medium") exitWith { _aicsskill = ai_skill_medium; };
- if(_skill == "hard") exitWith { _aicsskill = ai_skill_hard; };
- if(_skill == "extreme") exitWith { _aicsskill = ai_skill_extreme; };
- if(_skill == "random") exitWith { _aicsskill = ai_skill_random call BIS_fnc_selectRandom; };
- _aicsskill = ai_skill_random call BIS_fnc_selectRandom;
- };
- if(_aitype == "Hero") then {
- _unitGroup = createGroup RESISTANCE;
- } else {
- _unitGroup = createGroup EAST;
- };
- //diag_log text format ["[DZMS_Patrol]: Create the Driver"];
- _aiskin = ai_bandit_skin call BIS_fnc_selectRandom;
- _pilot = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
- [_pilot] joinSilent _unitGroup;
- call {
- if (_aitype == "hero") exitWith { _pilot setVariable ["Hero",true,true]; };
- if (_aitype == "bandit") exitWith { _pilot setVariable ["Bandit",true,true]; };
- if (_aitype == "special") exitWith { _pilot setVariable ["Special",true,true]; };
- };
- //Add the behaviour
- _pilot enableAI "TARGET";
- _pilot enableAI "AUTOTARGET";
- _pilot enableAI "MOVE";
- _pilot enableAI "ANIM";
- _pilot enableAI "FSM";
- _pilot setCombatMode "RED";
- _pilot setBehaviour "COMBAT";
- //Remove the items he spawns with by default
- removeAllWeapons _pilot;
- removeAllItems _pilot;
- //Now we need to figure out their loadout, and assign it
- //Get the weapon array based on skill
- //_weaponArray = [_skill] call DZMSGetWeapon;
- //_weapon = _weaponArray select 0;
- //_magazine = _weaponArray select 1;
- //Get the gear array
- //_aigearArray = [DZMSGear0,DZMSGear1,DZMSGear2,DZMSGear3,DZMSGear4,DZMSGear5];
- //_aigear = _aigearArray call BIS_fnc_selectRandom;
- //_gearmagazines = _aigear select 0;
- //_geartools = _aigear select 1;
- _pilot addweapon "Makarov_DZ";
- _pilot addmagazine "8Rnd_9x18_Makarov";
- _pilot addmagazine "8Rnd_9x18_Makarov";
- //Gear the AI backpack
- //_aipack = DZMSPacklist call BIS_fnc_selectRandom;
- //Lets add it to the Unit
- //for "_i" from 1 to 3 do {
- // _pilot addMagazine _magazine;
- //};
- //_pilot addWeapon _weapon;
- //_pilot selectWeapon _weapon;
- //_pilot addBackpack _aipack;
- //{
- // _pilot addMagazine _x
- //} forEach _gearmagazines;
- //{
- // _pilot addWeapon _x
- //} forEach _geartools;
- //diag_log text format ["[DZMS_Patrol]: Create Gunner"];
- _aiskin = ai_bandit_skin call BIS_fnc_selectRandom;
- _gunner = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
- [_gunner] joinSilent _unitGroup;
- call {
- if (_aitype == "hero") exitWith { _gunner setVariable ["Hero",true,true]; };
- if (_aitype == "bandit") exitWith { _gunner setVariable ["Bandit",true,true]; };
- if (_aitype == "special") exitWith { _gunner setVariable ["Special",true,true]; };
- };
- //Add the behaviour
- _gunner enableAI "TARGET";
- _gunner enableAI "AUTOTARGET";
- _gunner enableAI "MOVE";
- _gunner enableAI "ANIM";
- _gunner enableAI "FSM";
- _gunner setCombatMode "RED";
- _gunner setBehaviour "COMBAT";
- //Remove the items he spawns with by default
- removeAllWeapons _gunner;
- removeAllItems _gunner;
- //Now we need to figure out their loadout, and assign it
- //Get the weapon array based on skill
- //_weaponArray = [_skill] call DZMSGetWeapon;
- //_weapon = _weaponArray select 0;
- //_magazine = _weaponArray select 1;
- //Get the gear array
- //_aigearArray = [DZMSGear0,DZMSGear1,DZMSGear2,DZMSGear3,DZMSGear4,DZMSGear5];
- //_aigear = _aigearArray call BIS_fnc_selectRandom;
- //_gearmagazines = _aigear select 0;
- //_geartools = _aigear select 1;
- _gunner addweapon "Makarov_DZ";
- _gunner addmagazine "8Rnd_9x18_Makarov";
- _gunner addmagazine "8Rnd_9x18_Makarov";
- //Gear the AI backpack
- //_aipack = DZMSPacklist call BIS_fnc_selectRandom;
- //Lets add it to the Unit
- //for "_i" from 1 to 3 do {
- // _gunner addMagazine _magazine;
- //};
- //_gunner addWeapon _weapon;
- //_gunner selectWeapon _weapon;
- //_gunner addBackpack _aipack;
- //if (DZMSUseNVG) then {
- // _gunner addWeapon "NVGoggles";
- //};
- //{
- // _gunner addMagazine _x
- //} forEach _gearmagazines;
- //{
- // _gunner addWeapon _x
- //} forEach _geartools;
- //_aicsskill = DZMSSkills1;
- //{_gunner setSkill [(_x select 0),(_x select 1)]} forEach _aicsskill;
- //{_pilot setSkill [(_x select 0),(_x select 1)]} forEach _aicsskill;
- {
- _gunner setSkill [(_x select 0),(_x select 1)];
- } count _aicsskill;
- ai_vehicle_units = (ai_vehicle_units + 1);
- {
- _pilot setSkill [_x,1]
- } count _skillarray;
- ai_vehicle_units = (ai_vehicle_units + 1);
- //Lets prepare the unit for cleanup
- _pilot addEventHandler ["Killed",{[_this select 0, _this select 1, "vehicle"] call on_kill;}];
- _gunner addEventHandler ["Killed",{[_this select 0, _this select 1, "vehicle"] call on_kill;}];
- //diag_log text format ["[DZMS_Patrol]: Create the Vehicle"];
- _patrol = ["patrol"] call DZMSGetVeh;
- HC_VehicleResult = nil;
- _vehpos = [(_position select 0) + _wpRadius,(_position select 1) + _wpRadius, 0];
- HC_RequestVehicle = [_patrol,_vehpos,0,"NONE"];
- publicVariableServer "HC_RequestVehicle";
- waitUntil {uisleep 0.5; !isNil "HC_VehicleResult"};
- _patrol = HC_VehicleResult;
- //[_patrol] call DZMSSetupVehicle;
- _patrol setFuel 1;
- _patrol engineOn true;
- _patrol setVehicleAmmo 1;
- _patrol allowCrewInImmobile true;
- //dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_patrol];
- _pilot assignAsDriver _patrol;
- _pilot moveInDriver _patrol;
- _gunner assignAsGunner _patrol;
- _gunner moveInTurret [_patrol,[0]];
- //diag_log text format ["[DZMS_Patrol]: Spawn the Patrol Group"];
- //[_patrol] spawn veh_monitor;
- if (!isNil "_mission") then {
- _patrol setVariable ["missionclean","vehicle"];
- _patrol setVariable ["mission",_mission];
- // The line below adds the ai vehicle to be monitored in missionwinorfail
- ((wai_mission_data select _mission) select 4) set [count ((wai_mission_data select _mission) select 4), _patrol]; // added for vehicle monitor
- {
- _ainum = (wai_mission_data select _mission) select 0;
- wai_mission_data select _mission set [0, (_ainum + 1)];
- _x setVariable ["mission",_mission];
- } count (crew _patrol);
- } else {
- [_patrol] spawn vehicle_monitor; // use the standalone vehicle monitor if variable _mission is nil.
- };
- _unitGroup allowFleeing 0;
- _unitGroup setBehaviour "AWARE";
- // These are 4 waypoints in a NorthSEW around the center
- _wppos1 = [_xpos, _ypos+50, 0];
- _wppos2 = [_xpos+50, _ypos, 0];
- _wppos3 = [_xpos, _ypos-50, 0];
- _wppos4 = [_xpos-50, _ypos, 0];
- //diag_log text format ["[DZMS_Patrol]: Add Waypoints"];
- // We add the 4 waypoints
- _wp1 = _unitGroup addWaypoint [_wppos1, _wpRadius];
- _wp1 setWaypointType "MOVE";
- _wp2 = _unitGroup addWaypoint [_wppos2, _wpRadius];
- _wp2 setWaypointType "MOVE";
- _wp3 = _unitGroup addWaypoint [_wppos3, _wpRadius];
- _wp3 setWaypointType "MOVE";
- _wp4 = _unitGroup addWaypoint [_wppos4, _wpRadius];
- _wp4 setWaypointType "MOVE";
- // Then we add a center waypoint that tells them to visit the rest
- _wpfin = _unitGroup addWaypoint [[_xpos,_ypos, 0], _wpRadius];
- _wpfin setWaypointType "CYCLE";
- _wpfin setWaypointCompletionRadius 150;
- //diag_log text format ["[DZMS_Patrol]: Finished the Patrol Create"];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement