Graziani WML Questions

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
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Graziani WML Questions

Post by Graziani »

Hi everyone,

i'm stuck with this:

In my campaign, an ai unit is protecting an area with an object. I don't want this unit to leave the object area. I know this quote:

[avoid]
x,y=1-25,1-60
[/avoid]

but this quote is seemed to be placed in the [side] code. How can i do?


And i have a question about replace a unit by another when the first one dies.
I would like that in the hex he dies, another unit appears.


Thanks in advance!
Last edited by Graziani on December 26th, 2013, 3:02 pm, edited 2 times in total.
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
aquileia
Inactive Developer
Posts: 120
Joined: August 25th, 2012, 5:13 pm

Re: Force a specific ai unit to stay in a area -- Replace a

Post by aquileia »

You might be interested in
http://wiki.wesnoth.org/Practical_Guide ... I_Behavior

or more specific:
http://wiki.wesnoth.org/Micro_AIs#Guardian_Micro_AIs

There are several Guardian Micro AIs, you probably want the "stationed guardian" or the "zone guardian". If you want to see these in action, their author mattsc wrote an addon (AI Modification Demos) showcasing them. This is also helpful if you prefer to alter copied code instead of writing from scratch.
User avatar
Adamant14
Posts: 962
Joined: April 24th, 2010, 1:14 pm

Re: Force a specific ai unit to stay in a area -- Replace a

Post by Adamant14 »

If you want to use the [avoid] tag, then can you use it like in this example:

Code: Select all

	[side]
		type=Death Knight
		id="Lord Menachem"
		name= _ "Lord Menachem"
		side=7
		canrecruit=yes
		recruit= Skeleton, Skeleton Archer, Revenant, Deathblade
		team_name=Mal Kazur
		user_team_name= _ "Undead (Enemy)"
		facing=nw
		controller=ai
		[ai]
			[avoid]
				[not]
					x=6-15
					y=6-15
				[/not]
			[/avoid]
		[/ai]
	[/side]
In this example side=7 will only move within the coordinates set inside the [not] tag.


To answer your second question:

Code: Select all

	[event]
		name=die
		[filter]
			# add here a filter criterion for the unit that you want to replace ( id or type or race for example)
		[/filter]
		[filter_second] # the filter_second is optional, you can remove it if you don't need it
			# add here a filter criterion for the killer unit ( id or type or race for example)
		[/filter_second]
		[kill]
			x,y=$x1,$y1
			animate=no  # or yes if you like
		[/kill]
		[unit]
			type= # add here the type you want
			side= # add here the side you want
			x,y=$x1,$y1
		[/unit]
	[/event]
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: Force a specific ai unit to stay in a area -- Replace a

Post by SkyOne »

Graziani wrote:In my campaign, an ai unit is protecting an area with an object. I don't want this unit to leave the object area. I know this quote:

[avoid]
x,y=1-25,1-60
[/avoid]

but this quote is seemed to be placed in the [side] code. How can i do?
What version of BfW you are creating the campaign?
I checked your other posts, but I don't see the obvious hint on them. If you are on 1.11.7, what aquileia suggests is probably the best. (if you have questions, you can ask mattsc here.)

If you are on 1.10.x, I think installing "ai_special=guardian" in the [unit] tag helps you. But the unit just stays on the hex in the case until the enemy is in the attackable range.

If you really want to use the [avoid] tag (like what Adamant14 says), you might have to add another [side] for the unit with "no_leader=yes", I think.


P.S. when you have several questions in a short time, you can use the same thread, like tekelili does, instead of creating multiple threads. We can always edit the posts and the topic title by using the edit button, located at right bottom.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Force a specific ai unit to stay in a area -- Replace a

Post by Graziani »

I'm using BFW 1.10.6 for now. I tried the ai_guardian it seems to work.

And yes, i'm spamming the forum with my topics sorry for that i will do like tekkeli!


Like always, community give very quickly answers and sincerely, big thanks to you
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani XML Questions

Post by Graziani »

Hi again,

In my campaign, there is a level where if you lose more than a certain number of villages, it's a defeat (like lvl3 in UTBS)

I tried to understand how works the utbs code, and i don't really get it...

I just want that if the player lose x villages = defeat , and in the same time each time he lose 1 village, a speech occurs (or other event)...

Help?

Thanks in advance
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Graziani XML Questions

Post by 8680 »

Graziani wrote:I just want that if the player lose x villages = defeat , and in the same time each time he lose 1 village, a speech occurs (or other event)...
Have you tried something like this?

Code: Select all

[event]
    name=prestart
    {VARIABLE villages_lost 0}
[/event]

[event]
    ## Note that this literally only checks how many villages have been
    ## *lost* — it doesn’t care whether any of those villages have since
    ## been recaptured.
    name=capture
    first_time_only=no
    [filter_condition]
        {VARIABLE_CONDITIONAL owner_side equals 1}
    [/filter_condition]
    {VARIABLE_OP villages_lost add 1}
    [if]
        {VARIABLE_CONDITIONAL villages_lost less_than 5}
        [then]
            [message]
                id=Konrad
                message= _ "We have lost a village! If we lose five villages, we will be defeated!"
            [/message]
        [/then]
        [else]
            [message]
                id=Konrad
                message= _ "We have lost five villages! We are defeated!"
            [/message]
            [endlevel]
                result=defeat
            [/endlevel]
        [/else]
    [/if]
[/event]

[event]
    name=victory
    {CLEAR_VARIABLE villages_lost}
[/event]
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Graziani XML Questions

Post by beetlenaut »

8680 wrote:## Note that this literally only checks how many villages have been
## *lost* — it doesn’t care whether any of those villages have since
## been recaptured.
If you do need to keep track of recaptures, you could use a capture event in another way. On every capture event, store the locations that have owner=1 in in a variable like side_1_villages. Then, side_1_villages.length will contain the number of villages owned by side 1. Use 8680's code to handle the messages, or use a switch/case (or a set of if statements) to do actions based on the current number of villages.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Thanks a lot, it works perfectly!




Another question;

To clean my campaign files, i would like to create a Deaths files in my utils folder.
In this file, i want to put all my main characters last breath to clean more my scenarios CFG.

How does that work? Do i have to specifiy to the Main CFG that the death file exist or all works properly without work?
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Graziani WML Questions

Post by Dugi »

How does that work? Do i have to specifiy to the Main CFG that the death file exist or all works properly without work?
I don't understand what all works properly without work means, but I think that this is what you want to read:

If the file simply contains several [event] tags, you can directly add it into the scenarios, including a file like this: {~add-ons/My_Awesome_Campaign/deaths.cfg}
You can also use it as a macro, therefore placing a macro definition into the file (the usual #define DEATHS ... #enddef clause), making the file load, that is linking the file in _main before the scenarios like this: {~add-ons/My_Awesome_Campaign/utils.cfg}, and then you have to mention the name of the macro in all scenarios, using the usual {DEATHS} syntax.
There is a way to do that without placing anything into the scenarios, but it's far harder to do and can cause unexpected trouble (even to other people).

Keep on mind that macros and other usual ways of separating parts of code used many times into additional files does not optimalise anything (same time to load, same RAM usage), it just shortens the text, so that it might be easier to read for humans (not necessarily, you can use this also to hide pieces of code into annoyingly many places, obfuscating it).
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Thank you, i think that is too much work for few results. I will see.


I have now an [ai] question.
In one of my scenario, there are a lot of bats and other weak creatures. They don"t attack my characters because they are too strong for them.
But i need to force them attack the player.

Is that possible?
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Graziani WML Questions

Post by Dugi »

If you have tried aggression=1.0 and it didn't help, it might be quite a problem.
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Thanks, it was my fault, i wrote wrong code.


Mmmmh... I know i have a lot of questions but...

Shroud is easy to use. But fog... I want to speak about fog. I know there is a macro to remove fog.
But is that possible to remove fog from a certain place?
I mean permanently?
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
JaMiT
Inactive Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Graziani WML Questions

Post by JaMiT »

Graziani wrote:I know there is a macro to remove fog.
But is that possible to remove fog from a certain place?
I mean permanently?
In 1.10, no, not without leaving a fog-clearing unit in that place (which has the drawback of leaving a unit in that place).

In 1.11, there is [lift_fog].
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Thanks a lot :D .

I changed my campaign name from french to english and it won't launch anymore (sad :doh: ^^).
Error says it can't find my first scenario.
Do you see an error here?

Code: Select all

#textdomain wesnoth-frab
[textdomain]
    name="wesnoth-frab"
[/textdomain]

# wmlscope: set export=no
[campaign]
    id=De_rocs_et_de_sang
    icon="data/add-ons/From_rocks_and_blood/images/units/trolls/godug.png~RC(magenta>red)"
    image="data/add-ons/From_rocks_and_blood/images/campaign_image.png"
    name= _ "From Rocks And Blood"
    abbrev= _ "FRAB"
    rank=15
    first_scenario="01_Un_nouveau_chef"
    difficulties="NORMAL,HARD"
    difficulty_descriptions={MENU_IMG_TXT2 "units/trolls/grunt.png~RC(magenta>red)" _"Warrior" _"(Normal)"} + ";" +
    {MENU_IMG_TXT2 "units/trolls/warrior.png~RC(magenta>red)" _"Leader" _"(Challenging)"}
    define="CAMPAIGN_FROM_ROCKS_AND_BLOOD"
    description=_ "Il est temps d'unifier les trolls et de faire taire les querelles incessantes avec les voisins! Que ce soit pacifiquement ou dans le sang n'a plus d'importance!

" + _"(Advanced level, 23 scenarios.)"

[/campaign]

#ifdef CAMPAIGN_FROM_ROCKS_AND_BLOOD
[binary_path]
    path=data/add-ons/From_rocks_and_blood
[/binary_path]
[+units]
	{~add-ons/From_rocks_and_blood/units/}
[/units]
{~add-ons/From_rocks_and_blood/utils}
{~add-ons/From_rocks_and_blood/scenarios}
{~add-ons/From_rocks_and_blood/maps}
#endif

Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
Post Reply