passive_leader Question

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
aelius
Posts: 497
Joined: August 30th, 2004, 8:07 pm
Location: Virginia, USA

passive_leader Question

Post by aelius »

I'm attemtping to create a side 2 leader that simply sits there until your hero moves next to him, at which point they will talk. The problem I am having is that the side 2 leader keeps wandering off. In the side 2 [side] tag I have the following:

Code: Select all

	[ai]
		passive_leader=yes
	[/ai]
which I think is the correct code? I wonder if the fact that I change his keep into grassland in the pre-start event is interfering with the passive_leader tag? Anyone with good success using passive_leader in 1.1.1?

- b.
La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever. - Antoine de Saint Exupery (of course)
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

I'm not sure about passive_leader, except that I once had some similar problems with it. More reliable would be to use ai_algorithm=idle_ai, but that would make the whole side be completely idle, which might not be what you want. Other way could be to put a name=side turn event which sets the movement points (unit.moves) of the unit to 0 every time it's side is about to take it's turn.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Re: passive_leader Question

Post by scott »

Try this:

Code: Select all

[event]
name=side turn

[store_unit]
variable=passive_store
[filter]
description=leadername
[/filter]
[/store_unit]

{VARIABLE passive_store.moves 0}

[unstore_unit]
variable=passive_store
[/unstore_unit]

{CLEAR_VARIABLE passive_store}

[/event]
Works fine. You can surround the innards with an [if] statement if you want to turn it off after a point. If you don't want it to recruit, you would have to remember to adjust its gold too. I haven't tested it with a leader, but I assume it would still try to recruit.
Hope springs eternal.
Wesnoth acronym guide.
aelius
Posts: 497
Joined: August 30th, 2004, 8:07 pm
Location: Virginia, USA

Post by aelius »

Well, I thought it worked like a charm. The leader still moves and attacks. The actual code that I use in my scenario is:

Code: Select all


[event]
	name=side turn
	first_time_only=no

	[store_unit]
		variable=passive_store
		[filter]
			description=Ukark
		[/filter]
	[/store_unit]
	
	{VARIABLE passive_store.moves 0}

	{DEBUG_MSG $passive_store.moves}

	[unstore_unit]
		variable=passive_store 
	[/unstore_unit]

	{CLEAR_VARIABLE passive_store}
[/event] 
Adding a debug message and a first_time_only=no. The game reports his movement as 0 at the beginning of his side turn, but he still moves and attacks. I may have to resort to idle_ai...
- b.
La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever. - Antoine de Saint Exupery (of course)
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

I think so. I thought it was working for me on Gryphon Mountain, but I must be mistaken. The movement is wiped out and then immediately restored due to how side_turn works. Sorry.
Hope springs eternal.
Wesnoth acronym guide.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

To disable the movement of your leader, you can do something like this :

Code: Select all

	[event]
		name=prestart
		[object]
			silent=yes
			[filter]
				description=Ukark
			[/filter]
			[effect]
				apply_to=movement
				set=0
			[/effect]
		[/object]
	[/event]
He will be still able to attack...
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Set his current moves in a side turn event. Last I checked, units with 0 moves crash the game.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Elvish Pillager wrote:Set his current moves in a side turn event. Last I checked, units with 0 moves crash the game.
The first thing won't work. The second thing is correct.

I'm trying to see if changing goto_x and goto_y work. A recent bugfix makes these work for AI units.
Hope springs eternal.
Wesnoth acronym guide.
Xan
Inactive Developer
Posts: 258
Joined: August 28th, 2005, 3:05 pm
Contact:

Post by Xan »

scott wrote:
Elvish Pillager wrote:I'm trying to see if changing goto_x and goto_y work. A recent bugfix makes these work for AI units.
Only if he runs out of movement points, otherwise he can just use the rest afterwards.
"It is time people learned about their failures and my successes."
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

So if you set goto_x and goto_y to his current location in a side turn event, he'll still move?
Hope springs eternal.
Wesnoth acronym guide.
Xan
Inactive Developer
Posts: 258
Joined: August 28th, 2005, 3:05 pm
Contact:

Post by Xan »

Since the goto command will be done, the normal ai will use the rest of his moves.
"It is time people learned about their failures and my successes."
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

Elvish Pillager wrote:Last I checked, units with 0 moves crash the game.
Well i tried and it worked fine with me, except the number of movement point was bogus in the status bar.
Post Reply