Author Topic: Mount & Blade Mod Makers Q&A Thread  (Read 723195 times)

0 Members and 1 Guest are viewing this topic.

dunde

  • Grandmaster Knight
  • *
  • Curious Coder of The Vision
    • View Profile
  • Faction: Swadian
  • WB
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10230 on: March 22, 2012, 03:16:56 AM »
Is there a list of global variables somewhere? Can I make my own global variables like local variables?
variables.txt. It's autocreated while compiling native module system.
You are free to create your own global variables.

"$current_town" what does this global variable do exactly? I understand it is “set” when a play enters a town party and enters its menu. But, what is "$current_town" set to?
Is "$current_town" just a way to find the party_id of the town the player is currently at?
Then you can use slots to check information about that town; such as its relation with the player?
While main party encounted towns or castles, "$current_town" is set to the encountered party.
Just look at some lines at module_game_menus.py :
  (assign, "$current_town","$g_encountered_party"),
If you are at the town menus, and you need to get the town's relation with player, yes you can get it from relation slot of "$current_town".


I am having trouble understanding slots. I read the intro to the module system syntax and usage tutorial and this is what I get. A slot is a way to look up or set a variable dealing with something such as an item, party, ect.

However where is the variable located? The example from the tutorial says:

(click to show/hide)

Where can I find the 53rd variable of an item? Or in other words where can I find the variable that is an items base price? I looked in the module_items , but I found nothing regarding an items base price.

parties, factions, troops, items, scenes, agents, quests, teams and scene_props have slots.
You can get beard base price and save it to local variable or registers :

(item_get_slot, ":base_price", "itm_beard", slot_item_base_price),   # save it to ":base_price" local variable
(item_get_slot, reg0, "itm_beard", slot_item_base_price),   # save it to register 0
« Last Edit: March 22, 2012, 03:19:23 AM by dunde »

MadVader

  • Grandmaster Knight
  • *
  • Prophesy of Pendor 3.61 released - it's yummy
    • View Profile
    • Prophesy of Pendor
  • Faction: Neutral
  • M&BWB
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10231 on: March 22, 2012, 09:08:58 AM »
What dunde said and:
- $current_town is a party id, just a number, and is used to get town properties, correct
- Slots are arrays of integers that belong to an item, party, troop etc. (each item, party etc. has their own separate integer array.) Their definitions are in module_constants.py, and you can add your own slots, and remove existing ones - each slot is just an index in an array. They are indispensable for advanced features. Once you understand slots, you are past the beginner phase.
- Get a nice editor like Notepad++, or any that can search for strings over multiple files.
- Write test code (typically placed in a Camp submenu) that prints variable values when you experiment with code. Also insert debug messages (display_message) to print variable values in the code that interests you.

Example.. let's say you are baffled by $g_encountered_party. What is it and what does it do? (I'm preempting your next question here lol):
1. Do a global search for $g_encountered_party. Many hits, but it's set only in one place (I think :)).
At the start of script_game_event_party_encounter:
(store_script_param_1, "$g_encountered_party"),
2. You read the description of script_game_event_party_encounter and deduce it is the party id of the encountered party.
3. You further see how it's used all over the module system. It can be a lone party, one of the parties in battle, or a location (which are parties too).
4. You get sidetracked by script_game_event_party_encounter and want to see how does it really work, so you insert temporary debug code:
       (store_script_param_1, "$g_encountered_party"),
       (store_script_param_2, "$g_encountered_party_2"),# encountered_party2 is set when we come across a battle or siege, otherwise it's a negative value
       (str_store_party_name, s5, "$g_encountered_party"),
       (display_message, "@{!}DEBUG: You encountered a party named {s5}!"),

You build the module system, run the game, and get interesting debug messages.
5. Profit :)

VN-Killah

  • Guest
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10232 on: March 22, 2012, 05:57:37 PM »
You need to realize that the game engine is dumb and doesn't know what trp_watchman and trp_mercenaries end are. When the module system is compiled and the scripts to update the mercenary in each center is written to scripts.txt (update_mercenary_units_of_towns , update_mercen_units_of_castle), it takes the existing offset id of each entity (for example trp_watchman = 27 and trp_mercenaries_end = 33), which ends up being bit-shifted to avoid collision with other objects, and so you'll get 2136 3 1224979098644774913 360287970189639707 360287970189639713 where 2136 corresponds to store_random_in_range, the 3 is the number of parameters, the variable id immediately after that being the destination, and the last 2 are  the troop ranges (27 and 33 shifted).

When you inserted your new unit in between these numbers, it ends up shifting the id of each subsequent troop (trp_mercenaries_end  becomes #34), but the script still references the old offset. Since the entire game is wholly dependent on the offset system, the manual insertion of any troop except at the bottom will screw up all your savegames. What you can do is decrement the range in that script to get 360287970189639706, which will include the townsman troop (which isn't used by the AI in-game at all unless it upgrades from a rescued farmer); or increment 360287970189639714 to get the mercenaries_end placeholder troop itself included in the range and modify those troops accordingly. What you should do, however, is get the module system, which will do most of that for you.

Thanks a lot. I have tried to download the module system, but I'm still working out a few kinks in how to run the darn thing. I think I'm going to have to look around for a tutorial before I try any more scripting.

Many thanks again for the advice :)

By the way, I would also like to ask if anyone knows how the wages for troops in the game are determined. Is it based on their individuals skills, their overall level, their equipment, or what? The reason I'm asking is because I would like to be sure that, for example, a really elite troop that I create doesn't end up costing 3 thaler or something.
« Last Edit: March 22, 2012, 06:12:57 PM by VN-Killah »

Caba`drin

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&SNW
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10233 on: March 22, 2012, 06:44:23 PM »
By the way, I would also like to ask if anyone knows how the wages for troops in the game are determined. Is it based on their individuals skills, their overall level, their equipment, or what? The reason I'm asking is because I would like to be sure that, for example, a really elite troop that I create doesn't end up costing 3 thaler or something.
Check out the script "game_get_troop_wage"



VN-Killah

  • Guest
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10234 on: March 22, 2012, 08:14:30 PM »
Ok. So will I be able to set these wages to whatever I want by editing this script?

Caba`drin

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&SNW
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10235 on: March 22, 2012, 08:43:43 PM »
Ok. So will I be able to set these wages to whatever I want by editing this script?
Correct.



VN-Killah

  • Guest
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10236 on: March 22, 2012, 10:30:07 PM »
Cool! Many thanks  :D

Dennie

  • Recruit
  • *
    • View Profile
  • Faction: Rhodok
  • MP nick: NightsWatcher_Dragonborn
  • WB
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10237 on: March 23, 2012, 01:11:43 PM »
Hello everyone,

I've some questions for my mod, I hope you can help me with those:

First, I want to edit the multiplayer mode in my mod, so, I've made new factions and I want to have a multiplayer mode with those factions. How can I do this?

Second, I want to chance the banners of some kings. How can i make this possible?

Third, I want to edit the costum battle mode. With different troops from troops.txt Is that possible? If it is, how?

I hope you can help me, this will make my mod completely finished... almost  8-)

Muffin Raider

  • Recruit
  • *
    • View Profile
  • Faction: Neutral
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10238 on: March 24, 2012, 06:16:19 AM »


Thank you very much  MadVader and dunde for your help.

Quote
- Slots are arrays of integers that belong to an item, party, troop etc. (each item, party etc. has their own separate integer array.) Their definitions are in module_constants.py, and you can add your own slots, and remove existing ones - each slot is just an index in an array. They are indispensable for advanced features. Once you understand slots, you are past the beginner phase.

Yeah, I am still working on understanding slots. What I am trying to figure out is where exactly slot information comes from. Yes I know it comes from an array of integers that belong to the item, party, ect, BUT where is the so called “integer array” located? Are the arrays in some code we cannot see/access and the only way to get the info is to use slots to pull that information out of where ever it may be?

Quote
- Write test code (typically placed in a Camp submenu) that prints variable values when you experiment with code. Also insert debug messages (display_message) to print variable values in the code that interests you.

Awesome idea thanks for this bit of info, all newbies should hear this. along with your tutorial below.

Quote
Example.. let's say you are baffled by $g_encountered_party. What is it and what does it do? (I'm preempting your next question here lol):
1.   Do a global search for $g_encountered_party. Many hits, but it's set only in one place (I think :)).

Yes, this is why I was confused with “$current_town”. I saw it had been assigned various values throughout the code.

I used notepad++ (thanks) did a search and found:

(click to show/hide)

Will these assignments create complications when using “$current_town” to get info about encountered parties?

Quote
4. You get sidetracked by script_game_event_party_encounter and want to see how does it really work, so you insert temporary debug code:
       (store_script_param_1, "$g_encountered_party"),
       (store_script_param_2, "$g_encountered_party_2"),# encountered_party2 is set when we come across a battle or siege, otherwise it's a negative value
      (set_show_messages, 1)
(str_store_party_name, s5, "$g_encountered_party"),
       (display_message, "@{!}DEBUG: You encountered a party named {s5}!"),

You build the module system, run the game, and get interesting debug messages.
5. Profit :)

Again debug stuff was awesome all newbies should hear it. Also thanks for making it into a small tutorial. However, for future reference I had to add in (set_show_messages, 1),   in order to get the message to display in game.



MadVader

  • Grandmaster Knight
  • *
  • Prophesy of Pendor 3.61 released - it's yummy
    • View Profile
    • Prophesy of Pendor
  • Faction: Neutral
  • M&BWB
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10239 on: March 24, 2012, 09:06:55 AM »
Quote
- Slots are arrays of integers that belong to an item, party, troop etc. (each item, party etc. has their own separate integer array.) Their definitions are in module_constants.py, and you can add your own slots, and remove existing ones - each slot is just an index in an array. They are indispensable for advanced features. Once you understand slots, you are past the beginner phase.

Yeah, I am still working on understanding slots. What I am trying to figure out is where exactly slot information comes from. Yes I know it comes from an array of integers that belong to the item, party, ect, BUT where is the so called “integer array” located? Are the arrays in some code we cannot see/access and the only way to get the info is to use slots to pull that information out of where ever it may be?
The low-level handling of integer arrays is hidden in the engine. They are accessed only through something_get_slot/set_slot/slot_eq/slot_ge operations, and that's all you really need. Don't worry about where they are and simply use them :).

Quote
Quote
Example.. let's say you are baffled by $g_encountered_party. What is it and what does it do? (I'm preempting your next question here lol):
1.   Do a global search for $g_encountered_party. Many hits, but it's set only in one place (I think :)).

Yes, this is why I was confused with “$current_town”. I saw it had been assigned various values throughout the code.

I used notepad++ (thanks) did a search and found:

(click to show/hide)

Will these assignments create complications when using “$current_town” to get info about encountered parties?
The first six assigns are hacks for the starting quests to work, so they are exceptions to the general use, and will be only assigned at most once in a game.
At the beginning of a game, your party is created close to a town, but you don't have a chance to move and really "encounter" that town (so $g_encountered_party and $current_town are not updated normally), and the easiest thing for Taleworlds was to assign them explicitly. Town menu code uses $current_town, so it needs to have a proper value. Don't lose sleep over it, unless you want to engage in similar hackery.

Muffin Raider

  • Recruit
  • *
    • View Profile
  • Faction: Neutral
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10240 on: March 24, 2012, 07:33:04 PM »
Alright, that makes sense now. Thank you very much for the response.

Z.Master

  • Sergeant at Arms
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Zmaster
  • WBNW
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10241 on: March 24, 2012, 09:09:13 PM »
how to put  that  for recruiting is not required reputation with villages or to limit minimum recruits to 1?

_Sebastian_

  • Sergeant Knight
  • *
  • Battle of Europe Main Developer
    • View Profile
  • Faction: Bandit
  • MP nick: Wolves_Sebastian
  • WBNW
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10242 on: March 25, 2012, 12:14:19 AM »
Hi guys.
I want to change the "weapon switch system" of Warband.

So if a charachter switches from a weapon to another, then the first equipped weapon should be put away automatically(but with the animation)...and then the character should draw the other weapon.

I found no entry about the weapon switching in the whole module system and I dont know how to change it.

Does anyone know how to change it like this :?:
Thanks.

cmpxchg8b

  • Modder++
  • Grandmaster Knight
  • *
  • Master of rglPool
    • View Profile
  • Faction: Vaegir
  • MP nick: cmp
  • M&BWBWF&SNW
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10243 on: March 25, 2012, 12:19:19 AM »
It's hardcoded, but maybe you can put something together by playing animations in the ti_on_item_wielded and ti_on_item_unwielded triggers.
Warband Script Enhancer v3.1.5 - additional operations, game scripts and triggers for Warband modders

MaHuD

  • Napoleonic Wars Moderator
  • *
  • Terror Terroris
    • View Profile
  • Faction: Nord
  • MP nick: K-KA_Nr7_FWOb_MaHuD
  • WBWF&SNW
Re: Mount & Blade Mod Makers Q&A Thread
« Reply #10244 on: March 26, 2012, 12:43:22 AM »
Can "Key_clicked" be used anywhere, or does it have to be in specific places?
I tried to use it, but it didnt work. "key_is_down" does work however, but that doesn't respond fast enough.