Opened 10 years ago

Last modified 3 years ago

#2459 new enhancement

Add a cooperative mode

Reported by: Antoine cezar Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Simulation Keywords:
Cc: Patch:

Description (last modified by elexis)

I've sucessfully made it work with a dirty hack:

Index: source/network/NetServer.cpp
===================================================================
--- source/network/NetServer.cpp	(révision 14856)
+++ source/network/NetServer.cpp	(copie de travail)
@@ -645,7 +645,7 @@
 	PlayerAssignment assignment;
 	assignment.m_Enabled = true;
 	assignment.m_Name = name;
-	assignment.m_PlayerID = playerID;
+	assignment.m_PlayerID = 1;
 	m_PlayerAssignments[guid] = assignment;
 
 	// Send the new assignments to all currently active players

It worked with a modified host and an unmodified client, but you must not touch to the human player placement.

Since seemed to be just a mater of playerID I thougth that tweaking the gamesetup.js should do the trick. But whatever attempt I've made ended in "nothing happened" or "coredump".

I've spotted a potential reason in CNetServerWorker::AssignPlayer which "Remove anyone who's already assigned to this player" before assigning the new playerID and introduced my own method which just set on gui playerID to the other:

void CNetServerWorker::SetCooperation(const CStr& firstGuid, const CStr& secondGuid)
{
	if (m_PlayerAssignments.find(firstGuid) != m_PlayerAssignments.end()
	&&  m_PlayerAssignments.find(secondGuid) != m_PlayerAssignments.end())
	{
		
		m_PlayerAssignments[secondGuid].m_PlayerID = m_PlayerAssignments[firstGuid].m_PlayerID;
		SendPlayerAssignments();
	}
}

And tweaked gamesetup again, but nothing works for now.

Change History (14)

comment:1 by Stan, 9 years ago

Could you submit a patch ?

comment:2 by Antoine cezar, 9 years ago

Sorry didn't see your message.

I did not succeded to make a usable version of this hack. I've given up for the moment. I'll give it another if you find the feature interresting

comment:3 by elexis, 9 years ago

Component: Core engineUI & Simulation
Priority: If Time PermitsNice to Have

So the idea behind this is to have multiple clients control the same player? Would be cool.

In that case you would need to change the "Player X" entries in gamesetup to dropdowns, so that multiple clients can be assigned to the same player ID.

Introducing that might have unwanted consequences, maybe the chat messages might be updated too.

You are correct that CNetServerWorker::AssignPlayer needs to be changed.

comment:4 by elexis, 7 years ago

Refs #4435

comment:5 by wraitii, 7 years ago

Would be nice to distinguish this from a campaign co-op mode (from a ticket POV).

comment:6 by Antoine cezar, 7 years ago

In fact #4435 was exactly what I had in mind in the first place. But given my knowledge of the the code base at the time (and still today) the the best I figured out was to control the same faction. Controlling the same faction seems to me easier to achieve but I wonder in it's relevant if #4435 get implemented. Maybe both could coexists?

comment:7 by elexis, 7 years ago

Your patch also assigns two clients to the same player slot, hence same color, independent of the chosen civilization.

comment:8 by elexis, 7 years ago

Description: modified (diff)

Wouldn't be surprised if we don't have to change the network code at all. See also comments in the duplicate.

comment:9 by Imarok, 5 years ago

Component: UI & SimulationSimulation

Move tickets to Simulation as UI & Simulation got some sub components.

comment:10 by bb, 4 years ago

An issue found by D3014. The GUI in question there can't assume that the only changes are done via the gui. Probably needs some event-based changing. This might apply to more gui values.

comment:11 by Arthur, 3 years ago

Is there any Progress on this?

I got this feature working for Single Player (one of the AI's and I are controlling the same Player).

Though, on multiplayer it is a bit more complicated and somehow i am not able to compile the code on my machine to modify the c++ code.

comment:12 by Freagarach, 3 years ago

There has been no progress as far as I am aware, no. If you want you can join #0ad-dev on QuakeNet (IRC; https://www.wildfiregames.com/irc.html) such that we can try to help you with the compilation.

comment:13 by Vas, 3 years ago

That would be a very nice addition! Scenarios where it could be used:

  • play with your friend/relative in a non-competitive fashion, but still _with_ each other, having more feeling of sharing the game. So called "survival" games
  • promote building "shared" defenses, e.g. we both have buildings on same territory
  • Play 2vs2 games online where you are encouraged to learn from your buddies. That is pretty popular in some games
  • Play with people of different experience level. E.g. if controlling the whole game is too much for a person, they could start with only doing economy/conquest

comment:14 by Vas, 3 years ago

One way to implement this could be to turn around player/side assignment. E.g. tell which player does what, not which side is controlled by whom. For example:

  • player A controls 1
  • player B controls 2
  • player C controls 2

Instead of:

  • side 1 is controlled by "A"
  • side 2 is controlled by "B,C" (with some UI for multi-selection)

That being said, any approach is fine as long as it works :) Would be super-cool to have this!

Note: See TracTickets for help on using tickets.