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 …') |
Bumbadadabum (talk | contribs) 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] | |
| − | + | 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). | 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 | |
| − | + | #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} | ||
| − | + | {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} | {NEXT i} | ||
| − | + | [unstore_unit] | |
variable=advanced | variable=advanced | ||
| − | + | find_vacant=no | |
[/unstore_unit] | [/unstore_unit] | ||
| − | + | {CLEAR_VARIABLE advanced} | |
| − | + | #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).
- 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}
- enddef