yunings 发表于 2007-3-8 23:56:18

Adventure WoG Map Creation Tutorial

Author:TNT
Original posted:http://heroescommunity.com/viewthread.php3?TID=21539


ADVENTURE MAP CREATION TUTORIAL

By TNTsystems Corporation 2007.
NOTE!!!
(1) This tutorial will be updated shortly.
(2) I recommend downloading .doc file from
TNT Heroes 3 Group
, files section.
(3) Last code lines are not valid. Will be corrected in the next version.
(4) Sorry for any spelling/grammar errors.
(5) Adventure Map Creation tools will be uploaded to yahoo group that will make the creation process easier.
(6) ERM Box Project will be completed soon.
(7) Comments, suggestions, bug reports are welcome at tntvteod(at)neobee.net or deplement3@yahoo.co.uk
TNT, Supreme Master Arcomage of WR.

CHAPTER 1: Introduction to ERM

Even if you already understand the basics of ERM (like trigger, reciever syntax, variables etc.) you cannot skip this part – we’ll start creating our first map (it’s most important that you read the syntax in blue boxes). If you’re not sure about any part of ERM it is highly recommended that you carefully read this chapter.
The ERM (Event Related Model) is a scripting (programming) language for Heroes of Might and Magic III: In the Wake of Gods expansion pack that mainly consists of triggers, receivers and instructions. We will now explain these in greater detail.
Triggers
Triggers are events that will activate receivers following it. There’re two groups of triggers: default triggers and post-visit triggers. All default triggers begin with exclamation mark followed by a question mark (!?). When you begin line with !?, ERM will recognize a trigger. After !? should be two-letter trigger name. For example: object trigger (activates when a hero visits an object on the map) is defined with letters OB. So, when you want something to happen when a hero visits an object, place !?OB. The trigger is still incomplete. You must specify the object. This can be done either with its exact coordinates – x/y/l where x is horizontal coordinate, y vertical and l is the object level (0-surface, 1-underground) – you’ll need this all the time, or with the object type and subtype (this is used with ERM scripts). If you specify object’s type and subtype (T/S) then the following receivers will activate when any object of that type and subtype is entered. Subtype can be omitted – any object with specified type will be a trigger. At the end of a trigger goes semicolon (;). Post visit triggers work the same – they’re recognized with !$.
NEW TRIGGER LEARNED – Object Entrance
!?OB#1/#2/#3; where #1 = x, #2 = y, #3 = level
!?OB#1/#2; where #1 = type, #2 = subtype
!?OB#1; where #1 = type
!$OB sameAsAbove;
The rest of the triggers will be explained further on. If you don’t understand something about triggers – don’t worry – practice makes prefect. Now, lets see a quick overview of the receivers.
Receivers
Receivers are sets of commands you can use to make your adventure map (or ERM script). All of them begin with a pair of exclamation marks (!!) followed by two-letter receiver name. For example: information receiver is used to display message boxes and manage flags (we’ll cover flags later). Now the syntax: !!IF. Receiver commands can be accessed after the colon (:). To display a simple message with just OK button on the bottom you need message command (M). The message command is followed with a string between carets (^). At the end goes a semicolon (;).
NEW RECEIVER COMMAND LEARNED – Information Receiver Simple Message
!!IF:M^stringText^; where stringText is text you want to display.
Information Receiver has many commands but we’ll explain them when we need them. The rest of the receivers will be also explained futher on. IMPORTANT: you can’t have a receiver without a trigger above it! Read green text again and then proceed to practical work #1.
Practical Work #1
Open tutorial map one (tut_map01.h3m) and scroll your view to the bottom-right corner of the map. You should see Cale Frogs – your main (and only) hero and a water wheel. When hero visits the water wheel we want to display a message “Hello there. Want something?” In-game, when you click OK on our message box, the default message box with a resource icon will be shown and player will get certain amoung of resources (as usuall). To create our message box do following:
1) Open menu Tools/Map Specifications…/Timed Events tab;
2) Create a new Timed Event called “Practical Work #1” for example, set the day of 1st occurrence to maximum (672) and disable all players from getting the message.
3) In the message textbox write the code:
ZVSE
!?OB32/30/0;
!!IF:M^Hello there. Want something?^;
When you want to make a Timed Event ERM page, type “ZVSE” on the beginning (program thus recognizes that the Timed Event is ERM code page. Our water wheel is on the surface at 32, 30, so we create an object trigger for object at that position (the yellow square in map editor – object entrance). When the object is visit the message will be shown. Now save the map and run it in the game. If everything works fine proceed to the next section. If not, check if you typed everything correctly, Timed Event properties and similar.
Comments
As your code grows it’s harder to understand every part of it so you need to comment lines. This can be done rather easily. Everything behind the semicolon (;) is considered a comment. You can use asterisk (*) to create comments, too. This is the same code as in the practical work one but this one is commented. IMPORTANT: comments do not change the ERM functionality.
ZVSE
!?OB32/30/0; when the water wheel is visited
!!IF:M^Hello there. Want something?^; show message
If you create a map and want to add something afterwards, it may be hard to figure out what is 32/30/0. Yes, you can check the coordinates in the map editor but that takes additional time. Commenting will become a habit of yours after we’ve finished the tutorial.
Instructions
Instructions are receivers that are not activated by a trigger. Instead, they’re activated when the map initializes (on the beginning). Instructions have the same syntax as the receivers, but they begin with !#. For example: !#IF:M^The Map is initializing.^;
Instructions are used to modify the map before it is shown to the player. (If a square is impassable and you want it to become passable, you’ll use an instruction. The same goes if you want to disable the default behaviour of an object.)
Conditional Flags
Flags are yes/no (true/false, 0/1) variables which are used to check if something is done. For example: if you want to display a message when the water wheel is visited “Hello there. Want something?” and when you visit it again, the message should be “Get lost?” To set or reset a flag you use information reciever, variable command: !!IF:V#1/#2; where #1 is flag number and #2 is 0 (false – reset) or 1 (true – set). The code for above example is shown here:
ZVSE
!?OB32/30/0; when the water wheel is visited
!!IF&1:M^Get lost?^; show message if flag 1 is set
!!IF&-1:M^Hello there. Want something?^; show message if flag 1 is not set
!!IF:V1/1; set flag 1 (to true)
It is not recommended that you type all code “in line”. Make a few spaces for every receiver (trigger should remain intact as a header).
Practical Work #2
If Tutorial Map 1 is not opened open it now. We will now change code of our water wheel. To do so, open Timed Events section in the map editor and double click on the timed event with 'day 672. In the “message text” section of the window will be the code from practical work 1. Change the code as follows:
ZVSE
!?OB32/30/0; when the water wheel is visited
!!IF&1:M^Go away!^; show message if resources picked up
!!IF&-1:Q1/2^Hello there. Want something?^; ask the question if entered the first time
When the water wheel is visited a message box with text “Hello there. Want something?” and with two buttons (OK and Cancel) will be shown. If yes is clicked then you’ll get the default message with resources and if you visit the water wheel again, you’ll get message “Go away!”. If you clicked “no” in the first message box and visit the water wheel again, you’ll get the same message until you click yes. However, you’ll get resources from the default message box even if you’ve clicked “no”.
NEW RECEIVER COMMAND LEARNED – Information Receiver Question Message Box Style: Simple
!!IF:Q#1/2^stringText^; where #1 is the flag which will be set to true if “yes” clicked. “2” defines the style of the box (two buttons box)
We don’t want to give resources to hero if he/she refused them so we’ll disable the water wheel’s default action and enable it only if yes clicked. This can be done with Object Receiver:
ZVSE
*Map Setup*
!#OB32/30/0:S; disable the water wheel’s default action
!?OB32/30/0; when the water wheel is visited
!!IF&1:M^Go away!^; show message if resources picked up
!!IF&-1:Q1/2^Hello there. Want something?^; ask the question if entered the first time
!!OB32/30/0&1:R; enable the water wheel’s default action if “yes” clicked
!!OB32/30/0:S; disable again after the first visit
&1 means that the action will be taken only if flag 1 is set. &-1 means that the action will be taken only if flag 1 is not set. Conditional flags are marked in the above code box.
NEW RECEIVER COMMAND LEARNED – Object Receiver Enable and Disable to All command
!!OB#1/#2/#3:S; disables the object with coordinates #1, #2 on level #3 (0 – surface, 1 – underground) to all
!!OB#1/#2/#3:R; re-enables the object with coordinates #1, #2 on level #2 to all
Information System – Displaying Pictures
The default action when the water wheel is visited is to display a message box with picture of resource you’re going to get (along with their quantity). You can display the same type of box using information receiver: !!IF:Q1/21/0/1^”Hi there”, says a pikman guarding the water wheel.^; where 21 is the type of the picture (21 is for monsters), 0 is for subtype of the picture (subtype of the 21 – monster is a pikman). Number 1 following letter Q means the flag which will be set to true if yes click. Since our last number is 1, there will be no “no” button so the flag 1 will not be change at all! To display gems with quantity of 12 you need: !!IF:Q1/5/12/1^Here, take these gems.^; This will not add any resources to the visitor’s resource pool. You must add them manualy using player oriented commands receiver, resource command: !!OW:R-1/5/d12; where d12 means add 12, -1 is for current player (you can specify player).
NEW RECEIVER COMMAND LEARNED – Information Receiver Simple Question Box with a picture
!!IF:Q#1/#2/#3/1^stringText^; where #1 is flag, #2 is picture’s type, #3 subtype (or quantity)
NEW RECEIVER COMMAND LEARNED – Player Oriented Commands Receiver Resource Command
!!OW:R#1/#2/#3; where #1 is targeted player, #2 is the resource type and #3 is used to manage its quantity (set, add, remove, or check)
String Variables
String variables hold a string and are marked as “Z variables”. To setup a string variable you need a variable receiver (or instruction). For example: to set value of z1 to “Water Wheel”, you need to place either !!VRz1:S^Water Wheel^; after a trigger or !#VRz1:S^Water Wheel^; after ZVSE (in the Map Setup section). S is the string command of a variable receiver.
NEW RECEIVER COMMAND LEARNED – Variable Receiver Set String Command (Z-variables)
!!VRz#:S^stringText^; where # is Z-variable number
Practical Work #3
Open Tutorial Map 1 if it’s not opened already (tut_map01.h3m). We’re going to modify the water wheel once more. This time, it will give no resources, but will instead ask player to bring a speculum there. If he/she completes the objective, the description hint of the water wheel will change to “Water Wheel ”, and the player will earn 3500 of gold. Speculum is held by the pikman at 27/30/0. Now the code:
ZVSE
*Map Setup*
!#OB32/30/0:S; disable the water wheel’s default action
!#VRz1:S^Water Wheel^; initialize value for variable z1
!#OB32/30/0:Hz1; set z1 as description hint for water wheel
!#VRz2:S^Water Wheel ^; initialize value for variable z2
!#VRz3:S^Water Wheel ^; initialize value for variable z3
!?OB32/30/0; when the water wheel is visited
!!IF&-3/1/2:Q1/21/0/1^Sorry! No speculum, no reward. Off you go.^; show this if player hasn’t retrieved the speculum
!!IF&3/1/2/-4:Q1/6/3500/1^Good! Here is the reward I promissed.^; show this when done
!!OW&3/1/2/-4:R-1/6/d3500; give 3500 to current hero if speculum is retrieved
!!HE-1&3/1/2/-4:A-52; take the speculum from the hero if the quest completed
!!OB32/30/0&3/1/2:Hz3; set water wheel’s description hint to z3
!!IF&-2:Q2/21/0/2^Hello there. I will reward you well if you bring me the speculum from my brother. Accept?^; when first time visited show this message
!!OB32/30/0&2/-3:Hz2; set water wheel’s description hint to z2
!!IF:V1/1; set flag 1 when the first time visited
!!IF&3/2/1:V4/1; set flag 4 if objective completed
If any part of the code is unclear to you try reading the green sections. If you understand everything, we’re going to setup the pikman. You won’t be able to attack him, but to “visit” him. He’ll give you the speculum and flee.
NEW RECEIVER COMMAND LEARNED – Object Receiver Set Hint Command
!!OB#1/#2/#3:Hz#4; where #1/#2/#3 is the object’s location and #4 is the number of Z-variable. ARTIFACTS!!
Practical Work #4
To complete the quest from the water wheel you need a speculum. You’ll get one if you visit the pikman. We’ll set his description hint to “A Pikman”, disable the default action (fight) and when he is “visited” display the message box with the picture of speculum. When player clicks OK, the speculum will be added to his/her backpack and the pikman will disappear. The Code:
*Map Setup*
[…]
!#VRz4:S^A Pikman^; initialize value for variable z4
!#OB27/30/0:Hz4; set pikman’s description hint to z4
!#OB27/30/0:S; disable the pikman’s default action

[…]
!!UN&1/2/3:O27/30/0/1; delete the pikman and his hint if the objective is completed

!?OB27/30/0; when the pikman is “visited”
!!IF&3:Q1/21/0/1^I gave you all I have. Go to my brother now.^; show this if not visiting the first time
!!IF&-1/-2:Q1/21/0/1^Please visit my brother in the water wheel. OK?^; if the water wheel is not visited yet show this
!!IF&-2/1:Q1/21/0/1^Hey, you! Why don’t you help my brother? Go back to him and accept his little “quest”.^; show this if the quest is refused
!!IF&2/1/-3:Q1/8/52/1^The water wheeler? Yes, I’m his brother… OK, here is the Speculum.^; show this if the quest is accepted. (8 is for artifact, 52 for speculum)
!!IF&2/1:V3/1; set flag 3 if the quest accepted
!!HE-1&2/1:A52; give a speculum to the current hero if the quest accepted

Now test the map and see the results. You can find numbers of monsters, artifacts etc. in the formats section of the ERM help file.
NEW RECEIVER COMMAND LEARNED – Universal Commands Delete Object
!!UN:O#1/#2/#3; where #1/#2/#3 are the target object’s coordinates
!!UN:O#1/#2/#3/#4; where #1/#2/#3 are the target object’s coordinates and #4 = 1 if you want the hint to be deleted with the object (0 leaves the hint at the position)
NEW RECEIVER COMMAND LEARNED – Hero Receiver Set/Check/Get Artifact Command
!!HE#1:A#2; where #1 is the number of hero (-1 for current) and #2 is the number of the artifact (#2>0 adds the artifact, #2
NEW RECEIVER COMMAND LEARNED – Player Oriented Command Live Forever
!!OW:#1/#2; where #1 is the player (-1 is for current) and #2 is the number of days remaining before the player’s been banished (0-127) or 128-254 (live forever – don’t get warning message)
!#OW:D-1/254; set the current player to live forever
The new Quest Log – Papyrus
When the player gets a quest – it’s automaticly added to the Quest Log. However, if you create an ERM quest, you can’t put it the QL. You’ll use Papyrus instead. To add “Kill Kilgor” to the papyrus, you’ll create a string variable with the text and use Quest Log receiver: !!QW:A1/-1/-1/500; where 1 is the quest number, -1 is for the current hero (you may specify any hero you want), -1 for the current player, and 500 is the index of the string variable containing the quest text.
NEW RECEIVER LEARNED – Quest Log (Papyrus) Control
!!QW:A#1/#2/#3/$4; where #1 is the quest number, #2 is the hero who receives the quest, #3 is the owner of the hero who receives the quest, $4 is the index of Z-variable which contains the quest text
Practical Work #5
Now that you know QW receiver, we’ll add a quest to the hero’s papyrus when the quest from water wheel is accepted. This can be done thus:
*Map Setup*
[…]
!#VRz5:S^Bring the Speculum to the Water Wheel^; initialize value for variable z5

[…]
[!!OB32/30/0&2/-3:Hz2; set water wheel's description hint to z2]
!!QW&2:A1/-1/-1/5; set z5 as current hero’s quest 1
!!QW&1/2/3/-4:A1/-1/-1/-1; delete quest 1 if it’s completed
[!!IF:V1/1; set flag 1 when the first time visited]
Playing in-game sounds
If you want to play a sound during the game (when object is visited for example) you need to store its filename in a string variable and load it using play sound receiver: !!SN:Pz6; This will play sound from variable z6. If you want to play a sound already included in the game, just type its filename (can be found in the SN Format). To play an external file, type its location (data folder is the default) in the Z-variable. Example: if the sound kill.wav is located in the maps directory, use this: !!SN:Pz6; and !#VRz6:S^..\Maps\kill.wav^; Note that sound must be shorter than 10 seconds. If not, only the first 10 seconds will be played. Let’s include it in our tut_map01.h3m.
NEW RECEIVER LEARNED – Play Sound
!!SN:Pz$; where $ is the index of the string variable containing the filename
Practical Work #6
When the water wheel is visited we want to play the “quest” sound (it is played whenever a seer’s hut or a border guard is visited). Since the sound is already included in the game, we’ll create Z6 variable to contain it’s filename (quest.wav).
*Map Setup*
[…]
!#VRz6:S^quest.wav^; initialize value for variable z6

!!SN:Pz6; play sound when water wheel is visited
CHAPTER 2: Information System – Advanced Course
In this chapter, we’ll cover the information system in more depth. We’ll also list all available message boxes and their preview images. Since you already know the simple message box (M) and a part of question box (Q), we’ll skip those and learn how to show an external image (only BMP, JPG and GIF) or a video (AVI only). You’ll use two commands: !!IF:D1/7/0/0/8/0/0/0/9/0/0/0/0/0/0/0; where 1 is the box’s number,7 is the index of variable that holds box’s title, followed by two zeroes, 8/0/0/0 – four pictures (we’ll set only one – filename is in variable 8, 9/0/0/0 – mouseover hints (we’ll use only variable 9 – stores the hint for our picture). OK, we’ve setup our box. Now, we’re going to show it on the screen. This can be done using: IF:E10/1; where 1 is the number of the box and 10 stores the selection (if we’ve added any checkboxes, for example) – nothing in our case.
NEW RECEIVER COMMAND LEARNED – Information Receiver Setup/Display Extended Box Command
!!IF:D#1/#2/#3/#4/#5/#6/#7/#8/#9/#10/#11/#12/#13/#14; where #1 is the number of the box, #2 is the index of the string variable holding the title, #3 is 0, #4 is 0. #5-#8 – picture filenames, #9-#12 – picture hints, #13 is 0 and #14 is 0.
!!IF:E#1/#2; where #1 stores the answer (if there’ve been any checkboxes, optionbox etc.) and #2 is the number of previously setup box (D#1)
Practical Work #7
When the map initializes, we want to show a picture of the moon (“tm1.jpg”) and an introduction text. It goes thus:
*Map Setup*
[…]
!#VRz7:S^..\Maps\tm1.jpg^; initialize value for variable z7
!#VRz8:S^Welcome to the Tutorial Map!^; intialize value for variable z8
!#VRz9:S^This is my first picture in an extended dialog box!^; initialize value for variable z9
!#IF:D1/8/0/0/7/0/0/0/9/0/0/0/0/0/0/0; setup the box
!#IF:E1/1; display the box
[…]
Advancing the Storyline
What’s the objective you need to complete to finish the map? Are there any optional objectives? We’re going to create the master objective now (main objective or MO later in the text). It should has its storyline. You’ll hear about the graveyard of the unknown in the “Hill Fort Tavern” at 26/29/0. When you enter the object, you’ll get the default welcome message and then an option box will be displayed where you decide what to do there. It will contain these:
1. Drink and Eat. – increases movement points.
2. Rest. – takes all movement points, but dubles them the next turn.
3. Join the party. – enables more options.
4. Talk to Canne, the barman. – enables more options.
5. Exit the tavern.
We’ll first setup the box, then display it and manage its options. To setup the dialog, we’ll use the G command because D (see above) enables only 4 checkboxes and we need 5 radioboxes (optionboxes). The G syntax goes as follows: !!IF:G1/10/0/11/12/13/14/15/0/16; where 1 means we want radiboxes, not checkboxes, 10 stores the answer (what was selected), 0 means the no option is selected at the beginning (affects only checkboxes), 11 is the index of string (Z) variable that contains the title of the box (header), 12 to 15 are options 1 to 4, we want one option space and then the fifth option. IMPORTANT: z10 (the answer variable) will contain bits – choice 1 (1), choice 2 (2), choice 3 (4), choice 4 (8), choice 5 is blank, choice 6 (32). The box will be automatically displayed.
NEW RECEIVER COMMAND LEANRED – Information Receiver Radio/Checkbox Dialogue Command
!!IF:G#1/#2/#3/#4/#5/#6/#7/#8/#9/#10/#11/#12/#13/#14/#15/#16; where #1 is 0 (checkboxes) or 1 (radioboxes) #2 is the index of the string variable that contains the answer in bits, #3 is 1 (all checkboxes are set) or 0 (no checkboxes are set) – has no effect with radioboxes, #4 holds the index of the string variable containing the title (header) of the box, #5-#16 holds indexes of Z-variables containing the options’ texts.
Other Elements we need to know (at the moment)
MOVEMENT MANAGEMENT
We’ll use the HERO receiver and W command. To set movement points to 0, do this: !!HE-1:W0; where -1 means “current hero”, 0 is the value we want. Heroes usually have 1500-2000 movement points. If option 1 is selected, hero will get 500 movement points (type “d680” instead of 0 after W; “d” means “add”). Then, the player will have to pay 240 in gold. If option 2 is selected, player will lose all movement points and when the “end turn” button is clicked (or “E” pressed), he will get 1200 movement points.
NEW RECEIVER COMMAND LEARNED – Hero Receiver Change Movement Points Command
!!HE#:W$; where # is hero’s number (-1 for current) and $ is the value: if just a number – it means SET, if “d” and number it means ADD – if “d-“ and number it means SUBSTRACT, of course, “?” and number sends current value to the integer variable (V) with that number.
RESOURCE MANAGEMENT
We’ll use player oriented commands receiver – see page 3 for more information. To substract some resources, you’ll use “d-“ option, to check if player has enough resource, you’ll use “?i” (where i is the index of integer variable V receiving current among of desired resources).
Practical Work #8
Here is the code for “things” above. Be cautious not to miss anything – initialization goes at the top, Hill Fort code at the bottom. So, let’s begin:
*Map Setup*
[…]
!#VRz11:S^Welcome to the Hill Fort Tavern, traveler. What do you want to do here?^; intialize value for variable z11
!#VRz12:S^Drink and Eat…240gp^; initialize value for variable z12
!#VRz13:S^Rest…320gp^; initialize value for variable z13
!#VRz14:S^Join the Party.^; initialize value for variable z14
!#VRz15:S^Talk to Canne, the barman.^; initialize value for variable z15
!#VRz16:S^Exit the Tavern.^; initialize value for variable z16
!#OB26/29/0:S; disable the hill fort tavern
[…]
!?OB26/29/0; when the hill fort tavern is visited
!!IF:G1/10/0/11/12/13/14/15/0/16; display radiobox dialogue if option 1 is selected
!!OW&v10=1:R-1/6/d-240; take 240 gold if variable 10 holds “1”
!!HE-1&v10=1:Wd680; add 680 movement points to current hero if option 2 is selected
!!OW&v10=2:R-1/6/d-320; take 320 gold if variable 10 holds “2”
!!HE-1&v10=2:W0; remove all movement points from current hero
!?CM5; when something is clicked
!!CM:I?v11; variable v11 will receive number of the clicked object
!!HE-1&v11=12:Wd1200; add 1200 movement points to current hero if the end turn button is clicked
Mouse Click (CM) Trigger and Support
There are five types of this trigger. We’re using the last one. It activates following receivers if anything is clicked on the adventure screen. Syntax: !?CM5; Supporting receiver for this trigger is CM receiver. I command checks what’s clicked. It returns “12” if the end turn button is clicked. (See ERM Help for information about returning numbers.)
NEW TRIGGER LEARNED – Mouse Click 5
!?CM5; this activates following receiver when something is clicked on the adventure screen (left mouse button)
NEW RECEIVER LEARNED – Mouse Click Receiver, Clicked Item Command
!!CM:I#; where # is the returning number. Use ?v$ where $ is the index of V variable which receives the returning number
Debugging the Code
You’ll find that if we selected option 2 in the game, we would lose money and movement, but, when we click the end turn button, we’ll get some movement, but it will be instantly reset. So, we’re going to use a blessing that will add extra movement for one day to the hero. In fact, if you select option 2, you’ll buy the blessing. To set a blessing, we will use hero receiver, Y command. The code: !!HE-1:Y65/1200/1/1; where -1 means current hero, 65 means “add movement points” curse, 1200 means “add 1200 movement points” (power of the curse), following “1” means “lasts one day”, and last “1” means “set” the curse. (If you open the hill fort, you can buy the curse for ever, but it will not add any extra movement points, but, we can go in minus with our resources – gold, so, we will check if player has enough money to pay the curse, we’ll also check if player already bought the curse during that day.) Now, the code:
*Map Setup*
[…]
!#VRz10:S^Hill Fort Tavern^; initialize value for variable z10
!#OB26/29/0:Hz10; set hint of the hill fort tavern to the string contained in the z10 variable

!!OW:R-1/6/?v9; send current quantity of gold to variable v9
* modify following lines; they should look like this:
* if option 1 is selected
!!OW&v10=1/v9>=240/-6:R-1/6/d-240; take 240 gold if variable 10 holds “1”
!!HE-1&v10=1/v9>=240/-6:Wd680; add 680 movement points to current hero
!!IF&v10=1/v9>=240/4:M^Not today.^; show this if visited again on the same day
!!IF:V6/1; set flag 6 (“option 1 used” for this day)
*if option 2 is selected
!!OW&v10=2/v9>=320/-7:R-1/6/d-320; take 320 gold if variable 10 holds “2”
!!HE-1&v10=2/v9>=320/-7:W0; remove all movement points from current hero
!!IF:V7/1; set flag 7 (“option 2 used” for this day”)


* remove last receiver – HE:W
!!HE-1&v11=12/v10=2:Y65/1200/1/1; add “add movement” curse if the end turn is clicked
!!IF&v11=12:V6/0 V7/0; reset flags six and seven when the day ends
Advancing the Storyline
We need options 3 and 4 now. If you choose option 3 (join the party), another box with options will appear:
1. Ask your friend Raptor about your quest.
2. Overhear talk from the next table.
3. Offer 500 gold to anyone who can give you some directions on your quest.
4. Join Zaar’s table.
5. Exit the Tavern.
If you pick option one, your friend Raptor’s picture will be shown, and he will tell you about the old portal and that only one person in the land can activate it.
If you pick option two, you’ll hear hints about Grich Mansion robbery. (new optional quest)
Option three will open a new box, where you can select whos help you want (three different men will answer your call). All of them will tell you some details about the quest.
If you join Zaar’s table, he’ll ask you if you can loan him 200 gold. He’ll say he will give you 400 if you visit his house later. (new optional quest)
Options for “Talk to Barman” (4):
1. Ask him about your quest.
2. Ask him about people in the pub.
3. Exit the Tavern.
We’re using here trigger and receiver we already know, so this part should look familiar to you.
Practical Work #9
Here is the code for the above “project”. (We will use portrait of Paladin Attacker - 174 for Raptor.)
*Map Setup*
[…]
!#VRz17:S^At the pub.^; initalize value for variable z17
!#VRz18:S^Ask your friend Raptor about your quest.^; initalize value for variable z18
!#VRz19:S^Overhear talk from the next table.^; initalize value for variable z19
!#VRz20:S^Offer 500 gold to anyone who can give you some direction on your quest.^; initialize value for variable z20
!#VRz21:S^Join Zaar’s table.^; initialize value for variable z21
!#VRz22:S^Give the reward to Petters.^; initialize value for variable z22
!#VRz23:S^Give the reward to Mecho.^; initialize value for variable z23
!#VRz24:S^Give the reward to Dayane.^; initialize value for variable z24
* we will use z16 for “Exit the Tavern.”
!#VRz25:S^Find man who robbed Grich Mansion and bring him to Grich.^; initialize value for variable z25
!#VRz26:S^Visit Zaar’s house to get 400 gold.^; initialize value for variable z26
!#VRz27:S^Find all pieces of the puzzle. {4} Remaining.^; initialize value for variable z27
!#VRz28:S^Ask him about your quest.^; initialize value for variable z28
!#VRz29:S^Ask him about people in the pub.^; initialize value for variable z29

[…]
* if option 3 is selected
!!IF&v10=4/-8:G1/8/0/17/18/19/20/21/0/16; display radiobox dialogue
!!IF&v10=4/v8=1/-8:Q1/21/174/1^Oh, hi, Cale. The Graveyard of the Unknown? Well, the legend says there’s an old portal somewhere in the woods and that only one person in the land can activate it. It is said that when you collect all pieces of a puzzle – I don’t really understand this part – she will let you use the portal. However, the portal itself has never been found. I hope I was helpful. If you locate the portal, I would be glad to help you somehow. Just visit my house if you need me.^; show this if option one is selected
!!IF&v10=4/v8=2/-8:M^…Yea, I heard it, too… Perheps the thief is still in the area. I would like to earn that reward. Two thousands… Grich is very generous… I’ll do my best…^; show this if option 2 is selected
!!QW&v10=4/v8=2/-8:A2/-1/-1/25; set z25 as current hero’s quest 2
!!IF&v10=4/v8=4/v9>=500/-8:G1/7/0/17/22/23/24/0/16; display box if option 3 is selected
!!IF&v10=4/v8=4/v7=1/v9>=500/-8:M^I have a part of the cursed puzzle. Visit my house and I will give it to you. I lost hope for that Graveyard. Raise dead? Yea, sure… ^; show this if option 3/1 is selected
!!QW&v10=4/v8=4/v7=1/v9>=500/-8:A4/-1/-1/27; set z27 as current hero’s quest 4
!!IF&v10=4/v8=4/v7=2/v9>=500/-8:M^I heard that you need a boat to get there. I will rent you mine. Just visit my house. It’s a good boat: clean deck, four cannons…^; show this if option 3/2 is selected
!!IF&v10=4/v8=4/v7=4/v9>=500/-8:M^I will help you on your way. Just visit my house. I have some interesting things there, you know. Well, see ya.^; show this if option 3/3 is selected   
!!IF&v10=4/v8=4/v7=4/v9>=500/-8:V26/1; set flag 26 when Dayane’s quest accepted
!!OW&v10=4/v8=4/v9>=500/-8:R-1/6/d-500; take 500 gold from current player
!!IF&v10=4/v8=8/-8/v9>=200:Q10/6/200/2^Oh, hi Cale! I’m… a… well… can you… please… loan me 200 gold? I will give you 400 when you visit my house, you know… OK?^; show this if option 4 is selected
!!OW&v10=4/v8=8/v9>=200/10/-8:R-1/6/d-200; take 200 gold from current player
!!QW&v10=4/v8=8/v9>=200/10/-8:A3/-1/-1/26; set z26 as current hero’s quest 3
!!IF:V8/1; set flag 8 (“option 3 used” for this day)
* if option 4 is selected
!!IF&v10=8/-9:G1/6/0/17/28/29/0/16; display radiobox dialogue
!!IF&v10=8/v6=1/-9:M^Graveyard of the Unknown? Neverheard of it, sorry. Maybe you would like to join the pub. We have a lot of things to eat and drink and you can meet a friend in there. Consider it.^; show this if option 4/1 is selected
!!IF&v10=8/v6=2/-9:M^Let me see… There’re Mecho and Zaar – both drunk, I believe… Petters the farmer…Oh, Dayane is here! You should see her – most impressive… Cloves, Brigz and Welf – detectives… And some berely alive peasants. You should join them, Dayane, you know…^; show this if option 4/2 is selected
!!IF&v10=8:V9/1; set flag 9 (“option 4 used” for this day)

* change existing line – it should look like this:
!!IF&v11=12:V6/0 V7/0 V8/0 V9/0; reset flags 6, 7, 8 and 9 when the day ends
Updating the Map
There objects on the map with no hint text (title). We should name all house “A House” and when you “clear” the tavern, you should learn real names of those objects. (Zaar’s House, Dayane’s House etc.)
24/21 – Dayane’s House
15/31 – Grich Mansion
19/26 – Zaar’s House
24/34 – Detectives’ Headquarters
33/18 – Petters’ Farm
28/19 – Haunted House
26/24 – Mecho’s House
When you visit one of these objects and the hint hasn’t already been updated, it should be updated then. We also have to program these objects – make them do what we need:
1. If you visit Dayane’s House and you have never talked to her, you should be able to learn a spell
there, for a fee. If you’ve talked to her already, you can ask her to help you on your quest, in addition to the “learn spell” option.
2.If you visit Grich Mansion, you’ll get the optional quest (2) if you don’t have it already. Also, the hint
   will be updated if not already.
3.   Zaar will give you money if you have spoken to him, otherwise you’ll get message that he’s not at
home.
4. Detectives’ Headquarters will be empty if you haven’t overheard their conversation at the pub. If so,
they will tell you to go away.
5. Petters will give you the first piece of the puzzle if you’ve spoke to him in the pub. If not, his wife will
give an optional quest to bring wood to her from their worker, Weraldo. (He has “A Peasant” hint description until you talk to him, or take the optional quest from Mrs. Petters.) When the quest is completed, you’ll get 6 gems. (You’ll use these to buy another piece of the puzzle later.)
6. Haunted House contains the second piece of the puzzle, but you will have to defeat witches, wraiths
and ghosts before advancing futher into the house. You’ll find Ellene there who will thank you for destroying those monsters and ask you for 5 gems if choose to ask her about the puzzle, (if you already have the first part) or just tell you about it if you choose to ask her about your MO (if you don’t have the first part).
The code gets more and more complicated, so we need to write down what we want to code and refer to that later. When you try to create your own adventure map, it is highly recommended that you write down the story and its parts (like objectives, both main and optional) before starting the code. Now, we are going to add those things above to the map.
Practical Work #10
Don’t warry if you can’t understand what a part of code does – all new staff will be listed below the code. If you don’t understand something and you cannot find it below the code, check above green parts. (All syntax staff is there.)
*Map Setup*
[…]
!#VRz30:S^A House^; initialize value for variable z30
!#VRz31:S^A Tower^; initialize value for variable z31
!#VRz32:S^A Farm^; initialize value for variable z32
!#VRz33:S^Dayane’s House^; initialize value for variable z33
!#VRz34:S^Grich Mansion ^; initialize value for variable z34
!#VRz35:S^Zaar’s House^; initialize value for variable z35
!#VRz36:S^Detectives’ Headquarters^; initialize value for variable z36
!#VRz37:S^Petter’s Farm^; initialize value for variable z37
!#VRz38:S^Haunted House^; initialize value for variable z38
!#VRz39:S^A Peasant^; initialize value for variable z39
!#VRz40:S^Weraldo^; initialize value for variable z40
!#VRz41:S^Mecho’s House^; initialize value for variable z41
!#VRz42:S^Grich Mansion ^; initialize value for variable z42
!#VRz43:S^Welcome to Petters’ Farm!^; initialize value for variable z43
!#VRz44:S^tm5.jpg^; initialize value for variable z44
!#VRz45:S^Petters gave you the piece of the puzzle he owned.^; init. value for variable z45
!#VRz46:S^Petters’ Farm ^; initialize value for variable z46
!#VRz47:S^Petters’ Farm ^; initialize value for variable z47
!#VRz48:S^Bring wood from Weraldo to Petters’ Farm.^; initialize value for variable z48
!#VRz49:S^Find all pieces of the puzzle. {3} Remaining.^; initialize value for variable z49
!#VRz50:S^Find all pieces of the puzzle. {2} Remaining.^; initialize value for variable z50
!#VRz51:S^Find all pieces of the puzzle. {1} Remaining.^; initialize value for variable z51
!#VRz52:S^The Secret Puzzle^; initialize value for variable z52
!#VRz53:S^tm6.jpg^; initialize value for variable z53
!#VRz54:S^Nothing is revealed.^; initialize value for variable z54
!#OB24/21/0:Hz30; set hint of the Unicorn Glade to z30
!#OB15/31/0:Hz30; set hint of Grich Mansion to z30
!#OB19/26/0:Hz30; set hint of Zaar’s House to z30
!#OB24/34/0:Hz31; set hint of the Archers’ Tower to z31
!#OB33/18/0:Hz32; set hint of Petters’ Farm to z32
!#OB28/19/0:Hz30; set hint of the Haunted House to z30
!#OB20/31/0:Hz39; set hint for the Peasant to z39
!#OB24/21/0:S; disable the default action of the Unicorn Glade
!#OB20/31/0:S; disable the default action of the Peasant
!#OB26/24/0:Hz30; set hint for Mecho’s House to z30
!#OB24/34/0:S; disable the default action of the Archers’ Tower

* put black lines between blue ones (both light and dark)
!!QW&v10=4/v8=2/-8:A2/-1/-1/25; set z25 as current hero’s quest 2
!!IF&v10=4/v8=2/-8:V15/1; set flag 15 (Detectives’ conversation overheard)
!!QW&v10=4/v8=4/v7=1/v9>=500/-8:A4/-1/-1/27; set z27 as current hero’s quest 4
!!IF&v10=4/v8=4/v7=1/v9>=500/-8:V11/1; set flag 11 (You’ve spoken to Petters)
!!OB33/18/0&v10=4/v8=4/v7=1/v9>=500/-8:Hz37; set hint of Petters’ Farm to z37
!!IF&v10=4/v8=4/v7=2/v9>=500/-8:M^I heard that you need a boat to get there. I will
rent you mine. Just visit my house. It’s a good boat: clean deck, four cannons…^; show this if option 3/2 is selected
!!IF&v10=4/v8=4/v7=2/v9>=500/-8:V12/1; set flag 12 (You’ve spoken to Mecho)
!!OB26/24/0&v10=4/v8=4/v7=2/v9>=500/-8:Hz41; set hint for Mecho’s House to z41
!!OW&v10=4/v8=4/v9>=500/-8:R-1/6/d-500; take 500 gold from current player
!!IF&v10=4/v8=4/v7=4/v9>=500/-8:V13/1; set flag 13 (You’ve spoken to Dayane)
!!OB24/21/0&v10=4/v8=4/v7=4/v9>=500/-8:Hz33; set hint for Dayane’s House to z33
!!QW&v10=4/v8=8/v9>=200/10/-8:A3/-1/-1/26; set z26 as current hero’s quest 3
!!IF&v10=4/v8=8/v9>=200/10/-8:V14/1; set flag 14 (You’ve spoken to Zaar)
!!OB19/26/0&v10=4/v8=8/v9>=200/10/-8:Hz35; set hint for Zaar’s House to z35
!?OB24/34/0; when Detectives’ Headquarters are visited (Archers’ Tower)
!!OB24/34/0:Hz36; set hint for Detectives’ Headquarters to z36
!!IF:M^You’re in Detectives’ Headquarters, you know. WHAT THE HELL ARE YOU DOING IN HERE!? GET OUT!^; show this if detective’s headquarters are visited
!?OB15/31/0; when Grich Mansion is visited
!!OB15/31/0&-15:Hz34; set hint for Grich Mansion to z34
!!IF&-15:M^I’m robbed! Please find the thief. I will pay you 2500 gold! Just find the thief… and the goods. Came back here which him… or her…^; show this if you haven’t heard about the theft
!!QW&-15:A2/-1/-1/25; set z25 as current hero’s quest 2
!!IF&15/-16:M^Haven’t found the thief yet, eh? Keep looking. He’s got to be somewhere around here. Remember those gold pieces.^; show this if quest is not completed (flag 16), but you’ve already heard about the theft
!!IF:V15/1; set flag 15 (Heard about the theft)
!?OB33/18/0; when Petters’ Farm is visited
!!OB33/18/0:Hz37; set hint for Petters’ Farm to z37
!!IF&11/-19:D2/43/0/0/44/0/0/0/45/0/0/0/0/0/0/0; setup the box
!!IF&11/-19:E1/2; show the box if you’ve already spoken to Petters
!!QW&11/-19:A4/-1/-1/49; update quest 4 to z49
!!VRv13&11/-19:S1; set variable v13 to 1 (one piece of the puzzle acquired)
!!IF&-17/18:Q1/21/177/1^You don’t have the wood I asked for. Go to Weraldo and take some. Don’t return without it.^; show this if the quest is accepted, but it’s not completed
!!IF&-17/-18:Q18/21/177/2^Would you like to do me a favor? In fact, I’m going to give you some gems if you do it. Interested? OK. Bring me wood our worker, Weraldo, has. Deal?^; show this if quest is not accepted / completed (with Succubus Attacker image)
!!OB33/18/0&-17/18:Hz46; set hint for Petters’ Farm to z46
!!QW&-17/18:A5/-1/-1/48; set z48 as current hero’s quest 5
!!OB20/31/0&-17/18:Hz40; set hint for the Peasant to z40
!!IF&17/18/-20:Q1/5/6/1^Good work! Here are the gems I promissed you.^; show this if the quest is completed
!!OW&17/18/-20:R-1/5/d6; add 6 gems to the current hero’s resource pool
!!OB33/18/0&17/18/-20:Hz47; set hint for Petters’ Farm to z47
!!QW&17/18/-20:A5/-1/-1/-1; delete quest 5 if it’s completed
!!IF&11:V19/1; set flag 19 (puzzle part already acquired)
!!IF&17/18:V20/1; set flag 20 (quest 5 is done)
!?CM; when something is right clicked
!!CM:I?v12; send clicked object handle to variable v12
!!IF&v12=5/v13=1:D2/52/0/0/44/0/0/0/45/0/0/0/0/0/0/0; setup the box if quest log button is clicked
!!IF&v12=5/v13=1:E1/2; show the box if quest log button is clicked (1 piece)
!!IF&v12=5/v13=0/11:D3/52/0/0/53/0/0/0/54/0/0/0/0/0/0/0; setup the box if quest log button is clicked
!!IF&v12=5/v13=0/11:E1/3; show the box if quest log button is clicked (nothing opened)
!?OB20/31/0; when the peasant, Weraldo is visited
!!IF&-17/18:Q1/0/10/1^Here’s the wood for my mistress. Make sure she get it.^; show this quest 5 is not completed
!!IF&-17/18/-20:V17/1; set flag 17 (Weraldo is visited)
!!IF&-18:M^Mrs. Petters will reward you well if you visit her house and acomplish her task.^; show this if Petters’ Farm is not visited
!!OB33/18/0:Hz37; set the hint for Petters’ Farm to z37

!?OB19/26/0; when Zaar’s house is visited
!!OB19/26/0:Hz35; set hint for Zaar’s House to z35
!!IF&-14:M^Zaar’s house is empty. He often goes to the Hill Fort Tavern. Maybe you can find him there.^; if you haven’t talked to Zaar
!!IF&14/-21:Q1/6/400/1^Here’s the money. Thanks for those 200. I was really hungry…^; show this if you’ve already talked to Zaar
!!OW&14/-21:R-1/6/d400; give 400 gold to the current player
!!QW&14/-21:A3/-1/-1/-1; delete quest 3
!!IF&14:V21/1; set flag 21 (quest is already completed)
!?OB26/24/0; when Mecho’s House is visited
!!OB26/24/0:Hz41; set hint for Mecho’s House to z41
!!IF&-12:M^Mecho is not at home. He’s a drunk fool. Look at the Hill Fort Tavern.^; show this if you’ve never spoken to Mecho
!!IF&12/-22:M^Yes, I will give you my boat, but there is no shore to place it on. Sorry.^; show this if shore is not cleared (-22)
!!IF&12/22:M^OK, here’s the boat. I will take it to the shore. You can find it there.^; show this if shore is cleared (22)
!?OB28/19/0; when the Haunted House is visited
!!OB28/19/0:Hz38; set hint for Haunted House to z38
!!IF&-23:Q24/21/60/21/159/7^Would like to purse and engage these creatures (8 wights or 12 ghosts)?^; show this if guardians are not defeated
!!HE-1&-23/24:T28/19/0/60/8; provoke battle with 8 witches if they’re selected
!!HE-1&-23/-24:T28/19/0/159/12; provoke battle with 12 ghosts if they’re selected
NEW TRIGGER LEARNED – Right-click Trigger
!?CM; this trigger has no parameters.
NEW RECEIVER COMMAND LEARNED – Hero Receiver, Provoke Battle with some Monsters Command
!!HE:T#1/#2/#3/#4/#5; where #1 is the X coordinate of the spot on the adventure map where the battle will occure – this is important for ground bonuses (magic plants, evil fog, cursed grounds etc.), #2 is the Y coordinate, #3 is the level for the battle spot, #4 is the monster number, #5 is the monster’s quantity.
Terrain Creation at Run-time
If we want to create some terrain while playing the game, we need TR receiver. Syntax: !!TR#1/#2/#3:T$1/$2/$3/$4/$5/$6/$7/$8; where the first three # are tile coordinates we want to edit. T stays for “tile” command. For now, we need only the first two parameters of T command - $1 means terrain type, $2 means subtype. You can see terrain types and subtypes in the ERM help file.
NEW RECEIVER COMMAND LEARNED – Terrain Setup Receiver, Tile Properties command – terrain
!!TR#1/#2/#3:T$1/$2//////; where #1 is the X coordinate of the square, #2 is the Y coordinate, #3 is the tile level, $1 is the type of the tile and $2 is the subtype of the tile. The rest of the parameters are not changed.
Practical Work #11
Now we need to setup the “Need Boat” hut – Dayane will help you on your quest if you ask her. If you’ve already talked to her about your mission, she’ll help you “create” ground for the boat placement. Thus, terrain next Grich Mansion whill be created. Flag 25 will be set when the terrain is created.
*Map Setup*
!#VRz55:S^At Dayane’s House^;
!#VRz56:S^Learn a spell.^;
!#VRz57:S^Ask for help about the Boat placement.^;

!?OB24/21/0; when Dayane’s House is visited
!!IF&v14=0:Q27/9/15/2^Hello, Cale! Would you like to learn my new spell? Life is unfair – you can’t survive in this world without some magic. Well?^;
!!HE-1&27:M15/?v14; check if current hero (Cale Frogs) knows “Magic Arrow (15)” spell
!!HE-1&v14=1:M15/1; give “Magic Arrow” to the current hero if doesn’t know it already
!!IF&26:Q28/21/119/2^Oh, Cale, about your mission. I heard you need to cross the sea to get to that graveyard of yours. I know Mecho has a boat, but he needs a shore – everything is covered with trees or mountains in these parts, but I’ve learnt a spell to raise the ground! There is a place next to Grich Mansion where we can work the spell out. Do you want us to go there and raise terrain now?^; if you’ve already spoken to her
!!HE-1&28:P13/31/0; teleport hero to the Grich Mansion
!!TR12/31/0&28:T01/01/0/0/0/0/0/0; set terrain
!!TR12/30/0&28:T08/00/0/0/0/0/3/0;
!!TR13/30/0&28:T00/19/0/0/0/0/3/0;
!!TR13/32/0&28:T00/05/0/0/0/0/0/0;
!!TR11/30/0&28:T08/13/0/0/0/0/2/0;
!!TR11/32/0&28:T08/13/0/0/0/0/1/0;
!!TR12/32/0&28:T08/10/0/0/0/0/3/0;
!!TR11/31/0&28:T08/06/0/0/0/0/2/0;

sinco 发表于 2007-7-9 16:18:05

"yuning"(宇宁)is my name, you steal it,you should pay me 99999999 WoG money

sinco 发表于 2007-7-9 16:19:48

show me the money;daj;
页: [1]
查看完整版本: Adventure WoG Map Creation Tutorial

捐赠