Difference between revisions of "A Shop Like Thing"
From The Battle for Wesnoth Wiki
(Changed structure of page. Added comments and updated code where I could. Added see also. Kept links but it should all make sense now.) |
(Cleaned up the shop code and wrapped it as a macro definition.) |
||
Line 1: | Line 1: | ||
− | |||
− | |||
== A Shop Like Thing == | == A Shop Like Thing == | ||
− | + | Call this macro to place a moveto event in your scenario that defines a magic-items shop. Argument is a standard location filter. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [event] | + | #define SHOP FILTER |
− | + | [event] | |
− | + | name=moveto | |
− | + | first_time_only=no | |
− | + | [filter] | |
− | + | {FILTER} | |
− | + | [/filter] | |
− | + | [store_gold] | |
− | + | side=$side_number | |
− | + | variable=gold | |
− | + | [/store_gold] | |
− | + | [message] | |
− | + | speaker=narrator | |
− | + | message=_ "What items would you like to purchase?" | |
− | + | image=wesnoth-icon.png | |
− | + | [option] | |
− | + | message=_ "140 GP: Sharpen Melee Weapon, damage:+2" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=140 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-140 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=attack | |
− | + | range=melee | |
− | + | increase_damage=2 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | + | [option] | |
− | + | message=_ "150 GP: Enchance Ranged Weapon, damage +2" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=150 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | side=$side_number | |
− | + | amount=-150 | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=attack | |
− | + | range=ranged | |
− | + | increase_damage=2 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | + | [option] | |
− | + | message=_ "150 GP: Crystal Orb, damage +2 on magical attack" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=150 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-150 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=attack | |
− | + | increase_damage=2 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | |||
− | |||
− | + | [option] | |
− | + | message=_ "250 GP: Toughness Increase Scroll, HP+10" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=250 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-250 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=hitpoints | |
− | + | increase_total=10 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | + | [option] | |
− | + | message=_ "400 GP: Seven-League Boots, gives MP of 10" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=400 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-400 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=movement | |
− | + | set=10 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | + | [option] | |
− | + | message=_ "400 GP: Boot Upgrade, MP+1" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=400 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-400 | |
− | + | side=1 | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=movement | |
− | + | increase=1 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | + | [option] | |
− | + | message=_ "All GP: Healing Fountain, HP:+50" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=0 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=0 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=hitpoints | |
− | + | increase=50 | |
− | + | violate_max=1 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | |||
− | + | [option] | |
− | + | message=_ "300 GP: Rage Stone, add a melee swing" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=300 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-300 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=attack | |
− | + | range=melee | |
− | + | increase_attacks=1 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | + | [option] | |
− | + | message=_ "350 GP: Sight Stone, add a ranged attack" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=350 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-350 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=attack | |
− | + | range=ranged | |
− | + | increase_attacks=1 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | + | [option] | |
− | + | message=_ "350 GP: Fire Scepter, adds 8-1 ranged magical fire" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=350 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-350 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=new_attack | |
− | + | name=Fire Scepter | |
− | + | type=fire | |
− | + | range=ranged | |
− | + | damage=8 | |
− | + | number=1 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | |||
− | |||
− | |||
− | + | [option] | |
− | + | message=_ "350GP: Ice Scepter, adds 8-1 ranged magical ice" | |
− | + | [command] | |
− | + | [if] | |
− | + | [variable] | |
− | + | name=gold | |
− | + | greater_than=350 | |
− | + | [/variable] | |
− | + | [then] | |
− | + | [gold] | |
− | + | amount=-350 | |
− | + | side=$side_number | |
− | + | [/gold] | |
− | + | [object] | |
− | + | [effect] | |
− | + | apply_to=new_attack | |
− | + | name=Ice Scepter | |
− | + | type=cold | |
− | + | range=long | |
− | + | damage=8 | |
− | + | number=1 | |
− | + | [/effect] | |
− | + | [/object] | |
− | + | [/then] | |
− | + | [/if] | |
− | + | [/command] | |
− | + | [/option] | |
− | + | [/message] | |
− | + | [/event] | |
− | + | #enddef | |
− | |||
− | |||
== See Also == | == See Also == |
Revision as of 00:59, 27 February 2008
A Shop Like Thing
Call this macro to place a moveto event in your scenario that defines a magic-items shop. Argument is a standard location filter.
#define SHOP FILTER [event] name=moveto first_time_only=no [filter] {FILTER} [/filter] [store_gold] side=$side_number variable=gold [/store_gold] [message] speaker=narrator message=_ "What items would you like to purchase?" image=wesnoth-icon.png
[option] message=_ "140 GP: Sharpen Melee Weapon, damage:+2" [command] [if] [variable] name=gold greater_than=140 [/variable] [then] [gold] amount=-140 side=$side_number [/gold] [object] [effect] apply_to=attack range=melee increase_damage=2 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "150 GP: Enchance Ranged Weapon, damage +2" [command] [if] [variable] name=gold greater_than=150 [/variable] [then] [gold] side=$side_number amount=-150 [/gold] [object] [effect] apply_to=attack range=ranged increase_damage=2 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "150 GP: Crystal Orb, damage +2 on magical attack" [command] [if] [variable] name=gold greater_than=150 [/variable] [then] [gold] amount=-150 side=$side_number [/gold] [object] [effect] apply_to=attack increase_damage=2 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "250 GP: Toughness Increase Scroll, HP+10" [command] [if] [variable] name=gold greater_than=250 [/variable] [then] [gold] amount=-250 side=$side_number [/gold] [object] [effect] apply_to=hitpoints increase_total=10 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "400 GP: Seven-League Boots, gives MP of 10" [command] [if] [variable] name=gold greater_than=400 [/variable] [then] [gold] amount=-400 side=$side_number [/gold] [object] [effect] apply_to=movement set=10 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "400 GP: Boot Upgrade, MP+1" [command] [if] [variable] name=gold greater_than=400 [/variable] [then] [gold] amount=-400 side=1 [/gold] [object] [effect] apply_to=movement increase=1 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "All GP: Healing Fountain, HP:+50" [command] [if] [variable] name=gold greater_than=0 [/variable] [then] [gold] amount=0 side=$side_number [/gold] [object] [effect] apply_to=hitpoints increase=50 violate_max=1 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "300 GP: Rage Stone, add a melee swing" [command] [if] [variable] name=gold greater_than=300 [/variable] [then] [gold] amount=-300 side=$side_number [/gold] [object] [effect] apply_to=attack range=melee increase_attacks=1 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "350 GP: Sight Stone, add a ranged attack" [command] [if] [variable] name=gold greater_than=350 [/variable] [then] [gold] amount=-350 side=$side_number [/gold] [object] [effect] apply_to=attack range=ranged increase_attacks=1 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "350 GP: Fire Scepter, adds 8-1 ranged magical fire" [command] [if] [variable] name=gold greater_than=350 [/variable] [then] [gold] amount=-350 side=$side_number [/gold] [object] [effect] apply_to=new_attack name=Fire Scepter type=fire range=ranged damage=8 number=1 [/effect] [/object] [/then] [/if] [/command] [/option]
[option] message=_ "350GP: Ice Scepter, adds 8-1 ranged magical ice" [command] [if] [variable] name=gold greater_than=350 [/variable] [then] [gold] amount=-350 side=$side_number [/gold] [object] [effect] apply_to=new_attack name=Ice Scepter type=cold range=long damage=8 number=1 [/effect] [/object] [/then] [/if] [/command] [/option] [/message] [/event] #enddef