Jump to content

Help Editing Your I&A


RizlaUK

Recommended Posts

Hi,

 

I'm trying to tweak your excellent Invade & Annex mission a little, to suit our server. A few people have attempted this request but they haven't been able to do it. What i want to achieve is this;

 

1. During the Attack part of the mission, we have a threshold of 10 remaining Opfor (when we hit this threshold it should start a 5 min timer, if we don't kill the 10 remaining Opfor it goes to Defend after 5 mins; if we kill them it cuts the timer short and goes to Defend on the death of the last Opfor). This would prevent the boring situation of finding the stubborn last 10 and also prevent the situation of if we kill them before 10 mins, having to wait around.

 

2. During the Defend part of the mission the same behaviour as above, last 10 starts a 5 min timer etc. But, if the Opfor wipe out all the Bluefor from the AO, we then get a hint stating, "Opfor have re-taken the area, you have 5 mins to get back into the AO or the objective is lost!" A 5 minute countdown is activated which allows Bluefor to respawn, rearm and get back into the AO. If they don't, then it's a Failed Defend, hint, load next AO.

 

At the minute, with what has been tried already, the Attack never turns to a Defend, even though we have it set to 60% chance of Defend. Also, when the Attack gets to the threshold of the last 10, it just instantly completes the AO.

 

Here is the code, hopefully somebody can spot or suggest how to get this going.

 

Thanks a lot.

 

Rizla

 

/*
Author: 

	Jester [AW] & Quiksilver

Last modified: 

	16/04/2014 by QS
	
Description:

	When AO is complete, a chance that OPFOR will counterattack.
	
	Create AO detection trigger
	At end of sequence, count WEST.
	if (WEST < 1) exitWith {lost};
	if (WEST > 0) exitWith (held);
	
	Also, APCs spawned with EOS do not engage for whatever reason
_______________________________________________________*/

private ["_pos","_rad","_survivors","_type","_dt"];

sleep 1;

if(random 1 >= 0.35) then {
	
		_defendMessages = [
		"OPFOR Forces incoming! Seek cover immediately and defend the objective area!",
		"The enemy managed to call in reinforcements! Form a perimeter around the objective area!"
	];
	_targetStartText = format [
		"<t align='center' size='2.2'>Defend Target</t><br/><t size='1.5' align='center' color='#0d4e8f'>%1</t><br/>____________________<br/>We have a problem. The enemy managed to call in reinforcements. They are on the way to take back the last target. CaFo HQ have airdropped you resupplies, defend the objective at all costs!",
		currentAO
	];
	
	execVM "scripts\misc\supplycrates\supply_drop_defend.sqf";

	[_targetStartText] remoteExec ["AW_fnc_globalHint",0,false];
	["NewMainDefend", currentAO] remoteExec ["AW_fnc_globalNotification",0,false];

	{_x setMarkerPos (getMarkerPos currentAO);} forEach ["aoCircle_2","aoMarker_2"];
	"aoMarker_2" setMarkerText format["Defend %1",currentAO];

	sleep 10;
	//publicVariable "refreshMarkers";
	publicVariable "currentAO";
	currentAOUp = true;
	radioTowerAlive = false;

	_playersOnlineHint = format [
		"<t size='1.5' align='left' color='#C92626'>Enemy attacking %1!</t><br/><br/>____________________<br/>Get ready boys they are almost here!", currentAO
	];


	_defendTimer1 = 480;			// 480
	_defendTimer2 = random 120;		// 120
	//_defendTimer1 = 5;			// 480	
	//_defendTimer2 = random 10;		// 120
	
	[_playersOnlineHint] remoteExec ["AW_fnc_globalHint",0,false];

	sleep 160;

	hqSideChat = _defendMessages call BIS_fnc_selectRandom;
	[hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];

	_type = [1,2,3];
	_selectedType = _type select (floor (random (count _type)));
	
	if (_selectedType == 1) then {
		null = [["aoCircle_2"],[5,5],[3,2],[0],[1,0],[0,0,EAST],[0,2,420,FALSE,true]] call Bastion_Spawn;
	};
	if (_selectedType == 2) then {
		null = [["aoCircle_2"],[4,5],[3,2],[0],[2,5],[0,0,EAST],[0,2,420,FALSE,true]] call Bastion_Spawn;
	};
	if (_selectedType == 3) then {
		null = [["aoCircle_2"],[5,5],[3,2],[3],[1,0],[0,0,EAST],[0,2,420,FALSE,true]] call Bastion_Spawn;
	};
		
	hqSideChat = "Thermal images show the bastards are at the perimeter of the AO!";
	[hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];
			
	sleep 5;
			
	hqSideChat = "";
	[hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];
			
	//sleep _defendTimer1;
		
	hqSideChat = "";
	[hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];
	
	//sleep _defendTimer2;
	
		
	//Lets add a check to make sure all OPFOR units are killed.
	_PositionCheck = getMarkerPos currentAO;
	
	//Start a loop to check if units are alive or not
	_AttackContinue = true;
	_BluforPresentInitially = false;
	_DefenseTimer = 0;

	While {_AttackContinue} do
	{
		_OpforUnitList = [];
		_BluforUnitList = [];
		
		{if (side _x IsEqualTo EAST) then {_OpforUnitList pushback _x}; } forEach allUnits;
		{if (side _x IsEqualTo WEST) then {_BluforUnitList pushback _x}; } forEach allUnits;
		
		//If the opfor unit is more than 1000 M. away. Do not consider him apart of the town assault.
		{
			if (_x distance _PositionCheck > 1000) then {_OpforUnitList = _OpforUnitList - [_x];};
		} foreach _OpforUnitList;
		if (count _OpforUnitList < 10) then {_AttackContinue = false;};
		
		//If the blufor unit is more than 1000 M. away, we will not consider him a part of the town defense.
		{
			if (_x distance _PositionCheck > 1000) then {_BluforUnitList = _BluforUnitList - [_x];};
		} foreach _BluforUnitList;	
		
		if !(_BluforPresentInitially) then
		{
			if (count _BluforUnitList > 0) then {_BluforPresentInitially = true};
		}
		else
		{
			if (count _BluforUnitList < 1) then {_DefenseTimer = _DefenseTimer + 5} else {_DefenseTimer = 0};
			hqSideChat = format ["Blufor has %1 seconds left to return to the town!",300 - _DefenseTimer];
			[hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];			
			
			if (_DefenseTimer >= 300 && count _opforunitlist < 10) then {_AttackContinue = false;};
		};		
		
		
		
		//Check every 5 seconds
		sleep 5;
	};
	
	
	if (_DefenseTimer >= 300 && count _opforunitlist < 10) then
	{
		_targetEndText = format [
			"<t align='center' size='2.2'>Failed Defend! </t><br/><t size='1.5' align='center' color='#C92626'>%1</t><br/>____________________<br/>The assault has ended and the Opfor has retaken the objective. Try harder next time!",
			currentAO
		];
	
		[_targetEndText] remoteExec ["AW_fnc_globalHint",0,false];
	
		[["aoCircle_2"]] call EOS_deactivate;	
	}
	else
	{
		_targetEndText = format [
			"<t align='center' size='2.2'>Successful Defended! </t><br/><t size='1.5' align='center' color='#0d4e8f'>%1</t><br/>____________________<br/>The assault has ended and we've sent them packing - well done!",
			currentAO
		];
	
		[_targetEndText] remoteExec ["AW_fnc_globalHint",0,false];
		
		spawn QS_fnc_AOdelete;
	
		[["aoCircle_2"]] call EOS_deactivate;	
		
		
	};
		
	
   //----------------------------------------------------- MAINTENANCE
	
	_aoClean = [] execVM "scripts\misc\clearItemsAO.sqf";
	waitUntil {
		scriptDone _aoClean
	};
	sleep 20;
};
Link to comment
Share on other sites

Ok so Are you having problems with the defend part of the AO or just that it will not activate. If it is that it will not start it is probably because you don't have the parameter set in the description. I have not tested out the script that you have posted but it looks like it should work like how you want it to in point 2. Also for part 1 you would need to make the changes for that in the region**.sqf files.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Forum Statistics

    11.1k
    Total Topics
    66.4k
    Total Posts
×
×
  • Create New...