#Mapping basics:
#Do the acual tiling in the Map Editor. Once the map looks good, break out a
#text editor. Use this file and the provided maps for help.

#Example map and command list.
#comments are marked with #, spaces/caps don't matter in the def section.

#This is the actual map. Use a fixed-width font to display/edit correctly.
#"a" should be used as rock or whatever your border will be, but any letters,
#numbers, or symbols can be used. Case matters here.  There must be *exactly*
#one space between each symbol.  A "symbol" is whatever appears delimited by
#the spaces, so you could, for example, substiture "hi" instead of "h" below.
#It is suggested that you use the provided map editor for this part.

a 2 a a a a a
a 0 0 0 0 h a
a 0 0 0 a a a
a 0 0 0 3 5 a
a a a a a a a

#After the map comes the definitions section.
:def
#This gives the monsters that inhabit the area. They are defined in
#monster.txt
monster=Ant
monster=Rat

#This defines what the '0' character meant when used in the map.
:0
#Use the grass.png picture when displaying. Take a look at the
#images/tiles directory for the list of usable pictures.
pix grass.png
#Yes, you can walk on it. Use either 1 (grass) or 0 (rock).
walk 1

#note that this tile (a) will also be used for the off-map areas as well.
:a
pix rock.png
walk 0

:2
#Example of stairs.
pix mine.png
walk 1
#the word action gives the commands that occur upon stepping on the tile.
Action
#This does the work, moving the player to map2.txt, xy coord. 5, 7
move map2.txt 5 7

:3
pix town.png
#if you have already attacked, let the player through.
if var have_attacked=1 | walk 0 | walk 1
Action
#If you have already attacked, stop the script
if var have_attacked=1 | end | pass
#A dialog box will display this.
info Looks interesting.
#Ask the player to enter the hole. If they answer no, the script ends
#(without allowing them to move). If they answer yes, the script continues.
if question Enter this hole? | pass | end
#Attack the player with an Ant. If they run, the script ends. If they die,
#endgame.txt is processed. If they win, the script continues.
if attack Ant | pass | end
#set have_attacked, so it will only work once.
set have_attacked=1
#allow movement over this square after attacking.
walk 1

:h
pix grass.png
walk 1
#run the tile "Find Gold"
Action
if var get_gold=1 | info You find an empty chest | run Find Gold


#Note that tile names do not need to be just one character. While this tile
#cannot be displayed on the map, it can be called with the "run" command.
#This can be useful in building larger scripts.
:Find Gold
Action
info You find some gold.
give gold 50
set get_gold=1

#Displaying Items to be Found
#To find items and allow player the option of picking them up or not
#and display an image on the map for the item, use the following.
#Note that if you have multiple of the same item on the same map
#you will need to use different symbols and variables in order to
#have it correctly keep track of whether or not the item has been
#picked up.
:m
pix items/grass_healing_potion.png
#initially display the item tile, which must be in tiles/items/
#and must be named background_item_name.png where background is
#the name of the tile to show after the item is picked up and
#item_name is the name of the item with underscores for any spaces.
walk 1
Action
#check if they've already picked it up, if not, call find with
#the name of the item in double quotes followed by the amount.
#The amount should be a word for items and an integer for gold.
#Three examples:
#   find "old spell book" an
#   find "gold" 5
#   find "healing potion" a
if var gotpotion=1| pass| find "healing potion" a
#Call got to see if they've picked it up or not and set the
#variable you're using (gotpotion in this case) to 1 (ie. true).
if got "healing potion" |set gotpotion 1|pass
#Switch the tile to the background one if they've picked it up.
if var gotpotion=1| pix grass.png|pass

:5
pix exit.png
walk 1
Action
#Note the \. That continues the line. Rephased, it would be:
#info You Win
info \
You Win
#Call wingame.txt.
win


#onload/action:
#each tile has two scripts; one for when the map is entered (onload), and one
#for when the tile is touched by the player (action). The tile definition
#starts in onload mode, and can switch back and forth using "onload" and
#"action". There are two elements that need to be in the onload section;
#"pix", and "walk". Putting a few "if" statements in would also work.
#Commands like info, on the other hand, are a bad idea.

#xy
#The "xy" command will switch from defining types of tiles, to specific
#tiles. For example, you could fill an area with grass, then add something
#to some of the grass squares. Use ":x, y" to give data for a certain xy coord.
#(again, the tile starts out in onload mode, and can move to/from action) and
#the "tiles" command to move back.



#Complete list of working commands:
#Each entry gives the syntax, then an example, then some comments on the
#command. Also see the files in the data directory.

#\
#info \
#Display line.
#Not a real command, but if a line ends with \, it can continue to the
#next line.

#monster=String
#monster=Cave Bear
#Note that this only goes between :def and the first tile definition.
#It specififies the monsters available on the map. Use a monster more than
#once to weight the listings. (ie, Ant, Ant, and Spider will give Ants twice
#as often as Spiders.)


#:Letter or Number
#:t
#Start defining a new tile. Note that case matters, and only use one digit if
#you want to use it on the map. Also note that the tile "1" will be used for
#off-map portions.

#Number
#3
#returns the given number. Useful for if statements.

#action
#Switch to defining the action scripting, which is called when the player
#moves into or over the tile. Also see onload

#addpix Filename
#addpix potion.png
#Places the given picture on top of the current tile. It is recommended to
#use a tile with transparent areas. The same restrictions as the pix command
#apply.

#addskill String
#addskill Rage
#Gives the player the specified skill. Returns 1 on success, or 0 on failure.
#(Either through the player already having the skill, or the skill not
# existing.) Use Rage, Sneak Away, Dismember, or Frenzy.

#attack random Mapname OR attack String
#attack random level4.txt
#attack Ant
#Attack either a random monster from the map Mapname, or the monster
#given with String. Returns 1 if the player won, 0 if the player ran, or
#ends the script and calls endgame.txt if the player loses.

#die
#Die. This kills the player, and calls endgame.txt. Automatically called upon
#hp reaching 0.

#end
#End processing the script. Note that this is only useful with If.

#give String Action
#give maxhp 5
#give gold rng 9 9
#Adjust stats; possible values for String: hp, ep, maxhp, maxep, attack,
#defense, gold, exp, skillpoints. Note that Number can be either
#positive or negative, and can be any number or command.
#(rng works best, though)

#hero Filename minus .png extension
#hero hero_w
#Give a specific picture to the hero. While any picture can be used (that would
# work for pix=) it is recommended to use one of the hero_n (s, e, w) pictures.

#hurt Action
#hurt 10
#hurt rng 5 5
#Injure the player for Number or Action points, reduced by armor.

#if Action1 Comparison Action2 | Action3 | Action4
#if rng 4 5>2 | attack random level1.txt | pass
#Performs Action1 and Action2, (These can be any actions, though some are more
#useful than others) then compares them. (either use =, <, >, <=, or >=)
#If the comparison is true, then perform Action3. Otherwise, perform Action4.
#End and Pass are useful for the 3nd/4rd places, and Attack, Item, Rng,
#Question, Var, and Take are useful for the 1st.
#For actions that may kill the player, (eg: Hurt, give hp -5) simply follow the
#action with others, and don't bother with If, as death ends the script anyway.
#For Attack, success is defined by destroying the monster, failure by
#running away. Death simply ends the script. (And calls endgame.txt)

#info String
#info Hi there!
#Put the given line into the message scroller.

#item String
#item light healing potion
#Give the player the item specified. (case-insensitive) Fails if the
#inventory is full, so use with if to prevent trapping the player in an
#unwinable state.

#lose
#Lose the game. Note that this does not call endgame.txt, differing it from
#die. Use die whenever possible; use lose only in endgame.txt.

#move mapname x y
#move town.txt 4 6
#Move the player to the given location. mapname is the complete filename of the
#map, (no need for path) and x and y are the xy coordinates inside the map.

#onload
#Switch to defining the onload scripting, which is called when the player
#enters the map. Also see the action command. The tile starts in onload mode,
#so this command gives no extra power, but can help convenience.

#pass
#Do nothing. Only useful with If.

#pix Filename
#pix rock.png
#Change the picture to the given file. Only .png is supported,
#and the file must be in the images/tiles directory. One of these in the onload
#section of a tile is highly recommended. Note that subdirectories are
#supported.

#question String
#question Leave this area?
#This creates a dialog box with a body of String and yes/no buttons.
#Use with the If command. Yes returns 1, and No returns 0.

#refresh
#Refresh the screen. This is useful if you want to move the player *then*
#show a dialog box.

#rng Number1 Number2
#rng 4 9
#This creates a random number between 1 and Number2. (ie, if Number2 is 3, the
#possible values are 1, 2, or 3.) The number is then compared with Number1.
#If Number1 is higher or equal, the random number is returned. Otherwise,
#0 is returned. Note that the probability of >0 returning can be expressed
#as the fraction Number1/Number2. ie, rng 3 4 will return True 3/4ths of
#the time. Also note that rng 5 5 will return a random number between 1 and 5,
#which can be used in the give and hurt commands. Finally, note that rng 4 5
#will give a random number between 0 and 4.

#run String
#run Monster Attack
#This command runs the tile defined by String. Note that even through most
#tiles are only a single character, any string will work. The example runs
#the tile "Monster Attack".

#set String Operation Number
#set have_entered=1
#set num_attacked +1
#set a variable. Use the var command to compare. This information is
#saved when saving the game, and is useful for one-time actions. Use either -,
# +, or = as the Operation.

#stat String
#stat maxhp
#Returns the value of the stat String. Possible values for String:
#hp, ep, maxhp, maxep, attack, defense, gold, exp, skillpoints.

#store Number
#store 3
#Enter a store. The possible values are 1 (Weapons store), 2 (General store),
#3 (Armory), and 4 (Training Hall).

#take String
#Take or drop an inventory item. When used with If, can implement keys and
#the like.

#var String
#var have_entered
#returns the current value of String, or 0 if String is unset. Use with If.

#walk Number
#walk 1
#Set the ability for the player to walk on it. The only values accepted are
# 0 (can walk) and 1 (can not walk)

#win
#Call wingame.txt.


#Other information:
#When debugging, run the game from the command line. All errors are sent that
#direction.

#To create your own module, create a directory in modules, called whatever
#you want. (Make it fairly descriptive, though.) Include the needed files
#(copy-paste from another module would be the easy way to do this, though note
#that the save/ directory is unneeded) and everything should work.

#Note that subdirectories in the tiles/ directory will work.

#When drawing buttons, it is possible to change the widths and heights.
