Creating a -loyal- unit with an event? (solved)

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Creating a -loyal- unit with an event? (solved)

Post by kurt751 »

Not sure if this is the right forum, feel free to move as required.


I want an event to create a new unit having the loyal trait.
Well, pretty easy I thought, I'll just "borrow" some code from the official campaigns. Unfortunately it doesn't work as expected, or even at all...

Here is what I'm trying to use (all this is enclosed in my "event" tag which works fine, tested with a message):

Code: Select all

 	[unit]
		 type="Fire Dragon"
		 id="Createdunit"
		 name="Whatever"
		 unrenamable=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
		 x=16
		 y=18
 	[/unit]
Problem is, the "modifications" part crashes BoW right after going into the Multiplayer/Local Game menu. I don't even need to start a new game.
So I tried to replace it by a simple {IS_LOYAL} line, which AFAIK should do the same, but that too crashes BoW. If I don't put either in, BoW seems happy. But I'd really like that unit to have free upkeep...

How comes? It's code I copy/pasted from a campaign I've played, so why does it crash & burn BoW that way? I guess I missed some prerequisite (I'm pretty new to BoW, and by no stretch of imagination a programmer!), what could that be?
Thank you in advance.


(For the record, Battle for Wesnoth version 1.12.5, running on Linux Mint 17.3. Downloaded from Ubuntu Backports)
Last edited by kurt751 on June 14th, 2016, 4:43 pm, edited 1 time in total.

User avatar
zookeeper
WML Wizard
Posts: 9741
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Creating a -loyal- unit with an event?

Post by zookeeper »

I have a hard time believing that that [modifications] tag crashes the game. If you're certain that it's the cause, the we need to see the actual files because surely you have to have something else really wrong in them.

User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: Creating a -loyal- unit with an event?

Post by SkyOne »

Like zookeeper said, there is nothing incorrect on the code you post (as far as the unit is side=1).
{IS_LOYAL} doesn't do anything for trait-modifications. It just puts the loyal icon on the unit.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server

kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Creating a -loyal- unit with an event?

Post by kurt751 »

zookeeper wrote:I have a hard time believing that that [modifications] tag crashes the game.
Me too. :mrgreen:

Maybe it's the way I use it?
Can one put a unit creation inside an event triggered at some random point in the game like I did? See full event code below.

zookeeper wrote:If you're certain that it's the cause, the we need to see the actual files because surely you have to have something else really wrong in them.
Well, I'm only certain that as long as the "modification" and the {IS_LOYAL} parts are in the file, it crashes the game. Removing them fixes that.

Here is the full event as I tried to use it:

Code: Select all

[event]
	name=moveto
		[filter]
			x,y=116,117
		[/filter]
 	[unit]
		type="Fire Dragon"
		id="DragonHelp"
		name="Ruhsss"
		unrenamable=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
		x=116
		y=118
            {IS_LOYAL}
        [/unit]
        [message]
            speaker="DragonHelp"
            message= _ "You've liberated me. I'll fight at your side for a while!"
        [/message]
[/event]

User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: Creating a -loyal- unit with an event?

Post by SkyOne »

Hmmm... Still fine though...
zookeeper wrote:we need to see the actual files
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server

User avatar
zookeeper
WML Wizard
Posts: 9741
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Creating a -loyal- unit with an event?

Post by zookeeper »

Yeah, I tested that full event (coordinates and all) and it worked just fine.

kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Creating a -loyal- unit with an event?

Post by kurt751 »

All right, I made you a small, portable version of the problem. (The original file is a monster: 8 sides, dozens of units, a huge map, and so on.)
This is a simplified, self-contained scenario (map inside), into which I added the offending event (which continues to offend).
DragonCrash.cfg
Event crashing game
(3.61 KiB) Downloaded 93 times

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

Re: Creating a -loyal- unit with an event?

Post by Ravana »

Since you didnt include [multiplayer] wrapper, I added my own. Did not crash, created loyal unit.

kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Creating a -loyal- unit with an event?

Post by kurt751 »

Ravana wrote:Since you didnt include [multiplayer] wrapper, I added my own. Did not crash, created loyal unit.
:shock: Could you explain this please?
What is a multiplayer wrapper, why would I need one for a single player scenario, and where/how do I put one in my scenario if it's compulsory?

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

Re: Creating a -loyal- unit with an event?

Post by Ravana »

You mentioned using multiplayer menu, so I read that as it should work as mp scenario.

Doesnt have to be multiplayer, but needs something.
https://wiki.wesnoth.org/ScenarioWML

User avatar
beetlenaut
Developer
Posts: 2401
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Creating a -loyal- unit with an event?

Post by beetlenaut »

The first line in your file needs to be [multiplayer] and the last line needs to be [/multiplayer].

The top-level tags define what your level is for and what menu it starts from. If you use [scenario] tags instead of [multiplayer] for example, your level will be in the campaign menu, but it takes some more work; you have to have a _main.cfg file that points to the scenario. A bare map with no top-level tags can also be loaded from the multiplayer screen, but it can't have any complex code. (I thought. Apparently some events are allowed before it crashes.)

(I think I'm right about all this, but I may be out-of-date on multiplayer stuff.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Creating a -loyal- unit with an event?

Post by kurt751 »

Ravana wrote:You mentioned using multiplayer menu, so I read that as it should work as mp scenario.
Oh I see!... :D
Big misunderstanding: I meant the way to launch it. Undefined scenarios (= lacking a [multiplayer], [test], [tutorial] or [scenario] tag) are accessed in the game through the "Multiplayer" menu, "Local Game" choice. I do prefer this while I work on it, even it later on I'll wrap it in [scenario] tags, because once you've wrapped it in [scenario] tags, you have to create a full-fledged campaign with its _main.cfg and all that. Too much hassle while I'm still working on it and making successive versions, so I don't put any tag in to keep it a single file.

Do you mean this could be the reason all macros just crash the game?... :shock:
Interesting! I'll check this.

kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Creating a -loyal- unit with an event?

Post by kurt751 »

beetlenaut wrote:The top-level tags define what your level is for and what menu it starts from. If you use [scenario] tags instead of [multiplayer] for example, your level will be in the campaign menu, but it takes some more work; you have to have a _main.cfg file that points to the scenario.
Yes, as I said just above, that additional work is the reason I keep the WIP undefined. I always save incremental versions of the map, so it's so much easier to only have one single file to look after, with no external links.

beetlenaut wrote:A bare map with no top-level tags can also be loaded from the multiplayer screen, but it can't have any complex code. (I thought. Apparently some events are allowed before it crashes.)
OMG! So that is why I've been ripping out my hair by the handful since almost a week! :shock:
Yes, everything works, except macros. Any time I try to use the simplest macro (like {FLAG_VARIANT ragged} for instance), the game crashes away!...
Please, pretty please, could you (Westnoth dev team) make the game give an error stating you need the top level tags for macros to work, instead of just crashing?

beetlenaut wrote:(I think I'm right about all this, but I may be out-of-date on multiplayer stuff.)
No, that's a misunderstanding, it's not a multiplayer map. It's a simple (albeit huge) single player scenario.

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

Re: Creating a -loyal- unit with an event?

Post by Ravana »

I always save incremental versions of the map, so it's so much easier to only have one single file to look after, with no external links.
I hope you dont do it manually.
Big misunderstanding: I meant the way to launch it. Undefined scenarios (= lacking a [multiplayer], [test], [tutorial] or [scenario] tag) are accessed in the game through the "Multiplayer" menu, "Local Game" choice. I do prefer this while I work on it, even it later on I'll wrap it in [scenario] tags, because once you've wrapped it in [scenario] tags, you have to create a full-fledged campaign with its _main.cfg and all that. Too much hassle while I'm still working on it and making successive versions, so I don't put any tag in to keep it a single file.
I just put the scenario content you gave into _main.cfg of newly created addon folder.

gfgtdf
Developer
Posts: 1255
Joined: February 10th, 2013, 2:25 pm

Re: Creating a -loyal- unit with an event?

Post by gfgtdf »

It seems like you maybe used the experiemental 'create scenario' option in the map editor. This feature is quite incomplete (and will most likele stay incomplete for a while since there is noone currently working on it) so that it for example doesn't support things liek macros in it or similar.

It is strongly reccoemned not to use it and instead crete an addon by modyfing an existent addon. There is afaik also a dummy addon on the addon server for exactly this purpose.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

Post Reply