Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
you should spend a hour reading all header_xxx.py files to learn about game flags

I'm trying! :razz:

Edit 2: Was having an issue, but I solved it. I still don't understand why I was having it, and my fixed seemed arbitrary but it fixed it so...
                                  v
I've got this bit of code here
Code:
        (store_agent_hit_points, ":health", ":defeated_agent",1),
	(store_agent_hit_points, reg7, ":defeated_agent",1),
	(display_message, "@{reg7}"),
	(try_begin),
	  (this_or_next|ge, ":health", -5,
	   troop_is_hero, ":defeated_troop"),
	  (try_begin),
		(neg|agent_is_alive, ":defeated_agent"),
		(set_trigger_result, 2),
		(call_script, "script_play_voice_command", ":defeated_agent", "snd_order_hold"),
	  (try_end),

However, the conditions of the try seem to be ignored. When I test it in battle, I have enemies who are not heroes who take 160 damage (leaving reg7 at -147 as I can see from debug message, meaning ":health" should be the same value of -147) who pass through, and I know because I hear the "snd_order_hold" voice command (another debug tactic). So for some reason they are passing right through the try even though they fit none of the criteria.

Edit: the same thing is happening with my other template now too!

Here's code:
Code:
(eq, ":order", mordr_charge),
		(agent_get_troop_id, ":agent_troop", ":agent"),
		(store_faction_of_troop, ":agent_faction", ":agent_troop"),
		(store_faction_of_troop, reg7, ":agent_troop"),
		(display_message, "@{reg7}"),
		(store_random_in_range, ":rand", 0, 5),
		(try_begin),
		  (eq, ":rand", 1),
		  (try_begin),
		    (this_or_next|eq, ":agent_faction", 0,
			 this_or_next|eq, ":agent_faction", 1,
			 this_or_next|eq, ":agent_faction", 2,
			 this_or_next|eq, ":agent_faction", 3,
			 this_or_next|eq, ":agent_faction", 4,
			 this_or_next|eq, ":agent_faction", 5,
			 this_or_next|eq, ":agent_faction", 13,
			 this_or_next|eq, ":agent_faction", 14,
			 this_or_next|eq, ":agent_faction", 15,
			 this_or_next|eq, ":agent_faction", 25,
			 this_or_next|eq, ":agent_faction", 26,
			 this_or_next|eq, ":agent_faction", 27,
			              eq, ":agent_faction", 28),
		    (call_script, "script_play_voice_command", ":agent", "snd_eng_battlecry"),
		  (else_try),
		    (eq, ":agent_faction", 16),
			(call_script, "script_play_voice_command", ":agent", "snd_rus_battlecry"),
		  (else_try),
		    (eq, ":agent_faction", 20),
			(call_script, "script_play_voice_command", ":agent", "snd_arb_battlecry"),
		  (try_end),
		(try_end),

As you can see it checks the troop's faction and then sets that agent's battle-cry to the respective language... however even though my debug message shows that the faction of my Sarranid troops is 20 and the faction of my Vaegir troops is 16... they all shout in English anyways! This has nothing to do with my sounds, I'm sure of it. Can someone please tell me why my try's aren't working as they should, as they do in other places?

I solved the issue of it going through the try's but now I get opcode errors spamming my message log out of existence for mst_lead_charge. My Warband is up to date and everything, and I'm not using any deprecated or commented operations. I think the opcode error was 1073741855 at line 30 of mst_lead_charge. The issue lies within the second set of code, for sure.
 
Bustah said:
I think the opcode error was

don't think it, copy and paste it. We can give a quick explanation on how to read and interpret them the first time.

if from compiler you can copy the content of the window (use your mouse or shortcuts). If from the game check your rgl_log.txt.

one of the basic things you will need to learn is how to read error messages, how to find the code related to them, and then how to go about fixing the bug.

a more advanced thingy is to use logging. See this if you ever want to learn how: https://forums.taleworlds.com/index.php/topic,347990.msg8335287.html#msg8335287
 
kalarhan said:
don't think it, copy and paste it. We can give a quick explanation on how to read and interpret them the first time.

if from compiler you can copy the content of the window (use your mouse or shortcuts). If from the game check your rgl_log.txt.

one of the basic things you will need to learn is how to read error messages, how to find the code related to them, and then how to go about fixing the bug.

a more advanced thingy is to use logging. See this if you ever want to learn how: https://forums.taleworlds.com/index.php/topic,347990.msg8335287.html#msg8335287

OK, however just like the other error, I changed something arbitrary and it stopped. I'm telling no lies when I say I changed the volume of a sound and the chance for a war cry to happen and the error went away. When I say changed the chance I mean I changed (store_random_in_range, ":rand", 0, 5) to (store_random_in_range, ":rand", 0, 11).

Also I didn't really mean to say "think", I was trying to remember that number so wrote "think", then checked the logs to find out it was correct. It was coming from in the game, everything compiled perfectly. I would love to start logging, thank you for the link!
 
Bustah said:
checked the logs to find out it was correct

you need to learn how to interpret the full message. That will lead you to the game file and line of code that exploded. If you already know how to do that, then cool. If you need help to learn how to find said line then make sure to copy the entire thingy.

You should be able to say: it is this file, in this line, this operation, with this parameter being of wrong value. Or this file, this line, with this invalid operation. And so on.

Cheers
 
How am I supposed to tell where in module_game_templates.py "line 30; mst_lead_charge" is? Is it actually at the 30th line of mst_lead_charge? If so then that tells me nothing, because that line is a command that is working perfectly.
 
Bustah said:
"line 30; mst_lead_charge" is?

that is not the full error message, right? You are at least missing the trigger number there  :grin:

copy the entire thingy until you learn which parts are important and which ones can be ignored.
 
OK, the error started again. It's the exact same as before.

Unrecognized opcode 1073741855,; LINE NO: 30:
At Mission Template mst_lead_charge trigger no: 4 consequences
At Mission Template mst_lead_charge trigger no: 4 consequences

This is it ^ character for character.

I'm also noticing that random sounds are playing instead of the ones I want... it all just started, I don't know why.
 
Bustah said:
Unrecognized opcode 1073741855,; LINE NO: 30:
At Mission Template mst_lead_charge trigger no: 4 consequences

Unrecognized opcode  -> invalid operation. You have a bug on how you built your operation and the engine can't recognize it. Lets find the error
1073741855 -> wrong operation (indicates a combined one like "this_or_next|eq", not a singular operation like "eq"
LINE NO: 30: 31th line of code (don't count comments or empty lines, its 31th tuple or operation)
At Mission Template: file module_mission_templates.py
mst_lead_charge:  template "lead_charge"
trigger no: 4  -> count your trigger and find it on that template
consequences: second block of code for that trigger

find the code and post it here if you can't figure out the error
 
OK, it makes a lot more sense now! I have a few suspicions about my this_or_nexts. I believe I've been doing them incorrectly... and your tips have all but confirmed my suspicions. Let me do some testing and I will be back with an answer!

Edit: it fixed the error part of the issue, but the rest still isn't working properly. It's going to be a long night
 
Bustah said:
It's going to be a long night

welcome to the coder's life  :razz:

use a proper text editor like SublimeText with Python color coding
Code:
  (this_or_next|ge, ":health", -5,
	   troop_is_hero, ":defeated_troop"),

this bug should be easy to pick up with a colored version

you can also use SublimeText with MB style if you visit the OSP tool section (amazing tool that will save you tons of time and frustation)
http://forums.taleworlds.com/index.php/topic,320675.0.html
 
Bustah said:
The sound is functional

give a good description of each sound file with issues, and if possible post a link to download them. That way modders that work with sound effects can pinpoint errors (stuff the engine can`t handle well).

you can also visit the tutorial section or use search on this thread for older discussions on how to make sound files that work well on Warband.
 
kalarhan said:
nope, that is the point. To remember to check how the AI will use the weapon once it stop using the shield. A 2-handed copy may be better as you can replace the 1-handed weapon with a version that has different animations (and in some cases even a different type). Or it requires a review of the spears (or whatever 1-h / 2-h weapons he has) and all capabilities.

Some mods, as a example, have pikes using the 2-handed sword skill (and appropriate animations), and 2-handed spears as polearms.

Cheers

I'm too stupid  :facepalm:: it was enough to unequip then re-equip the agent with the same item/shield. and it works perfectly !
Thanks everyone  :grin:
 
When I add overlays in presentation, only 5 overlay is showing instead of 9 overlays. How can I solve this problem? Codes are these:
Code:
("diplomacy_agree_comes", 0, mesh_load_window, [
    (ti_on_presentation_load,
     [
      (presentation_set_duration, 999999),
      (set_fixed_point_multiplier, 1000),#create_text_overlay

      (assign, "$reason_box", -1),
      (assign, "$reason_attack_other_country", -1),
      (assign, "$reason_defend_other_country", -1),
      (assign, "$reason_trade", -1),
      (assign, "$reason_political_intrigue", -1),
      (assign, "$reason_trust_us", -1),
      (assign, "$reason_trust_other_country", -1),
      (assign, "$reason_become_ally_with_us", -1),
      (assign, "$reason_be_our_client_state", -1),
      (assign, "$cik_su_prnstdan_test", -1),

      (str_clear, s1),
      (str_clear, s2),
      (str_clear, s3),
      (str_clear, s4),

      (try_begin),
      (eq, "$diplomacy_reason_1", slot_diplomacy_reason_defend_us),
      (try_begin),
      (eq, "$diplomacy_with_faction", "fac_xelosas"),
      (str_store_string, s1, "@Defend us.(Xelosas)"),
      (else_try),
      (eq, "$diplomacy_with_faction", "fac_velcsoris"),
      (str_store_string, s1, "@Defend us.(Velcsoris)"),
      (try_end),
      (else_try),
      (eq, "$diplomacy_reason_1", slot_diplomacy_reason_trade),
      (try_begin),
      (eq, "$diplomacy_with_faction", "fac_xelosas"),
      (str_store_string, s1, "@Trade.(Xelosas)"),
      (else_try),
      (eq, "$diplomacy_with_faction", "fac_velcsoris"),
      (str_store_string, s1, "@Trade.(Velcsoris)"),
      (try_end),
      (try_end),
      
      (try_begin),
      (eq, "$diplomacy_reason_2", slot_diplomacy_reason_defend_us),
      (try_begin),
      (eq, "$diplomacy_with_faction", "fac_xelosas"),
      (str_store_string, s2, "@Defend Us 2.(Xelosas)"),
      (else_try),
      (eq, "$diplomacy_with_faction", "fac_velcsoris"),
      (str_store_string, s2, "@Defend Us 2. (Velcsoris)"),
      (try_end),
      (else_try),
      (eq, "$diplomacy_reason_2", slot_diplomacy_reason_trade),
      (try_begin),
      (eq, "$diplomacy_with_faction", "fac_xelosas"),
      (str_store_string, s2, "@Trade 2.(Xelosas)"),
      (else_try),
      (eq, "$diplomacy_with_faction", "fac_velcsoris"),
      (str_store_string, s2, "@Trade 2. (Velcsoris)"),
      (try_end),
      (try_end),

#      (assign, "$reason_box", -1),
#      (assign, "$reason_attack_other_country", -1),
#      (assign, "$reason_defend_other_country", -1),
#      (assign, "$reason_trade", -1),
#      (assign, "$reason_political_intrigue", -1),
#      (assign, "$reason_trust_us", -1),
#      (assign, "$reason_trust_other_country", -1),
#      (assign, "$reason_become_ally_with_us", -1),
#      (assign, "$reason_be_our_client_state", -1),
       

      (create_text_overlay, "$reason_box", "@{s1}^^{s2}^^{s3}^^{s4}", tf_scrollable),

      (create_in_game_button_overlay, "$reason_attack_other_country", "@Attack Another Country"),
      (create_in_game_button_overlay, "$reason_defend_other_country", "@Defend Each Other"),
      (create_in_game_button_overlay, "$reason_trade", "@Trade Each Other"),
      (create_in_game_button_overlay, "$reason_political_intrigue", "@Political Intrigue"),
      (create_in_game_button_overlay, "$reason_trust_other_country", "@Trust Other Country"),
      (create_in_game_button_overlay, "$reason_become_ally_with_us", "@Become Ally With Us"),
      (create_in_game_button_overlay, "$reason_be_our_client_state", "@Be our Client State"),
      (create_in_game_button_overlay, "$cik_su_prnstdan_test", "@Exit"),
      (position_set_x, pos1, 250),
      (position_set_y, pos1, 250),
      (overlay_set_size, "$reason_attack_other_country", pos1),
      (overlay_set_size, "$reason_defend_other_country", pos1),
      (overlay_set_size, "$reason_trade", pos1),
      (overlay_set_size, "$reason_political_intrigue", pos1),
      (overlay_set_size, "$reason_trust_other_country", pos1),
      (overlay_set_size, "$reason_become_ally_with_us", pos1),
      (overlay_set_size, "$reason_be_our_client_state", pos1),
      (overlay_set_size, "$cik_su_prnstdan_test", pos1),

      (position_set_x, pos1, 500),
      (position_set_y, pos1, 900),
      (overlay_set_position, "$reason_box", pos1),
      
      (position_set_x, pos1, 250),
      (position_set_y, pos1, 800),
      (overlay_set_position, "$reason_attack_other_country", pos1),

      (position_set_x, pos1, 250),
      (position_set_y, pos1, 750),
      (overlay_set_position, "$reason_defend_other_country", pos1),

      (position_set_x, pos1, 250),
      (position_set_y, pos1, 700),
      (overlay_set_position, "$reason_trade", pos1),

      (position_set_x, pos1, 250),
      (position_set_y, pos1, 650),
      (overlay_set_position, "$reason_political_intrigue", pos1),

      (position_set_x, pos1, 250),
      (position_set_y, pos1, 600),
      (overlay_set_position, "$reason_trust_other_country", pos1),

      (position_set_x, pos1, 250),
      (position_set_y, pos1, 550),
      (overlay_set_position, "$reason_become_ally_with_us", pos1),

      (position_set_x, pos1, 250),
      (position_set_y, pos1, 500),
      (overlay_set_position, "$reason_be_our_client_state", pos1),

      (position_set_x, pos1, 850),
      (position_set_y, pos1, 850),
      (overlay_set_size, "$reason_box", pos1),
      
#      (position_set_x, pos1, 320),
#      (position_set_y, pos1, 560),
#      (overlay_set_position, reg0, pos1),
      
      (position_set_x, pos1, 360),
      (position_set_y, pos1, 130),
      (overlay_set_area_size, "$reason_box", pos1),
      ]),

    (ti_on_presentation_event_state_change,
     [
      (store_trigger_param_1, ":object"),
      (store_trigger_param_2, ":val"),

      (try_begin),
      (eq, ":object", "$cik_su_prnstdan_test"),
      (presentation_set_duration, 0),
      (try_end),
      ]),
    ]),
 
Kortlcha said:
When I add overlays in presentation, only 5 overlay is showing instead of 9 overlays

screen is 1.00 x 0.75 in dimensions. Using multiplier = 1000, that is 1000x750

Use Kuba helper to see coordinates with your mouse

From VC source
Code:
load = ti_on_presentation_load
run = ti_on_presentation_run
event = ti_on_presentation_event_state_change
hover = ti_on_presentation_mouse_enter_leave
click = ti_on_presentation_mouse_press

# Shows coordinates on a presentation for easy development
# Set debug_show_presentation_coordinates on module_constants.py
coord_helper = [
  (load, [
      (eq, debug_show_presentation_coordinates, 1),
      (create_text_overlay, "$mouse_coordinates", "str_empty_string"),
      (overlay_set_color, "$mouse_coordinates", 0xFF0000),
      (position_set_x, pos1, 10),
      (position_set_y, pos1, 700),
      (overlay_set_position, "$mouse_coordinates", pos1),
  ]),
  (run, [
      (eq, debug_show_presentation_coordinates, 1),
      (set_fixed_point_multiplier, 1000),
      
      (mouse_get_position, pos1),
      (position_get_x, reg1, pos1),
      (position_get_y, reg2, pos1),
      (overlay_set_text, "$mouse_coordinates", "@{reg1}, {reg2}"),
  ])
]
 
Does anyone know of more layout text codes for dialogues and menus? For example, when creating a menu or dialogue you can use "^" before the text to make the whole text drop a line, or more depending on how many "^" you use. I'm specifically looking for an align left code. I've tried codes from python and from other languages but none seem to work. Help is appreciated.
 
Kortlcha said:
So what codes should I write?

look at your monitor

what happens if you try to place a sticker in the middle of it, then another one outside the boundaries of your monitor (say 10 cm away from the border). That is what you were doing.

1000x750 is your canvas size.



Iron Sight said:
I'm specifically looking for an align left code.
you can do that with presentations (custom UI). The menu is a hardcoded presentation, easy to use, but limited in what you can do with it.

if you just want to reposition your menu elements see game_variables.txt
 
When is the fact that someone is going to be able to be taken prisoner decided? Before or after ti_agent_killed_or_wounded? Because for some reason after some battles I have more prisoners than there were people wounded and I have some where there are less. It seems that even though I am setting the result of ti_agent_killed_or_wounded in my code, and they show up as killed or wounded in the battle correctly, the prisoner aftermath is wrong. If I leave the battle early, they have the right amount afterwards... it's just the prisoners part that is behaving incorrectly. Any ideas?

Edit: OK so after some testing I have found that despite setting the result of the trigger, their fate regarding prisonership is already decided.  :???:
 
Bustah said:
When is the fact that someone is going to be able to be taken prisoner decided? Before or after ti_agent_killed_or_wounded? Because for some reason after some battles I have more prisoners than there were people wounded and I have some where there are less. It seems that even though I am setting the result of ti_agent_killed_or_wounded in my code, and they show up as killed or wounded in the battle correctly, the prisoner aftermath is wrong. If I leave the battle early, they have the right amount afterwards... it's just the prisoners part that is behaving incorrectly. Any ideas?

Edit: OK so after some testing I have found that despite setting the result of the trigger, their fate regarding prisonership is already decided.  :???:
you can use agent_set_no_death_knock_down_only on ti_on_agent_hit
 
Ikaguia said:
you can use agent_set_no_death_knock_down_only on ti_on_agent_hit

But the thing is, I need it both ways... I've implemented a system where the more damage a character takes beyond 0hp, their chance of dying increases. However I've made it such that if the game has already decided (through ti_on_agent_killed_or_wounded) that said character should be wounded, that chance decreases. For example, if a character's health at the point of being defeated is between -10 and -20, they have a 1 in 6 chance of surviving that defeat, however if they were decided to be wounded by the game (surgery skill or hit with a blunt weapon) then their chance increases to 1 in 2. I'll put the code in a spoiler in case I'm not explaining it well enough.

Code:
  ti_on_agent_killed_or_wounded, 0, 0, [],
  [
    (store_trigger_param, ":defeated_agent", 1),
	(store_trigger_param, ":wounded", 3),
	(val_mul, ":wounded", 5),
	(agent_get_troop_id, ":defeated_troop", ":defeated_agent"),
	(store_agent_hit_points, ":health", ":defeated_agent",1),
	(assign, ":death_chance", 10),
	(try_begin),
	  (neg|agent_is_alive, ":defeated_agent"), #so that this doesn't apply to auto-resolve
	  (try_begin),
	    (this_or_next|troop_is_hero, ":defeated_troop"),
	                 (ge, ":health", -2),
		(set_trigger_result, 2),
	  (else_try),
	    (ge, ":health", -10),
	    (val_sub, ":death_chance", 5),
	    (val_sub, ":death_chance", ":wounded"),
	    (store_random_in_range, ":rand", 0, ":death_chance"),
		(try_begin),
		  (eq, ":rand", 1),
		  (set_trigger_result, 2),
		(else_try),
		  (set_trigger_result, 1),
		(try_end),
	  (else_try),
	    (ge, ":health", -20),
	    (val_sub, ":death_chance", 4),
	    (val_sub, ":death_chance", ":wounded"),
	    (store_random_in_range, ":rand", 0, ":death_chance"),
		(try_begin),
		  (eq, ":rand", 1),
		  (set_trigger_result, 2),
		(else_try),
		  (set_trigger_result, 1),
	    (try_end),
	  (else_try),
	    (ge, ":health", -30),
		(val_sub, ":death_chance", 2),
		(val_sub, ":death_chance", ":wounded"),
		(store_random_in_range, ":rand", 0, ":death_chance"),
		(try_begin),
		  (eq, ":rand", 1),
		  (set_trigger_result, 2),
		(else_try),
		  (set_trigger_result, 1),
		(try_end),
	  (else_try),
	    (ge, ":health", -40),
		(val_sub, ":death_chance", 1),
		(val_sub, ":death_chance", ":wounded"),
		(store_random_in_range, ":rand", 0, ":death_chance"),
		(try_begin),
		  (eq, ":rand", 1),
		  (set_trigger_result, 2),
		(else_try),
		  (set_trigger_result, 1),
		(try_end),
	  (else_try),
	    (gt, -40, ":health"),
		(set_trigger_result, 1),
	  (try_end),
	(try_end),
  ],

Do you see my issue? The game decides prisoners based on what the original death/wound system decided, not what actually happened in the battle. If I use agent_set_no_death_knock_down_only then everyone will be wounded and people that I decide will die will show up as dead on the battlefield and casualties screen but can still be taken prisoner at the end.
 
Status
Not open for further replies.
Back
Top Bottom