Random terrain in MP

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Ravana
Forum Moderator
Posts: 3009
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Random terrain in MP

Post by Ravana »

Is it possible to use random terrain change in multiplayer that does not require all players have downloaded that map?
Best would be 8 options with equal chance.
User avatar
alexanderthegre
Posts: 193
Joined: December 8th, 2011, 3:23 am
Location: nowhere

Re: Random terrain in MP

Post by alexanderthegre »

I haven't tested any of this, but it might be of use.

Code: Select all


#Change a specified area to a terrain type

[set_variable]
 name=random_dummy
 rand=1..8
[/set_variable]
[switch]
 variable=$random_dummy
 [case]
  value=1
  [terrain]
   [filter]
    #Filter
   [/filter]
   terrain=#Code to change it to
  [/terrain]
 [/case]
#Add more [case]s as necessary.
[/switch]

Code: Select all


#Change the whole map to a new one

[set_variable]
 name=random_dummy
 rand=1..8
[/set_variable]
[switch]
 variable=$random_dummy
 [case]
  value=1
  [replace_map]
   map=#path to your new map
   expand=yes
   shrink=yes
  [/replace_map]
 [/case]
#etc.
[/switch]

User avatar
Ravana
Forum Moderator
Posts: 3009
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Random terrain in MP

Post by Ravana »

Code: Select all

[event]
    name=side 6 turn end
    first_time_only=no
   
   [set_variable]
 name=random_dummy
 rand=1..8
[/set_variable]
[switch]
 variable=$random_dummy
 [case]
  value=1
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Mm
  [/terrain]
 [/case]
  [case]
  value=2
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Uu
  [/terrain]
 [/case] [case]
  value=3
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Wwt
  [/terrain]
 [/case] [case]
  value=4
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Hh
  [/terrain]
 [/case] [case]
  value=5
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Kud
  [/terrain]
 [/case] [case]
  value=6
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Dd
  [/terrain]
 [/case] [case]
  value=7
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Gs^Fds
  [/terrain]
 [/case] [case]
  value=8
  [terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Aa
  [/terrain]
 [/case]

[/switch]
[/event]
Used that, no error and no change.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Random terrain in MP

Post by Anonymissimus »

Your problem isn't about randomness, it's about usage of custom terrain. You *cannot* use any custom terrain or units in a multiplayer addon if you do not want to require users to have downloaded the addon to save themselves from getting kicked due to unknown terrain/unit type.

EDIT
Above replies to your original post. For the rest see Ceres.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Random terrain in MP

Post by Ceres »

Code: Select all

variable=$random_dummy
You have to remove the "$" there, because you want the variable name, not the variable's value.

Code: Select all

[terrain]
   [filter]
    x,y=8,5
   [/filter]
   terrain=Mm
  [/terrain]
Don't use a [filter], just put the x,y directly in the [terrain].

Code: Select all

[/case] [case]
Better put these on different lines.
User avatar
Ravana
Forum Moderator
Posts: 3009
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Random terrain in MP

Post by Ravana »

That is not custom terrain, that is random terrain from list of terrains in core files.

Thanks, now it works
Post Reply