Jump to content
Sign in to follow this  
wiggum2

Reduce enemy number if less human Players are there (MP)

Recommended Posts

Hi,

i search for a script do delete/reduce the number of enemys on the Map if there are less human players. So if i have a Coop mission for 6 players, but we play it only with 3 some enemy groups should be deleted.

This is what i have currently, what do you think about it ?

if (!isServer) exitWith {};

_plnum = playersNumber west;

if (_plnum <= 2) then {
{deletevehicle _x} foreach units myGroupName1;
sleep 5;
deleteGroup myGroupName1;
{deletevehicle _x} foreach units myGroupName2;
sleep 5;
deleteGroup myGroupName2;
};
if (_plnum <= 4) then {
{deletevehicle _x} foreach units myGroupName3;
sleep 5;
deleteGroup myGroupName3;
};

If anyone knows a better solution that works in MP too please tell me it.

Share this post


Link to post
Share on other sites

My 2 cents:

AI is local to the server, so the scripts dealing with AI groups should work in SP and MP most of the time.

One thing i see a problem with is that one of the groups you delete ingame could already be in sight or fighting with a player, it would kill the atmosphere if somebody sees groups disappearing into thin air. Depends when and how you delete groups though. Players could drop out of the session during gameplay, so you would delete groups while the mission is underway, right?

SO maybe before deleting a group check whether they're in combat and have a target.

Share this post


Link to post
Share on other sites
Hi,

i search for a script do delete/reduce the number of enemys on the Map if there are less human players. So if i have a Coop mission for 6 players, but we play it only with 3 some enemy groups should be deleted.

This is what i have currently, what do you think about it ?

If anyone knows a better solution that works in MP too please tell me it.

I recently tried something like this for a multiplayer game. I've had bad experiences spawning units on the fly, so what I do is statically define most of the enemies in the editor, and selectively delete them at mission start. The missions I make and play aren't long enough for JIP to be a real issue.

What's nice is that it's small enough to fit in an AI's Init box in the editor.

Theoretically, you could call it at any point in the mission, but Strangelove already pointed out that you need to be wise in deciding when to do that.

USAGE:

[3, usSniper] execVM "scalePlayers.sqf";  // Delete a unit when less than 3 players
[3, group usSniper] execVM "scalePlayers.sqf";  // Delete a group
[3, [indMG1, indMG2, indCommander] execVM "scalePlayers.sqf";  // Delete an array of units

// Does NOT handle detecting occupied vehicles!

///////////////////////////////////////////////////////////////////////////////

private ["_minPlayerCount", "_unitsAffected", "_fKillTheseUnits"];

_minPlayerCount = _this select 0;
_unitsAffected = _this select 1;

///////////////////////////////////////////////////////////////////////////////


//
//	Do not eliminate troops if you're not the server, or we're in editor mode, or we have enough players
//

_fKillTheseUnits = (isServer && (!isNil "paramsArray") && (playersNumber east < _minPlayerCount));
// ^^^^^^^^^^^ EDIT THIS CONDITION ^^^^^^^^^^^^

if ( _fKillTheseUnits ) then
{
private ["_unitsAffectedArray", "_containingVehiclesArray"];
_containingVehiclesArray = [];


//
//	Handle different input types
//

switch (typeName _unitsAffected) do
{
	case "ARRAY":
	{
		_unitsAffectedArray = _unitsAffected;
	};

	case "GROUP":
	{
		_unitsAffectedArray = units _unitsAffected;
	};

	case "OBJECT":
	{
		_unitsAffectedArray = [_unitsAffected];
	};
};

//
//	Delete units
//

{
	//
	//	Keep track of containing vehicles
	//

	private "_vx";
	_vx = vehicle _x;
	if (_x != _vx) then
	{
		if (!(_vx in _containingVehiclesArray)) then
		{
			_containingVehiclesArray set [count _containingVehiclesArray, _vx];
		};
	};

	//
	//	Delete unit
	//

	if (typeName _x == "OBJECT") then
	{
		deleteVehicle _x;
	};
} foreach _unitsAffectedArray;

//
//	If we caused any vehicles to be empty, delete those vehicles
//

{
	if (count crew _x < 1) then { deleteVehicle _x };
} foreach _containingVehiclesArray;
};

!_fKillTheseUnits

There's a few bugs still in there.

Share this post


Link to post
Share on other sites

@ bartkusa

Thanks for the Script, i will try it !

My plan was to place all units in the editor and remove them only at the start of the mission. There is still a problem with JIP (start with 2 and 4 join later but enemys are already deleted) but i think it will not be that big...

Why would you start a Coop Mission that was made for 6 Players with 2 and have 4 other that will join after 30min...thats stupid and i think normally nobody does such thing (hopefully).

Share this post


Link to post
Share on other sites

I usually place several enemy groups in reserve, a bit (but not completely) away from the area of operations. These units are waiting for a trigger switch: isPlayer leader myPlayableGroup

When the trigger fires the reserves move into the area of operation (usually on guard waypoints, but sometimes with more elaborate movement patterns).

If there are two playable groups, I make two reserve groups. Thre playable is three reserves, and so on.

These triggers will go off even if a player decides to JIP as the leader of a previously AI-led team. Thus producing a dynamic resistance, that takes the number of human players into account. It's a foolprof method that works perfectly in any MP environment, on a hosted game as well as on a dedicated server.

Share this post


Link to post
Share on other sites

You could use DAC. It has build in Options to achive exact such stuff

DAC_Auto_UnitCount

Share this post


Link to post
Share on other sites
I usually place several enemy groups in reserve, a bit (but not completely) away from the area of operations. These units are waiting for a trigger switch: isPlayer leader myPlayableGroup

When the trigger fires the reserves move into the area of operation (usually on guard waypoints, but sometimes with more elaborate movement patterns).

If there are two playable groups, I make two reserve groups. Thre playable is three reserves, and so on.

These triggers will go off even if a player decides to JIP as the leader of a previously AI-led team. Thus producing a dynamic resistance, that takes the number of human players into account. It's a foolprof method that works perfectly in any MP environment, on a hosted game as well as on a dedicated server.

Sounds great !

I have only one playable group (soldiers named p1-p6) but want to have these reserves move if there are more human players in this group.

So i would use this ?:

isPlayer p2 AND is Player p3

Or would this work too ?

playersNumber west >= 3

Share this post


Link to post
Share on other sites

Ok, i now use this code and it works:

playersNumber west > 2;

This is as condition in a trigger that will spawn a unit at missionstart if there are more then 2 west players.

Problem is, it looks like that AI (set to playable) is also count as "player", so if i have 4 AI guys in my group the above trigger will always fire.

Is this only in SP or MP too ?

Is there a way to dont count AI units in my group as "player" ?

Share this post


Link to post
Share on other sites

MP missions only (playableunits is empty in SP):

{isplayer _x} count playableunits > 2

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  

×