ChaosRider’s WML questions
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.
-
- Posts: 7
- Joined: July 7th, 2012, 9:03 am
- Location: Dancing on the head of a pin
Re: Its me again :D.
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)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!)
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
Merry meet, and merry part, and merry meet again.
Re: Its me again :D.
The
kill_counter
should go in the unit’s [variables]
, id est unit.variables.kill_counter
.- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
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.
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
Ok, i try it by my own way, but its not working ... Anyone could try fix it ?
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.
Re: Its me again :D.
This part is completely, really completely wrong, it looks like a combination of WML and another programming language.
It should be like this:
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).
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
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]
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).
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
Ok, i have some errors ... I upload here also SS .
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
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.
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
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
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.
Re: Its me again :D.
First, the closing tag misses a "/".Code: Select all
[set_variables] [value] variable_x=0 [/value] [set_variables]
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]
Code: Select all
{VARIABLE variable_x 0}
Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
And another one error with this code .
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
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.
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
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.
-
- Posts: 1549
- Joined: June 18th, 2009, 1:45 am
Re: Its me again :D.
My goodness, I haven't done this in a very long time.
That should do it. Warning: untested and possibly rusty.
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
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
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.
Re: Its me again :D.
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
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
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 . 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) .
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.
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Its me again :D.
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 . Is this should be changed like that
"licznik_zabic_demonblood_{unit_name}" ?
EDIT: This code is good, its not need to be changed .
"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
Last edited by Iris on July 14th, 2012, 8:06 pm, edited 1 time in total.
Reason: Merged two consecutive posts.
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.