Map Database  •  FAQ  •  RSS  •  Login

Mission files document released!

<<

Litude

User avatar

King Karolus

Posts: 1233

Joined: 01 May 2006, 22:00

Website: http://www.knightsandmerchants.net

Location: Finland

Post 22 May 2006, 12:36

Mission files document released!

It seems like my host is down, and I promised to release the document on the commands that you can use when creating missions yesterday, so I decided to release it here on the forum.
  Code:
/------------------------------------------------------------------------------------------\ |                                                                                          | |                              -KNIGHTS AND MERCHANTS-                                     | |                              MISSION DESIGN DOCUMENT                                     | |                            FOR THE PEASANTS REBELLION!                                   | |                                                                                          | |                                  BY REAL HOTDOG                                          | |                                    VERSION 0.7                                           | |                                                                                          | |                                    INCOMPLETE!                                           | |                                                                                          | |                                                                                          | |                   THIS IS AN INCOMPLETE VERSION OF THE DOCUMENT AND,                     | |                   IS NOT NEARLY AS GOOD AS THE FINAL VERSION WILL BE                     | |                                                                                          | \------------------------------------------------------------------------------------------/  /---------------------------------------------\  | ======================                      |  | |0. TABLE OF CONTENTS|                      |  | ======================                      |  |                                             |      THIS GUIDE IS BEING MADE ABSOLUTELY  |    SECTION                           CODE   |      FREE OF ANY PROFIT! IF YOU PAID FOR  |  1. Purpose of this guide           [POFG]  |      THIS GUIDE ON USUAL SCAMMING PLACES  |    1.1 Version history              [VERH]  |      SUCH AS EBAY, NAG YOUR SELLER, NOW!  |  2. Explanation of the commands     [EXTC]  |  |  3. Values                          [VALU]  |  |    3.1 Ware ID-Values               [WAID]  |  |    3.2 Unit ID-Values               [UNID]  |  |    3.3 Building ID-Values           [BLID]  |  |  4. Closing & Credits               [CGCS]  |  |                                             |  \---------------------------------------------/ ============================================================================================ | 1. Purpose of this guide                                                          [POFG] | ============================================================================================ This file will describe all the commands that can be used when editing the mission files. In order to convert the mission files into readable ASCII you must calculate the file with EF using XOR (8-bit Unsigned Byte and value in Hex!). This tutorial has been made using mission1.dat file! Another purpose for this guide is also to help those who might be interested in making a mission editor for the game and make sure they don't need to do the extra job to find out what all the different strings do. Note that a text only version is currently available! A HTML version of this guide will probably be released later... ============================================================================================ |   1.1. Version history                                                            [VERH] | ============================================================================================ Version 0.7  Release Date: 21.5.2006 Changes: - Initial release ============================================================================================ | 2. Explanation of the commands                                                    [EXTC] | ============================================================================================ When you convert the files you'll probably notice that there are some strings with // in them. By using them, you can write comment/note into the script so that you can easier understand what's happening in different parts of the code. The official missions have also got a lot of comments written inside them. The strange part is that some missions have the comments written in German (not strange since creators are from Germany), but some mission also have the comments in English (maybe Adam Sprys wrote the comments in German & Andre Qua? in English?). You can also put an entire line as a comment by NOT starting it with a !. Please also note that always when scripts include coordinates the first value specifies the x coordinate and the second the y coordinate. Note that when specifing the x coordinate a higher value will mean that the object will be more to the right and a higher y value will put the objective lower on the map. Some things that are yet unknown but would be nice to know is whether there is specific order for the commands to come, or if you're allowed to put them where ever you want. If a piece of script that has been copied has a command inside pharenthesis it means that the command was not in the original script but was added Every mission file should start with the following strings: !SET_MAP   "data\mission\sMaps\save01.map" !SET_MAX_PLAYER   4 The first string tells the game which terrain file to be used with the specified mission file. The second string tells how many players can be playing on the map at the same time. Make sure that every string you write starts with an ! as otherwise the game will just ignore it completely taking it as a comment. After that the following strings should come: !SET_CURR_PLAYER 0 !SET_HUMAN_PLAYER 0 !ENABLE_PLAYER 0 !CLEAR_UP 62 65 15   // kl?rt auf !CENTER_SCREEN 55 65 !RELEASE_HOUSE 9 (!SET_STOCK  15 16) The string !SET_CURR_PLAYER 0 tells the game which players houses, soldiers etc. you're currently scripting. All the scripts that set houses, units etc. after this string will go to the player specified by the value after !SET_CURR_PLAYER. To start scripting to another player put the same command and change the value to that of another player. !SET_HUMAN_PLAYER 0 tells the game which player the human shall control. !ENABLE_PLAYER allows you to move around your units and makes all your citizens work, so it's a neccessary string. The !CLEAR_UP command tells the game somehow (yet unkown) which areas are explored and which aren't. The !CENTER_SCREEN command tells the game from which place the view will start from when you start the mission, using coordinates. !RELESE_HOUSE tells the game to allow you to build the building even though you haven't got the required buildings to normally allow you to build it. You can put a storehouse by using the command !SET_STOCK and then putting the X and Y coordinates after the string like "!SET_STOCK  15 16" would put it into X coordinate 15 and Y coordinate 16. Now you will find these commands: !ADD_GOAL 2  0   511        1200 !ADD_GOAL 3  1  0  1 !ADD_GOAL 3  1  0  2 !ADD_GOAL 4  1  0  1 !ADD_GOAL 4  1  0  2 !ADD_GOAL 4  1  0  3 !ADD_LOST_GOAL 3  0  0  0 All the "!ADD_GOAL" strings above add a building that has to be destroyed. It is currently unknown which of the goals enable what building. It looks like (not confirmed) the first string tells which players building, the second how many of them has to be destoryed, the third is no idea, and the fourth probably which type of building. Let's continue, and face these values: !BLOCK_HOUSE 1 !BLOCK_HOUSE 2 !BLOCK_HOUSE 3 !BLOCK_HOUSE 4 !BLOCK_HOUSE 5 !BLOCK_HOUSE 10 !BLOCK_HOUSE 12 !BLOCK_HOUSE 15 !BLOCK_HOUSE 16 !BLOCK_HOUSE 17 !BLOCK_HOUSE 20 !BLOCK_HOUSE 21 !BLOCK_HOUSE 24 !BLOCK_HOUSE 25 The block house commands tells the game to not allow you to build specific buildings. The value after the !BLOCK_HOUSE part is which building that is not allowed to be built. Building values can be found within the value section of this document. Now to some more values: !SET_GROUP 15 63 54 0 3 10      // axtk?mpfer !SEND_GROUP 63 47 0 (!SET_GROUP_FOOD) The above commands will create a group of soldiers and task them to walk into a specific place. The first number in !SET_GROUP is the type of unit (see Solder ID-Values for more information), the second is the X coordinate, third is Y coordinate, fourth is their facing direction, sixth is how many soldiers there should be per row, and the final one tells how many soldiers there are in the group. If you want to place a troop with full condition use the commands !SET_GROUP_FOOD. This is a "compass" telling the directions to use when creating soldier groups:     7 0 1      \|/     6- -2      /|\     5 4 3 By using the soldiers per row thing you can change the formation of the units. Putting a higher value to it than the total amount of soldiers could lead to unwanted results so you'd probably be better of without messing around with it. By using the !SEND_GROUP command you will be able to task a group of soldiers to move into an area that you've specified. The first number is the X coordinate and the second one is the Y coordinate. The last one will tell the game in which direction the soldiers shall be looking at when they reach their destination. The game checks which group is supposed to be start moving by looking which group has been previously made. Now it's time to get into the values that will allow you to place buildings and roads: !SET_HOUSE 21 67 67 SET_STREET 66 67 !SET_STREET 66 68 !SET_STREET 67 69 SET_STREET 67 67 !SET_STREET 67 68 !SET_STREET 66 69 !SET_STREET 66 70 !SET_STREET 67 70 !SET_HOUSE 17 67 57 !SET_HOUSE_DAMAGE 200 !SET_HOUSE 17 59 56 !SET_HOUSE_DAMAGE 70 !SET_HOUSE 11 63 70 !SET_HOUSE_DAMAGE 60 !SET_STREET 52 70 !SET_STREET 57 67 !SET_STREET 66 58 ... (Cut due to lenght) Using the command !SET_HOUSE you can put a building on the map. The first value tells the game which type of building in question, and the second will tell the X coordinate and the third the Y coordinate. The second command doesn't start with a ! so the game will ignore the line taking it as a comment. The next line !SET_STREET 66 68 now starts with a ! so it will work. The command will place a piece of road into X coordinate 66 and Y coordinate 68. The next few commands will also place roads until this part comes: !SET_HOUSE 17 67 57 !SET_HOUSE_DAMAGE 200 The first string will put HOUSE 17 (see Values section) into X coordinate 67 and Y coordinate 57. The string coming afterwards will script the house to be damaged by 200. Please make sure that always when you want to damage a building using commands, the house damage commands must be right after the command when you put the house (although it might work by putting it anywhere as long as the building you want to damage is the most recently scripted building, by order in the script). All the commands there are now explained so it's on to the next piece of script: !ADD_WARE 1  400   // Steine !ADD_WARE 2  50      // Bretter !ADD_WARE 7  700   // Truhe !ADD_WARE 8  70      // Wein !ADD_WARE 9  20      // Korn !ADD_WARE 10  50   // Brot !ADD_WEAPON 18 20 !ADD_WEAPON 24 9 These commands above add wares to your primary storehouse, "!ADD_WARE_TO_SECOND" command will add the wares to your second storehouse. "!ADD_WARE_TO_THIRD" probably adds the wares into your third storehouse, but it has not been tested. How the game checks for the first and second storehouses have not yet been tested, but it's probably determinated by the way they come in the script. The number of spaces between the ware ID and the quantity is not important as it will work with only one space. If you want to know the values for each ware check Ware ID-Numbers under the Values section. Now let's see how units are created: !SET_UNIT_BY_STOCK 9    // setze bauarbeiter !SET_UNIT_BY_STOCK 9    // setze bauarbeiter !SET_UNIT_BY_STOCK 9    // setze bauarbeiter !SET_UNIT_BY_STOCK 0    // setze einheit !SET_UNIT_BY_STOCK 0    // setze einheit !SET_UNIT_BY_STOCK 0    // setze einheit !SET_UNIT_BY_STOCK 0   // setze einheit !SET_UNIT_BY_STOCK 0   // setze einheit !SET_UNIT_BY_STOCK 0   // setze einheit !SET_UNIT_BY_STOCK 0   // setze einheit !SET_UNIT_BY_STOCK 0   // setze einheit !SET_UNIT_BY_STOCK 0   // setze einheit !SET_UNIT_BY_STOCK 0   // setze einheit !SET_UNIT 5 54 70   // setze einheit !SET_GROUP 14 55 82 7 5 20      // Mililz !SEND_GROUP 45 67 7 !SET_GROUP 14 57 81 0 5 15      // Mililz !SEND_GROUP 61 63 0 !SET_GROUP 14 76 66 7 5 15      // Mililz The first commands should be really self explaining. !SET_UNIT_BY_STOCK will put an unit by your storehouse, and the number is the unit ID. By using the command !SET_UNIT you can put one unit anywhere you want. The first number is the ID number of the unit, second is the X coordinate and the third is the Y coordinate. The !SET_GROUP commands were explained previously. Now it's time to take a look at how to script computer players, as a lot of the commands are already explained above. !SET_CURR_PLAYER 1 !ENABLE_PLAYER 1 !SET_AI_PLAYER !SET_AI_START_POSITION 20 5 !SET_AI_CHARACTER TOWN_DEFENSE 0 !SET_AI_NO_BUILD !SET_ALLIANCE 2 1 !SET_ALLIANCE 3 1 Some of those commadns are old, but a lot of them are new. Unfortunaely currently nothing is yet tested with the AI players so the document will end here. Don't loose your hope as I WILL continue writing this and try out different things with the AI. ============================================================================================ | 3. Values                                                                         [VALU] | ============================================================================================ In this section you will find the values of all buildings, units, wares etc. The same ID-Numbers are used in multiple places and they seem to always be the same. ============================================================================================ |   3.1 Ware ID-Values                                                              [WAID] | ============================================================================================ ID-Numbers ---------- 0  = Tree trunk 1  = Stone 2  = Timber 3  = Iron ore 4  = Gold ore 5  = Coal 6  = Iron 7  = Gold 8  = Wine 9  = Corn 10 = Loaves 11 = Flour 12 = Leather 13 = Sausages 14 = Pig 15 = Skin 16 = Wooden Shield 17 = Long Shield 18 = Leather Armor 19 = Iron Armament 20 = Handaxe 21 = Longsword 22 = Lance 23 = Pike 24 = Longbow 25 = Crossbow 26 = Horse 27 = Fish ============================================================================================ |   3.2 Unit ID-Values                                                              [UNID] | ============================================================================================ If there's a number with two different units, it means that by using the !SET_UNIT command you will get the first unit on the list, and !SET_GROUP can be used to get the second unit on the list. !SET_UNIT can also be used to put normal soldiers. ID-Numbers ---------- UNIT                                      GROUP 0  = Serf                                 0  = Nothing 1  = Woodcutter                           1  = Nothing 2  = Miner                                2  = Nothing 3  = Animal Breeder                       3  = Nothing 4  = Farmer                               4  = Nothing 5  = Carpenter                            5  = Nothing 6  = Baker                                6  = Nothing 7  = Butcher                              7  = Nothing 8  = Fisherman                            8  = Nothing 9  = Laborer                              9  = Nothing 10 = Stonemason                           10 = Nothing 11 = Blacksmith                           11 = Nothing 12 = Metallurgist                         12 = Nothing 13 = Recruit                              13 = Nothing 14 = Militia                              14 = Militia 15 = Axe Fighter                          15 = Axe Fighter 16 = Sword Fighter                        16 = Sword Fighter 17 = Bowman                               17 = Bowman 18 = Crossbowman                          18 = Crossbowman 19 = Lance Carrier                        19 = Lance Carrier 20 = Pikeman                              20 = Pikeman 21 = Scout                                21 = Scout 22 = Knight                               22 = Knight 23 = Barbarian                            23 = Barbarian 24 = Wolf                                 24 = Rebel 25 = Fish                                 25 = Rogue 26 = Seasnake                             26 = Warrior 27 = Seastar                              27 = Vagabond 28 = Crab                                 28 = Catapult 29 = Sea flower                           29 = Ballista 30 = Sea leaf                             30 = Nothing 31 = Sea duck                             31 = Nothing ============================================================================================ |   3.3 Building ID-Values                                                          [BLID] | ============================================================================================ ID-Numbers ---------- 0  = Sawmill 1  = Iron Smithy 2  = Weapon Smithy 3  = Coal Mine 4  = Gold Mine 5  = Iron Mine 6  = Fisherman's Hut 7  = Bakery 8  = Farm 9  = Woodcutter's 10 = Armor Smithy 11 = Storehouse 12 = Stables 13 = School House 14 = Quarry 15 = Metallurgist's 16 = Swine farm 17 = Watch Tower 18 = Town Hall 19 = Weapons Workshop 20 = Armory Workshop 21 = Barracks 22 = Mill 23 = Vehicles Workshop 24 = Butcher's 25 = Tannery 26 = Crashes Game (Used in beta?) 27 = Inn 28 = Vineyard ============================================================================================ | 4. Closing & Credits                                                              [CGCS] | ============================================================================================ Now it's time for the booring section that noone ever reads. I hope you liked this document and feel free to send suggestions and additional information to me by email, real._.hotdog.@.walla...com (remove punctations, but leave last one) Now I want to say thanks to the following people: free_sms_km    Without him this guide would be nothing, he figured out how to break the                encryption! Krom           Offering to make an editor for the game (labeling this guide useless :P) You            For reading this, after all a guide without readers is no guide? [END OF FILE][/quote] I hope the strange color in the document isn't a problem for you, and if you want a downloadalbe version just copy all the contents into a text document! Happy Mapping! :D
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 25 May 2006, 13:49

This guide is great ! It explains a lot of KM mission scripting stuff.
Keep it running. Don't worry, I won't finish any editor in a long time LOL :wink:

P.S. Here is its current status:
Image
http://krom.rscsites.org/images/stories/temp/kamed_2.jpg
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Litude

User avatar

King Karolus

Posts: 1233

Joined: 01 May 2006, 22:00

Website: http://www.knightsandmerchants.net

Location: Finland

Post 25 May 2006, 19:59

Looks nice! Seems like you have made some decent progress on the terrain files as well. Did you recieve any reply from Qage on the e-mail you sent to him?
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 26 May 2006, 17:27

Yes, I got mail from him including description of decoded data :) That helped a lot.
I hope to continue my work on the editor next month (I need to pass exams, I must study hard now).
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

arbuckle

Peasant

Posts: 4

Joined: 02 Jul 2006, 22:00

Post 04 Jul 2006, 22:35

I'm not sure I understand this:

"In order to convert the mission files into readable ASCII you must calculate the file with
EF using XOR (8-bit Unsigned Byte and value in Hex!)."

Can you explain what you mean by EF? And what does XOR have to do with hex to ascii conversion?
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 07 Jul 2006, 15:19

I'll try to explain.

Each byte needs to be calculated using XOR function with EF hex value.
InputByte XOR 0xEF = ResultByte
Once you convert whole file using this method you can see it as readable text :)
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

arbuckle

Peasant

Posts: 4

Joined: 02 Jul 2006, 22:00

Post 11 Jul 2006, 20:10

thanks krom.
I'm just posting this for anybody who may have the same touble as me in the future.

*******************************************
/*I'll try to explain.

Each byte needs to be calculated using XOR function with EF hex value.
InputByte XOR 0xEF = ResultByte
Once you convert whole file using this method you can see it as readable text Smile*/

#include <iostream>
#include <fstream>
using namespace std;
#define KEY 0xEF

void main()
{
FILE *filePtr = NULL;
filePtr = fopen("import.dat", "rb");
if(!filePtr)
return;

char byte, result;
while(!feof(filePtr))
{
fread(&byte, sizeof(char), 1, filePtr);
result = byte ^ KEY;
cout<<result;
}
};
****************************************************
<<

twelvespike

Rogue

Posts: 55

Joined: 04 Jun 2006, 22:00

Location: England

Post 11 Jul 2006, 21:39

looks hard and confusing to me il stick to playing it!! lol
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 12 Jul 2006, 05:36

LOL, I'll write it in Delphi then:
  Code:
var f:file; c:array[1..512000]of char; st:string; NumBytesRead:integer; begin assignfile(f,'mission1.dat'); //load the file blockread(f,c,512000,NumBytesRead) //read 512kbytes from file, actual count is NumBytesRead variable setlength(st,NumBytesRead); //set output length for i:=1 to NumBytesRead do st[i]:=chr(ord(c[i]) xor 239); //convert everything with EF (which is 239) closefile(f); //close the file end; [/quote]
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

The Knight

User avatar

Pikeman

Posts: 177

Joined: 28 Jul 2006, 22:00

KaM Skill Level: Average

Post 30 Jul 2006, 15:20

HEy, folks. Congratulations! You have pulsih illegal hacking code of the game. :shock: This is not allowed. Barbarian and me we have beware this secret a long time. Congratulations, you have killed the secret of KaM!
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 31 Jul 2006, 06:20

Thanks for writing here TheKnight :)
What are you talking about ?
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Litude

User avatar

King Karolus

Posts: 1233

Joined: 01 May 2006, 22:00

Website: http://www.knightsandmerchants.net

Location: Finland

Post 31 Jul 2006, 14:56

It's not like there wouldn't be any other games around that have documents available on how to hack the game. :P

The Knight, do you realize how many desperate KaM fans have been waiting years to be able to create their own missions for the game? And it's not like the editors you were going to release would have been more legal, right?

If Joymania and/or ZuXXeZ sends me an e-mail asking me to remove the content I'll do so, but I don't really see this as a problem.
<<

The Knight

User avatar

Pikeman

Posts: 177

Joined: 28 Jul 2006, 22:00

KaM Skill Level: Average

Post 31 Jul 2006, 15:31

What ever you want, but I again say: now you have killed the secret of KaM Source. Congratulation. -.-
BTW please answer my private message to you!
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 31 Jul 2006, 18:52

The Knight, secrets are good things, they lure us to decipher them :)

I'd really like to have a talk with you regarding KaM modding. Do you have working ICQ account ?
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

The Knight

User avatar

Pikeman

Posts: 177

Joined: 28 Jul 2006, 22:00

KaM Skill Level: Average

Post 31 Jul 2006, 20:45

85637988

Return to “Map Design”

Who is online

Users browsing this forum: Google [Bot] and 18 guests