Defeat upon zero gold.

The place to post your WML questions and answers.

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.
Post Reply
tw
Posts: 47
Joined: March 30th, 2007, 12:19 pm

Defeat upon zero gold.

Post by tw »

I'm having a scenario where bandits are trying to rob the players castles. I've got it so you lose gold whenever they move to a castle tile. (Though they can currently rob the same tile repeatedly, that would be nice to fix). But I can't work out how to make the loss when the side's gold reaches zero.
I'm hoping this won't turn out to be as problematic as my previous question. (About victory on controlling certain number of villages)
User avatar
Blitzmerker
Posts: 50
Joined: March 20th, 2007, 5:44 pm
Location: Germany

Post by Blitzmerker »

Code: Select all

[store_gold]
side=1 (if you are playing side 1)
variable=gold
[/store_gold]
[if]
	[variable]
	name=gold
	equals=0
	[/variable]
	[then]
		[endlevel]
		result=defeat
		[/endlevel]
	[/then]
[/if]
put this in any event you are loosing gold.
:(){ :|:& };:
tw
Posts: 47
Joined: March 30th, 2007, 12:19 pm

Post by tw »

Works great. I needed to use less_than as the condition though because when using the [gold] tag the game lets it drop below zero. Which has given me an interesting scenario idea actually.
Darn Penguin
Posts: 211
Joined: March 18th, 2007, 9:53 pm
Location: Location, Location!

Post by Darn Penguin »

tw wrote:Works great. I needed to use less_than as the condition though because when using the [gold] tag the game lets it drop below zero. Which has given me an interesting scenario idea actually.
If your gold drops below Zero the bank of Wesnoth sends orcs to "collect" the money you owe. :lol:
Out with the old, in with the new.
Hi folks! Remember me? Please say no.
tw
Posts: 47
Joined: March 30th, 2007, 12:19 pm

Post by tw »

Pretty much :wink:
My campaign, Town vs Gown, under development:
http://www.wesnoth.org/forum/viewtopic.php?t=15822
User avatar
Blitzmerker
Posts: 50
Joined: March 20th, 2007, 5:44 pm
Location: Germany

Post by Blitzmerker »

If the lose gold, 100 for exmaple, you could store the gold before losing it so the gold can't drop below zero.

Code: Select all

[store_gold]
	side=1
	variable=leftgold
[/store_gold]
[if]
	[variable]
		name=leftgold
		greater_than_equal_to=100
	[/variable]
	[then]
		[gold]
			side=1
			amount=-100
		[/gold]
	[/then]
	[else]
		[set_variable]
			name=leftgold
			multiply=-1
		[/set_variable]
		[gold]
			side=1
			amount=$leftgold
		[/gold]
	[/else]
[/if]
:(){ :|:& };:
Post Reply