summoning skill
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.
- beetlenaut
- Developer
- Posts: 2827
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: summoning skill
Correct. The
#define
section doesn't do anything unless you activate it by using its name that way. When you use its name, all the #defined code is copied into that place automatically.The event name is attacker_hits. It doesn't say anything should happen to a defender. If you want that, you need to write another event for defender_hits where the attacker has the ability and the unit on $x2, $y2 is harmed.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: summoning skill
About #define. I am beginning to understand how it works. If a skill has 2 #defines, then the text after #define must be written into the character's file. I only wrote the first #define before, but not the second #define. As a result, many skills cannot be run. XDbeetlenaut wrote: ↑July 31st, 2021, 2:09 amCorrect. The#define
section doesn't do anything unless you activate it by using its name that way. When you use its name, all the #defined code is copied into that place automatically.
The event name is attacker_hits. It doesn't say anything should happen to a defender. If you want that, you need to write another event for defender_hits where the attacker has the ability and the unit on $x2, $y2 is harmed.
Oh. Can I understand it this way. That is, melee poisoning can only be triggered when I am attacked. If I want to trigger melee poisoning when I attack an enemy, I must edit a corresponding event( $x2, $y2 ).
- beetlenaut
- Developer
- Posts: 2827
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: summoning skill
Correct. The macro runs its code wherever its name is written. (It's name is the first text after the define.) If the name is not written somewhere, then it never runs its code.
Yes. In an [event], the
name
part tells the event when to run its code. Your event runs its code only when the attacker hits because that is its name. So, you are correct that you would need to make that corresponding event with a different name.Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: summoning skill
thank you very much for your help. Under your guidance, I have collected almost all the skills I am interested in and successfully made them run successfully.beetlenaut wrote: ↑July 31st, 2021, 1:49 pmCorrect. The macro runs its code wherever its name is written. (It's name is the first text after the define.) If the name is not written somewhere, then it never runs its code.Yes. In an [event], thename
part tells the event when to run its code. Your event runs its code only when the attacker hits because that is its name. So, you are correct that you would need to make that corresponding event with a different name.
Now I have a problem with the operation of the last skill.
I found {SOUL_SIPHON "eviscerate" 1} in the default [unit_type] of this code. eviscerate is the name of the attack skill. I changed it to {SOUL_SIPHON "sword" 1} according to the skills of the custom role. But after the test, there was no effect of healing nearby allies. XD
Code: Select all
{SOUL_SIPHON "sword" 1}
[attack]
name=sword
#textdomain wesnoth-units
description= _"sword"
#textdomain wesnoth-httt
icon=attacks/sword-holy.png
type=blade
range=melee
[specials]
{WEAPON_SPECIAL_SOUL_SIPHON}
[/specials]
damage=14
number=4
[/attack]
================================================================================================
#define WEAPON_SPECIAL_SOUL_SIPHON
[dummy]
id=soul_siphon
name= _ "reap"
name_inactive= _ "reap"
description= _ "A portion of the damage dealt by this attack is converted into healing energy and spread among nearby allies."
description_inactive= _ "A portion of the damage dealt by this attack is converted into healing energy and spread among nearby allies."
[/dummy]
#enddef
#define SOUL_SIPHON WEAPON FACTOR
[event]
name=attacker_hits
first_time_only=no
[filter_attack]
name={WEAPON}
special=soul_siphon
[/filter_attack]
[store_unit]
[filter]
[filter_adjacent]
x,y=$x1,$y1
is_enemy=no
[/filter_adjacent]
[not]
x,y=$x2,$y2
[/not]
[/filter]
variable=ally
[/store_unit]
{VARIABLE counter 0}
{VARIABLE heal_health $damage_inflicted}
{VARIABLE_OP heal_health divide {FACTOR}}
{FOREACH ally i}
{VARIABLE_OP counter add 1}
{NEXT i}
[if]
[variable]
name=counter
greater_than=0
[/variable]
[then]
{VARIABLE_OP heal_health divide $counter}
[/then]
[/if]
{FOREACH ally i}
[heal_unit]
[filter]
x,y=$ally[$i].x,$ally[$i].y
[/filter]
amount=$heal_health
animate=yes
restore_statuses=no
[/heal_unit]
{NEXT i}
{CLEAR_VARIABLE heal_health}
{CLEAR_VARIABLE counter}
{CLEAR_VARIABLE ally}
[/event]
[event]
name=defender hits
first_time_only=no
[filter_second_attack]
special=soul_siphon
[/filter_second_attack]
[store_unit]
[filter]
[filter_adjacent]
x,y=$x2,$y2
is_enemy=no
[/filter_adjacent]
[not]
x,y=$x1,$y1
[/not]
[/filter]
variable=ally
[/store_unit]
{VARIABLE counter 0}
{VARIABLE heal_health $damage_inflicted}
{VARIABLE_OP heal_health divide {FACTOR}}
{FOREACH ally i}
{VARIABLE_OP counter add 1}
{NEXT i}
[if]
[variable]
name=counter
greater_than=0
[/variable]
[then]
{VARIABLE_OP heal_health divide $counter}
[/then]
[/if]
{FOREACH ally i}
[heal_unit]
[filter]
x,y=$ally[$i].x,$ally[$i].y
[/filter]
amount=$heal_health
animate=yes
restore_statuses=no
[/heal_unit]
{NEXT i}
{CLEAR_VARIABLE heal_health}
{CLEAR_VARIABLE counter}
{CLEAR_VARIABLE ally}
[/event]
#enddef
- beetlenaut
- Developer
- Posts: 2827
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: summoning skill
I copied this code into a unit, and it healed its allies correctly. The problem is not in the code you posted above, but if you post the whole file with the [unit_type] in it, maybe I will see what the problem is.
You know you need to reload Wesnoth or use F5 to apply changes in the code, right?
You know you need to reload Wesnoth or use F5 to apply changes in the code, right?
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: summoning skill
Strange, I just tested it. The skills can be run. XDbeetlenaut wrote: ↑August 1st, 2021, 6:01 am I copied this code into a unit, and it healed its allies correctly. The problem is not in the code you posted above, but if you post the whole file with the [unit_type] in it, maybe I will see what the problem is.
You know you need to reload Wesnoth or use F5 to apply changes in the code, right?
Maybe I forgot to reload the game.
Re: summoning skill
beetlenaut wrote: ↑August 1st, 2021, 6:01 am I copied this code into a unit, and it healed its allies correctly. The problem is not in the code you posted above, but if you post the whole file with the [unit_type] in it, maybe I will see what the problem is.
You know you need to reload Wesnoth or use F5 to apply changes in the code, right?
I found that elf or neutral has no exclusive ability to increase damage. I tried to make one. I found alignment=neutral or race=elf No effect.Is the game mechanics disallowing this code?
Code: Select all
#define ABILITY_TSM_Elf_King
[leadership]
id=TSM_Elf_King
value=40
cumulative=no
affect_self=no
name= _ "Elf King"
description= _ "Damage increased by 40"
special_note=_"Damage increased by 40"
[affect_adjacent]
adjacent=n,ne,se,s,sw,nw
[filter]
race=elf
[/filter]
[/affect_adjacent]
[/leadership]
#enddef
- beetlenaut
- Developer
- Posts: 2827
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: summoning skill
This will probably never happen to you. It is always the programmer's fault, not the game's fault. This code works fine though. I tested it to be sure. You must have a problem in the [unit_type] tag where you call this code. If you post that, I can probably help you.
There is another option. You can also go out to the BfW main menu and press F5. That reloads all the files, and is probably faster than restarting the game.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: summoning skill
F5 is really a good thing. I used to close the game and then open the game.beetlenaut wrote: ↑August 3rd, 2021, 3:29 amThis will probably never happen to you. It is always the programmer's fault, not the game's fault. This code works fine though. I tested it to be sure. You must have a problem in the [unit_type] tag where you call this code. If you post that, I can probably help you.
There is another option. You can also go out to the BfW main menu and press F5. That reloads all the files, and is probably faster than restarting the game.
In fact, there are several traits in the original document. In order to avoid confusion, I deleted other traits. This document test {ABILITY_TSM_Elf_King} still does not work properly. The elves standing around did not increase their attack power. XD
The game version I use is the latest 1.15.
Code: Select all
#textdomain wesnoth-httt
[unit_type]
id=tsm Galadriel
name= _ "Galadriel"
gender=female
race=elf
image="units/tsm/Galadriel/Galadriel.png"
profile="portraits/tsm/Galadriel.png"
{DEFENSE_ANIM "units/tsm/Galadriel/Galadriel-DEFENSE.png" "units/tsm/Galadriel/Galadriel-DEFENSE-1.png" {SOUND_LIST:HUMAN_FEMALE_HIT} }
[abilities]
{ABILITY_TELEPORT}
{ABILITY_TSM_Elf_King}
[/abilities]
[resistance]
arcane=80
[/resistance]
hitpoints=95
movement_type=woodlandfloat
movement=7
experience=250
level=5
alignment=lawful
advances_to=null
{AMLA_DEFAULT}
cost=1
usage=fighter
description= _ "Galadriel"
die_sound={SOUND_LIST:ELF_FEMALE_HIT}
[defense]
hills=50
flat=40
village=30
castle=40
shallow_water=50
forest=50
[/defense]
[standing_anim]
start_time=0
[frame]
image="units/tsm/Galadriel/Galadriel1.png:[200]"
[/frame]
[frame]
image="units/tsm/Galadriel/Galadriel[2,3,2].png:[250*3]"
[/frame]
[frame]
image="units/tsm/Galadriel/Galadriel1.png:[200]"
[/frame]
[/standing_anim]
[attack]
name=touch
description=_"精灵之触"
icon=attacks/touch-faerie.png
type=impact
range=melee
damage=12
number=3
[specials]
{WEAPON_SPECIAL_MARKSMAN}
[/specials]
[/attack]
[attack]
name=faerie fire
description= _"精灵之火"
type=arcane
damage=15
number=4
range=ranged
[specials]
{WEAPON_SPECIAL_MAGICAL}
[/specials]
icon=attacks/faerie-fire.png
[/attack]
[attack]
name=lightning
description= _"雷电"
icon=attacks/lightning.png
type=fire
range=ranged
[specials]
{WEAPON_SPECIAL_MAGICAL}
[/specials]
damage=12
number=5
[/attack]
[attack_anim]
[filter_attack]
name=faerie fire
[/filter_attack]
hits=yes
{MISSILE_FRAME_FAERIE_FIRE}
[frame]
begin=-450
end=-375
image="units/tsm/Galadriel/Galadriel.png"
sound=magic-faeriefire.ogg
halo=halo/elven/faerie-fire-halo1.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-375
end=-300
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo2.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-300
end=-225
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo3.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-225
end=-150
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo4.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-150
end=-75
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo5.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-75
end=0
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo6.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-0
end=75
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo7.png
halo_x,halo_y=-19,-13
[/frame]
[/attack_anim]
[attack_anim]
[filter_attack]
name=faerie fire
[/filter_attack]
hits=no
{MISSILE_FRAME_FAERIE_FIRE}
[frame]
begin=-450
end=-375
image="units/tsm/Galadriel/Galadriel.png"
sound=magic-faeriefire-miss.ogg
halo=halo/elven/faerie-fire-halo1.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-375
end=-300
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo2.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-300
end=-225
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo3.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-225
end=-150
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo4.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-150
end=-75
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo5.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-75
end=0
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo6.png
halo_x,halo_y=-19,-13
[/frame]
[frame]
begin=-0
end=75
image="units/tsm/Galadriel/Galadriel.png"
halo=halo/elven/faerie-fire-halo7.png
halo_x,halo_y=-19,-13
[/frame]
[/attack_anim]
#define ELDER_MAGE_LIGHTNING DIRECTION_NUMBER
[attack_anim]
[filter_attack]
name=lightning
[/filter_attack]
{LIGHTNING_BOLT {DIRECTION_NUMBER} }
[if]
hits=yes
[frame]
begin=-300
end=-200
image="units/tsm/Galadriel/Galadriel-magic.png"
sound=lightning.ogg
[/frame]
[/if]
[else]
hits=no
[frame]
begin=-300
end=-200
image="units/tsm/Galadriel/Galadriel.png"
sound=lightning-miss.ogg
[/frame]
[/else]
[frame]
begin=-200
end=-100
image="units/tsm/Galadriel/Galadriel-magic.png"
[/frame]
[frame]
begin=-100
end=100
image="units/tsm/Galadriel/Galadriel-magic-1.png"
[/frame]
[frame]
begin=100
end=200
image="units/tsm/Galadriel/Galadriel-magic.png"
[/frame]
[frame]
begin=200
end=250
image="units/tsm/Galadriel/Galadriel.png"
[/frame]
[/attack_anim]
#enddef
{ELDER_MAGE_LIGHTNING 1}
{ELDER_MAGE_LIGHTNING 2}
{ELDER_MAGE_LIGHTNING 3}
[attack_anim]
[filter_attack]
name=touch
[/filter_attack]
[frame]
begin=-200
end=-100
image="units/tsm/Galadriel/Galadriel-magic.png"
[/frame]
[frame]
begin=-100
end=100
image="units/tsm/Galadriel/Galadriel-magic-1.png"
[/frame]
[frame]
begin=100
end=200
image="units/tsm/Galadriel/Galadriel-magic.png"
[/frame]
[/attack_anim]
[animation]
apply_to=pre_teleport
start_time=-1200
teleport_sparkle_1_start_time=-1200
teleport_sparkle_2_start_time=-1000
teleport_sparkle_3_start_time=-800
[teleport_sparkle_1_frame]
duration=800
halo=misc/blank-hex.png:1,halo/teleport-9.png,halo/teleport-8.png,halo/teleport-1.png,halo/teleport-2.png,halo/teleport-3.png,halo/teleport-4.png,halo/teleport-5.png,halo/teleport-6.png,halo/teleport-7.png,halo/teleport-8.png,halo/teleport-9.png,misc/blank-hex.png:1
halo_x=-10
halo_y=30~-30
[/teleport_sparkle_1_frame]
[teleport_sparkle_2_frame]
duration=800
halo=misc/blank-hex.png:1,halo/teleport-9.png,halo/teleport-8.png,halo/teleport-1.png,halo/teleport-2.png,halo/teleport-3.png,halo/teleport-4.png,halo/teleport-5.png,halo/teleport-6.png,halo/teleport-7.png,halo/teleport-8.png,halo/teleport-9.png,misc/blank-hex.png:1
halo_x=0
halo_y=40~-40
[/teleport_sparkle_2_frame]
[teleport_sparkle_3_frame]
duration=800
halo=misc/blank-hex.png:1,halo/teleport-9.png,halo/teleport-8.png,halo/teleport-1.png,halo/teleport-2.png,halo/teleport-3.png,halo/teleport-4.png,halo/teleport-5.png,halo/teleport-6.png,halo/teleport-7.png,halo/teleport-8.png,halo/teleport-9.png,misc/blank-hex.png:1
halo_x=10
halo_y=30~-30
[/teleport_sparkle_3_frame]
[frame]
duration=200
image="units/tsm/Galadriel/1.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/2.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/3.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/4.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/5.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/6.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/7.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/8.png"
[/frame]
[frame]
duration=300
image="misc/blank-hex.png"
[/frame]
[/animation]
[animation]
apply_to=post_teleport
start_time=-1200
teleport_sparkle_1_start_time=-1200
teleport_sparkle_2_start_time=-1000
teleport_sparkle_3_start_time=-800
[teleport_sparkle_1_frame]
duration=800
halo=misc/blank-hex.png:1,halo/teleport-9.png,halo/teleport-8.png,halo/teleport-1.png,halo/teleport-2.png,halo/teleport-3.png,halo/teleport-4.png,halo/teleport-5.png,halo/teleport-6.png,halo/teleport-7.png,halo/teleport-8.png,halo/teleport-9.png,misc/blank-hex.png:1
halo_x=10
halo_y=-30~30
[/teleport_sparkle_1_frame]
[teleport_sparkle_2_frame]
duration=800
halo=misc/blank-hex.png:1,halo/teleport-9.png,halo/teleport-8.png,halo/teleport-1.png,halo/teleport-2.png,halo/teleport-3.png,halo/teleport-4.png,halo/teleport-5.png,halo/teleport-6.png,halo/teleport-7.png,halo/teleport-8.png,halo/teleport-9.png,misc/blank-hex.png:1
halo_x=0
halo_y=-40~40
[/teleport_sparkle_2_frame]
[teleport_sparkle_3_frame]
duration=800
halo=misc/blank-hex.png:1,halo/teleport-9.png,halo/teleport-8.png,halo/teleport-1.png,halo/teleport-2.png,halo/teleport-3.png,halo/teleport-4.png,halo/teleport-5.png,halo/teleport-6.png,halo/teleport-7.png,halo/teleport-8.png,halo/teleport-9.png,misc/blank-hex.png:1
halo_x=-10
halo_y=-30~30
[/teleport_sparkle_3_frame]
[frame]
duration=300
image="misc/blank-hex.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/8.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/7.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/6.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/5.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/4.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/3.png"
[/frame]
[frame]
duration=100
image="units/tsm/Galadriel/2.png"
[/frame]
[frame]
duration=200
image="units/tsm/Galadriel/1.png"
[/frame]
[/animation]
[healing_anim]
start_time=-300
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing1.png"
[/frame]
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing2.png"
[/frame]
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing3.png"
[/frame]
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing4.png"
[/frame]
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing5.png"
[/frame]
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing6.png"
[/frame]
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing7.png"
[/frame]
[frame]
duration=75
image="units/tsm/Galadriel/Galadriel.png"
halo="halo/elven/druid-healing8.png"
[/frame]
[/healing_anim]
[/unit_type]
Re: summoning skill
I found out what's going on! I have always used the first level of "Heir_To_The_Throne" to test skills. I always thought that the elves controlled by the computer were also my "ally" and could enjoy the skill bonus. Now I find that many skills can only be effective on the characters I recruited myself, and have no effect on computers that are not hostile.beetlenaut wrote: ↑August 3rd, 2021, 3:29 amThis will probably never happen to you. It is always the programmer's fault, not the game's fault. This code works fine though. I tested it to be sure. You must have a problem in the [unit_type] tag where you call this code. If you post that, I can probably help you.
There is another option. You can also go out to the BfW main menu and press F5. That reloads all the files, and is probably faster than restarting the game.
Is there a way to make the buffs have an effect on non-hostile characters controlled by the computer?
I found that ABILITY_IRON_WARDEN can have an effect on computer-controlled non-hostile characters, but I don't know which code makes it effective. XD
Re: summoning skill
There are similar keys to
affect_self=no
which let you control that aspect.- beetlenaut
- Developer
- Posts: 2827
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: summoning skill
Ravana said "similar" keys. You can
affect_
different groups. You should look at the wiki page about abilities to see them. They will probably be obvious. The wiki always tells you all the tags, keys, and values allowed, so you should look at it first when need to know which code to use.Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: summoning skill
OK,thank you.beetlenaut wrote: ↑August 4th, 2021, 5:43 am Ravana said "similar" keys. You canaffect_
different groups. You should look at the wiki page about abilities to see them. They will probably be obvious. The wiki always tells you all the tags, keys, and values allowed, so you should look at it first when need to know which code to use.
I used "affect_allies=yes" successfully.
Re: summoning skill
I found that generally insert affect_allies=yes in the code, I can make the skills work on allies. But when it comes to [dummy] and [event]. I inserted affect_allies=yes and it seems to have no effect.beetlenaut wrote: ↑August 4th, 2021, 5:43 am Ravana said "similar" keys. You canaffect_
different groups. You should look at the wiki page about abilities to see them. They will probably be obvious. The wiki always tells you all the tags, keys, and values allowed, so you should look at it first when need to know which code to use.
Code: Select all
#define ABILITY_GUARDIAN_ANGEL1
[dummy]
id=guardianangel1
name= _ "Lesser Guardian Angel"
description= _ "Nearby allies (within a radius of 2) have a 40% chance to halve the damage of physical attack to defense。"
special_note=_"Nearby allies (within a radius of 2) have a 40% chance to halve the damage of physical attack to defense。"
[/dummy]
#enddef
#define ABILITY_GUARDIAN_ANGEL2
[dummy]
id=guardianangel2
name= _ "Guardian angel"
description= _ "Nearby allies (within a radius of 2) have a 60% chance to halve the damage of physical attack to defense。"
special_note=_"Nearby allies (within a radius of 2) have a 60% chance to halve the damage of physical attack to defense。"
[/dummy]
#enddef
#define GUARDIAN_ANGEL TYPE CHANCE FACTOR
[event]
name=attacker_hits
first_time_only=no
[filter_attack]
type=blade,impact,pierce
[/filter_attack]
[store_unit]
[filter]
x,y=$x2,$y2
[filter_location]
radius=2
[and]
[filter]
type={TYPE}
ability=guardianangel1,guardianangel2
side=$second_unit.side
[/filter]
[/and]
[/filter_location]
[/filter]
variable=shielded
[/store_unit]
[set_variable]
name=chance_to_heal
rand=1..100
[/set_variable]
{VARIABLE heal_health $damage_inflicted}
{VARIABLE_OP heal_health divide {FACTOR}}
[if]
[variable]
name=second_unit.hitpoints
greater_than=0
[/variable]
[and]
[variable]
name=chance_to_heal
less_than_equal_to={CHANCE}
[/variable]
[/and]
[then]
{FOREACH shielded i}
[heal_unit]
[filter]
x,y=$shielded[$i].x,$shielded[$i].y
[/filter]
amount=$heal_health
animate=yes
restore_statuses=no
[/heal_unit]
{NEXT i}
[/then]
[/if]
{CLEAR_VARIABLE heal_health}
{CLEAR_VARIABLE shielded}
{CLEAR_VARIABLE chance_to_heal}
[/event]
#enddef