New syntax changes have made it in for wesnoth version 1.11.2. If there are problems or more discussion needed, now seems like a good time in the wesnoth development cycle to do so. Below is the history of these changes, you might want to scroll to near the end of the thread.
Hello
After playing around with some animations, I noticed that there is a lot of redundant WML that makes it hard to create new animations or follow what is happening easily.
So I suggest a possible approach to combat this that is backwards compatible with what there is now, along the same line that x and y positioning can be done for placing items/time of day spots/etc. (i.e. x=1-3,6 and y=1,4,5,6 for coords (1,1) (2,4) (3,5) (6,6))
So, how would this work for animations?
Well say you have a macro for MISSILE_FRAME_FIRE_BREATH_N (in animation_utils.cfg). Currently it is:
- Code: Select all • Expand
#define MISSILE_FRAME_FIRE_BREATH_N OFFSET_POSITION
# Animate a projectile for a fire-breath attack.
[missile_frame]
begin=-400
end=100
halo=projectiles/fire-breath-n-1.png:80,projectiles/fire-breath-n-2.png:80,projectiles/fire-breath-n-3.png:80,projectiles/fire-breath-n-4.png:80,projectiles/fire-breath-n-5.png:80
halo_x,halo_y={OFFSET_POSITION}
[/missile_frame]
#enddef
I suggest using square brackets where there is a sequence or comma separated file numbers in file names possible to simplify. This gives:
- Code: Select all • Expand
#define MISSILE_FRAME_FIRE_BREATH_N OFFSET_POSITION
# Animate a projectile for a fire-breath attack.
[missile_frame]
begin=-400
end=100
halo=projectiles/fire-breath-n-[1-5].png:80
halo_x,halo_y={OFFSET_POSITION}
[/missile_frame]
#enddef
See, much better and less prone to error.
I would suggest using square brackets with dash separated sequences or commas for not in sequence frames to simplify halos. This might even be quicker to load as it would just be a c++ expansion after reading the file to the long version we are already accustomed to (cutting out about half the disk reading time on average from looking at the macros). So in all, not much of a change and backwards compatible.
I would suggest that where the square brackets are used for the frame number, they might match to the duration and where the durations are short, just use the last specified one for all the remaining ones. i.e.
- Code: Select all • Expand
halo=projectiles/frame[1-6]:[80,80,70,70,60,60]
So far so good. However, the image and image_diagonal frames could do with some simplifying too. Because the halos don't always match up this requires some effort to make work properly.
I suggest to do the same thing for image and image_diagonal frames and in the c++ code, just pretend that it is reading a series of missile_frame and such whole blocks of WML. Also, make the begin tag comma separatable, making the end the next begin in the list until the actual end which would remain specified. If not fully specified, could just average the remainder to get the proper begin and end times, ignoring any extra ones.
For exmaple the existing FIRE_BURST_SMALL
- Code: Select all • Expand
#define FIRE_BURST_SMALL
[missile_frame]
begin=0
end=75
image="projectiles/fire-burst-small-1.png"
image_diagonal="projectiles/fire-burst-small-1.png"
offset=0.8
[/missile_frame]
[missile_frame]
begin=75
end=150
image="projectiles/fire-burst-small-2.png"
image_diagonal="projectiles/fire-burst-small-2.png"
offset=0.83
[/missile_frame]
[missile_frame]
begin=150
end=225
image="projectiles/fire-burst-small-3.png"
image_diagonal="projectiles/fire-burst-small-3.png"
offset=0.86
[/missile_frame]
[missile_frame]
begin=225
end=300
image="projectiles/fire-burst-small-4.png"
image_diagonal="projectiles/fire-burst-small-4.png"
offset=0.89
[/missile_frame]
[missile_frame]
begin=300
end=375
image="projectiles/fire-burst-small-5.png"
image_diagonal="projectiles/fire-burst-small-5.png"
offset=0.92
[/missile_frame]
[missile_frame]
begin=375
end=450
image="projectiles/fire-burst-small-6.png"
image_diagonal="projectiles/fire-burst-small-6.png"
offset=0.95
[/missile_frame]
[missile_frame]
begin=450
end=525
image="projectiles/fire-burst-small-7.png"
image_diagonal="projectiles/fire-burst-small-7.png"
offset=0.98
[/missile_frame]
[missile_frame]
begin=525
end=600
image="projectiles/fire-burst-small-8.png"
image_diagonal="projectiles/fire-burst-small-8.png"
offset=1.0
[/missile_frame]
#enddef
becomes
- Code: Select all • Expand
[missile_frame]
begin=0,75,150,225,300,375,450,525
end=600
image="projectiles/fire-burst-small-[1-8].png"
image_diagonal="projectiles/fire-burst-small-[1-8].png"
offset=0.8,0.83,0.86,0.89,0.92,0.95,0.98,1.0
[/missile_frame]
*note that I suggest that offset not have any square brackets, as this might be confusing with existing code
If a halo tag is present with square brackets as well as image/image_diagonal, then they are put into separate frames with seaprate halos. So to make this work (i.e. for FAERIE_FIRE) you would have separate frames as now and use the square brackets for the halo (as this is the faster changing of the 2). So if halo is present with square brackets it is expanded to a comma separated list as now, and if image/image_diagonal is present with square brackets, then the whole frame gets duplicated and sequenced.
I've attached an example animation-utils with the changes and it simplifies the code and actually removes half of the charaters in it. Of course this won't work without accompanying changes to the c++ code.
