Feasibility of Coding new abilities(double attack,trample,.)
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.
Feasibility of Coding new abilities(double attack,trample,.)
I like a lot BoW and i worked out new units and maps to play with my friends.
i managed to make new abilities by editing the existing ones, but i didn't managed to make new ones.
Example;
Then i'd like to code some new abilities that affect the number of attack turns like;
having the unit able to attack two units per turn
or getting being able to move for the remaining moves if had killed a unit in attack
Thanks in advance for reading!:D
i managed to make new abilities by editing the existing ones, but i didn't managed to make new ones.
Example;
Code: Select all
#define ABILITY_DARK_AURA
# Canned definition of the Illuminates ability to be included in an
# [abilities] clause.
[dark_aura]
id=dark_aura
value=-25
max_value=0
cumulative=yes
name= _ "dark aura"
female_name= _ "female^dark_aura"
description= _ "Dark Aura:
This unit obscures the sun in the surrounding area, making chaotic units fight better, and legal units fight worse.
Any units adjacent to this unit will fight as if it were dusk when it is day, and as if it were night when it is dusk."
affect_self=yes
[/dark_aura]
#enddef
having the unit able to attack two units per turn
or getting being able to move for the remaining moves if had killed a unit in attack
Thanks in advance for reading!:D
Re: Feasibility of Coding new abilities(double attack,trampl
Abilities with unrecognized tag names don’t do anything —
This could be implemented as a weapon special thus:
However, non-skirmisher units lose all movement when moving next to a non-level-0 enemy (into the enemy’s Zone of Control), so
[dark_aura]
should be changed back to [illuminates]
.This can be done by settingSilux wrote:being able to move for the remaining moves if had killed a unit in attack
movement_used=0
in the [attack]
tags of the [unit_type]
s you want to be able to do this (if you only want the units to be able to move after using some of their attacks but not others, only set movement_used
in those attack’s tags).This could be implemented as a weapon special thus:
Code: Select all
#define WEAPON_SPECIAL_SPRING_ATTACK
## We are in the [attack] tag’s [specials] subtag (aka [attack][specials]).
## Close the [specials] tag.
[/specials]
## Now we are in the [attack] tag.
## Set movement_used.
movement_used=0
## Reopen [specials].
[+specials]
## Now we are back in [attack][specials].
#enddef
## For more information on reopening (“amending”) tags, see
## <http://wiki.Wesnoth.org/SyntaxWML>.
movement_used=0
could only be used by skirmishers or against level 0 enemies.This can be done by settingSilux wrote:having the unit able to attack two units per turn
attacks=2
in the [unit_type]
tag. The number can be changed, though there’s no point in setting it over 6. Also, attacking not only eats all a unit’s moves, but uses them as fuel — units with no moves left cannot attack, unless their attacks are made to not use movement, as above.Re: Feasibility of Coding new abilities(double attack,trampl
Thanks!:D
I understood the code.
I got the point of how attack and moves work.
Now i can make a sort of berseker that refresh it's moves on attack^^
Zone of Control isn't a problem if the unit gains moves every time it attacks.
It would behave like the Ulfseker with the choice of stopping the assault.
I agree that more than 6 attacks are unnecessary(only six neighbours at time).
Anyway it would be cool to have some sort of Supermario berseker that stomps enemy heads all the way until the leader.
I'll try to get it work tomorrow:)
I understood the code.
I got the point of how attack and moves work.
Now i can make a sort of berseker that refresh it's moves on attack^^
Zone of Control isn't a problem if the unit gains moves every time it attacks.
It would behave like the Ulfseker with the choice of stopping the assault.
I agree that more than 6 attacks are unnecessary(only six neighbours at time).
Anyway it would be cool to have some sort of Supermario berseker that stomps enemy heads all the way until the leader.
I'll try to get it work tomorrow:)
Re: Feasibility of Coding new abilities(double attack,trampl
This should restore a unit’s moves after it attacks:
I forgot in my previous example (spring attack) that it would need a
Also, I’ve moved this to the proper subforum, WML Workshop (Coder’s Corner is for C++).
Code: Select all
#define ABILITY_MOVE_AFTER_ATTACK
[dummy]
id="MoveAfterAttack"
name="..."
description="..."
[/dummy]
[/abilities]
[event]
id="ABILITY_MOVE_AFTER_ATTACK-attack_end-1"
name=attack_end
first_time_only=no
[filter]
ability="MoveAfterAttack"
[/filter]
[modify_unit]
[filter]
id=$unit.id
[/filter]
moves=$unit.max_moves
[/modify_unit]
[/event]
[event]
id="ABILITY_MOVE_AFTER_ATTACK-attack_end-2"
name=attack_end
first_time_only=no
[filter_second]
ability="MoveAfterAttack"
[/filter_second]
[modify_unit]
[filter]
id=$second_unit.id
[/filter]
moves=$second_unit.max_moves
[/modify_unit]
[/event]
[+abilities]
#enddef
[dummy]
tag to be displayed in the sidebar, as above (inserted before the [/specials]
).Also, I’ve moved this to the proper subforum, WML Workshop (Coder’s Corner is for C++).
Last edited by 8680 on January 29th, 2013, 6:30 pm, edited 1 time in total.
Reason: Added first_time_only=no. For the, what, seventh time?
Reason: Added first_time_only=no. For the, what, seventh time?
Re: Feasibility of Coding new abilities(double attack,trampl
The latest code works partially, as the first unit having the ability which attacks gets to move a second time, while successive units behave as default.
I managed to get a dark version of illuminate by setting value at -25 instead of +25.It doesn't provide any bonus at dusk, but only negates the disadvantage in the day:D
I managed to get a dark version of illuminate by setting value at -25 instead of +25.It doesn't provide any bonus at dusk, but only negates the disadvantage in the day:D
Re: Feasibility of Coding new abilities(double attack,trampl
AddSilux wrote:The latest code works partially, as the first unit having the ability which attacks gets to move a second time, while successive units behave as default.
first_time_only=no
to the events. I think I have forgotten this at least thrice as many times as not.
Many add-ons have a “de-illuminates” or “darkens” ability; download some and see how they do it. I’m fairly sure Era of Magic (EoMa) and Invasion from the Unknown (IftU) have such an ability. I think IftU is more complex, so you may want to start with EoMa; on the other hand, I think EoMa takes more space (it has more images), so you may want to start with IftU.Silux wrote:I managed to get a dark version of illuminate by setting value at -25 instead of +25.It doesn't provide any bonus at dusk, but only negates the disadvantage in the day:D
Re: Feasibility of Coding new abilities(double attack,trampl
What you are encountering is that min_value= defaults to 0. If you want your ability to reduce the lawful bonus below zero (which gives a bonus to chaotic units), change "max_value=25" (from the default illuminates) to "min_value=-25". (Have you looked at the the documentation for defining abilities?)Silux wrote:I managed to get a dark version of illuminate by setting value at -25 instead of +25.It doesn't provide any bonus at dusk, but only negates the disadvantage in the day:D
Re: Feasibility of Coding new abilities(double attack,trampl
ok now i have both of them working as intented!
I looked on the documentation before posting, but i missed how to add new keys to the abilities.
Looking at how custom campaigns are made is really interesting!
I found out that moving after attacking is more useful as i thought.Its best use is "hit and run" attacks, possibly conquering a village on retreat.
New questions:
How i can make a unit to be able to move and attack the turn which is recruited?
I looked on the documentation before posting, but i missed how to add new keys to the abilities.
Looking at how custom campaigns are made is really interesting!
I found out that moving after attacking is more useful as i thought.Its best use is "hit and run" attacks, possibly conquering a village on retreat.
New questions:
How i can make a unit to be able to move and attack the turn which is recruited?
Re: Feasibility of Coding new abilities(double attack,trampl
Modify it in its recruit event.Silux wrote:How i can make a unit to be able to move and attack the turn which is recruited?
Re: Feasibility of Coding new abilities(double attack,trampl
Like so:JaMiT wrote:Modify it in its recruit event.
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
## A StandardUnitFilter for which units you want this to apply to.
## See <http://wiki.wesnoth.org/StandardUnitFilter>.
[/filter]
[modify_unit]
[filter]
id=$unit.id
[/filter]
moves=$unit.max_moves
attacks_left=$unit.max_attacks
[/modify_unit]
[/event]
Re: Feasibility of Coding new abilities(double attack,trampl
where this event has to be placed?
i tried to put it in the scenario and on the unit, but it had no effect.
example:
i tried to put it in the scenario and on the unit, but it had no effect.
example:
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
## A StandardUnitFilter for which units you want this to apply to.
## See <http://wiki.wesnoth.org/StandardUnitFilter>.
[/filter]
[modify_unit]
[filter]
id=Troll Whelp
[/filter]
moves=$unit.max_moves
attacks_left=$unit.max_attacks
[/modify_unit]
[/event]
Re: Feasibility of Coding new abilities(double attack,trampl
If you want it to apply to all recruited Troll Whelps, try this:
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
type="Troll Whelp"
[/filter]
[modify_unit]
[filter]
id=$unit.id
[/filter]
moves=$unit.max_moves
attacks_left=$unit.max_attacks
[/modify_unit]
[/event]
Either should work. If you want it to apply in all scenarios, put it in the unit type. If you want it to apply only in specific scenarios, put it in those scenarios.Silux wrote:i tried to put it in the scenario and on the unit, but it had no effect.
Re: Feasibility of Coding new abilities(double attack,trampl
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
## A StandardUnitFilter for which units you want this to apply to.
## See <http://wiki.wesnoth.org/StandardUnitFilter>.
[/filter]
[modify_unit]
[filter]
id=$unit.id
[/filter]
moves=$unit.max_moves
attacks_left=$unit.max_attacks
[/modify_unit]
[/event]
Tried that on the cfg of the orc assassin and the results were scary.As soon as someone recruited an orc assassin all units, even those recruited from other sides, got to be able to move the turn when recruited.
Battle with orcs were much more interesting, faster and brutal than usual:)
So it's possible to make units to affect the behavior of other units, maybe just only units of a certain race.
That's quite illuminating for me!
so:
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
type="General"
[/filter]
[modify_unit]
[filter]
id=$unit.id
[/filter]
apply_to=attack
range=melee
increase_damage=20%
range=ranged
increase_damage=20%
[/modify_unit]
[/event]
[event]
name=die
first_time_only=no
[filter]
type="General"
[/filter]
[modify_unit]
[filter]
id=$unit.id
[/filter]
apply_to=attack
range=melee
increase_damage=-20%
range=ranged
increase_damage=-20%
[/modify_unit]
[/event]
Re: Feasibility of Coding new abilities(double attack,trampl
Now that you know what happened, do you know why it happened? Just in case: This event had no effect until someone recruited an orc assassin because you put the event in the unit type definition. (Events defined in a unit type do not exist until a unit of that type exists.) The event affected all units because the event's filter was empty (meaning it fired for all recruit events).Silux wrote:As soon as someone recruited an orc assassin all units, even those recruited from other sides, got to be able to move the turn when recruited.
You cannot repeat attribute keys within a tag. One of the "range=" lines will overwrite the other. Then again, why specify range= if you intend to modify all ranges by the same amount? (Or do you have custom ranges that are intentionally not modified?) Generally speaking, if a restriction is not specified in WML, the default tends to be "everything".Silux wrote:Code: Select all
[modify_unit] [filter] id=$unit.id [/filter] apply_to=attack range=melee increase_damage=20% range=ranged increase_damage=20% [/modify_unit]
Also, there is no reason to expect keys for the [effect] tag to work directly inside [modify_unit].
No, (even assuming [modify_unit] could work the way you wrote it) it would boost the attack of each "General", not a boost times the number of Generals. (You told [modify_unit] that it should only apply to the unit that triggered the event -- i.e. filtered on the unit's unique ID matching the ID of the unit that triggered the event by being recruited or killed. Which ends up being rather pointless in the "killed" case, as the only unit being modified is about to be deleted, never to return.)Silux wrote:It sould boost the attack of "General" units for each General in the battle.
Re: Feasibility of Coding new abilities(double attack,trampl
Code: Select all
[filter]
side=1
[/filter]
[modify_unit]
[filter]
id=$unit.id
[/filter]
apply_to=attack
increase_damage=20%
[/modify_unit]
So this once fired if the side is 1, will boost the attack of the unit by 20%