Jump to content
Sign in to follow this  
kanelbolle

Capture & Hold - MP mission

Recommended Posts

Hi,

i am trying to make a capture and hold mission in Arma 2.

But i am experiencing problems with the capture zones.

I am using triggers and Public Variables for this and it seem to work well.

The problem seem to be that when both sides are in the zone

The marker becomes yellow that indicates that there is a battle in the town, but after some time 1 of the teams captures the zone even if there is a enemy player in the zone.

Can any one help me with this problem ? Or is there a better way of doing this ? And am i using Public Variables right ?

I have the mission test file here:

http://www.tnett.no/kanelbolle/CaptureAndHold.Takistan.zip

Edited by Kanelbolle

Share this post


Link to post
Share on other sites

i would try a repeated, anyone present trigger and in on act have something like this:

_null = [triggerName,markername] spawn {
_trigger = _this select 0;
_marker = _this select 1;

_eastCap = 60;
_westCap = 60;
while {(count (list _trigger)) != 0} do {
	if ( ({alive _x AND (side _x) == west} count list _trigger) > ({alive _x AND (side _x) == east} count list _trigger) ) then {
		_westCap = _westCap - 1;
		if (_eastCap < 60) then {_eastCap = _eastCap + 1};
	};
	if ( ({alive _x AND (side _x) == east} count list _trigger) > ({alive _x AND (side _x) == west} count list _trigger) ) then {
		_eastCap = _eastCap - 1;
		if (_westCap < 60) then {_westCap = _westCap + 1};
	};
	sleep 1;
	if (_westCap == 0) then {_marker setMarkerColor "BLUE"};
	if (_eastCap == 0) then {_marker setMarkerColor "RED"};
};
};

btw, code is untested so may not work..

but the goal of the snippet is to have more bluefor than opfor inside trigger for 60 seconds to turn marker blue, and same for opfor,

if opfor gets more than blues inside while blue is capturing, the timer goes backwards 1 second a time until opfor reaches 60 seconds

and so on and so forth..

snippet ends when nooen is inisde trigger area.

Share this post


Link to post
Share on other sites

This is mine AAS code...May can help you:

if !(isServer) exitWith {};
_unit_capture = ArrayParam select 0;
_capture_time = ArrayParam select 1;
_capture_time_b = _capture_time + 1;
sec1blu = false;
sec1red = false;
_e = 0;
_i = 0;
While {true} do 
{
_unit = WEST countSide list trg1;
_unitop = EAST countSide list trg1;
if (_unit == 0) then {_i = 0;};
if (_unitop == 0) then {_e = 0;};
if (sec2red) then {_i = 0;};
while {_unit > _unit_capture && _unit > _unitop && _i < _capture_time_b && !sec1blu} do 
{
if (_unitop == 0) then {_e = 0;};
_unit = WEST countSide list trg1;
_unitop = EAST countSide list trg1;
sleep 1;
_i = _i +1;
_ih = _capture_time - _i;
if (_i == _capture_time) then 
	{
		flag1 setFlagTexture "\ca\ca_e\data\flag_us_co.paa";
		"sec1" setMarkerColor "ColorBlue";
		sec1red = false;
		sec1blu = true;
		publicvariable "sec1blu";
		publicvariable "sec1red";
		_i = 0;
	};
};
sleep 0.2;
while {_unitop > _unit_capture && _unitop > _unit && _e < _capture_time_b && !sec1red} do 
{
if (_unit == 0) then {_i = 0;};
_unit = WEST countSide list trg1;
_unitop = EAST countSide list trg1;
sleep 1;
_e = _e +1;
_eh = _capture_time - _e;
if (_e == _capture_time) then 
	{
	flag1 setFlagTexture "\ca\ca_e\data\flag_tkm_co.paa";
	"sec1" setMarkerColor "ColorRed";
	sec1red = true;
	sec1blu = false;
	publicvariable "sec1blu";
	publicvariable "sec1red";
	_e = 0;
	};
};
sleep 0.2;
if (!isNil ("sec1blu")) then
{
	if (sec1blu) then
	{
		flag1 setFlagTexture "\ca\ca_e\data\flag_us_co.paa";
		"sec1" setMarkerColor "ColorBlue";
		sec1red = false;
		sec1blu = true;
		publicvariable "sec1blu";
		publicvariable "sec1red";
	};
};
sleep 0.2;
if (!isNil ("sec1red")) then
{
	if (sec1red) then
	{
		flag1 setFlagTexture "\ca\ca_e\data\flag_tkm_co.paa";
		"sec1" setMarkerColor "ColorRed";
		sec1red = true;
		sec1blu = false;
		publicvariable "sec1blu";
		publicvariable "sec1red";
	};
};
sleep 0.2;	
};

Share this post


Link to post
Share on other sites

Ok, thx will try the codes out and see what i can get it working on my mission :)

Share this post


Link to post
Share on other sites

Thx i edited the first code and got it working:

_null = [t1_captrigger] spawn {
_trigger = _this select 0;
_eastCap = 10;
_westCap = 10;

while {(count (list _trigger)) != 0} do {
	if ( ({alive _x AND (side _x) == west} count list _trigger) > ({alive _x AND (side _x) == east} count list _trigger) ) then {
		if (_westCap > 0) then {
		   _westCap = _westCap - 1;
		};
		if (_eastCap < 10) then {_eastCap = _eastCap + 1};
	};
	if ( ({alive _x AND (side _x) == east} count list _trigger) > ({alive _x AND (side _x) == west} count list _trigger) ) then {
		if (_eastCap > 0) then {
		_eastCap = _eastCap - 1;
		};
		if (_westCap < 10) then {_westCap = _westCap + 1};
	};

	if ({alive _x AND (side _x) == west} count list _trigger > 0) then {
	if ({alive _x AND (side _x) == east} count list _trigger > 0) then {
	   Hint "Battle at: Feruz Abad";
	};
	};

	sleep 1;


	if (_westCap < 1) then	{
	   "town1marker" setMarkerColor "ColorBlue";	   
	   PUB_WEST_HOLD_TOWN1 = true;
	   publicVariable "PUB_WEST_HOLD_TOWN1";
 	   PUB_EAST_HOLD_TOWN1 = false;
	   publicVariable "PUB_EAST_HOLD_TOWN1";
	};
	if (_eastCap < 1) then {
	   "town1marker" setMarkerColor "ColorRed";
	   PUB_WEST_HOLD_TOWN1 = false;
	   publicVariable "PUB_WEST_HOLD_TOWN1";
 	   PUB_EAST_HOLD_TOWN1 = true;
	   publicVariable "PUB_EAST_HOLD_TOWN1";
	   };   
};
};

I added a hint when there are players on both sides, but this will turn up all the time while this i true.

Any good ide on how to make this only show 1 time every time there are players on both teams in the zone ?

Share this post


Link to post
Share on other sites
Thx i edited the first code and got it working:

*snip*

I added a hint when there are players on both sides, but this will turn up all the time while this i true.

Any good ide on how to make this only show 1 time every time there are players on both teams in the zone ?

add this to top of script before the while loop:

_oneSide = true;

	if ({alive _x AND (side _x) == west} count list _trigger > 0[b] AND _oneSide[/b]) then {
		if ({alive _x AND (side _x) == east} count list _trigger > 0) then {
			Hint "Battle at: Feruz Abad";
			[b]_oneSide = false[/b];
		};
	};

---------- Post added at 09:59 PM ---------- Previous post was at 09:52 PM ----------

and add this under the above snippet:

		if (!_oneSide AND (({alive _x AND (side _x) == west} count list _trigger) == 0 OR ({alive _x AND (side _x) == east} count list _trigger) == 0)) then {
		_oneSide = true;
	};

it will reset the hint if only west or only east units is inside the trigger.

Share this post


Link to post
Share on other sites

thx. Will try it out right away.

1 more qestion. Does it mather if i place this trigger in the editor with the code when it is a multiplayer mission. I have had problems that the color did not change on the marker for other players.

This i solved by just checking if the public Variable PUB_WEST_HOLD_TOWN1 was true

and then make it change the color....

Share this post


Link to post
Share on other sites

try replacing this line:

"town1marker" setMarkerColor "ColorBlue"; 

with this one:

{
if (_x == player) then {"town1marker" setMarkerColor "ColorBlue"};
} foreach playableUnits;

also repeat for the other colors.

i think it should play correct for all players, though JIP is a whole new issue im not sure about, but AAS does that well i believe.

Share this post


Link to post
Share on other sites

Arnt the Variables "_westCap" & "_eastCap" local to the computer of every player ?

Won't this risk the value of these to be different on every computer ?

Share this post


Link to post
Share on other sites

hey there, this was extremely useful to me so far, but i have an additional request that i dont know how to implement.

description:

i have 3 capture points, they all work. what i want to do now is, before f.e. blufor can cap point 2 they have to own point 1, same for point 3, they have to own point 1 & 2 before they can cap point 3. for the opfor the same pattern but reversed, they have to have point 3 & 2 to cap 1 and so on.

does anyone have a solution for that?

im not that much of a scripter, yet...

so an example would be great

thx in advance,

s4ikD

Share this post


Link to post
Share on other sites

[sBS]mac's PVP script pack does all this (assuming you're creating a PVP mission and not vs. AI). it's very good, but make a backup of your mission folder before you run it's setup over your mission.

Share this post


Link to post
Share on other sites

i already tried the pvp script pack, but its so complex that i couldnt set the script for the object cap order apart from the rest, so no help for me there.. its all tightly woven into each other.

Share this post


Link to post
Share on other sites
description:

i have 3 capture points, they all work. what i want to do now is, before f.e. blufor can cap point 2 they have to own point 1, same for point 3, they have to own point 1 & 2 before they can cap point 3. for the opfor the same pattern but reversed, they have to have point 3 & 2 to cap 1 and so on.

does anyone have a solution for that?

im not that much of a scripter, yet...

so an example would be great

i asume you use seized by triggers or something.

anywho, for this example we use seized by triggers.

in init.sqf place:

point1Capped = false;
point2CApped = false;

point1 trigger:

cond:

this

on act: if you have markers or anything add that after this below.

point1Capped = true;

point2 trigger:

cond:

this and point1Capped

on act:

point2CApped = true;

point3 trigger:

cond:

this AND point1Capped AND point2CApped

on act:

 whatever you do here 

Share this post


Link to post
Share on other sites

thank you very much, works like a charm :)

Share this post


Link to post
Share on other sites

Trying to make my own C&H for a radar station. Both teams attack. On the trigger on the map I have this condition (with a timeout of 30 sec)

(player in thisList) && (player countEnemy thisList < 1)

The activation

scoreFor = (side player); publicVariable "scoreFor";

And then on the server I'll add a PVEH that gives a point to the correct team, with a sleep of 30 seconds to prevent non-correct score updates. Will this work?

Does triggers with timeouts check the conditition every 0.5 sec?

E: Guessing this won't work on non-dedicated servers

edit: something like this

if (!isServer) exitWith {};
bluforscore = 0;
opforscore = 0;
addingScore = false;
"scoreFor" addPublicVariableEventHandler {
if (!addingScore) then {
	addingScore = true;
	_team =  (_this select 1);
	if (_team == WEST) then {
	bluforscore = bluforscore+1;
	} else {
	opforscore = opforscore+1;
	};
	sleep 30;
	addingScore = false;
};
};

Edited by cuel

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×