help for add-ons

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.
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

help for add-ons

Post by zijing »

I try to make add-ons compatible with SP and MP.I delete the #ifdef MULTIPLAYER and #endif and then change the [modification]type to hybrid,and it success with almost all the add-ons,but with healing Tent and Raze and Rebuild ann-ons by Eagle 11,It shows me this:

The following add-ons had errors and could not be loaded:
• /home/jing/.local/share/wesnoth/1.14/data/add-ons/Healing_Tent/_main.cfg
• /home/jing/.local/share/wesnoth/1.14/data/add-ons/Lootable_Villages/_main.cfg

Please report this to the respective authors or maintainers of these add-ons.

Details:

Macro/file 'NEW:VILLAGE' is missing
at ~add-ons/Healing_Tent/healertent_mod.cfg:10
included from ~add-ons/Healing_Tent/_main.cfg:2

Macro/file 'OVERLAY_RANDOM_L' is missing
at ~add-ons/Lootable_Villages/lootvillage_mod.cfg:13
included from ~add-ons/Lootable_Villages/_main.cfg:6

But the strange thing is,I launch map editor then I go back to the main menu,the add-on Healing Tent and Raze and Rebuild can be used and no error found.
Cansome one tell me what is the problem?I don't want to launch map editor every time I launch my game and go back to the main menu.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: help for add-ons

Post by Pentarctagon »

It sounds like there's an #ifdef EDITOR in there somewhere, if that's the case.

Also, moved to the WML Workshop.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

Re: help for add-ons

Post by zijing »

Pentarctagon wrote: February 2nd, 2020, 5:48 pm It sounds like there's an #ifdef EDITOR in there somewhere, if that's the case.

Also, moved to the WML Workshop.
There's no #ifdef EDITOR,and what's the meaning of "Also, moved to the WML Workshop."?
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

Re: help for add-ons

Post by zijing »

Here's the code for _main.cfg:

Code: Select all

(#if def MULTIPLAYER)I delete it already
{~add-ons/Healing_Tent/healertent_mod.cfg}
	[binary_path]
		path=data/add-ons/Healing_Tent/
	[/binary_path]
{~add-ons/Healing_Tent/images}
(#endif)

for the healertent_mod.cfg:

Code: Select all


[binary_path]
		path=data/add-ons/Healing_Tent/
[/binary_path]

{~add-ons/Healing_Tent/images}


#Healing Tent
{NEW:VILLAGE             *^Vch                                                     tent-fancy-red}

[terrain_type]
    symbol_image=terrain/tent-fancy-red
    id=Healer_tent
    name= _ "Healing Tent"
    editor_name= _ "Tent Village"
    string=^Vch
    aliasof=_bas, Vt
    default_base=Re
    heals=8
    gives_income=no
    editor_group=village
[/terrain_type]

[modification]
    id=Healertent
    name=_"Healing Tent"
    description=_"If this mod is on, then your leader unit may deploy an Healing Tent, to do so the unit should have full moves and be standing on flat terrain(open desert, snow covered and cavernous flats also count), then through the right-click context-menu can order it to deploy the Healing Tent. When the leader deploys the tent its moves are depleted for that turn.

The Healing Tent functions like an portable village that provides the usual village healing benefits but no income. If an enemy unit enters the hex with the Healing Tent it gets instantly destroyed(this also applies to neutral tents without a side), the leader unit can pick up the deployed tent of its own side to carry it elsewhere. Note that whilst you can steal an ally's tent, your leader can carry and deploy only one tent at a time.

The Healing Tent cannot be pitched within 3 radius of any village, castle or keep tile, therefore its of limited use in most maps, except in those that are Randomly generated."
    require_modification=yes
	type=hybrid

	#building the tent part
	[event]
		name=prestart
		first_time_only=no
		[set_menu_item]
			id=pitch_tent
			description= _ "Deploy Healing Tent!"
			image="misc/build-tent.png"
			[show_if]
				[have_unit]
					side=$side_number
					x,y=$x1,$y1
					canrecruit=yes
					[not]
						[filter_wml]
							[status]
								deployed_tent=yes
							[/status]
						[/filter_wml]
					[/not]
					[filter_wml]
						moves=$this_unit.max_moves
					[/filter_wml]
				[/have_unit]
				[and]
					[not]
						[have_location]
							terrain=*^V*,C*,K*
							[and]
								x=$x1
								y=$y1
								radius=1
							[/and]
						[/have_location]
					[/not]
				[/and]
			[/show_if]
			[command]
				[store_side]
					side=$side_number
					variable=worker
				[/store_side]

				[store_unit]
					[filter]
						x=$x1
						y=$y1
					[/filter]
					variable=unit
				[/store_unit]

				[set_variable]
					name=finished
					value=no
				[/set_variable]
				[while]
					[variable]
						name=finished
						equals=no
					[/variable]

					[do]
						[message]
							speaker=unit
							message= _ "Are you sure ?"
							[option]
								message= {MENU_IMG_TXT "icons/scroll_red.png" ("<span color='yellow'>" + _ "Cancel" + "</span>")}
								[command]
									[set_variable]
										name=finished
										value=yes
									[/set_variable]
								[/command]
							[/option]

							[option]
								message= {MENU_IMG_TXT "icons/potion_red_medium.png" ("<span color='green'>" + _ "Deploy the Healing Tent" + "</span>") }
								[show_if]
									[have_unit]
										side=$side_number
										x,y=$x1,$y1
										canrecruit=yes
										[filter_location]
											terrain=G*,R*,Aa,Dd,Dt,Ur,Urb,Uu,Uue
										[/filter_location]
									[/have_unit]
								[/show_if]

								[command]
									[set_variable]
										name=finished
										value=yes
									[/set_variable]
									[set_variable]
										name=unit.status.deployed_tent
										value=yes
									[/set_variable]
									[set_variable]
										name=unit.moves
										value=0
									[/set_variable]

									[unstore_unit]
										variable=unit
									[/unstore_unit]

									[terrain]
										x=$x1
										y=$y1
										layer=overlay
										terrain=^Vch
									[/terrain]

									[capture_village]
										x=$x1
										y=$y1
										side=$side_number
									[/capture_village]

									[sound]
										name=miss-1.ogg
									[/sound]
									[delay]
										time=120
									[/delay]
									[sound]
										name=bite.ogg
									[/sound]
									[delay]
										time=220
									[/delay]
									[sound]
										name=dart.wav
									[/sound]
									[delay]
										time=180
									[/delay]
									[sound]
										name=dart.wav
									[/sound]
								[/command]
							[/option]
						[/message]
					[/do]
				[/while]
			[/command]
		[/set_menu_item]
	[/event]

	#tearing down the tent part
    [event]
        name=side_turn
        first_time_only=no
        [store_side]
            side=$side_number
            variable=current_side
        [/store_side]

        [set_menu_item]
            [show_if]
                [have_unit]
                    side=$side_number
                    canrecruit=yes
                    x=$x1
                    y=$y1
                    [filter_wml]
                        [status]
                            deployed_tent=yes
                        [/status]
                    [/filter_wml]
                    [filter_location]
                        x=$x1
                        y=$y1
                        terrain=*^Vch
						side=$current_side
                    [/filter_location]
                [/have_unit]
            [/show_if]
            id=teardown_healtent
            description=_ "Teardown Healing Tent!"
			image="misc/tear-down.png"
            [command]
                [store_unit]
                    [filter]
                        x=$x1
                        y=$y1
                    [/filter]
                    variable=unit
                [/store_unit]
                {VARIABLE tentX $x1}
                {VARIABLE tentY $y1}

				[terrain]
					x=$tentX
					y=$tentY
					#x,y={X},{Y}
					layer=overlay
					terrain=^
				[/terrain]

                [set_variable]
                    name=unit.status.deployed_tent
                    value=no
                [/set_variable]

                [set_variable]
                    name=unit.moves
                    value=0
                [/set_variable]

                [unstore_unit]
                    variable=unit
                    {CLEAR_VARIABLE unit}
				    text="<span color='#cccc33'>" + _ "teared down Healing Tent" + "</span>"
                [/unstore_unit]

				[sound]
					name=staff.wav
				[/sound]
				[delay]
					time=120
				[/delay]
				[sound]
					name=claws.ogg
				[/sound]
				[delay]
					time=220
				[/delay]
				[sound]
					name=wose-die.ogg
				[/sound]
				[delay]
					time=180
				[/delay]
				[sound]
					name=mace.wav
				[/sound]
            [/command]
        [/set_menu_item]
	[/event]

	#delete the tent if hostile enters
	[event]
		name=capture
		first_time_only=no
		[filter]
            [filter_location]
                terrain=*^Vch*
            [/filter_location]
			[filter_side]
				[not]
					[allied_with]
						side=$owner_side
					[/allied_with]
				[/not]
			[/filter_side]
		[/filter]

        [terrain]
            x=$x1
            y=$y1
            layer=overlay
            terrain=^
        [/terrain]
	[/event]
[/modification]
Raze and Rebuild,_main.cfg:

Code: Select all


	[binary_path]
		path=data/add-ons/Lootable_Villages/
	[/binary_path]
	{~add-ons/Lootable_Villages/images}
	{~add-ons/Lootable_Villages/lootvillage_mod.cfg}

lootvillage_mod.cfg:

Code: Select all

#have to ensure not using mainline rubble as its used in some maps as decoration.

[terrain_type]
    symbol_image=misc/rubble-tile
    id=rubble_for_village
    name= _ "Village Rubble"
    string=^Drv
    aliasof=_bas
    editor_group=flat
[/terrain_type]

#Rubble
{OVERLAY_RANDOM_L        *^Drv                                             -1       misc/rubble}


#define DESTROY X Y
    [terrain]
        x={X}
        y={Y}
        layer=overlay
        terrain=^Drv
    [/terrain]
#enddef


#define RAZE_SOUND
    [sound]
        name=melee-fire.ogg
    [/sound]
    [delay]
        time=120
    [/delay]
    [sound]
        name=fire.wav
    [/sound]
    [delay]
        time=220
    [/delay]
    [sound]
        name=wose-die.ogg
    [/sound]
    [delay]
        time=180
    [/delay]
    [sound]
        name=torch-miss.ogg
    [/sound]
#enddef


#define COMPLETE_ACTION GOLD_NUMBER
    [set_variable]
        name=finished
        value=yes
    [/set_variable]

    [set_variable]
        name=unit.status.worked_this_turn
        value=yes
    [/set_variable]
    [set_variable]
        name=unit.moves
        value=0
    [/set_variable]

    [unstore_unit]
        variable=unit
    [/unstore_unit]

    [gold]
        amount={GOLD_NUMBER}
        side=$side_number
    [/gold]
#enddef


#define SHOW_IF TERRAINLIST
    [show_if]
        [have_unit]
            side=$side_number
            x,y=$x1,$y1
            canrecruit=yes
            [filter_location]
                terrain={TERRAINLIST}
            [/filter_location]
        [/have_unit]
    [/show_if]
#enddef


#define BUILD_SOUND_1
    [sound]
        name=miss-1.ogg
    [/sound]
    [delay]
        time=120
    [/delay]
    [sound]
        name=bite.ogg
    [/sound]
    [delay]
        time=220
    [/delay]
    [sound]
        name=dart.wav
    [/sound]
    [delay]
        time=180
    [/delay]
    [sound]
        name=dart.wav
    [/sound]
#enddef


#define CAPTURE_VILLAGE
    [capture_village]
        x=$x1
        y=$y1
        side=$side_number
    [/capture_village]
#enddef


[modification]
    id=Raze_Rebuild_Mod
    name=_"Raze and Rebuild Mod"
    description=_"If this mod is on, then any unit(except leaders) can sack villages, to do so the unit should have full moves and be inside the village, then through right-click context-menu can order it to sack the village.
When an village is razed it yields random 3-7 gold for that unit's side and rubble appears at that hex, and the razing unit has it's moves depleted for that turn.

To rebuild a village leader unit must be standing on the rubble hex and have full movement points, then through right-click context-menu you can rebuild the village.
Rebuilding an village that was on flat costs 14 gold, cave, water, snow, desert terrain costs 13g, swamp costs 12g, mountain and hills costs 15 gold."
    require_modification=yes
	type=hybrid

# -----------------------------------------------------------------
# The part about razing villages.
# -----------------------------------------------------------------
    [event]
        name=side_turn
        first_time_only=no
        [store_side]
            side=$side_number
            variable=current_side
        [/store_side]

        [set_menu_item]
            [show_if]
                [have_unit]
                    side=$side_number
                    canrecruit=no
                    x=$x1
                    y=$y1
                    [not]
                        [filter_wml]
                            [status]
                                use_trap=yes
                            [/status]
                        [/filter_wml]
                    [/not]
					[not]
						type=Exi Guardtower
					[/not]
                    [filter_wml]
                        moves=$this_unit.max_moves
                    [/filter_wml]
                    [filter_location]
                        x=$x1
                        y=$y1
                        terrain=*^V*
						[not]
							terrain=*^Vch*
						[/not]
                    [/filter_location]
                [/have_unit]
            [/show_if]
            id=destroy_village
            description=_ "Sack this Village !"
			image="misc/burn-village.png"
            [command]
                [store_unit]
                    [filter]
                        x=$x1
                        y=$y1
                    [/filter]
                    variable=unit
                [/store_unit]
                {VARIABLE trapX $x1}
                {VARIABLE trapY $y1}
                {DESTROY $trapX $trapY}

                [set_variable]
                    name=unit.status.use_trap
                    value=yes
                [/set_variable]

                [set_variable]
                    name=gold_bonus
                    rand=3..7
                [/set_variable]

                 [set_variable]
                     name=unit.moves
                     value=0
                 [/set_variable]

                [gold]
                    amount=$gold_bonus
                    side=$side_number
                [/gold]

                [unstore_unit]
                    variable=unit
                    {CLEAR_VARIABLE unit}
				    text="<span color='#cccc33'>" + _ "Plundered $gold_bonus gold" + "</span>"
                [/unstore_unit]

				{RAZE_SOUND}
            [/command]
        [/set_menu_item]

        [store_unit]
            [filter]
                [filter_wml]
                    [status]
                        use_trap=yes
                    [/status]
                [/filter_wml]
            [/filter]
            kill=yes
            variable=this_side_workers
        [/store_unit]

        {FOREACH this_side_workers i}
		[clear_variable]
			name=this_side_workers[$i].status.use_trap
        [/clear_variable]

        [unstore_unit]
			variable=this_side_workers[$i]
        [/unstore_unit]
        {NEXT i}

        [clear_variable]
            name=this_side_workers
        [/clear_variable]
	[/event]
# -----------------------------------------------------------------
# First, the rebuilding part.

# Then, the options for each terrain type with varying gold cost.
# -----------------------------------------------------------------
    [event]
        name=prestart
        first_time_only=no
        [set_menu_item]
			id=get_to_work
			description= _ "Rebuild this Village!"
			image="misc/rebuild-village.png"
			[show_if]
				[have_unit]
					side=$side_number
					x,y=$x1,$y1
					canrecruit=no
					[not]
						[filter_wml]
							[status]
								worked_this_turn=yes
							[/status]
						[/filter_wml]
					[/not]
					[filter_wml]
						moves=$this_unit.max_moves
					[/filter_wml]
                    [filter_location]
                        x=$x1
                        y=$y1
                        terrain=*^Drv*
                    [/filter_location]
				[/have_unit]
			[/show_if]
			[command]
				[store_side]
					side=$side_number
					variable=worker
				[/store_side]

				[store_unit]
					[filter]
						x=$x1
						y=$y1
					[/filter]
					variable=unit
				[/store_unit]

				[set_variable]
					name=finished
					value=no
				[/set_variable]
				[while]
					[variable]
						name=finished
						equals=no
					[/variable]
					[do]
# wmlindent: start ignoring
						[message]
							speaker=unit
# wmllint: display on
							message= _ "Are you sure ?"
# wmllint: display off

							[option]
								message= {MENU_IMG_TXT "icons/scroll_red.png" ("<span color='yellow'>" + _ "Cancel" + "</span>")}
								[command]
									[set_variable]
										name=finished
										value=yes
									[/set_variable]
								[/command]
							[/option]

# -----------------------------------------------------------------
# WATER TYPES

# Sea villages one gold cheaper due to being rather remote access.
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Ww^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Ww^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Wwg^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Wwg^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Wwt^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Wwt^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Ford equal to Flat movetype so costs 14g
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Wwf^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Wwf^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Swamp extra cheap 12g
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 12g" + "</span>")}
								{SHOW_IF "Ss^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=12
										[/variable]
										[then]
											{COMPLETE_ACTION (-12)}
											{MODIFY_TERRAIN "Ss^Vhs" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Beach Sand, assuming mapper paid attention and placed this as beach
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Ds^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]

										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Ds^Vhs" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# FLAT TYPES

# Flat costs 14g
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gg^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]

										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gg^Vh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gs^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gs^Vc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gd^Vo" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gll^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gll^Ve" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Road tiles
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rr^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rr^Vhc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rrc^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rrc^Vhc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rp^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rp^Vhc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rb^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rb^Vht" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Re^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Re^Vct" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rd^Vdt" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Ur^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Ur^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------------------------
# Snow, Desert and Caves cost 1g less since most races have difficulty reaching them
# -----------------------------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Aa^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Aa^Vaa" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Dd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Dd^Vda" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Uu^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Uu^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Uue^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Uue^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------------------------
# ELEVATED TYPES

# Mountain and hills costs 15g due to defensive bonuses
# -----------------------------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Hh^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Hh^Vhh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Hhd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Hhd^Vhh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Hd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Hd^Vda" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Uh^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Uh^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Ha^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Ha^Vhha" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Mm^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Mm^Vhh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Md^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Md^Vd" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Ms^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Ms^Vhha" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
						[/message]
					[/do]
				[/while]
			[/command]
		[/set_menu_item]
	[/event]
# -----------------------------------------------------------------------------------
# Removing the working status from any units that have worked in the last turn, whenever starting a new turn.
# -----------------------------------------------------------------------------------
    [event]
        name=side turn
        first_time_only=no

        [store_unit]
            [filter]
                side=$side_number

                [filter_wml]
                    [status]
                        worked_this_turn=yes
                    [/status]
                [/filter_wml]
            [/filter]

            kill=yes
            variable=this_side_workers
        [/store_unit]

        {FOREACH this_side_workers i}
            [clear_variable]
                name=this_side_workers[$i].status.worked_this_turn
            [/clear_variable]

            [unstore_unit]
                variable=this_side_workers[$i]
            [/unstore_unit]
        {NEXT i}

        [clear_variable]
            name=this_side_workers
        [/clear_variable]
    [/event]
[/modification]
Last edited by Pentarctagon on February 3rd, 2020, 1:37 pm, edited 1 time in total.
Reason: [c] -> [code]
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: help for add-ons

Post by Pentarctagon »

zijing wrote: February 3rd, 2020, 7:32 am
Pentarctagon wrote: February 2nd, 2020, 5:48 pm It sounds like there's an #ifdef EDITOR in there somewhere, if that's the case.

Also, moved to the WML Workshop.
There's no #ifdef EDITOR,and what's the meaning of "Also, moved to the WML Workshop."?
WML problems with add-ons don't belong in the Technical Support forums, so I moved the thread to the WML Workshop.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

Re: help for add-ons

Post by zijing »

Pentarctagon wrote: February 3rd, 2020, 1:40 pm
zijing wrote: February 3rd, 2020, 7:32 am
Pentarctagon wrote: February 2nd, 2020, 5:48 pm It sounds like there's an #ifdef EDITOR in there somewhere, if that's the case.

Also, moved to the WML Workshop.
There's no #ifdef EDITOR,and what's the meaning of "Also, moved to the WML Workshop."?
WML problems with add-ons don't belong in the Technical Support forums, so I moved the thread to the WML Workshop.
So,how can I fix this problem?
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: help for add-ons

Post by Ravana »

Pentarctagon already fixed it by moving the thread.
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

Re: help for add-ons

Post by zijing »

Ravana wrote: February 3rd, 2020, 1:51 pm Pentarctagon already fixed it by moving the thread.
I mean my question,not about the thread
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: help for add-ons

Post by Pentarctagon »

It looks likes the macro isn't defined until after the point it tries to read the add-on when the #ifdef MULTIPLAYER is defined. I don't know why though.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
MoonyDragon
Posts: 149
Joined: November 29th, 2017, 5:46 pm

Re: help for add-ons

Post by MoonyDragon »

It seems (as Pentarctagon has already stated) that terrain building macros aren't defined until either the editor, multiplayer or singleplayer has been started. To propose a quick fix to your problem, I suggest to simply copy them into the mod file.
Insert this into the healertent_mod.cfg file:

Code: Select all

#define NEW:VILLAGE TERRAINLIST IMAGESTEM

#arg PROB
100#endarg

#arg ANIM
#endarg

#arg TIME
#endarg

    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=village
        [/tile]

        probability={PROB}

        [image]
            name={IMAGESTEM}@V{ANIM}.png:{TIME}
            variations=";2;3;4;5;6;7"
            layer=0
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef
And as far as lootvillage_mod.cfg is concerned, replace the macro OVERLAY_RANDOM_L with this:

Code: Select all

#define NEW:OVERLAY TERRAIN IMAGESTEM
    # Places {IMAGESTEM}[1-11].png as overlay tiles.

#arg LAYER
0#endarg

#arg FLAG
overlay#endarg

#arg PROB
100#endarg

#arg ANIM
#endarg

#arg TIME
#endarg

#arg CENTER
90,144#endarg

    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"
        [tile]
            pos=1
            type={TERRAIN}
            set_no_flag={FLAG}
        [/tile]

        probability={PROB}

        [image]
            name={IMAGESTEM}@V{ANIM}.png:{TIME}
            variations=";2;3;4;5;6;7;8;9;10;11"
            layer={LAYER}
            base=90,160
            center={CENTER}
        [/image]
    [/terrain_graphics]
#enddef

#Rubble
{NEW:OVERLAY        *^Drv                                                    misc/rubble  LAYER=-1}
Default L0 Era - Level 1 leaders with level 0 recruits!
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

Re: help for add-ons

Post by zijing »

MoonyDragon wrote: February 4th, 2020, 4:22 am It seems (as Pentarctagon has already stated) that terrain building macros aren't defined until either the editor, multiplayer or singleplayer has been started. To propose a quick fix to your problem, I suggest to simply copy them into the mod file.
Insert this into the healertent_mod.cfg file:

Code: Select all

#define NEW:VILLAGE TERRAINLIST IMAGESTEM

#arg PROB
100#endarg

#arg ANIM
#endarg

#arg TIME
#endarg

    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=village
        [/tile]

        probability={PROB}

        [image]
            name={IMAGESTEM}@V{ANIM}.png:{TIME}
            variations=";2;3;4;5;6;7"
            layer=0
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef
And as far as lootvillage_mod.cfg is concerned, replace the macro OVERLAY_RANDOM_L with this:

Code: Select all

#define NEW:OVERLAY TERRAIN IMAGESTEM
    # Places {IMAGESTEM}[1-11].png as overlay tiles.

#arg LAYER
0#endarg

#arg FLAG
overlay#endarg

#arg PROB
100#endarg

#arg ANIM
#endarg

#arg TIME
#endarg

#arg CENTER
90,144#endarg

    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"
        [tile]
            pos=1
            type={TERRAIN}
            set_no_flag={FLAG}
        [/tile]

        probability={PROB}

        [image]
            name={IMAGESTEM}@V{ANIM}.png:{TIME}
            variations=";2;3;4;5;6;7;8;9;10;11"
            layer={LAYER}
            base=90,160
            center={CENTER}
        [/image]
    [/terrain_graphics]
#enddef

#Rubble
{NEW:OVERLAY        *^Drv                                                    misc/rubble  LAYER=-1}
Wow,it works.Thanks!Just but the lootvillage's rebuild part got some problem,the rebuild section doesn't appear,Ijust got the cancel option only
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

Re: help for add-ons

Post by zijing »

after modified:

Code: Select all

#have to ensure not using mainline rubble as its used in some maps as decoration.

[terrain_type]
    symbol_image=misc/rubble-tile
    id=rubble_for_village
    name= _ "Village Rubble"
    string=^Drv
    aliasof=_bas
    editor_group=flat
[/terrain_type]


#define NEW:OVERLAY TERRAIN IMAGESTEM
    # Places {IMAGESTEM}[1-11].png as overlay tiles.

#arg LAYER
0#endarg

#arg FLAG
overlay#endarg

#arg PROB
100#endarg

#arg ANIM
#endarg

#arg TIME
#endarg

#arg CENTER
90,144#endarg

    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"
        [tile]
            pos=1
            type={TERRAIN}
            set_no_flag={FLAG}
        [/tile]

        probability={PROB}

        [image]
            name={IMAGESTEM}@V{ANIM}.png:{TIME}
            variations=";2;3;4;5;6;7;8;9;10;11"
            layer={LAYER}
            base=90,160
            center={CENTER}
        [/image]
    [/terrain_graphics]
#enddef

#Rubble
{NEW:OVERLAY        *^Drv                                                    misc/rubble  LAYER=-1}


#define DESTROY X Y
    [terrain]
        x={X}
        y={Y}
        layer=overlay
        terrain=^Drv
    [/terrain]
#enddef


#define RAZE_SOUND
    [sound]
        name=melee-fire.ogg
    [/sound]
    [delay]
        time=120
    [/delay]
    [sound]
        name=fire.wav
    [/sound]
    [delay]
        time=220
    [/delay]
    [sound]
        name=wose-die.ogg
    [/sound]
    [delay]
        time=180
    [/delay]
    [sound]
        name=torch-miss.ogg
    [/sound]
#enddef


#define COMPLETE_ACTION GOLD_NUMBER
    [set_variable]
        name=finished
        value=yes
    [/set_variable]

    [set_variable]
        name=unit.status.worked_this_turn
        value=yes
    [/set_variable]
    [set_variable]
        name=unit.moves
        value=0
    [/set_variable]

    [unstore_unit]
        variable=unit
    [/unstore_unit]

    [gold]
        amount={GOLD_NUMBER}
        side=$side_number
    [/gold]
#enddef


#define SHOW_IF TERRAINLIST
    [show_if]
        [have_unit]
            side=$side_number
            x,y=$x1,$y1
            canrecruit=yes
            [filter_location]
                terrain={TERRAINLIST}
            [/filter_location]
        [/have_unit]
    [/show_if]
#enddef


#define BUILD_SOUND_1
    [sound]
        name=miss-1.ogg
    [/sound]
    [delay]
        time=120
    [/delay]
    [sound]
        name=bite.ogg
    [/sound]
    [delay]
        time=220
    [/delay]
    [sound]
        name=dart.wav
    [/sound]
    [delay]
        time=180
    [/delay]
    [sound]
        name=dart.wav
    [/sound]
#enddef


#define CAPTURE_VILLAGE
    [capture_village]
        x=$x1
        y=$y1
        side=$side_number
    [/capture_village]
#enddef


[modification]
    id=Raze_Rebuild_Mod
    name=_"Raze and Rebuild Mod"
    description=_"If this mod is on, then any unit(except leaders) can sack villages, to do so the unit should have full moves and be inside the village, then through right-click context-menu can order it to sack the village.
When an village is razed it yields random 3-7 gold for that unit's side and rubble appears at that hex, and the razing unit has it's moves depleted for that turn.

To rebuild a village leader unit must be standing on the rubble hex and have full movement points, then through right-click context-menu you can rebuild the village.
Rebuilding an village that was on flat costs 14 gold, cave, water, snow, desert terrain costs 13g, swamp costs 12g, mountain and hills costs 15 gold."
    require_modification=yes
	type=hybrid

# -----------------------------------------------------------------
# The part about razing villages.
# -----------------------------------------------------------------
    [event]
        name=side_turn
        first_time_only=no
        [store_side]
            side=$side_number
            variable=current_side
        [/store_side]

        [set_menu_item]
            [show_if]
                [have_unit]
                    side=$side_number
                    canrecruit=no
                    x=$x1
                    y=$y1
                    [not]
                        [filter_wml]
                            [status]
                                use_trap=yes
                            [/status]
                        [/filter_wml]
                    [/not]
					[not]
						type=Exi Guardtower
					[/not]
                    [filter_wml]
                        moves=$this_unit.max_moves
                    [/filter_wml]
                    [filter_location]
                        x=$x1
                        y=$y1
                        terrain=*^V*
						[not]
							terrain=*^Vch*
						[/not]
                    [/filter_location]
                [/have_unit]
            [/show_if]
            id=destroy_village
            description=_ "Sack this Village !"
			image="misc/burn-village.png"
            [command]
                [store_unit]
                    [filter]
                        x=$x1
                        y=$y1
                    [/filter]
                    variable=unit
                [/store_unit]
                {VARIABLE trapX $x1}
                {VARIABLE trapY $y1}
                {DESTROY $trapX $trapY}

                [set_variable]
                    name=unit.status.use_trap
                    value=yes
                [/set_variable]

                [set_variable]
                    name=gold_bonus
                    rand=3..7
                [/set_variable]

                 [set_variable]
                     name=unit.moves
                     value=0
                 [/set_variable]

                [gold]
                    amount=$gold_bonus
                    side=$side_number
                [/gold]

                [unstore_unit]
                    variable=unit
                    {CLEAR_VARIABLE unit}
				    text="<span color='#cccc33'>" + _ "Plundered $gold_bonus gold" + "</span>"
                [/unstore_unit]

				{RAZE_SOUND}
            [/command]
        [/set_menu_item]

        [store_unit]
            [filter]
                [filter_wml]
                    [status]
                        use_trap=yes
                    [/status]
                [/filter_wml]
            [/filter]
            kill=yes
            variable=this_side_workers
        [/store_unit]

        {FOREACH this_side_workers i}
		[clear_variable]
			name=this_side_workers[$i].status.use_trap
        [/clear_variable]

        [unstore_unit]
			variable=this_side_workers[$i]
        [/unstore_unit]
        {NEXT i}

        [clear_variable]
            name=this_side_workers
        [/clear_variable]
	[/event]
# -----------------------------------------------------------------
# First, the rebuilding part.

# Then, the options for each terrain type with varying gold cost.
# -----------------------------------------------------------------
    [event]
        name=prestart
        first_time_only=no
        [set_menu_item]
			id=get_to_work
			description= _ "Rebuild this Village!"
			image="misc/rebuild-village.png"
			[show_if]
				[have_unit]
					side=$side_number
					x,y=$x1,$y1
					canrecruit=no
					[not]
						[filter_wml]
							[status]
								worked_this_turn=yes
							[/status]
						[/filter_wml]
					[/not]
					[filter_wml]
						moves=$this_unit.max_moves
					[/filter_wml]
                    [filter_location]
                        x=$x1
                        y=$y1
                        terrain=*^Drv*
                    [/filter_location]
				[/have_unit]
			[/show_if]
			[command]
				[store_side]
					side=$side_number
					variable=worker
				[/store_side]

				[store_unit]
					[filter]
						x=$x1
						y=$y1
					[/filter]
					variable=unit
				[/store_unit]

				[set_variable]
					name=finished
					value=no
				[/set_variable]
				[while]
					[variable]
						name=finished
						equals=no
					[/variable]
					[do]
# wmlindent: start ignoring
						[message]
							speaker=unit
# wmllint: display on
							message= _ "Are you sure ?"
# wmllint: display off

							[option]
								message= {MENU_IMG_TXT "icons/scroll_red.png" ("<span color='yellow'>" + _ "Cancel" + "</span>")}
								[command]
									[set_variable]
										name=finished
										value=yes
									[/set_variable]
								[/command]
							[/option]

# -----------------------------------------------------------------
# WATER TYPES

# Sea villages one gold cheaper due to being rather remote access.
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Ww^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Ww^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Wwg^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Wwg^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Wwt^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Wwt^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Ford equal to Flat movetype so costs 14g
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Wwf^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Wwf^Vm" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Swamp extra cheap 12g
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 12g" + "</span>")}
								{SHOW_IF "Ss^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=12
										[/variable]
										[then]
											{COMPLETE_ACTION (-12)}
											{MODIFY_TERRAIN "Ss^Vhs" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Beach Sand, assuming mapper paid attention and placed this as beach
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Ds^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]

										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Ds^Vhs" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# FLAT TYPES

# Flat costs 14g
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gg^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]

										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gg^Vh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gs^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gs^Vc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gd^Vo" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Gll^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Gll^Ve" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------
# Road tiles
# -----------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rr^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rr^Vhc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rrc^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rrc^Vhc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rp^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rp^Vhc" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rb^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rb^Vht" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Re^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Re^Vct" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Rd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Rd^Vdt" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 14g" + "</span>")}
								{SHOW_IF "Ur^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=14
										[/variable]
										[then]
											{COMPLETE_ACTION (-14)}
											{MODIFY_TERRAIN "Ur^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------------------------
# Snow, Desert and Caves cost 1g less since most races have difficulty reaching them
# -----------------------------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Aa^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Aa^Vaa" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Dd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Dd^Vda" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Uu^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Uu^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 13g" + "</span>")}
								{SHOW_IF "Uue^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=13
										[/variable]
										[then]
											{COMPLETE_ACTION (-13)}
											{MODIFY_TERRAIN "Uue^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
# -----------------------------------------------------------------------------------
# ELEVATED TYPES

# Mountain and hills costs 15g due to defensive bonuses
# -----------------------------------------------------------------------------------
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Hh^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Hh^Vhh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Hhd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Hhd^Vhh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Hd^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Hd^Vda" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Uh^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Uh^Vud" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Ha^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Ha^Vhha" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Mm^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Mm^Vhh" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Md^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Md^Vd" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
							[option]
								message= {MENU_IMG_TXT2 "icons/crossed_sword_and_hammer.png" ("<span color='green'>" + _ "Rebuild Village" + "</span>") ("<span size='small'>" + _ "Cost: 15g" + "</span>")}
								{SHOW_IF "Ms^Drv"}
								[command]
									[if]
										[variable]
											name=worker.gold
											greater_than_equal_to=15
										[/variable]
										[then]
											{COMPLETE_ACTION (-15)}
											{MODIFY_TERRAIN "Ms^Vhha" $x1 $y1}
											{CAPTURE_VILLAGE}
											{BUILD_SOUND_1}
										[/then]
									[/if]
								[/command]
							[/option]
						[/message]
					[/do]
				[/while]
			[/command]
		[/set_menu_item]
	[/event]
# -----------------------------------------------------------------------------------
# Removing the working status from any units that have worked in the last turn, whenever starting a new turn.
# -----------------------------------------------------------------------------------
    [event]
        name=side turn
        first_time_only=no

        [store_unit]
            [filter]
                side=$side_number

                [filter_wml]
                    [status]
                        worked_this_turn=yes
                    [/status]
                [/filter_wml]
            [/filter]

            kill=yes
            variable=this_side_workers
        [/store_unit]

        {FOREACH this_side_workers i}
            [clear_variable]
                name=this_side_workers[$i].status.worked_this_turn
            [/clear_variable]

            [unstore_unit]
                variable=this_side_workers[$i]
            [/unstore_unit]
        {NEXT i}

        [clear_variable]
            name=this_side_workers
        [/clear_variable]
    [/event]
[/modification]
So I didn't get option to rebuild village
Last edited by zijing on February 4th, 2020, 10:21 pm, edited 1 time in total.
User avatar
MoonyDragon
Posts: 149
Joined: November 29th, 2017, 5:46 pm

Re: help for add-ons

Post by MoonyDragon »

I tested the mod on Wesnoth 1.14.9 and had had the same problem... Until I took a closer glance at the code and saw that you need to have a leader on the village rubble terrain in order to rebuilt the village. If you are annoyed by this requirement, simply comment out all canrecruit= tags.

EDIT: Also, if you want to paste multiple lines of code, please use [code] instead of [c]. This way, others can expand / collapse them and save space and time.
Default L0 Era - Level 1 leaders with level 0 recruits!
User avatar
zijing
Posts: 21
Joined: January 18th, 2020, 11:23 am

Re: help for add-ons

Post by zijing »

Another problem here.I try to make a mod that let all recruited units become loyal,but it doesn't work at all,or tell me an WML error.
Here's the code:

Code: Select all


[modification]
    id=Loyalty_Mod
    name= _ "Units Loyal Mod"
    description= _ "If this mod is on, then all your units become loyal."
    require_modification=yes
	type=hybrid

    [event]
        name=recruit
	id=unit_loyal
	first_time_only=no
        [set_variables]
            [literal]
                {TRAIT_LOYAL}
            [/literal]
        [/set_variables]
    [/event]
[/modification]
It doesn't work here.Or either this one:

Code: Select all


[modification]
    id=Loyalty_Mod
    name= _ "Units Loyal Mod"
    description= _ "If this mod is on, then all your units become loyal."
    require_modification=yes
	type=hybrid

    [event]
        name=recruit
	id=unit_loyal
	first_time_only=no
        [effect]
        [set_variables]
            [literal]
                {TRAIT_LOYAL}
            [/literal]
        [/set_variables]
        [/effect]
    [/event]
[/modification]
This occur an error.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: help for add-ons

Post by Pentarctagon »

I'd suggest taking a look at [modify_unit]. Also, for the code you posted, you never specified which unit you're trying to make loyal (the recruit event is not restricted to only the unit that was just recruited) nor would using [set_variables] like that do anything if you did (what you have basically says to set a variable with no name to the contents of the {TRAIT_LOYAL} macro).
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply