Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Hello people, I have a question,
So I almost finished modding and wanted to start the game for a test and I get this..:

https://imgur.com/g1CYgYF
When the game tries to load the textures.

Does anyone know how I can fix that?...
 
MadGuarang said:
It surely has to do something with number of parties on the world map and unoptimized triggers.
What's the average savegame size of your mod?

Garedyr - You probably do not remember, but you were the first person that introduced me into a warband coding, and cannibalism kit was my first code I have applied to my mod. You're 1st on my credit list :smile:

1. Average save is around 7-10 MB.   
2. Yes, I have a lot of parties on my map, but same I did in previous stutter-free version. I also reduced amount of parties just to see would that help and I still had that issue.
3. Triggers - I have added some triggers for town's improvement's but they are mostly 7*24 or 30*24.    Is there any way to track how do they affect game performance?  Then again my issue is that 1.00 with more parties on world map worked a lot better, than less parties in 1.20 of mod version.

I am opened for any suggestions, really!

That savegame file size is fine so it eliminates any potential hard to fix problems as a potential cause of map stuttering.
Keep in mind that the more parties and slots for them you have, the more data needs to be stored and processed by the CPU when specific triggers are called. That leads us directly to what Ruthven said:

Ruthven said:
Check if you have any triggers/scripts with nested try_for_parties loops. That is what causes map lag 99.9999% of the time.

You should try to avoid using try_for_parties if possible and replace it with try_for_range instead.
 
Avareee said:
Hello people, I have a question,
So I almost finished modding and wanted to start the game for a test and I get this..:

https://imgur.com/g1CYgYF
When the game tries to load the textures.

Does anyone know how I can fix that?...

One or more of your assets are flagged to use a shader that’s not present in native Warband. Probably an animated flag shader. If they are OSP, you could try using the mb_2a.fxo and mb_2b.fxo compiled shader files from whichever mod provided the asset(s) in question. If not, then you’ll need to search OpenBRF for all meshes using tex_mul_color_alpha_lance_banner and substitute this shader for a suitable native one. In the later case, the lance wouldn’t be animated if it had been in its original mod.
 
Avareee said:
Hello people, I have a question,
So I almost finished modding and wanted to start the game for a test and I get this..:

https://imgur.com/g1CYgYF
When the game tries to load the textures.

Does anyone know how I can fix that?...

You have added something to your brf which uses a shader which you have forgotten to add as well to your ressources.
 
Garedyr said:
MadGuarang said:
It surely has to do something with number of parties on the world map and unoptimized triggers.
What's the average savegame size of your mod?

Garedyr - You probably do not remember, but you were the first person that introduced me into a warband coding, and cannibalism kit was my first code I have applied to my mod. You're 1st on my credit list :smile:

1. Average save is around 7-10 MB.   
2. Yes, I have a lot of parties on my map, but same I did in previous stutter-free version. I also reduced amount of parties just to see would that help and I still had that issue.
3. Triggers - I have added some triggers for town's improvement's but they are mostly 7*24 or 30*24.    Is there any way to track how do they affect game performance?  Then again my issue is that 1.00 with more parties on world map worked a lot better, than less parties in 1.20 of mod version.

I am opened for any suggestions, really!

That savegame file size is fine so it eliminates any potential hard to fix problems as a potential cause of map stuttering.
Keep in mind that the more parties and slots for them you have, the more data needs to be stored and processed by the CPU when specific triggers are called. That leads us directly to what Ruthven said:

Ruthven said:
Check if you have any triggers/scripts with nested try_for_parties loops. That is what causes map lag 99.9999% of the time.

You should try to avoid using try_for_parties if possible and replace it with try_for_range instead.

Garedyr, Ruthven - thanks a lot, at least I have something to work with. I have checked all simple triggers and triggers and also thought about my world map situation. Your suggestions are very probable, because indeed I have lots of bandit parties roaming on map, that is few times larger than vanilla map. I do also have additional mercenaries, patrols and scouts - originally commented out from warband.

My 'suspects' are:
1.    this trigger is 0.1 second and checks all bandit parties / bandit lairs (last part of code):
Code:
  # Attach Lord Parties to the town they are in
  (0.1,
   [
       (try_for_range, ":troop_no", heroes_begin, heroes_end),
         (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
         (troop_get_slot, ":troop_party_no", ":troop_no", slot_troop_leaded_party),
         (ge, ":troop_party_no", 1),
		 (party_is_active, ":troop_party_no"),
		 
         (party_get_attached_to, ":cur_attached_town", ":troop_party_no"),
         (lt, ":cur_attached_town", 1),
         (party_get_cur_town, ":destination", ":troop_party_no"),
         (is_between, ":destination", centers_begin, centers_end),
         (call_script, "script_get_relation_between_parties", ":destination", ":troop_party_no"),
         (try_begin),
           (ge, reg0, 0),
           (party_attach_to_party, ":troop_party_no", ":destination"),
         (else_try),
           (party_set_ai_behavior, ":troop_party_no", ai_bhvr_hold),
         (try_end),
         
         (try_begin),
           (this_or_next|party_slot_eq, ":destination", slot_party_type, spt_town),
           (party_slot_eq, ":destination", slot_party_type, spt_castle),
           (store_faction_of_party, ":troop_faction_no", ":troop_party_no"),
           (store_faction_of_party, ":destination_faction_no", ":destination"),
           (eq, ":troop_faction_no", ":destination_faction_no"),
           (party_get_num_prisoner_stacks, ":num_stacks", ":troop_party_no"),
           (gt, ":num_stacks", 0),
           (assign, "$g_move_heroes", 1),
           (call_script, "script_party_prisoners_add_party_prisoners", ":destination", ":troop_party_no"),#Moving prisoners to the center
           (assign, "$g_move_heroes", 1),
           (call_script, "script_party_remove_all_prisoners", ":troop_party_no"),
         (try_end),
       (try_end),
	   	   
	[color=red](try_for_parties, ":bandit_camp"),   ##!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! try for parties!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/color]
	 	 (gt, ":bandit_camp", "p_spawn_points_end"),
		 #Can't have party is active here, because it will fail for inactive parties
		 (party_get_template_id, ":template", ":bandit_camp"),
		 (ge, ":template", "pt_steppe_bandit_lair"),
		
		 (store_distance_to_party_from_party, ":distance", "p_main_party", ":bandit_camp"),
	     (lt, ":distance", 3), 
	     (party_set_flags, ":bandit_camp", pf_disabled, 0),
	     (party_set_flags, ":bandit_camp", pf_always_visible, 1),	   
	   (try_end),
    ]),

2. this is another 'suspect'. it is checked every 3 (in-game hours) but what I do not understand is that trigger for player loosing its court is messed with  bandits forced going in and out their lairs. Weird? Maybe if I split them into 2 different triggers, set 'bandit' trigger as stand alone, that would help... or its gonna break something I am not aware of?


Code:
 (3, #check to see if player's court has been captured
   [
     (try_begin), #The old court has been lost
       (is_between, "$g_player_court", centers_begin, centers_end),
       (store_faction_of_party, ":court_faction", "$g_player_court"),
       (neq, ":court_faction", "fac_player_supporters_faction"),
       (call_script, "script_add_notification_menu", "mnu_notification_court_lost", 0, 0),
     (else_try),	#At least one new court has been found
       (lt, "$g_player_court", centers_begin),
       #Will by definition not active until a center is taken by the player faction
       #Player minister must have been appointed at some point
       (this_or_next|faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
		(gt, "$g_player_minister", 0),
		
       (assign, ":center_found", 0),
       (try_for_range, ":walled_center", walled_centers_begin, walled_centers_end),
         (eq, ":center_found", 0),
         (store_faction_of_party, ":court_faction", ":walled_center"),
         (eq, ":court_faction", "fac_player_supporters_faction"),
         (assign, ":center_found", ":walled_center"),
       (try_end),
       (ge, ":center_found", 1),
       (call_script, "script_add_notification_menu", "mnu_notification_court_lost", 0, 0),
     (try_end),
  #Also, piggy-backing on this -- having bandits go to lairs and back
    (try_for_parties, ":bandit_party"),           ##!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! try for parties!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       (gt, ":bandit_party", "p_spawn_points_end"),
       (party_get_template_id, ":bandit_party_template", ":bandit_party"),
       (is_between, ":bandit_party_template", "pt_steppe_bandits", "pt_deserters"),
       (party_template_get_slot, ":bandit_lair", ":bandit_party_template", slot_party_template_lair_party),
       (try_begin),#If party is active and bandit is far away, then move to location
         (gt, ":bandit_lair", "p_spawn_points_end"),
         (store_distance_to_party_from_party, ":distance", ":bandit_party", ":bandit_lair"), #this is the cause of the error
         (gt, ":distance", 30),
         #All this needs checking
         (party_set_ai_behavior, ":bandit_party", ai_bhvr_travel_to_point),
         (party_get_position, pos5, ":bandit_lair"),
         (party_set_ai_target_position, ":bandit_party", pos5),
       (else_try), #Otherwise, act freely
         (get_party_ai_behavior, ":behavior", ":bandit_party"),
         (eq, ":behavior", ai_bhvr_travel_to_point),
         (try_begin),
           (gt, ":bandit_lair", "p_spawn_points_end"),
           (store_distance_to_party_from_party, ":distance", ":bandit_party", ":bandit_lair"),
           (lt, ":distance", 3),
           (party_set_ai_behavior, ":bandit_party", ai_bhvr_patrol_party),
           (party_template_get_slot, ":spawnpoint", ":bandit_party_template", slot_party_template_lair_spawnpoint),
           (party_set_ai_object, ":bandit_party", ":spawnpoint"),
           (party_set_ai_patrol_radius, ":bandit_party", 45),
         (else_try),
           (lt, ":bandit_lair", "p_spawn_points_end"),
           (party_set_ai_behavior, ":bandit_party", ai_bhvr_patrol_party),
           (party_template_get_slot, ":spawnpoint", ":bandit_party_template", slot_party_template_lair_spawnpoint),
           (party_set_ai_object, ":bandit_party", ":spawnpoint"),
           (party_set_ai_patrol_radius, ":bandit_party", 45),
         (try_end),
       (try_end),
     (try_end),
     #Piggybacking on trigger:
     (try_begin),
       (troop_get_slot, ":betrothed", "trp_player", slot_troop_betrothed),
       (gt, ":betrothed", 0),
       (neg|check_quest_active, "qst_wed_betrothed"),
       (neg|check_quest_active, "qst_wed_betrothed_female"),
       (str_store_troop_name, s5, ":betrothed"),
       (display_message, "@Betrothal to {s5} expires"),
       (troop_set_slot, "trp_player", slot_troop_betrothed, -1),
       (troop_set_slot, ":betrothed", slot_troop_betrothed, -1),
     (try_end),
     ]),

Anyways, thanks a lot guys, just one more, last question. Is there any way to check/debug which triggers or scripts affect game performance during gameplay? I don't know how to describe it other way, but let say if you run task manager in windows you can see which app affects your pc, right? I am not sure, but I think that I read somewhere on this forum about something similar in Warband, but still I am not sure...

Appreciate your help, a lot!
 
Cozur said:
What part of the code controls companions appearing in taverns? In case you'd rather have them appear in the castle hall instead?

I believe that this is it:

Code:
 ("town_tavern",[
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
          (this_or_next|eq,"$entry_to_town_forbidden",0),
          (eq, "$sneaked_into_town",1),
#          (party_get_slot, ":scene", "$current_town", slot_town_tavern),
#          (scene_slot_eq, ":scene", slot_scene_visited, 1), #check if scene has been visited before to allow entry from menu. Otherwise scene will only be accessible from the town center.
          ]
       ,"Visit the tavern.",
       [
           (try_begin),
             (eq,"$all_doors_locked",1),
             (display_message,"str_door_locked",0xFFFFAAAA),
           (else_try),
             (call_script, "script_cf_enter_center_location_bandit_check"),
           (else_try),
             (assign, "$town_entered", 1),
             (set_jump_mission, "mt_town_default"),
             (mission_tpl_entry_set_override_flags, "mt_town_default", 0, af_override_horse),
             (try_begin),
               (eq, "$sneaked_into_town",1),
               (mission_tpl_entry_set_override_flags, "mt_town_default", 0, af_override_all),
             (try_end),
             (party_get_slot, ":cur_scene", "$current_town", slot_town_tavern),
             (jump_to_scene, ":cur_scene"),
             (scene_set_slot, ":cur_scene", slot_scene_visited, 1),

             (assign, "$talk_context", tc_tavern_talk),
             (call_script, "script_initialize_tavern_variables"),

			 (store_random_in_range, ":randomize_attacker_placement", 0, 4),

             (modify_visitors_at_site, ":cur_scene"),
             (reset_visitors),
             
             (assign, ":cur_entry", 17),

			 #this is just a cheat right now
             #(troop_set_slot, "trp_belligerent_drunk", slot_troop_cur_center, "$g_encountered_party"),
			 (try_begin),
				(eq, "$cheat_mode", 1),
				(troop_get_slot, ":drunk_location", "trp_belligerent_drunk", slot_troop_cur_center),
				(try_begin),
					(eq, "$cheat_mode", 0),
				(else_try),
					(is_between, ":drunk_location", centers_begin, centers_end),
					(str_store_party_name, s4, ":drunk_location"),
					(display_message, "str_belligerent_drunk_in_s4"),
			    (else_try),
					(display_message, "str_belligerent_drunk_not_found"),
				(try_end),
				
				(troop_get_slot, ":promoter_location", "trp_fight_promoter", slot_troop_cur_center),
				(try_begin),
					(eq, "$cheat_mode", 0),
				(else_try),
					(is_between, ":promoter_location", centers_begin, centers_end),
					(str_store_party_name, s4, ":promoter_location"),
					(display_message, "str_roughlooking_character_in_s4"),
			    (else_try),
					(display_message, "str_roughlooking_character_not_found"),
				(try_end),				
			 (try_end),
			 
			 #this determines whether or not a lord who dislikes you will commission an assassin
			 (try_begin),
				(store_current_hours, ":hours"),
				(store_sub, ":hours_since_last_attempt", ":hours", "$g_last_assassination_attempt_time"),
				(gt, ":hours_since_last_attempt", 168),
				(try_for_range, ":lord", active_npcs_begin, active_npcs_end),
					(troop_slot_eq, ":lord", slot_lord_reputation_type, lrep_debauched),
					(troop_get_slot, ":led_party", ":lord", slot_troop_leaded_party),
					(party_is_active, ":led_party"),
					(party_get_attached_to, ":led_party_attached", ":led_party"), 
					(eq, ":led_party_attached", "$g_encountered_party"),
					(call_script, "script_troop_get_relation_with_troop", "trp_player", ":lord"),
					(lt, reg0, -20),
					(assign, "$g_last_assassination_attempt_time", ":hours"),
#					(assign, "$g_last_assassination_attempt_location", "$g_encountered_party"),
#					(assign, "$g_last_assassination_attempt_perpetrator", ":lord"),
					
					(troop_set_slot, "trp_hired_assassin", slot_troop_cur_center, "$g_encountered_party"),					
				(try_end),
			 (try_end),	
						
			 (try_begin),
				 (eq, ":randomize_attacker_placement", 0),
				 (call_script, "script_setup_tavern_attacker", ":cur_entry"),

				 (val_add, ":cur_entry", 1),
			 (try_end),
			 
			 (try_begin),
				(eq, 1, 0),
				(troop_slot_eq, "trp_fight_promoter", slot_troop_cur_center, "$current_town"),
                (set_visitor, ":cur_entry", "trp_fight_promoter"),

                (val_add, ":cur_entry", 1),
			 (try_end),
			 
             (party_get_slot, ":mercenary_troop", "$current_town", slot_center_mercenary_troop_type),
             (party_get_slot, ":mercenary_amount", "$current_town", slot_center_mercenary_troop_amount),
             (try_begin),
			   (gt, ":mercenary_troop", 0),
               (gt, ":mercenary_amount", 0),
               (set_visitor, ":cur_entry", ":mercenary_troop"),
               (val_add, ":cur_entry", 1),
             (try_end),

			 (try_begin),
				 (eq, ":randomize_attacker_placement", 1),
				 (call_script, "script_setup_tavern_attacker", ":cur_entry"),

				 (val_add, ":cur_entry", 1),
			 (try_end),
             
             (try_for_range, ":companion_candidate", companions_begin, companions_end),
               (troop_slot_eq, ":companion_candidate", slot_troop_occupation, 0),
               (troop_slot_eq, ":companion_candidate", slot_troop_cur_center, "$current_town"),
			   (neg|troop_slot_ge, ":companion_candidate", slot_troop_prisoner_of_party, centers_begin),
			   
               (set_visitor, ":cur_entry", ":companion_candidate"),

               (val_add, ":cur_entry", 1),
             (try_end),
			 
			 (try_begin),
				 (eq, ":randomize_attacker_placement", 2),
				 (call_script, "script_setup_tavern_attacker", ":cur_entry"),

				 (val_add, ":cur_entry", 1),
			 (try_end),
			 			 
             (try_begin), #this doubles the incidence of ransom brokers and (below) minstrels
               (party_get_slot, ":ransom_broker", "$current_town", slot_center_ransom_broker),
               (gt, ":ransom_broker", 0),
               
               (assign, reg0, ":ransom_broker"),
               (assign, reg1, "$current_town"),
			   
               (set_visitor, ":cur_entry", ":ransom_broker"),
               (val_add, ":cur_entry", 1),
			 (else_try),
			   (is_between, "$g_talk_troop", ransom_brokers_begin, ransom_brokers_end),
			   (store_add, ":alternative_town", "$current_town", 9),
			   
			   (try_begin),
				(ge, ":alternative_town", towns_end),
				(val_sub, ":alternative_town", 22),
			   (try_end),
			   (try_begin),
				(eq, "$cheat_mode", 1),
			    (str_store_party_name, s3, "$current_town"),
			    (str_store_party_name, s4, ":alternative_town"),
			    (display_message, "@{!}DEBUG - Current town is {s3}, but also checking {s4}"),
			   (try_end),	
			   
               (party_get_slot, ":ransom_broker", ":alternative_town", slot_center_ransom_broker),
               (gt, ":ransom_broker", 0),
			   
               (set_visitor, ":cur_entry", ":ransom_broker"),
               (val_add, ":cur_entry", 1),
             (try_end),
			 
             (try_begin),
               (party_get_slot, ":tavern_traveler", "$current_town", slot_center_tavern_traveler),
               (gt, ":tavern_traveler", 0),
               (set_visitor, ":cur_entry", ":tavern_traveler"),
               (val_add, ":cur_entry", 1),
             (try_end),
			 
              (assign,":bard",0),#dedal
             (try_begin),
               (party_get_slot, ":tavern_minstrel", "$current_town", slot_center_tavern_minstrel),
               (gt, ":tavern_minstrel", 0),
			   (assign,":bard",1),#dedal
               (set_visitor, ":cur_entry", ":tavern_minstrel"),
               (val_add, ":cur_entry", 1),
			 (else_try),  
			   (store_add, ":alternative_town", "$current_town", 9),
			   (try_begin),
				(ge, ":alternative_town", towns_end),
				(val_sub, ":alternative_town", 22),
			   (try_end),
               (party_get_slot, ":tavern_minstrel", ":alternative_town", slot_center_tavern_minstrel),			   
               (gt, ":tavern_minstrel", 0),
			   (assign,":bard",1),#dedal
               (set_visitor, ":cur_entry", ":tavern_minstrel"),
               (val_add, ":cur_entry", 1),
             (try_end),
			 
             (try_begin),
               (party_get_slot, ":tavern_bookseller", "$current_town", slot_center_tavern_bookseller),
               (gt, ":tavern_bookseller", 0),
               (set_visitor, ":cur_entry", ":tavern_bookseller"),
               (val_add, ":cur_entry", 1),
             (try_end),
			 
			 (try_begin),
				 (eq, ":randomize_attacker_placement", 3),
				 (call_script, "script_setup_tavern_attacker", ":cur_entry"),
				 (val_add, ":cur_entry", 1),
			 (try_end),
			 			 
             (try_begin),
               (neg|check_quest_active, "qst_eliminate_bandits_infesting_village"),
               (neg|check_quest_active, "qst_deal_with_bandits_at_lords_village"),
               (assign, ":end_cond", villages_end),
               (try_for_range, ":cur_village", villages_begin, ":end_cond"),
                 (party_slot_eq, ":cur_village", slot_village_bound_center, "$current_town"),
                 (party_slot_ge, ":cur_village", slot_village_infested_by_bandits, 1),
                 (neg|party_slot_eq, ":cur_village", slot_town_lord, "trp_player"),
                 (set_visitor, ":cur_entry", "trp_farmer_from_bandit_village"),
                 (val_add, ":cur_entry", 1),
                 (assign, ":end_cond", 0),
               (try_end),
             (try_end),
             
             (try_begin),
               (eq, "$g_starting_town", "$current_town"),
                              
               (this_or_next|neg|check_quest_finished, "qst_collect_men"),
               (this_or_next|neg|check_quest_finished, "qst_learn_where_merchant_brother_is"),
               (this_or_next|neg|check_quest_finished, "qst_save_relative_of_merchant"),
               (this_or_next|neg|check_quest_finished, "qst_save_town_from_bandits"),
               (eq,  "$g_do_one_more_meeting_with_merchant", 1),
               
			   (assign, ":troop_of_merchant", 0),	
               (try_begin),
                 (eq, "$g_encountered_party_faction", "fac_kingdom_1"),
                 (assign, ":troop_of_merchant", "trp_swadian_merchant"),
               (else_try),  
                 (eq, "$g_encountered_party_faction", "fac_kingdom_2"),
                 (assign, ":troop_of_merchant", "trp_vaegir_merchant"),
               (else_try),                   
                 (eq, "$g_encountered_party_faction", "fac_kingdom_3"),
                 (assign, ":troop_of_merchant", "trp_khergit_merchant"),
               (else_try),  
                 (eq, "$g_encountered_party_faction", "fac_kingdom_4"),
                 (assign, ":troop_of_merchant", "trp_nord_merchant"),
               (else_try),  
                 (eq, "$g_encountered_party_faction", "fac_kingdom_5"),
                 (assign, ":troop_of_merchant", "trp_rhodok_merchant"),
               (else_try),  
                 (eq, "$g_encountered_party_faction", "fac_kingdom_6"),
                 (assign, ":troop_of_merchant", "trp_sarranid_merchant"),
               (try_end),
			   (gt, ":troop_of_merchant", 0),	
               
               (set_visitor, ":cur_entry", ":troop_of_merchant"),
               (val_add, ":cur_entry", 1),
             (try_end),                         
             
           #then at the end of the tavern menu add this lines :

			#dedal begin
			(try_for_range,":entry",32,41),
					(store_random_in_range,":r",0,100),
					(gt,":r",50),#random chance of spawning 
					(try_begin),
						(eq,":bard",0),
						(store_random_in_range,":r",0,15),
						(gt,":r",13),
						(mission_tpl_entry_clear_override_items,"mt_town_default",":entry"),
						(store_random_in_range,":r",0,2),
						(try_begin),
							(eq,":r",0),
							(mission_tpl_entry_add_override_item,"mt_town_default",":entry","itm_dedal_lutnia"),
						(else_try),
							(mission_tpl_entry_add_override_item,"mt_town_default",":entry","itm_dedal_lira"),
						(try_end),
						(store_random_in_range,":dna",0,1000),
						(store_random_in_range,":troop","trp_musican_male","trp_musican_female"),
						(set_visitor,":entry",":troop",":dna"),
						(assign,":bard",1),
					(else_try),
						(store_random_in_range,":town_walker",town_walkers_begin,town_walkers_end),
						(store_random_in_range,":dna",0,1000),
						(mission_tpl_entry_clear_override_items,"mt_town_default",":entry"),
						(store_random_in_range,":r",0,10),
						(try_begin),
							(gt,":r",2),
							(mission_tpl_entry_add_override_item,"mt_town_default",":entry","itm_dedal_kufel"),
						(try_end),
						(set_visitor,":entry",":town_walker",":dna"),
					(try_end),
			(try_end),
			#dedal end
             (change_screen_mission),
           (try_end),
        ],"Door to the tavern."),

exactly that part:
Code:
  (try_for_range, ":companion_candidate", companions_begin, companions_end),
               (troop_slot_eq, ":companion_candidate", slot_troop_occupation, 0),
               (troop_slot_eq, ":companion_candidate", slot_troop_cur_center, "$current_town"),
			   (neg|troop_slot_ge, ":companion_candidate", slot_troop_prisoner_of_party, centers_begin),
			   
               (set_visitor, ":cur_entry", ":companion_candidate"),

               (val_add, ":cur_entry", 1),
 
Is there a way to set a trigger for each time the game is loaded from a save game? Sphere asked the same question but didn't receive a reply. His question was almost 9 years ago, so I thought I'd ask again.

https://forums.taleworlds.com/index.php/topic,128079.msg3087919.html#msg3087919
sphere said:
The short version:

Is there a trigger/simple_trigger/other methods that can run a script/operation block once immediately after a game is loaded.


The longer version:

Attempting to come up with a work-flow that enables auto-upgrading of mod variables/structures/data in existing save-games that will hopefully improve chances of save-game compatibility.  Now thinking of a way to run this upgrading script after every loading of game (new game should be ok since it uses the current mod from the start), so that it can compare some stored global of the last modded version vs the current version, and do white-box upgrading of supported old versions.

Currently, I am thinking of using a trigger with 0 interval and no rearming, but I am not sure whether triggers that won't get rearmed will execute on a game load (as opposed to new game?), as similar trigger (same trigger index but different script content from previous mod versions) may have executed before that particular save-game.

The other alternative is a simple_trigger that executes regularly, but it has the problem of unneeded checking after the first execution.  Also have the problem of not executing before other dependent scripts uses the older mod version's data.

Thanks in advance for any help renderable.
 
Okay, I have rather simple question. There is a code for mounted archers AI improvement by JunYue(君悦). You can see this code under the spoiler.

0.5, 0, 0, [],
  [     
        (set_fixed_point_multiplier, 1000),
        (try_for_agents, ":agent_no"),
            (agent_is_alive, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (agent_is_non_player, ":agent_no"),
            (neg|agent_slot_eq, ":agent_no", 1003, 1),
            (agent_get_horse, ":horse_no", ":agent_no"),
            (assign, ":melee_weapon", -1),
            (try_begin),
                (agent_slot_eq, ":agent_no", slot_agent_is_running_away, 0),
                (gt, ":horse_no", -1),
                (agent_get_team, ":team_no", ":agent_no"),
                (agent_get_division, ":class_no", ":agent_no"),
                (team_get_weapon_usage_order, ":weapon_usage_order", ":team_no", ":class_no"),
                (team_get_movement_order, ":movement_order", ":team_no", ":class_no"),
                (team_get_hold_fire_order, ":hold_fire", ":team_no", ":class_no"),
                (assign, ":thrown_ammo", 0),
                (assign, ":ranged_weapon", -1),
                (try_for_range, ":item", 0, 4),
                  (agent_get_item_slot, ":item_weapon", ":agent_no", ":item"),
                  (gt, ":item_weapon", 0),
                  (item_get_type, ":item_weapon_type", ":item_weapon"),
                  (try_begin),
                    (eq, ":item_weapon_type", itp_type_thrown),
                    (agent_get_ammo_for_slot, ":ammo_for_slot", ":agent_no", ":item"),
                    (val_add, ":thrown_ammo", ":ammo_for_slot"),
                  (else_try),
                    (this_or_next|eq, ":item_weapon_type", itp_type_bow),
                    (this_or_next|eq, ":item_weapon_type", itp_type_pistol),
                    (eq, ":item_weapon_type", itp_type_musket),
                    (assign, ":ranged_weapon", ":item_weapon"),
                  (else_try),
                    (this_or_next|eq, ":item_weapon_type", itp_type_one_handed_wpn),
                    (this_or_next|eq, ":item_weapon_type", itp_type_two_handed_wpn),
                    (eq, ":item_weapon_type", itp_type_polearm),
                    (assign, ":melee_weapon", ":item_weapon"),
                  (try_end),
                (try_end),
                (gt, ":ranged_weapon", -1),         
                (neg|item_has_property, ":ranged_weapon", itp_cant_reload_on_horseback),
                (neg|item_has_property, ":ranged_weapon", itp_cant_use_on_horseback),
                (agent_get_ammo, ":ammo", ":agent_no", 0),
                (val_sub, ":ammo", ":thrown_ammo"),
                (gt, ":ammo", 0),
                (agent_set_slot, ":agent_no", 1003, 2),
                (neg|eq, ":hold_fire", aordr_hold_your_fire),
                (neg|eq, ":weapon_usage_order", wordr_use_melee_weapons),
                (eq, ":movement_order", mordr_charge),
                (agent_get_position, pos50, ":agent_no"),
                (agent_get_speed, pos31, ":agent_no"),
                (position_get_y,":speed_y",pos31),
                (assign, ":distance_closest", 100000),#1000m
                (assign, ":enemies_closest", -1),
                (try_for_agents, ":enemies"),
                    (agent_is_alive, ":enemies"),
                    (agent_is_human, ":enemies"),
                    (agent_get_position, pos36, ":enemies"),
                    (agent_get_team, ":enemies_team", ":enemies"),
                    (teams_are_enemies, ":team_no", ":enemies_team"),
                    (get_distance_between_positions, ":distance", pos50, pos36),
                    (try_begin),
                      (agent_slot_eq, ":enemies", slot_agent_is_running_away, 1),
                      (val_add, ":distance", 10000),
                    (try_end),
                    (try_begin),
                      (agent_get_horse, ":enemies_horse", ":enemies"),
                      (gt, ":enemies_horse", -1),
                      (agent_get_speed, pos32, ":enemies"),
                      (position_get_y,":speed_y_enemies",pos32),
                      (val_sub, ":speed_y_enemies", ":speed_y"),
                      (store_div, ":distance_cavalry", ":speed_y_enemies",5),
                      (val_max, ":distance_cavalry", 0),
                      (val_add, ":distance_cavalry", 500),
                      (val_sub, ":distance", ":distance_cavalry"),
                    (else_try),
                      (agent_get_wielded_item, ":weapon_hold", ":enemies", 1),
                      (neg|gt, ":weapon_hold", 1),
                      (val_sub, ":distance", 500),
                    (try_end),
                    (lt, ":distance", ":distance_closest"),
                    (assign, ":distance_closest", ":distance"),
                    (assign, ":enemies_closest", ":enemies"),
                (try_end),
                (neq, ":enemies_closest", -1),
                (agent_get_position, pos51, ":enemies_closest"),
                (get_distance_between_positions, ":distance_true", pos50, pos51),
                (try_begin),
                  (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                  (gt,":distance_true",200),
                  (agent_set_wielded_item, ":agent_no", ":ranged_weapon"),
                (else_try),
                  (le, ":distance_true", 200),
                  (gt, ":melee_weapon", -1),
                  (agent_set_wielded_item, ":agent_no", ":melee_weapon"),
                (try_end),
                (assign, ":speed_limit", 1000),
                (try_begin),
                    (agent_get_wielded_item, ":weapon_hold", ":agent_no", 0),
                    (gt, ":weapon_hold", 0),
                    (item_get_type, ":weapon_type", ":weapon_hold"),
                    (this_or_next|eq, ":weapon_type", itp_type_bow),
                    (this_or_next|eq, ":weapon_type", itp_type_pistol),
                    (eq, ":weapon_type", itp_type_musket),
                    (agent_get_bone_position, pos53, ":agent_no", 8, 1),
                    (agent_get_bone_position, pos54, ":enemies_closest", 9, 1),
                    (position_has_line_of_sight_to_position, pos53, pos54),
                    (agent_set_look_target_agent, ":agent_no", ":enemies_closest"),
                    (try_begin),
                      (assign, ":shoot_distance", 4000),
                      (agent_get_attack_action, ":attack_action", ":agent_no"),
                      (eq, ":attack_action", 1),
                      (try_begin),
                        (gt, ":distance_closest", 700),
                        (le, ":distance_closest", ":shoot_distance"),
                        (store_div, ":speed_limit", ":speed_y",2000),#
                        (val_max, ":speed_limit", 0),
                      (try_end),
                      (eq, ":weapon_type", itp_type_bow),
                      (try_begin),
                        (le, ":distance_true", ":shoot_distance"),
                        (agent_set_defend_action, ":agent_no", -2, 1),
                        (agent_set_attack_action, ":agent_no", 3, 0),
                      (else_try),
                        (gt, ":distance_true", ":shoot_distance"),
                        (agent_set_attack_action, ":agent_no", -2, 1),
                        (agent_set_defend_action, ":agent_no", 3, 1),
                      (try_end),
                    (else_try),
                      (eq, ":weapon_type", itp_type_bow),
                      (le, ":distance_true", ":shoot_distance"),#
                      (agent_get_combat_state, ":combat_state", ":agent_no"),
                      (neq, ":combat_state", :cool:,
                      (agent_set_attack_action, ":agent_no", 3, 1),
                    (try_end),
                (try_end),
                (agent_set_speed_limit, ":agent_no", ":speed_limit"),
                (try_begin),
                  (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                  (lt, ":distance_closest", 10000),
                  (try_begin),
                    (get_scene_boundaries, pos2, pos3),
                    (position_transform_position_to_local, pos4, pos2,pos50),
                    (position_get_x, ":left", pos4),
                    (position_get_y, ":down", pos4),
                    (position_transform_position_to_local, pos4, pos2,pos3),
                    (position_get_x, ":map_width", pos4),
                    (position_get_y, ":map_height", pos4),
                    (store_sub, ":right", ":map_width", ":left"),
                    (store_sub, ":up", ":map_height", ":down"),
                    (position_transform_position_to_local, pos4, pos50, pos51),
                    (position_get_x, ":enemies_x", pos4),
                    (position_get_y, ":enemies_y", pos4),
                    (assign, ":effect", 0),
                    (try_begin),
                      (neg|gt, ":distance_closest", 1000),
                      (assign, ":effect", -78000),
                    (else_try),
                      (gt, ":distance_closest", 2000),#
                      (store_sub,":effect", ":distance_closest", 0),
                      (val_mul, ":effect", 5),
                      (val_clamp, ":effect", 35000, 90000),
                    (try_end),
                    (assign, ":distance_to_boundary", 30000),
                    (val_min, ":distance_to_boundary", ":left"),
                    (val_min, ":distance_to_boundary", ":up"),
                    (val_min, ":distance_to_boundary", ":right"),
                    (val_min, ":distance_to_boundary", ":down"),
                    (try_begin),
                      (lt, ":distance_to_boundary", 30000),
                      (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                      (store_div, ":map_middle_x", ":map_width", 20),
                      (store_div, ":map_middle_y", ":map_height", 20),
                      (position_copy_origin, pos4, pos2),
                      (position_move_x, pos4, ":map_middle_x", 1),
                      (position_move_y, pos4, ":map_middle_y", 1),
                      (get_distance_between_positions,":distance_middle", pos4, pos50),
                      (position_transform_position_to_local, pos4, pos50, pos4),
                      (position_get_x, ":map_middle_x", pos4),
                      (position_get_y, ":map_middle_y", pos4),
                      (val_mul, ":map_middle_x", 100),
                      (val_mul, ":map_middle_y", 100),
                      (val_mul, ":enemies_x", 100),
                      (val_mul, ":enemies_y", 100),
                      (store_div,":cos_middle",":map_middle_x",":distance_middle"),
                      (store_div,":sin_middle",":map_middle_y",":distance_middle"),
                      (store_div,":cos_enemies",":enemies_x",":distance_true"),
                      (store_div,":sin_enemies",":enemies_y",":distance_true"),
                      (store_acos, ":angle_cos", ":cos_middle"),
                      (store_asin, ":angle_sin", ":sin_middle"),
                      (store_acos, ":angle_cos_enemies", ":cos_enemies"),
                      (store_asin, ":angle_sin_enemies", ":sin_enemies"),
                      (try_begin),
                        (lt, ":angle_sin", 0),
                        (val_mul,":angle_cos", -1),
                        (val_add,":angle_cos", 360000),
                      (try_end),
                      (try_begin),
                        (lt, ":angle_sin_enemies", 0),
                        (val_mul,":angle_cos_enemies", -1),
                        (val_add,":angle_cos_enemies", 360000),
                      (try_end),
                      (store_sub, ":k2", ":angle_cos", ":angle_cos_enemies"),
                      (val_sub, ":k2", 270000),
                      (val_sub, ":k2", ":effect"),
                      (store_add, ":effect", ":k2", ":effect"),
                      (try_begin),
                        (lt, ":angle_cos", ":angle_cos_enemies"),
                        (val_add, ":effect", 360000),
                      (try_end),
                      (val_clamp,":effect",-210000, 15000),
                      (agent_set_attack_action, ":agent_no", -2, 1),
                      (agent_set_defend_action, ":agent_no", 3, 1),
                    (try_end),
                    (store_cos, ":cos", ":effect"),
                    (store_sin, ":sin", ":effect"),
                    (store_mul, ":k_x1", ":cos", ":enemies_y",),
                    (store_mul, ":k_x2", ":sin", ":enemies_x",),
                    (store_mul, ":k_y1", ":sin", ":enemies_y",),
                    (store_mul, ":k_y2", ":cos", ":enemies_x",),
                    (store_add, ":move_x",":k_x1", ":k_x2"),
                    (store_sub, ":move_y",":k_y1", ":k_y2"),
                    (position_move_x, pos50, ":move_x", 0),
                    (position_move_y, pos50, ":move_y", 0),
                  (try_end),
                  (agent_set_scripted_destination, ":agent_no", pos50, 1),
                (else_try),
                  (agent_clear_scripted_mode, ":agent_no"),
                  (agent_force_rethink, ":agent_no"),
                (try_end),
            (else_try),
                (try_begin),
                  (agent_slot_eq, ":agent_no", 1003, 0),
                  (agent_set_slot, ":agent_no", 1003, 1),
                (else_try),
                  (agent_slot_eq, ":agent_no", 1003, 2),
                  (this_or_next|agent_slot_eq, ":agent_no", slot_agent_is_running_away, 1),
                  (this_or_next|lt, ":horse_no", 0),
                  (this_or_next|eq, ":ammo", 0),
                  (this_or_next|eq, ":hold_fire", aordr_hold_your_fire),
                  (this_or_next|eq, ":weapon_usage_order", wordr_use_melee_weapons),
                  (neq, ":movement_order", mordr_charge),
                  (agent_clear_scripted_mode, ":agent_no"),
                  (agent_set_speed_limit, ":agent_no", 100),
                  (agent_force_rethink, ":agent_no"),
                  (agent_set_slot, ":agent_no", 1003, 3),
                  (this_or_next|eq, ":hold_fire", aordr_hold_your_fire),
                  (eq, ":ammo", 0),
                  (gt, ":melee_weapon", -1),
                  (agent_set_wielded_item, ":agent_no", ":melee_weapon"),
                (try_end),
            (try_end),
        (try_end),
  ])

So my question is: how to change the direction of movement of mounted archers? Currently, they are moving to the right (counterclockwise), how can I change the direction to clockwise / leftwards?

Would be thankful for your help, guys.
 
Barabashenko said:
Okay, I have rather simple question.

how to change the direction of movement of mounted archers?

Code:
(agent_set_scripted_destination, ":agent_no", pos50, 1),

you need to review the math behind calculation for pos50 used on this line, as it is how it calculates based on the map, agent position, enemy position, etc the point where to run to. If in doubt check header_operations.py for the operations descriptions, as it also uses trigonometry operations.
 
Where in module_scripts is it defined how many items of a certain class a troop carry?

After observing the AI, troops armed with multiple kinds of polearms always have only one in their loadout, whereas troops armed with a variety of twohande or onehanded weapons frequently spawn with two or even three weapons of same class.

I'm looking to limit it to one  weapon of each class per soldier, in order to avoid frequent weapon switching that occurs often in troops with many weapons in their inventories.

Also, the same question is valid for ammo bags. Is there a AI limit of one ammo bag (quivers, etc) per troop? Or does simply not giving a ranged troop a shield ensures it will receive double ammo?
 
JhonBrazil said:
Where in module_scripts is it defined how many items of a certain class a troop carry?

on modsys we set the flags for guarantee_XXX. The agent loadout is done by the engine, so you can either replace it with a mission trigger OR setup your troop around the engine rules.
 
kalarhan said:
Code:
(agent_set_scripted_destination, ":agent_no", pos50, 1),

you need to review the math behind calculation for pos50 used on this line, as it is how it calculates based on the map, agent position, enemy position, etc the point where to run to. If in doubt check header_operations.py for the operations descriptions, as it also uses trigonometry operations.

Well, I've found the needed part of the code, but I just can't realize which value I should change and to what - I am too bad at math. As I understand, the value for x in the maneuver function should be changed, maybe to opposite value. If anyone can suggest which value I should change - please, reply in this thread.

So, the needed part of this code:
(try_begin),
                  (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                  (lt, ":distance_closest", 10000),
                  (try_begin),
                    (get_scene_boundaries, pos2, pos3),
                    (position_transform_position_to_local, pos4, pos2,pos50),
                    (position_get_x, ":left", pos4),
                    (position_get_y, ":down", pos4),
                    (position_transform_position_to_local, pos4, pos2,pos3),
                    (position_get_x, ":map_width", pos4),
                    (position_get_y, ":map_height", pos4),
                    (store_sub, ":right", ":map_width", ":left"),
                    (store_sub, ":up", ":map_height", ":down"),
                    (position_transform_position_to_local, pos4, pos50, pos51),
                    (position_get_x, ":enemies_x", pos4),
                    (position_get_y, ":enemies_y", pos4),
                    (assign, ":effect", 0),
                    (try_begin),
                      (neg|gt, ":distance_closest", 1000),
                      (assign, ":effect", -78000),
                    (else_try),
                      (gt, ":distance_closest", 2000),#
                      (store_sub,":effect", ":distance_closest", 0),
                      (val_mul, ":effect", 5),
                      (val_clamp, ":effect", 35000, 90000),
                    (try_end),
                    (assign, ":distance_to_boundary", 30000),
                    (val_min, ":distance_to_boundary", ":left"),
                    (val_min, ":distance_to_boundary", ":up"),
                    (val_min, ":distance_to_boundary", ":right"),
                    (val_min, ":distance_to_boundary", ":down"),
                    (try_begin),
                      (lt, ":distance_to_boundary", 30000),
                      (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                      (store_div, ":map_middle_x", ":map_width", 20),
                      (store_div, ":map_middle_y", ":map_height", 20),
                      (position_copy_origin, pos4, pos2),
                      (position_move_x, pos4, ":map_middle_x", 1),
                      (position_move_y, pos4, ":map_middle_y", 1),
                      (get_distance_between_positions,":distance_middle", pos4, pos50),
                      (position_transform_position_to_local, pos4, pos50, pos4),
                      (position_get_x, ":map_middle_x", pos4),
                      (position_get_y, ":map_middle_y", pos4),
                      (val_mul, ":map_middle_x", 100),
                      (val_mul, ":map_middle_y", 100),
                      (val_mul, ":enemies_x", 100),
                      (val_mul, ":enemies_y", 100),
                      (store_div,":cos_middle",":map_middle_x",":distance_middle"),
                      (store_div,":sin_middle",":map_middle_y",":distance_middle"),
                      (store_div,":cos_enemies",":enemies_x",":distance_true"),
                      (store_div,":sin_enemies",":enemies_y",":distance_true"),
                      (store_acos, ":angle_cos", ":cos_middle"),
                      (store_asin, ":angle_sin", ":sin_middle"),
                      (store_acos, ":angle_cos_enemies", ":cos_enemies"),
                      (store_asin, ":angle_sin_enemies", ":sin_enemies"),
                      (try_begin),
                        (lt, ":angle_sin", 0),
                        (val_mul,":angle_cos", -1),
                        (val_add,":angle_cos", 360000),
                      (try_end),
                      (try_begin),
                        (lt, ":angle_sin_enemies", 0),
                        (val_mul,":angle_cos_enemies", -1),
                        (val_add,":angle_cos_enemies", 360000),
                      (try_end),
                      (store_sub, ":k2", ":angle_cos", ":angle_cos_enemies"),
                      (val_sub, ":k2", 270000),
                      (val_sub, ":k2", ":effect"),
                      (store_add, ":effect", ":k2", ":effect"),
                      (try_begin),
                        (lt, ":angle_cos", ":angle_cos_enemies"),
                        (val_add, ":effect", 360000),
                      (try_end),
                      (val_clamp,":effect",-210000, 15000),
                      (agent_set_attack_action, ":agent_no", -2, 1),
                      (agent_set_defend_action, ":agent_no", 3, 1),
                    (try_end),
                    (store_cos, ":cos", ":effect"),
                    (store_sin, ":sin", ":effect"),
                    (store_mul, ":k_x1", ":cos", ":enemies_y",),
                    (store_mul, ":k_x2", ":sin", ":enemies_x",),
                    (store_mul, ":k_y1", ":sin", ":enemies_y",),
                    (store_mul, ":k_y2", ":cos", ":enemies_x",),
                    (store_add, ":move_x",":k_x1", ":k_x2"),
                    (store_sub, ":move_y",":k_y1", ":k_y2"),
                    (position_move_x, pos50, ":move_x", 0),
                    (position_move_y, pos50, ":move_y", 0),
                  (try_end),
                  (agent_set_scripted_destination, ":agent_no", pos50, 1),
 
I am hoping someone can help me with the following problem.
I have been trying to make my own module which has been going ok up until now.
I have tried to add a sixth tier to the troop tree, just started off with one troop to see how it works but i have this error.
If someone could help me with this i would be greatful.

Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Traceback (most recent call last):
  File "process_troops.py", line 107, in <module>
    save_troops()
  File "process_troops.py", line 34, in save_troops
    file.write("\ntrp_%s %s %s %s %d %d %d %d %d %d\n  "%(convert_to_identifier(troop[0]),replace_spaces(troop[1]),replace_spaces(troop[2]), replace_spaces(str(troop[13])), troop[3],troop[4],troop[5], troop[6], troop[14], troop[15]))
  File "H:\mb_warband_module_system_1171\Module_system 1.171\process_common.py", line 30, in replace_spaces
    return string.replace(string.replace(s0,"\t","_")," ","_")
  File "C:\Python27\lib\string.py", line 521, in replace
    return s.replace(old, new, maxreplace)
AttributeError: 'int' object has no attribute 'replace'
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .
 
markfamily said:
I am hoping someone can help me with the following problem.
I have been trying to make my own module which has been going ok up until now.
I have tried to add a sixth tier to the troop tree, just started off with one troop to see how it works but i have this error.
If someone could help me with this i would be greatful.

Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Traceback (most recent call last):
  File "process_troops.py", line 107, in <module>
    save_troops()
  File "process_troops.py", line 34, in save_troops
    file.write("\ntrp_%s %s %s %s %d %d %d %d %d %d\n  "%(convert_to_identifier(troop[0]),replace_spaces(troop[1]),replace_spaces(troop[2]), replace_spaces(str(troop[13])), troop[3],troop[4],troop[5], troop[6], troop[14], troop[15]))
  File "H:\mb_warband_module_system_1171\Module_system 1.171\process_common.py", line 30, in replace_spaces
    return string.replace(string.replace(s0,"\t","_")," ","_")
  File "C:\Python27\lib\string.py", line 521, in replace
    return s.replace(old, new, maxreplace)
AttributeError: 'int' object has no attribute 'replace'
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .
Give us the edited code snippet too, so we can have a look at it :wink:
 
Thank you for the reply
I basically changed anything pointing to tier 5 in the script.py module and i copied the knight troop info for the noble just as a test run before i entered my full edits.
These are the troop.py edits

["swadian_noble","Swadian_Noble","Swadian_Nobles",tf_mounted|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_gloves|tf_guarantee_helmet|tf_guarantee_horse|tf_guarantee_shield,0,0,fac_kingdom_1,
  [itm_heavy_lance,itm_sword_two_handed_b,itm_sword_medieval_d_long,itm_morningstar,itm_morningstar,itm_sword_medieval_d_long,itm_tab_shield_heater_cav_b,
    itm_coat_of_plates_red,itm_cuir_bouilli,itm_plate_boots,itm_guard_helmet,itm_great_helmet,itm_bascinet,itm_charger,itm_warhorse,itm_gauntlets,itm_mail_mittens],
  def_attrib|level(2:cool:,wp_one_handed (150) | wp_two_handed (130) | wp_polearm (130) | wp_archery (75) | wp_crossbow (75) | wp_throwing (75),knows_common|knows_riding_5|knows_shield_5|knows_ironflesh_5|knows_power_strike_5,swadian_face_middle_1, swadian_face_older_2],

upgrade(troops,"swadian_knight","swadian_noble")

This is the constants.py edit
slot_faction_tier_1_troop        = 41
slot_faction_tier_2_troop        = 42
slot_faction_tier_3_troop        = 43
slot_faction_tier_4_troop        = 44
slot_faction_tier_5_troop        = 45
slot_faction_tier_6_troop        = 46

These are the scipt edits
    (faction_set_slot, "fac_culture_1",  slot_faction_tier_1_troop, "trp_swadian_recruit"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_2_troop, "trp_swadian_militia"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_3_troop, "trp_swadian_footman"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_4_troop, "trp_swadian_infantry"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_5_troop, "trp_swadian_knight"),
      (faction_set_slot, "fac_culture_1",  slot_faction_tier_6_troop, "trp_swadian_noble"),

        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_1_troop),
        (faction_set_slot, ":faction_no",  slot_faction_tier_1_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_2_troop),
        (faction_set_slot, ":faction_no",  slot_faction_tier_2_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_3_troop),
        (faction_set_slot, ":faction_no",  slot_faction_tier_3_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_4_troop),
        (faction_set_slot, ":faction_no",  slot_faction_tier_4_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_5_troop),
        (faction_set_slot, ":faction_no",  slot_faction_tier_5_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_6_troop),
        (faction_set_slot, ":faction_no",  slot_faction_tier_6_troop, ":troop"),

(try_begin),
            (eq, "$players_kingdom", ":giver_faction_no"),
            (call_script, "script_cf_faction_get_random_enemy_faction", ":giver_faction_no"),#Can fail
            (assign, ":cur_target_faction", reg0),
            (store_add, ":max_tier_no", slot_faction_tier_6_troop, 1),
            (store_random_in_range, ":random_tier_no", slot_faction_tier_2_troop, ":max_tier_no"),
            (faction_get_slot, ":cur_target_troop", ":cur_target_faction", ":random_tier_no"),
            (gt, ":cur_target_troop", 0),
            (store_random_in_range, ":quest_target_amount", 3, 7),
            (assign, ":quest_target_troop", ":cur_target_troop"),
            (assign, ":quest_target_faction", ":cur_target_faction"),
            (assign, ":quest_importance", 1),
            (store_character_level, ":quest_gold_reward", ":cur_target_troop"),
            (val_add, ":quest_gold_reward", 5),
            (val_mul, ":quest_gold_reward", ":quest_gold_reward"),
            (val_div, ":quest_gold_reward", 5),
            (val_mul, ":quest_gold_reward", ":quest_target_amount"),
            (assign, ":quest_xp_reward", ":quest_gold_reward"),
            (assign, ":result", ":quest_no"),
            (assign, ":quest_expiration_days", 90),
            (assign, ":quest_dont_give_again_period", 20),
          (try_end),

(try_begin), #if troop not present, search for another type which is
(store_troop_count_companions, ":number", ":troop_type", "$g_encountered_party"),
(eq, ":number", 0),
(assign, ":troop_type", 0),
(try_for_range, ":new_tier", slot_faction_tier_1_troop, slot_faction_tier_6_troop),
(faction_get_slot, ":troop_type", "$g_encountered_party_faction", ":new_tier"),
(faction_get_slot, ":new_troop_type", "$g_encountered_party_faction", ":new_tier"),
(store_troop_count_companions, ":number", ":new_troop_type", "$g_encountered_party"),
(gt, ":number", 0),
(assign, ":troop_type", ":new_troop_type"),
(try_end),
(try_end),

That's everything I have changed for this edit.
 
markfamily said:
  File "process_troops.py", line 107, in <module>
    save_troops()
  File "process_troops.py", line 34, in save_troops
    file.write("\ntrp_%s %s %s %s %d %d %d %d %d %d\n  "%(convert_to_identifier(troop[0]),replace_spaces(troop[1]),replace_spaces(troop[2]), replace_spaces(str(troop[13])), troop[3],troop[4],troop[5], troop[6], troop[14], troop[15]))
  File "H:\mb_warband_module_system_1171\Module_system 1.171\process_common.py", line 30, in replace_spaces
    return string.replace(string.replace(s0,"\t","_")," ","_")
  File "C:\Python27\lib\string.py", line 521, in replace
    return s.replace(old, new, maxreplace)
AttributeError: 'int' object has no attribute 'replace'

one of your troops has broken syntax as the message above tells us
 
Like Kalarhan wrote, you are missing one comma most probably at some place. Check carefully line for every addon you have made. I think (not sure, have no other code at hand currently) that you might have missed it after declaring the troop tree, so it should be
Code:
upgrade(troops,"swadian_knight","swadian_noble"),
but compare it with the other troop trees before, I might be wrong.
 
Thank you both it was a silly mistake I missed a comma and it took me half an hour staring at the same line before I noticed it.
 
Thank you for previous help and now i have another question.
I have finished doing my troop trees and know the part i have not been looking forward to giving them all new items, I downloaded a osp armor pack and put all the entries in module items also the resource and textures then complied without issue, then went into game to look at the new items through the cheatmenu through some were in the first town I went to and the items are there but you cannot see them also when you put them on example the leg armor your legs disappear.
SO my question is what have i done wrong.
The pack i installed was rus armor pack
 
Status
Not open for further replies.
Back
Top Bottom