From 8cccfb15ccbcca47e9ce590e146ef1c272b683cb Mon Sep 17 00:00:00 2001
From: Dalas121 <33790750+Dalas121@users.noreply.github.com>
Date: Sat, 28 Dec 2024 07:07:14 -0600
Subject: [PATCH] Move custom AMLAs from EI to core (#9635)
EI contains a basic custom set of AMLAs, replacing the default +3hp for all player units. Units gain a +8hp AMLA option, and units with 1/2/3+ melee/ranged strikes gain options for +4/+2/+1 melee/ranged damage, respectively. Investing XP into these AMLAs remains much weaker than leveling a new unit.
---
data/campaigns/Eastern_Invasion/_main.cfg | 5 +-
.../Eastern_Invasion/utils/amlas.cfg | 296 ---------------
data/core/macros/amla.cfg | 349 +++++++++++++++++-
3 files changed, 340 insertions(+), 310 deletions(-)
delete mode 100644 data/campaigns/Eastern_Invasion/utils/amlas.cfg
diff --git a/data/campaigns/Eastern_Invasion/_main.cfg b/data/campaigns/Eastern_Invasion/_main.cfg
index 84aa5326d0b6..b7ee5f4ca261 100644
--- a/data/campaigns/Eastern_Invasion/_main.cfg
+++ b/data/campaigns/Eastern_Invasion/_main.cfg
@@ -174,9 +174,12 @@
[/entry]
[/about]
+ [load_resource]
+ id=use_stronger_amlas
+ [/load_resource]
+
#ifdef CAMPAIGN_EASTERN_INVASION
{GLOBAL__ANIMATIONS_RECRUIT}
- {GLOBAL__UNIVERSAL_AMLAS}
{GLOBAL__ABILITY_TERROR}
{GLOBAL__TRAIT_DESERTER}
{GLOBAL__IMPLMENTATION_SHIELD_OF_THE_SENTINEL}
diff --git a/data/campaigns/Eastern_Invasion/utils/amlas.cfg b/data/campaigns/Eastern_Invasion/utils/amlas.cfg
deleted file mode 100644
index 9277e00a7350..000000000000
--- a/data/campaigns/Eastern_Invasion/utils/amlas.cfg
+++ /dev/null
@@ -1,296 +0,0 @@
-#textdomain wesnoth-ei
-
-#define DEFAULT_AMLA_EFFECTS
- [effect]
- apply_to=max_experience
- increase=20%
- [/effect]
-
- [effect]
- apply_to=hitpoints
- heal_full=yes
- [/effect]
-
- [effect]
- apply_to=status
- remove=poisoned
- [/effect]
-
- [effect]
- apply_to=status
- remove=slowed
- [/effect]
-#enddef
-
-#define GLOBAL__UNIVERSAL_AMLAS
- #############################
- # EXPLAIN AMLAS
- #############################
- [event]
- name=explain_amlas
-
- [filter_condition]
- {VARIABLE_CONDITIONAL finished_explaining_amlas not_equals yes}
- [/filter_condition]
-
- [message]
- speaker=narrator
- image=wesnoth-icon.png
- message=_"In this campaign, whenever a max-level unit advances, they can select one of several minor bonuses!"
- [/message]
- {VARIABLE finished_explaining_amlas yes}
- [/event]
-
- #############################
- # IMPLEMENT AMLAS
- #############################
- [event]
- name=pre advance
- first_time_only=no
-
- [filter]
- [not]
- id=$amla_currently_advancing_id
- [/not]
- [/filter]
-
- #--------------------
- # SKIP IF NOT MAX-LEVEL
- #--------------------
- {STORE_UNIT_VAR id=$unit.id advances_to amla_candidate_advances_to}
- [if] {VARIABLE_CONDITIONAL amla_candidate_advances_to equals ""}
- [then]
- [/then]
-
- [else]
- {CLEAR_VARIABLE amla_candidate_advances_to}
- [return]
- [/return]
- [/else]
- [/if]
- {CLEAR_VARIABLE amla_candidate_advances_to}
-
- #--------------------
- # AVOID RECURSION
- #--------------------
- # modifying a unit re-triggers "pre advance", so avoid infinite recursion
- {VARIABLE amla_currently_advancing_id $unit.id}
-
- #--------------------
- # EXPLAIN AMLAS
- #--------------------
- [fire_event]
- name=explain_amlas
- [/fire_event]
-
- #--------------------
- # ADD AMLAS
- #--------------------
- [remove_object]
- object_id=universal_amlas_object
- id=$unit.id
- [/remove_object]
- [modify_unit]
- [filter]
- id=$unit.id
- [/filter]
-
- [object]
- id=universal_amlas_object
- [effect]
- apply_to=remove_advancement
- amlas=amla_default
- [/effect]
-
- #--------------------
- # HITPOINTS
- #--------------------
- [effect]
- apply_to=new_advancement
- [advancement]
- id=hitpoints_increase
- description= _ "Gain +8 hitpoints."
- strict_amla=yes
- max_times=-1
- [effect]
- apply_to=hitpoints
- increase_total=8
- [/effect]
-
- {DEFAULT_AMLA_EFFECTS}
- [/advancement]
- #--------------------
- # MELEE DAMAGE
- #--------------------
- [advancement]
- id=melee_increase1
- description= _ "Gain +4 melee damage."
- strict_amla=yes
- max_times=-1
-
- [filter]
- [has_attack]
- range=melee
- number=1
- [/has_attack]
-
- [not]
- [has_attack]
- range=melee
- number=2-99
- [/has_attack]
- [/not]
- [/filter]
-
- [effect]
- apply_to=attack
- increase_damage=4
- range=melee
- [/effect]
-
- {DEFAULT_AMLA_EFFECTS}
- [/advancement]
- [advancement]
- id=melee_increase2
- description= _ "Gain +2 melee damage."
- strict_amla=yes
- max_times=-1
-
- [filter]
- [has_attack]
- range=melee
- number=2
- [/has_attack]
-
- [not]
- [has_attack]
- range=melee
- number=3-99
- [/has_attack]
- [/not]
- [/filter]
-
- [effect]
- apply_to=attack
- increase_damage=2
- range=melee
- [/effect]
-
- {DEFAULT_AMLA_EFFECTS}
- [/advancement]
- [advancement]
- id=melee_increase3
- description= _ "Gain +1 melee damage."
- strict_amla=yes
- max_times=-1
-
- [filter]
- [has_attack]
- range=melee
- number=3-99
- [/has_attack]
- [/filter]
-
- [effect]
- apply_to=attack
- increase_damage=1
- range=melee
- [/effect]
-
- {DEFAULT_AMLA_EFFECTS}
- [/advancement]
- [advancement]
- id=ranged_increase1
- description= _ "Gain +3 ranged damage."
- strict_amla=yes
- max_times=-1
-
- [filter]
- [has_attack]
- range=ranged
- number=1
- [/has_attack]
-
- [not]
- [has_attack]
- range=ranged
- number=2-99
- [/has_attack]
- [/not]
- [/filter]
-
- [effect]
- apply_to=attack
- increase_damage=3
- range=ranged
- [/effect]
-
- {DEFAULT_AMLA_EFFECTS}
- [/advancement]
- [advancement]
- id=ranged_increase2
- description= _ "Gain +2 ranged damage."
- strict_amla=yes
- max_times=-1
-
- [filter]
- [has_attack]
- range=ranged
- number=2
- [/has_attack]
-
- [not]
- [has_attack]
- range=ranged
- number=3-99
- [/has_attack]
- [/not]
- [/filter]
-
- [effect]
- apply_to=attack
- increase_damage=2
- range=ranged
- [/effect]
-
- {DEFAULT_AMLA_EFFECTS}
- [/advancement]
- [advancement]
- id=ranged_increase3
- description= _ "Gain +1 ranged damage."
- strict_amla=yes
- max_times=-1
-
- [filter]
- [has_attack]
- range=ranged
- number=3-99
- [/has_attack]
- [/filter]
-
- [effect]
- apply_to=attack
- increase_damage=1
- range=ranged
- [/effect]
-
- {DEFAULT_AMLA_EFFECTS}
- [/advancement]
- [/effect]
- [/object]
- [/modify_unit]
-
- #--------------------
- # RESET AMLAS
- #--------------------
- [event]
- name=post advance
- {CLEAR_VARIABLE amla_currently_advancing_id}
-
- [remove_object]
- object_id=universal_amlas_object
- id=$unit.id
- [/remove_object]
- [/event]
- [/event]
-#enddef
diff --git a/data/core/macros/amla.cfg b/data/core/macros/amla.cfg
index 6c27a4851ded..7f9f480d7156 100644
--- a/data/core/macros/amla.cfg
+++ b/data/core/macros/amla.cfg
@@ -1,6 +1,25 @@
#textdomain wesnoth-help
#this file contains macros for After Max Level Advancement (AMLA)
+#define AMLA_EFFECTS_HEAL_AND_RAISE_XP
+ [effect]
+ apply_to=max_experience
+ increase=20%
+ [/effect]
+ [effect]
+ apply_to=hitpoints
+ heal_full=yes
+ [/effect]
+ [effect]
+ apply_to=status
+ remove=poisoned
+ [/effect]
+ [effect]
+ apply_to=status
+ remove=slowed
+ [/effect]
+#enddef
+
#define AMLA_DEFAULT
# Canned definition of the default AMLA.
[advancement]
@@ -12,19 +31,323 @@
[effect]
apply_to=hitpoints
increase_total=3
- heal_full=yes
- [/effect]
- [effect]
- apply_to=max_experience
- increase=20%
- [/effect]
- [effect]
- apply_to=status
- remove=poisoned
- [/effect]
- [effect]
- apply_to=status
- remove=slowed
[/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
[/advancement]
#enddef
+
+#
+# This is a resource intended for use in select mainline campaigns, and should not be relied upon for UMC.
+# It may change in ways that aren't backwards-compatible with or that negatively affect the balance of UMC content that uses it.
+#
+# Include this resource in your [campaign] tag to replace the default +3hp AMLA with more powerful AMLA choices.
+# All max-level units gain a +8hp AMLA option, and units with melee/ranged attacks gain options for increased melee/ranged damage.
+# Units whose melee attacks all have 1 strike gain a +4 melee dmg option. Units whose melee attacks all have <=2 strikes gain a +2 melee dmg option. Otherwise, units gain a +1 melee dmg option.
+# The same pattern follows for ranged attacks.
+#
+# The optional `use_stronger_amlas_filter` variable can be used to modify which units this macro affects. `use_stronger_amlas_filter` defaults to `side=1`
+[resource]
+ id=use_stronger_amlas
+
+ #############################
+ # INITIALIZE AMLA FILTER
+ #############################
+ [event]
+ name=prestart
+ [filter_condition]
+ [variable]
+ name=use_stronger_amlas_filter.length
+ equals=0
+ [/variable]
+ [/filter_condition]
+ [set_variable]
+ name=use_stronger_amlas_filter.side
+ value=1
+ [/set_variable]
+ [/event]
+
+ #############################
+ # IMPLEMENT AMLAS
+ #############################
+ [event]
+ name=unit placed,post advance
+ first_time_only=no
+ [insert_tag]
+ name=filter
+ variable=use_stronger_amlas_filter
+ [/insert_tag]
+
+ # skip if this unit already has active AMLAs
+ [filter]
+ [not]
+ [filter_wml]
+ [modifications]
+ [object]
+ id=universal_amlas_object
+ [/object]
+ [/modifications]
+ [/filter_wml]
+ [/not]
+ [/filter]
+
+ #--------------------
+ # ADD AMLAS IF MAX-LEVEL
+ #--------------------
+ [if]
+ [variable]
+ name=unit.advances_to
+ equals=""
+ [/variable]
+ [then]
+ #--------------------
+ # ADD AMLAS
+ #--------------------
+ [modify_unit]
+ [filter]
+ id=$unit.id
+ [/filter]
+ [object]
+ id=universal_amlas_object
+ [effect]
+ apply_to=remove_advancement
+ amlas=amla_default
+ [/effect]
+ [effect]
+ apply_to=new_advancement
+
+ #--------------------
+ # HITPOINTS
+ #--------------------
+ # +8 hitpoints
+ [advancement]
+ id=hitpoints_increase
+ description= _ "Gain +8 hitpoints."
+ strict_amla=yes
+ major_amla=yes # this makes the XP bar blue, allowing the player to differentiate between campaigns with these AMLAs (blue) and campaigns without (purple)
+ max_times=-1
+ [effect]
+ apply_to=hitpoints
+ increase_total=8
+ [/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
+ [/advancement]
+
+ #--------------------
+ # MELEE DAMAGE
+ #--------------------
+ # +4 melee damage
+ [advancement]
+ id=melee_increase1
+ description= _ "Gain +4 melee damage."
+ strict_amla=yes
+ max_times=-1
+ [filter]
+ [has_attack]
+ range=melee
+ number=1
+ [/has_attack]
+ [not]
+ [has_attack]
+ range=melee
+ number=2-99
+ [/has_attack]
+ [/not]
+ [/filter]
+ [effect]
+ apply_to=attack
+ increase_damage=4
+ range=melee
+ [/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
+ [/advancement]
+
+ # +2 melee damage
+ [advancement]
+ id=melee_increase2
+ description= _ "Gain +2 melee damage."
+ strict_amla=yes
+ max_times=-1
+ [filter]
+ [has_attack]
+ range=melee
+ number=2
+ [/has_attack]
+ [not]
+ [has_attack]
+ range=melee
+ number=3-99
+ [/has_attack]
+ [/not]
+ [/filter]
+ [effect]
+ apply_to=attack
+ increase_damage=2
+ range=melee
+ [/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
+ [/advancement]
+
+ # +1 melee damage
+ [advancement]
+ id=melee_increase3
+ description= _ "Gain +1 melee damage."
+ strict_amla=yes
+ max_times=-1
+ [filter]
+ [has_attack]
+ range=melee
+ number=3-99
+ [/has_attack]
+ [/filter]
+ [effect]
+ apply_to=attack
+ increase_damage=1
+ range=melee
+ [/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
+ [/advancement]
+
+ #--------------------
+ # RANGED DAMAGE
+ #--------------------
+ # +4 ranged damage
+ [advancement]
+ id=ranged_increase1
+ description= _ "Gain +4 ranged damage."
+ strict_amla=yes
+ max_times=-1
+ [filter]
+ [has_attack]
+ range=ranged
+ number=1
+ [/has_attack]
+ [not]
+ [has_attack]
+ range=ranged
+ number=2-99
+ [/has_attack]
+ [/not]
+ [/filter]
+ [effect]
+ apply_to=attack
+ increase_damage=4
+ range=ranged
+ [/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
+ [/advancement]
+
+ # +2 ranged damage
+ [advancement]
+ id=ranged_increase2
+ description= _ "Gain +2 ranged damage."
+ strict_amla=yes
+ max_times=-1
+ [filter]
+ [has_attack]
+ range=ranged
+ number=2
+ [/has_attack]
+ [not]
+ [has_attack]
+ range=ranged
+ number=3-99
+ [/has_attack]
+ [/not]
+ [/filter]
+ [effect]
+ apply_to=attack
+ increase_damage=2
+ range=ranged
+ [/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
+ [/advancement]
+
+ # +1 ranged damage
+ [advancement]
+ id=ranged_increase3
+ description= _ "Gain +1 ranged damage."
+ strict_amla=yes
+ max_times=-1
+ [filter]
+ [has_attack]
+ range=ranged
+ number=3-99
+ [/has_attack]
+ [/filter]
+ [effect]
+ apply_to=attack
+ increase_damage=1
+ range=ranged
+ [/effect]
+ {AMLA_EFFECTS_HEAL_AND_RAISE_XP}
+ [/advancement]
+ [/effect]
+ [/object]
+ [/modify_unit]
+ [/then]
+ [/if]
+ [/event]
+
+ #############################
+ # AMLAS HELP MESSAGE
+ #############################
+ [event]
+ name=pre advance
+ first_time_only=no
+ [filter_condition]
+ [variable]
+ name=unit.advances_to
+ equals=""
+ [/variable]
+ [/filter_condition]
+
+ [get_global_variable]
+ namespace=WesnothMainline
+ from_global=AMLA_hint_message_shown
+ to_local=AMLA_hint_message_shown
+ side=global
+ [/get_global_variable]
+ [if]
+ [variable]
+ name=AMLA_hint_message_shown
+ not_equals=yes
+ [/variable]
+ [then]
+ [message]
+ speaker=narrator
+ image=wesnoth-icon.png
+ #po: newlines at the end are deliberate, and function as spacers before the [option]s
+ message=_"Congratulations, your $unit.type has leveled up... but it’s already at its max level!
+
+When this happens, some campaigns — like this one — allow you to select a minor bonus to hitpoints or damage. These bonuses are called “AMLAs”: “After Maximum Level Advancements”. If your max-level units have normal, blue experience bars, that means these AMLAs are available.
+
+Other campaigns don’t have these AMLA options, and instead always give max-level units +3 max hp when they level up. If your max-level units have purple experience bars, they’ll only get +3 max hp when the level up.
+
+"
+ [option]
+ message=_"Ok, continue with the game"
+ [/option]
+ [option]
+ message=_"Don’t show this message again"
+ [command]
+ [set_variable]
+ name=AMLA_hint_message_shown
+ value=yes
+ [/set_variable]
+ [set_global_variable]
+ namespace=WesnothMainline
+ from_local=AMLA_hint_message_shown
+ to_global=AMLA_hint_message_shown
+ side=global
+ immediate=yes
+ [/set_global_variable]
+ [clear_variable]
+ name=AMLA_hint_message_shown
+ [/clear_variable]
+ [/command]
+ [/option]
+ [/message]
+ [/then]
+ [/if]
+ [/event]
+[/resource]