Difference between revisions of "A Shop Like Thing"

From The Battle for Wesnoth Wiki
(Cleaned up the shop code and wrapped it as a macro definition.)
m
Line 18: Line 18:
 
             message=_ "What items would you like to purchase?"
 
             message=_ "What items would you like to purchase?"
 
             image=wesnoth-icon.png
 
             image=wesnoth-icon.png
 
+
 
             [option]
 
             [option]
 
                 message=_ "140 GP: Sharpen Melee Weapon, damage:+2"
 
                 message=_ "140 GP: Sharpen Melee Weapon, damage:+2"
Line 43: Line 43:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "150 GP: Enchance Ranged Weapon, damage +2"
 
                 message=_ "150 GP: Enchance Ranged Weapon, damage +2"
Line 68: Line 68:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "150 GP: Crystal Orb, damage +2 on magical attack"
 
                 message=_ "150 GP: Crystal Orb, damage +2 on magical attack"
Line 92: Line 92:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "250 GP: Toughness Increase Scroll, HP+10"
 
                 message=_ "250 GP: Toughness Increase Scroll, HP+10"
Line 116: Line 116:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "400 GP: Seven-League Boots, gives MP of 10"
 
                 message=_ "400 GP: Seven-League Boots, gives MP of 10"
Line 140: Line 140:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "400 GP: Boot Upgrade, MP+1"
 
                 message=_ "400 GP: Boot Upgrade, MP+1"
Line 164: Line 164:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "All GP: Healing Fountain, HP:+50"
 
                 message=_ "All GP: Healing Fountain, HP:+50"
Line 189: Line 189:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "300 GP: Rage Stone, add a melee swing"
 
                 message=_ "300 GP: Rage Stone, add a melee swing"
Line 214: Line 214:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "350 GP: Sight Stone, add a ranged attack"
 
                 message=_ "350 GP: Sight Stone, add a ranged attack"
Line 239: Line 239:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "350 GP: Fire Scepter, adds 8-1 ranged magical fire"
 
                 message=_ "350 GP: Fire Scepter, adds 8-1 ranged magical fire"
Line 267: Line 267:
 
                 [/command]
 
                 [/command]
 
             [/option]
 
             [/option]
 
+
 
             [option]
 
             [option]
 
                 message=_ "350GP: Ice Scepter, adds 8-1 ranged magical ice"
 
                 message=_ "350GP: Ice Scepter, adds 8-1 ranged magical ice"

Revision as of 01:01, 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

See Also