Help with WML for a particular scenario

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
JaMiT
Inactive Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Help with WML for a particular scenario

Post by JaMiT »

chak_abhi wrote:But I face a problem if I load the scenario for the very first time. The side leaders for sides 2 & 3 do not show up at all. I am clueless about working a solution.
Have you confirmed that those leaders do show up if you remove that [if] tag?
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

Yes, the situation normalises on removing the [if] tag.
Last edited by chak_abhi on February 17th, 2013, 5:09 pm, edited 2 times in total.
User avatar
Adamant14
Posts: 968
Joined: April 24th, 2010, 1:14 pm

Re: Help with WML for a particular scenario

Post by Adamant14 »

Can you post the whole code?
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

Sorry, I had committed a bad mistake, I had used the variable no_side2 & no_side3 in a previous scenario but forgot to clear them. When I corrected it everything became normal. Anyway thanks for the help. :)
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

I need help yet again.
Imagine a situation where the leader of an ai controlled side is moving from one location to another (they have been set previously) with a group of escorts (programmed such that they move with the leader and guard it). I want the leader to move along a road (Rr) which has no branching, and not to step on hexes other than the road. However the escorts are free to step on the other hexes. Can it be done? What will be the appropriate code?
Thanks in advance.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with WML for a particular scenario

Post by mattsc »

chak_abhi wrote:Imagine a situation where the leader of an ai controlled side is moving from one location to another (they have been set previously) with a group of escorts (programmed such that they move with the leader and guard it). I want the leader to move along a road (Rr) which has no branching, and not to step on hexes other than the road. However the escorts are free to step on the other hexes. Can it be done?
Yes, absolutely. There are a number of different ways of accomplishing this, but here's what I would do: Take the Messenger Escort Micro AI for the general behavior, and change the movement of the leader so that he can only move on road terrain.

Now, the "problem" with this is that Micro AIs only become available in Wesnoth 1.11.2. However, the code is also contained in the AI-Demos add-on, so you could lift it from there until 1.11.2 comes out (there's also a demo scenario that you can test first). And if you're using 1.10, I think this particular AI should also work there (not all of the MAIs do). If you have problems with that, let me know, but in either case, take the 1.11 version as your template, the code in the 1.10 add-on is way out of date. In fact, I should probably remove that add-on.

EDIT: Actually, I just had a quick look at the code and the Messenger Escort AI will not work in 1.10 as it is. However, the change is simple (the weapon number needs to be decreased by 1 in the ai.attack() function - but not in the rest of the code). Again, if you need this for 1.10, I'd be happy to help you with the needed changes.
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

This is appearing too complex! :? Isn't there any simpler alternative?
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: Help with WML for a particular scenario

Post by pyrophorus »

It seems to me it's very close to the 'carriage moving along a road' feature we discussed earlier.
I would:
1- disable the canrecruit key of the leader (and set the leader overlay icon), to avoid AI trying to mess into.
2- make it travel to its new keep with the escort.
3- restore its canrecruit ability.
4- setup a die event for this leader if needed.

Friendly,
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

pyrophorus wrote:It seems to me it's very close to the 'carriage moving along a road' feature we discussed earlier.
Yeah, it is, but the road is more than a hex wide at some points.
I would:
1- disable the canrecruit key of the leader (and set the leader overlay icon), to avoid AI trying to mess into.
2- make it travel to its new keep with the escort.
There is no definite keep here. So this problem can be avoided.
4- setup a die event for this leader if needed.

Friendly,
This will be done. Thanks for now, but I feel some more modifications are needed to make it work properly.
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

I am stuck once again with a problem.
There is a situation where a particular unit of the player's side must drop a bomb on any one of a group of pre-designated hexes. To place the bomb I use the following code in the prestart event.

Code: Select all

#define MENU_DROP_BOMB
    [set_menu_item]
    id=drop_bomb_option
    description= _ "Drop bomb here"
    [show_if]
    [have_unit]
    [/have_unit]
    [/show_if]
    [filter_location]
    [filter_adjacent_location]
    [filter]
    id=Hirdukmob
    [/filter]
    [/filter_adjacent_location]
    terrain=Rrc
    [/filter_location]
    
    [command]
    [set_menu_item]
    id=drop_bomb_option
    [show_if]
    [not]
    [/not]
    [/show_if]
    [/set_menu_item]

    [item]
    image=items/bomb.png
    x,y=$x1,$y1
    [/item]

    [store_locations]
    [filter]
    x,y=$x1,$y1
    [/filter]
    variable=bomb_location
    [/store_locations]

    [message]
    speaker=Flarklup
    message= _ "We must now get away from here quickly, otherwise we also will be blasted off!"
    [/message]
    [message]
    speaker=Hirdukmob
    message= _ "Yes, lets get away from this place!"
    [/message]

    {VARIABLE bomb_placed 1}
    {VARIABLE right_time 0}

    [/command]
    [/set_menu_item]
#enddef
The bomb must burst 2 turns after it has been placed, and kill any unit within 2 hexes, and also harm units within 3 or 4 hexes. For this I use the following code:

Code: Select all

[event]
    name=new turn
    first_time_only=no
    [if]
    [variable]
    name=bomb_placed
    equals=1
    [/variable]

    [then]
    [set_variable]
    name=right_time
    add=1
    [/set_variable]
    [/then]
    [/if]

    [if]
    [variable]
    name=right_time
    equals=2
    [/variable]
 
    [then]
    [scroll_to]
    x=$bomb_location.x
    y=$bomb_location.y
    [/scroll_to]
    
    [remove_item]
    x=$bomb_location.x
    y=$bomb_location.y
    [/remove_item]

    [sound]
    name=explosion.ogg
    [/sound]

    [item]
    x,y=$bomb_location.x,$bomb_location.y	
	halo=projectiles/fire-burst-small-1.png:50,projectiles/fire-burst-small-2.png:50,projectiles/fire-burst-small-3.png:50,projectiles/fire-burst-small-4.png:50,projectiles/fire-burst-small-5.png:50,projectiles/fire-burst-small-6.png:50,projectiles/fire-burst-small-7.png:50,projectiles/fire-burst-small-8.png:50,misc/blank-hex.png:1000000
    [/item]
    [delay]
    time=800
    [/delay]
    [remove_item]
    x=$bomb_location.x
    y=$bomb_location.y
    [/remove_item]

    [terrain]
    x=$bomb_location.x
    y=$bomb_location.y
    terrain="Dd^Dc" # this is a sandhole at the center of the explosion
		       [/terrain]

    [kill]
    [filter_location]
    x=$bomb_location.x
    y=$bomb_location.y  # kills anyone two hexes around
    radius=2
    [/filter_location]
    animate=yes
    fire_event=yes
    [/kill]

    [terrain]
    x=$bomb_location.x
    y=$bomb_location.y
    radius=2
    terrain="Dd"
    [/terrain]
    
    [redraw]
    [/redraw]

    [harm_unit]
    [filter]
    [filter_location]
    x=$bomb_location.x
    y=$bomb_location.y
    radius=3
    [/filter_location]
    [/filter]
    amount=20
    animate=yes
    [/harm_unit]
    [harm_unit]
    [filter]
    [filter_location]
    x=$bomb_location.x
    y=$bomb_location.y
    radius=4
    [/filter_location]
    [/filter]
    amount=10
    animate=yes
    [/harm_unit]

    [if]
    [have_unit]
    id=Dorsfkign
    [/have_unit]

    [then]
    [message]
    speaker=Hirdukmob
    message= _ "The bomb has blasted and yet Dorfskign is alive! We hadn't placed it properly!"
    [/message]
    [message]
    speaker=Flarklup
    message= _ "What have we done!"
    [/message]

    {DEFEAT}
    [/then]

    [/if]
 
    {CLEAR_VARIABLE bomb_location}
    [/then]
    [/if]
    [/event]
But this code doesn't work. The blast animation never takes place and in the end every unit on the map gets killed. I cannot locate the source of the error. Can anyone please help? Thanks in advance.
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: Help with WML for a particular scenario

Post by pyrophorus »

Hi,
Obviously, you 'bomb_location' variable is empty. This is why animation don't start and the code kills everyone. IMO this code is wrong:

Code: Select all

        
        [store_locations]
        [filter]
        x,y=$x1,$y1
        [/filter]
        variable=bomb_location
        [/store_locations]
And should be:

Code: Select all

    [store_locations]
        x,y=$x1,$y1
        variable=bomb_location
    [/store_locations]
Friendly,
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

I need help for a strange problem that creeps up again and again at the same time.
In a scenario of a campaign written by me an error comes at a particular time of gameplay. It says something like: Microsoft visual library error, wml trigger, to know more go to Microsoft visual library C++, to debug press retry--JIT must be enabled. (I do not remember the exact words but the main points are these)
The code for the part where the error comes is:

Code: Select all

[event]
    name=last breath
    [filter]
    id=Ajtimon
    [/filter]

    
    [message]
    speaker=Ajtimon
    message= _ "I may have fallen, but I die a free man! More will come after me, and how 

many of them can you kill? Mother Doreldos will be free very soon!"
    [/message]

    [kill]
    x,y=$x1,$y1
    [/kill]

    [message]
    speaker=narrator
    image=wesnoth-icon.png
    message= _ "As soon as Ajtimon had fallen some help arrived unexpectedly taking the 

Gloenish by surprise."
    [/message]
*******************
    [recall]
    id=Milux
    x,y=33,2
    [/recall]

    [recall]
    id=Homorro
    x,y=34,1
    [/recall]
 
    [recall]
    id=Ajisx
    x,y=33,1
    [/recall]

    [recall]
    id=Ronglus
    x,y=34,3
    [/recall]

    [recall]
    id=Kavaras
    x,y=34,2
    [/recall]

    [recall]
    id=Kiltab
    x,y=33,3
    [/recall]

    [recall]
    id=Bojensur
    x,y=32,2
    [/recall]
[/event]
(The *** denotes the portion where the error is triggered)
If this same portion is implemented in any other place (e.g say in an event named turn 2) this error does not appear and the recall takes place normally.
What is the cause of this error? What is the remedy? Can anyone please help? Thanks in advance.
N.B. I use BfW 1.11.1.
Last edited by chak_abhi on March 20th, 2013, 5:19 pm, edited 1 time in total.
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Help with WML for a particular scenario

Post by Max »

it would help if you could tell us the file and line part of the error message.
chak_abhi
Posts: 347
Joined: June 24th, 2010, 3:37 pm

Re: Help with WML for a particular scenario

Post by chak_abhi »

I have uploaded the information contained in the window. Unlike standard wesnoth errors this one appears in the middle of gameplay (not during loading a campaign or scenario). The last line contains the options given by the window (abort, retry & ignore). While pressing abort or ignore the program just closes, pressing retry causes the same thing but gives an error: wesnoth.exe has encountered a problem and needs to close.
Attachments
error.txt
(402 Bytes) Downloaded 211 times
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Help with WML for a particular scenario

Post by Max »

related bug report: http://gna.org/bugs/?16148. the test case supplied by jamit isn't an exact match though.
Post Reply