ai_special=guardian seems don't works [solve]

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
Cluric
Posts: 16
Joined: October 6th, 2012, 7:57 pm

ai_special=guardian seems don't works [solve]

Post by Cluric »

Hi, it's me again :)

An other problem with my WML code.

I've a bridge, and I create 2 unit near to this bridge to "defend" the acces. For that I try to use "ai_special=guardian" but...

I try two different way :
("Engeance" is a created unit witch works correclty, I don't thinks the problem is here)
TRY NUM 1 :

Code: Select all

(In the SIDE section)
{NAMED_GENERIC_UNIT 2 Engeance 45 6 garde1 "Garde du pont"}
{NAMED_GENERIC_UNIT 2 Engeance 46 8 garde2 "Garde du pont"}
And next :

Code: Select all

[event]
        name=prestart
        [objectives]
            #objectives are defined here
        [/objectives]
		# Modification of the two guards to made them static
		[modify_unit]
			[filter]
				id=garde1, garde2
			[/filter]
			# hitpoints=5
			ai_special=guardian
		[/modify_unit]
    [/event]
And TRY NUM 2

Code: Select all

# Units --> protect the bridge
		[unit]
			side=2
			type="Engeance"
			id=garde1
			name"Garde du Pont"
			x=45
			y=6
			random_traits=yes
			ai_special=guardian
		[/unit]
		[unit]
			side=2
			type="Engeance"
			id=garde2
			name="Garde du Pont"
			x=46
			y=8
			random_traits=yes
			ai_special=guardian
               [/unit]
Your help is welcome ! :)
Last edited by Cluric on October 15th, 2012, 8:47 am, edited 2 times in total.
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: ai_special=guardian seems don't works

Post by pyrophorus »

Cluric wrote: I've a bridge, and I create 2 unit near to this bridge to "defend" the acces. For that I try to use "ai_special=guardian" but...
But what ? Which behavior do you expect exactly ?

Friendly,
Cluric
Posts: 16
Joined: October 6th, 2012, 7:57 pm

Re: ai_special=guardian seems don't works

Post by Cluric »

Well I wanted these units no longer move. But when I run the script, they move as soon as I approach to them

I hear about the GUARDIAN Macro, so I modify the first code like this :

Code: Select all

  # Units --> protect the bridge
	{NAMED_GENERIC_UNIT 2 Engeance 45 6 garde1 "Garde du pont"}
	{GUARDIAN}
	{NAMED_GENERIC_UNIT 2 Engeance 46 8 garde2 "Garde du pont"}
	{GUARDIAN}
Then the units still move :(

I link the stderr file, if It can help (however I don't think so because messages seem to have nothing to do with the topic
Battle for Wesnoth v1.10.1
Started on Mon Oct 15 10:13:17 2012

Automatically found a possible data directory at C:/Users/Fred/Desktop/Wesnoth

Data directory: C:/Users/Fred/Desktop/Wesnoth
User configuration directory: C:/Users/Fred/Documents/My Games/Wesnoth1.10
User data directory: C:/Users/Fred/Documents/My Games/Wesnoth1.10
Cache directory: C:/Users/Fred/Documents/My Games/Wesnoth1.10/cache
Checking video mode: 1024x768x32...
setting mode to 1024x768x32
20121015 10:13:21 error filesystem: Trying to open file with empty name.
20121015 10:13:31 warning unit: Unknown attribute 'genre' discarded.
20121015 10:13:31 warning unit: Unknown attribute 'recruitment_ignore_bad_combat' discarded.
20121015 10:13:31 warning unit: Unknown attribute 'recruitment_ignore_bad_combat' discarded.
20121015 10:13:32 warning unit: Unknown attribute 'recruitment_ignore_bad_combat' discarded.
20121015 10:13:48 error ai/actions: Return value of AI ACTION was not checked. This may cause bugs!
User avatar
Elvish_Hunter
Posts: 1600
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: ai_special=guardian seems don't works

Post by Elvish_Hunter »

Cluric wrote:Then the units still move
Because ai_special=guardian does not block the unit. It merely stops it from moving until it can attack an enemy unit.
If you want to completely forbid a unit to move, you need to set its max_moves to 0. You have several ways:
1) modify directly the max_moves variable, either while creating the unit, or with [store_unit], or with [modify_unit]:

Code: Select all

{NAMED_GENERIC_UNIT 2 Engeance 45 6 garde1 "Garde du pont"}
[+unit]
    moves=0
    max_moves=0
[/unit]
2) assigning it an object that sets moves to 0:

Code: Select all

{NAMED_GENERIC_UNIT 2 Engeance 45 6 garde1 "Garde du pont"}
[+unit]
    [modifications]
        [object]
            duration=forever
            silent=yes
            [effect]
                apply_to=movement
                set=0
            [/effect]
        [/object]
    [/modifications]
I'd recommend the first option if you want to be able to allow again movement in a later time, and the second if the unit may level up and you do not want to lose its block.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Cluric
Posts: 16
Joined: October 6th, 2012, 7:57 pm

Re: ai_special=guardian seems don't works

Post by Cluric »

Okay, once again it was me who had misunderstood what I thought to. I know however, that the code does exactly what it says, and yet I always come back crying "does not work, help me" :)

Thank you for your detailed response, I will test it immediately.

EDIT : Fine, your code works on the first try ! I make a macro for reuse in the future, it's perfect
User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: ai_special=guardian seems don't works [solve]

Post by SkyOne »

Ah, I see...
Put "passive_leader=yes", please, on your file of this one: http://forums.wesnoth.org/viewtopic.php ... 26#p539826 I edited it as "no" because I thought you wanted the leader, Chef Trolloc, to behave like the ai_special=guardian. (but you probably did it already, I guess.) Elvish_Hunter probably recommends to do the first one on my post, though.

You can actually use the same thread to ask multiple questions by editing the topic title & adding sub-titles if necessary. (zookeeper doesn't mind AFaIK because he is a nice person, but ex-Forum Emperor mentioned it, and I support his opinions on the forums...)

(this post has been edited to add words.)
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
Post Reply