Bitrons WML Questions

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.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

Ability code. Your code is almost correct.

There is an error that might be preventing it from working. The game cannot know what unit is to be affected by your object. Add this into its code to let it know:

Code: Select all

[filter]
  id=$inspired[$i].id
[/filter]
Last edited by Dugi on November 17th, 2015, 4:01 pm, edited 1 time in total.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Well, it still dont work :/

Code: Select all

[object]
    [filter]
        id=inspired[$i].id
    [/filter]
    silent=yes
    duration=turn
    [effect]
        increase_damage=1
        increase_accuracy=10
    [/effect]
[/object]
I also tried it within the [effect] block
User avatar
James_The_Invisible
Posts: 534
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: [Ability] - Inspiration

Post by James_The_Invisible »

Add apply_to=attack to [effect] tag.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

oh thanks! but still...

here's the whole thing again:

Code: Select all

#define ABILITY_INSPIRATION
[dummy]
    id=inspiration
    name= _ "Inspiration"
    description=  _ "Inspires adjacent units and makes them faster and stronger."
[/dummy]

[/abilities]
    [event]
        name=turn refresh # After the normal restoration of movement
        first_time_only=no
        id=inspiration_movement_event
        [store_unit]
            [filter]
                [filter_adjacent] # Grab all units standing next to units with inspiration
                    ability=inspiration
                    [filter_side] # Don't get inspired by enemies
                        is_enemy=no
                    [/filter_side]
                [/filter_adjacent]
            [/filter]
            variable=inspired
        [/store_unit]
        {FOREACH inspired i} # Repeat this for every inspired unit
        {VARIABLE_OP inspired[$i].moves add 1} # Add 1 movement point to the moves restored to maximum
            [unstore_unit] # Return it back to the game
                variable=inspired[$i]
                find_vacant=no
            [/unstore_unit]
            [object]
                [filter]
                    id=inspired[$i].id
                [/filter]
                silent=yes
                duration=turn
                [effect]
                    apply_to=attack
                    increase_damage=1
                    increase_accuracy=10
                [/effect]
            [/object]
        {NEXT i}
        {CLEAR_VARIABLE inspired} # Clean up
    [/event]
[+abilities]
#enddef
Last edited by Bitron on November 17th, 2015, 3:33 pm, edited 1 time in total.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

increase_accuracy= doesn't work. You have to add a [chance_to_hit] weapon special like the one I showed you in an earlier post. Without the [filter_self] tag. In [effect], you can add weapon specials using the [specials] tag with mode=append (as long as apply_to=attack). The increase_damage= part should work.
User avatar
James_The_Invisible
Posts: 534
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: [Ability] - Inspiration

Post by James_The_Invisible »

Dugi wrote:increase_accuracy= doesn't work.
It should according to wiki. Yes, it was added there just a few months ago but it was in Wesnoth for ages.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

Oh, haven't noticed. Now I am quite clueless why it doesn't work. Maybe Bitron could tell us what does work and what doesn't.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Well.. all units next to Inspirators are getting the extra movementpoint, but not the additional damage and also not the additional accuracy. (using the last-posted ability-code)

I'd guess that the Object simply doesn't reach the the inspired unit, maybe its the filter?
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

:facepalm:
My bad.

Replace:
id=inspired[$i].id
with:
id=$inspired[$i].id
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Very well!, it works!
The inspired Unit gets +1 movementpoint, +1 Damage for Both ranged and melee, and +10% accuracy for both ranged and melee!

But, if a unit is already inspired and keep staying next to a Inspirator, the buff stacks within the opponents turn and resets to normal buff again in my turn after.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

Add side=$side_number into the first [filter] tag, as I wrote before.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Dugi wrote:My implementation of the increased movement is not stackable. With an [object], you would have to be careful. The error that enemies inspire your units too can be fixed by replacing the part is_enemy=no by enemy_of=$side_number
Don't get inspired by enemies with Inspiration, or don't get inspired in the opponents turn?
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

The quote pertains a different thing. Just add that side=$side_number into the first [filter] tag.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

ahh okay .. so just like this ?:

Code: Select all

[store_unit]
  [filter]
    side=$side_number
    [filter_adjacent] # Grab all units standing next to units with inspiration
      ability=inspiration
      [filter_side] # Don't get inspired by enemies
         is_enemy=no
      [/filter_side]
    [/filter_adjacent]
  [/filter]
  variable=inspired
[/store_unit]
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

Yeah, that should be it.
Post Reply