Announcement

Collapse
No announcement yet.

Mission Scripted Artillery

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mission Scripted Artillery

    The one thing pretty much all ArmA missions are missing, and something that is a very, very major part of war is artillery.

    So, I set out to make a simple, effective, easy-to-use, and mildly realistic artillery script for use in missions.

    Added in functionality for enemy artillery fire missions, plus some reactionary forces. Infantry platoons and armour that will move out to the rough location of the enemy when spotted in enough strength (8 men in 300m2 for armour, 4 men in 300m2 for the platoon). It all works eerily well, and God help the Platoon that tries to defeat this enemy. Did a little test run with an AI Platoon ... they lasted about 10 minutes, I hope humans can beat that :P

    A whole other script was created for the artillery and reactionary forces to be called, posting it up as well.

    I'd appreciate it if any scripters/coders could take a quick look at these two scripts, I did a large portion of them while sleep deprived, so I hope I didn't do anything exceedingly dumb. My only concern is for the FPS of the server, having to create/destroy triggers so often. Not sure if this will effect it too much, my hunch is it won't, but you never know.


    Here is the code for what I have so far. Use it however you'd like. I'm going to be posting any future improvements here.


    Code:
    //Written by beta
    //Creates an artillery fire mission
    
    
    _target = _this select 0;  //artillery target
    _rounds = _this select 1;  //number of shells
    _timeBetween = _this select 2;  //time between shells
    _dispersion = _this select 3;  //area to shell
    _type = _this select 4;  //type of shell - "R_80mm_HE", "R_57mm_HE", "Sh_105_HE"
    _planned = _this select 5;  //planned fire mission
    _waitOut = _this select 6;  //time to wait
    _sideFriendly = _this select 7;  //side that called arty
    _sideEnemy = _this select 8;  //enemy of side that called arty
    _num = _this select 9;  //number of enemy needed for fire mission
    
    _typeStr = format ["%1", _type];
    _sideFriendlyStr = format ["%1", _sideFriendly];
    _sideEnemyStr = format ["%1", _sideEnemy];
    
    sleep _waitOut;
    
    _trg1 = createTrigger["EmptyDetector", getPos _target];
    _trg1 setTriggerArea[_dispersion, _dispersion, 0, false];
    _trg1 setTriggerActivation[_sideFriendlyStr, "PRESENT", false];
    _trg1 setTriggerStatements["this", "", ""];
    
    sleep 1;
    _friendlies = list _trg1;
    deleteVehicle _trg1;
    
    _trg2 = createTrigger["EmptyDetector", getPos _target];
    _trg2 setTriggerArea[_dispersion, _dispersion, 0, false];
    _trg2 setTriggerActivation[_sideEnemyStr, "PRESENT", false];
    _trg2 setTriggerStatements["this", "", ""];
    
    sleep 1;
    _enemies = list _trg2;
    deleteVehicle _trg2;
    
    if ((count _friendlies < 1) && (count _enemies > _num)) then
    {
    	_trg3 = createTrigger["EmptyDetector", getPos _target];
    	_trg3 setTriggerArea[_dispersion, _dispersion, 0, false];
    	_trg3 setTriggerActivation["ANY", "PRESENT", false];
    	_trg3 setTriggerStatements["this", "", ""]; 
    
    	sleep 1;
    	_hiders = list _trg3;
    	deleteVehicle _trg3;
    
    	if (!_planned) then
    	{
    		_rand1 = ceil random (_dispersion);
    		_rand2 = ceil random (_dispersion);
    		_rand2 = _rand2 * -1;
    		_rand3 = ceil random (_dispersion);
    		_rand4 = ceil random (_dispersion);
    		_rand4 = _rand4 * -1;
    		_rand5 = random 1;
    		_rand6 = random 1;
    		_rand7 = random 1;
    		_rand8 = random _timeBetween;
    
    		_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    		_dir = getDir _shell;
    		_shell setVectorUp [-1, 0, 0];
    		_shell setVectorDir [sin (_dir), cos (dir), -1];
    		_shell setVelocity [0, 0, -500];
    		sleep 20;
    
    		if (_rand5 > 0.3) then 
    		{
    			_rand1 = ceil random (_dispersion * 0.5);
    			_rand2 = ceil random (_dispersion * 0.5);
    			_rand2 = _rand2 * -1;
    			_rand3 = ceil random (_dispersion * 0.5);
    			_rand4 = ceil random (_dispersion * 0.5);
    			_rand4 = _rand4 * -1;
    
    			_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    			_dir = getDir _shell;
    			_shell setVectorUp [-1, 0, 0];
    			_shell setVectorDir [sin (_dir), cos (dir), -1];
    			_shell setVelocity [0, 0, -500];
    			sleep 20;
    		};
    
    		if (_rand6 > 0.5) then 
    		{
    			_rand1 = ceil random (_dispersion * 0.25);
    			_rand2 = ceil random (_dispersion * 0.25);
    			_rand2 = _rand2 * -1;
    			_rand3 = ceil random (_dispersion * 0.25);
    			_rand4 = ceil random (_dispersion * 0.25);
    			_rand4 = _rand4 * -1;
    
    			_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    			_dir = getDir _shell;
    			_shell setVectorUp [-1, 0, 0];
    			_shell setVectorDir [sin (_dir), cos (dir), -1];
    			_shell setVelocity [0, 0, -500];
    			sleep 20;
    		};
    
    		if (_rand7 > 0.7) then 
    		{
    			_rand1 = ceil random (_dispersion * 0.125);
    			_rand2 = ceil random (_dispersion * 0.125);
    			_rand2 = _rand2 * -1;
    			_rand3 = ceil random (_dispersion * 0.125);
    			_rand4 = ceil random (_dispersion * 0.125);
    			_rand4 = _rand4 * -1;
    
    			_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    			_dir = getDir _shell;
    			_shell setVectorUp [-1, 0, 0];
    			_shell setVectorDir [sin (_dir), cos (dir), -1];
    			_shell setVelocity [0, 0, -500];
    			sleep 20;
    		};
    	};
    
    	{_x hideBehindScripted true; _x setHideBehind [_x findCover [getPos _x, getPos hideFrom, 100], _x getHideFrom objNull];} forEach _hiders;
    
    	for [{_i=0}, {_i<_rounds}, {_i=_i+1}] do
    	{
    		_rand1 = ceil random _dispersion;
    		_rand2 = ceil random _dispersion;
    		_rand2 = _rand2 * -1;
    		_rand3 = ceil random _dispersion;
    		_rand4 = ceil random _dispersion;
    		_rand4 = _rand4 * -1;
    		_rand8 = random _timeBetween;
    
    		_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    		_dir = getDir _shell;
    		_shell setVectorUp [-1, 0, 0];
    		_shell setVectorDir [sin (_dir), cos (dir), -1];
    		_shell setVelocity [0, 0, -500];
    		sleep (_timeBetween + _rand8);
    	};
    
    	sleep 20;
    
    	{_x hideBehindScripted false; _x setHideBehind [objNull, objNull];} forEach _hiders;
    };
    Code:
    //Written by beta
    //AI strategic support
    
    
    _detected = list BLUFOR_Detected;  //BLUFOR detection list
    _plt1Cmt = false;  //1 Platoon committed flag
    _plt2Cmt = false;  //2 Platoon committed flag
    _armCmt = false;  //Armour committed flag
    _art60Cmt = false;  //60mm mortar artillery committed flag
    _art80Cmt = false;  //80mm mortar artillery committed flag
    _art60FM = false;  //60mm mortar artillery fire mission flag
    _art80FM = false;  //80mm mortar artillery fire mission flag
    
    //infinite loop
    for [{_i=0}, {_i<1}, {_i=0}] do
    {	
    	_detected = list BLUFOR_Detected;
    
    	if (count _detected > 0) then
    	{
    		{
    			_trgInner = createTrigger["EmptyDetector", getPos _x];
    			_trgInner setTriggerArea[300, 300, 0, false];
    			_trgInner setTriggerActivation["WEST", "PRESENT", false];
    			_trgInner setTriggerStatements["this", "", ""];
    			
    			sleep 1;
    			_innerDetected = list _trgInner;
    			deleteVehicle _trgInner;
    			
    			if (!_plt1Cmt && (count _innerDetected > 4)) then
    			{
    				 _plt1Cmt = true;
    				 
    				 _wp = p1s1 addWaypoint [getPos _x, 50];
    				 [p1s1, 1] setWaypointBehaviour "AWARE";
    				 [p1s1, 1] setWaypointType "GUARD";
    				 p1s1 setCurrentWaypoint [p1s1, 1];
    				 
    				 _wp = p1s2 addWaypoint [getPos _x, 50];
    				 [p1s2, 1] setWaypointBehaviour "AWARE";
    				 [p1s2, 1] setWaypointType "GUARD";
    				 p1s2 setCurrentWaypoint [p1s2, 1];
    				 
    				 _wp = p1s3 addWaypoint [getPos _x, 50];
    				 [p1s3, 1] setWaypointBehaviour "AWARE";
    				 [p1s3, 1] setWaypointType "GUARD";
    				 p1s3 setCurrentWaypoint [p1s3, 1];
    				 
    				 _wp = p1sw addWaypoint [getPos _x, 50];
    				 [p1sw, 1] setWaypointBehaviour "AWARE";
    				 [p1sw, 1] setWaypointType "GUARD";
    				 p1sw setCurrentWaypoint [p1sw, 1];
    				 
    				 _wp = p1hq addWaypoint [getPos _x, 50];
    				 [p1hq, 1] setWaypointBehaviour "AWARE";
    				 [p1hq, 1] setWaypointType "GUARD";
    				 p1hq setCurrentWaypoint [p1hq, 1];
    			};
    			
    			if (!_plt2Cmt && (count _innerDetected > 4)) then
    			{
    				 _plt2Cmt = true;
    				 
    				 _wp = p2s1 addWaypoint [getPos _x, 50];
    				 [p2s1, 1] setWaypointBehaviour "AWARE";
    				 [p2s1, 1] setWaypointType "GUARD";
    				 p2s1 setCurrentWaypoint [p2s1, 1];
    				 
    				 _wp = p2s2 addWaypoint [getPos _x, 50];
    				 [p2s2, 1] setWaypointBehaviour "AWARE";
    				 [p2s2, 1] setWaypointType "GUARD";
    				 p2s2 setCurrentWaypoint [p2s2, 1];
    				 
    				 _wp = p2s3 addWaypoint [getPos _x, 50];
    				 [p2s3, 1] setWaypointBehaviour "AWARE";
    				 [p2s3, 1] setWaypointType "GUARD";
    				 p2s3 setCurrentWaypoint [p2s3, 1];
    				 
    				 _wp = p2sw addWaypoint [getPos _x, 50];
    				 [p2sw, 1] setWaypointBehaviour "AWARE";
    				 [p2sw, 1] setWaypointType "GUARD";
    				 p2sw setCurrentWaypoint [p2sw, 1];
    				 
    				 _wp = p2hq addWaypoint [getPos _x, 50];
    				 [p2hq, 1] setWaypointBehaviour "AWARE";
    				 [p2hq, 1] setWaypointType "GUARD";
    				 p2hq setCurrentWaypoint [p2hq, 1];
    			};
    			
    			if (!_armCmt && (count _innerDetected > 8)) then
    			{
    				_armCmt = true;
    				
    				_wp = a1 addWaypoint [getPos _x, 50];
    				[a1, 1] setWaypointBehaviour "AWARE";
    				[a1, 1] setWaypointType "GUARD";
    				a1 setCurrentWaypoint [a1, 1];
    				 
    				_wp = a2 addWaypoint [getPos _x, 50];
    				[a2, 1] setWaypointBehaviour "AWARE";
    				[a2, 1] setWaypointType "GUARD";
    				a2 setCurrentWaypoint [a2, 1];
    				
    				_wp = a3 addWaypoint [getPos _x, 50];
    				[a3, 1] setWaypointBehaviour "AWARE";
    				[a3, 1] setWaypointType "GUARD";
    				a3 setCurrentWaypoint [a3, 1];
    				
    				_wp = a4 addWaypoint [getPos _x, 50];
    				[a4, 1] setWaypointBehaviour "AWARE";
    				[a4, 1] setWaypointType "GUARD";
    				a4 setCurrentWaypoint [a4, 1];
    			};
    			
    			if (!_art60FM && !_art60Cmt && (count _innerDetected > 4)) then
    			{
    				_trgArty60 = createTrigger["EmptyDetector", getPos _x];
    				_trgArty60 setTriggerArea[100, 100, 0, false];
    				_trgArty60 setTriggerActivation["EAST", "PRESENT", false];
    				_trgArty60 setTriggerStatements["this", "", ""];
    				
    				sleep 1;
    				_arty60Detected = list _trgArty60;
    				deleteVehicle _trgArty60;
    				
    				if (count _arty60Detected < 1) then {_art60FM = true;};
    			};
    			
    			if (_art60FM && !_art60Cmt) then
    			{
    				_art60Cmt = true;
    						
    				arty60Handle = [_x, 40, 1, 100, "R_57mm_HE", false, 0, "EAST", "WEST", 4] execVM "scripts\arty_fire_mission.sqf";
    			};
    			
    			if (!_art80FM && !_art80Cmt && (count _innerDetected > 8)) then
    			{
    				_trgArty80 = createTrigger["EmptyDetector", getPos _x];
    				_trgArty80 setTriggerArea[150, 150, 0, false];
    				_trgArty80 setTriggerActivation["EAST", "PRESENT", false];
    				_trgArty80 setTriggerStatements["this", "", ""];
    				
    				sleep 1;
    				_arty80Detected = list _trgArty80;
    				deleteVehicle _trgArty80;
    				
    				if (count _arty80Detected < 1) then {_art80FM = true;};
    			};
    			
    			if (_art80FM && !_art80Cmt) then
    			{
    				_art80Cmt = true;
    						
    				arty80Handle = [_x, 40, 2, 150, "R_80mm_HE", false, 0, "EAST", "WEST", 8] execVM "scripts\arty_fire_mission.sqf";
    			};
    			
    			if (scriptDone arty60Handle) then {_art60Cmt = false; _art60FM = false;};
    			if (scriptDone arty80Handle) then {_art80Cmt = false; _art80FM = false;};
    		}
    		forEach _detected;
    	};
    	
    	sleep 5;
    };
    What I'm looking to improve upon:

    - Test in MP as a server-only run script system

    What's already done:

    - Simulate 2 types of fire mission: pre-planned and on the spot
    - Simulate splash down (multiple attempts sometimes) before fire for effect is called
    - 3 different types of shells, 80mm mortar, 60mm mortar, 105mm howitzer
    - Allow for customizability via script call; target, number of rounds, time between rounds, beaten area, type of rounds, whether it is pre-planned or not
    - Spawn rounds at height with proper vector and high velocity to get a decent "incoming" sound
    - Simulate AI "fear" of artillery
    - Enemy AI use artillery on targets
    - Enemy AI send out reactionary forces to enemy contacts
    Last edited by beita; 03-15-2009, 12:40 PM. Reason: More stuff.

  • #2
    Re: Mission Scripted Artillery

    Well, I think this script set is ready for a thorough test and play testing. Think I have ironed out all the bugs I can see so far, now all that's left is to see how the Server handles it, though I am confident it shouldn't be too much of a load.

    This is the latest code, along with a description on how to set it up in a mission:

    Things You Will Need:
    In the folder scripts\
    - ai_support.sqf
    - arty_fire_mission.sqf
    In the init.sqf
    - [] execVM "scripts\ai_support.sqf"; (to be run on the server ONLY)
    In the editor
    - An Invisible H named hideFrom
    - A trigger, covering the entire enemy Area of Operations with:
    - BLUFOR Detected By OPFOR
    - Named BLUFOR_Detected
    (The following can be changed on a per mission basis, will need to edit the ai_support.sqf script file)
    - 3 Rifle Sections (group named p1s1, p1s2, p1s3), 1 Weapons Section (group named p1sw), 1 Platoon HQ (group named p1hq) with NO waypoints
    - 3 Rifle Sections (group amed p2s1, p2s2, p2s3), 1 Weapons Section (group named p2sw), 1 Platoon HQ (group named p2hq) with NO waypoints
    - 4 Armoured vehicles (group named a1, a2, a3, a4) with NO waypoints


    Once that is in place, the AI will call artillery, and send reaction forces to BLUFOR spotted at certain strengths.

    Code for the 2 script files:

    arty_fire_mission.sqf
    Code:
    //Written by beta
    //Creates an artillery fire mission
    
    
    _target = _this select 0;  //artillery target
    _rounds = _this select 1;  //number of shells
    _timeBetween = _this select 2;  //time between shells
    _dispersion = _this select 3;  //area to shell
    _type = _this select 4;  //type of shell - "R_80mm_HE", "R_57mm_HE", "Sh_105_HE"
    _planned = _this select 5;  //planned fire mission
    _waitOut = _this select 6;  //time to wait
    _sideFriendly = _this select 7;  //side that called arty
    _sideEnemy = _this select 8;  //enemy of side that called arty
    _num = _this select 9;  //number of enemy needed for fire mission
    
    _typeStr = format ["%1", _type];
    _sideFriendlyStr = format ["%1", _sideFriendly];
    _sideEnemyStr = format ["%1", _sideEnemy];
    
    sleep _waitOut;
    
    _trg1 = createTrigger["EmptyDetector", getPos _target];
    _trg1 setTriggerArea[_dispersion, _dispersion, 0, false];
    _trg1 setTriggerActivation[_sideFriendlyStr, "PRESENT", false];
    _trg1 setTriggerStatements["this", "", ""];
    
    sleep 1;
    _friendlies = list _trg1;
    deleteVehicle _trg1;
    
    _trg2 = createTrigger["EmptyDetector", getPos _target];
    _trg2 setTriggerArea[_dispersion, _dispersion, 0, false];
    _trg2 setTriggerActivation[_sideEnemyStr, "PRESENT", false];
    _trg2 setTriggerStatements["this", "", ""];
    
    sleep 1;
    _enemies = list _trg2;
    deleteVehicle _trg2;
    
    if ((count _friendlies < 1) && (count _enemies > _num)) then
    {
    	_trg3 = createTrigger["EmptyDetector", getPos _target];
    	_trg3 setTriggerArea[_dispersion, _dispersion, 0, false];
    	_trg3 setTriggerActivation["ANY", "PRESENT", false];
    	_trg3 setTriggerStatements["this", "", ""]; 
    
    	sleep 1;
    	_hiders = list _trg3;
    	deleteVehicle _trg3;
    
    	if (!_planned) then
    	{
    		_rand1 = ceil random (_dispersion);
    		_rand2 = ceil random (_dispersion);
    		_rand2 = _rand2 * -1;
    		_rand3 = ceil random (_dispersion);
    		_rand4 = ceil random (_dispersion);
    		_rand4 = _rand4 * -1;
    		_rand5 = random 1;
    		_rand6 = random 1;
    		_rand7 = random 1;
    		_rand8 = random _timeBetween;
    
    		_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    		_dir = getDir _shell;
    		_shell setVectorUp [1, 0, 0];
    		_shell setVectorDir [0, 0, cos (_dir) * -1];
    		_shell setVelocity [0, 0, -500];
    		sleep 20;
    
    		if (_rand5 > 0.3) then 
    		{
    			_rand1 = ceil random (_dispersion * 0.5);
    			_rand2 = ceil random (_dispersion * 0.5);
    			_rand2 = _rand2 * -1;
    			_rand3 = ceil random (_dispersion * 0.5);
    			_rand4 = ceil random (_dispersion * 0.5);
    			_rand4 = _rand4 * -1;
    
    			_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    			_dir = getDir _shell;
    			_shell setVectorUp [1, 0, 0];
    			_shell setVectorDir [0, 0, cos (_dir) * -1];
    			_shell setVelocity [0, 0, -500];
    			sleep 20;
    		};
    
    		if (_rand6 > 0.5) then 
    		{
    			_rand1 = ceil random (_dispersion * 0.25);
    			_rand2 = ceil random (_dispersion * 0.25);
    			_rand2 = _rand2 * -1;
    			_rand3 = ceil random (_dispersion * 0.25);
    			_rand4 = ceil random (_dispersion * 0.25);
    			_rand4 = _rand4 * -1;
    
    			_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    			_dir = getDir _shell;
    			_shell setVectorUp [1, 0, 0];
    			_shell setVectorDir [0, 0, cos (_dir) * -1];
    			_shell setVelocity [0, 0, -500];
    			sleep 20;
    		};
    
    		if (_rand7 > 0.7) then 
    		{
    			_rand1 = ceil random (_dispersion * 0.125);
    			_rand2 = ceil random (_dispersion * 0.125);
    			_rand2 = _rand2 * -1;
    			_rand3 = ceil random (_dispersion * 0.125);
    			_rand4 = ceil random (_dispersion * 0.125);
    			_rand4 = _rand4 * -1;
    
    			_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    			_dir = getDir _shell;
    			_shell setVectorUp [1, 0, 0];
    			_shell setVectorDir [0, 0, cos (_dir) * -1];
    			_shell setVelocity [0, 0, -500];
    			sleep 20;
    		};
    	};
    
    	{_x hideBehindScripted true; _x setHideBehind [_x findCover [getPos _x, getPos hideFrom, 100], _x getHideFrom objNull];} forEach _hiders;
    
    	for [{_i=0}, {_i<_rounds}, {_i=_i+1}] do
    	{
    		_rand1 = ceil random _dispersion;
    		_rand2 = ceil random _dispersion;
    		_rand2 = _rand2 * -1;
    		_rand3 = ceil random _dispersion;
    		_rand4 = ceil random _dispersion;
    		_rand4 = _rand4 * -1;
    		_rand8 = random _timeBetween;
    
    		_shell = _typeStr createVehicle [(getPos _target select 0) + (_rand1 + _rand2), (getPos _target select 1) + (_rand3 + _rand4), 2500];
    		_dir = getDir _shell;
    		_shell setVectorUp [1, 0, 0];
    		_shell setVectorDir [0, 0, cos (_dir) * -1];
    		_shell setVelocity [0, 0, -500];
    		
    		sleep (_timeBetween + _rand8);
    	};
    
    	sleep 20;
    
    	{_x hideBehindScripted false; _x setHideBehind [objNull, objNull];} forEach _hiders;
    };
    ai_support.sqf
    Code:
    //Written by beta
    //AI strategic support
    
    
    _detected = list BLUFOR_Detected;  //BLUFOR detection list
    _plt1Cmt = false;  //1 Platoon committed flag
    _plt2Cmt = false;  //2 Platoon committed flag
    _armCmt = false;  //Armour committed flag
    _art60Cmt = false;  //60mm mortar artillery committed flag
    _art80Cmt = false;  //80mm mortar artillery committed flag
    _art60FM = false;  //60mm mortar artillery fire mission flag
    _art80FM = false;  //80mm mortar artillery fire mission flag
    
    //infinite loop
    for [{_i=0}, {_i<1}, {_i=0}] do
    {	
    	_detected = list BLUFOR_Detected;
    
    	if (count _detected > 0) then
    	{
    		{
    			_trgInner = createTrigger["EmptyDetector", getPos _x];
    			_trgInner setTriggerArea[300, 300, 0, false];
    			_trgInner setTriggerActivation["WEST", "PRESENT", false];
    			_trgInner setTriggerStatements["this", "", ""];
    			
    			sleep 1;
    			_innerDetected = list _trgInner;
    			deleteVehicle _trgInner;
    			
    			if (!_plt1Cmt && (count _innerDetected > 4)) then
    			{
    				 _plt1Cmt = true;
    				 
    				 _wp = p1s1 addWaypoint [getPos _x, 50];
    				 [p1s1, 1] setWaypointBehaviour "AWARE";
    				 [p1s1, 1] setWaypointType "GUARD";
    				 p1s1 setCurrentWaypoint [p1s1, 1];
    				 
    				 _wp = p1s2 addWaypoint [getPos _x, 50];
    				 [p1s2, 1] setWaypointBehaviour "AWARE";
    				 [p1s2, 1] setWaypointType "GUARD";
    				 p1s2 setCurrentWaypoint [p1s2, 1];
    				 
    				 _wp = p1s3 addWaypoint [getPos _x, 50];
    				 [p1s3, 1] setWaypointBehaviour "AWARE";
    				 [p1s3, 1] setWaypointType "GUARD";
    				 p1s3 setCurrentWaypoint [p1s3, 1];
    				 
    				 _wp = p1sw addWaypoint [getPos _x, 50];
    				 [p1sw, 1] setWaypointBehaviour "AWARE";
    				 [p1sw, 1] setWaypointType "GUARD";
    				 p1sw setCurrentWaypoint [p1sw, 1];
    				 
    				 _wp = p1hq addWaypoint [getPos _x, 50];
    				 [p1hq, 1] setWaypointBehaviour "AWARE";
    				 [p1hq, 1] setWaypointType "GUARD";
    				 p1hq setCurrentWaypoint [p1hq, 1];
    			};
    			
    			if (!_plt2Cmt && (count _innerDetected > 4)) then
    			{
    				 _plt2Cmt = true;
    				 
    				 _wp = p2s1 addWaypoint [getPos _x, 50];
    				 [p2s1, 1] setWaypointBehaviour "AWARE";
    				 [p2s1, 1] setWaypointType "GUARD";
    				 p2s1 setCurrentWaypoint [p2s1, 1];
    				 
    				 _wp = p2s2 addWaypoint [getPos _x, 50];
    				 [p2s2, 1] setWaypointBehaviour "AWARE";
    				 [p2s2, 1] setWaypointType "GUARD";
    				 p2s2 setCurrentWaypoint [p2s2, 1];
    				 
    				 _wp = p2s3 addWaypoint [getPos _x, 50];
    				 [p2s3, 1] setWaypointBehaviour "AWARE";
    				 [p2s3, 1] setWaypointType "GUARD";
    				 p2s3 setCurrentWaypoint [p2s3, 1];
    				 
    				 _wp = p2sw addWaypoint [getPos _x, 50];
    				 [p2sw, 1] setWaypointBehaviour "AWARE";
    				 [p2sw, 1] setWaypointType "GUARD";
    				 p2sw setCurrentWaypoint [p2sw, 1];
    				 
    				 _wp = p2hq addWaypoint [getPos _x, 50];
    				 [p2hq, 1] setWaypointBehaviour "AWARE";
    				 [p2hq, 1] setWaypointType "GUARD";
    				 p2hq setCurrentWaypoint [p2hq, 1];
    			};
    			
    			if (!_armCmt && (count _innerDetected > 8)) then
    			{
    				_armCmt = true;
    				
    				_wp = a1 addWaypoint [getPos _x, 50];
    				[a1, 1] setWaypointBehaviour "AWARE";
    				[a1, 1] setWaypointType "GUARD";
    				a1 setCurrentWaypoint [a1, 1];
    				 
    				_wp = a2 addWaypoint [getPos _x, 50];
    				[a2, 1] setWaypointBehaviour "AWARE";
    				[a2, 1] setWaypointType "GUARD";
    				a2 setCurrentWaypoint [a2, 1];
    				
    				_wp = a3 addWaypoint [getPos _x, 50];
    				[a3, 1] setWaypointBehaviour "AWARE";
    				[a3, 1] setWaypointType "GUARD";
    				a3 setCurrentWaypoint [a3, 1];
    				
    				_wp = a4 addWaypoint [getPos _x, 50];
    				[a4, 1] setWaypointBehaviour "AWARE";
    				[a4, 1] setWaypointType "GUARD";
    				a4 setCurrentWaypoint [a4, 1];
    			};
    			
    			if (!_art60FM && !_art60Cmt && (count _innerDetected > 4)) then
    			{
    				_trgArty60 = createTrigger["EmptyDetector", getPos _x];
    				_trgArty60 setTriggerArea[100, 100, 0, false];
    				_trgArty60 setTriggerActivation["EAST", "PRESENT", false];
    				_trgArty60 setTriggerStatements["this", "", ""];
    				
    				sleep 1;
    				_arty60Detected = list _trgArty60;
    				deleteVehicle _trgArty60;
    				
    				if (count _arty60Detected < 1) then {_art60FM = true;};
    			};
    			
    			if (_art60FM && !_art60Cmt) then
    			{
    				_art60Cmt = true;
    						
    				arty60Handle = [_x, 40, 1, 100, "R_57mm_HE", false, 0, "EAST", "WEST", 4] execVM "scripts\arty_fire_mission.sqf";
    			};
    			
    			if (!_art80FM && !_art80Cmt && (count _innerDetected > 8)) then
    			{
    				_trgArty80 = createTrigger["EmptyDetector", getPos _x];
    				_trgArty80 setTriggerArea[150, 150, 0, false];
    				_trgArty80 setTriggerActivation["EAST", "PRESENT", false];
    				_trgArty80 setTriggerStatements["this", "", ""];
    				
    				sleep 1;
    				_arty80Detected = list _trgArty80;
    				deleteVehicle _trgArty80;
    				
    				if (count _arty80Detected < 1) then {_art80FM = true;};
    			};
    			
    			if (_art80FM && !_art80Cmt) then
    			{
    				_art80Cmt = true;
    						
    				arty80Handle = [_x, 40, 2, 150, "R_80mm_HE", false, 0, "EAST", "WEST", 8] execVM "scripts\arty_fire_mission.sqf";
    			};
    			
    			if (scriptDone arty60Handle) then {_art60Cmt = false; _art60FM = false;};
    			if (scriptDone arty80Handle) then {_art80Cmt = false; _art80FM = false;};
    		}
    		forEach _detected;
    	};
    	
    	sleep 5;
    };
    Last edited by beita; 03-16-2009, 07:13 AM. Reason: Stupid vector math.

    Comment


    • #3
      Re: Mission Scripted Artillery

      Nice work Beta. I used the "Mortar" fire in the Street Sweeper, but it is pretty set in terms of positioning, the above seems to be a lot more random based on spotting of forces.
      BlackDog1




      "What we do in life... echoes in eternity!"

      Comment


      • #4
        Re: Mission Scripted Artillery

        Yeah, it works pretty well. Still could be better, but that will require a lot more work and basically a whole AI command structure.

        I'm working on that too (with some great help). If we can get it working properly, the AI will seem more like an organized force more than ever before. Patrolling, calling reinforcements, retreating when things are looking bad, calling artillery, all of these will be happening which will make missions very dynamic. Plus, we are aiming to make it super-easy to set up, just place your units, give them names, place game logics for various patrol points, and then the scripts take over and do their stuff.

        The functions are being designed with server load first and foremost, everything will be done to minimize the effect it will have on the server, and I am hoping it will be possible to go up to at least Company size, most likely even higher.

        Comment

        Connect

        Collapse

        TeamSpeak 3 Server

        Collapse

        Advertisement

        Collapse

        Twitter Feed

        Collapse

        Working...
        X