Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
_Sebastian_ said:
MitchellD said:
Has anybody ever figured out the game engine's algorithm for giving agents items from the troop inventory, or come up with a good estimation based on observation?
Pure randomness.

Script is weighted by the item value. It will distribute items of the medium value (price $), and reserve a % for the cheapest and the most expensive one. I don't have the exact numbers here, but its something like:

1 - cheapest: 10%
2 - random: 80 %
3 - most expensive: 10%

If you look at VC code you will notice that the DLC uses a trigger to replace the armor (body piece) of agents to create a different distribution. Its under "common_gear_check".

This is a logger/trigger I used to test the feature and that you can adapt to check how your items are being used by agents:

Code:
logger_armor_selection = (
	10, 0 , ti_once , 
	[#(ge, "$cheat_mode", 1),
	(mission_tpl_are_all_agents_spawned),
	 ],
	[
	 (set_show_messages, 0),	

	 (display_message, "@^-----------------------------------^"),

	 (try_for_range, ":i", 0, 1000),
	 	(troop_set_slot, "trp_temp_array_a", ":i", -1),
	 	(troop_set_slot, "trp_temp_array_b", ":i", 0),
	 	(troop_set_slot, "trp_temp_array_c", ":i", -1),
	 (try_end),

	 (assign, ":troop_index_add", 25),	 	
	 (assign, ":troop_index", 0),

	 #setup 
	 (try_for_agents, ":agent"),
	 	(agent_is_human, ":agent"),
	 	(agent_is_alive, ":agent"),
	 	(agent_is_ally, ":agent"),	
 		(assign, ":is_know_troop", 0),
 		(assign, ":array_limit", 1000),
 		(val_div, ":array_limit", ":troop_index_add"),	
 		(assign, ":slot", 0),
 		(agent_get_troop_id, ":troop_id", ":agent"),
 			 			 		
	 	(try_for_range, ":i", 0, ":array_limit"),
	 		(troop_get_slot, ":saved_troop", "trp_temp_array_a", ":slot"),

	 		(assign, reg20, ":saved_troop"),
	 		(assign, reg21, ":troop_id"),		
	 		
	 		(try_begin),
		 		(eq, ":saved_troop", ":troop_id"),
		 		(assign, ":is_know_troop", 1),
		 		(assign, ":array_limit", 0),
		 	(else_try),
		 		(eq, ":saved_troop", -1),
				(assign, ":is_know_troop", 0),
		 		(assign, ":array_limit", 0),		 		
	 		(else_try),
	 			(val_add, ":slot", ":troop_index_add"),		 		    		 		    
	 		(try_end),
	 	(try_end),

	 	(eq, ":is_know_troop", 0),
 		(assign, reg1, ":troop_index"),	
 		(val_add, ":troop_index", ":troop_index_add"), 		

	 	(try_for_range, ":slot2", 0, 65),
	 		(troop_get_inventory_slot, ":item", ":troop_id", ":slot2"),	 		
	 		(neq, ":item", -1),

	 		(item_get_type, ":type", ":item"),
	 		(eq, ":type", itp_type_body_armor),		 		
			(troop_set_slot, "trp_temp_array_a", reg1, ":troop_id"),	
			(troop_set_slot, "trp_temp_array_b", reg1, ":item"),
 			(troop_set_slot, "trp_temp_array_c", reg1, 0),	
 			(val_add, reg1, 1),		 						 				 		    	 		    			 				 		    	 		    
		(try_end), 	
	 (try_end),

	 # count gear used
	 (try_for_agents, ":agent"),
	 	(str_clear, s1),
	 	(str_clear, s2),
	 	(str_clear, s3),

	 	(agent_is_human, ":agent"),
	 	(agent_is_alive, ":agent"),
	 	(agent_is_ally, ":agent"),	 

	 	(assign, reg1, ":agent"),
	 	(agent_get_troop_id, ":troop_id", ":agent"),
	 	(assign, reg2, ":troop_id"),
	 	(str_store_troop_name, s4, ":troop_id"),	
	
 		# current chest armor
		(agent_get_item_slot, ":wielded_item", ":agent", ek_body),

	 	(try_begin),
	 		(assign, ":array_limit", 1000),
	 		(val_div, ":array_limit", ":troop_index_add"),	
	 		(assign, ":slot", 0),
	 			 			 		
		 	(try_for_range, ":i", 0, ":array_limit"),
		 		(troop_get_slot, ":saved_troop", "trp_temp_array_a", ":slot"),

		 		(try_begin),
			 		(eq, ":saved_troop", ":troop_id"),
			 		(assign, ":array_limit", 0),
			 		(store_add, ":limit", ":slot", 25),			 		
			 		(try_for_range, ":ii", ":slot", ":limit"),
				 		(troop_get_slot, ":saved_armor", "trp_temp_array_b", ":ii"),
				 		(neq, ":saved_armor", 0),				 		
				 		(eq, ":saved_armor", ":wielded_item"),
				 		(troop_get_slot, ":count", "trp_temp_array_c", ":ii"),				 		
				 		(val_add, ":count", 1),
				 		(troop_set_slot, "trp_temp_array_c", ":ii", ":count"),
				 		(assign, ":limit", 0),
			 		(try_end),
		 		(else_try),
		 			(val_add, ":slot", ":troop_index_add"),		 		    		 		    
		 		(try_end),
		 	(try_end),		 	
	 	(try_end),	 	
	 (try_end),

	 # print report
	 (try_for_range, ":i", 0, 1000),
		(troop_get_slot, ":saved_troop", "trp_temp_array_a", ":i"),
		(gt, ":saved_troop", 0),
		(troop_get_slot, ":piece", "trp_temp_array_b", ":i"),
		(gt, ":piece", 0),		
		(troop_get_slot, ":count", "trp_temp_array_c", ":i"),
		(assign, reg1, ":saved_troop"),
		(assign, reg2, ":piece"),
		(assign, reg3, ":count"),
		(str_store_troop_name, s1, ":saved_troop"),
		(str_store_item_name, s2, ":piece"),
		(display_message, "@Trp: {reg1} | Using: {reg2} | Times: {reg3} | {s1} | {s2}"),
	 (try_end), 
	 (display_message, "@^-------------------------------------^"),	

	 (set_show_messages, 1),
	])
 
Antonis said:
Hi guys, can I ask a question? I want to change the custom battles scenes. I found the bunch in the Scene objects folder, it's the 'scn_quick_battle_x' and 'scn_quick_battle_scene_x', right? So, I was wondering, is there a guide that acts as reference as to what scene they each correspond too? Like, Farmhouse is what scene and so on. Thank you!

check presentation "game_custom_battle_designer", its the one that controls the Custom Battle UI.

Constants are used for the list of scenes: quick_battle_battle_scenes_begin, quick_battle_battle_scenes_end, quick_battle_scene_names_begin...

Code:
quick_battle_troops_begin = "trp_quick_battle_troop_1"
quick_battle_troops_end = "trp_quick_battle_troops_end"

quick_battle_troop_texts_begin = "str_quick_battle_troop_1"
quick_battle_troop_texts_end = "str_quick_battle_troops_end"

quick_battle_scenes_begin = "scn_quick_battle_scene_1"
quick_battle_scenes_end = "scn_quick_battle_maps_end"

quick_battle_scene_images_begin = "mesh_cb_ui_maps_scene_01"

quick_battle_battle_scenes_begin = quick_battle_scenes_begin
quick_battle_battle_scenes_end = "scn_quick_battle_scene_4"

quick_battle_siege_scenes_begin = quick_battle_battle_scenes_end
quick_battle_siege_scenes_end = quick_battle_scenes_end

quick_battle_scene_names_begin = "str_quick_battle_scene_1"


and the presentation has code like this to translate the selection:

Code:
(try_begin),
        (eq, "$g_quick_battle_game_type", 0), #battle
        (try_for_range, ":cur_scene", quick_battle_battle_scenes_begin, quick_battle_battle_scenes_end),
          (store_sub, ":cur_scene_name", ":cur_scene", quick_battle_scenes_begin),
          (val_add, ":cur_scene_name", quick_battle_scene_names_begin),
          (overlay_add_item, "$g_presentation_obj_custom_battle_designer_1", ":cur_scene_name"),
        (try_end),
        (try_begin),
          (is_between, "$g_quick_battle_map", quick_battle_battle_scenes_begin, quick_battle_battle_scenes_end),
          (store_sub, ":cur_map", "$g_quick_battle_map", quick_battle_battle_scenes_begin),
          (overlay_set_val, "$g_presentation_obj_custom_battle_designer_1", ":cur_map"),
        (else_try),
          (overlay_set_val, "$g_presentation_obj_custom_battle_designer_1", 0),
          (assign, "$g_quick_battle_map", quick_battle_battle_scenes_begin),
        (try_end),
      (else_try),
        (try_for_range, ":cur_scene", quick_battle_siege_scenes_begin, quick_battle_siege_scenes_end),
          (store_sub, ":cur_scene_name", ":cur_scene", quick_battle_scenes_begin),
          (val_add, ":cur_scene_name", quick_battle_scene_names_begin),
          (overlay_add_item, "$g_presentation_obj_custom_battle_designer_1", ":cur_scene_name"),
        (try_end),
        (try_begin),
          (is_between, "$g_quick_battle_map", quick_battle_siege_scenes_begin, quick_battle_siege_scenes_end),
          (store_sub, ":cur_map", "$g_quick_battle_map", quick_battle_siege_scenes_begin),
          (overlay_set_val, "$g_presentation_obj_custom_battle_designer_1", ":cur_map"),
        (else_try),
          (overlay_set_val, "$g_presentation_obj_custom_battle_designer_1", 0),
          (assign, "$g_quick_battle_map", quick_battle_siege_scenes_begin),
        (try_end),
      (try_end),
 
Khamukkamu said:
Added to scene_props.py:
Code:
("dorwinion_sack",sokf_type_container,"dorwinion_sack","0", []),

change the physical model. You are using a invalid one "0". Copy from another chest.

You can use CTRL+F on OpenBRF to see them. Player chest, as a example, uses: "bo_player_chest"

Code:
("chest_a",sokf_type_container,"chest_gothic","bochest_gothic", []),
  ("container_small_chest",sokf_type_container,"package","bobaggage", []),
  ("container_chest_b",sokf_type_container,"chest_b","bo_chest_b", []),
  ("container_chest_c",sokf_type_container,"chest_c","bo_chest_c", []),
  ("player_chest",sokf_type_container,"player_chest","bo_player_chest", []),

See if that was the only issue.
 
Yes! That worked! ha... i thought that wasn't necessary given that I named the mesh, but not the collision object.. guess i was wrong.

Created the collision object --> hooked it up to scene_props.py like you mentioned --> tested and voila, works!

Thanks again!
 
Hi everyone!


I have been trying to add the spear bracing kit to my mod, but despite doing everything in the instructions, including adding
(assign, "$setting_use_spearwall", 1),

in module_scripts.



I added the code at the beginning of mission_templates, and then the triggers in lead_charge, as shown below:

Code:
  (
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [
     (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
     (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
     ],
    [
      spearwall_trigger_1,
      spearwall_trigger_2,
      spearwall_trigger_3,
      spearwall_trigger_4,
      spearwall_trigger_5,
      spearwall_trigger_6,
      spearwall_trigger_7,
      spearwall_trigger_8,
      spearwall_trigger_9,
      (ti_on_agent_spawn, 0, 0, [],
       [rest of the code...

It is like the triggers don't fire, and i don't understand why. The code clearly says the key to activate it is "b", but it simply does not work.
What am i missing?
I also tried lumos' version, but again, it does not work.
 
LArVRo.jpg

Why does this man and other mans like him spawn instead of villagers ?

I was put 2 menus which does decide to play with scenario and sandbox. Player is supposed to be start as a king when he selected the scenario, if he select the sandbox, then the cities which will be gived to player is will be given to another faction which that assigned as an "inactive" faction at game_start.

But, this guys don't show up in other villages. Just the villages which have been already given to player -or- to another faction with a loop.
 
Hi all,

Is it possible to advance a quest when the player enters a scene?

I'm trying to NOT add another item to TLD, as Swyter is keeping it compatible with both Vanilla M&B and Warband. Adding a quest item, then progressing the quest by checking that the item was indeed picked up (through dialogue) is what I know how to do...
 
Khamukkamu said:
Is it possible to advance a quest when the player enters a scene?

sure, just define what is your "scene" and where it is the safest spot to add the condition:

1) Its a one time mission_template
2) Its a common mission_template like "town"

If (1) you can use the mission_template triggers, as the checks will be limited to only that case (and won't create a mess on your code). Avoid doing this if its (2).

A simple example:
Code:
      (ti_after_mission_start, 0, ti_once,  [],
        [
          (quest_slot_eq,"qst_my_new_quest",slot_quest_current_state, 2),
          (quest_set_slot,"qst_my_new_quest",slot_quest_current_state, 3),
      ]),

For (2) you are better off just updating it when you are about to start the mission (the jump_to_ operations), unless you need to confirm the action (using a dialog, a pickup item, etc).


remember to use operation: "add_quest_note_from_sreg" to add notes (explanations) for your quest
 
HyperCharge said:
Why does this man and other mans like him spawn instead of villagers ?

Make sure your town/villages have the appropriate culture, and that culture itself has the correct npcs defined like in this example (from VC):

Code:
      (faction_set_slot, "fac_culture_norse", slot_faction_town_walker_male_troop, "trp_town_walker_7"),
      (faction_set_slot, "fac_culture_norse", slot_faction_town_walker_female_troop, "trp_town_walker_8"),
      (faction_set_slot, "fac_culture_norse", slot_faction_village_walker_male_troop, "trp_village_walker_7"),
      (faction_set_slot, "fac_culture_norse", slot_faction_village_walker_female_troop, "trp_village_walker_8"),
      (faction_set_slot, "fac_culture_norse", slot_faction_town_spy_male_troop, "trp_spy_walker_1"),
      (faction_set_slot, "fac_culture_norse", slot_faction_town_spy_female_troop, "trp_spy_walker_2"),

Code:
      # walkers
      (try_for_range, ":center_no", centers_begin, centers_end),
        (try_for_range, ":walker_no", 0, num_town_walkers),
          (call_script, "script_center_set_walker_to_type", ":center_no", ":walker_no", walkert_default),
        (try_end),
      (try_end),

note the slot: slot_faction_village_walker_male_troop, for the culture: Norse
and the use of script_center_set_walker_to_type
 
@kalarhan,

I have already set the slot settings.

In game_start script, I put ":player_faction_culture" as fac_culture_7. If sandbox is selected, then player's culture will be fac_culture_1. Actually, code is telling everything very well.  :smile:
Code:
("start_scenario",[],"Story mode",
        [
          (troop_set_type,"trp_player", 0),
          (assign,"$character_gender",tf_male),
          (assign, "$scenario", 1),
          (faction_set_slot, "fac_kingdom_9", slot_faction_state, sfs_inactive), #Inactivate the Ottoman beylik because player wanted to play scenario
          (start_presentation, "prsnt_fracture_moment_story"),
        ]
      ),
      ("start_no_scenario",[],"Sandbox mode",
        [
          (troop_set_type,"trp_player", 0),
          (assign,"$character_gender",tf_male),
          (assign, "$scenario", 0),
          (assign, ":player_faction_culture", "fac_culture_1"), #well, player didn't want to play with scenario, then set the culture to 1.
          (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, ":player_faction_culture"),
          (faction_set_slot, "fac_player_faction",  slot_faction_culture, ":player_faction_culture"),
          (faction_set_slot, "fac_kingdom_9", slot_faction_state, sfs_active), #then activate the Ottoman Beylik as an AI faction.
          (call_script, "script_give_center_to_faction_aux", "p_town_1", "fac_kingdom_9"), #give them player's fiefs
          (call_script, "script_give_center_to_lord", "p_town_1",  "trp_kingdom_9_lord", 0),
		  (call_script, "script_mcc_default_settings"), # It will be used until race presentation is done. This comes after race presentation.
		  (start_presentation, "prsnt_mcc_character_creation"),

          #(start_presentation, "prsnt_race_selection"), #TO DO
        ]
      ),
 
TRCY_Maresal said:
What are "illegal identifier" and "AttributeError" errors?

"illegal identifier": syntax errors, you have wrong stuff on your code  :razz:

like this
Code:
(assign, "my_var", 10), # should be ":my_var"
(str_store_string, s10, "my string"), # should be "@my string"

Fix the param with the error. Just read the compiler message, that is something like: "ERROR: Illegal Identifier: my_var"


AttributeError: Python exception. Again you have syntax problems.

and so on
 
I'm running into a script related error in Co-Op/MP, I'm assuming this is because the group ID is different under module_coop_scripts and module_coop_templates (coop portion of the mod).

So usage is Module_Coop_Templates calls script on Module_Scripts, but Module_Scripts assigns an incorrect group ID, you can probably check Module_Coop_Scripts below and help me find the correct group ID.

Here is the error that appears:

Code:
 SCRIPT ERROR ON OPCODE 1785: Invalid Group ID: 1; LINE NO: 7: 
 At Script [685] decide_run_away_or_not. At Script [685] decide_run_away_or_not. SCRIPT ERROR ON OPCODE 1785: Invalid Group ID: 1; LINE NO: 7:
^ The script above is in module_scripts, it seems to retrieve a incorrect group ID, I've no idea on how to acquire the group ID used in Co-Op, if someone would help with that I would appeciate it.

Here is the script code in Module_Scripts for the error above:

Code:
	("decide_run_away_or_not",
		[
			(store_script_param, ":script_param_1", 1),
			(store_script_param, ":script_param_2", 2),
			(assign, ":value", 0),
			(agent_get_team, ":team_script_param_1", ":script_param_1"),
			(agent_get_division, ":division_script_param_1", ":script_param_1"), #Line 7, Group ID error appears to be in here, further tests reveal its script_param_1's value but can't be sure.
			(try_begin),
				(lt, ":division_script_param_1", 9),
				(team_get_movement_order, ":movement_order_team_script_param_1_division_script_param_1", ":team_script_param_1", ":division_script_param_1"),
				(eq, ":movement_order_team_script_param_1_division_script_param_1", 14),
				(assign, ":value", 1),
			(try_end),
			(agent_get_slot, ":script_param_1_is_running_away", ":script_param_1", slot_agent_is_running_away),
			(try_begin),
				(eq, ":script_param_1_is_running_away", 0),
				(try_begin),
					(eq, ":value", 1),
					(agent_clear_scripted_mode, ":script_param_1"),
					(agent_start_running_away, ":script_param_1"),
					(agent_set_slot, ":script_param_1", slot_agent_is_running_away, 1),
				(else_try),
					(ge, ":script_param_2", 45),
					(agent_get_slot, ":script_param_1_courage_score", ":script_param_1", slot_agent_courage_score),
					(store_agent_hit_points, ":agent_hit_points_script_param_1", ":script_param_1"),
					(val_mul, ":agent_hit_points_script_param_1", 4),
					(try_begin),
						(agent_is_ally, ":script_param_1"),
						(val_sub, ":agent_hit_points_script_param_1", 100),
					(try_end),
					(val_mul, ":agent_hit_points_script_param_1", 10),
					(store_sub, ":value_2", 3500, ":agent_hit_points_script_param_1"),
					(lt, ":script_param_1_courage_score", ":value_2"),
					(agent_get_troop_id, ":troop_id_script_param_1", ":script_param_1"),
					(neg|troop_is_hero, ":troop_id_script_param_1"),
					(agent_clear_scripted_mode, ":script_param_1"),
					(agent_start_running_away, ":script_param_1"),
					(agent_set_slot, ":script_param_1", slot_agent_is_running_away, 1),
				(try_end),
			(else_try),
				(neq, ":value", 1),
				(agent_get_slot, ":script_param_1_courage_score", ":script_param_1", slot_agent_courage_score),
				(store_agent_hit_points, ":agent_hit_points_script_param_1", ":script_param_1"),
				(val_mul, ":agent_hit_points_script_param_1", 4),
				(try_begin),
					(agent_is_ally, ":script_param_1"),
					(val_sub, ":agent_hit_points_script_param_1", 100),
				(try_end),
				(val_mul, ":agent_hit_points_script_param_1", 10),
				(store_sub, ":value_3", 3700, ":agent_hit_points_script_param_1"),
				(ge, ":script_param_1_courage_score", ":value_3"),
				(agent_stop_running_away, ":script_param_1"),
				(agent_set_slot, ":script_param_1", slot_agent_is_running_away, 0),
			(try_end)
		]),

Also, here is the Module_Coop_Scripts (You might be able to find the group ID in here, I personally couldn't figure this issue out)
Since module_coop_scripts is too big to post in here, I pastebined it and provided a raw link to check: http://pastebin.com/raw/NhGiVcpX
 
troycall said:
I'm running into a script related error in Co-Op/MP, I'm assuming this is because the group ID is different under module_coop_scripts and module_coop_templates (coop portion of the mod).

Here is the error that appears:

you are counting your lines the wrong way:

1) It starts on 0 (zero), not 1
2) It only considers full commands: (.....), 
3) Empty lines are not counted

So your 7th line is this:
Code:
                (team_get_movement_order, ":movement_order_team_script_param_1_division_script_param_1", ":team_script_param_1", ":division_script_param_1"),
as you can see the OPcode 1785 is that operation:

Code:
team_get_movement_order                = 1785   # (team_get_movement_order, <destination>, <team_no>, <sub_class>),
 
kalarhan said:
troycall said:
I'm running into a script related error in Co-Op/MP, I'm assuming this is because the group ID is different under module_coop_scripts and module_coop_templates (coop portion of the mod).

Here is the error that appears:

you are counting your lines the wrong way:

1) It starts on 0 (zero), not 1
2) It only considers full commands: (.....), 
3) Empty lines are not counted

So your 7th line is this:
Code:
                (team_get_movement_order, ":movement_order_team_script_param_1_division_script_param_1", ":team_script_param_1", ":division_script_param_1"),
as you can see the OPcode 1785 is that operation:

Code:
team_get_movement_order                = 1785   # (team_get_movement_order, <destination>, <team_no>, <sub_class>),

Does Group ID mean <team_no> OR <sub_class>?
 
Khamukkamu said:
When does the script 'game_start' fire?

When "Start New Game" is clicked or after the the opening menus? (Become an adventurer and ride to your destiny...)

Add a line like this on that script (or similar to each of the menus):

Code:
(display_message, "@Script for new game!"),

Compile your code, start a new game, and keep a eye on your rgl_log.txt.

-->On Sublime Text, as a example, it will auto-reload the file to keep it updated with each new entry. Other editors may require you to reload the file manually. Or you can use a terminal command to tail the file. Any of these work fine.

Printing debugging messages is a very important tool to figure out how things work and how to solve bugs.
 
Status
Not open for further replies.
Back
Top Bottom