Problem with hero, canrecruit and recall

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
IceFinger
Posts: 5
Joined: May 19th, 2008, 1:30 pm

Problem with hero, canrecruit and recall

Post by IceFinger » May 19th, 2008, 2:20 pm

I'm trying to do something unusual, and it's hard to success.
The idea is simple, the hero of the story is not the "chief" or recruiter, who change many times.
So if I do like the hero in the storie is not really in the [side], like in the [side] I do a different recruiter, and my hero is a classic unit with the tag {IS_HERO}, it's fine only for the forst scenario, because when I change the recruiter in the [side] for the next scenario, I cannot recall the characters from the previous scenario.
If my hero is the main in the [side] with canrecruit=no, and the recruiter is a classic unit with canrecruit=yes, it works well for the first scenario, but the unit with the canrecruit=yes appear in the next scenario, and provoque bug because the two units appear in the same case.
I found a solution with the second, at the end of the scenario I kill the unit with canrecruit=yes. After My hero appear normaly in the next scenario. But I think it's not the best way, so somebody have a solution (maybe if I change the canrecruit at the end, but how to do that ?) If you want a piece of code to see, ask me, but I took example from the main campaign and I don't think it's the problem.
Thank you.

AI
Developer
Posts: 2394
Joined: January 31st, 2008, 8:38 pm

Re: Problem with hero, canrecruit and recall

Post by AI » May 19th, 2008, 3:57 pm

Okay, the first problem you have is with how sides are stored: unless you define save_id in the [side], it uses description (the name of the leader) as the identifier of the side.

Then, if you have a recall list for that side, it tries to recall a unit with canrecruit=yes from it and if successful, completely ignores your leader definition.

So, here's what you want to do:

-In every scenario, add a save_id to the player's side, these must be the same.
-Set no_leader=yes for the player's side in every scenario.
-In the prestart event, recall (or create on scenario 1) your hero.
-In the prestart event, create the recruiter (or MODIFY_UNIT him to set canrecruit=yes)
-In the victory event, either kill or MODIFY_UNIT your recruiter so canrecruit is set to no again.

That should fix most of your issues.

IceFinger
Posts: 5
Joined: May 19th, 2008, 1:30 pm

Re: Problem with hero, canrecruit and recall

Post by IceFinger » May 20th, 2008, 12:30 pm

Thank you for your answer, but it didn't work :?

here it is what I did :

in the side of the first scénario :

[side]
save_id="goodies"
no_leader=yes
controller="human"
{GOLD 60 30 0}
fog="yes"
share_view="no"
shroud="yes"
share_maps="no"
recruit="Elvish Shaman, Elvish Archer, Elvish Fighter"
[/side]
, in the side of the second :

[side]
side="1"
save_id="goodies"
no_leader=yes
controller="human"
{GOLD 60 30 0}
fog="yes"
share_view="no"
shroud="yes"
share_maps="no"
recruit="Elvish Shaman, Elvish Archer, Elvish Fighter"
[/side]

when I create the hero and the recruiter :

[unit]
type="Elvish Druid"
description="Tailia"
user_description=_"Talia"
profile=portraits/Talia.jpg
unrenamable="yes"
x="18"
y="9"
canrecruit="yes"
side="1"
[/unit]
[unit]
type="Elvish Shaman"
profile=portraits/Jalia.jpg
description= "Jalia"
user_description= _ "Jalia"
unrenamable="yes"
{IS_HERO}
side="1"
x="15"
y="9"
[/unit]

after I kill talia when the scenario end.
on the next scenario I recall Jalia.

When I try, the first scenario works well, but the I cannot recall anything on the second, and Jalia not appear.
Do I do something wrong ?

thank you.

vicza
Posts: 238
Joined: January 16th, 2008, 11:40 pm
Location: Moscow

Re: Problem with hero, canrecruit and recall

Post by vicza » May 20th, 2008, 3:28 pm

If you want Jalia to be your leader in the 2nd scenario, in the 1st write:
save_id="Jalia"

To give her recruiting write something like:

Code: Select all

    
		[store_unit]
		[filter]
			description=Jalia
		[/filter]
			kill=no
			variable=stored_Jalia
		[/store_unit]
		[set_variable]
			name=stored_Jalia.canrecruit
			value=yes
		[/set_variable]

		[unstore_unit]
			variable=stored_Jalia
		[/unstore_unit]

		{CLEAR_VARIABLE stored_Jalia}


IceFinger
Posts: 5
Joined: May 19th, 2008, 1:30 pm

Re: Problem with hero, canrecruit and recall

Post by IceFinger » May 20th, 2008, 4:17 pm

That's not I wanted to do, but thanks to you I understood how to change the parameters of the units, and I found a good solution :

The hero is in the size, with can recruit=no. After I create a unit witch can recruit.
At the end, I set canrecruit=no to this unit.
At the next scenario I do the same side, but with canrecruit=yes, I recall what I want, and after I set can recruit=no. After that I can recall, or create a new unit which is able to recruit (that's what I want).
Thank you both, now I can continue. :wink:

Post Reply