diff --git a/data/campaigns/Descent_Into_Darkness/scenarios/11_Descent_into_Darkness.cfg b/data/campaigns/Descent_Into_Darkness/scenarios/11_Descent_into_Darkness.cfg index 0588b60622a8..efb30dbec917 100644 --- a/data/campaigns/Descent_Into_Darkness/scenarios/11_Descent_into_Darkness.cfg +++ b/data/campaigns/Descent_Into_Darkness/scenarios/11_Descent_into_Darkness.cfg @@ -520,65 +520,17 @@ [/remove_item] # Previously recruited and new adepts can now also become liches - # To tranform them, all units from the recall list get copied - # and replaced by a new one with the changed type - [store_unit] - [filter] - type=Dark Adept DiD, Dark Sorcerer DiD - [/filter] - variable=mages - kill=yes - [/store_unit] - - [for] - array=mages - variable=i - [do] - # Get the new type: - [switch] - variable=mages[$i].type - [case] - value=Dark Adept DiD - [set_variable] - name=new_type - value=Dark Adept - [/set_variable] - [/case] - [case] - value=Dark Sorcerer DiD - [set_variable] - name=new_type - value=Dark Sorcerer - [/set_variable] - [/case] - [/switch] - - # Create a new mage with the same attributes as the old one: - [unit] - type=$new_type - max_experience=$mages[$i].max_experience - max_hitpoints=$mages[$i].max_hitpoints - experience=$mages[$i].experience - name=$mages[$i].name - id=$mages[$i].id - gender=$mages[$i].gender - side=1 - placement=recall # The only place they can be at the moment. - [modifications] - [insert_tag] - name=trait - variable=mages[$i].modifications.trait[0] - [/insert_tag] - [insert_tag] - name=trait - variable=mages[$i].modifications.trait[1] - [/insert_tag] - [/modifications] - [/unit] - [/do] - [/for] - - {CLEAR_VARIABLE mages,new_type} + [lua] + code = << + for i, u in ipairs(wesnoth.get_recall_units { type = 'Dark Adept DiD, Dark Sorcerer DiD' }) do + if u.type == 'Dark Adept DiD' then + u:transform('Dark Adept') + elseif u.type == 'Dark Sorcerer DiD' then + u:transform('Dark Sorcerer') + end + end + >> + [/lua] [disallow_recruit] side=1 diff --git a/data/campaigns/Secrets_of_the_Ancients/scenarios/18_Abandoned_Outpost.cfg b/data/campaigns/Secrets_of_the_Ancients/scenarios/18_Abandoned_Outpost.cfg index a7a8a782f07c..70d4eaca0ed1 100644 --- a/data/campaigns/Secrets_of_the_Ancients/scenarios/18_Abandoned_Outpost.cfg +++ b/data/campaigns/Secrets_of_the_Ancients/scenarios/18_Abandoned_Outpost.cfg @@ -206,72 +206,20 @@ Now the process is complete for both of us. I posted a guard so nothing could ha type=Vampire Bat [/allow_recruit] - # Now, all the bats on the recall list get copied, except for the type. - [store_unit] - [filter] - type=Vampire Bat SotA, Blood Bat SotA, Dread Bat SotA - [/filter] - variable=bats - kill=yes - [/store_unit] - - [for] - array=bats - variable=i - [do] - # Get the new type: - [switch] - variable=bats[$i].type - [case] - value=Vampire Bat SotA - [set_variable] - name=new_type - value=Vampire Bat - [/set_variable] - [/case] - [case] - value=Blood Bat SotA - [set_variable] - name=new_type - value=Blood Bat - [/set_variable] - [/case] - [case] - value=Dread Bat SotA - [set_variable] - name=new_type - value=Dread Bat - [/set_variable] - [/case] - [/switch] - - # Create a new bat with the same attributes as the old one: - [unit] - type=$new_type - max_experience=$bats[$i].max_experience - max_hitpoints=$bats[$i].max_hitpoints - experience=$bats[$i].experience - name=$bats[$i].name - id=$bats[$i].id - side=1 - placement=recall # The only place they can be at the moment. - [modifications] - [insert_tag] - name=trait - variable=bats[$i].modifications.trait[0] - [/insert_tag] - [insert_tag] - name=trait - variable=bats[$i].modifications.trait[1] - [/insert_tag] - [/modifications] - [/unit] - [/do] - [/for] - - [clear_variable] - name=bats, new_type - [/clear_variable] + # Now the type of all bats on the recall list is changed + [lua] + code = << + for i, u in ipairs(wesnoth.get_recall_units { type = 'Vampire Bat SotA, Blood Bat SotA, Dread Bat SotA' }) do + if u.type == 'Vampire Bat SotA' then + u:transform('Vampire Bat') + elseif u.type == 'Blood Bat SotA' then + u:transform('Blood Bat') + elseif u.type == 'Dread Bat SotA' then + u:transform('Dread Bat') + end + end + >> + [/lua] #ifndef HARD [terrain]