Help with WML for a particular scenario

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.
Post Reply
User avatar
Adamant14
Posts: 905
Joined: April 24th, 2010, 1:14 pm

Re: Help with WML for a particular scenario

Post by Adamant14 »

I tested the code, and it works fine.

Please check the id of your leader.
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

Adamant14 wrote:I tested the code, and it works fine.

Please check the id of your leader.
Yeah, I was wrong with the code. It is working fine now. Thanks! :)

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

Can anyone please address a small query?
If I want to keep a certain ai controlled side idle I can use the following code:

Code: Select all

[ai]
            ai_algorithm=idle_ai
        [/ai]
But if I want to activate the side at a certain time what will be the code needed?
Thanks in advance.

User avatar
Adamant14
Posts: 905
Joined: April 24th, 2010, 1:14 pm

Re: Help with WML for a particular scenario

Post by Adamant14 »

Maybe you can do it this way:

Code: Select all

	# you can use this event to make the side do nothing ...

	[event]
		name= # add the event-name you want here
		[modify_side]
			side= # add the side you want here
			controller=null
		[/modify_side]
	[/event]

	# ... and this event to activate the side again

	[event]
		name= # add the event-name you want here
		[modify_side]
			side= # add the side you want here
			controller=ai
		[/modify_side]
	[/event]
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

Thanks a lot! :)

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

I need help with a matter.
I want to give an ability named invisibility to certain units in two consequetive scenarios. I have created the ability using the following code:

Code: Select all

#define ABILITY_INVISIBLE
    # Canned definition of the Invisibility ability to be included in an
    # [abilities] clause.
    [hides]
        id=invisible
        name= _ "invisible"
        female_name= _ "invisible"
        description= _ "invisible:
Enemy units cannot see this unit, except in case they stand immediately beside it. Defense 

is at 80 percent for every terrain except water, where it is 70 percent."
        description_inactive= _ "invisible:
Enemy units cannot see this unit, except in case they stand immediately beside it. Defense 

is at 80 percent for every terrain except water, where it is 70 percent."
        name_inactive= _ "invisible"
        female_name_inactive= _ "female^invisible"
        
        affect_self=yes
        
    [/hides]
    [effect]
    apply_to=defense
    replace=true
        [defense]
        deep_water=30
        shallow_water=30
        reef=30
        swamp_water=30
        flat=20
        sand=20
        forest=20
        hills=20
        mountains=20
        village=20
        castle=20
        cave=20
        frozen=20
        unwalkable=20
        impassable=20
        fungus=20
        [/defense]
    [/effect]
#enddef
If I want to give the ability to a certain unit can I use the following code:

Code: Select all

[modify_unit]
id=$unit.id
{ABILITY_INVISIBILITY}
[/modify_unit]
Are the above codes appropriate?
Now what is the code that I have to use in order to remove the ability?
Thanks in advance.

JaMiT
Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Help with WML for a particular scenario

Post by JaMiT »

chak_abhi wrote:Are the above codes appropriate?
Well, according to your own comment:
chak_abhi wrote: # Canned definition of the Invisibility ability to be included in an
# [abilities] clause.
Yet you did not use it in an [abilities] clause, so I am guessing it will not work.

Then again, it probably would not work even in an [abilities] clause because you would then be defining your [effect] inside [abilities], which does not work.

What it seems like you want is an [object] with two [effect]s -- the first with apply_to=new_ability to give the unit the "invisible" ability (minus the [effect] you had in that), and the second with apply_to=defense. A duration of "level" will make it last until the end of the current scenario. To get it to appear to continue in the next scenario, track the units in a variable and re-apply the object when the next scenario starts.


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

Re: Help with WML for a particular scenario

Post by chak_abhi »

I am facing another problem.
In a scenario I want a certain unit to have the ability of crushing petrified units which are located in adjacent hexes. The player has to use an option from the menu to utilise this. I use the following code.

Code: Select all

#define MENU_CRUSH_PETRIFIED_UNIT
    [set_menu_item]
    id=crush_petrified_unit_option
    description= _ "Crush petrified unit"
    [show_if]
    [have_unit]
    [filter_wml]
    [status]
    petrified=yes
    [/status]
    x,y=$x1,$y1
    [/filter_wml]
    [/have_unit]
    [/show_if]
    [filter_location]
    [filter_adjacent_location]
    [filter]
    type=Dwarvish Witness, Dwarvish Annalist, Dwarvish Loremaster
    [/filter]
    [/filter_adjacent_location]
    [/filter_location]
    [command]
    [kill]
    x,y=$x1,$y1
    animate=yes
    fire_event=yes
    [/kill]
    [/command]
    [/set_menu_item]
#enddef
I place the code in the concerned scenario.

Code: Select all

[event]
name=prestart
{MENU_CRUSH_PETRIFIED_UNIT}
[/event]
But the option doesn't show up on the menu while playing. What is the error responsible for this?
Thanks in advance.

User avatar
pyrophorus
Posts: 513
Joined: December 1st, 2010, 12:54 pm

Re: Help with WML for a particular scenario

Post by pyrophorus »

There are several errors, try to replace your conditions by:

Code: Select all

[show_if]   
		[have_unit]
			x,y=$x1,$y1
			[filter_wml]
				[status]
					petrified=yes
				[/status]
			[/filter_wml]
		 	[filter_adjacent]
				type=Dwarvish Witness, Dwarvish Annalist, Dwarvish Loremaster
			[/filter_adjacent]
		 [/have_unit]
[/show_if]
and delete the whole 'filter_locations' which is useless. It should work better.
Friendly,
Campaign Return to Noelren *** HowTos: WML filtering, WML variables
Please help to to update the Guide to UMC Campaigns

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

Thanks once again, pyrophorus! :)

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

There is another point where I notice a problem. If at the start of a scenario I set the controller for a particular side as "controller=null" then the side leader doesn't show up at all during game play. I want to use it because I need to change the controller to ai once a particular event occurs. Am I facing a bug? I use Bfw 1.11.0.

JaMiT
Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Help with WML for a particular scenario

Post by JaMiT »

chak_abhi wrote:If at the start of a scenario I set the controller for a particular side as "controller=null" then the side leader doesn't show up at all during game play.
Correct.
SideWML wrote:null: the side doesn't get a turn to move and doesn't have a leader generated from the contents of the [side] tag.
I believe one work-around is to initially define the controller as "ai", then change it to "null" in a start or prestart event.

Or you could take the more involved approach I've tried of defining an AI with no candidate actions for the side until such time as the side is supposed to act. (But I did that because I wanted to suppress some candidate actions anyway. Probably not such a good idea in general.)

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

Thanks, I will try these. :)

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

Re: Help with WML for a particular scenario

Post by chak_abhi »

I am facing a problem again for which I need help.
I have created a scenario from where the player can proceed to 3 different scenarios. After completing 2 of them he/she has to return to this scenario both times, which means that this scenario should be played thrice.
There are 8 enemy sides. I want to ensure that if the player manages to kill any of the leaders he/she would be relieved of facing that side when he/she faces the scenario for the next time. So I use the following code (it has been used separately for sides 2-9):

Code: Select all

[event]
    name=die
    [filter]
    side=2
    canrecruit=yes
    [/filter]

    {VARIABLE no_side2 1}
    [/event]
And in the prestart event I place the code (also used separately for sides 2-9):

Code: Select all

[if]
    [variable]
    name=no_side2
    numerical_equals=1
    [/variable]

    [then]
    [kill]
    side=2
    [/kill]
    [/then]
    [/if]

    
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.
Can anyone please help? Thanks in advance.

Post Reply