How to create a fake attack animation during an event?

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
blob
Posts: 22
Joined: January 17th, 2009, 12:33 pm

How to create a fake attack animation during an event?

Post by blob »

In a campaign I am writing, during a particular event, I want one unit to fake attacking another. With that, I mean that the attack animation should show, the defense or hit animation should show, and the associated sound effects should play. I want to be in control of the number of strokes (just one, actually) and whether the attack hits or misses. There should be no floating numbers or actual changes to the units. Consider something like {FAKE_UNIT_MOVE}, only for an attack animation.

Unfortunately, I could not find a macro or something equivalent in WML.

Now, given that the involved units are of specific unit types and even at specific hex coordinates, I could probably do what I want by hiding the units and building the animation via [item] tags. However, this is not particularly future-proof as the animation frames (file names, paths, numbers) might change between Wesnoth versions, so this might work in one particular version of Wesnoth, but not in the next. Similar thing with the sounds.

So, did I miss something, or do I have to do this the awkward way?
The Cost Of Living (1.8): main thread, feedback thread
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: How to create a fake attack animation during an event?

Post by zookeeper »

[animate_unit]. Look how it's used for example in 'Towards the Caves' in SoF.
User avatar
Reepurr
Posts: 1088
Joined: August 29th, 2010, 5:38 pm

Re: How to create a fake attack animation during an event?

Post by Reepurr »

As far as I'm aware, you also need a {MODIFY_UNIT} to change facing. Maybe I just had lots of problems.

Here's a snippet from my old abandoned campaign, where a unit on 4,5 is attacking a unit with an ID of Gun1, with his axe:

Code: Select all

	{MOVE_UNIT x,y=3,8 4 5}
	{MODIFY_UNIT x,y=4,5 facing ne}
	{MODIFY_UNIT x,y=5,5 facing sw}
[animate_unit]
            flag=attack
            [filter]
                x,y=4,5
            [/filter]
            [filter_second]
                id=Gun1
            [/filter_second]
                [primary_attack]
                    name=axe
                [/primary_attack]
            hits=yes
        [/animate_unit]
"What do you mean, "a dwarvish dragonguard with marksman is overpowered"?"

Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
blob
Posts: 22
Joined: January 17th, 2009, 12:33 pm

Re: How to create a fake attack animation during an event?

Post by blob »

Not sure how I could miss the [animate_unit] tag when it's right there in the docs. Either way, works a treat. Thank you very much.
The Cost Of Living (1.8): main thread, feedback thread
User avatar
boru
Posts: 788
Joined: November 19th, 2009, 11:02 pm

Re: How to create a fake attack animation during an event?

Post by boru »

You can put the facing directly into [animate_unit]

Example:
Spoiler:
“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.
Post Reply