Trouble with Making Scenario...

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
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Trouble with Making Scenario...

Post by appleide »

Okay... so I copied another game's idea... but I wanted to learn WML... thats why i didnt bother thinking too much...

1st point... is it possible to put a one scenario campaign all into one file? Because thats what I did...

2nd point... When i try to start up this campaign, it says theres an unexpected character... I couldn't find it... but after i press "ok", it goes to the end of the campaign, the end credits...

I placed this file into the campaigns folder, that's all... BTW its not finished yet...

EDIT: deleted attachment no longer needed to save space :wink:
Last edited by appleide on January 12th, 2006, 2:29 am, edited 2 times in total.
Why did the fish laugh? Because the sea weed.
claus
Posts: 186
Joined: April 4th, 2005, 5:51 am

Post by claus »

I think i found several problems:

The message and option part of the moveto event looks strange. If you want an example how to make options you might look at the Bay of Pearls scenario file from the HttT campaign. (I would use an object for the increase hitpoints and the increase melee attack part.)

I am not sure if a [message] with only message=... is displayed or not. I think you should use speaker=narrator for those in the start event.

The description key in the [side] tags should be description (not Description) and the gold and income macros are GOLD and INCOME and require three arguments, one for easy, one for normal and one for hard. In addition both should be inside of each [side] tag. (You could use gold= and income= inside of the [side] tags instead, especially when you only want one difficulty.)

One more point: I believe you should add a first_scenario=DotrClone (It might be a problem thet the campaign and the scenario have the same id) inside of [campaign] and close [campaign] before the [scenario] starts.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

The [message]'s and [option]'s are all messed up in the Konrad moveto event, and also what claus said seems to be correct. You'll probably want to keep http://www.wesnoth.org/wiki/ReferenceWML open at all times when you're writing WML (and especially when you're new to it) and check what the tags and keys you use really expect inside of them, and so on.

Also, close the [campaign] tag before the #ifdef. If you look at existing campaign files, there's first the [campaign][/campaign] and then the #ifdef.
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

Thanks, Claus and Zookeeper!... I couldn't have figured out how to do the option menu without both of your advice...

But theres a problem... Inside the scenario (yes! it works now!!), when konrad steps onto the village, option menu comes up.. but when he moves off and goes in again, its not there anymore... how do i make it recurring, coming up everytime he steps into the village??

Code: Select all

[event]
name=moveto
[filter]
description=Konrad
x=37
y=1
[/filter]
[message]
description=Konrad
message=_ "What abilities would you like to purchase?"
[option]
message=_ "increase melee attack"
[command]
[/command]
[/option]
[option]
message=_ "increase hitpoints"
[command]
[/command]
[/option]
[/message]
[/event]
Why did the fish laugh? Because the sea weed.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

first_time_only=no does the trick:

Code: Select all

[event]
name=moveto
first_time_only=no
[filter] 
...
By default, an event triggers only once.
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

Progressed alot... :) after this part... only coding the new ai is left...:roll:

I want the opponent leader to be respawned when he dies...

But....

Code: Select all

[if]
[have_unit]
[filter]
description=opponent
[/filter]
[/have_unit]
[else]
[unit]
description=opponent
x=5
y=39
[/unit]
[/else]
[/if]
Why did the fish laugh? Because the sea weed.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

[have_unit] takes a standard unit filter, but not inside a [filter] tag. I used to have problems figuring out whether or not I should use a [filter] tag or not, but the wiki is actually quite consistent on this: it usually says whether to just use a "standard unit filter" (see http://www.wesnoth.org/wiki/FilterWML) or "[filter] (standard unit filter)" (which just means to put the standard unit filter inside a [filter] tag). So in this case, just use:

Code: Select all

[if]
[have_unit]
description=opponent
[/have_unit]
[else]
[unit]
description=opponent
x=5
y=39
[/unit]
[/else]
[/if]
(of course, the [unit] definition you have there is incomplete, since there is no type, side etc)
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

What if I want to resurrect a leader when he dies? Even when he's the only leader??

If thats not possible... then what about the code to check that whenever his health is less than 20 and is next to an enemy unit, he gets teleported back to base with full health??


That's all i could figure out so far... but how do you check whether they are next to an enemy unit and if they have less than 20 health??

In this case though, type and side is not necessary, right? (but it is when you are creating a new unit...)

Code: Select all

[Event]
name=moveto
first_time_only=no
[filter]
description=Opponent
[/filter]
[teleport]
[filter]
description=Opponent
[/filter]
x=39
y=5
[/teleport]
[/Event]
[Event]
name=moveto
first_time_only=no
[filter]
description=konrad
[/filter]
[teleport]
[filter]
description=Opponent
[/filter]
x=39
y=5
[/teleport]
[/Event]
The following might be able to check how mumch hitpoints... but how do you define "hitpoints" as a variable??

Code: Select all

[if]
[have_unit]
description=Opponent
[/have_unit]
[variable]
name=hitpoints
less_than=20
[/variable]
[then]
[teleport]
[filter]
description=Opponent
[/filter]
x=5
y=39
[/teleport]
[/then]
[/if]
Also... I want to eventually turn this into a multiplayer scenario with up to 3 heroes per side... wont be hard, right?? :roll:
Why did the fish laugh? Because the sea weed.
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

Actually... Don't worry... I figured out another way....
Why did the fish laugh? Because the sea weed.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

appleide wrote:What if I want to resurrect a leader when he dies? Even when he's the only leader??
Make a name=die event for the leader, and in that either heal him or spawn a new version of him.
appleide wrote:That's all i could figure out so far... but how do you check whether they are next to an enemy unit and if they have less than 20 health??
Store the locations of the hexes that have an enemy on them and which are around the unit by using [store_locations]. If the variable where you stored them was surrounding_enemies, check surrounding_enemies.length. If it's 0, no locations were stored, and thus no enemies were adjacent to the unit, if it's greater than 0, there were enemies adjacent.
appleide wrote:

Code: Select all

[Event]
name=moveto
first_time_only=no
[filter]
description=Opponent
[/filter]
[teleport]
[filter]
description=Opponent
[/filter]
x=39
y=5
[/teleport]
[/Event]
[Event]
name=moveto
first_time_only=no
[filter]
description=konrad
[/filter]
[teleport]
[filter]
description=Opponent
[/filter]
x=39
y=5
[/teleport]
[/Event]
These events (it's "event", not "Event", btw) really make no sense. They cause "Opponent" to teleport to 39,5 whenever "konrad" or "Opponent" himself moves.
appleide wrote:The following might be able to check how mumch hitpoints... but how do you define "hitpoints" as a variable??
You need to store the unit, and check the unit variable hitpoints. So if you store the unit to variable stored_unit, you can check the variable stored_unit.hitpoints directly to see the number of hitpoints the unit has.
appleide wrote:Also... I want to eventually turn this into a multiplayer scenario with up to 3 heroes per side... wont be hard, right?? :roll:
It'll be some time before you get that working. But really, you seem to have a lot of basic errors and clear mistakes in how you perceive some of this WML stuff. I suggest you take some time to work out how filters, [if]'s, variables and unit variables work. Just create a working "empty" scenario and experiment with different kinds of events. For example:
  • An event that triggers when a specific unit steps on a specific hex.
  • An event that tells you when there are less than five enemy units left.
  • An event that tells you how many forest hexes there are on the map.
...and so on. Also, while I didn't give you ready code for checking for adjacent enemies or for checking a unit's hitpoints earlier, I did give you enough information for you to be able to implement those things. If not, then you need to practise the basics more.
appleide wrote:Actually... Don't worry... I figured out another way....
I wrote this much already, so I'll post it whether you want it or not. :wink:
Last edited by zookeeper on January 12th, 2006, 4:36 am, edited 1 time in total.
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

Thanks zookeeper... I've applied what you've said. :)

Code: Select all

[event]
name=moveto
first_time_only=no
[filter]
x=37,34,40,37
y=1,2,2,4

[/filter]
[store_gold]
side={side_number}
[/store_gold]

blablabla
Here... there are 4 shops... but instead of making 4 sections of duplicate code (at least not until I have thought of every item to implement), i just used commas seperating the coordinates in the filter... but there is no effect.



Thanks!!
Last edited by appleide on January 12th, 2006, 6:36 am, edited 1 time in total.
Why did the fish laugh? Because the sea weed.
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

How do you make this apply to a specific player only?? i.e not everyone gets this message.

note: everyone would get a different version of the message... but it would result in alot of duplicate code.. anyway to resolve that??

EDIT: just found the section on macros...

Code: Select all

[event]
name=start
first_time_only=no
[message]
speaker=narrator
message=_ "What kind of Hero are you?"
[option]
message=_ "Commander (begins with 100 gold)"
[command]
[unit]
type=Commander
description=Player1
x=37
y=2
side=1
user_description=Hero
upkeep=full
moves=1
[/unit]
[/command]
[/option]
[option]
message=_ "Longbowman (begins with 130 gold)"
[command]
[unit]
type=Longbowman
description=Player1
x=37
y=2
side=1
user_description=Hero
upkeep=full
moves=1
[/unit]
[/command]
[/option]
[option]
message=_ "Red Mage (begins with 50 gold)"
[command]
[unit]
type=Red Mage
description=Player1
x=37
y=2
side=1
user_description=Hero
upkeep=full
moves=1
[/unit]
[/command]
[/option]
[option]
message=_ "White Mage (begins with no gold)"
[command]
[unit]
type=White Mage
description=Player1
x=37
y=2
side=1
user_description=Hero
upkeep=full
moves=1
[/unit]
[/command]
[/option]
[option]
message=_ "Swordsman (begins with 100 gold)"
[command]
[unit]
type=Swordsman
description=Player1
x=37
y=2
side=1
user_description=Hero
upkeep=full
moves=1
[/unit]
[/command]
[/option]
[option]
message=_ "Pikeman (begins with 110 gold)"
[command]
[unit]
type=Pikeman
description=Player1
x=37
y=2
side=1
user_description=Hero
upkeep=full
moves=1
[/unit]
[/command]
[/option]
[/message]
[/event]

Edit: i solved it.... ALpha version works 100% But there will be more features. Like the one this post is talking about above this.
Last edited by appleide on January 12th, 2006, 10:00 am, edited 1 time in total.
Why did the fish laugh? Because the sea weed.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

There is no coordinates problem, there is a [store_gold] problem. Correcting it will still not make it do anything visible, though. Learn how to use variables first. Set a variable, and print out the value in a [message] or something.
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

zookeeper wrote:There is no coordinates problem, there is a [store_gold] problem. Correcting it will still not make it do anything visible, though. Learn how to use variables first. Set a variable, and print out the value in a [message] or something.
Thanks for replying... but I already solved it... forgot to edit the post....

:lol:


The scenario I am making is posted in the User's Forum

http://www.wesnoth.org/forum/viewtopic.php?t=9240
Why did the fish laugh? Because the sea weed.
Post Reply