ChaosRider’s 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.
Post Reply
Rebel_Angel
Posts: 7
Joined: July 7th, 2012, 9:03 am
Location: Dancing on the head of a pin

Re: Its me again :D.

Post by Rebel_Angel »

Use a die event to add 1 to a custom variable 'kill_counter' (tracked individually for each unit). Then, after each kill, if kill_counter = N, apply the effect and then reset kill_counter to 0.

Something like this (though maybe not exactly, I'm not certain)

Code: Select all

#define ABILITY_SOULTAKER N
    [dummy]
        id=soultaker
        name= _ "soultaker"
        description= _ "Soultaker:
This unit gains an additional point added to its maximum damage whenever it kills {N} living units."
    [/dummy]
[/abilities]

[event]
name=die
first_time_only=no
    [filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]

    [filter_second]
        ability=soultaker
    [/filter_second]

        [set_variable]
            name=second_unit.kill_counter
            add=1
        [/set_variable]

            [if]
                [variable]
                     name=second_unit.kill_counter
                     equals={N}
                [/variable]

                    [then]
                        [unstore_unit]
                            variable=second_unit
                            {COLOR_HEAL}
                            text= _ "+1 damage"
                            find_vacant=no
                        [/unstore_unit]

                        [object]
                            silent=yes
                            duration=forever
                                [filter]
                                    x,y=$x2,$y2
                                [/filter]
                                    [effect]
                                        apply_to=attack
                                        range=melee
                                        increase_damage=1
                                        increase=1
                                   [/effect]
                       [/object]

                       [set_variable]
                           name=second_unit.kill_counter
                           value=0
                       [/set_variable]
                    [/then]
        [/if]
[/event]     

[+abilities]
#enddef         
Be aware that I haven't tested any part of this. Also, I might be handling the kill_counter variable wrongly (I've been away from Wesnoth and WML for quite a while, so I may be remembering the rules wrong!)
Merry meet, and merry part, and merry meet again.
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Its me again :D.

Post by 8680 »

The kill_counter should go in the unit’s [variables], id est unit.variables.kill_counter.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

Nope, its not working xP.
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

Ok, i try it by my own way, but its not working :P... Anyone could try fix it :P ?

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities]
[event]
	name=set_x
	first_time_only=yes
	[set_variables]
		[value]
			variable_x=0
		[/value]
	[set_variables]
[/event]
[event]
    name=die
    first_time_only=no
    [filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]

    [filter_second]
        ability=demonicblood
    [/filter_second]
	if (x<5) then
		[set_variables]
			[value]
				variable_x=variable_x+1
			[/value]
		[set_variables]
	end
	if (x=5) then
		[unstore_unit]
			variable=second_unit
			{COLOR_HEAL}
			text= _ "+1 damage"
			find_vacant=no
		[/unstore_unit]

		[object]
			silent=yes
			duration=forever
			[filter]
				x,y=$x2,$y2
			[/filter]
			[effect]
				apply_to=attack
				increase_damage=1
				increase=1
			[/effect]
		[/object]
		[set_variables]
			[value]
				variable_x=variable_x-5
			[/value]
		[set_variables]
	end
[/event]

[+abilities]
#enddef
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Its me again :D.

Post by Dugi »

This part is completely, really completely wrong, it looks like a combination of WML and another programming language.

Code: Select all

   if (x<5) then
      [set_variables]
         [value]
            variable_x=variable_x+1
         [/value]
      [set_variables]
   end
   if (x=5) then
      [unstore_unit]
         variable=second_unit
         {COLOR_HEAL}
         text= _ "+1 damage"
         find_vacant=no
      [/unstore_unit]

      [object]
         silent=yes
         duration=forever
         [filter]
            x,y=$x2,$y2
         [/filter]
         [effect]
            apply_to=attack
            increase_damage=1
            increase=1
         [/effect]
      [/object]
      [set_variables]
         [value]
            variable_x=variable_x-5
         [/value]
      [set_variables]
   end
It should be like this:

Code: Select all

   [if]
      [variable]
                  name=variable_x
                  less_than=5
      [/variable]
      [then]
      [set_variable]
            name=variable_x
            add=1
      [set_variable]
      [/then]
   [/if]
   [if]
      [variable]
                  name=variable_x
                  equals=5
      [/variable]
      [then]
      [unstore_unit]
         variable=second_unit
         {COLOR_HEAL}
         text= _ "+1 damage"
         find_vacant=no
      [/unstore_unit]

      [object]
         silent=yes
         duration=forever
         [filter]
            x,y=$x2,$y2
         [/filter]
         [effect]
            apply_to=attack
            increase_damage=1
            increase=1
         [/effect]
      [/object]
      [set_variable]
            name=variable_x
            sub=5
      [set_variable]
      [/then]
    [/if]
Have a look at some scenarios using variables, like Swamp of Dread of TttT.
I have just corrected the syntax, it will work only under special circumstances. The set_x event will trigger only if you trigger it somehow, otherwise it should be rather a name=start event. Also, all units with this ability will share the same kill count, so only one unit with that ability should be in that campaign (you will have to save that variable inside the unit otherwise, or use an array where they would have units' IDs assigned to them, but the way using arrays is much harder).
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

Ok, i have some errors :D... I upload here also SS :P.

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities]
[event]
   name=set_x
   first_time_only=yes
   [set_variables]
      [value]
         variable_x=0
      [/value]
   [set_variables]
[/event]
[event]
    name=die
    first_time_only=no
    [filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]

    [filter_second]
        ability=demonicblood
    [/filter_second]
[if]
      [variable]
                  name=variable_x
                  less_than=5
      [/variable]
      [then]
      [set_variable]
            name=variable_x
            add=1
      [set_variable]
      [/then]
   [/if]
   [if]
      [variable]
                  name=variable_x
                  equals=5
      [/variable]
      [then]
      [unstore_unit]
         variable=second_unit
         {COLOR_HEAL}
         text= _ "+1 damage"
         find_vacant=no
      [/unstore_unit]

      [object]
         silent=yes
         duration=forever
         [filter]
            x,y=$x2,$y2
         [/filter]
         [effect]
            apply_to=attack
            increase_damage=1
            increase=1
         [/effect]
      [/object]
      [set_variable]
            name=variable_x
            sub=5
      [set_variable]
      [/then]
    [/if]
[/event]

[+abilities]
#enddef
Attachments
Bez tytułu.png
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

One fixed, but i have another bug, and ss in english : ).

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities]
[event]
   name=set_x
   first_time_only=yes
   [set_variables]
      [value]
         variable_x=0
      [/value]
   [set_variables]
[/event]
[event]
    name=die
    first_time_only=no
    [filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]
    [filter_second]
        ability=demonicblood
    [/filter_second]
[if]
      [variable]
                  name=variable_x
                  less_than=5
      [/variable]
      [then]
      [set_variable]
            name=variable_x
            add=1
      [set_variable]
      [/then]
   [/if]
   [if]
      [variable]
                  name=variable_x
                  equals=5
      [/variable]
      [then]
      [unstore_unit]
         variable=second_unit
         {COLOR_HEAL}
         text= _ "+1 damage"
         find_vacant=no
      [/unstore_unit]

      [object]
         silent=yes
         duration=forever
         [filter]
            x,y=$x2,$y2
         [/filter]
         [effect]
            apply_to=attack
            increase_damage=1
            increase=1
         [/effect]
      [/object]
      [set_variable]
            name=variable_x
            sub=5
      [/set_variable]
      [/then]
    [/if]
[/event]

[+abilities]
#enddef
Attachments
Bez tytułu.png
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Its me again :D.

Post by Ceres »

Code: Select all

[set_variables]
    [value]
       variable_x=0
    [/value]
[set_variables]
First, the closing tag misses a "/".
Second, [set_variables] is for arrays, if you want to set a single variable you have to use this:

Code: Select all

[set_variable]
   name=variable_x
   value=0
[/set_variable]
or, alternatively, the shortened form

Code: Select all

{VARIABLE variable_x 0}
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

And another one error with this code :D.

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities]
[event]
   name=set_x
   first_time_only=yes
   [set_variables]
      [value]
         {VARIABLE variable_x 0}
      [/value]
   [/set_variables]
[/event]
[event]
    name=die
    first_time_only=no
    [filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]
    [filter_second]
        ability=demonicblood
    [/filter_second]
[if]
      [variable]
                  name=variable_x
                  less_than=5
      [/variable]
      [then]
      [set_variable]
            name=variable_x
            add=1
      [set_variable]
      [/then]
   [/if]
   [if]
      [variable]
                  name=variable_x
                  equals=5
      [/variable]
      [then]
      [unstore_unit]
         variable=second_unit
         {COLOR_HEAL}
         text= _ "+1 damage"
         find_vacant=no
      [/unstore_unit]

      [object]
         silent=yes
         duration=forever
         [filter]
            x,y=$x2,$y2
         [/filter]
         [effect]
            apply_to=attack
            increase_damage=1
            increase=1
         [/effect]
      [/object]
      [set_variable]
            name=variable_x
            sub=5
      [/set_variable]
      [/then]
    [/if]
[/event]

[+abilities]
#enddef
Attachments
Bez tytułu.png
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

Ok, this starting game without errors, but its not make dmg bigger with enemies deaths...

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities][event]
name=die
first_time_only=no
[filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]
    [filter_second]
        ability=demonicblood
    [/filter_second]
[store_unit]
[filter]
x,y=$x2,$y2
[/filter]
variable=demonicblood_now
kill=no
[/store_unit]
[switch]
variable=demonicblood_now.variables.demonicblood
[case]
value=5
[unstore_unit]
         variable=demonicblood_now
         {COLOR_HEAL}
         text= _ "+1 damage"
         find_vacant=no
      [/unstore_unit]

      [object]
         silent=yes
         duration=forever
         [filter]
            x,y=$x2,$y2
         [/filter]
         [effect]
            apply_to=attack
            increase_damage=1
         [/effect]
      [/object]
{VARIABLE demonicblood_now.variables.demonicblood 0}
[/case]
[else]
{VARIABLE_OP demonicblood_now.variables.demonicblood add 1}
[/else]
[/switch]
[/event]

[+abilities]
#enddef
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
monochromatic
Posts: 1549
Joined: June 18th, 2009, 1:45 am

Re: Its me again :D.

Post by monochromatic »

My goodness, I haven't done this in a very long time.

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities][event]
name=die
first_time_only=no
[filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]
    [filter_second]
        ability=demonicblood
    [/filter_second]
[store_unit]
[filter]
x,y=$x2,$y2
[/filter]
variable=demonicblood_now
kill=no
[/store_unit]
{VARIABLE_OP demonicblood_now.variables.demonicblood add 1}
[if]
    [variable]
	    name=demonicblood_now.variables.demonicblood
		numerical_equals=5 # Or whatever number
	[/variable]
	[then]
      [unstore_unit]
         variable=demonicblood_now
         {COLOR_HEAL}
         text= _ "+1 damage"
         find_vacant=no
      [/unstore_unit]

      [object]
         silent=yes
         duration=forever
         [filter]
            x,y=$x2,$y2
         [/filter]
         [effect]
            apply_to=attack
            increase_damage=1
         [/effect]
      [/object]
{VARIABLE demonicblood_now.variables.demonicblood 0}
    [/then]
[/if]
[/event]

[+abilities]
#enddef
That should do it. Warning: untested and possibly rusty.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

This also not making dmg bigger, game is started without errors. The one diffrence is fact i had bug - my units after killing enemie on one of sxc collection map didnt have 4 movement point, it had only 0 movement points.
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Its me again :D.

Post by 8680 »

Try this.

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities]
[event]
    name=die
    first_time_only=no
    [filter]
        [not]
            [filter_wml]
                [status]
                    not_living=yes
                [/status]
            [/filter_wml]
        [/not]
    [/filter]
    [filter_second]
        ability=demonicblood
    [/filter_second]
    ## Deleted the kill-counting.
    ## What was it for anyway?
    [object]
        silent=yes
        duration=forever
        [filter]
            id=$second_unit.id
        [/filter]
        [effect]
            apply_to=attack
            increase_damage=1
        [/effect]
        [then]
            [floating_text]
                x,y=$x2,$y2
                text="<span color='green'>+1 damage</span>"
            [/floating_text]
        [/then]
    [/object]
[/event]
[+abilities]
#enddef
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

Kills counting is here to make this ability effect slower, cause if this will give 1 dmg more with each killed enemie unit then it will be too fast, which is mean unit will be overpowerfull :P. I had already ability which is giving dmg with each killed enemie, but the problem is to make same ability which will work slower(not with each killed enemie, but when unit with ability kill "n" enemies, in this example 5 enemies) :D.
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Its me again :D.

Post by ChaosRider »

I think this can work, but i have to only here change name of licznik_zabic_demonblood, to make it depends of unit name. If this not will be changed then all siege trolls which they are on map in same time will have another 1 dmg when one of them will have 5 kills :P. Is this should be changed like that
"licznik_zabic_demonblood_{unit_name}" ?

Code: Select all

#define ABILITY_DEMONICBLOOD
    [dummy]
        id=demonicblood
        name= _ "demonicblood"
        description= _ "Demonicblood:
This unit gains an additional point added to its maximum damage whenever it kills a living unit because it has entered into a pact with the devil."
    [/dummy]
[/abilities]

[event]
    name=die
    first_time_only=no
    [filter]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]

    [filter_second]
        ability=demonicblood
    [/filter_second]

[if]
    [variable]
        name=licznik_zabic_demonblood
        equals=5
    [/variable]

    [then]       
        [unstore_unit]
            variable=second_unit
            {COLOR_HEAL}
           text= _ "+1 damage"
            find_vacant=no
        [/unstore_unit]

        [object]
            silent=yes
            duration=forever
            [filter]
                x,y=$x2,$y2
            [/filter]
            [effect]
                apply_to=attack
                increase_damage=1
                increase=1
            [/effect]
        [/object]
    [set_variable]
        name=licznik_zabic_demonblood
        value=0
    [/set_variable]
    [/then]
 
    [else]
        [set_variable]
             name=licznik_zabic_demonblood
             add=1
        [/set_variable]
    [/else]
[/if]
[/event]

[+abilities]
#enddef
EDIT: This code is good, its not need to be changed :).
Last edited by Iris on July 14th, 2012, 8:06 pm, edited 1 time in total.
Reason: Merged two consecutive posts.
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Post Reply