WML questions: invalid wml

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
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: event name=movefrom?

Post by battlestar »

Thanks!

Another question: Any idea for how to create a unit that is limited to moving in hex that are dark in illumination?
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
trewe
Translator
Posts: 122
Joined: December 24th, 2012, 5:37 pm
Location: Portugal
Contact:

Re: WML questions: event name=movefrom?

Post by trewe »

battlestar wrote:Thanks!

Another question: Any idea for how to create a unit that is limited to moving in hex that are dark in illumination?
Maybe by giving the unit a teleport like ability, together with movement costs equal to its max_moves on all passable terrains (to prevent the unit moving around forever)

Code: Select all

[teleport]
    id=afraid_of_light
    name= _ "shadow lurker"
    description= _ "This unit is limited to move to nocturnal locations."
    [tunnel]
        id=afraid_of_light
        [source]
            x,y=$teleport_unit.x,$teleport_unit.y
            [not]
                [filter]
                    [not]
                        id=$teleport_unit.id
                    [/not]
                [/filter]
            [/not]
        [/source]

        [target]
            time_of_day=chaotic,neutral
            [and]
                x,y=$teleport_unit.x,$teleport_unit.y
                radius=$teleport_unit.max_moves
            [/and]
            [not]
                [filter]
                [/filter]
            [/not]
        [/target]

        [filter]
            ability=afraid_of_light
        [/filter]
    [/tunnel]
[/teleport]
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: WML questions: afraid of the light?

Post by Dugi »

I doubt that will work properly. It will let the unit ignore all movement costs (can be partially fixed with [filter_radius] to prevent it from passing impassable terrains), pass through enemies ([filter_radius] should help here) and ignore ambushers (the player will see where they lurk).

What might work is an enter hex event that sets its moves to 0 if they step on a dark hex, it should be also much easier to code, but maybe setting a unit's moves to 0 does not interrupt movement. They'll still see through the darkness, though.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: WML questions: afraid of the light?

Post by Sapient »

If it is an AI controlled unit, then it would be far simpler to use [avoid]
http://wiki.wesnoth.org/AiWML#The_.5Bai ... ng_Aspects
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
trewe
Translator
Posts: 122
Joined: December 24th, 2012, 5:37 pm
Location: Portugal
Contact:

Re: WML questions: afraid of the light?

Post by trewe »

enhancing my original idea.

the ability:

Code: Select all

[teleport]
    id=afraid_of_light
    name= _ "shadow lurker"
    description= _ "This unit is limited to move to nocturnal locations."
    [tunnel]
        id=afraid_of_light

        [source]
            x,y=$teleport_unit.x,$teleport_unit.y
        [/source]

        [target]
            find_in=teleport_unit.variables.reachable_chaotic_locations
        [/target]

        [filter]
            ability=afraid_of_light
        [/filter]
    [/tunnel]
[/teleport]
and the events:

Code: Select all

[event]
    name=turn refresh
    first_time_only=no

    [store_unit]
        [filter]
            side=$side_number
            ability=afraid_of_light
        [/filter]
        variable=lurkers
    [/store_unit]

    {FOREACH lurkers i_temp}
        [store_reachable_locations]
            [filter]
                id=$lurkers[$i_temp].id
            [/filter]
            [filter_location]
                time_of_day=chaotic
            [/filter_location]
            variable=lurkers[$i_temp].variables.reachable_chaotic_locations
        [/store_reachable_locations]

        [set_variables]
            name=lurkers[$i_temp].variables.original_movement_costs
            to_variable=lurkers[$i_temp].movement_costs
        [/set_variables]

        [set_variables]
            name=lurkers[$i_temp].vision_costs
            to_variable=lurkers[$i_temp].movement_costs
        [/set_variables]

        [set_variables]
            name=lurkers[$i_temp].movement_costs
            [value]
                #deep_water=$lurkers[$i_temp].max_moves
                shallow_water=$lurkers[$i_temp].max_moves
                reef=$lurkers[$i_temp].max_moves
                swamp_water=$lurkers[$i_temp].max_moves
                flat=$lurkers[$i_temp].max_moves
                sand=$lurkers[$i_temp].max_moves
                forest=$lurkers[$i_temp].max_moves
                hills=$lurkers[$i_temp].max_moves
                mountains=$lurkers[$i_temp].max_moves
                village=$lurkers[$i_temp].max_moves
                castle=$lurkers[$i_temp].max_moves
                frozen=$lurkers[$i_temp].max_moves
                #unwalkable=$lurkers[$i_temp].max_moves
                #impassable=$lurkers[$i_temp].max_moves
                fungus=$lurkers[$i_temp].max_moves
                cave=$lurkers[$i_temp].max_moves
            [/value]
        [/set_variables]

        [unstore_unit]
            variable=lurkers[$i_temp]
        [/unstore_unit]
    {NEXT i_temp}

    {CLEAR_VARIABLE lurkers}
[/event]

[event]
    name=side turn end
    first_time_only=no

    [store_unit]
        [filter]
            side=$side_number
            ability=afraid_of_light
        [/filter]
        variable=lurkers
    [/store_unit]

    {FOREACH lurkers i_temp}
        [set_variables]
            name=lurkers[$i_temp].movement_costs
            to_variable=lurkers[$i_temp].variables.original_movement_costs
        [/set_variables]

        {CLEAR_VARIABLE lurkers[$i_temp].variables.reachable_chaotic_locations,lurkers[$i_temp].variables.original_movement_costs}

        [unstore_unit]
            variable=lurkers[$i_temp]
        [/unstore_unit]
    {NEXT i_temp}

    {CLEAR_VARIABLE lurkers}
[/event]
That solves any original flaws plus it is manageable by the AI (which an moveto/enter hex event would not)
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: afraid of the light?

Post by battlestar »

All very good ideas, I'll have to try them out. Originally I only thought of it as ai controlled units, but would be a cool thing to have as a general ability.

I'm currently having some problems which I think is a syntax issue... the error I get is Invalid WML found: [variable] not supported. I haven't been able to debug this section of code due to this doorstop. Thanks to anyone who could tell me what's causing that error.

Below is the entire section of code, I believe the error is referring to the [variable] in the second [event].

Code: Select all

# --- 4. A thing with tentacles attacks as you cross a thin passage through a subterranean lake. d 8-10 16,22-27,30
	[event]
		name=moveto
		first_time_only=yes
		[filter]
			side=1
			x,y=16-27,22-30
		[/filter]
		{SSC_CLEARGROUP_DEP_MODE}
		{SSC_DIAL-002-08}
# (tosses pebble into the water)
		{LSB_DIAL_W _"Glwn tosses pebble into the water"}
		{SSC_DIAL-002-09}
# (*a deep eye surfaces with camera focusing on the eye)
		{GENERIC_UNIT 5 "SCC_Deep_Eye" 20 26}
		{SSC_DIAL-002-10}
		[store_unit]
			[filter]
				type=SCC_Deep_Eye
			[/filter]
			variable=deep_eye
			kill=yes
		[/store_unit]
# ### animate submerge.
# tentacles 22,25 18,25 18,28 22,27
		{GENERIC_UNIT 5 "Tentacle of the Deep" 22 25}
		{GENERIC_UNIT 5 "Tentacle of the Deep" 18 25}
		{GENERIC_UNIT 5 "Tentacle of the Deep" 18 28}
		{GENERIC_UNIT 5 "Tentacle of the Deep" 22 27}
		
		{VARIABLE fight_tentacles 1}
	[/event]




	[event]
		name=die
		first_time_only=no
		[filter]
			side=5
			type=Tentacle of the Deep
		[/filter]
		[filter_condition]
			[have_unit]
				side=5
				type=Tentacle of the Deep
				count=1 # The primary dying unit is not removed from the game until the end of this event
			[/have_unit]
			[variable]
				name=fight_tentacles
				greater_than=0 # active for value 1 or 2
			[/variable]
		[/filter_condition]
		{REPEAT 5 (
			{VARIABLE_CONDITIONAL randX rand (18..24)}
			{VARIABLE_CONDITIONAL randY rand (24..29)}
			{LSB_DIAL Valia _"this code is running."} # ###
			[switch]
				variable=REPEAT_i
				[case]
					value=4
					{IF_VAR fight_tentacles equals 1 (
						[then]
							[unstore_unit]
								variable=deep_eye
								find_vacant=yes
								x,y=$randX,$randY
							[/unstore_unit]
							{LSB_DIAL Valia _"this code is running 2."} # ###
						[/then]
					 )}
				[/case]
				[else]
					{GENERIC_UNIT 5 "Tentacle of the Deep" $randX $randY}
					{LSB_DIAL Valia _"this code is running 3."} # ###
				[/else]
			[/switch]
			{CLEAR_VARIABLE randX}
			{CLEAR_VARIABLE randY}
		)}
		[switch]
			variable=fight_tentacles
			[case]
				value=1
				{VARIABLE fight_tentacles 2}
			[/case]
			[case]
				value=2
				{VARIABLE fight_tentacles 1}
			[/case]
		[/switch]
	[/event]




	[event]
		name=die
		[filter]
			side=5
			type=SCC_Deep_Eye
		[/filter]
		[filter_second]
			side=1
		[/filter_second]
		{CLEAR_VARIABLE deep_eye}
		{CLEAR_VARIABLE fight_tentacles}
		[kill]
			[filter]
				side=5
				type=Tentacle of the Deep
			[/filter]
			animate=yes
			fire_event=yes
		[/kill]
		{SSC_REDRAW}
	[/event]
LUA: Llama Under Apprenticeship
Hell faction: completed
Dindoz
Posts: 17
Joined: February 25th, 2014, 1:50 pm

Re: WML questions: invalid wml

Post by Dindoz »

Hi,
What do you use for replace [terrain_graphics] in 1.11.11 ?

I used :

Code: Select all

# [item]
# 	[if] 
# 		{X},{Y} = 0,0
# 	[/if]
# 
# 		[else]
# 			[item]
# 				halo=terrain/ward-circle-[01~08].png:140
# 				x,y={X},{Y}
# 			[/item]
# 		[/else]
# [/item]
That worked fine in 1.11.10 but not in 1.11.11
Computer : Clevo w310cz Os : Ubuntu 13.10 TBoW : 11.11.11
Sorry for my poor english I do my best.
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: WML questions: invalid wml

Post by pyrophorus »

Hi !
No, I think the error is here:

Code: Select all

    {REPEAT 5 (
         {VARIABLE_CONDITIONAL randX rand (18..24)}
         {VARIABLE_CONDITIONAL randY rand (24..29)}
VARIABLE_CONDITIONAL expands to:

Code: Select all

    [variable]
        name=randX
        rand=18..24
    [/variable]
which makes no sense outside of a conditionnal tag ( [if] or [filter_condition])

Friendly,
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: invalid wml

Post by battlestar »

aye, those were meant to be variable_ops :doh:
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: invalid wml

Post by battlestar »

1. Is there any direct way to count how many players are in a multiplayer match? (besides adding 1 to a variable for each side until next turn refresh)

2. Is there any code to prevent gold gain from towns for a specific side or race?

3. Is there anything to check the gold gain setting (a) of a scenario in campaign? (b) for multiplayer match? (other than to store all the villages a side owns, divided by the gold difference including total unit level for upkeep cost and store recruit costs... which sounds very tedious)

4. Any idea for coding a unit ability that does not heal on villages?

Thanks!
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: WML questions: invalid wml

Post by iceiceice »

Off the top of my head:
1. Try counting how many sides have controller = empty. In 1.10 it is really not a good idea to do any reasoning about the values of controller, but testing empty vs. not empty is safe and won't cause OOS.

2,4: I guess I would consider using turn start events that happen just before the upkeep stage and replace villages with terrains that look similar. I'm thinking you could identify towns that *should* contribute gold and add them up and give that gold. At least this you don't have to completely redo the upkeep calculation for units, although you will have to do part of it. You could similarly manually heal only heal that units that were *supposed* to heal during upkeep. IIRC if you use harm_unit with a negative value you will even get the little green healing text. There might be a simpler way than this, I don't really know.

3: In 1.11, yes, I added this. In 1.10, I'm not completely sure, but I'm a little doubtful. See here: http://wiki.wesnoth.org/LuaWML:Misc#wesnoth.game_config

Edit: Whoops didn't read properly. According to that page, yes I guess you can get "Base income" and "Village income" in 1.10. And "rest heal amount" And also reset these to whatever values you like. So that might give you another approach here.
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: WML questions: invalid wml

Post by tekelili »

1. Depending on your scenario specifications, you could consider using

Code: Select all

    [store_unit]
        variable=temp
        [filter]
            canrecruit=yes
        [/filter]
    [/store_unit]
    {VARIABLE players $temp.length}
2. I would try

Code: Select all

    [store_villages]
        variable=village_count
        side=$special_side
    [/store_villages]
    [gold]
            side=$special_side
            amunt="$(-$village_count.length*2)"
    [/gold]
upkeep could need need be also taken into account, but I duno if you can just define that side units as upkeep=free. Details can complicate or make implementaion easier :|
EDIT: you can also try:

Code: Select all

[side]
    village_gold=0
[/side]


4. I need to know some details here, as if the unit would be healed by an allied white mage standing adjacent to that unit on village. But mostly I would write an event in the unit (besides lot of people told this doesnt work, it really works) :hmm:
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: invalid wml

Post by battlestar »

Thanks guys, you answered my questions 1-3 very well. Though for #3, instead of lua could I just save a side in a variable and use "village_gold"?

For 4, I'm thinking a faction (that can both be played as MP and in SP campaigns), that still gains gold from villages but doesn't get the heal benefit. So units still can be healed by healers and scenario events, including events that manipulate hp at new turn or turn refresh... Like ice suggested I'm thinking replacing actual village with an image then manually giving the gold to the player.

And yeah, event in unit works, almost all custom abilities have events in them, which is under [unit].
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: invalid wml

Post by battlestar »

Is there any way to get some codes to happen right before the attack dialog shows up? Apparently the name=attack event happens right after the attack dialog.
LUA: Llama Under Apprenticeship
Hell faction: completed
gfgtdf
Developer
Posts: 1431
Joined: February 10th, 2013, 2:25 pm

Re: WML questions: invalid wml

Post by gfgtdf »

idk whether select events fire in this case but i think not. Another hacky option is trying to emulate a hover event with wesnoth.theme_items/wesnoth.get_displayed_unit.
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