Using gold in a filter...
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
- Bob_The_Mighty
- Posts: 875
- Joined: July 13th, 2006, 1:15 pm
Using gold in a filter...
Is there a way of using gold in an event filter?
I want characters to be able to buy special weapons, but i need some way of disallowing the event if they don't have enough money...
Any ideas?
I want characters to be able to buy special weapons, but i need some way of disallowing the event if they don't have enough money...
Any ideas?
Re: Using gold in a filter...
Store the side's gold into a variable, and then check for the value using an [if]. Units don't have gold, so it wouldn't make much sense in a filter (unless you had side filters in addition to unit filters).Bob_The_Mighty wrote:Is there a way of using gold in an event filter?
I want characters to be able to buy special weapons, but i need some way of disallowing the event if they don't have enough money...
- Bob_The_Mighty
- Posts: 875
- Joined: July 13th, 2006, 1:15 pm
Ok, well I've got the gold bit working.
However, it doesn't actually change the unit's weapon stats.
Can someone set me straight?
It is a MP scenario, and I've tried it on both 1.0 and 1.1.7.
Don't work on either.
I'm a bit hazy on the store tag, so it's probably something to do with that.
anyway this is what I have:
[event]
name=moveto
first_time_only=no
[filter]
x="6"
y="61"
side="1,2,3,4,5"
[/filter]
[store_unit]
variable=shopper
[filter]
x,y=6,61
[/filter]
[/store_unit]
[store_gold]
side=$shopper.side
variable=gold
[/store_gold]
[if]
[variable]
name=gold
greater_than=39
[/variable]
[then]
[message]
speaker=narrator
caption="Joshua The Blacksmith"
image="portraits/core/Jason_Lutes/human-peasant.png"
message= _ "Greetings, adventurer. Welcome to my smith. I know you are probably well-equipped for the trial ahead, but perhaps I can interest you in my services. That weapon of yours has seen better days! Give me half an hour and I'm sure I can beat it back into shape. I will only charge 40 gold pieces."
[option]
message= _ "I would like you to improve my weapon."
[command]
[message]
speaker=unit
message= _ "I would like you to improve my weapon."
[/message]
[message]
speaker=narrator
message= _ "Half an hour later..."
[/message]
[message]
speaker=narrator
caption="Joshua The Blacksmith"
image="portraits/core/Jason_Lutes/human-peasant.png"
message= _ "There you go, good as new."
[/message]
[object]
[effect]
apply_to=attack
range=short
increase_damage=1
duration=level
[/effect]
description= _ "Your melee weapon does 1 extra damage."
[/object]
[gold]
side=$shopper.side
amount=-40
[/gold]
[/command]
[/option]
[option]
message= _ "Thank you joshua, but I must decline your offer."
[command]
[/command]
[/option]
[/message]
[/then]
[else]
[message]
speaker=narrator
caption="Joshua The Blacksmith"
image="portraits/core/Jason_Lutes/human-peasant.png"
message= _ "Come back when you've got more gold, eh?"
[/message]
[/else]
[/if]
[unstore_unit]
variable=shopper
[/unstore_unit]
[/event]
However, it doesn't actually change the unit's weapon stats.
Can someone set me straight?
It is a MP scenario, and I've tried it on both 1.0 and 1.1.7.
Don't work on either.
I'm a bit hazy on the store tag, so it's probably something to do with that.
anyway this is what I have:
[event]
name=moveto
first_time_only=no
[filter]
x="6"
y="61"
side="1,2,3,4,5"
[/filter]
[store_unit]
variable=shopper
[filter]
x,y=6,61
[/filter]
[/store_unit]
[store_gold]
side=$shopper.side
variable=gold
[/store_gold]
[if]
[variable]
name=gold
greater_than=39
[/variable]
[then]
[message]
speaker=narrator
caption="Joshua The Blacksmith"
image="portraits/core/Jason_Lutes/human-peasant.png"
message= _ "Greetings, adventurer. Welcome to my smith. I know you are probably well-equipped for the trial ahead, but perhaps I can interest you in my services. That weapon of yours has seen better days! Give me half an hour and I'm sure I can beat it back into shape. I will only charge 40 gold pieces."
[option]
message= _ "I would like you to improve my weapon."
[command]
[message]
speaker=unit
message= _ "I would like you to improve my weapon."
[/message]
[message]
speaker=narrator
message= _ "Half an hour later..."
[/message]
[message]
speaker=narrator
caption="Joshua The Blacksmith"
image="portraits/core/Jason_Lutes/human-peasant.png"
message= _ "There you go, good as new."
[/message]
[object]
[effect]
apply_to=attack
range=short
increase_damage=1
duration=level
[/effect]
description= _ "Your melee weapon does 1 extra damage."
[/object]
[gold]
side=$shopper.side
amount=-40
[/gold]
[/command]
[/option]
[option]
message= _ "Thank you joshua, but I must decline your offer."
[command]
[/command]
[/option]
[/message]
[/then]
[else]
[message]
speaker=narrator
caption="Joshua The Blacksmith"
image="portraits/core/Jason_Lutes/human-peasant.png"
message= _ "Come back when you've got more gold, eh?"
[/message]
[/else]
[/if]
[unstore_unit]
variable=shopper
[/unstore_unit]
[/event]
The problem seems to be that you're storing the unit (which by default also removes it from play) and unstoring the unit only after trying to apply the [object] - but you can give an [object] only to a unit that exists in the field, so it never applies to any unit. So what you need to do is add a kill=no to the first [store_unit] and remove the [unstore_unit] at the end (you still need the [store_unit] to get the unit's side). Then, make sure that range=short is range=melee when playing with 1.1.7 (there the default ranges are melee and ranged, not short and long).
Actually, you could even remove all the storing of the unit as well, since you could just use the variable $side_number instead of $shopper.side (both ways should work).
Actually, you could even remove all the storing of the unit as well, since you could just use the variable $side_number instead of $shopper.side (both ways should work).
- Bob_The_Mighty
- Posts: 875
- Joined: July 13th, 2006, 1:15 pm