Autogame on multiplayer

Discuss the future of Warzone 2100 with us.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Autogame on multiplayer

Post by cajadas »

Hi,

I've been trying to test some multiplayer features and noticed the best way to do it would be using AI. I've best suggested to use the "autogame on" cheat i doesn't seem to work on multiplayer.

Was this feature disabled or deleted for multiplayer? Can i easily get it up and running?

I'm working on master (20110320).

Thanks.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Autogame on multiplayer

Post by Per »

It should work. You need to enter cheat mode first?
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: Autogame on multiplayer

Post by Berg »

I did a few test with now trunk and old trunk this cheat works in multiplay in old trun but seems not to work in the last version it has nexus.slo with the same cheat code in it as old trunk had in AI.slo

so yes it was tried in cheat mode but did not function

regards berg


PS:maybe its QT?
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Autogame on multiplayer

Post by cajadas »

By Cyps suggestions, i when looking over the src folder for AI script loading indications and found this on loadMultiScripts() (src/mulyiint.cpp).

Code: Select all

// Load AI players
	resForceBaseDir("multiplay/skirmish/");
	for (int i = 0; i < game.maxPlayers; i++)
	{
		// The i == selectedPlayer hack is to enable autogames
		if (bMultiPlayer && game.type == SKIRMISH && (!NetPlay.players[i].allocated || i == selectedPlayer)
		    && NetPlay.players[i].ai >= 0 && myResponsibility(i))
		{
			resLoadFile("SCRIPT", aidata[NetPlay.players[i].ai].slo);
			resLoadFile("SCRIPTVAL", aidata[NetPlay.players[i].ai].vlo);
		}
	}
Notice the condition confirms if it is a skirmish game. May this be the reason for "autogame on" only working on skirmish games but not on multiplayer? I'll test tomorrow.

However, by this code i can't understand what AI files are being loaded since the only AI scripts now are nexus, dydo and semperfi and none of this names appears here.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Autogame on multiplayer

Post by Per »

Multiplayer games are also counted as "skirmish". Sorry, the terminology here is imprecise and confusing.

Did you specifically mean if the "autogame" feature works in multiplayer games with other people? I think there is a check to prevent that in the script somewhere.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Autogame on multiplayer

Post by cajadas »

Besides this condition on loadMultiScripts() i found no other mention of "autogame" on other files in the src folder. However, inside nexus.slo there is a condition to check in the console message is "autogame on":

Code: Select all

event consoleEv(consoleTr)
{	
	//turn on 'autogame'
	if(message == "autogame on" && (sender == me))
	{
		if(debugModeEnabled())
		{
			if(myResponsibility(me))
			{
				if(not bRunning)		//make sure current machine is responsible for this AI and it's not already active
				{
					console(getPlayerName(me) & " is active");
					reassignAI();
					setEventTrigger(startLevel, chainloadTr);
				}
			}
		}
	}
...
I believe the ai.slo file was substituted by nexus.slo and when a player types "autogame on" this is the AI script running (since the default NetPlay.players.ai value is 0) but i cant find any check here to prevent this feature on multiplayer games with other people.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Autogame on multiplayer

Post by Per »

Hmm. Right. The only thing I see is that it checks that you are the host (all AIs run on the host).
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Autogame on multiplayer

Post by cajadas »

But all players run the function loadMultiScripts() when starting a multiplayer session. When "autogame" is enabled on a peer not host doesn't he run the AI script?

The thing is, as i am trying use "autogame" to test my multiplayer implementation. If a peer doesn't run the AI when "autogame" is enabled i'm afraid i can't monitor message traffic.

EDIT: I checked out the myResponsibility function and noticed that it return true if the player is responsible for himself (a.k.a. not AI), which checks out on a multiplayer game (at least in the tests i've made).
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Autogame on multiplayer

Post by Per »

AIs only run on host, not on peers. myResponsibility(player) is true for if player is human and we are this player, or if we are host and player is an AI.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Autogame on multiplayer

Post by cajadas »

Since every player loads the AI scripts, wouldn't there be a way to activate AI on peer letting the host think that he's still a human player?

EDIT: I can't find anywhere the function consoleEv() being called. I guess this might be the problem. Since "autogame on" is enabled on 2.3.8 i think this might be QT related.
cajadas
Trained
Trained
Posts: 56
Joined: 01 Mar 2011, 17:33

Re: Autogame on multiplayer

Post by cajadas »

Hi,

I'm still looking in the code how the function consoleEv() in nexus.slo is called to figure out with does it work on skirmish and not on multiplayer. Doesn't every player load nexus.slo on loadMultiScript() (src/multiint.cpp) ?

Moreover, how are AI functions (such as consoleEv) called on src?

Thanks