Some problems & questions making a multiplayer scenario

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

Hieronymus
Posts: 41
Joined: February 24th, 2005, 2:10 pm

Some problems & questions making a multiplayer scenario

Post by Hieronymus »

Hi all,

After making some multiplayer maps I am making my first multiplayer scenario, and use WML for the first time. The scenario I want to make is a bit difficult, since I am trying to make the following:

On the map there are certain villages which, if you capture them, will give you one unit per turn. These units will be "spawned" at the end of the turn of the person who has the village. Each of these "spawn-villages" have there own x,y pos where they will spawn the unit.

Now I am a bit of a perfectionist, and I want my WML code to be reusable for different maps. I am trying to make it so that when changing the map, the only thing you need to change in the WML are the top level macro calls:
{ADD_SPAWN_VILLAGE villageX villageY spawnX spawnY spawnUnitType}

No I am experiencing some troubles, and after some testing (with debug messages) I've come to know that most of them are because of variables which at a certain point have no value (although I have initialized them). I think I may have made some syntax errors, I was first confusing the preprocessor parameter syntax with the actual WML variables syntax and I may still be doing something wrong there. Like I use the following in a definition (macro), where VILLAGENR and SIDE are macro parameters:
[variable]
name=village{VILLAGENR}Owner
numerical_equals={SIDE}
[/variable]
Is that valid? If VILLAGENR is 1, will it take the WML variable village1Owner?

Also I have another question: is there some intern WML variable which you can use to determine which side's turn it is. I only know of "side" which can be used in filters only. But I need to use it outside filters as well. For now I have made my own turnSide variable, but there are some troubles with it and I would rather get rid of it.

Anyway, I would appreciate if some of you could have a look at the code (which is attached to this message). I have added some commentary and used good indents, and also have used macro's, so it should be quite readable.

P.S.: Tomsik, here you are, here is my code, so please don't nag me anymore about it in mp games :-)
Attachments
HieronymusScenario.cfg
the .cfg file in WML
(4.61 KiB) Downloaded 480 times
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

1.you didnt used many definded macros
2.about vilagenr:
i try used something like this something{var}somthing and it didnt work,
3.Place here what dont work
Hieronymus
Posts: 41
Joined: February 24th, 2005, 2:10 pm

Post by Hieronymus »

tomsik wrote:1.you didnt used many definded macros
2.about vilagenr:
i try used something like this something{var}somthing and it didnt work,
3.Place here what dont work
1. Not many macro's? Are you sure we are talking about the same thing? The definitions, starting with #define DEFNAME? I've used 8 of them, and put almost every piece of code inside one.

2. Ok, thanks. I just discovered that you can use arrays, and I probably should use that instead.

3. Currently, when I test it, it says that it "cannot find unit '' ". That is because the variables to the SPAWN macro seems to have no value. Something must go wrong when calling it, or calling the macro which is calling it. You can test it yourself by using any map and place a {ADD_SPAWN_VILLAGE villageX villageY spawnX spawnY spawnUnitType}
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

i propose change in set spawn check change side turn to new turn and
try with arrays
Hieronymus
Posts: 41
Joined: February 24th, 2005, 2:10 pm

Post by Hieronymus »

tomsik wrote: i propose change in set spawn check
what kind of change?
tomsik wrote: change side turn to new turn
change the name of the macro? what good will that do?
tomsik wrote: and try with arrays
yes, i should try with arrays
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

Hieronymus wrote:
tomsik wrote: i propose change in set spawn check
what kind of change?
tomsik wrote: change side turn to new turn
change the name of the macro? what good will that do?
yhm its one sentence
Change in SET_SPAWN_CHECK "name=side turn" to "name=new turn" but its only proposal
Hieronymus
Posts: 41
Joined: February 24th, 2005, 2:10 pm

Post by Hieronymus »

tomsik wrote: yhm its one sentence
Change in SET_SPAWN_CHECK "name=side turn" to "name=new turn" but its only proposal
That would make all spawns for all players take place at the beginning of the first player's turn... but it has nothing to do with the problems I am having

Anyone else who could help me a little?
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

only proposal
fabi
Inactive Developer
Posts: 1260
Joined: March 21st, 2004, 2:42 pm
Location: Germany

if inside of [variable] ?

Post by fabi »

Code: Select all

#define NEXT_SIDE_TURN
	# set turnOfSide variable to next side
	[set_variable]
		name=turnOfSide
		[if]
			[variable]
				name=turnOfSide
				numerical_equals=$nrSides
			[/variable]
			[then]
				value=1
			[/then]
			[else]
				add=1
			[/else]
		[/if]
	[/set_variable]
	[message]
   		message="Debug in NEXT_SIDE_TURN: nrSides $nrSides, turnOfSide $turnOfSide, nrVillages $nrVillages"
   	[/message]
#enddef
As far as i know you aren't allowed to use [if] inside [set_variable].

try :

Code: Select all

[if]   
[variable]
            name=turnOfSide
            numerical_equals=$nrSides
[/variable] 
[then]
 [set_variable]
      name=turnOfSide 
      value=1
 [/set_variable]
[/then]
[else]
 [set_variable]
      name=turnOfSide 
      add=1
 [/set_variable]
[/else]
[/if]
There could be more bugs, i only saw this at first look.
Greetings
fabi
Inactive Developer
Posts: 1260
Joined: March 21st, 2004, 2:42 pm
Location: Germany

another bug

Post by fabi »

Code: Select all

	[if]
		[variable]
			name=village{VILLAGENR}Owner
			numerical_equals={SIDE}
		[/variable]
		[then]
			{SPAWN {$village{VILLAGENR}SpawnType} {SIDE} $village{VILLAGENR}SpawnX $village{VILLAGENR}SpawnY}
		[/then]
	[/if]
{$village{VILLAGENR}SpawnType}

Pherhaps i don't understand what is done here, but i think the outer brackets are wrong here.
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Re: another bug

Post by Rhuvaen »

fabi wrote:

Code: Select all

{$village{VILLAGENR}SpawnType}
He's trying to use arrays. According to the wiki, the dot is missing:

Code: Select all

$village[VILLAGENR].SpawnType
However, I didn't have a lot of success with them so far, and there's only specific tags where they are interpreted at all. I don't know if you have to use the dollar sign on the VILLAGENR (array index), it might depend on the context.

Does this construct actually work for you (those are curly brackets!):

Code: Select all

$village{VILLAGENR}SpawnType
:?: Can you actually improvise a variable name like that? That would be a simple workaround to arrays.

BTW, are variable names case-sensitive? If not, it might not make a lot of sense to type "SpawnType"...
Last edited by Rhuvaen on March 16th, 2005, 10:54 am, edited 1 time in total.
Hieronymus
Posts: 41
Joined: February 24th, 2005, 2:10 pm

Post by Hieronymus »

Thanks fabi, I'll try those things
Hieronymus
Posts: 41
Joined: February 24th, 2005, 2:10 pm

Re: another bug

Post by Hieronymus »

Rhuvaen wrote:
fabi wrote:

Code: Select all

{$village{VILLAGENR}SpawnType}
He's trying to use arrays. According to the wiki, the dot is missing:

Code: Select all

$village[VILLAGENR].SpawnType
However, I didn't have a lot of success with them so far, and there's only specific tags where they are interpreted at all. I don't know if you have to use the dollar sign on the VILLAGENR (array index), it might depend on the context.

Does this construct actually work for you (that curly brackets!):

Code: Select all

$village{VILLAGENR}SpawnType
:?: Can you actually improvise a variable name like that? That would be a simple workaround to arrays.

BTW, are variable names case-sensitive? If not, it might not make a lot of sense to type "SpawnType"...
I was not trying to use arrays here (since I did not know yet that I could). So it was indeed kind of a workaround to arrays.

I am still not sure if it works though, Tomsik says it doesn't work but he still uses the same in his newest version of his "The War" scenario and that seems to be working fine:

Code: Select all

[set_variable]
   name=kills{SIDE}_type
   value={WHAT}
[/set_variable]
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

hmm in other macro it dont work, maybe i make something bad it that macro, if it work sorry
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Re: another bug

Post by Rhuvaen »

Hieronymus wrote:
Rhuvaen wrote:Does this construct actually work for you (that curly brackets!):

Code: Select all

$village{VILLAGENR}SpawnType
:?: Can you actually improvise a variable name like that? That would be a simple workaround to arrays.
I am still not sure if it works though, Tomsik says it doesn't work but he still uses the same in his newest version of his "The War" scenario and that seems to be working fine:

Code: Select all

[set_variable]
   name=kills{SIDE}_type
   value={WHAT}
[/set_variable]
I'm investigating this and it doesn't work, generally. I think it does work when the variable is on the right side of an assignment, when the argument is evaluated. That would mean:
Good Code:

Code: Select all

name=kills{SIDE}_type
Bad Code:

Code: Select all

kills{SIDE}_type={WHAT}
I'm about to test this though, so don't take it as 'etched in a rune tablet' :wink: .
tomsik wrote:maybe i make something bad it that macro, if it work sorry
Huh? You apologise if a WML feature is working :roll: ? Well, it's not your "fault" :lol: ...
Post Reply