the KNOCKBACK ability

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.
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: the KNOCKBACK ability

Post by fog_of_gold »

Yes, of course. So @Dixie, use [/specials] and [/attack] instead of [/abilities] and [+attack] and [+specials] instead of [+abilities].
@zookeeper:
It will work for weapon specials.(I even tested it (not this specials itself) with the new version) Why shouldn't it?
Last edited by fog_of_gold on April 9th, 2010, 9:39 pm, edited 1 time in total.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: the KNOCKBACK ability

Post by Dixie »

Well I'll try it out. There are three things I still don't understand about it though:

1) You suggest two tags. Should I put both? Or just the [+special] one? Or what?

2) I suppose it is intentionnal, but what is the logic of putting the [/special] (or attack or ability, whichever) before the [+special]? Shouldn't the slash ("/") tag be used for closing, thus coming after the plus ("+") tag?

3) Why would I in particular need those tags? I've never any specials using those, be it in mainline or other user-made eras. If it makes it work though, why not? But I just don't get it.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: the KNOCKBACK ability

Post by fog_of_gold »

Dixie wrote:[...]1) You suggest two tags. Should I put both? Or just the [+special] one? Or what?
That aren't really tags. You need both:
Spoiler:
2) I suppose it is intentionnal, but what is the logic of putting the [/special] (or attack or ability, whichever) before the [+special]? Shouldn't the slash ("/") tag be used for closing, thus coming after the plus ("+") tag?
Like I said above, it isn't really a tag, I just called it tag. With [+xx], you can add something to last tag of this type. The code, if you add the pieces of macros and files together, may look like following for the [unit_type] tag:
Spoiler:
And the game will change it to this:
Spoiler:
And because these events are in a [unit_type] tag now, they'll be written into the game, too.

I hope you understand now. If not, feel free to ask. Also, look in the mainline ability "feeding". This ability have got this method, too.
3) Why would I in particular need those tags? I've never any specials using those, be it in mainline or other user-made eras. If it makes it work though, why not? But I just don't get it.
Unfortunatly, the game will only notice the events in [scenario], [unit_type] and maybe some less others. Any event tag in another tag will be ignored, even if this tag is also in one of the tags above.
Like above, I hope you understand. If not, feel free to ask.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: the KNOCKBACK ability

Post by Dixie »

Ok, I get that about event tag working only in specific places, and bout the "+" "tags" not really being tags.

I wonder though. In your last post, in the "spoilers", you just did the opposite of what you said just above.

First Spoiler:
[/specials]
[/attack]
[...]
[+attack]
[+specials]
Second and Third spoiler:
[+attack]
[+specials]
{WEAPON_SPECIAL_POISON}
[/specials]
[/attack]
Was that an error?

Also, I notice the feeding ability seems to put the "+" tag before the "/", unless I'm mistaken? See:
Spoiler:
And jsut to make sure, you are telling me to include these "tags" in the ability.cfg file, not in every unit file, right? So I can link it like any other weapon special macro afterwards?

Anyway, I'll try it out and tell you how it goes. Thanks a lot! :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: the KNOCKBACK ability

Post by fog_of_gold »

Dixie wrote: [...]Was that an error?
The ability macro looks in this way, not in the way you thought:
Spoiler:
and the file includes the macro looks like this:
Spoiler:
So everything after [+specials] is already the next special.
Also, I notice the feeding ability seems to put the "+" tag before the "/", unless I'm mistaken? See:
Spoiler:
The [abilities] tag is still within a comment. The same thing with [/abilities]. So ignore these two commands. If I remove every comment, it would look this way:
Spoiler:
And jsut to make sure, you are telling me to include these "tags" in the ability.cfg file, not in every unit file, right? So I can link it like any other weapon special macro afterwards?
Yes you can, just like it's a usually weapon special. Just make sure, that you can't use them in any [effect] (a way to include abilities and weapon specials manually within [event] or [advancement]), just in the [units]-[unit_type]-[abilities] tag.

[edited to correct some mistakes]
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: the KNOCKBACK ability

Post by Dixie »

Victory! The knockback ability now works! This was merely a WML battle, not the war, though, as I've got some more issues to fix. Let's just adress the first (and probably simplest) one in this post. I'll work on the second afterwards.

Here goes: Knockback works... but only on offense, as the original description said. There is no "active_on=" line anywhere, though. I tried adding such a line and leaving the space after the "=" blank, as to imply it's active both on offense and defense (which is what I actually want). That's what the wiki says at least. I placed it just under the [event] tag, along with the "first_time_only=no" line, which seemed like a suitable place to me, since the wiki doesn't precise where it should go. Well, anyway, it still just works on defense. Did I forget something? Is there a line or command the wiki omits that I should be aware of? Are my ambitions impossible?

Here's the code:
Spoiler:
Thanks a lot, people! :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: the KNOCKBACK ability

Post by fog_of_gold »

Well, unfortunatly, it isn't that much easy. If you take a look at EventWML, you'll see, that it'll only be fired, if the unit hits is the attacker. As far as I know, just adding 'defender hits' with a comma after the 'name' key should make it work. If not we'll have to copy the whole event code and change attacker hits to defender hits. Hopefully we haven't to. So to make the code work in the way you want to have it, change the part of the code into this:

Code: Select all

[...]
[event]
        name=attacker hits,defender hits
        first_time_only=no
[...]
I just looked at your 'retreat' specials, and at least one problem was, that you was filtering a location being always blocked by the enemy. This should work (removed every minus from the directions, added our method and added defender hits):
Spoiler:
[edited because I forgot to add [/xx] [+xx]]
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: the KNOCKBACK ability

Post by Dixie »

Hm. You have managed to fix my retreat ability (which was my second issue). However the "name=attacker hits,defender hits" thing doesn't work. The game misinterpretsthe code. Here is what it does:

Say U1 has knockback and attacks U2.
U1 (the attacker) hits = U2 is knocked back. OR U2 (the defender) hits U1 in retaliation, but U2 is still knocked back.
If U2 attacks U1 afterwards, the knockback ability is totally void.

So I don't really know what to do. If I had the choice between either jsut offense or jsut defense, I would pick defense. Would a line saying "active_on=defense" work? What else would you suggest?

I'll continue looking at the event wiki page, just in case.

Thanks again for your concern :)

EDIT:
Could it be possible to do it using an additionnal macro or something using the [filter_second_attack] filter tag, and then inversing the code in the [event] tag or something to make it work on defense? Where would I put such a command? In every [era] tag of my IME_eras.cfg?
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: the KNOCKBACK ability

Post by Dixie »

Double post, sorry to all purists out there. The situation has evolved though, so I figured a double-post was needed.

I must declare... this is a success! I managed to have it work on defense! Yay! :D :mrgreen: :geek: :D

:eng: Here is the code to knockback:
Spoiler:
:eng: Here is the code to retreat:
Spoiler:
There still are some issues, though. Here are my observations:

- Retreat on defense gives exp to both units.
- Retreat on defense makes you abandon a village.
- Retreat on defense doesn,t work if the attacker (the not-retreating unit) is on a village!

- Retreat on offense doesn't give exp to retreating unit.
- Retreat on offense makes you abandon a village.
- Retreat on offense doesn't work if the defender (the not-retreating unit) is on a village!

- Knockback on defense gives exp to both units.
- However, knockback on defense gives its own level in exp to the knockbacked unit (if it is knockbacked)
(ex: U1 has knockback and is lv1, and is attacked by U2, which is lv2. If U2 is knockbacked, it will earn 2 exps, instead of the 1 exp it should)!
- Knockback on defense doesn't make you leave a village.

- Knockback on offense gives exp to both units.
- Knockback on offense doesn't make you leave a village.

As of now, I can't seem to think straight anymore. I don't really understand how the experience-giving part of the code works, I'd have to look at it longer. Also, I can't find the line about not knocking back out of a village, so I can't reverse it to make retreat work properly.

Anyway, I'll inspect it some more tomorrow, thanks for any help. This is getting real close to being a complete success!


Edit:
I managed to have it work properly! Everything looks fine, and I've edited the above code to put the correct one in. Feel free to test it and report any bugs if you wish, but it should be ok now. :mrgreen:

Thanks to all of you for your support!
Last edited by Dixie on June 11th, 2010, 4:27 pm, edited 1 time in total.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: the KNOCKBACK ability

Post by Dixie »

Well people, seems I'm pseudo thread-necroing some more, but...

Well, knockback worked perfectly fine a few weeks ago. I had tested it in every conceivable way. And now, this morning, it doesn't work on attack anymore. It works on defense, though, and retreat works top-notch! I've tried different previous supposedly working versions of knockback, I've tried various units, maps, terrains... But to no avail. I've proof-read the code over and over, and couldn't figure what the problem was. I even rebooted my laptop, rebooted the wesnoth app several times... I just don't get it. This is so god damn frustrating!

Anyway, would anybody have an explanation? Or at least try the above code and tell me if it's working for them?

Thanks, people.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: the KNOCKBACK ability

Post by zookeeper »

Dixie wrote:Well people, seems I'm pseudo thread-necroing some more, but...

Well, knockback worked perfectly fine a few weeks ago. I had tested it in every conceivable way. And now, this morning, it doesn't work on attack anymore. It works on defense, though, and retreat works top-notch! I've tried different previous supposedly working versions of knockback, I've tried various units, maps, terrains... But to no avail. I've proof-read the code over and over, and couldn't figure what the problem was. I even rebooted my laptop, rebooted the wesnoth app several times... I just don't get it. This is so god damn frustrating!

Anyway, would anybody have an explanation?
Well, the fact that the following doesn't make any sense at all could be one:

Code: Select all

       [filter_second]
           [not]
               [filter_second_location]
                   terrain=*^V*
               [/filter_second_location]
           [/not]
       [/filter_second]
That is, is there a [filter_second_location] somewhere on this page? I think not.

Other than that, you could just find out what it is which isn't working right.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: the KNOCKBACK ability

Post by Dixie »

Oh god, I feel so dumb right now, it looks so obvious now *face palm*.

Still I could have sworn it used to work in every conceivable way a few weeks ago, and that it contained that code. How could I possibly have missed such an obvious bug in my tests? Anyway, it's fixed now... Thank you dearly, zookeeper, your WML wisdom is always most appreciated. :)

Anyway, I've corrected it in the above code, so fear not using it if you need to.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Post Reply