Changes to WML

Discussion and development of scenarios and campaigns for the game.

Moderators: Forum Moderators, Developers

Post Reply
kmj
Posts: 67
Joined: February 15th, 2004, 5:57 pm

Changes to WML

Post by kmj » March 6th, 2004, 9:37 pm

I've just commited two changes to WML:

"victory_when_enemies_defeated" has been added. If "victory_when_enemies_defeated=no" is found in the scenario, then the level will not end when all enemy sides have been defeated. This allows you to create scenarios where an enemy side has no leader, or where there simply is no enemy side.

the [set_variable] tag has been modified to allow "random=...." The usage is as such.. // random generation works as follows:

Code: Select all

		 random=<comma delimited list>
		 If the first element of the list looks like a number*, then we
		 assume that we are supposed to generate an integer in a specified
		 range, so the second element had better be a number, too. Otherwise,
		 the elements are treated as strings and one is randomly chosen from
		 the list. 
		 * "looks like a number" means first char is a digit or "-".
some examples:

Code: Select all

		# choose from a list
		[set_variable]
			name=blahblah
			random=one,two,three,four
		[/set_variable]

		# choose from another list
		[set_variable]
			name=blahblah
			random=alpha,beta,gamma
		[/set_variable]

		# choose a number in a given range
		[set_variable]
			name=bluhbluh
			random=-1,3
		[/set_variable]
		
		# choose a number in given range again
		[set_variable]
			name=bluhbluh
			random=0,100
		[/set_variable]
	
		# effectively the same as using 'value=' instead of 'random='
		[set_variable]
			name=bluhbluh
			random=9
		[/set_variable]

		# empty strings are legal
		[set_variable]
			name=bluhbluh
			random=,sdfs,sfsdf,fsfdssfs,sdfsdfsfdsdfsdf,,
		[/set_variable]

		# weighted list if you want it to usually choose "no"
		[set_variable]
			name=wonkywonky
			random=yes,no,no,no,no
		[/set_variable]

If you see a reason to in your campaigns, please use these and let me know if there are any issues. There shouldn't be, of course; but you never know.

cedric
Posts: 320
Joined: January 24th, 2004, 10:27 pm
Location: Rennes, France
Contact:

Re: Changes to WML

Post by cedric » March 6th, 2004, 10:17 pm

kmj wrote:If you see a reason to in your campaigns, please use these and let me know if there are any issues. There shouldn't be, of course; but you never know.
That's nice, and will be very useful! :)

Just one thought: isn't there any unset_variable? Randomness will be of much use, but most of the time the variable should be temporary, otherwise savegames will soon be cluttered up with obsolete variables...

--
Cedric

kmj
Posts: 67
Joined: February 15th, 2004, 5:57 pm

Re: Changes to WML

Post by kmj » March 6th, 2004, 10:56 pm

cedric wrote:
kmj wrote:If you see a reason to in your campaigns, please use these and let me know if there are any issues. There shouldn't be, of course; but you never know.
That's nice, and will be very useful! :)

Just one thought: isn't there any unset_variable? Randomness will be of much use, but most of the time the variable should be temporary, otherwise savegames will soon be cluttered up with obsolete variables...

--
Cedric
the easiest fix would be to use the same variable over and over, whenever possible.. but that's a good point..

Dave
Founding Developer
Posts: 7066
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave » March 7th, 2004, 1:03 am

Looks great!

One thing: I would suggest using a '-' notation for ranges of random numbers. i.e.

random=1,10

should mean 'picks 1 or 10 with equal probability'. Allow

random=1-10

to be expanded internally to

random=1,2,3,4,5,6,7,8,9,10

and thus mean 'picks a random number between 1 and 10'.

You could also have for instance

random=-20--10,0,10-20

to mean 'pick at random a number in the range -20 to -10, 0, or a number in the range 10-20, with all numbers having equal chance of being chosen'

Otherwise, all looks great :)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

Christophe33
Posts: 826
Joined: January 21st, 2004, 1:10 am
Location: San Diego, CA

Post by Christophe33 » March 7th, 2004, 5:00 am

Will the random funcction allows to generate a random coordinate (within some factor) for the plcement of an object....like the sceptre of fire?
It really sounds great.
Never tell a dwarf that he shortchanged you!

kmj
Posts: 67
Joined: February 15th, 2004, 5:57 pm

Post by kmj » March 7th, 2004, 8:20 am

Christophe33 wrote:Will the random funcction allows to generate a random coordinate (within some factor) for the plcement of an object....like the sceptre of fire?
It really sounds great.
The following code works...

Code: Select all

[event]
	name=start
	[set_variable]
		name=xpos
		random=5,15
	[/set_variable]
	[set_variable]
		name=ypos
		random=1,6
	[/set_variable]
	[unit]
		description=Rodalfed
		type=Elder Mage
		side=1
		x=$xpos
		y=$ypos
	[/unit]
[/event]
I noticed that the five or six times I ran it, it picked similar values, but different enough that it's random... still, I'm wondering if perhaps I should reseed the generator with the time each time the "random" is called... maybe it doesn't matter.. it's late.

...of course, with random placement you'll have to be careful you don't ask it to place on a wall or some such thing.

Slainte
Posts: 90
Joined: September 22nd, 2003, 9:29 am
Location: Barcelona - Spain
Contact:

Post by Slainte » March 7th, 2004, 9:32 am

Random will come very handy... and I hink reseeding it is about mandatory...

One thing i am not sure... (still learning my way 'round wml and scenarios... is there a way to pass variables from scenario to scenario? Are those variables created in the scenario persistent?

User avatar
Gafgarion
Posts: 607
Joined: February 26th, 2004, 10:48 pm

Post by Gafgarion » March 7th, 2004, 9:42 am

Slainte wrote:Random will come very handy... and I think reseeding it is about mandatory...
I agree, reseeding should be implemented. Although I must admit that my programming knowledge is limited, all of my Computer Science teachers stressed remembering to reseed when talking about using a random function.

Anyways, these are great additions to WML and I know the scenario developers will be very pleased.
-Gafgarion
Elvish Pillager wrote:Normal Trolls use clubs, not ostriches.
"Language is the source of misunderstandings." -Antoine de Saint-Exupéry

llogiq

1-10 considered harmful...

Post by llogiq » March 7th, 2004, 12:37 pm

I agree with dave that having a notation for intervals would be helpful, but I think "-" imposes an unnecessary limitation: what about an interval from -20 to -10?

Therefore I propose either using ".." as infix as in

Code: Select all

random=1..10
or (I do not know if this is possible) even " to " as in

Code: Select all

random=1 to 10

kmj
Posts: 67
Joined: February 15th, 2004, 5:57 pm

Post by kmj » March 7th, 2004, 7:19 pm

Slainte: once a variable is created, it lasts through the whole game (I'm told).


Yeah, I think using -1..-10 is more readable than -1--10. I should have that committed in the next couple of days.

cedric
Posts: 320
Joined: January 24th, 2004, 10:27 pm
Location: Rennes, France
Contact:

Post by cedric » March 8th, 2004, 12:44 am

kmj wrote:Yeah, I think using -1..-10 is more readable than -1--10. I should have that committed in the next couple of days.
Right, more readable, albeit not consistent with the ranges notation currently used (for locations)...

--
Cedric

kmj
Posts: 67
Joined: February 15th, 2004, 5:57 pm

Post by kmj » March 8th, 2004, 3:27 am

cedric wrote:
kmj wrote:Yeah, I think using -1..-10 is more readable than -1--10. I should have that committed in the next couple of days.
Right, more readable, albeit not consistent with the ranges notation currently used (for locations)...

--
Cedric
This is true, but given that locations are locations and these are numeric values, I'd rather have the inconsistency than use "-10--1"... I've updated the code in CVS, as specified.. Numeric and string values can be intermingled, as long as no string values contain "..".

Dave
Founding Developer
Posts: 7066
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave » March 8th, 2004, 1:50 pm

Realistically, I think that the frequency of use of negative numbers as random numbers would be rare. I very very rarely generate random negative numbers in programming.

[quote='Slainte']
One thing i am not sure... (still learning my way 'round wml and scenarios... is there a way to pass variables from scenario to scenario? Are those variables created in the scenario persistent?
[/quote]

Yes, variables created are persistent.

See for example Muff Malal's Peninsula, where a variable is created to see if Moremirmu is found and survives the battle, then that variable is checked in Valley of Death to see if Moremirmu should come and help the player.

Variables wouldn't be very useful if they weren't persistent.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

kmj
Posts: 67
Joined: February 15th, 2004, 5:57 pm

Post by kmj » March 8th, 2004, 5:38 pm

Well, dave, you're the final arbiter. Want me to change it to dashes, then?

edit changed a "?" to a "."

Post Reply