Skip to content

Commit

Permalink
Give Forester an AMLA allowing him to reflect ranged attacks that mis…
Browse files Browse the repository at this point in the history
…s back to the opponent
  • Loading branch information
Dugy committed May 15, 2024
1 parent 72b7056 commit 91a7fc9
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 2 deletions.
48 changes: 46 additions & 2 deletions units/Forester.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,32 @@
Due to their solitude, they lack any relation to other humans, and so they do not have any problem to kill anyone they do not like. This lack of understanding can be exploited by bandits, who occasionally persuade them to join their cause."
die_sound={SOUND_LIST:HUMAN_DIE}
{DEFENSE_ANIM_RANGE "units/human-outlaws/ranger-sword-defend-2.png" "units/human-outlaws/ranger-sword-defend-1.png" {SOUND_LIST:HUMAN_HIT} melee }
{DEFENSE_ANIM_RANGE "units/human-outlaws/ranger-bow-defend.png" "units/human-outlaws/ranger-bow.png" {SOUND_LIST:HUMAN_HIT} ranged }
[defend]
start_time=-126
[filter_attack]
range=ranged
[/filter_attack]
[if]
hit_sound_start_time=-25
hits=hit
[frame]
image=units/human-outlaws/ranger-bow-defend.png:1,units/human-outlaws/ranger-bow.png:250,units/human-outlaws/ranger-bow-defend.png:1
[/frame]
[hit_sound_frame]
sound={SOUND_LIST:HUMAN_HIT}
[/hit_sound_frame]
[/if]
[else]
hit_sound_start_time=-25
hits=miss
[frame]
image=units/human-outlaws/ranger-sword-attack1.png:100,units/human-outlaws/ranger-sword-attack2.png:250,units/human-outlaws/ranger-sword-attack3.png:100
[/frame]
[hit_sound_frame]
sound=dagger-swish.wav
[/hit_sound_frame]
[/else]
[/defend]

[portrait]
size=400
Expand Down Expand Up @@ -254,6 +279,25 @@ Due to their solitude, they lack any relation to other humans, and so they do no
[/effect]
{AMLA_DEFAULT_BONUSES}
[/advancement]
[advancement]
max_times=1
id=reflect
description= _ "able to deflect enemy shots to hit enemies when they miss"
image=attacks/sword-human.png
strict_amla=yes
require_amla="sword"
[effect]
apply_to=attack
name=bow
increase_damage=-1
remove_specials=marksman
[set_specials]
mode=append
{WEAPON_SPECIAL_REFLECTS}
[/set_specials]
[/effect]
{AMLA_DEFAULT_BONUSES}
[/advancement]
[advancement]
max_times=1
always_display=yes
Expand Down Expand Up @@ -387,4 +431,4 @@ Due to their solitude, they lack any relation to other humans, and so they do no
{AMLA_DEFAULT_BONUSES}
[/advancement]
) "Forester"}
[/unit_type]
[/unit_type]
7 changes: 7 additions & 0 deletions utils/abilities.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,13 @@ Enemy units cannot see this unit during dawn or dusk, except if they have units
description= _ "When a defender target misses, the attacker will hit him without any checks."
[/dummy]
#enddef
#define WEAPON_SPECIAL_REFLECTS
[dummy]
id=reflects
name= _ "reflects"
description= _ "Causes opponents's attacks to hit the opponent when the opponent misses."
[/dummy]
#enddef
#define WEAPON_SPECIAL_PIERCE
[dummy]
id=pierce
Expand Down
116 changes: 116 additions & 0 deletions utils/abilities_events.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,122 @@
{CLEAR_VARIABLE has_leech,has_drain,healed,damage_dealt}
[/event]

[event]
name=defender misses
first_time_only=no
[filter_attack]
special_id=reflects
[/filter_attack]
{VARIABLE has_slow no}
{VARIABLE has_poison no}
[if]
[variable]
name=second_weapon.specials.poison.id
equals=poison
[/variable]
[then]
{VARIABLE has_poison yes}
[/then]
[/if]
[if]
[variable]
name=second_weapon.specials.slow.id
equals=slow
[/variable]
[then]
{VARIABLE has_slow yes}
[/then]
[/if]
[set_variable]
name=resistance
to_variable="unit.resistance.$weapon.type"
[/set_variable]
{VARIABLE damage_to_deal $second_weapon.damage}
[if]
[variable]
name=unit.status.slowed
equals=yes
[/variable]
[then]
{VARIABLE_OP damage_to_deal divide 2}
[/then]
[/if]
{VARIABLE damage_dealt "$($($damage_to_deal*$resistance)/100)"}
[harm_unit_loti]
[filter]
x,y=$x2,$y2
[/filter]
[filter_second]
x,y=$x1,$y1
[/filter_second]
amount=$damage_to_deal
damage_type=$weapon.type
poisoned=$has_poison
slowed=$has_slow
fire_event=yes
fire_attacker_hits=true
[/harm_unit_loti]
{CLEAR_VARIABLE resistance,has_slow,has_poison,damage_to_deal}
[/event]

[event]
name=attacker misses
first_time_only=no
[filter_second_attack]
special_id=reflects
[/filter_second_attack]
{VARIABLE has_slow no}
{VARIABLE has_poison no}
[if]
[variable]
name=weapon.specials.poison.id
equals=poison
[/variable]
[then]
{VARIABLE has_poison yes}
[/then]
[/if]
[if]
[variable]
name=weapon.specials.slow.id
equals=slow
[/variable]
[then]
{VARIABLE has_slow yes}
[/then]
[/if]
[set_variable]
name=resistance
to_variable="second_unit.resistance.$weapon.type"
[/set_variable]
{VARIABLE damage_to_deal $second_weapon.damage}
[if]
[variable]
name=second_unit.status.slowed
equals=yes
[/variable]
[then]
{VARIABLE_OP damage_to_deal divide 2}
[/then]
[/if]
{VARIABLE damage_dealt "$($($damage_to_deal*$resistance)/100)"}
[harm_unit_loti]
[filter]
x,y=$x1,$y1
[/filter]
[filter_second]
x,y=$x2,$y2
[/filter_second]
amount=$damage_to_deal
damage_type=$weapon.type
poisoned=$has_poison
slowed=$has_slow
fire_event=yes
fire_attacker_hits=true
[/harm_unit_loti]
{CLEAR_VARIABLE resistance,has_slow,has_poison,damage_to_deal}
[/event]

[event]
name=side turn
first_time_only=no
Expand Down

0 comments on commit 91a7fc9

Please sign in to comment.