A Shop Like Thing

From The Battle for Wesnoth Wiki
Revision as of 14:27, 9 April 2007 by Henkutsu (talk | contribs) (Changed structure of page. Added comments and updated code where I could. Added see also. Kept links but it should all make sense now.)

Please note that this code is a bit out of date. All references to "range" should be "melee" or "ranged" now instead of "short" and "long" (Have been fixed now). There may be other parts that are out of date, particularily in regards to adding specials. Check ReferenceWML on the tags just to check :) Happy coding.

A Shop Like Thing

Just paste this code into your scenario: The code inside each [option] tag are different items, their attributes can easily be changed. In the first section of code, it defines on what coordinates on the map are the shops located. it also shows which sides can use them. You can take out any item in [options] tags and this code still works., as long as you have the beginning and the end bits.

"side=1,2,3,4 x=37,34,40,37 y=1,2,2,4"

[event]
name=moveto 
first_time_only=no
[filter]
side=1,2,3,4
x=37,34,40,37
y=1,2,2,4
[/filter]
[store_gold]
side=$side_number
variable=gold
[/store_gold]
[message]
speaker=narrator
message=_ "What items would you like to purchase?"

Melee damage increase

[option]
message=_ "Sharpen Melee Weapon g:140 dmg: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]

Ranged damage increase

[option]
message=_ "Enchance Ranged Weapon g:150 dmg: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]

Extra damage and magical enhancement

(May be partially out of date)

[option]
message=_ "Crystal Orb g:150 dmg:+2 Magical"
[command]
[if]
[variable]
name=gold
greater_than=150
[/variable]
[then]
[gold]
amount=-150
side=$side_number
[/gold]
[object]
[effect]
apply_to=attack
special=magical
increase_damage=2
[/effect]
[/object]
[/then]
[/if]
[/command]
[/option]

Increase maximum HP

[option]
message=_ "Toughness Increase Scroll g:250 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]

Set Movement to 10

[option]
message=_ "Flying Boots g:400 m:to 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]

Add Extra Movement

[option] 
message=_ "Boot Upgrade g:400 m:+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] 

Heal damage

(May be partially out of date)

[option]
message=_ "Healing Fountain g:All 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]

Extra Melee attack

[option]
message=_ "Rage Stone g:300 atks:+1 Melee"
[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]

Extra ranged attack

[option] 
message=_ "Sight Stone g:350 atks:+1 ranged"
[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]

Add a weapon

(May be partially out of date)

[option]
message=_ "Fire Scepter g:350 atks: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
special=magical
range=ranged
damage=8
number=1
[/effect]
[/object]
[/then]
[/if]
[/command]
[/option]

Add a weapon

(May be partially out of date)

[option]
message=_ "Ice Scepter g:350 atks: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
special=magical
range=long
damage=8
 number=1
[/effect] 
[/object]  [/then]
[/if]  
[/command]
[/option]
##########################closing tags
[/message]
[/event]

See Also