Attack Animation
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.
Attack Animation
I have carefully looked over the recent posts here regarding animation and tried to glean what I can from them. Unfortunately as a novice coder, I need a bit more guidance.
I am trying to code what ought to be a simple animation of two characters attacking each other. I suppose it would be considered a "cutscene" although it is a prelude to an actual battle scenario, not a separate scenario comprised of only talk and animation.
What I want to have happen is, a goblin ("Terro") approaches, attacks a knight ("Shining"), the knight attacks in response and kills the goblin. I have tried different ways to code this but it always comes out the same way. All animations are assigned to the goblin unit while the knight unit remains stationary.
The goblin unit is doing (mostly) what I ask it to do. He doesn't actually attack .. it sort of looks like he's defending but the major problem is the knight does nothing.
I'd appreciate any help .. the rest of the scenario works pretty well, it's only this animation thing that's really a problem.
I am trying to code what ought to be a simple animation of two characters attacking each other. I suppose it would be considered a "cutscene" although it is a prelude to an actual battle scenario, not a separate scenario comprised of only talk and animation.
What I want to have happen is, a goblin ("Terro") approaches, attacks a knight ("Shining"), the knight attacks in response and kills the goblin. I have tried different ways to code this but it always comes out the same way. All animations are assigned to the goblin unit while the knight unit remains stationary.
Code: Select all
[animation]
apply_to=myanimation
flag=attack
with_bars=no
[filter]
id=Terro
[/filter]
[primary_attack]
name=spear
range=melee
[/primary_attack]
hits=yes
[animate]
flag=attack
[filter]
id=Shining
[/filter]
[facing]
x,y=4,6
[/facing]
[primary_attack]
name=sword
[/primary_attack]
[/animate]
[/animation]
[move_unit_fake]
type=Goblin Spearman
side=1
x=1,4
y=1,6
[/move_unit_fake]
[unit]
type=Goblin Spearman
id=Terro
name= _ "Terro"
side=1
x=4
y=6
facing=se
[/unit]
[animate_unit]
flag=myanimation
[/animate_unit]
[kill]
id=Terro
animate=yes
[/kill]
# Shining faces Clammie
[unit]
id=Shining
facing=se
[/unit]
I'd appreciate any help .. the rest of the scenario works pretty well, it's only this animation thing that's really a problem.
“It is written in my life-blood, such as that is, thick or thin; and I can no other.” - J.R.R. Tolkien
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
Re: Attack Animation
Looks like you're seriously confusing three separate things: how an animation is defined, how an animation is given to a single unit and how the animation is called. If you want to animate two units fighting, using the regular animations they already have, then all you need is [animate_unit]. You don't need to define a new animation nor do you need to give any units any animations.
Check the cutscene of "Towards the Caves" in Sceptre of Fire, it does pretty much exactly what you're saying you want to do. Check out how [animate_unit] works from the wiki so that you understand how it works. Bookmark http://wiki.wesnoth.org/ReferenceWML if you haven't already, and always keep it open when writing WML.
Check the cutscene of "Towards the Caves" in Sceptre of Fire, it does pretty much exactly what you're saying you want to do. Check out how [animate_unit] works from the wiki so that you understand how it works. Bookmark http://wiki.wesnoth.org/ReferenceWML if you haven't already, and always keep it open when writing WML.
Re: Attack Animation
Zookeeper, thanks for your speedy reply. Yes, the SoF scenario is almost exactly what I want ... I originally started with code similar to that, and when it didn't work, began adding more and more to it in hopes of a miracle. After looking at this excellent example, I've scaled my code back to exactly what is in SoF. Unfortunately, I have the same result .. my goblin moves, and my knight doesn't. Knight's bar won't hide, knight won't defend himself, knight won't face attacker, knight won't attack, knight won't face other direction after attack. I must have made some grave error earlier in my coding (or in a previous life, perhaps).
I have spent a lot of time with the wiki recently but a lot of the definitions could be improved. The explanation for [animate_unit] is a good example:
I'm sort of stuck now. Trying a few tweaks, but honestly I have no idea why one sprite will obey and the other won't.
I have spent a lot of time with the wiki recently but a lot of the definitions could be improved. The explanation for [animate_unit] is a good example:
Code: Select all
[animate_unit]: Uses an animation of a unit to animate it on screen (if the unit has the corresponding animation).
“It is written in my life-blood, such as that is, thick or thin; and I can no other.” - J.R.R. Tolkien
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
Re: Attack Animation
That doesn't surprise me; you are not the first one not getting wml animations right. As a matter of fact, none (!!!) of the animations were correct in 1.7 mainline scenarios, so even experienced designers are unable to write them properly. (Thanks to Anonymissimus for tracking and fixing all of them.) The engine is anal with respect to how you specify an animation; if it isn't exactly what it expects, nothing will happen.boru wrote:I have no idea why one sprite will obey and the other won't.
So, be sure to have "flag=attack" or "=defend" in [animate_unit] and each [animate] subtags. Be sure to spell "hits=yes/no/kill" and not just "hit=..." (and be sure to put it). Look at the .cfg files describing the units. If they are using [filter_attack] tags (resp [filter_second_attack]) in animations, you have to use [primary_attack] tags (resp [secondary_attack]). And the other way around, if they don't, you have to remove them.
Hope it helps. If it doesn't, post your code.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Attack Animation
In my first post in this thread
http://forums.wesnoth.org/viewtopic.php ... on#p409943
is a list of mainline scenarios with [animate_unit] which should now (latest dev version) all have correct syntax (due to the work by silene and me...).
I've improved the wiki descriptions after I had done that stuff, it was REALLY cryptic before. Feel free to improve the descriptions further if you still don't understand them.
http://forums.wesnoth.org/viewtopic.php ... on#p409943
is a list of mainline scenarios with [animate_unit] which should now (latest dev version) all have correct syntax (due to the work by silene and me...).
I've improved the wiki descriptions after I had done that stuff, it was REALLY cryptic before. Feel free to improve the descriptions further if you still don't understand them.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: Attack Animation
Thanks to silene and Anon (and thanks again to zookeeper) for helping me through this. After a few hours, I was able to put together an acceptable result. Units still won't defend, but my previously lethargic knight will now turn and whack that goblin with gusto. I then added another [animate_unit] tag to turn the knight back in the proper direction. Overall it looks pretty good.
Would it help if I reported a WML bug in "[animate] flag=defend"?
The "value" key for "[animate_unit] flag=attack" doesn't seem to inflict any damage. Either that, or I'm implementing it incorrectly. Is there an example where the value key works in attack animations? UtBS Final Confrontation uses [store_unit] to inflict damage during its battle animation. None of the examples Anon mentions use the value key.
Anon, I appreciate what you've done for the wiki and I think there is still room for improvement. Once I'm at a level where I more fully understand WML, I will do what I can to pitch in.
Would it help if I reported a WML bug in "[animate] flag=defend"?
The "value" key for "[animate_unit] flag=attack" doesn't seem to inflict any damage. Either that, or I'm implementing it incorrectly. Is there an example where the value key works in attack animations? UtBS Final Confrontation uses [store_unit] to inflict damage during its battle animation. None of the examples Anon mentions use the value key.
Anon, I appreciate what you've done for the wiki and I think there is still room for improvement. Once I'm at a level where I more fully understand WML, I will do what I can to pitch in.
“It is written in my life-blood, such as that is, thick or thin; and I can no other.” - J.R.R. Tolkien
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
Re: Attack Animation
No, please post your animation here first so that we can check that the bug isn't in your code.boru wrote:Would it help if I reported a WML bug in "[animate] flag=defend"?
It isn't supposed to. The value= key is just there for choosing animations. If the animation only works for some values and you don't provide such a value, the animation won't be displayed. (Though I have no idea why someone would make an animation that is displayed only for 5 damage hits, but not for 4 or 6.)boru wrote:The "value" key for "[animate_unit] flag=attack" doesn't seem to inflict any damage.
Re: Attack Animation
Thanks for explaining that, I'll use the method from UtBS then.silene wrote:No, please post your animation here first so that we can check that the bug isn't in your code.boru wrote:Would it help if I reported a WML bug in "[animate] flag=defend"?
Okay, here goes:
Code: Select all
[animate_unit] flag=attack with_bars=no [filter] id=Terro [/filter] [primary_attack] name=spear range=ranged [/primary_attack] hits=yes value=1 # theoretically, value_second will make Terro throw his spears twice ... (development verson only). Right now he only throws once. value_second=2 [animate] # Shining does not defend or turn and his green bar stays :( flag=defend # I tried this with [filter] tag as well ... does not seem to work either way [filter_second] id=Shining [/filter_second] with_bars=no [facing] [filter] id=Terro [/filter] [/facing] hits=yes value=1 [/animate] [/animate_unit]
It isn't supposed to. The value= key is just there for choosing animations. If the animation only works for some values and you don't provide such a value, the animation won't be displayed. (Though I have no idea why someone would make an animation that is displayed only for 5 damage hits, but not for 4 or 6.)boru wrote:The "value" key for "[animate_unit] flag=attack" doesn't seem to inflict any damage.
“It is written in my life-blood, such as that is, thick or thin; and I can no other.” - J.R.R. Tolkien
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
Re: Attack Animation
Key value_second= is not the amount of swings, it is the swing number (and again, it is only for filtering purpose). Filtering goes in [filter], even for nested animations. Also, keep in mind that a defense animation is just a single parry/dodge image, so it may just be that you missed it. By the way, what is the unit type of Shining?
Re: Attack Animation
Shining is a knight. As you recommended, I did check the Horse_Knight.cfg file to see, knights do have a defense animation. It's a frame where the horse rears up and would be hard to miss, since I've tested it dozens of times. On the other hand, maybe I'm lousy at catching these things because I don't see the defense animation triggering in other cutscenes, for example in SoF Toward The Caves, I don't see Thursagan or Durstorn defend.
“It is written in my life-blood, such as that is, thick or thin; and I can no other.” - J.R.R. Tolkien
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.