Changing unit type of a Leader?

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.
quantumfleet
Posts: 38
Joined: June 17th, 2011, 1:26 am

Re: Changing unit type of a Leader?

Post by quantumfleet »

I have a new question, related to my previous one: How can I remove the undead trait, or at least its effects? Transforming a unit doesn't remove any of its traits, including the undead trait, and I can't find anything on the wiki about removing traits. I tried adding a different trait that added something that looks like this:

Code: Select all


    [effect]
    apply_to=status
    remove=not_living
    [/effect]

But it doesn't remove the immunity to poison, drain, plague effect of the undead trait. (Do new abilities always get applied before preexisting ones? Because if so, that not_living bit gets reapplied after my new trait anyway.)
Currently working on various ideas using 1.9.8.9
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Changing unit type of a Leader?

Post by Sapient »

You can remove the traits by storing the unit into a variable, using CLEAR_VARIABLE on the traits, then unstoring the unit variable. The attribute generate_traits=yes will cause new traits appropriate to the unit type to automatically be generated.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
quantumfleet
Posts: 38
Joined: June 17th, 2011, 1:26 am

Re: Changing unit type of a Leader?

Post by quantumfleet »

I'm not entirely sure how, but this code intended to get rid of all traits (especially undead) managed to duplicate them :hmm:

Code: Select all

[store_unit]
		[filter]
		side={SIDE}
		canrecruit=yes
		[/filter]
		variable=leader
		kill=yes
	[/store_unit]
		{CLEAR_VARIABLE leader.modifications.trait.id}
		{CLEAR_VARIABLE leader.modifications.trait.effect.add}
	[unstore_unit]
	variable=leader
	[/unstore_unit]
Currently working on various ideas using 1.9.8.9
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Changing unit type of a Leader?

Post by Sapient »

Try this:

{CLEAR_VARIABLE leader.modifications.trait[0]}

Also, make sure you do this after changing the unit's race to something other than undead.

Disclaimer: untested
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
WhiteWolf
Forum Moderator
Posts: 773
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Changing unit type of a Leader?

Post by WhiteWolf »

Hi

I did not read every post, your problem may be solved.
The problem with modifying only the type, is that the attack, resistance, moves etc. values will remain. But there is another solution:

Code: Select all

[store_unit]
    [filter]
        id=<Your-leaders-id>
    [/filter]
    kill=yes
    variable=leader_stored
[/store_unit]

[unit]
    type=<the new type you want>
    id=$leader_stored.id
    name=$leader_stored.name
    profile=$leader_stored.profile
    side=$leader_stored.side
    experience=$leader_stored.experience
    hitpoints=$leader_stored.hitpoints
    # Max hitpoints and experience will depend on the new type, so it don't have to be set to the original value
    x=$leader_stored.x
    y=$leader_stored.y
    canrecruit=yes
    # In theory, the leader don't have any traits, so there's no need of copying them
[/unit]
    
{CLEAR_VARIABLE leader_stored}

And for removing and creating traits, there is a macro I wrote (of course not by only myself, I got lots of help from others):
Spoiler:
Spoiler:
Main UMC campaigns: The Ravagers - now for 1.18, with even more bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Post Reply