Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
kalarhan said:
vitali-attila said:
There is another thing I can't solve. If the ":cur_agent" is the player, the code should remove the ":cur_item"(which he has in one of his weapon slots) from the inventory, of course, forever.
The code below is what I tried to do. But it does not work...
Code:
(try_begin),
  (eq, ":cur_agent", ":player_agent"), 
  (assign, ":break", 0),
  (try_for_range, ":slot_no", 0, 4),
    (eq, ":break", 0),
    (agent_get_item_slot, ":cur_slot", ":player_agent", ":slot_no"),
    (eq, ":cur_slot", ":cur_item"), 
    #(troop_remove_item, "trp_player", ":cur_item"), #TEST -> does not work 
    (troop_set_inventory_slot, "trp_player", ":slot_no", -1), #does not work either
  (assign,":break", 1),
(try_end),
(try_end),
Could you please tell me what is wrong and how to fix it?

did you read Caba's text about troops X agents?

about your snippet: you are not showing how you are getting the id's for the agent and the player_agent, so no way to know if they are correct.
If you want to remove the item for the mission duration, use a agent_ operation
If you want to also remove the item forever, then add a extra line for your troop.

Code:
troop_remove_item                        = 1531  # (troop_remove_item, <troop_id>, <item_id>),
                                                 # Removes an item from the troop equipment or inventory. Operation will remove first matching item it finds.

keep in mind that operation does not take into account the IMOD of a item, and if you have duplicates it will have some weird results :XD
you should get the current item IMOD and look for it on the troop inventory.

You should never assume the agents slots are the same as the troop, not even for weapons. You can drop and pick new gear in a mission, and that will break your script.

Yes, I read it, thank you for the information.

Here is the whole code, I get the parameters from mission_template.py I have written my own mst_ block:
Code:
# Trigger Param 1: damage inflicted agent_id
# Trigger Param 2: damage dealer agent_id
# Trigger Param 3: inflicted damage
# Register 0: damage dealer item_id
# Position Register 0: position of the blow
#                      rotation gives the direction of the blow
vitali_on_couched_lance_damage = (
 ti_on_agent_hit, 0, 0, [],
 [
  (store_trigger_param_1, ":inflicted_agent"),
  (store_trigger_param_2, ":cur_agent"),
  (store_trigger_param_3, ":inflicted_damage"),
  (assign, ":cur_item", reg0),
  (call_script, "script_game_event_agent_hit", ":inflicted_agent", ":cur_agent", ":inflicted_damage", ":cur_item"),
  (try_end),
 ])

Then in "script_game_event_agent_hit":
Code:
# Param 1: damage inflicted agent_id
# Param 2: damage dealer agent_id
# Param 3: inflicted damage
# Param 4: damage dealer item_id
# Param 5: position of the blow
#                      rotation gives the direction of the blow
("game_event_agent_hit",
[
  #(store_script_param, ":inflicted_agent", 1), #uncomment the line when will you use this variable
  (store_script_param, ":cur_agent", 2), 
  (store_script_param, ":inflicted_damage", 3), 
  (store_script_param, ":cur_item", 4), 
  (get_player_agent_no, ":player_agent"),		
  (try_begin),
    (gt, ":inflicted_damage", 70), 
    (agent_is_active, ":cur_agent"),
    #If a polish hussar lance is used
    (this_or_next|eq, ":cur_item", itm_gusar_lanza),
    (this_or_next|eq, ":cur_item", itm_gusar_lanza_b),
    (             eq, ":cur_item", itm_gusar_lance),
    (play_sound_at_position, "snd_lance_broken", pos0),
    #If it's a player through the lance away(cause it's broken)
    (try_begin),
    (eq, ":cur_agent", ":player_agent"), 
    (assign, ":break", 0),
    (try_for_range, ":slot_no", 0, 4),
      (eq, ":break", 0),
      (agent_get_item_slot, ":cur_slot", ":player_agent", ":slot_no"),
      (eq, ":cur_slot", ":cur_item"), 
      #(troop_remove_item, "trp_player", ":cur_item"), #TEST -> does not work 
      (troop_set_inventory_slot, "trp_player", ":slot_no", -1), #does not work either
      (assign,":break", 1),
      (display_message, "@The broken lance is removed form the inventory"),
    (try_end),
  (try_end),
  (agent_unequip_item, ":cur_agent", ":cur_item"),
  (agent_equip_item, ":cur_agent", "itm_konchar"),
  (agent_set_wielded_item, ":cur_agent", "itm_konchar"),
]),

Everything here except removing the lance(":cur_item") from the inventory yet works.
I did know that the IMOD of the item plays role. I thought only item's id is important. And how to get it? With troop_get_inventory_slot_modifier? But it's only for troops, right?
 
Since the tech support borad is pretty much dead, I'll link my problem here: http://forums.taleworlds.com/index.php/topic,334014.0.html

If anyone has experience with AI mesh errors, please help me.
 
vitali-attila said:
I did know that the IMOD of the item plays role. I thought only item's id is important.

Imagine you have two lances, one is a masterwork lance and the other is a cracked lance.

You are using the cracked lance... it *breaks*. Your script will remove the first one that finds, so it will remove the masterwork one (expensive, better quality).

Slot  Weapon    Quality            Item_ID
0      Lance        Masterwork      333
1      Lance        Cracked            333
2      Shield        Plain                50
3      Sword      Plain                  67

Or you could find a lance in the ground and pick it up. That won't match your troop slots. And so on.

You are missing a try_end there. Fix your identation as that makes it easier to see it.

Did you download Lav's version of the modules? It has a better header_operations.py (with documentation)

Add display_message for debugging when you are doing something new and that you are unsure about it. After it is working you can exclude them

 
So I need some help

Before I ask my question I will tell you what posts I am using to begin modding:
  • The Ultimate Introduction to Modding
  • And of course this post

So now to my question.

I have a problem while trying to Initialize my mod.
Here is an example (not my picture because I am having errors)
XaazO.png

(I cannot post my own picture of the error unless I have my own Microsoft account which I have forgotten the password and username for)

My Error is:
The problem with mine is that it only Exports just a few of the files.
Here is the files it Exports:
  • strings
  • skills
  • animations
  • meshes
  • sounds
  • faction data
  • item data
  • quest data
  • postfx_prams.....
The rest are a error (for example):
<party_set_marshall, ":eek:ld_marshall_party", 0>,
Name Error: name 'party_set_marshall' is not defined

or

Traceback <most recent call last>
File "process_mission_tmps.py",line 8, in <module>
from process_operations import *
File "C:/Users/GCG/Documents/MB Mod/Module_system 1.165/ process_operations..py" (I cant read past this point)
, line 8614, in module.

Please Help Anyone!

EDIT: Thank You for everybody that helped!
 
jacobhinds said:
You've done everything right, it's not your fault. Someone who was working on Viking Conquest decided now was a good time to rename a single vital file called header_operations.py, and change the word marshall to marshal for no good reason. This is extremely frustrating because it broke a lot of stuff even outside of viking conquest, and due to weird compiling errors I didn't realise what was going on until I'd reinstalled the module system twice.  :neutral:

If you're using notepad ++, search through all the files simultaneously and replace every instance of "party_set_marshall" with "party_set_marshal". It shouldn't take long as there aren't many of them.

You can also go to header_operations.py and add the line
party_set_marshal                    = 1604
which is probably quicker.
 
GoldenDawnEmpire said:
So I need some help

Before I ask my question I will tell you what posts I am using to begin modding:
  • The Ultimate Introduction to Modding
  • And of course this post

So now to my question.

I have a problem while trying to Initialize my mod.
Here is an example (not my picture because I am having errors)
XaazO.png

(I cannot post my own picture of the error unless I have my own Microsoft account which I have forgotten the password and username for)

My Error is:
The problem with mine is that it only Exports just a few of the files.
Here is the files it Exports:
  • strings
  • skills
  • animations
  • meshes
  • sounds
  • faction data
  • item data
  • quest data
  • postfx_prams.....
The rest are a error (for example):
<party_set_marshall, ":eek:ld_marshall_party", 0>,
Name Error: name '' is not defined

or

Traceback <most recent call last>
File "process_mission_tmps.py",line 8, in <module>
from process_operations import *
File "C:/Users/GCG/Documents/MB Mod/Module_system 1.165/ process_operations..py" (I cant read past this point)
, line 8614, in module.
Please Help Anyone!

Hi. I also had such problem with "party_set_marshall". In my case there was a misprint in header_operations.py. There this operation was called party_set_marshal (one letter 'l', and it must be marshall). I solved this by just adding one more 'l' to the operation in header_operations.py. Afterwards the module compiled successfully. I hope this will help you.
 
kalarhan said:
Imagine you have two lances, one is a masterwork lance and the other is a cracked lance.

You are using the cracked lance... it *breaks*. Your script will remove the first one that finds, so it will remove the masterwork one (expensive, better quality).

Slot  Weapon    Quality            Item_ID
0      Lance        Masterwork      333
1      Lance        Cracked            333
2      Shield        Plain                50
3      Sword      Plain                  67

Or you could find a lance in the ground and pick it up. That won't match your troop slots. And so on.

You are missing a try_end there. Fix your identation as that makes it easier to see it.

Did you download Lav's version of the modules? It has a better header_operations.py (with documentation)

Add display_message for debugging when you are doing something new and that you are unsure about it. After it is working you can exclude them
Well, I could not find a way to define the IMOD of the ":cur_item". Maybe you know how to do this?
Anyway, even without using a modifier the item is not removed when I get back to the World Map after a battle.
Code:
#If it's a player remove it from the inventory forever(cause it's broken)
(try_begin), #vitali TEST(not working yet. work on)
	(eq, ":cur_agent", ":player_agent"), 
	(assign, ":has_item", -1),
	(try_for_range, ":slot_no", 0, 4),
		(troop_get_inventory_slot, ":cur_slot", ":player_agent", ":slot_no"),
		(eq, ":cur_slot", ":cur_item"), 
		#(store_item_kind_count, ":num_cur_items", ":cur_item"), #add this(if 2 hussar lances, decide which to remove) and extend when the simple removing will work
		(assign, ":has_item", ":cur_item"),
	(try_end),
	(try_begin),
		(ge, ":has_item", 0),
		(troop_remove_item, "trp_player", ":cur_item"), 
		(display_message, "@The broken lance is removed form the inventory :)"),
	(else_try),
		(display_message, "@The lance could not be found :("),
	(try_end),
(try_end),
 
vitali-attila said:
kalarhan said:
Imagine you have two lances, one is a masterwork lance and the other is a cracked lance.

You are using the cracked lance... it *breaks*. Your script will remove the first one that finds, so it will remove the masterwork one (expensive, better quality).

Slot  Weapon    Quality            Item_ID
0      Lance        Masterwork      333
1      Lance        Cracked            333
2      Shield        Plain                50
3      Sword      Plain                  67

Or you could find a lance in the ground and pick it up. That won't match your troop slots. And so on.

You are missing a try_end there. Fix your identation as that makes it easier to see it.

Did you download Lav's version of the modules? It has a better header_operations.py (with documentation)

Add display_message for debugging when you are doing something new and that you are unsure about it. After it is working you can exclude them
Well, I could not find a way to define the IMOD of the ":cur_item". Maybe you know how to do this?
Anyway, even without using a modifier the item is not removed when I get back to the World Map after a battle.
Code:
#If it's a player remove it from the inventory forever(cause it's broken)
(try_begin), #vitali TEST(not working yet. work on)
	(eq, ":cur_agent", ":player_agent"), 
	(assign, ":has_item", -1),
	(try_for_range, ":slot_no", 0, 4),
		(troop_get_inventory_slot, ":cur_slot", ":player_agent", ":slot_no"),
		(eq, ":cur_slot", ":cur_item"), 
		#(store_item_kind_count, ":num_cur_items", ":cur_item"), #add this(if 2 hussar lances, decide which to remove) and extend when the simple removing will work
		(assign, ":has_item", ":cur_item"),
	(try_end),
	(try_begin),
		(ge, ":has_item", 0),
		(troop_remove_item, "trp_player", ":cur_item"), 
		(display_message, "@The broken lance is removed form the inventory :)"),
	(else_try),
		(display_message, "@The lance could not be found :("),
	(try_end),
(try_end),

You are still confused about troops X agents . Check Caba's comment again, and download Lav's version of modules as his header_operations.py is very well organized and has more helpful text in there...

Code:
(troop_get_inventory_slot, ":cur_slot", ":player_agent", ":slot_no"),
Code:
troop_get_inventory_slot                 = 1541  # (troop_get_inventory_slot, <destination>, <troop_id>, <inventory_slot_no>),
                                                 # Retrieves the item_id of a specified equipment or inventory slot. Returns -1 when there's nothing there.

Besides that you should remember to post the debug messages on future questions, as saying something doesn't work can mean a lot of things  :smile:. That is why the debug messages are there, so show them to us too.



use this struct to print variables
Code:
(assign, reg10, ":cur_item"),
(assign, reg11, ":player_agent"),
(display_message, "@Stuff I am debugging... and my variables are {reg10} , {reg11}"),

 
Hi im having a little problem(more doubts) i have made a scene village and maked my own village 111 in the parties entry but i want to give that village to belong to uxhall(don't remember exact name) how can i do it?
I also want to have a specie of a local militar men for now in appearance later to have him producing better troops for more money( if possible) in a specie of keep that i've putted in my village scene?(have already putted village elder)
And i want to know how can i make player begin already a lord for example when choosing go to praven begin already a swadian lord and start with my village in this case?
Thx you all for your time
 
Ok, just jumping through the great wall of coding, and I've encountered something while implementing Caba's script for troop weapon selections

Placed the scripts, constants and mission_templates on the module system, and the outcome is from the mission_templates about an indention error, particularly this:
Code:
order_weapon_type_triggers = [     
	(0, 0, 1, [(key_clicked, key_for_onehand)], [(call_script, "script_order_weapon_type_switch", onehand)]),
	(0, 0, 1, [(key_clicked, key_for_bothhands)], [(call_script, "script_order_weapon_type_switch", bothhands)]),	
	(0, 0, 1, [(key_clicked, key_for_ranged)], [(call_script, "script_order_weapon_type_switch", ranged)]),
	(0, 0, 1, [(key_clicked, key_for_shield)], [(call_script, "script_order_weapon_type_switch", shield)]),
	]

It seems the error is pointing the o on the order word, and I couldn't figure out what's going on, even when I've doubled checked my other codes. Then I searched for the indention error and realised that it has to be placed in the start of the line.


Genius. I spent hours trying to figure out a simple mistake. Wonder why I didn't learn coding when I was 5.


So just a question, in laymans terms, that is a new piece of code that I'm adding onto mission templates. and for every code in that file, I have to shove the code to the left most side in order for it to work?, and that other py files like scripts and game_menus all consists of one whole code?
 
Johao said:
So just a question, in laymans terms, that is a new piece of code that I'm adding onto mission templates. and for every code in that file, I have to shove the code to the left most side in order for it to work?, and that other py files like scripts and game_menus all consists of one whole code?

Python is based on indentation  (http://www.diveintopython.net/getting_to_know_python/indenting_code.html).
When you include something like the above you are using Python + MBScript, so you need to follow Python rules as well

when you include a new script inside the "scripts" variable, etc, you are using MBScript, so in a way it is "one whole code" on the Python side.

read this http://forums.taleworlds.com/index.php/topic,240255.0.html and other guides on MBScript
 
The faction I created is a branch of Vaegirs so I just want to use the Vaegir symbol, how do I give the new faction the Vaegir banner?

http://static1.wikia.nocookie.net/__cb20100527032723/mountandblade/images/0/05/Vaegirs_Banner.jpg

THis I mean. So like you click the faction ingame and ^ shows up instead of a blank spot
 
open module_meshs.py

you will see a pic_arms_xxxxx there for each faction. Include yours (copy of Vaegirs) and check the scripts that uses it, like in module_tableau_materials.py
 
thank you.

for some body armor items, some show default pants since the meshes themselves lack thighs/legs. is there a way to enable/disable that for other body armors? im trying to swap the new nomad armor for the old one but the old one requires the default pants, and idk how to add it. otherwise when I switch the meshes it replaces the new armor but my thighs are invis
 
A way to skip MB Warband quest /merchant intro? Mine's apparently bugged. After I kill the bandit a novice warrior spawns instead of the merchant.

Is it because I made new factions and the towns belong to different factions now?
 
Is there a list somewhere specifying what will and what won't break save compatibility? For instance I saw globals mentioned in this context, but not sure at all what are the exact constraints.
 
Status
Not open for further replies.
Back
Top Bottom