Fix song verse ability for UtBS

This commit is contained in:
Hejnewar 2023-08-17 14:20:30 +02:00 committed by GitHub
parent 1693c0e0eb
commit f94bf19a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 108 additions and 72 deletions

View file

@ -19,7 +19,6 @@
[abilities]
{UTBS_ABILITY_HEALS}
[/abilities]
{SONG_VERSE_EVENTS 1 2}
description= _ "Faerie and elven magic have oft been aptly associated with life, from which they draw the majority of their power. However, with the death of much of Irdyas flora, the Quenoth Elves were forced to seek another source for their sorcery. In time, they learned to harness the power of the suns Sela and Naia - the twin stars that had razed the forests of Irdya to ashes, yet still spring forth the energy required for sparking life. Those who master this new magic sing of the dual nature of these embodiments of fire: flames that are both life and lifes demise."
die_sound={SOUND_LIST:ELF_FEMALE_HIT}
[attack]
@ -43,8 +42,7 @@
icon=attacks/faerie-fire-sun.png
[specials]
{WEAPON_SPECIAL_MAGICAL}
{WEAPON_SPECIAL_SONG_VERSE (active_on=offense) 0 2}
{SONG_VERSE_DESCRIPTION 1}
{WEAPON_SPECIAL_SONG_VERSE_BASE 2}
[/specials]
[/attack]
[attack]
@ -59,8 +57,7 @@
[specials]
{WEAPON_SPECIAL_MAGICAL}
{WEAPON_SPECIAL_RAY}
{WEAPON_SPECIAL_SONG_VERSE () 1 2}
{SONG_VERSE_DESCRIPTION 2}
{WEAPON_SPECIAL_SONG_VERSE 2 2}
[/specials]
defense_weight = 0
[/attack]

View file

@ -20,7 +20,6 @@
[abilities]
{UTBS_ABILITY_HEALS}
[/abilities]
{SONG_VERSE_EVENTS 2 3}
description= _ "In times past, those who stepped beyond the boundary of the worlds of elf and faerie were called Sylphs, mystics with unparalleled knowledge of the secrets of the natural sphere. However, in the harsh new world, the path into the realm of the faerie became no longer a journey into the heart of nature, but a diverging path between light and darkness. Those elves who embrace the burning suns as the fulcrum of life and death learn also to harness their power, transforming into beings imbued with radiant fire. These Sun Sylphs very much embody the power that they wield: light that heals and protects, and flames that smolder with destruction."
die_sound={SOUND_LIST:ELF_FEMALE_HIT}
[attack]
@ -44,8 +43,7 @@
icon=attacks/faerie-fire-sun.png
[specials]
{WEAPON_SPECIAL_MAGICAL}
{WEAPON_SPECIAL_SONG_VERSE (active_on=offense) 0 3}
{SONG_VERSE_DESCRIPTION 1}
{WEAPON_SPECIAL_SONG_VERSE_BASE 3}
[/specials]
[/attack]
[attack]
@ -60,8 +58,7 @@
[specials]
{WEAPON_SPECIAL_MAGICAL}
{WEAPON_SPECIAL_RAY}
{WEAPON_SPECIAL_SONG_VERSE () 1 3}
{SONG_VERSE_DESCRIPTION 2}
{WEAPON_SPECIAL_SONG_VERSE 2 3}
[/specials]
defense_weight = 0
[/attack]
@ -77,8 +74,7 @@
[specials]
{WEAPON_SPECIAL_MAGICAL}
{WEAPON_SPECIAL_NOVA}
{WEAPON_SPECIAL_SONG_VERSE () 2 3}
{SONG_VERSE_DESCRIPTION 3}
{WEAPON_SPECIAL_SONG_VERSE 3 3}
[/specials]
defense_weight = 0
[/attack]

View file

@ -73,23 +73,68 @@ _ "This attack uses 6 attacks"#enddef
[/event]
#enddef
#define WEAPON_SPECIAL_SONG_VERSE ACTIVE_ON X DISTINGUISHER
#define STR_VERSE_RESTRICT_1
_ "This attack is the first verse of the Song of Sun Ascension, which progresses by one verse each turn this unit uses a song verse attack. When the last verse is sung or the song sequence is broken due to not attacking for a turn, the song starts again from the first verse."#enddef
#define STR_VERSE_RESTRICT_2
_ "This attack is the second verse of the Song of Sun Ascension, which progresses by one verse each turn this unit uses a song verse attack. When the last verse is sung or the song sequence is broken due to not attacking for a turn, the song starts again from the first verse."#enddef
#define STR_VERSE_RESTRICT_3
_ "This attack is the third verse of the Song of Sun Ascension, which progresses by one verse each turn this unit uses a song verse attack. When the last verse is sung or the song sequence is broken due to not attacking for a turn, the song starts again from the first verse."#enddef
#define STR_VERSE_NAME_1
_ "first verse"#enddef
#define STR_VERSE_NAME_2
_ "second verse"#enddef
#define STR_VERSE_NAME_3
_ "third verse"#enddef
#define WEAPON_SPECIAL_SONG_VERSE_BASE MAX
# param MAX is the total number of verses the unit has, needed for id
[disable]
id = verse_{DISTINGUISHER}
id = song_with_{MAX}_verses
[filter_self]
formula = "self.wml_vars.consecutive_attacks != {X}"
formula = "self.wml_vars.current_verse > 1"
[/filter_self]
{ACTIVE_ON}
active_on = offense
name = {STR_VERSE_NAME_1}
description = {STR_VERSE_RESTRICT_1}
[/disable]
#enddef
#define SONG_VERSE_EVENTS X DISTINGUISHER
#define WEAPON_SPECIAL_SONG_VERSE VERSE MAX
# param VERSE is the this attack should be active on
# param MAX is the total number of verses the unit has, needed for id
# example: {WEAPON_SPECIAL_SONG_VERSE 2 3} means this attack should be active on second verse out of three
# don't set MAX to 1, use WEAPON_SPECIAL_SONG_VERSE_BASE instead to prevent an obscure error related to debug/script unit placement
[disable]
id = song_with_{MAX}_verses
[filter_self]
formula = "self.wml_vars.current_verse != {VERSE}"
[/filter_self]
name = {STR_VERSE_NAME_{VERSE}}
description = {STR_VERSE_RESTRICT_{VERSE}}
[/disable]
#enddef
#define SONG_VERSE_EVENTS MAX
# MAX is the number of attacks after which unit resets back to the first verse
# this macro must be called for each unique MAX
[event]
name = attack end
first_time_only = no
id = song_verse_attack_{MAX}
[filter_attack]
special_id = verse_{DISTINGUISHER}
special_id = song_with_{MAX}_verses
[/filter_attack]
[modify_unit]
@ -105,15 +150,15 @@ _ "This attack uses 6 attacks"#enddef
[/event]
[event]
name = new turn
name = side turn
first_time_only = no
id = song_verse_new_turn_{X}
id = song_verse_side_turn_{MAX}
[modify_unit]
[filter]
side = $side_number
[has_attack]
special_id = verse_{DISTINGUISHER}
special_id = song_with_{MAX}_verses
[/has_attack]
[/filter]
@ -127,11 +172,12 @@ _ "This attack uses 6 attacks"#enddef
[event]
name = recruit, recall, post advance
first_time_only = no
id = song_verse_placed_{X}
id = song_verse_placed_{MAX}
[filter]
side = $side_number
[has_attack]
special_id = verse_{DISTINGUISHER}
special_id = song_with_{MAX}_verses
[/has_attack]
[/filter]
@ -141,8 +187,8 @@ _ "This attack uses 6 attacks"#enddef
[/filter]
[set_variable]
name = consecutive_attacks
value = 0
name = current_verse
value = 1
[/set_variable]
[set_variable]
name = attacked_this_turn
@ -154,13 +200,13 @@ _ "This attack uses 6 attacks"#enddef
[event]
name = side turn end
first_time_only = no
id = song_verse_main_{X}
id = song_verse_main_{MAX}
[store_unit]
[filter]
side = $side_number
[has_attack]
special_id = verse_{DISTINGUISHER}
special_id = song_with_{MAX}_verses
[/has_attack]
[/filter]
@ -172,19 +218,40 @@ _ "This attack uses 6 attacks"#enddef
[if]
[have_unit]
find_in = this_item
formula = "self.wml_vars.consecutive_attacks < {X}"
formula = "self.wml_vars.current_verse < {MAX}"
[/have_unit]
[then]
[modify_unit]
[filter]
find_in = this_item
[/filter]
# this if is required to cover the case where unit has not been initialized (e.g. was debug-spawned) and attacked in the same turn
[if]
[variable]
name = this_item.variables.current_verse
equals = $empty
[/variable]
[then]
[modify_unit]
[filter]
find_in = this_item
[/filter]
[set_variable]
name = consecutive_attacks
add = 1
[/set_variable]
[/modify_unit]
[set_variable]
name = current_verse
value = 2
[/set_variable]
[/modify_unit]
[/then]
[else]
[modify_unit]
[filter]
find_in = this_item
[/filter]
[set_variable]
name = current_verse
add = 1
[/set_variable]
[/modify_unit]
[/else]
[/if]
[/then]
[else]
[modify_unit]
@ -193,8 +260,8 @@ _ "This attack uses 6 attacks"#enddef
[/filter]
[set_variable]
name = consecutive_attacks
value = 0
name = current_verse
value = 1
[/set_variable]
[/modify_unit]
[/else]
@ -202,17 +269,20 @@ _ "This attack uses 6 attacks"#enddef
[modify_unit]
[filter]
find_in = this_item
formula = "self.wml_vars.attacked_this_turn = 0"
formula = "self.wml_vars.attacked_this_turn != 1"
[/filter]
[set_variable]
name = consecutive_attacks
value = 0
name = current_verse
value = 1
[/set_variable]
[/modify_unit]
[/do]
[/foreach]
[/event]
#enddef
#define SONG_VERSE_ILLUMINATES
[event]
name = attack_end
first_time_only = no
@ -248,31 +318,6 @@ _ "This attack uses 6 attacks"#enddef
[/event]
#enddef
#define STR_VERSE_RESTRICT_1
_ "This attack can only be used as the first verse of the song."#enddef
#define STR_VERSE_RESTRICT_2
_ "This attack can only be used as the second verse of the song."#enddef
#define STR_VERSE_RESTRICT_3
_ "This attack can only be used as the third verse of the song."#enddef
#define STR_VERSE_NAME_1
_ "first verse"#enddef
#define STR_VERSE_NAME_2
_ "second verse"#enddef
#define STR_VERSE_NAME_3
_ "third verse"#enddef
#define SONG_VERSE_DESCRIPTION X
[dummy]
name = {STR_VERSE_NAME_{X}}
description = {STR_VERSE_RESTRICT_{X}}
[/dummy]
#enddef
#define WEAPON_SPECIAL_ONCE_PER_TURN ATTACK_NAME
[disable]
id = once_per_turn
@ -1281,9 +1326,7 @@ Marksman attacks are only affected if the chance to hit is greater than 60%."
{WEAPON_SPECIAL_NOVA_EVENTS}
{WEAPON_SPECIAL_USES_ATTACKS_EVENTS}
{WEAPON_SPECIAL_ONCE_PER_TURN_EVENTS}
{SONG_VERSE_EVENTS 0 2}
{SONG_VERSE_EVENTS 1 2}
{SONG_VERSE_EVENTS 0 3}
{SONG_VERSE_EVENTS 1 3}
{SONG_VERSE_EVENTS 2 3}
{SONG_VERSE_EVENTS 2}
{SONG_VERSE_EVENTS 3}
{SONG_VERSE_ILLUMINATES}
[/resource]