Animated unit creation

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
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Animated unit creation

Post by doofus-01 »

I'm hoping to have an animation fire as a unit appears. Simply creating the unit, then animating with [animate_unit] looks silly because the unit just stands there for a bit before the animation fires.

It looks like creating the unit to a side's recall list, then [recall]-ing it with "show=yes" fires the animation nicely (with the desired animation assigned to "recruited"), but it also makes them face a random direction.

Code: Select all

[side]
<side info>
[unit]
type=...
id=...
x,y=recall,recall
facing=... <--------- this does nothing
[/unit]
[/side]

[event]
name=start
...
[recall]
id=...
x,y=...
show=yes
[/recall]
...
[/event]
Or something makes them face a random direction, it isn't [recall] behavior that I remember though maybe I just didn't notice.

My questions:

1. Is there a better way to simultaneously put a unit on the map and fire one of its animations.

2. If using the "recruited" animation is the way to go, is there a way to force the unit to face a certain direction? It is tempting to think [unstore_unit] could be helpful, instead of [recall], but it looks like the animation options for that are limited.

3. If this has been done before, and I wouldn't be surprised if it has, does anyone know where?

Thanks.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
User avatar
StDrake
Posts: 996
Joined: July 21st, 2009, 6:50 am

Re: Animated unit creation

Post by StDrake »

well you could make a bit of a cheating animation using [item]s instead and then [unit] or unstoring, would have to try it out to see if it doesn't end up with blinking
Like cats? I've made a whole faction of them to kick ass with!
Don't like cats? I've made a whole faction of them to kick their asses! So everyone's happy :)
Felinian faction is part of the Beyond Southern Hells era
kitties need sprites! art topic here
mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: Animated unit creation

Post by mich »

1. Is there a better way to simultaneously put a unit on the map and fire one of its animations.
You can create a unit on the map with "animate=yes". This will automatically fire the recruit animation. So something like this works

Code: Select all

[unit]
type=...
id=...
x,y=1,1
animate=yes
[/unit]
Unfortunately it seems that when "animate=yes" is used, then "facing=...." doesn't work.....
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Animated unit creation

Post by doofus-01 »

mich wrote:You can create a unit on the map with "animate=yes". This will automatically fire the recruit animation. So something like this works
Now that you mention it, I see that was in the wiki. Though not in a place I would have expected.

But if that doesn't really change the situation, this is a bug?

EDIT: As for the [item] idea, I don't want any looping, and padding it with empty images makes it a more ugly hack. It would be better if facing could be made to work.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
User avatar
StDrake
Posts: 996
Joined: July 21st, 2009, 6:50 am

Re: Animated unit creation

Post by StDrake »

I don't understand what you mean by looping and padding with empty images, you got [delay] markers to control animation speed with [item]s
I used that for my artillery special to show explosions on hit
just made myself this little pretty:

Code: Select all

#define ANIMFRAME IMG X Y DUR
[item]
x,y={X},{Y}
#better halo or image? i think halo goes on top so better that
halo={IMG}
[/item]
[delay]
time={DUR}
[/delay]
[remove_item]
x,y={X},{Y}
halo={IMG}
[/remove_item]
#enddef
play whatever you like with this, set proper facing on a unit storage var and unstore it right after the anim, appearing on unstore is pretty immediate as far as I can tell
It's a workaround, but what can you do if things don't work like they should
Like cats? I've made a whole faction of them to kick ass with!
Don't like cats? I've made a whole faction of them to kick their asses! So everyone's happy :)
Felinian faction is part of the Beyond Southern Hells era
kitties need sprites! art topic here
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Animated unit creation

Post by doofus-01 »

Oh. That's even more of a hack, though it might work. I thought you meant using

Code: Select all

[item]
x,y=...
halo=img1.png:100,img2.png:100, etc.
[/item]
[unit]
<blah>
[/unit]
[remove_item]
<blah>
[/remove_item]
But I'm wary of drawing, delaying, removing, repeat, because Wesnoth often has lags, and I have no faith that it would make it through that smoothly.

Bug Report
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Animated unit creation

Post by zookeeper »

doofus-01 wrote:I'm hoping to have an animation fire as a unit appears. Simply creating the unit, then animating with [animate_unit] looks silly because the unit just stands there for a bit before the animation fires.
You make it sound like that's not a bug, whereas it sure sounds like one to me, unless there's a good reason for the delay.
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Animated unit creation

Post by doofus-01 »

It is possible I was too vague and sloppy with my choice of words. The delay is something like 100-500 milliseconds (I don't know how to time it). It is long enough to clearly see and recognize the base frame, though it is less than one second. It doesn't waste a lot of time, but it does look bad. For an example, imagine the skeleton's (the undead unit) base frame appeared before the recruited animation happened.

I didn't think it was a bug because Wesnoth often has little pauses and lags between actions. At least on all of my installations, past and present.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Animated unit creation

Post by zookeeper »

doofus-01 wrote:It is possible I was too vague and sloppy with my choice of words. The delay is something like 100-500 milliseconds (I don't know how to time it). It is long enough to clearly see and recognize the base frame, though it is less than one second. It doesn't waste a lot of time, but it does look bad. For an example, imagine the skeleton's (the undead unit) base frame appeared before the recruited animation happened.

I didn't think it was a bug because Wesnoth often has little pauses and lags between actions. At least on all of my installations, past and present.
Well, this is a stab in the dark, but maybe you'd like to try this: give the unit type a dummy standing animation, try it with both a short and a long duration and see if the duration matches the delay you're seeing. As far as I know units without a standing animation are given a default one, which could very well be something like 100-500ms in duration. If that's the case, then 1) it's both a bug and 2) you might be able to workaround it by giving the unit a really short standing animation.
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Animated unit creation

Post by doofus-01 »

OK, I can try that. I'll post how it goes tomorrow.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Boucman
Inactive Developer
Posts: 2119
Joined: March 31st, 2004, 1:04 pm

Re: Animated unit creation

Post by Boucman »

in the mean time i'll try to fix the randomness in recruit aniamtions :)
Fight key loggers: write some perl using vim
Boucman
Inactive Developer
Posts: 2119
Joined: March 31st, 2004, 1:04 pm

Re: Animated unit creation

Post by Boucman »

aaand fixed

i'm interested in the delay though...

if you could post a savegame and a way to reproduce, open a bug and assign to me or PM me the number so I assign it myself that would be cool
Fight key loggers: write some perl using vim
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Animated unit creation

Post by doofus-01 »

It happened fairly regularly with my add-on, but I can't always get it to happen now. It does often happen though. If you load this campaign (it's recycled from my FAI post), an elf should show up at the beginning of each turn. It may take a few turns, but you should be able to see it. It is more noticeable with a firedragon, but I don't know if something going into so many hexes should be expected to cause special problems.

Bug report
Attachments
_main.cfg
(11.8 KiB) Downloaded 113 times
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Post Reply