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:
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. Thank you very much for the advises. With your help I finally managed to make the lance get lost.  :grin:
It's curious that the same code(removing the lance from the player's inventory) did not succeed when I launched it during the battle, but worked perfectly when I called from the mnu_battle_debrief.
Anyway if you are interested how I made it:
The code works the following way:
First a script is called from module_mission_template
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_vitali_game_event_agent_hit", ":inflicted_agent", ":cur_agent", ":inflicted_damage", ":cur_item"),
	(try_end),
 ])

Then if the agent is the player, a global variable "$g_hussar_lance_broken" is incremented. That means that there is one broken lance in the player's inventory
Code:
#script_vitali_game_event_agent_hit
("vitali_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", 90), #if this is a big damage
		(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
		(try_begin),
			(eq, ":cur_agent", ":player_agent"),
			(troop_has_item_equipped, "trp_player", ":cur_item"),
			#add 1 more broken lance
			(val_add, "$g_hussar_lance_broken", 1),
		(try_end),
. . . etc.

Afterwards, when the mission(battle) is complete the game checks how many lances have been broken
It is done in  mnu_battle_debrief
Code:
#If there is 1 or more broken lances, call the script
(try_begin),
	(ge, "$g_hussar_lance_broken", 1),
	(call_script, "script_vitali_remove_hussar_lance"),
(try_end),

Finally, depending on how many lances are broken the following script removes them from the player's inventory
Code:
#script_vitali_remove_hussar_lance
("vitali_remove_hussar_lance",
[
#Through the lance away(cause it's broken)
(display_message, "@script_vitali_remove_hussar_lance started"),
(try_for_range, ":i", 0, "$g_hussar_lance_broken"), #loop as many times as the player broke the lances in the previous battle
	(assign, ":break", 0),
	(try_for_range, ":slot_no", 0, 4),
		(eq, ":break", 0),
		(troop_get_inventory_slot, ":cur_slot", "trp_player", ":slot_no"),
		(this_or_next|eq, ":cur_slot", "itm_gusar_lanza"),
		(this_or_next|eq, ":cur_slot", "itm_gusar_lanza_b"),
		(             eq, ":cur_slot", "itm_gusar_lance"),
		(troop_set_inventory_slot, "trp_player", ":slot_no", -1), 
		(assign,":break", 1),
		(assign, reg10, ":cur_slot"),
		(assign, reg11, ":slot_no"),	
		(display_message, "@The broken lance is removed from the inventory"),			
		(display_message, "@hussar lance = {reg10}, slot_no = {reg11}"),			
	(try_end),
(try_end),
(assign, "$g_hussar_lance_broken", 0), #obnulim :)
]),
...And assigns the global variable back to 0.

What do you think? Maybe I left something vital?
 
vitali-attila said:
What do you think? Maybe I left something vital?

whatever works  :smile:. I did a quick test after you first post, and your initial solution worked for me (remove items while inside the mission). I am using 1.167 btw. Both troop_remove_item and troop_set_inventory_slot are OK.

You can solve a problem in many ways. Some will be more complicate than others, but you will learn how to get the easy solution with experience. In any case, your code is very well organized, that is already a huge step in the right direction.

Code:
	(0, 0, 0, [
      	(key_clicked, key_k),
      	(display_message, "@removing gear", 0xff0000),     	      	
      	],
      [
      	(get_player_agent_no, ":player"),
      	(troop_get_inventory_slot, ":item", "trp_player", 0),
      	(agent_unequip_item, ":player", ":item", 0),
      	(troop_set_inventory_slot, "trp_player", 0, -1),

      	(troop_get_inventory_slot, ":item2", "trp_player", 1),     
      	(agent_unequip_item, ":player", ":item2", 1), 	
      	(troop_remove_item, "trp_player", ":item2"),
      	(display_message, "@done", 0x00FF00),
      ]),
 
So I made a solution to a problem I had with snow being too low on mountains, but when the camera goes below a certain height the map seems to turn into night even if it is high noon. (the time doesn't change, just the sky turns dark) Is there a way to make sure the camera must remain above a certain height?
 
I found it in module_animations:
["ready_bow", acf_rot_vertical_bow|acf_anim_length(100), amf_priority_attack|amf_use_weapon_speed|amf_keep|amf_client_owner_prediction|amf_rider_rot_bow,
  [1.5, "anim_human", combat+500, combat+530, blend_in_ready|arf_make_custom_sound, pack2f(0.14, 0.44)],
],
["release_bow", acf_rot_vertical_bow|acf_anim_length(100), amf_priority_attack|amf_use_weapon_speed|amf_play|amf_client_owner_prediction|amf_rider_rot_bow,
  [0.3, "anim_human", combat+530, combat+532, arf_blend_in_2],
],
#not used
["ready_bow_mounted", acf_rot_vertical_bow|acf_anim_length(100), amf_priority_attack|amf_use_weapon_speed|amf_keep|amf_client_owner_prediction|amf_rider_rot_bow,
  [1.5, "anim_human", combat+800, combat+830, blend_in_ready|arf_make_custom_sound, pack2f(0.10, 0.40)],

],
#not used
["release_bow_mounted", acf_rot_vertical_bow|acf_anim_length(100), amf_rider_rot_bow,
  [0.3, "anim_human", combat+830, combat+832, arf_blend_in_2],

],
["ready_crossbow", acf_rot_vertical_bow|acf_anim_length(100), amf_priority_attack|amf_use_weapon_speed|amf_keep|amf_client_owner_prediction|amf_rider_rot_crossbow,
  [1.5, "anim_human", combat+1300, combat+1320, blend_in_ready],
],
I want to use Papa's bow animations for only as mounted. But these "ready_bow_mounted" and "release_bow_mounted" animations are inactive( #not used) . How can I make them active?
 
Do you know where the animations were to set? For example "ready_bow" animation is for pulling bow. How can the pyton know this? or
Is there any other way to use different animations for bows while mounted&while on foot?
 
Animations are largely hardcoded, i.e. the warband executable assigns and reads them automatically. You can do this manually to a certain extent with agent_set_animation, but it's extremely limited. The only animations you can assign during combat are things with the amf_play flag, like the cheer animation and the death animation and other things that get played once.

You can change what the animation looks like and how long it is, and to a certain extent how it acts, but adding new ones with new contexts is problematic/impossible.
 
But there were this animations i want to add in older versions as you said. Maybe they can be added again. Which module_system version should I search for this? or Do you know the codes?
----Is it realy impossible? :sad:
 
kalarhan said:
vitali-attila said:
What do you think? Maybe I left something vital?

whatever works  :smile:. I did a quick test after you first post, and your initial solution worked for me (remove items while inside the mission). I am using 1.167 btw. Both troop_remove_item and troop_set_inventory_slot are OK.

You can solve a problem in many ways. Some will be more complicate than others, but you will learn how to get the easy solution with experience. In any case, your code is very well organized, that is already a huge step in the right direction.

Code:
	(0, 0, 0, [
      	(key_clicked, key_k),
      	(display_message, "@removing gear", 0xff0000),     	      	
      	],
      [
      	(get_player_agent_no, ":player"),
      	(troop_get_inventory_slot, ":item", "trp_player", 0),
      	(agent_unequip_item, ":player", ":item", 0),
      	(troop_set_inventory_slot, "trp_player", 0, -1),

      	(troop_get_inventory_slot, ":item2", "trp_player", 1),     
      	(agent_unequip_item, ":player", ":item2", 1), 	
      	(troop_remove_item, "trp_player", ":item2"),
      	(display_message, "@done", 0x00FF00),
      ]),

In my case troop_remove_item removed not the first found item(that was in the weapon slot), but the last found item(that was in the inventory). I tested it while having 5-6 lances :smile:
As for removing the item while inside a mission, I do not know why it does not work in my game.
Yeah, and I am modifying WFaS 1.143, not Warband. :grin:  As I have noticed, you play it as well.
I want to make a mod for WFaS and include this script into it. And I will include you in the credits, if you don't mind.
 
vitali-attila said:
As for removing the item while inside a mission, I do not know why it does not work in my game.
Yeah, and I am modifying WFaS 1.143, not Warband. :grin:  As I have noticed, you play it as well.
I want to make a mod for WFaS and include this script into it.
ah well that changes things, WFaS engine is older. I have WFaS, but I don't even remember the last time I played it lol.

In my case troop_remove_item removed not the first found item(that was in the weapon slot), but the last found item(that was in the inventory). I tested it while having 5-6 lances :smile:
that is not a problem in my opinion. It still removes the item so you will need to buy new ones, but at the same time it reduces the micromanaging as the player will not have to open inventory and replace the item manually every time it breaks (that is what squires are for!)

Unless you want to make it a rare event. Otherwise the player will end up starting new fights without a lance and have those WTF moments hehe (forgot the lance, again!)

And I will include you in the credits, if you don't mind.
No need, this is a open forum for learning how to mod. If you try to give credit for small things you will go crazy trying to keep the list updated  :mrgreen:
Unless the OSP author requested credit of course  :wink:
 
Is there a way for me to add banners other loads can't use? I want to add a bunch of my own custome banners to the game but I hate it when I see another lord using my banner. kthx
 
kalarhan said:
Unless you want to make it a rare event. Otherwise the player will end up starting new fights without a lance and have those WTF moments hehe (forgot the lance, again!)

Hmm. I have not thought about this. Perhaps I should make a more complicated code where the lance is replaced with the lance from inventory. You remember you told about masterwork and cracked lances), what if that last lance is the masterwork and the one that actually broke - cracked? :grin:

No need, this is a open forum for learning how to mod. If you try to give credit for small things you will go crazy trying to keep the list updated  :mrgreen:
Unless the OSP author requested credit of course  :wink:

OK. Anyway thank you again. I began to believe in myself as a modder as I managed to complete this lance breaking script. :grin:

Now I've a new task. I want to allow the player to become a king from the beginning of the game. Yet it does not come out, but I'm trying to follow the story line(it's code) of "False Dmitry the Third"(you become a king at the end). Maybe you have some ideas?
 
vitali-attila said:
Now I've a new task. I want to allow the player to become a king from the beginning of the game. Yet it does not come out, but I'm trying to follow the story line(it's code) of "False Dmitry the Third"(you become a king at the end). Maybe you have some ideas?

this has being done on a few mods, including this OSP: http://forums.taleworlds.com/index.php/topic,323422.0.html

How about instead of doing it over again, you start from that and include more features?

(and Viking Conquest RE is also adding this idea)  :wink:
 
Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_global_variables.py", line 12, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Traceback (most recent call last):
  File "process_map_icons.py", line 6, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Exporting faction data...
Exporting item data...
Traceback (most recent call last):
  File "process_items.py", line 66, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Exporting scene data...
Traceback (most recent call last):
  File "process_scenes.py", line 15, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Exporting troops data
Exporting particle data...
Traceback (most recent call last):
  File "process_scene_props.py", line 7, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_tableau_materials.py", line 8, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_presentations.py", line 8, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Exporting party_template data...
Traceback (most recent call last):
  File "process_parties.py", line 4, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Exporting quest data...
Exporting info_page data...
Traceback (most recent call last):
  File "process_scripts.py", line 7, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_mission_tmps.py", line 8, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_game_menus.py", line 5, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_simple_triggers.py", line 5, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Traceback (most recent call last):
  File "process_global_variables_unused.py", line 3, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936
    ),
    ^
IndentationError: unexpected indent
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .

Getting this awkward error .. I don't know why it's saying there's an unexpected indent at line 9936 when I didn't even touch the piece of code?
 
Pilgrim said:
Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\process_operatio
ns.py", line 22, in <module>
    from module_game_menus import *
  File "E:\MB Modding\Module System Warband\Module_system 1.166\module_game_menu
s.py", line 9936y key to exit. . .

Getting this awkward error .. I don't know why it's saying there's an unexpected indent at line 9936 when I didn't even touch the piece of code?

check your code around that line, you have either a indentation error or you are missing a closing character: , ) ] somewhere

add it here using CODE tag if you can`t figure this out
 
Is there any way to make scene in main menu ? or something like that ? i tried to make presentation, it jumps to scene i put, but when i compiled and opened the game, it stopped itself.  :mrgreen:
 
Status
Not open for further replies.
Back
Top Bottom