Changing the image of a unit
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.
Changing the image of a unit
With Wesnoth 1.12, this can simply be done by changing the value of $unit.image.
But with Westnoth 1.14.16 the behaviour is different: whatever the value of the "image" key in the description of the unit, the one which is displayed is the one from the definition of the unit type. This is true even when changing the content of the save file.
I don't understand why this change of behaviour (why keep the "image" key in the unit if it is not used), and I don't know how to circumvent it.
But with Westnoth 1.14.16 the behaviour is different: whatever the value of the "image" key in the description of the unit, the one which is displayed is the one from the definition of the unit type. This is true even when changing the content of the save file.
I don't understand why this change of behaviour (why keep the "image" key in the unit if it is not used), and I don't know how to circumvent it.
My campaign, Bloodlust, is is need of feedback!
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Changing the image of a unit
The current animation system is much more powerful than it was in the past, so it is more complicated as well. (The
The only way to change the image of a unit after it is loaded is to pass it an object that adds an animation. (See EffectWML for more information.) Adding a single-frame standing animation should change the base image. However, if the unit already had a standing animation, I think you will have to add some filters or a base_score to make sure your new standing animation is chosen over the old one every time--otherwise it will be random. (AnimationWML has details on that.)
If it's possible in your case, it would probably be easier to change the unit_type so that it is reloaded. You can use
image
tag seems to be used to build the default animations when the unit is loaded for the first time. Someone can correct me if that's wrong.)The only way to change the image of a unit after it is loaded is to pass it an object that adds an animation. (See EffectWML for more information.) Adding a single-frame standing animation should change the base image. However, if the unit already had a standing animation, I think you will have to add some filters or a base_score to make sure your new standing animation is chosen over the old one every time--otherwise it will be random. (AnimationWML has details on that.)
If it's possible in your case, it would probably be easier to change the unit_type so that it is reloaded. You can use
[base_unit]
to make a clone of another unit with nothing but the image changed.Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Changing the image of a unit
I have changed image by adding image mod "O(0) followed by BLIT. It seems to still work in 1.15.15.
Re: Changing the image of a unit
Thank you for the answers.
I want to have a unit_type with no image, and the image dynamically changed when some AMLA have been taken.
You gave me two techniques that could allow me to reach this goal.
If it does not work, I will come again to ask additional questions.
If it works, I will come back to thank you again!
I want to have a unit_type with no image, and the image dynamically changed when some AMLA have been taken.
You gave me two techniques that could allow me to reach this goal.
If it does not work, I will come again to ask additional questions.
If it works, I will come back to thank you again!
My campaign, Bloodlust, is is need of feedback!
Re: Changing the image of a unit
Code: Select all
[effect]
apply_to=image_mod
replace="~O(0)~BLIT($temp.image)"
[/effect]
If the unit_type does not define any image, then the image_mod has apparently no effect.
My campaign, Bloodlust, is is need of feedback!