MP Scenario with placed monsters

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
BrandonD
Posts: 19
Joined: July 28th, 2009, 7:32 pm

MP Scenario with placed monsters

Post by BrandonD »

Hi guys, I'm running Wesnoth 1.8.6 on Mac OS Snow Leopard. I'm working on simple MP scenarios just so I can learn more about how the programming side of Wesnoth works.

With this project I created a map with the map editor - next I wanted to create a cfg file which would basically place 6 specific monsters at specific points on the map. I created a 7th player with no leader, and used that player to place those 6 monsters (which are currently all Arch Mages). Unfortunately when I play the game these 6 monsters do not appear.

Here is what I have at this point:
#textdomain wesnoth-multiplayer

[multiplayer]
id=Brandon3
name= _ "Brandon3"
description= _ "A large map divided into quadrants, and swarming with creatures."
map_data="{~Wesnoth_1.8/editor/maps/Brandon3}"

{DEFAULT_SCHEDULE}
{DEFAULT_MUSIC_PLAYLIST}

[side]
[ai]
villages_per_scout=12
[/ai]
side=1
canrecruit=yes
fog=yes
[/side]
[side]
[ai]
villages_per_scout=12
[/ai]
side=2
canrecruit=yes
fog=yes
[/side]
[side]
[ai]
villages_per_scout=12
[/ai]
side=3
canrecruit=yes
fog=yes
[/side]
[side]
[ai]
villages_per_scout=12
[/ai]
side=4
canrecruit=yes
fog=yes
[/side]
[side]
[ai]
villages_per_scout=12
[/ai]
side=5
canrecruit=yes
fog=yes
[/side]

[side]
[ai]
villages_per_scout=12
[/ai]
side=6
canrecruit=yes
fog=yes
[/side]
[side]
[ai]
villages_per_scout=12
[/ai]
side=7
no_leader=yes
allow_player=no
fog=yes
[/side]

[event]
name=prestart
[if]
[have_unit]
side=7
[/have_unit]
[then]
[kill]
animate=no
fire_event=no
side=7
[/kill]
{UNIT 53 15 (Arch Mage)}
{UNIT 53 25 (Arch Mage)}
{UNIT 3 15 (Arch Mage)}
{UNIT 3 25 (Arch Mage)}
{UNIT 28 3 (Arch Mage)}
{UNIT 27 37 (Arch Mage)}

[set_recruit]
side=7
type=""
[/set_recruit]
[/then]
[/if]
[/event]
[/multiplayer]
Further info: The MP map is located in Library/Application Support/Wesnoth_1.8/editor/maps and the cfg file is located in Library/Application Support/Wesnoth_1.8/data/add-ons

If I am leaving out any crucial info please let me know, any help would be hugely appreciated! Thanks very much :)
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: MP Scenario with placed monsters

Post by zookeeper »

Ok, so...

Code: Select all

[event]
name=prestart
[if]
[have_unit]
side=7
[/have_unit]
[then]
[kill]
animate=no
fire_event=no
side=7
[/kill]
{UNIT 53 15 (Arch Mage)}
{UNIT 53 25 (Arch Mage)}
{UNIT 3 15 (Arch Mage)}
{UNIT 3 25 (Arch Mage)}
{UNIT 28 3 (Arch Mage)}
{UNIT 27 37 (Arch Mage)}

[set_recruit]
side=7
type=""
[/set_recruit]
[/then]
[/if]
[/event]
What that [if] does is that it checks if there's any side 7 units, and if there are, then it kills all of them and places some Arch Mages. When the scenario starts, there are no side 7 units so it never does anything.

Also, does the UNIT macro take just 3 arguments? No, it takes 5, so that already should give you error messages on startup which you didn't mention.
BrandonD
Posts: 19
Joined: July 28th, 2009, 7:32 pm

Re: MP Scenario with placed monsters

Post by BrandonD »

Hi, thank you for the quick reply!

For this cfg file, all I did was copy another cfg file that generated specific monsters, copied and altered it. So for the most part I don't understand alot of the code.

When I play the map it doesn't give me any error messages at all, it just plays the game as normal but without any additional characters.

Thanks for the comments related to the "if/kill" commands.

If you don't mind, can you please direct me to where I can learn more about the UNIT macro and its 5 arguments? Or you can also tell them to me if it's not too much of a pain.

Thanks again for your help.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: MP Scenario with placed monsters

Post by zookeeper »

BrandonD wrote:Hi, thank you for the quick reply!

For this cfg file, all I did was copy another cfg file that generated specific monsters, copied and altered it. So for the most part I don't understand alot of the code.

When I play the map it doesn't give me any error messages at all, it just plays the game as normal but without any additional characters.
In that case I'm pretty sure that your whole scenario file is never seen by the game; what you have in your map list is probably just the plain map.

What you probably want is to create your own one-scenario add-on, instead of putting the files in the editor directories. You can download a map-pack add-on and copy its file structure, or make something even simpler.
BrandonD wrote:Thanks for the comments related to the "if/kill" commands.

If you don't mind, can you please direct me to where I can learn more about the UNIT macro and its 5 arguments? Or you can also tell them to me if it's not too much of a pain.
All the core built-in macros are in data/core/macros/, and unit-spawning macros in unit-utils.cfg.
BrandonD
Posts: 19
Joined: July 28th, 2009, 7:32 pm

Re: MP Scenario with placed monsters

Post by BrandonD »

Thank you again for your quick reply. Here is where I'm at: I've created a folder within add-ons called "BrandonsMaps". Within this folder is a _main.cfg file which I copied from another add-on and changed the names where appropriate. It appeared that nearly every add-on had
"maps" and "scenarios" folders, so I created these folders as well. Within the maps folder is my map file "BrandonsMaps.map" and within the scenarios folder is my "BrandonsMaps.cfg" file.

When I try to run Wesnoth in multiplayer mode this error comes up:
The following add-on had errors and could not be loaded: (...)/Wesnoth_1.8/data/add-ons/BrandonsMaps/_main.cfg ERROR DETAILS:Found invalid closing tag time for tag multiplayer (opened at ~add-ons/BrandonsMaps/scenarios/BrandonsMaps.cfg:1 included from ~add-ons/BrandonsMaps/_main.cfg:3), value ']' at core/macros/schedules.cfg:11 included from core/_main.cfg:6 included from _main.cfg:5 included from core/macros/schedules.cfg:99 included from core/_main.cfg:6 included from _main.cfg:5 included from ~add-ons/BrandonsMaps/scenarios/BrandonsMaps.cfg:1 included from ~add-ons/BrandonsMaps/_main.cfg:3
I was not able to copy and paste this message and had to type it by hand, I believe I got it all correct.

Here is my BrandonsMaps.cfg file as it currently is (which I have attempted to simplify and streamline):

Code: Select all

[multiplayer]
    id=BrandonsMaps
    name= _ "BrandonsMaps"
    description= _ "A large map divided into quadrants, and swarming with creatures."
    map_data="{~add-ons/BrandonsMaps/maps/BrandonsMaps.map}"

    {DEFAULT_SCHEDULE}
    {DEFAULT_MUSIC_PLAYLIST}

    [side]
        side=1
        canrecruit=yes
        fog=yes
    [/side]
    [side]
        side=2
        canrecruit=yes
        fog=yes
    [/side]
    [side]
        side=3
        canrecruit=yes
        fog=yes
    [/side]
    [side]
        side=4
        canrecruit=yes
        fog=yes
    [/side]
    [side]
        side=5
        canrecruit=yes
        fog=yes
    [/side]
    [side]
        side=6
        canrecruit=yes
        fog=yes
    [/side]
    [side]
        side=7
        no_leader=yes
        allow_player=no
        fog=yes
	hidden=yes
        [unit]
        	side=7
        	type=Arch Mage
        	x=10
        	y=10
        	generate_name=yes
        	random_traits=yes
        	random_gender=yes
        	upkeep=full
        [/unit]
    [/side]
[/multiplayer]
Please let me know what is causing the problem. Thank you again for all your help!
BrandonD
Posts: 19
Joined: July 28th, 2009, 7:32 pm

Re: MP Scenario with placed monsters

Post by BrandonD »

....By the way, as you may have noticed in the cfg file, there are no longer 6 units placed on the board but only 1. As soon as I learn how to place this one unit correctly then I will move on from there.
BrandonD
Posts: 19
Joined: July 28th, 2009, 7:32 pm

Re: MP Scenario with placed monsters

Post by BrandonD »

This is the text from my _main.cfg:

Code: Select all

#ifdef MULTIPLAYER
  {~add-ons/BrandonsMaps/maps}
  {~add-ons/BrandonsMaps/scenarios}
#endif
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2361
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: MP Scenario with placed monsters

Post by Lord-Knightmare »

The _main.cfg looks fine to me, If you want to place units on your map then here's the code for you...

Code: Select all

[event]
    name=prestart
    {GENERIC_UNIT 7 "Arch Mage" 53 15}
[/event]
This places an Arch Mage belonging to side 7 on the co-ordinates 53,15.
Also the side tag for 7 should look more simple like this:

Code: Select all

[side]
    side=7
    no_leader=yes
    controller=ai
    allow_player=no
    team_name="Monsters"
    gold=100
[/side]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
BrandonD
Posts: 19
Joined: July 28th, 2009, 7:32 pm

Re: MP Scenario with placed monsters

Post by BrandonD »

Lord-Knightmare wrote:The _main.cfg looks fine to me, If you want to place units on your map then here's the code for you...
Yes! Thank you, it works now! I discovered the other problem, which was that I was not saving the files as plain text.

One last question, where would I find a list of the character's and monster's "official names" so if I wanted to place one on the board I could make sure to use the correct name? Thank you!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: MP Scenario with placed monsters

Post by zookeeper »

BrandonD wrote:One last question, where would I find a list of the character's and monster's "official names" so if I wanted to place one on the board I could make sure to use the correct name? Thank you!
Look for the [unit_type] id= values in data/core/units/.

Also, {~add-ons/BrandonsMaps/maps} doesn't do anything so you can remove that.
BrandonD
Posts: 19
Joined: July 28th, 2009, 7:32 pm

Re: MP Scenario with placed monsters

Post by BrandonD »

Thanks both of you for your help, I'm very excited to start making more elaborate scenarios :)
Post Reply