Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.

Thorgrim

Knight at Arms
I decided we should have some kind of FAQ thread for mod makers, so...

Below is a list of Questions and answers relating to all aspects of modding Mount and Blade.  This list will be updated regularly.  Post any questions you have and we will attempt to answer them.  Also please do contribute any knowledge you have, by adding to any answers or resources, or giving answers to your own questions, and I will add it to this top post.


General editing

Q: What tools are there for general mod making?

A: There are the official tools: http://forums.taleworlds.com/viewforum.php?f=12

The in game editor can be used in game, making it very quick and easy to use, since you can immediately see any changes.
The in game editor allows decoration of scenes with items and new buildings, editing of scene settings and information, generation of terrain for use in scenes, editing of NPC faces.

The python module system is a little harder to use, and will be explained in more detail below.

There is also Effidian's excellent Unofficial editor: http://forums.taleworlds.com/viewtopic.php?t=5937


Q: Can I change the font used in game?
A: Yes, GandalfTheGrey made a great tutorial on how to do this: http://forums.taleworlds.com/viewtopic.php?t=6563


Q: How can I make my mod easy to install for those who want to use it?
A: Janus has the perfect answer: http://forums.taleworlds.com/viewtopic.php?t=5488


Q: Why can't I see the changes I made to my mod?
A: Many things are stored in the save files, and so changes made to your mod may only be visible when you start a new game.  Not everything requires you to start a new game however.


Q: How can I find out the exact coordinates the player party is at on the world map in-game?
A: With edit mode enabled, simply hit Ctrl+E on the world map in the game to have your coordinates displayed.

Another way to get a location on the map is to hold down the Z key in the map editor, and move the cursor over the map. When you release the z key the location is also copied into the clipboard so you can paste it into a python script or whatever you need it for.


Q: How can I make unique faces for NPCs?
A: With edit mode enabled, go to your Character screen and click the Edit Face button. Play around with all the sliders and settings until you've got the face you're after. Now click Ctrl+E, and you'll notice a box/button pop up at the top right with a string of characters in it. Click this and it will copy the face code to the clipboard. In module_troops.py, simply paste in it in as the face code.


The following Q&A links have been collected by smiling_cataphract:

Q: How do I use the in game Edit mode?
A: http://forums.taleworlds.com/index.php/topic,10371.0.html - a .750 Edit mode tutorial by Armagan

Q: How do I handle towns?
A: http://forums.taleworlds.com/index.php?PHPSESSID=4a421afb177ef04b5c3e26f4ab693478&/topic,8532.0.html – deals with a possible bug with having too many towns in game.
http://forums.taleworlds.com/index.php/topic,15183.0.html – why do towns become battles?
http://forums.taleworlds.com/index.php/topic,8605.0.html – another like problem, with code
http://forums.taleworlds.com/index.php/topic,14376.0.html – safely removing towns
http://forums.taleworlds.com/index.php/topic,13584.0.html – a mistake with merchants
http://forums.taleworlds.com/index.php/topic,11706.0.html – teleportation issues
http://forums.taleworlds.com/index.php/topic,10910.0.html – another question about towns

Q: How do I add new troops/NPCs?
http://forums.taleworlds.com/index.php/topic,10998.0.html – a solution for quick adding of troops
http://forums.taleworlds.com/index.php/topic,14900.0.html – help with adding an NPC
http://forums.taleworlds.com/index.php/topic,6990.msg103506.html#msg103506 – a bit of python code
http://forums.taleworlds.com/index.php/topic,14583.0.html – changing gate watch

Q: How do I add new items?
http://forums.taleworlds.com/index.php/topic,6687.msg98377.html#msg98377 – robrob’s short tutorial
http://forums.taleworlds.com/index.php/topic,14464.0.html – a mistake you can avoid
http://forums.taleworlds.com/index.php/topic,10901.0.html – animation problem

Q: How do I add/change scenes?
http://forums.taleworlds.com/index.php?PHPSESSID=4a421afb177ef04b5c3e26f4ab693478&/topic,5751.0.html – a comprehensive guide
http://forums.taleworlds.com/index.php/topic,11701.0.html – a discussion on altering the look of scenes

Q: How do I handle party spawns?
http://forums.taleworlds.com/index.php/topic,6687.msg98377.html#msg98377 – a three-step “wizard” for adding new SPs.
http://forums.taleworlds.com/index.php/topic,12135.0.html – a quick SP solution.

Q: How do I create dialogs?

http://forums.taleworlds.com/index.php/topic,6197.0.html - a tutorial by Fujiwara. It's old but I haven't seen any newer one.


...

Python Editing with the Official Module System
Thanks to Winter for his help with this section :smile:

Q: What the hell does this error mean?!
A: Winter has made an excellent 'translation list' here:

http://forums.taleworlds.com/viewtopic.php?p=96347#96347

Q: How do I create new quests for my mod?
A: http://forums.taleworlds.com/viewtopic.php?p=96630#96630

Q: How do I make new Dialogues for NPCs?
A: Winter made this tutorial that tells you all you need to know (as long as you are comfortable using python)

http://forums.taleworlds.com/viewtopic.php?p=108022#108022


...

Model Editing

Q: Can I add new models?
A: Yes, BRFEdit can edit most things in the BRF files (the files that contain all the games visual resource data).  Meshes, textures and materials can all be changed, with limited shader and collision mesh editing suport as well. 

You can get it here: http://forums.taleworlds.com/index.php/topic,8771.0.html
This tool is replacement of Lurbs BRFView tool, which does not support animated meshes etc.

For some tutorials see:
Extension Tutorial - Unwrapping in Wings 3d
Extension Tutorial - Making Scenes and Scene props (using wings3d)

Adding new items to mount and blade using Wings 3d (free) - Yoshiboy
Add New Items to Mount and Blade: VIDEO TUTORIAL - n00854180t
Texturing for Dummies using Wings3D


Q: Is there an easy way to add new textures?
A: Yes, Simpson has made a very handy little tool, you can find it here.

BRFEdit can also do everything the above tool can do, making it somewhat obsolete, though still a great tool.


Q: Why are my objects causing crashes/not looking right in game?
A: Fisheye has a nice thread giving some general tips for adding BRF models.

You can find it here: http://forums.taleworlds.com/viewtopic.php?t=7535&sid=ee07d78177f58019e99c8f35709c8f0d


Q: Can I edit animated objects?
A: Yes.  BRFEdit can import animated meshes, however the skeletons that define the animations cannot yet be modified.

Here is a great tutorial by Yoshi on rigging meshes using 3dsMax / gMax:  http://forums.taleworlds.com/index.php/topic,15272.0.html


Q: I added a new scene object, but how can I make it so the player cant walk through it?

A: To stop players walking through objects, you need collision meshes for them. 

BRFEdit can import obj meshes to use as collision manifolds.

Fisheye also has some nice little scripts to make these:

Quick and Dirty collision mesh BRF Maker
OBJ to BRF collision model converter

Some info on collision meshes: BRF Format and collision meshes: brief documentation (Pt 1)


Q: Do I have to over-write the vanilla brf files, or can I make some that are only used for my own mod?

A: Janus has a nice explanation of how to add your own module resources here:

http://forums.taleworlds.com/viewtopic.php?t=6628


Q: Are there any modelling tutorials to get me started?

A: Highelfwarrior made a simple wings tutorial.  You can find it here:

http://forums.taleworlds.com/index.php/topic,10868.0.html

If you wish to create animated meshes, you may want to try this tutorial on using gmax.


Q: Can I make new faces, with custom face morphs?

A: Yes: http://forums.taleworlds.com/index.php/topic,15707.0.html

...


World Map Editing


Q: Can I edit the world map?
A: Yes, try the map editor: http://forums.taleworlds.com/viewtopic.php?t=5646&start=0

It is possible to totally re make the map, the only thing you cant currently do is add more textures (you are limited to painting with the current 9), however you can change the existing textures, by editing the materials.brf file, and changing the textures that the map_<type> materials use.


Q: Can I make bridges, waterfalls, impassable walls and other map features?
A: Yes, take a look at http://forums.taleworlds.com/viewtopic.php?t=6048 for some examples.


Q: Can I edit the towns on the map?
A: Yes, the map editor can move towns around, change town icons, and change town names.  The unofficial editor can also do this.  To make new town icons, see this thread: http://forums.taleworlds.com/viewtopic.php?p=95423#95423

Khalid ibn Walid has also made an extensive and very handy guide for adding all the extras that you will need for your new town:

Making new towns -- a primer

Fisheye also has a great tutorial on making new locations complete with custom scene and menus: http://forums.taleworlds.com/viewtopic.php?t=6919

...

Added many links to the general section, thanks to smiling_cataphract, will add many more from Yoshiboy, and sort them all out a bit later  - Thorgrim
 
Because I figured it would be useful, I've gone ahead and compiled a little database containing the most common errors you're likely to encounter when building the Python code into a working mod, and their meanings.

Error:
SyntaxError: invalid syntax
Meaning:
Missing a bracket, comma or quotation mark -- [], (), , or "" -- OR you have too many of them.

Error:
TypeError: list indices must be integers
Meaning:
Missing a comma/too many brackets.

Error:
ERROR: INPUT TOKEN NOT FOUND: <name>
NameError: global name 'cause_error' is not defined
Meaning:
You have a starting dialog-state -- example, [trp_constable_hareck,"constable_hareck_introduce_1", -- that isn't being led to by an ending dialog-state -- example, "close_window",[]],

Error:
ERROR: INPUT TOKEN NOT FOUND: <empty>
NameError: global name 'cause_error' is not defined
Meaning:
You have an empty starting dialog-state -- example, [trp_constable_hareck,"constable_hareck_introduce_1",

Error:
NameError: name '<something>' is not defined
Meaning:
Missing a prefix such as trp_, itm_ or mnu_ OR missing a name OR misspelled a name.

Error:
IndexError: tuple index out of range
Meaning:
Nebulous. If you're modding module_mission_templates.py, look for undefined alter flags and undefined AI flags, these are the most common source.

Error:
TypeError: int argument required
Meaning:
Missing an integer such as a mission-template flag. You can find out which calls are integers by looking at Armagan's documentation at the beginning of each module file, (int) calls being integers.

Error:
IndexError: list index out of range
Meaning:
There's an error in one of your list calls -- a list is anything between brackets.

Error:
Error: Unable to find object:<name>
ERROR: Illegal Identifier:<name>
Meaning:
The object you're trying to call does not yet exist OR there is a misspelling in the name.

That's all the ones I was able to produce reliably on short notice. Hope it helps!

Hydraulically,
Winter
 
maw said:
would somebody of talent be so kind as to provide a down and dirty on Creating New Quests through Python?

i'm not referring to a 'cut and paste' but some explanation on the different mod files that have to be edited to make them work.

any help is appreciated. maw
Here is the bare-bones way to create new quests with the Python code.

First, you need a consequence block (at the end of a dialogue line, for example) that begins your quest, such as this one:

[[assign,"$do_stuff_quest_active",1], -- This is just a string, not related to the actual quest, but handy for coding quest-related condition and consequence blocks later.
[setup_quest_text,"qst_do_stuff"], -- This activates the quest text for qst_do_stuff. From my experience, this is not strictly necessary, but it pays to play things safe.
[start_quest,"qst_do_stuff"]]], -- This is the consequence that will actually begin your quest.

You can use this kind of consequence block in module_dialogs.py, module_game_menus.py, module_triggers.py and perhaps others as well.

Next, you have to input your quest text at the bottom of module_quests.py.

("do_stuff", "Do some really amazing stuff", qf_show_progression, -- This is where most of the action happens. The first string sets up the name of your quest, the second string sets up the short text as you will see it in the top left-hand bar of the quest window, and then come the quest flags, which determine whether you want this to be a random quest (qf_random_quest) OR if you want to show what percentage of this quest is completed (qf_show_progression). It should be possible to put a 0 there if you don't want any quest flags.
"Some guy asked you to do some really amazing stuff, and he'll give you some gold." -- This is the long quest text that will show up in the large top-right window of the quest screen.
), -- And this closes your block.

Having done this, input whatever content (dialogue, fights and so on) you want this quest to have.

With everything else done the time has come to close your quest.

[[add_xp_as_reward,100], -- This is a way to add XP as a reward for your quest. There are other ways to reward the player as well, such as add_gold_to_troop, add_item_to_troop, and so on.
[complete_quest,"do_stuff"], -- This completes your quest. You can also use succeed_quest or fail_quest, but they're not really necessary when you can use a simple string to do the same job.
[set_quest_progression,"qst_do_some_more_stuff",40], -- If you have set the qf_show_progression flag on your quest, use this operation to adjust the percentage shown. 40, in this example, will show the quest "do_some_more_stuff" as 40% complete.
[assign,"$quest_succeeded_do stuff",1]]], -- This is a string you can use for future conditions blocks which depend on whether the player has succeeded the quest, failed it or has otherwise finished it. You can make the string anything you like, and use any number of strings for this purpose.

This is all you need for a basic quest. More complex ones will require more complicated finagling, especially quests involving heroes (which can be an amazing pain to get rid of, you can read about my struggles in my Storymod thread).

Germinally,
Winter
 
I have some questions regarding adding new factions to the game. I know how to add new factions, and new towns owned by said new factions.

I'm wondering how to add a count (I know how to add people, but acts like a vaegir count conversation wise) that will allow you to join that faction and give out faction quests and give you a higher rank in that faction, lower your standing in others, etc.

Crazed Rabbit
 
Crazed Rabbit said:
I have some questions regarding adding new factions to the game. I know how to add new factions, and new towns owned by said new factions.

I'm wondering how to add a count (I know how to add people, but acts like a vaegir count conversation wise) that will allow you to join that faction and give out faction quests and give you a higher rank in that faction, lower your standing in others, etc.

Crazed Rabbit
As far as I know, all the information for this is stored in module_dialogs.py. All the counts and kings in the game use the dialog-state "governer_talk". To this dialogue, you will have to add all the conversation options and code relevant to your newly created faction, and then your new count should work like all the others.

Ostensively,
Winter
 
Crazed Rabbit said:
I have some questions regarding adding new factions to the game. I know how to add new factions, and new towns owned by said new factions.

I'm wondering how to add a count (I know how to add people, but acts like a vaegir count conversation wise) that will allow you to join that faction and give out faction quests and give you a higher rank in that faction, lower your standing in others, etc.

Crazed Rabbit

If you're using python files, check out the little tut Making New Towns - a Primer. It's a bit long-winded, but it has a lot of what you're looking for.

As for the rest, as winter said, it's a matter of copying and pasting all the stuff you need in the dialogues, constants, troops & possibly triggers files.
 
This is a copy of my post from the Storymod Recruitment Thread; I figured it might be nice to have it here, to build this thread up as a knowledge base and a major resource for modders.

Winter's Dialogue Tutorial for Python

Here is a bog-standard bit of conversation in M&B, held together by the cement of Python code. There is more information regarding this type of stuff at the start of module_dialogs.py, so if you want to read Armagan's explanations and further possibilities, download the module system and take a look.

I'll highlight and explain each piece of the dialogue line in turn.

[trp_rezzik,"start", [[eq,"$rezzik_introduced",0]], "Who are you? What do you -hic- want? I'll not go back! I'll not, you can't make me!", "rezzik_introduce",[]],

[trp_rezzik, is what defines the troop you're talking to. Adding the tag |plyr to the end ([trp_rezzik|plyr,) will make this line spoken by the player character instead. There's also an easy way to give lines to a third character ([trp_rezzik|other(trp_somebody)) as long as that character is in the scene.
"start", is the starting dialog-state. There are several types of starting dialog-state which you can use in the very first line; "start" for example is used when you encounter an NPC in a scene such as Zendar centre. There are others available for party encounters on the map, for chatting with prisoners, and so on.
[[eq,"$rezzik_introduced",0]], is the conditions block. Pure code. If there are conditions on a line of dialogue, the game won't use this line unless those conditions have been met. In this case, the string "$rezzik_introduced" is 0, therefore Rezzik has not yet been introduced. After "$rezzik_introduced" is set to 1, the game will no longer try to use this line when talking to Rezzik.
"Who are you? What do you -hic- want? I'll not go back! I'll not, you can't make me!", is the actual dialogue, no code involved. This also means that formatting is not possible. So, no bold text, no italics, and so on.
"rezzik_introduce", is the ending dialog-state. This means that this particular line of dialogue will lead into any other line which has the starting dialog-state "rezzik_introduce".
[]], is the consequence block. More pure code. If the line of dialogue has any results, such as giving gold or XP or a host of others, it will go here.

Giving the player multiple lines with the same starting dialog-state will let the player choose between those lines as normal. The game only has room for 5 dialogue options at a time. The lines can't be too long, either, or they will spill out of their box.

Another example:

[trp_khergit_ride_leader,"ride_leader_bribe_2", [], "Men have decided. We let you pass for four goats, pound of myrrh, and a sheep for me. Or same in coin.", "ride_leader_bribe_3",[]],

This line is spoken by the troop khergit_ride_leader, has no conditions, no consequences, and leads into all lines with the starting dialog_state "ride_leader_bribe_3". That means it leads into this simple block of three options:

[trp_khergit_ride_leader|plyr,"ride_leader_bribe_3", [], "That's two hundred denars! I won't pay that!", "ride_leader_bribe_4",[]],
[trp_khergit_ride_leader|plyr,"ride_leader_bribe_3", [], "Here it is.", "ride_leader_bribe_6", []],
[trp_khergit_ride_leader|plyr,"ride_leader_bribe_3", [], "On second thought, perhaps I should leave instead. Good day.", "close_window",[]],


The first option leads to "ride_leader_bribe_4", the second to "ride_leader_bribe_6", and the third will end the conversation and close the dialogue window.

If I was unclear anywhere, I'll be happy to answer any questions.

Pantheistically,
Winter
 
I'm starting this post as a knowledge base; particularly, a list of things in the M&B module system that, even though they look like they ought to work, simply don't for some reason. If you've run into something during your modding efforts that qualifies, please submit them to the list, because they could save someone (and possibly yourself too) a couple of hours of bugfixing trying to find what the hell went wrong.

Things I've run into myself:

deduce_gold_from_troop -- Absolutely does not work, use troop_remove_gold instead.
Result: Crash to desktop with the words 'unrecognised opcode 10061'

tf_unkillable -- Doesn't work at all.
Result: Any troops with tf_unkillable will remain quite killable.

store_enemy_count -- Works intermittently or not at all.
Result: Any mission triggers with store_enemy_count in the conditions block will fire as if store_enemy_count wasn't there.
 
As of v0.711.

store_troop_kind_count: only stores the number of troops of the specified type in the main party regardless of which party you actually specify.

remove_troop_from_party: Works for removing troops from any party, but if used in a scene/mission, always displays a string, e.g. "Dark Hunter has left the party" regardless of which party the troop was removed from.
 
Winter said:
store_enemy_count -- Works intermittently or not at all.
Result: Any mission triggers with store_enemy_count in the conditions block will fire as if store_enemy_count wasn't there.
I thought the same thing. If you take the trouble of tracking the variable it actually changes from around 1-4 or so (may range a bit further than that). I made a trigger that gave gold in that amount every 5 seconds or so during battle to observed what number it was actually at.
You get the same sort of results using "store_ally_count" and "store_friend_count".
I contacted Armagan about something else and mentioned that problem bugging me, and here's what he had to say about it:
Armagan said:
store_enemy_count etc. return normalized values with respect to "battle size" and advantage modifiers. If you have a "pump_number_to_entry" command adding, say, 5 units, the actual number that will appear in battle will change with these modifiers but store_enemy_count will re-convert the actual number back to 5.
So, apparently it's not a bug, it's just not storing the value you would expect from the name. Ah well.

Here's one he confirmed as a bug: "troop_remove_item" will consistently cause a crash if removing an item from the player which is equipped, but "troop_remove_items" works fine. He said that one will be fixed in the next version. So, FYI, until the next version you should only use "troop_remove_items" to remove stuff from the player.
 
As far as I can tell:

change_screen_exchange_members: will not work in town - only on the world map

(my personal bane - ~sigh~)

DE

(If you know how to exchange members in town, without having to use the hire mercenaries functions - or some other method that does not require you to pay - I would love to hear about it)
 
I just encountered a few more.

call_script -- Does not work from module_game_menus.py.
Result: Menu options will be mysteriously unclickable.

start_map_conversation -- Does not work from "start" conversations.
Result: Nothing will happen.

jump_to_menu -- Does not work from "start" conversations.
Result: Nothing will happen.
 
Janus said:
I contacted Armagan about something else and mentioned that problem bugging me, and here's what he had to say about it:
Armagan said:
store_enemy_count etc. return normalized values with respect to "battle size" and advantage modifiers. If you have a "pump_number_to_entry" command adding, say, 5 units, the actual number that will appear in battle will change with these modifiers but store_enemy_count will re-convert the actual number back to 5.
So, apparently it's not a bug, it's just not storing the value you would expect from the name. Ah well.
That's a damned shame, because if there was a condition that works the way you'd think, it could be awesomely useful. Triggers that would only fire after you whittle your enemies down to a certain number. Long missions would be a whole lot easier to code, and there'd be a great increase in frame rate for some of the things I've been trying to do.

Pecuniarily,
Winter
 
Hopefully this belongs here...

Did a little search on adding/modding in custom heroes and didn't find anything, sooo...

How difficult is it to add in recruitable heroes to the game? Is it something someone who's never modded before could pick up with a bit of experimentation and a starting point?

And finally, if something like that is possible, could it be added to an existing mod (like, oh, lets say I'm playing Janus' great Arena-expansion mod, but wanted some more heroes, could I create some and add them into that mod at all?).

And lastly, would that require a new saved-game.

A buddy and I want to put versions of our characters into each other's game :grin:

Thanks a lot for your time :smile:
 
DevinC said:
Hopefully this belongs here...

Did a little search on adding/modding in custom heroes and didn't find anything, sooo...

How difficult is it to add in recruitable heroes to the game? Is it something someone who's never modded before could pick up with a bit of experimentation and a starting point?

And finally, if something like that is possible, could it be added to an existing mod (like, oh, lets say I'm playing Janus' great Arena-expansion mod, but wanted some more heroes, could I create some and add them into that mod at all?).

And lastly, would that require a new saved-game.

A buddy and I want to put versions of our characters into each other's game :grin:

Thanks a lot for your time :smile:

New heroes is super easy... just use the edtior copy borcha and add him+rename+change things or whoever and then add a line or two into conversation so he adds your party (look at borcha or marnid)

Not as good as winters but faster! :wink:
 
DevinC said:
Hopefully this belongs here...

Did a little search on adding/modding in custom heroes and didn't find anything, sooo...

How difficult is it to add in recruitable heroes to the game? Is it something someone who's never modded before could pick up with a bit of experimentation and a starting point?
It's ridiculously easy. You basically just make a new troop with the troop flag tf_hero, and then create a situation (such as a conversation) where you can do a troop_join on him. After that, all you have to do is copy/paste the convo from Borcha or Marnid and file off the serial numbers.

And finally, if something like that is possible, could it be added to an existing mod (like, oh, lets say I'm playing Janus' great Arena-expansion mod, but wanted some more heroes, could I create some and add them into that mod at all?).
It would be possible for any mod if you use the Unofficial Editor. Janus is generous enough to include his source with the mod, so you could even do it in Python (in that particular case) if you wanted.

And lastly, would that require a new saved-game.
Probably. I'm not entirely sure, but M&B's savegames tend to react poorly to content that wasn't there when the game began.

Hope that answers your questions!

Refreshingly,
Winter
 
Thats awesome Winter, thanks alot :grin: That answers everything perfectly, I should be able to get by with this!

*edit* And thank you as well, Lu Bu :grin: Looking forward to your mod, by the way!
 
DevinC said:
Thats awesome Winter, thanks alot :grin: That answers everything perfectly, I should be able to get by with this!

*edit* And thank you as well, Lu Bu :grin: Looking forward to your mod, by the way!

No Problem and good to hear that. :wink: i hope you checked out the newest stuff! (like my city...)

You could post into the thread what you think about them.
 
Looks like you got it covered pretty well, just one thing:
Winter said:
DevinC said:
And lastly, would that require a new saved-game.
Probably. I'm not entirely sure, but M&B's savegames tend to react poorly to content that wasn't there when the game began.
Actually, as long as he adds the troop at the end of the list, it should be compatible with old savegames. If he were to remove a troop or add one in the middle of the pack (displacing others) then it would cause problems in that case.
There are also no compatibility problems with adding new conversations at all, as far as I know.

So, stick the new hero(es) at the end of the troop list and you should be fine. Just don't try to remove them later unless you want to start a new game. :wink:
 
Status
Not open for further replies.
Back
Top Bottom