Difference between revisions of "An effect that changes icons"

From The Battle for Wesnoth Wiki
(Created page with '== An effect that changes icons == Want to make this work? [object] name= _ "Flaming Sword" image=items/flame-sword.png description= _ "This sword …')
 
m (An effect that changes icons: ran wmlindent)
Line 1: Line 1:
 
== An effect that changes icons ==
 
== An effect that changes icons ==
 
Want to make this work?
 
Want to make this work?
    [object]
+
[object]
        name= _ "Flaming Sword"
+
    name= _ "Flaming Sword"
        image=items/flame-sword.png
+
    image=items/flame-sword.png
        description= _ "This sword deals 50% more damage than other swords and deals fire damage."
+
    description= _ "This sword deals 50% more damage than other swords and deals fire damage."
  [effect]
+
    [effect]
apply_to=attack
+
        apply_to=attack
name=sword
+
        name=sword
set_type=fire
+
        set_type=fire
increase_damage=50%
+
        increase_damage=50%
'''set_icon=attacks/sword-flaming.png'''
+
        '''set_icon=attacks/sword-flaming.png'''
  [/effect]
+
    [/effect]
    [/object]
+
[/object]
  
 
Place this macro after that the unit takes the object, and also in a global post advance event (in all scenarios, for all units who might have their attack icons altered).
 
Place this macro after that the unit takes the object, and also in a global post advance event (in all scenarios, for all units who might have their attack icons altered).
  
#define UPDATE_ICONS
+
#define UPDATE_ICONS
#It searches through all the effects of all the items, looking for a set_icon tag.
+
    #It searches through all the effects of all the items, looking for a set_icon tag.
#When it finds one, it finds all attacks with the same name as the name that the
+
    #When it finds one, it finds all attacks with the same name as the name that the
#attack affects, and changes their icons. This works only until the next advancement,
+
    #attack affects, and changes their icons. This works only until the next advancement,
#then it has to be reapplied. It might check for other properties of the attack filter
+
    #then it has to be reapplied. It might check for other properties of the attack filter
#of the unit, just needs a little bit of tweaking.
+
    #of the unit, just needs a little bit of tweaking.
[store_unit]
+
    [store_unit]
[filter]
+
        [filter]
x,y=$x1,$y1
+
            x,y=$x1,$y1
[/filter]
+
        [/filter]
variable=advanced
+
        variable=advanced
kill=no
+
        kill=no
[/store_unit]
+
    [/store_unit]
 
     {FOREACH advanced.modifications.object i}
 
     {FOREACH advanced.modifications.object i}
    {FOREACH advanced.modifications.object[$i].effect j}
+
        {FOREACH advanced.modifications.object[$i].effect j}
[if]
+
            [if]
[variable]
+
                [variable]
name=advanced.modifications.object[$i].effect[$j].set_icon
+
                    name=advanced.modifications.object[$i].effect[$j].set_icon
contains="png"
+
                    contains="png"
[/variable]
+
                [/variable]
[then]
+
                [then]
{VARIABLE attack_name $advanced.modifications.object[$i].effect[$j].name}
+
                    {VARIABLE attack_name $advanced.modifications.object[$i].effect[$j].name}
        {FOREACH advanced.attack k}
+
                    {FOREACH advanced.attack k}
[if]
+
                        [if]
[variable]
+
                            [variable]
name=advanced.attack[$k].name
+
                                name=advanced.attack[$k].name
equals=$attack_name
+
                                equals=$attack_name
[/variable]
+
                            [/variable]
[then]
+
                            [then]
{VARIABLE advanced.attack[$k].icon $advanced.modifications.object[$i].effect[$j].set_icon}
+
                                {VARIABLE advanced.attack[$k].icon $advanced.modifications.object[$i].effect[$j].set_icon}
[/then]
+
                            [/then]
[/if]
+
                        [/if]
        {NEXT k}
+
                    {NEXT k}
[/then]
+
                [/then]
[/if]
+
            [/if]
    {NEXT j}
+
        {NEXT j}
 
     {NEXT i}
 
     {NEXT i}
    [unstore_unit]
+
    [unstore_unit]
 
         variable=advanced
 
         variable=advanced
find_vacant=no
+
        find_vacant=no
 
     [/unstore_unit]
 
     [/unstore_unit]
{CLEAR_VARIABLE advanced}
+
    {CLEAR_VARIABLE advanced}
#enddef
+
#enddef

Revision as of 18:12, 12 October 2013

An effect that changes icons

Want to make this work? [object]

   name= _ "Flaming Sword"
   image=items/flame-sword.png
   description= _ "This sword deals 50% more damage than other swords and deals fire damage."
   [effect]
       apply_to=attack
       name=sword
       set_type=fire
       increase_damage=50%
       set_icon=attacks/sword-flaming.png
   [/effect]

[/object]

Place this macro after that the unit takes the object, and also in a global post advance event (in all scenarios, for all units who might have their attack icons altered).

  1. define UPDATE_ICONS
   #It searches through all the effects of all the items, looking for a set_icon tag.
   #When it finds one, it finds all attacks with the same name as the name that the
   #attack affects, and changes their icons. This works only until the next advancement,
   #then it has to be reapplied. It might check for other properties of the attack filter
   #of the unit, just needs a little bit of tweaking.
   [store_unit]
       [filter]
           x,y=$x1,$y1
       [/filter]
       variable=advanced
       kill=no
   [/store_unit]
   {FOREACH advanced.modifications.object i}
       {FOREACH advanced.modifications.object[$i].effect j}
           [if]
               [variable]
                   name=advanced.modifications.object[$i].effect[$j].set_icon
                   contains="png"
               [/variable]
               [then]
                   {VARIABLE attack_name $advanced.modifications.object[$i].effect[$j].name}
                   {FOREACH advanced.attack k}
                       [if]
                           [variable]
                               name=advanced.attack[$k].name
                               equals=$attack_name
                           [/variable]
                           [then]
                               {VARIABLE advanced.attack[$k].icon $advanced.modifications.object[$i].effect[$j].set_icon}
                           [/then]
                       [/if]
                   {NEXT k}
               [/then]
           [/if]
       {NEXT j}
   {NEXT i}
   [unstore_unit]
       variable=advanced
       find_vacant=no
   [/unstore_unit]
   {CLEAR_VARIABLE advanced}
  1. enddef