Jump to content
Sign in to follow this  
CptBBQ

Reveal enemies between players in coop

Recommended Posts

Hi guys,

sorry that I couldn´t think of a more fitting thread title.. :D

I´m currently working on a 2 player coop mission and I want the players the 'share' their information on enemy positions. Basically, when one player spots an enemy, the other player should have him revealed on his map as well.

The only approach I could think of was using 'knowsAbout' and 'reveal' although I know these commands are very limited in their potential. So I had to compromise, but it actually somehow works, kind of..

There are definitely more enemies revealed on the map and the overall situational awareness is indeed enhanced. BUT.. the enemy positions don´t seem to be updated correctly, only the initial 'reveal' is spot on, after that the markers often differ for both players, or some markers don´t appear at all.

I already like this script, but I´m sure some of you would know a way to improve it. Or is there even an other completely different approach to this?

Anyway, here´s the script, any comments appreciated.

if (!isDedicated) then {

while {true} do {

	_allUnits = + allUnits;
	_vehicles = + vehicles;
	_array = _allUnits + _vehicles;
	opforUnits = [];
	{if (side _x == east) then {opforUnits set [count opforUnits, _x];};} forEach _array;


	if (player == player1) then {
		player1Knows = [];
		{if (player knowsAbout _x >= 0.1) then {player1Knows set [count player1Knows, _x];};} forEach opforUnits;
		publicVariable "player1Knows";
		waitUntil {!isNil "player2Knows"};
		{if (player knowsabout _x < 1) then {player reveal _x;};} forEach player2Knows; 
		player2Knows = nil;
		opforUnits = nil;
	};

	if (player == player2) then {
		player2Knows = [];
		{if (player knowsAbout _x >= 0.1) then {player2Knows set [count player2Knows, _x];};} forEach opforUnits;
		publicVariable "player2Knows";
		waitUntil {!isNil "player1Knows"};
		{if (player knowsabout _x < 1) then {player reveal _x;};} forEach player1Knows; 
		player1Knows = nil;
		opforUnits = nil;
	};	
sleep 20;
};

};

Cheers,

CptBBQ

Share this post


Link to post
Share on other sites

Ok, sure. But then only one player has a team to command.

Sorry, I should have stated that this is not an option.

Isn´t there a 'good' way to do this? Or at least better than what I did?

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  

×