Defense and abilities
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.
Defense and abilities
Hello!
I'm trying to create an ability who heals and increases by 10% the defense of adjacents mounted units (allies). I usually look at the abilities from the game to help me but there isn't any abilities which changes the defense.
I tried this, but it doesn't work :
Can you help me?
Sorry about my bad bad bad english
I'm trying to create an ability who heals and increases by 10% the defense of adjacents mounted units (allies). I usually look at the abilities from the game to help me but there isn't any abilities which changes the defense.
I tried this, but it doesn't work :
Code: Select all
[defense]
id=test4
value=-10
[filter_base_value]
greater_than=20
[/filter_base_value]
affect_allies=yes
affect_enemies=no
affect_self=no
[affect_adjacent]
adjacent=n,ne,se,s,sw,nw
[filter]
movement_type=mounted
[/filter]
[/affect_adjacent]
[/defense]
Sorry about my bad bad bad english
Re: Defense and abilities
There is no simple way (as in, doable with ability tags alone) to do a defense-altering ability. In fact, I believe it's practically impossible in a way which would be reflected everywhere it needs to be in the interface; the best I can think of is giving every potential attacker's every attack an invisible weapon special which decreases their chance to hit. However, the improved defense would only show up in the damage calculations dialog, meaning that when moving your cavalry, the hexes next to the support unit would not display the improved defense value.
Re: Defense and abilities
Thank's for your answer.
I am going to find another idea, because it is a little bit hard for me!
Hum, I have another question! I want that my unit give 1 exp point to adjacent units (when the units heal) but i don't know how to do that!
I am going to find another idea, because it is a little bit hard for me!
Hum, I have another question! I want that my unit give 1 exp point to adjacent units (when the units heal) but i don't know how to do that!
Re: Defense and abilities
The simplest way would be to give every possible unit which could benefit from it an object which increases the defenses when an allied unit with that ability is adjacent.
e.g.
e.g.
Code: Select all
[event]
name=turn refresh,recruit,recall,post advance
first_time_only=no
id=increase_defense_event
[filter_condition] # do not fire this event without a reason
[have_unit]
[filter_wml]
movement_type=mounted
[/filter_wml]
[not]
[filter_wml]
[modifications]
[object]
custom_object_id=increases_defenses
[/object]
[/modifications]
[/filter_wml]
[/not]
[/have_unit]
[/filter_condition]
[store_unit]
[filter] # any mounted units still without the object
[filter_wml]
movement_type=mounted
[/filter_wml]
[not]
[filter_wml]
[modifications]
[object]
custom_object_id=increases_defenses
[/object]
[/modifications]
[/filter_wml]
[/not]
[/filter]
variable=possible_targets
[/store_unit]
{FOREACH possible_targets i_temp}
[object]
silent=yes
custom_object_id=increases_defenses # prevent the object being given more than once
[filter]
id=$possible_targets[$i_temp].id
[/filter]
[effect] # apply this effect if an allied unit with said ability is adjacent
[filter]
[filter_adjacent]
ability=increase_defense
is_enemy=no
[/filter_adjacent]
[/filter]
apply_to=defense
replace=no
[defense] # all defenses which should be modified
shallow_water=-10
reef=-10
swamp_water=-10
flat=-10
sand=-10
forest=-10
hills=-10
#mountains=-10
village=-10
castle=-10
cave=-10
frozen=-10
fungus=-10
[/defense]
[/effect]
[/object]
{NEXT i_temp}
{CLEAR_VARIABLE possible_targets}
[/event]
Re: Defense and abilities
Well, your code also makes the effect permanent. As opposed to abilities, an [effect] [filter] only selects whether or not to apply the effect at all, not when it should be "active".trewe wrote:The simplest way would be to give every possible unit which could benefit from it an object which increases the defenses when an allied unit with that ability is adjacent.
Re: Defense and abilities
A working alternative would be to make no change to the terrain defence at all, but to add it a weapon special that decreases the opponent's chance to hit if the user is adjacent to a unit with that ability, something like this:
Code: Select all
[chance_to_hit]
id=defended
apply_to=opponent
sub=10
[filter_self]
[filter_adjacent]
ability=defend
is_enemy=no
[/filter_adjacent]
[/filter_self]
[/chance_to_hit]
Re: Defense and abilities
Thank's Dugi!
Your method works perfectly!
Your method works perfectly!
Re: Defense and abilities
Yeah, it works as long as they also have a ranged attack to give that special to. Otherwise, ranged attacks will hit them normally.
Re: Defense and abilities
I have a second question!
I'm trying to create an ability, "student", which give 1 exp at the beginning of the turn if an adjacent unit has the ability "teacher".
Of course, that does not work. Can you help me?
I'm trying to create an ability, "student", which give 1 exp at the beginning of the turn if an adjacent unit has the ability "teacher".
Code: Select all
#define ABILITY_STUDENT
[dummy]
id=student
[/dummy]
[abilities]
[/abilities]
[event]
name=turn_refresh
first_time_only=no
[modify_unit]
[filter]
side=$side_number
ability=student
[filter_adjacent]
ability=teacher
side=$side_number
[/filter_adjacent]
[/filter]
experience="$($this_unit.experience + 1)"
[/modify_unit]
[/event]
#enddef
Re: Defense and abilities
When your currentPicka79 wrote:I'm trying to create an ability, "student", which give 1 exp at the beginning of the turn if an adjacent unit has the ability "teacher".Code: Select all
#define ABILITY_STUDENT [dummy] id=student [/dummy] [abilities] [/abilities] [event] name=turn_refresh first_time_only=no [modify_unit] [filter] side=$side_number ability=student [filter_adjacent] ability=teacher side=$side_number [/filter_adjacent] [/filter] experience="$($this_unit.experience + 1)" [/modify_unit] [/event] #enddef
ABILITY_STUDENT
macro is included in an [abilities]
tag, like this:
Code: Select all
[abilities]
{ABILITY_ABC}
{ABILITY_STUDENT}
{ABILITY_XYZ}
[/abilities]
Code: Select all
[abilities]
{ABILITY_ABC}
[dummy]
id=student
[/dummy]
[abilities]
[/abilities]
[event]
...
[/event]
{ABILITY_XYZ}
[/abilities]
Code: Select all
[abilities]
{ABILITY_ABC}
[dummy]
id=student
[/dummy]
[/abilities]
[event]
...
[/event]
[+abilities]
{ABILITY_XYZ}
[/abilities]
Code: Select all
#define ABILITY_STUDENT
[dummy]
id=student
[/dummy]
[/abilities]
[event]
...
[/event]
[+abilities]
#enddef
Re: Defense and abilities
I tried your code but my unit won nothing
I doubtless made an error in [event].
My current code :
I doubtless made an error in [event].
My current code :
Code: Select all
#define ABILITY_STUDENT
[dummy]
id=student
[/dummy]
[/abilities]
[event]
name=turn_refresh
first_time_only=no
[modify_unit]
[filter]
side=$side_number
ability=student
[filter_adjacent]
ability=teacher
side=$side_number
[/filter_adjacent]
[/filter]
experience="$($this_unit.experience + 1)"
[/modify_unit]
[/event]
[+abilities]
#enddef
Re: Defense and abilities
name=turn_refresh -> name = turn refresh
Re: Defense and abilities
It always doesn't work!
Re: Defense and abilities
You may need to escape the variable and formula substitutions in
This would be so that the variable and the formula will not be substituted by
experience="$($this_unit.experience + 1)"
by adding vertical lines after the dollar signs (so it becomes experience="$|($|this_unit.experience + 1)"
).This would be so that the variable and the formula will not be substituted by
[event]
, but rather passed on to [modify_unit]
— the variable $this_unit
does not exist until [modify_unit]
is running, so if it’s substituted before that, the formula would be + 1
.Low lines and spaces are interchangeable iniceiceice wrote:name=turn_refresh -> name = turn refresh
[event]name
.Re: Defense and abilities
Ah, didn't know that, I always just copy the wiki verbatim when possible.