build village

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
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

Code: Select all

#define PWSMGIVE TARGET_SIDE
    [option]
        [set_variable]
            name=df_player_name
            value=$player_{TARGET_SIDE}.name
        [/set_variable]
            label= _"side" + "{TARGET_SIDE}" + "$player_{TARGET_SIDE}.name"
        [store_locations]
            x=$x1
            y=$y1
            variable=GVL
        [/store_locations]
        [show_if]
            [variable]
                name=side_number
                numerical_not_equals={TARGET_SIDE}
            [/variable]
            [have_unit]
                side={TARGET_SIDE}
                canrecruit=yes
            [/have_unit]
            [variable]
                name=side_number
                numerical_equals=$GVL.owner_side
            [/variable]
#            [have_location]
#            [village]
#            x=$x1
#            y=$y1
#            side=$side_number
#            [/village]
#            [/have_location]
        [/show_if]
        [command]        
        [capture_village]
            x=$x1
            y=$y1
            side={TARGET_SIDE}
        [/capture_village]
        [/command]
    [/option]
#enddef
I found the macro with the code you posted. There are several problems with it, but most of them are the same kind: You don't seem to know that you can only use tags and keys in specific places. If you look at the wiki, you can see that [option] in [message] can take two different keys. Only two. You can't put [set_variable] or [store_locations] there. The game is ignoring those tags. Likewise, you can't put [village] inside [have_location] (or side=... inside [village] either). You have similar errors in other parts of your code.

Also, this is the wrong place for some of these conditionals. Some of them should go in the [show_if] of [set_menu_item] instead of the [show_if] of [option]. Checking to see if the hex is a village here isn't useful, because the game is already showing the message about villages at this point.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

beetlenaut wrote: January 7th, 2024, 11:55 am

Code: Select all

#define PWSMGIVE TARGET_SIDE
    [option]
        [set_variable]
            name=df_player_name
            value=$player_{TARGET_SIDE}.name
        [/set_variable]
            label= _"side" + "{TARGET_SIDE}" + "$player_{TARGET_SIDE}.name"
        [store_locations]
            x=$x1
            y=$y1
            variable=GVL
        [/store_locations]
        [show_if]
            [variable]
                name=side_number
                numerical_not_equals={TARGET_SIDE}
            [/variable]
            [have_unit]
                side={TARGET_SIDE}
                canrecruit=yes
            [/have_unit]
            [variable]
                name=side_number
                numerical_equals=$GVL.owner_side
            [/variable]
#            [have_location]
#            [village]
#            x=$x1
#            y=$y1
#            side=$side_number
#            [/village]
#            [/have_location]
        [/show_if]
        [command]        
        [capture_village]
            x=$x1
            y=$y1
            side={TARGET_SIDE}
        [/capture_village]
        [/command]
    [/option]
#enddef
I found the macro with the code you posted. There are several problems with it, but most of them are the same kind: You don't seem to know that you can only use tags and keys in specific places. If you look at the wiki, you can see that [option] in [message] can take two different keys. Only two. You can't put [set_variable] or [store_locations] there. The game is ignoring those tags. Likewise, you can't put [village] inside [have_location] (or side=... inside [village] either). You have similar errors in other parts of your code.

Also, this is the wrong place for some of these conditionals. Some of them should go in the [show_if] of [set_menu_item] instead of the [show_if] of [option]. Checking to see if the hex is a village here isn't useful, because the game is already showing the message about villages at this point.
I hope check "village owner",only village owner can use the optoin change village owner,how do?
User avatar
Ravana
Forum Moderator
Posts: 3012
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: build village

Post by Ravana »

Start by removing all invalid key and tags from where they currently are. Then look where they are allowed to be.
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

Ravana wrote: January 7th, 2024, 3:10 pm Start by removing all invalid key and tags from where they currently are. Then look where they are allowed to be.
Ok,i fix it,but i have a iuess,how Quickly locate WMLcode placed in the wrong location?
beetlenaut wrote: January 7th, 2024, 5:48 am
ERROR1025 wrote: January 7th, 2024, 5:06 am Ok,is work,but auto delete forest,if have forest in build hex,i hope only add villvge.
Wouldn't a person cut down trees to build a house?

You seem to want one hex to be forest and village at the same time, which can't happen in the game. There must be separate terrains in each hex. If you mean that you want to see a building with trees surrounding it very close to its walls, you would need to draw that yourself, and create terrain codes for it too. I don't think anyone has done this before because it would be a lot of work: There would be thousands of possibilities of tree and building types mixed together, and it wouldn't really benefit the game very much.
Oh,I try use "^Cv" add Castle and "^Cva" add "Main Castle",but can not work
i hope only add Castle or "Main Castle"
case:
Village+Flat→Village+Castle+Flat
Forest+Flat→Forest+Castle+Flat
Flat→Flat+Castle
These mixed terrain exists in some "campaign maps",I hope to know how to add it directly instead of covering the terrain.
User avatar
Ravana
Forum Moderator
Posts: 3012
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: build village

Post by Ravana »

Schema validation would help, but is not so easy to set up. So for you its better to test which tag is not working, and verify that documentation allows them used that way.

Or you can just do the documentation checking process for each tag. If tag or attribute used inside specific tag is not referenced in outer tag documentation, it is usually not doing anything.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

ERROR1025 wrote: January 7th, 2024, 4:49 pm Oh,I try use "^Cv" add Castle and "^Cva" add "Main Castle",but can not work
This does not work because castles are base terrains, not overlays.
ERROR1025 wrote: January 7th, 2024, 4:49 pm Village+Flat→Village+Castle+Flat
Forest+Flat→Forest+Castle+Flat
Flat→Flat+Castle
Each hex can have one base, and one overlay. That is the limit. Since castle and flat are both bases, you can't have both of them together. That combination does not exist in any map. Forest and village are both overlays, so you can't put them together, but you can put either one on top of castle or flat. You can use the map editor with the terrain codes visible to see this information. (To see something like Cv^Fp in the map editor, place the castle then hold [Shift] while placing the forest on it.)
Ravana wrote: January 7th, 2024, 4:56 pm test which tag is not working, and verify that documentation allows them to be used that way
That is how I do it.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

beetlenaut wrote: January 7th, 2024, 6:53 pm
ERROR1025 wrote: January 7th, 2024, 4:49 pm Oh,I try use "^Cv" add Castle and "^Cva" add "Main Castle",but can not work
This does not work because castles are base terrains, not overlays.
ERROR1025 wrote: January 7th, 2024, 4:49 pm Village+Flat→Village+Castle+Flat
Forest+Flat→Forest+Castle+Flat
Flat→Flat+Castle
Each hex can have one base, and one overlay. That is the limit. Since castle and flat are both bases, you can't have both of them together. That combination does not exist in any map. Forest and village are both overlays, so you can't put them together, but you can put either one on top of castle or flat. You can use the map editor with the terrain codes visible to see this information. (To see something like Cv^Fp in the map editor, place the castle then hold [Shift] while placing the forest on it.)
Ravana wrote: January 7th, 2024, 4:56 pm test which tag is not working, and verify that documentation allows them to be used that way
That is how I do it.
Saurgrath.map(in Legend_of_Wesmere) 20.21 is Village+Castle+Flat
data2.map contains the effect I want to achieve
5.1 to 7.1
5.3 to 7.3
5.5 to 7.5
5.7 to 7.7
Is there WML code OR lua OR define that can do this without listing all "base terrain" lookup tables?
base ONLY Coastal Reef;Deep Water;Shallow Water;Swamp add Shallow Water+Castle code [Cme]
base ONLY Frozen add Frozen+Castle code [Cva]
base other:Castle code [Cv]
(only change base)
Attachments
data2.map
(2.77 KiB) Downloaded 20 times
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

I am guessing that "Saurgrath" is the map called "Saurian Treasury" in my version. The hex (20,21) is a castle with a village on it. It has the terrain code "Ko^Vd".

You can type the command ":show_terrain_codes" during the game to see that. The map editor also has a button on the top right to show the same codes. You can load the data2.map into the game or editor and check the terrain codes for the effects you want to achieve. None of them will have Village+Castle+Flat because the game doesn't allow it.

Edit: I don't understand the last part of your post, but this is a list of all base terrains if that's what you want.

Code: Select all

Gray Deep Water: Wog
Medium Deep Water: Wo
Tropical Deep Water: Wot
Gray Shallow Water: Wwg
Medium Shallow Water: Ww
Tropical Shallow Water: Wwt
Ford: Wwf
Gray Coastal Reef: Wwrg
Medium Coastal Reef: Wwr
Tropical Coastal Reef: Wwrt
Swamp Water Reed: Ss
Muddy Quagmire: Sm
Green Grass: Gg
Semi-dry Grass: Gs
Dry Grass: Gd
Leaf Litter: Gll
Dark Dirt: Rb
Regular Dirt: Re
Dry Dirt: Rd
Regular Cobbles: Rr
Clean Gray Cobbles: Rrc
Overgrown Cobbles: Rp
Icy Cobbles: Rra
Ice: Ai
Snow: Aa
Desert Sands: Dd
Beach Sands: Ds
Regular Hills: Hh
Dry Hills: Hhd
Dunes: Hd
Snow Hills: Ha
Regular Mountains: Mm
Dry Mountains: Md
Snowy Mountains: Ms
Desert Mountains: Mdd
Basic Stone Floor: Irs
Ancient Stone Floor: Ias
Royal Rug: Icr
Normal Rug: Icn
Cave Rug: Urc
Basic Wooden Floor: Iwr
Old Wooden Floor: Ior
Cave Floor: Uu
Earthy Cave Floor: Uue
Dark Flagstones: Urb
Cave Path: Ur
Mycelium: Tb
Rockbound Cave: Uh
Earthy Rockbound Cave: Uhe
Regular Chasm: Qxu
Earthy Chasm: Qxe
Ethereal Abyss: Qxua
Lava Chasm: Ql
Lava: Qlf
Volcano: Mv
Natural Cave Wall: Xu
Mine Wall: Xuc
Natural Earthy Cave Wall: Xue
Stone Wall: Xos
Straight Mine Wall: Xom
Straight White Wall: Xoi
Clean Stone Wall: Xoc
Ancient Stone Wall: Xoa
Catacombs Stone Wall: Xot
Overgrown Stone Wall: Xof
Void: Xv
Encampment: Ce
Ruined Encampment: Cer
Snowy Encampment: Cea
Orcish Castle: Co
Snowy Orcish Castle: Coa
Human Castle: Ch
Snowy Human Castle: Cha
Elven Castle: Cv
Elven Castle Ruin: Cvr
Winter Elven Castle: Cva
Dwarven Underground Castle: Cud
Dwarven Castle: Cf
Dwarven Castle Ruins: Cfr
Winter Dwarven Castle: Cfa
Ruined Human Castle: Chr
Sunken Human Ruin: Chw
Swamp Human Ruin: Chs
Desert Castle: Cd
Ruined Desert Castle: Cdr
Troll Encampment: Cte
Aquatic Encampment: Cme
Aquatic Castle: Cm
Encampment Keep: Ke
Ruined Encampment Keep: Ker
Tall Encampment Keep: Ket
Snowy Encampment Keep: Kea
Orcish Keep: Ko
Snowy Orcish Keep: Koa
Human Castle Keep: Kh
Snowy Human Castle Keep: Kha
Elven Castle Keep: Kv
Elven Keep Ruin: Kvr
Winter Elven Keep: Kva
Dwarven Underground Keep: Kud
Dwarven Castle Keep: Kf
Dwarven Ruin Keep: Kfr
Winter Dwarven Keep: Kfa
Ruined Human Castle Keep: Khr
Sunken Human Castle Keep: Khw
Swamp Human Castle Keep: Khs
Desert Keep: Kd
Ruined Desert Keep: Kdr
Aquatic Encampment Keep: Kme
Troll Encampment Keep: Kte
Aquatic Keep: Km
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Post Reply